|
@@ -1,6 +1,7 @@
|
|
package com.xxl.job.executor.service.jobhandler;
|
|
package com.xxl.job.executor.service.jobhandler;
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.extra.spring.SpringUtil;
|
|
import cn.hutool.extra.spring.SpringUtil;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.TypeReference;
|
|
import com.alibaba.fastjson.TypeReference;
|
|
@@ -15,6 +16,7 @@ import com.jeeplus.sys.service.dto.UserDTO;
|
|
import com.xxl.job.core.context.XxlJobHelper;
|
|
import com.xxl.job.core.context.XxlJobHelper;
|
|
import com.xxl.job.core.handler.annotation.XxlJob;
|
|
import com.xxl.job.core.handler.annotation.XxlJob;
|
|
import com.xxl.job.executor.feign.*;
|
|
import com.xxl.job.executor.feign.*;
|
|
|
|
+import org.apache.commons.lang3.ObjectUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -71,89 +73,90 @@ public class SampleXxlJob {
|
|
List<StaffUserInfoDTO> staffUserInfoDTOS = JSON.parseObject(list, new TypeReference<List<StaffUserInfoDTO>>() {});
|
|
List<StaffUserInfoDTO> staffUserInfoDTOS = JSON.parseObject(list, new TypeReference<List<StaffUserInfoDTO>>() {});
|
|
for (StaffUserInfoDTO staffUserInfoDTO : staffUserInfoDTOS) {
|
|
for (StaffUserInfoDTO staffUserInfoDTO : staffUserInfoDTOS) {
|
|
//根据所在部门获取部门主任
|
|
//根据所在部门获取部门主任
|
|
- List<UserDTO> userDTOS = SpringUtil.getBean(IUserApi.class).findListByOfficeId(staffUserInfoDTO.getDepartment());
|
|
|
|
- for (UserDTO userDTO : userDTOS) {
|
|
|
|
- if (CollectionUtil.isNotEmpty(userDTO.getPostDTOList())){
|
|
|
|
- for (PostDTO postDTO : userDTO.getPostDTOList()) {
|
|
|
|
- if (postDTO.getCode().equals("bmzr")){
|
|
|
|
- //创建calendar对象
|
|
|
|
- Calendar instance = Calendar.getInstance();
|
|
|
|
- //获取员工试用期限后的日期
|
|
|
|
- instance.setTime(staffUserInfoDTO.getInTime());
|
|
|
|
- //根据试用期限往后推相应的时间
|
|
|
|
- instance.add(Calendar.MONTH,Integer.parseInt(staffUserInfoDTO.getTimeLimit()));
|
|
|
|
- //获取推送后的日期
|
|
|
|
- Date newDate = instance.getTime();
|
|
|
|
- //获取到当前日期
|
|
|
|
- Date beginDate = new Date();
|
|
|
|
- //计算时间只差
|
|
|
|
- int interval1 = Integer.parseInt(this.getInterval(beginDate, newDate));
|
|
|
|
- String taskName = null;
|
|
|
|
- String titleStr = null;
|
|
|
|
- //如果还剩三天则发送通知
|
|
|
|
- if (interval1<=3 && interval1 >=0) {
|
|
|
|
- taskName = "转正申请还未提交";
|
|
|
|
- titleStr = "距离转正申请提交还剩" + interval1 + "天,请尽快提交";
|
|
|
|
- Set<String> noticeUserSet = new HashSet<String>();
|
|
|
|
-
|
|
|
|
- String byIdForXXL = SpringUtil.getBean(IUserApi.class).getByIdForXXL(userDTO.getId());
|
|
|
|
- UserDTO createUser = JSON.parseObject(byIdForXXL, new TypeReference<UserDTO>() {});
|
|
|
|
- if(null != createUser && StringUtils.isNotBlank(createUser.getId())){
|
|
|
|
- noticeUserSet.add(createUser.getId());
|
|
|
|
- }
|
|
|
|
|
|
+ String jyUserList = SpringUtil.getBean(IUserApi.class).getJyUserList();
|
|
|
|
+ List<UserDTO> dtoList = JSON.parseObject(jyUserList, new TypeReference<List<UserDTO>>() {});
|
|
|
|
+ for (UserDTO userDTO : dtoList) {
|
|
|
|
+ if (ObjectUtil.isNotEmpty(userDTO.getPostDTO())){
|
|
|
|
+ if (userDTO.getPostDTO().getCode().equals("bmzr") && staffUserInfoDTO.getDepartment().equals(userDTO.getOfficeDTO().getId())){
|
|
|
|
+ //创建时间格式化对象
|
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
|
+ //获取员工入职时间
|
|
|
|
+ calendar.setTime(staffUserInfoDTO.getInTime());
|
|
|
|
+ //获取员工试用期限
|
|
|
|
+ int months=Integer.parseInt(staffUserInfoDTO.getTimeLimit());
|
|
|
|
+ calendar.add(Calendar.MONTH, months);
|
|
|
|
+ //获取结束时间
|
|
|
|
+ Date newDate=calendar.getTime();
|
|
|
|
+ //获取到当前日期
|
|
|
|
+ Date beginDate = new Date();
|
|
|
|
+ //计算时间只差
|
|
|
|
+ int interval1 = Integer.parseInt(this.getInterval(beginDate, newDate));
|
|
|
|
+ String taskName = null;
|
|
|
|
+ String titleStr = null;
|
|
|
|
+ //如果还剩三天则发送通知
|
|
|
|
+ if (interval1<=3 && interval1 >=0) {
|
|
|
|
+ taskName = staffUserInfoDTO.getName()+"转正申请还未提交";
|
|
|
|
+ titleStr = "距离"+staffUserInfoDTO.getName()+"转正申请提交还剩" + interval1 + "天,请尽快提交";
|
|
|
|
+ Set<String> noticeUserSet = new HashSet<String>();
|
|
|
|
+
|
|
|
|
+ String byIdForXXL = SpringUtil.getBean(IUserApi.class).getByIdForXXL(userDTO.getId());
|
|
|
|
+ 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
|
|
|
|
|
|
+ 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(jyAudit.getProjectProId());
|
|
// String currentTask = SpringUtil.getBean(IFlowableApi.class).getTaskIdByprocInstId(jyAudit.getProjectProId());
|
|
- myNotice.setTaskId("");
|
|
|
|
- myNotice.setDefId("");
|
|
|
|
- myNotice.setTitle(titleStr);
|
|
|
|
- myNotice.setTaskName(taskName);
|
|
|
|
- myNotice.setLink("结束");
|
|
|
|
- myNotice.setType("0");
|
|
|
|
- myNotice.setCreateUser("管理员");
|
|
|
|
- myNotice.setCreateTime(new Date());
|
|
|
|
- for (String noticeUserId : noticeUserList) {
|
|
|
|
- myNotice.setNoticeId(noticeUserId);
|
|
|
|
- myNotice.setNoticeName(createUser.getName());
|
|
|
|
- //根据taskName和通知人 查询重复数量
|
|
|
|
- String myNoticeInfo = JSON.toJSONString(myNotice);
|
|
|
|
- Map<String, String> map = new HashMap();
|
|
|
|
|
|
+ myNotice.setTaskId("");
|
|
|
|
+ myNotice.setDefId("");
|
|
|
|
+ myNotice.setTitle(titleStr);
|
|
|
|
+ myNotice.setTaskName(taskName);
|
|
|
|
+ myNotice.setLink("结束");
|
|
|
|
+ myNotice.setType("0");
|
|
|
|
+ myNotice.setCreateUser("管理员");
|
|
|
|
+ myNotice.setCreateTime(new Date());
|
|
|
|
+ for (String noticeUserId : noticeUserList) {
|
|
|
|
+ myNotice.setNoticeId(noticeUserId);
|
|
|
|
+ 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);
|
|
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);
|
|
|
|
- }
|
|
|
|
|
|
+ SpringUtil.getBean(IFlowableApi.class).updateMyNotice(map);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|