Commit 35b60965 authored by yf's avatar yf

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

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