|
@@ -1,9 +1,11 @@
|
|
|
package com.xxl.job.executor.service.jobhandler;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.extra.spring.SpringUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.TypeReference;
|
|
|
import com.jeeplus.domain.JyAudit;
|
|
|
+import com.jeeplus.domain.JyUserSeal;
|
|
|
import com.jeeplus.domain.MyNoticeList;
|
|
|
import com.jeeplus.domain.ProgramProjectListInfo;
|
|
|
import com.jeeplus.flowable.feign.IAssessApi;
|
|
@@ -11,10 +13,10 @@ import com.jeeplus.flowable.feign.IFlowableApi;
|
|
|
import com.jeeplus.sys.feign.IUserApi;
|
|
|
import com.jeeplus.sys.service.dto.UserDTO;
|
|
|
import com.xxl.job.core.context.XxlJobHelper;
|
|
|
-import com.xxl.job.core.handler.IJobHandler;
|
|
|
import com.xxl.job.core.handler.annotation.XxlJob;
|
|
|
import com.xxl.job.executor.feign.AssessFeignApi;
|
|
|
import com.xxl.job.executor.feign.JyProjectAuditFeignApi;
|
|
|
+import com.xxl.job.executor.feign.JyProjectUserSealFeignApi;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -172,98 +174,208 @@ public class SampleXxlJob {
|
|
|
System.out.println("进来了---");
|
|
|
String json = SpringUtil.getBean(JyProjectAuditFeignApi.class).selectAudit();
|
|
|
List<JyAudit> projectList = JSON.parseObject(json, new TypeReference<List<JyAudit>>() {});
|
|
|
- for (JyAudit jyProjectAudit : projectList) {
|
|
|
- //对逾期状态及审核状态进行修改
|
|
|
- SpringUtil.getBean(JyProjectAuditFeignApi.class).updateStatus(jyProjectAudit.getId());
|
|
|
- //对数据进行发送通知
|
|
|
- String taskName = null;
|
|
|
- String titleStr = null;
|
|
|
- //如果当前时间小于项目通过时间
|
|
|
- if(jyProjectAudit.getProjectAgreeTime().after(new Date())){
|
|
|
- taskName = "嘉溢-项目一级校审";
|
|
|
- titleStr = "项目【"+ jyProjectAudit.getProjectName()+"】即将逾期,";
|
|
|
- }
|
|
|
+ if (null != projectList){
|
|
|
+ for (JyAudit jyProjectAudit : projectList) {
|
|
|
+ //对逾期状态及审核状态进行修改
|
|
|
+ SpringUtil.getBean(JyProjectAuditFeignApi.class).updateStatus(jyProjectAudit.getId());
|
|
|
+ //对数据进行发送通知
|
|
|
+ String taskName = null;
|
|
|
+ String titleStr = null;
|
|
|
+ //如果当前时间小于项目通过时间
|
|
|
+ if(jyProjectAudit.getProjectAgreeTime().after(new Date())){
|
|
|
+ taskName = "嘉溢-项目一级校审";
|
|
|
+ titleStr = "项目【"+ jyProjectAudit.getProjectName()+"】即将逾期,";
|
|
|
+ }
|
|
|
|
|
|
- //获取当前时间
|
|
|
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
- Date currentDate = new Date();
|
|
|
- //将当前时间转化为字符串
|
|
|
- String format = simpleDateFormat.format(currentDate);
|
|
|
- //创建calendar对象
|
|
|
- Calendar instance = Calendar.getInstance();
|
|
|
- //将日期设置为项目通过时间
|
|
|
- instance.setTime(jyProjectAudit.getProjectAgreeTime());
|
|
|
- //往后推一个月
|
|
|
- instance.add(Calendar.MONTH,1);
|
|
|
- //获取推送后的日期
|
|
|
- Date newDate = instance.getTime();
|
|
|
- int interval1 = Integer.parseInt(this.getInterval(currentDate, newDate));
|
|
|
- //计算天数之差
|
|
|
- if(interval1 <= 5 && interval1 >=0){
|
|
|
- titleStr = titleStr + "剩余:" + interval1 + "天。请尽快发起!";
|
|
|
- }
|
|
|
+ //获取当前时间
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ Date currentDate = new Date();
|
|
|
+ //将当前时间转化为字符串
|
|
|
+ String format = simpleDateFormat.format(currentDate);
|
|
|
+ //创建calendar对象
|
|
|
+ Calendar instance = Calendar.getInstance();
|
|
|
+ //将日期设置为项目通过时间
|
|
|
+ instance.setTime(jyProjectAudit.getProjectAgreeTime());
|
|
|
+ //往后推一个月
|
|
|
+ instance.add(Calendar.MONTH,1);
|
|
|
+ //获取推送后的日期
|
|
|
+ Date newDate = instance.getTime();
|
|
|
+ int interval1 = Integer.parseInt(this.getInterval(currentDate, newDate));
|
|
|
+ //计算天数之差
|
|
|
+ if(interval1 <= 5 && interval1 >=0){
|
|
|
+ titleStr = titleStr + "剩余:" + interval1 + "天。请尽快发起!";
|
|
|
+ }
|
|
|
|
|
|
- Set<String> noticeUserSet = new HashSet<String>();
|
|
|
- if(StringUtils.isNotBlank(jyProjectAudit.getCreateById())){
|
|
|
+ Set<String> noticeUserSet = new HashSet<String>();
|
|
|
+ if(StringUtils.isNotBlank(jyProjectAudit.getCreateById())){
|
|
|
|
|
|
- String byIdForXXL = SpringUtil.getBean(IUserApi.class).getByIdForXXL(jyProjectAudit.getCreateById());
|
|
|
- UserDTO createUser = JSON.parseObject(byIdForXXL, new TypeReference<UserDTO>() {});
|
|
|
- if(null != createUser && StringUtils.isNotBlank(createUser.getId())){
|
|
|
- noticeUserSet.add(createUser.getId());
|
|
|
+ String byIdForXXL = SpringUtil.getBean(IUserApi.class).getByIdForXXL(jyProjectAudit.getCreateById());
|
|
|
+ UserDTO createUser = JSON.parseObject(byIdForXXL, new TypeReference<UserDTO>() {});
|
|
|
+ if(null != createUser && StringUtils.isNotBlank(createUser.getId())){
|
|
|
+ noticeUserSet.add(createUser.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<String> noticeUserList = new ArrayList<String>(noticeUserSet);
|
|
|
+ if(noticeUserList.size()>0){
|
|
|
+ MyNoticeList myNotice = new MyNoticeList();
|
|
|
+ myNotice.setCreateById("1");
|
|
|
+ myNotice.setCreateTime(new Date());
|
|
|
+ myNotice.setUpdateById("1");
|
|
|
+ myNotice.setUpdateTime(new Date());
|
|
|
+ myNotice.setDelFlag(0);
|
|
|
+ //根据procInsId获取taskId
|
|
|
+ String currentTask = SpringUtil.getBean(IFlowableApi.class).getTaskIdByprocInstId(jyProjectAudit.getProjectProId());
|
|
|
+ myNotice.setTaskId(currentTask);
|
|
|
+ myNotice.setDefId(jyProjectAudit.getProjectDeId());
|
|
|
+ myNotice.setTitle(titleStr);
|
|
|
+ myNotice.setTaskName(taskName);
|
|
|
+ myNotice.setLink("结束");
|
|
|
+ myNotice.setType("0");
|
|
|
+ myNotice.setCreateUser("管理员");
|
|
|
+ myNotice.setCreateTime(new Date());
|
|
|
+
|
|
|
+ for (String noticeUserId : noticeUserList) {
|
|
|
+ myNotice.setNoticeId(noticeUserId);
|
|
|
+ String byIdForXXL = SpringUtil.getBean(IUserApi.class).getByIdForXXL(jyProjectAudit.getCreateById());
|
|
|
+ UserDTO createUser = JSON.parseObject(byIdForXXL, new TypeReference<UserDTO>() {});
|
|
|
+ myNotice.setNoticeName(createUser.getName());
|
|
|
+ //根据taskName和通知人 查询重复数量
|
|
|
+ String myNoticeInfo = JSON.toJSONString(myNotice);
|
|
|
+ Map<String,String> map = new HashMap();
|
|
|
+ map.put("myNoticeInfo", myNoticeInfo);
|
|
|
+ String jsonInfo = SpringUtil.getBean(IFlowableApi.class).getRepetitionCountBymyNoticeTitle(map);
|
|
|
+ MyNoticeList repetitionCountBymyNotice = JSON.parseObject(jsonInfo, new TypeReference<MyNoticeList>() {});
|
|
|
+
|
|
|
+ if(null == repetitionCountBymyNotice){
|
|
|
+ // 生成id
|
|
|
+ String id = UUID.randomUUID().toString().replace("-", "");
|
|
|
+ myNotice.setId(id);
|
|
|
+ myNotice.setRepetitionCount(0);
|
|
|
+
|
|
|
+ myNoticeInfo = JSON.toJSONString(myNotice);
|
|
|
+ map.put("myNoticeInfo", myNoticeInfo);
|
|
|
+ SpringUtil.getBean ( IFlowableApi.class ).insertMyNotice(map);
|
|
|
+ }else{
|
|
|
+ myNotice.setId(repetitionCountBymyNotice.getId());
|
|
|
+ myNotice.setRepetitionCount(repetitionCountBymyNotice.getRepetitionCount()+1);
|
|
|
+
|
|
|
+ myNoticeInfo = JSON.toJSONString(myNotice);
|
|
|
+ map.put("myNoticeInfo", myNoticeInfo);
|
|
|
+ SpringUtil.getBean ( IFlowableApi.class ).updateMyNotice(map);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- List<String> noticeUserList = new ArrayList<String>(noticeUserSet);
|
|
|
- if(noticeUserList.size()>0){
|
|
|
- MyNoticeList myNotice = new MyNoticeList();
|
|
|
- myNotice.setCreateById("1");
|
|
|
- myNotice.setCreateTime(new Date());
|
|
|
- myNotice.setUpdateById("1");
|
|
|
- myNotice.setUpdateTime(new Date());
|
|
|
- myNotice.setDelFlag(0);
|
|
|
- //根据procInsId获取taskId
|
|
|
- String currentTask = SpringUtil.getBean(IFlowableApi.class).getTaskIdByprocInstId(jyProjectAudit.getProcInsId());
|
|
|
- myNotice.setTaskId(currentTask);
|
|
|
- myNotice.setDefId(jyProjectAudit.getProcessDefinitionId());
|
|
|
- myNotice.setTitle(titleStr);
|
|
|
- myNotice.setTaskName(taskName);
|
|
|
- myNotice.setLink("结束");
|
|
|
- myNotice.setType("0");
|
|
|
- myNotice.setCreateUser("管理员");
|
|
|
- myNotice.setCreateTime(new Date());
|
|
|
+ }
|
|
|
|
|
|
- for (String noticeUserId : noticeUserList) {
|
|
|
- myNotice.setNoticeId(noticeUserId);
|
|
|
- String byIdForXXL = SpringUtil.getBean(IUserApi.class).getByIdForXXL(jyProjectAudit.getCreateById());
|
|
|
- UserDTO createUser = JSON.parseObject(byIdForXXL, new TypeReference<UserDTO>() {});
|
|
|
- myNotice.setNoticeName(createUser.getName());
|
|
|
- //根据taskName和通知人 查询重复数量
|
|
|
- String myNoticeInfo = JSON.toJSONString(myNotice);
|
|
|
- Map<String,String> map = new HashMap();
|
|
|
- map.put("myNoticeInfo", myNoticeInfo);
|
|
|
- String jsonInfo = SpringUtil.getBean(IFlowableApi.class).getRepetitionCountBymyNoticeTitle(map);
|
|
|
- MyNoticeList repetitionCountBymyNotice = JSON.parseObject(jsonInfo, new TypeReference<MyNoticeList>() {});
|
|
|
|
|
|
- if(null == repetitionCountBymyNotice){
|
|
|
- // 生成id
|
|
|
- String id = UUID.randomUUID().toString().replace("-", "");
|
|
|
- myNotice.setId(id);
|
|
|
- myNotice.setRepetitionCount(0);
|
|
|
+ }
|
|
|
|
|
|
- myNoticeInfo = JSON.toJSONString(myNotice);
|
|
|
- map.put("myNoticeInfo", myNoticeInfo);
|
|
|
- SpringUtil.getBean ( IFlowableApi.class ).insertMyNotice(map);
|
|
|
- }else{
|
|
|
- myNotice.setId(repetitionCountBymyNotice.getId());
|
|
|
- myNotice.setRepetitionCount(repetitionCountBymyNotice.getRepetitionCount()+1);
|
|
|
|
|
|
- myNoticeInfo = JSON.toJSONString(myNotice);
|
|
|
+ /**
|
|
|
+ * 嘉溢项目外审发送通知
|
|
|
+ * @param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @XxlJob("projectOutInstanceTask")
|
|
|
+ public void projectOutInstanceTask(){
|
|
|
+ System.out.println("进来了---");
|
|
|
+ String json = SpringUtil.getBean(JyProjectUserSealFeignApi.class).findSeal();
|
|
|
+ List<JyUserSeal> projectList = JSON.parseObject(json, new TypeReference<List<JyUserSeal>>() {});
|
|
|
+ if (CollectionUtil.isNotEmpty(projectList)){
|
|
|
+ for (JyUserSeal jyUserSeal : projectList) {
|
|
|
+ //对数据进行发送通知
|
|
|
+ String taskName = null;
|
|
|
+ String titleStr = null;
|
|
|
+ //如果当前时间小于用印修改时间
|
|
|
+ if(jyUserSeal.getUpdateTime().after(new Date())){
|
|
|
+ taskName = "嘉溢-项目用印申请";
|
|
|
+ titleStr = "项目【"+ jyUserSeal.getProjectName().substring(0,jyUserSeal.getProjectName().lastIndexOf(","))+"】即将逾期,";
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取当前时间
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ Date currentDate = new Date();
|
|
|
+ //将当前时间转化为字符串
|
|
|
+ String format = simpleDateFormat.format(currentDate);
|
|
|
+ //创建calendar对象
|
|
|
+ Calendar instance = Calendar.getInstance();
|
|
|
+ //将日期设置为用印修改时间
|
|
|
+ instance.setTime(jyUserSeal.getUpdateTime());
|
|
|
+ //往后推两周
|
|
|
+ instance.add(Calendar.DATE,14);
|
|
|
+ //获取推送后的日期
|
|
|
+ Date newDate = instance.getTime();
|
|
|
+ int interval1 = Integer.parseInt(this.getInterval(currentDate, newDate));
|
|
|
+ //计算天数之差
|
|
|
+ if(interval1 <= 3 && interval1 >=0){
|
|
|
+ titleStr = titleStr + "剩余:" + interval1 + "天。请尽快发起!";
|
|
|
+ }
|
|
|
+
|
|
|
+ Set<String> noticeUserSet = new HashSet<String>();
|
|
|
+ if(StringUtils.isNotBlank(jyUserSeal.getCreateById())){
|
|
|
+
|
|
|
+ String byIdForXXL = SpringUtil.getBean(IUserApi.class).getByIdForXXL(jyUserSeal.getCreateById());
|
|
|
+ UserDTO createUser = JSON.parseObject(byIdForXXL, new TypeReference<UserDTO>() {});
|
|
|
+ if(null != createUser && StringUtils.isNotBlank(createUser.getId())){
|
|
|
+ noticeUserSet.add(createUser.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<String> noticeUserList = new ArrayList<String>(noticeUserSet);
|
|
|
+ if(noticeUserList.size()>0){
|
|
|
+ MyNoticeList myNotice = new MyNoticeList();
|
|
|
+ myNotice.setCreateById("1");
|
|
|
+ myNotice.setCreateTime(new Date());
|
|
|
+ myNotice.setUpdateById("1");
|
|
|
+ myNotice.setUpdateTime(new Date());
|
|
|
+ myNotice.setDelFlag(0);
|
|
|
+ //根据procInsId获取taskId
|
|
|
+ String currentTask = SpringUtil.getBean(IFlowableApi.class).getTaskIdByprocInstId(jyUserSeal.getProcInsId());
|
|
|
+ myNotice.setTaskId(currentTask);
|
|
|
+ myNotice.setDefId(jyUserSeal.getProcessDefinitionId());
|
|
|
+ myNotice.setTitle(titleStr);
|
|
|
+ myNotice.setTaskName(taskName);
|
|
|
+ myNotice.setLink("结束");
|
|
|
+ myNotice.setType("0");
|
|
|
+ myNotice.setCreateUser("管理员");
|
|
|
+ myNotice.setCreateTime(new Date());
|
|
|
+
|
|
|
+ for (String noticeUserId : noticeUserList) {
|
|
|
+ myNotice.setNoticeId(noticeUserId);
|
|
|
+ String byIdForXXL = SpringUtil.getBean(IUserApi.class).getByIdForXXL(jyUserSeal.getCreateById());
|
|
|
+ UserDTO createUser = JSON.parseObject(byIdForXXL, new TypeReference<UserDTO>() {});
|
|
|
+ myNotice.setNoticeName(createUser.getName());
|
|
|
+ //根据taskName和通知人 查询重复数量
|
|
|
+ String myNoticeInfo = JSON.toJSONString(myNotice);
|
|
|
+ Map<String,String> map = new HashMap();
|
|
|
map.put("myNoticeInfo", myNoticeInfo);
|
|
|
- SpringUtil.getBean ( IFlowableApi.class ).updateMyNotice(map);
|
|
|
+ String jsonInfo = SpringUtil.getBean(IFlowableApi.class).getRepetitionCountBymyNoticeTitle(map);
|
|
|
+ MyNoticeList repetitionCountBymyNotice = JSON.parseObject(jsonInfo, new TypeReference<MyNoticeList>() {});
|
|
|
+
|
|
|
+ if(null == repetitionCountBymyNotice){
|
|
|
+ // 生成id
|
|
|
+ String id = UUID.randomUUID().toString().replace("-", "");
|
|
|
+ myNotice.setId(id);
|
|
|
+ myNotice.setRepetitionCount(0);
|
|
|
+
|
|
|
+ myNoticeInfo = JSON.toJSONString(myNotice);
|
|
|
+ map.put("myNoticeInfo", myNoticeInfo);
|
|
|
+ SpringUtil.getBean ( IFlowableApi.class ).insertMyNotice(map);
|
|
|
+ }else{
|
|
|
+ myNotice.setId(repetitionCountBymyNotice.getId());
|
|
|
+ myNotice.setRepetitionCount(repetitionCountBymyNotice.getRepetitionCount()+1);
|
|
|
+
|
|
|
+ myNoticeInfo = JSON.toJSONString(myNotice);
|
|
|
+ map.put("myNoticeInfo", myNoticeInfo);
|
|
|
+ SpringUtil.getBean ( IFlowableApi.class ).updateMyNotice(map);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|