Commit 35b60965 authored by yf's avatar yf

创建请假时新增消息、创建巡检任务时新增代办

parent e0f56c03
......@@ -37,29 +37,29 @@ public class CurrentRiskTask {
/**
* 每天零点发送任务
* @param isDailypOther 除每月 1 号外,是否新增日查之外的巡查 默认不新增
*
*/
public void senTask(){
boolean isDailypOther=false;
public void senTask() {
boolean isDailypOther = false;
//判断是否查询当天巡查任务是否发放
Calendar calendar = Calendar.getInstance();
int hour = calendar.get(Calendar.HOUR_OF_DAY);
int day = calendar.get(Calendar.DAY_OF_MONTH);
//查询所有的任务列表
QueryWrapper<CurrentRiskPostList> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("status","0");
queryWrapper.eq("status", "0");
List<CurrentRiskPostList> currentRiskPostLists = currentRiskPostListService.list();
if(CollectionUtils.isEmpty(currentRiskPostLists)){
if (CollectionUtils.isEmpty(currentRiskPostLists)) {
return;
}
//查询所有人的巡查类型,按巡查类型分类
List<CurrentRiskPostList> patrolTypeList = currentRiskPostListService.selectCurrentRiskPostListList3();
for (CurrentRiskPostList patrolType : patrolTypeList){
for (CurrentRiskPostList patrolType : patrolTypeList) {
//初始化用户巡查总表
CurrentRiskUserPatrol currentRiskUserPatrol = new CurrentRiskUserPatrol();
//开始时间,结束时间
try {
initTime(currentRiskUserPatrol,patrolType.getPatrolType());
initTime(currentRiskUserPatrol, patrolType.getPatrolType());
} catch (Exception e) {
e.printStackTrace();
log.info("初始化时间出错");
......@@ -67,27 +67,27 @@ public class CurrentRiskTask {
//查询当天巡查任务是否发放
//查询是否发送过
QueryWrapper<CurrentRiskUserPatrol> patrolQueryWrapper = new QueryWrapper<>();
patrolQueryWrapper.eq("user_id",patrolType.getUserId()).eq("risk_post_id", patrolType.getPostId())
.eq("patrol_type",patrolType.getPatrolType())
.ge("start_time",currentRiskUserPatrol.getStartTime()).le("start_time",currentRiskUserPatrol.getEndTime());
patrolQueryWrapper.eq("user_id", patrolType.getUserId()).eq("risk_post_id", patrolType.getPostId())
.eq("patrol_type", patrolType.getPatrolType())
.ge("start_time", currentRiskUserPatrol.getStartTime()).le("start_time", currentRiskUserPatrol.getEndTime());
//如果是日查 且 属于主动点击行为,则进行校验
if(hour > 2 && patrolType.getPatrolType().equals(CycleType.DAILY.getValue())){
if(currentRiskUserPatrolService.count(patrolQueryWrapper) > 0){
if (hour > 2 && patrolType.getPatrolType().equals(CycleType.DAILY.getValue())) {
if (currentRiskUserPatrolService.count(patrolQueryWrapper) > 0) {
continue;
}
}
// 大于1号 且 非日查 要添加 计划查询的数据要进行测验
if(day > 1 && isDailypOther && !patrolType.getPatrolType().equals(CycleType.DAILY.getValue())){
if(currentRiskUserPatrolService.count(patrolQueryWrapper) > 0){
if (day > 1 && isDailypOther && !patrolType.getPatrolType().equals(CycleType.DAILY.getValue())) {
if (currentRiskUserPatrolService.count(patrolQueryWrapper) > 0) {
continue;
}
}
//新增任务
List<CurrentRiskPostList> saveCurrentRiskPostLists = currentRiskPostLists.stream().
List<CurrentRiskPostList> saveCurrentRiskPostLists = currentRiskPostLists.stream().
filter(currentRiskPostList -> currentRiskPostList.getPostId().equals(patrolType.getPostId())
&& currentRiskPostList.getPatrolType().equals(patrolType.getPatrolType())
&& currentRiskPostList.getUserId().equals(patrolType.getUserId())).collect(Collectors.toList());
if(CollectionUtils.isEmpty(saveCurrentRiskPostLists)){
&& currentRiskPostList.getUserId().equals(patrolType.getUserId())).collect(Collectors.toList());
if (CollectionUtils.isEmpty(saveCurrentRiskPostLists)) {
continue;
}
currentRiskPostLists.removeAll(saveCurrentRiskPostLists);
......@@ -102,7 +102,7 @@ public class CurrentRiskTask {
currentRiskUserPatrolService.insertCurrentRiskUserPatrol(currentRiskUserPatrol);
//新增巡查明细信息
List<CurrentRiskUserPatrolDetail> list = new ArrayList<>();
saveCurrentRiskPostLists.forEach(saveCurrentRiskPostList ->{
saveCurrentRiskPostLists.forEach(saveCurrentRiskPostList -> {
CurrentRiskUserPatrolDetail currentRiskUserPatrolDetail = new CurrentRiskUserPatrolDetail();
currentRiskUserPatrolDetail.setCurrentRiskId(saveCurrentRiskPostList.getCurrentRiskId());
currentRiskUserPatrolDetail.setPatrolId(currentRiskUserPatrol.getId());
......@@ -114,16 +114,22 @@ public class CurrentRiskTask {
currentRiskUserPatrolDetailService.saveBatch(list);
SysUser user = userService.selectUserById(patrolType.getUserId());
//创建代办
commonMessageInfoService.insertBacklogInfo(String.valueOf(currentRiskUserPatrol.getId()), "risk_confirm_sub", String.valueOf(currentRiskUserPatrol.getId()),
"巡查任务", "巡查",
"您有一条新的巡查任务待确认", "0", user.getUserName(),
"巡查任务", "" , "patrolExecute", user.getNickName());
}
}
/**
* 开始时间,结束时间计算
*
* @param currentRiskUserPatrol 对象
* @param patrolType 巡检类型 0 日查 1 周查 2 月查 3 季查 4 年查
* @param patrolType 巡检类型 0 日查 1 周查 2 月查 3 季查 4 年查
*/
private void initTime(CurrentRiskUserPatrol currentRiskUserPatrol,String patrolType)throws Exception{
private void initTime(CurrentRiskUserPatrol currentRiskUserPatrol, String patrolType) throws Exception {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar calendar = Calendar.getInstance();
int currentYear = calendar.get(Calendar.YEAR);
......@@ -131,47 +137,47 @@ public class CurrentRiskTask {
String startTime = "";
String endTime = "";
//日查
if(patrolType.equals(CycleType.DAILY.getValue())){
if (patrolType.equals(CycleType.DAILY.getValue())) {
startTime = SDF.format(calendar.getTime()) + " 00:00:00";
endTime = SDF.format(calendar.getTime()) + " 23:59:59";
}
//周查
if(patrolType.equals(CycleType.WEEKLY.getValue())){
if (patrolType.equals(CycleType.WEEKLY.getValue())) {
// 获取当前是周几,注意返回值是1-7,1表示周日,2表示周一,以此类推
int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);
if(dayOfWeek == 1 ){
if (dayOfWeek == 1) {
calendar.add(Calendar.DATE, -6);
}else{
calendar.add(Calendar.DATE, 2-dayOfWeek);
} else {
calendar.add(Calendar.DATE, 2 - dayOfWeek);
}
startTime = SDF.format(calendar.getTime()) + " 00:00:00";
calendar.add(Calendar.DATE, 6);
endTime = SDF.format(calendar.getTime()) + " 23:59:59";
}
//月查
if(patrolType.equals(CycleType.MONTH.getValue())){
if (patrolType.equals(CycleType.MONTH.getValue())) {
startTime = currentYear + "-" + currentMonth + "-01 00:00:00";
calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
int lastDayOfMonth = calendar.get(Calendar.DAY_OF_MONTH);
endTime = currentYear + "-" + currentMonth + "-" + lastDayOfMonth +" 23:59:59";
endTime = currentYear + "-" + currentMonth + "-" + lastDayOfMonth + " 23:59:59";
}
//季查
if(patrolType.equals(CycleType.QUARTERLY.getValue())){
if (patrolType.equals(CycleType.QUARTERLY.getValue())) {
// 获取当前月份,注意返回值是0-11,因此需要加1
int month = calendar.get(Calendar.MONTH) + 1;
// 获取当前季度,注意返回值是1-4,1表示第一季度,以此类推
int quarter = (month - 1) / 3 + 1;
//季度初始月份
int quarterMonth = 1 + (3 * (quarter-1));
startTime = currentYear + "-"+quarterMonth + "-01 00:00:00";
int quarterMonth = 1 + (3 * (quarter - 1));
startTime = currentYear + "-" + quarterMonth + "-01 00:00:00";
calendar.setTime(SDF.parse(startTime));
calendar.add(Calendar.MONTH,2);
calendar.add(Calendar.MONTH, 2);
calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
int lastDayOfMonth = calendar.get(Calendar.DAY_OF_MONTH);
endTime = currentYear + "-" + currentMonth + "-" + lastDayOfMonth +" 23:59:59";
endTime = currentYear + "-" + currentMonth + "-" + lastDayOfMonth + " 23:59:59";
}
//年查
if(patrolType.equals(CycleType.YEARLY.getValue())){
if (patrolType.equals(CycleType.YEARLY.getValue())) {
startTime = currentYear + "-01-01 00:00:00";
endTime = currentYear + "-12-31 23:59:59";
}
......
......@@ -2,6 +2,7 @@ package com.censoft.censoftrongtong.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.censoft.censoftrongtong.domain.CurrentRiskUserHoliday;
import com.censoft.censoftrongtong.service.ICommonMessageInfoService;
import com.censoft.censoftrongtong.service.ICurrentRiskUserHolidayService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
......@@ -11,6 +12,7 @@ import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.domain.server.Sys;
import com.ruoyi.system.service.ISysUserService;
import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
......@@ -33,6 +35,7 @@ import java.util.List;
public class CurrentRiskUserHolidayController extends BaseController {
private ICurrentRiskUserHolidayService currentRiskUserHolidayService;
private ISysUserService sysUserService;
private ICommonMessageInfoService commonMessageInfoService;
/**
* 查询现状风险巡查用户请假列表
......@@ -41,9 +44,9 @@ public class CurrentRiskUserHolidayController extends BaseController {
public TableDataInfo list(CurrentRiskUserHoliday currentRiskUserHoliday) {
startPage();
QueryWrapper<CurrentRiskUserHoliday> queryWrapper = new QueryWrapper<>();
if (currentRiskUserHoliday.getType()==null) {
if (currentRiskUserHoliday.getType() == null) {
}else{
} else {
if ("0".equals(currentRiskUserHoliday.getType())) {
//申请人
queryWrapper.eq("apply_user_id", getUserId());
......@@ -116,6 +119,11 @@ public class CurrentRiskUserHolidayController extends BaseController {
currentRiskUserHoliday.setApproveUserId(getUserId());
currentRiskUserHolidayService.updateCurrentRiskUserHoliday(currentRiskUserHoliday);
}
SysUser user = sysUserService.selectUserById(getUserId());
//给上报人发消息
commonMessageInfoService.insertMessageInfo(currentRiskUserHoliday.getId() + "", "finish", "请假提醒"
, "今日用户'" + user.getNickName() + "'已请假,望知晓!"
, "0", getUsername(), "请假提醒", "", "/patrolCancle/detail?id=" + currentRiskUserHoliday.getId(), user.getUserName());
return AjaxResult.success();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment