diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/inspect/ContentMapper.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/inspect/InspectContentMapper.java similarity index 76% rename from hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/inspect/ContentMapper.java rename to hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/inspect/InspectContentMapper.java index 159ec5c..cad89ee 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/inspect/ContentMapper.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/inspect/InspectContentMapper.java @@ -8,5 +8,5 @@ import org.apache.ibatis.annotations.Mapper; * @author ysj */ @Mapper -public interface ContentMapper extends BaseMapper{ +public interface InspectContentMapper extends BaseMapper{ } diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/inspect/ObjectMapper.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/inspect/InspectObjectMapper.java similarity index 77% rename from hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/inspect/ObjectMapper.java rename to hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/inspect/InspectObjectMapper.java index b130b94..2785f87 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/inspect/ObjectMapper.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/inspect/InspectObjectMapper.java @@ -8,6 +8,6 @@ import org.apache.ibatis.annotations.Mapper; * @author ysj */ @Mapper -public interface ObjectMapper extends BaseMapper { +public interface InspectObjectMapper extends BaseMapper { } diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/BusinessScheduledTask.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/BusinessScheduledTask.java deleted file mode 100644 index f908b36..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/BusinessScheduledTask.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.hnac.hzims.scheduled.scheduled; - -import com.hnac.hzims.scheduled.service.inspect.TaskService; -import com.hnac.hzims.scheduled.service.operation.business.MaintenanceService; -import com.xxl.job.core.biz.model.ReturnT; -import com.xxl.job.core.handler.annotation.XxlJob; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.tool.utils.DateUtil; -import org.springblade.core.tool.utils.Func; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import java.util.Date; -import static com.hnac.hzinfo.inspect.task.TaskContants.*; - - -/** - * 业务模块定时任务 - * @author ysj - */ -@Slf4j -@Component -public class BusinessScheduledTask { - - @Autowired - private TaskService service; - - private MaintenanceService maintenanceService; - - /** - * 巡检任务派发 : 一分钟执行一次 - */ - @XxlJob(INSPECT_TASK_DISTRIBUTE) - //@Scheduled(cron = "0/40 * * * * ? ") - public ReturnT inspectTaskDistribute(String param) { - if (Func.isBlank(param)) { - param = DateUtil.format(new Date(), "yyyy-MM"); - } - service.inspectTaskDistribute(param); - return new ReturnT<>("SUCCESS"); - } - - /** - * 巡检任务派发 : 一天执行一次 凌晨0时执行 - */ - @XxlJob(MAINTENANCE_TASK_DISTRIBUTE) - //@Scheduled(cron = "0/40 * * * * ? ") - public ReturnT maintenanceTaskDistribute(String param) { - if (Func.isBlank(param)) { - param = DateUtil.format(new Date(), "yyyy-MM"); - } - maintenanceService.maintenanceTaskDistribute(param); - return new ReturnT<>("SUCCESS"); - } - -} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/ContentService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/ContentService.java deleted file mode 100644 index f1f04cf..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/ContentService.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.hnac.hzims.scheduled.service.inspect; - -import com.hnac.hzinfo.inspect.obj.entity.ContentEntity; -import org.springblade.core.mp.base.BaseService; - -/** - * @author ysj - */ -public interface ContentService extends BaseService { - -} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/ObjectService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/ObjectService.java deleted file mode 100644 index 7512337..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/ObjectService.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.hnac.hzims.scheduled.service.inspect; - -import com.hnac.hzinfo.inspect.obj.entity.ObjectEntity; -import org.springblade.core.mp.base.BaseService; - -/** - * @author ysj - */ -public interface ObjectService extends BaseService { - -} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/ObjectUserService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/ObjectUserService.java deleted file mode 100644 index 2963621..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/ObjectUserService.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.hnac.hzims.scheduled.service.inspect; - -import com.hnac.hzinfo.inspect.obj.entity.ObjectUserEntity; -import org.springblade.core.mp.base.BaseService; - -/** - * @author ysj - */ -public interface ObjectUserService extends BaseService { - -} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/PlanObjectTemplateService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/PlanObjectTemplateService.java deleted file mode 100644 index 9c7314f..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/PlanObjectTemplateService.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.hnac.hzims.scheduled.service.inspect; - -import com.hnac.hzinfo.inspect.plan.entity.PlanObjectTemplateEntity; -import org.springblade.core.mp.base.BaseService; - -/** - * @author ysj - */ -public interface PlanObjectTemplateService extends BaseService { - -} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/PlanOrgService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/PlanOrgService.java deleted file mode 100644 index 3372f82..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/PlanOrgService.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.hnac.hzims.scheduled.service.inspect; - -import com.hnac.hzinfo.inspect.plan.entity.PlanOrgEntity; -import org.springblade.core.mp.base.BaseService; - -/** - * @author ysj - */ -public interface PlanOrgService extends BaseService { - -} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/PlanPositionService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/PlanPositionService.java deleted file mode 100644 index 334cfc6..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/PlanPositionService.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.hnac.hzims.scheduled.service.inspect; - -import com.hnac.hzinfo.inspect.plan.entity.PlanPositionEntity; -import org.springblade.core.mp.base.BaseService; - -/** - * @author ysj - */ -public interface PlanPositionService extends BaseService { - -} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/PlanUserService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/PlanUserService.java deleted file mode 100644 index 7634f14..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/PlanUserService.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.hnac.hzims.scheduled.service.inspect; - -import com.hnac.hzinfo.inspect.plan.entity.PlanUserEntity; -import org.springblade.core.mp.base.BaseService; - -/** - * 巡检计划用户模板服务类 - * - * @author Chill - */ -public interface PlanUserService extends BaseService { - -} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/ProjectContentService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/ProjectContentService.java deleted file mode 100644 index 82cd962..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/ProjectContentService.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.hnac.hzims.scheduled.service.inspect; - - -import com.hnac.hzinfo.inspect.obj.entity.ProjectContentEntity; -import org.springblade.core.mp.base.BaseService; - -/** - * @author ysj - */ -public interface ProjectContentService extends BaseService{ - -} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/ProjectService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/ProjectService.java deleted file mode 100644 index ef2a474..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/ProjectService.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.hnac.hzims.scheduled.service.inspect; - - -import com.hnac.hzinfo.inspect.obj.entity.ProjectEntity; -import org.springblade.core.mp.base.BaseService; - -/** - * @author ysj - */ -public interface ProjectService extends BaseService{ - -} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/TaskObjectProjectContentService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/TaskObjectProjectContentService.java deleted file mode 100644 index 0db0ebb..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/TaskObjectProjectContentService.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.hnac.hzims.scheduled.service.inspect; - -import com.hnac.hzinfo.inspect.task.entity.TaskObjectProjectContentEntity; -import org.springblade.core.mp.base.BaseService; - -/** - * @author ysj - */ -public interface TaskObjectProjectContentService extends BaseService { - -} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/TaskObjectProjectService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/TaskObjectProjectService.java deleted file mode 100644 index 400d84b..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/TaskObjectProjectService.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.hnac.hzims.scheduled.service.inspect; - -import com.hnac.hzinfo.inspect.task.entity.TaskObjectProjectEntity; -import org.springblade.core.mp.base.BaseService; - -/** - * @author ysj - */ -public interface TaskObjectProjectService extends BaseService { - -} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/TaskObjectService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/TaskObjectService.java deleted file mode 100644 index fb033a0..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/TaskObjectService.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.hnac.hzims.scheduled.service.inspect; - -import com.hnac.hzinfo.inspect.task.entity.TaskObjectEntity; -import org.springblade.core.mp.base.BaseService; - -/** - * @author ysj - */ -public interface TaskObjectService extends BaseService { - -} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/TaskPlanService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/TaskPlanService.java deleted file mode 100644 index 442f0bf..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/TaskPlanService.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.hnac.hzims.scheduled.service.inspect; - -import com.hnac.hzinfo.inspect.plan.entity.PlanEntity; -import org.springblade.core.mp.base.BaseService; - -/** - * @author ysj - */ -public interface TaskPlanService extends BaseService { - - -} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/TaskRemindManager.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/TaskRemindManager.java deleted file mode 100644 index 5ef3415..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/TaskRemindManager.java +++ /dev/null @@ -1,295 +0,0 @@ -package com.hnac.hzims.scheduled.service.inspect; - -import com.alibaba.fastjson.JSON; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.hnac.hzinfo.core.push.enums.PushAudienceType; -import com.hnac.hzinfo.core.push.model.PushAudience; -import com.hnac.hzinfo.core.push.model.PushInfo; -import com.hnac.hzinfo.core.push.model.PushPlatform; -import com.hnac.hzinfo.inspect.task.TaskContants; -import com.hnac.hzinfo.inspect.task.entity.TaskEntity; -import com.xxl.job.core.log.XxlJobLogger; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.sms.model.SmsResponse; -import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.CollectionUtil; -import org.springblade.core.tool.utils.Func; -import org.springblade.resource.feign.IPushClient; -import org.springblade.resource.feign.ISmsClient; -import org.springblade.resource.vo.PushInfoVO; -import org.springblade.system.user.cache.UserCache; -import org.springblade.system.user.entity.User; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.data.redis.core.DefaultTypedTuple; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.stereotype.Component; - -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.ZoneOffset; -import java.time.format.DateTimeFormatter; -import java.util.*; -import java.util.concurrent.*; -import java.util.stream.Collectors; - -/** - * 巡检任务通知、短信提醒管理器 - * 提醒列表使用redis缓存 - * - * @author py - */ -@Slf4j -@Component -public class TaskRemindManager { - - /** - * 巡检任务开始前发送短信信息阿里云模板 - **/ - @Value("${hzims.inspect.task.templateCode.taskBegin}") - private String taskBeginTemplateCode; - - /** - * 巡检任务结束前发送短信信息阿里云模板 - **/ - @Value("${hzims.inspect.task.templateCode.taskEnd}") - private String taskEndTemplateCode; - - /** - * 巡检消息推送模板 - 极光 - **/ - @Value("${hzims.inspect.task.jgPushCode}") - private String jgPushCode; - - @Autowired - private TaskService taskService; - @Autowired - private RedisTemplate redisTemplate; - @Autowired - private ISmsClient smsClient; - @Autowired - private IPushClient pushClient; - - - /** - * 开始前提醒任务列表 - */ - final static String REMIND_TASK_BEGIN_LIST = "hzinfo:remind:begin:tasks"; - /** - * 结束前提醒任务列表 - */ - final static String REMIND_TASK_END_LIST = "hzinfo:remind:end:tasks"; - - /** - * 开始 - * 重置redis开始提醒缓存列表 - * 按照时间排序 : 正序 - */ - public void replaceBeginTaskCacheList(List taskBegin){ - //先删除 - redisTemplate.opsForZSet().removeRange(REMIND_TASK_BEGIN_LIST,0, -1); - setTaskBeginList(taskBegin); - } - - /** - * 结束 - * 重置redis结束提醒缓存列表 - * 按照时间排序 : 正序 - */ - public void replaceEndTaskCacheList(List taskEnd){ - //先删除 - redisTemplate.opsForZSet().removeRange(REMIND_TASK_END_LIST,0, -1); - setTaskEndList(taskEnd); - } - - /** - * 开始 - * 任务批量加入redis提醒缓存列表中 - * - */ - public void setTaskBeginList(List tasks){ - HashSet set = new HashSet(); - - for (TaskEntity task : tasks) { - DefaultTypedTuple tuple = new DefaultTypedTuple<>(task, (double) task.getStartRemindTime().toEpochSecond(ZoneOffset.of("+8"))); - set.add(tuple); - } - if(Func.isNotEmpty(set)){ - redisTemplate.opsForZSet().add(REMIND_TASK_BEGIN_LIST, set); - } - } - - /** - * 结束 - * 任务批量加入redis提醒缓存列表中 - */ - public void setTaskEndList(List tasks){ - HashSet set = new HashSet(); - for (TaskEntity task : tasks) { - DefaultTypedTuple tuple = new DefaultTypedTuple<>(task, (double) task.getEndRemindTime().toEpochSecond(ZoneOffset.of("+8"))); - set.add(tuple); - } - if(Func.isNotEmpty(set)){ - redisTemplate.opsForZSet().add(REMIND_TASK_END_LIST, set); - } - } - - - /** - * 把任务加入redis提醒缓存列表中 - * 加入的时候 按照时间排序 : 正序 - */ - public void addTaskToCacheList(TaskEntity task){ - DateTimeFormatter dfShort = DateTimeFormatter.ofPattern("yyyy-MM-dd "); - DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); - - redisTemplate.expire(REMIND_TASK_BEGIN_LIST,365,TimeUnit.DAYS); - if(task.getStartRemindTime().isAfter(LocalDateTime.parse(dfShort.format(LocalDate.now()) + "00:00:00", df))){ - redisTemplate.opsForZSet().add(REMIND_TASK_BEGIN_LIST, task, task.getStartRemindTime().toEpochSecond(ZoneOffset.of("+8"))); - log.info("--------------- key = hzinfo:remind:begin:tasks ---- size = " + redisTemplate.opsForZSet().size(REMIND_TASK_BEGIN_LIST)); - } - - if(task.getEndRemindTime().isAfter(LocalDateTime.parse(dfShort.format(LocalDate.now()) + "00:00:00", df))){ - redisTemplate.opsForZSet().add(REMIND_TASK_END_LIST, task, task.getEndRemindTime().toEpochSecond(ZoneOffset.of("+8"))); - log.info("--------------- key = hzinfo:remind:end:tasks ---- size = " + redisTemplate.opsForZSet().size(REMIND_TASK_END_LIST)); - } - } - - /** - * 任务开始前 - */ - static final int BEGIN_SEND_FLAG = 1; - /** - * 任务结束前 - */ - static final int END_SEND_FLAG = 2; - - /** - * 任务开始、结束前提醒 - */ - public void taskRemind(){ - sendMsg(BEGIN_SEND_FLAG); - sendMsg(END_SEND_FLAG); - } - - /** - * 任务开始、结束前提醒 - */ - public void cleanCache(){ - long currentTime = LocalDateTime.now().toEpochSecond(ZoneOffset.of("+8")); - String key = REMIND_TASK_BEGIN_LIST; - for (int i = 0; i < 2; i++) { - if(i == 1 ){ - key = REMIND_TASK_END_LIST; - } - Set tasks = redisTemplate.opsForZSet().rangeByScore(key,0, currentTime); - if(Func.isNotEmpty(tasks)){ - for (TaskEntity task : tasks) { - //用户id为空,删除数据 - redisTemplate.opsForZSet().remove(key, task); - } - } - log.info(key + " 清空cache后 ---- size = " + redisTemplate.opsForZSet().size(key)); - } - - } - - /** - * 任务开始/结束前 - * 推送消息、发送短信 - * @param sendFlag 发送标识:任务开始前提醒 1;任务结束前提醒 2; - */ - private void sendMsg(int sendFlag){ - //redis key; 消息推送标题; 短信模板code - String key = "", title = "", templateCode = ""; - - switch (sendFlag){ - case BEGIN_SEND_FLAG: - key = REMIND_TASK_BEGIN_LIST; - title = "任务开始前提醒"; - templateCode = taskBeginTemplateCode; - break; - case END_SEND_FLAG: - key = REMIND_TASK_END_LIST; - title = "任务结束前提醒"; - templateCode = taskEndTemplateCode; - break; - default: - break; - } - - DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); - long currentTime = LocalDateTime.now().toEpochSecond(ZoneOffset.of("+8")); - Set tasks = redisTemplate.opsForZSet().rangeByScore(key,0, currentTime); - if(Func.isNotEmpty(tasks)){ - //若该任务已完成 则无需再进行短信推送 - List taskIds = tasks.stream().map(TaskEntity::getId).collect(Collectors.toList()); - List undoneTaskList = taskService.list(Wrappers.lambdaQuery() - .ne(TaskEntity::getStatus, TaskContants.TaskStatusEnum.FINISH_STATUS.getStatus()) - .in(TaskEntity::getId, taskIds) - ); - if(CollectionUtil.isEmpty(undoneTaskList)) { - XxlJobLogger.log("巡检短信通知列表为空;redis内取出数据为:" + JSON.toJSONString(taskIds)); - return; - } - List undoneTaskIds = undoneTaskList.stream().map(TaskEntity::getId).collect(Collectors.toList()); - for (TaskEntity task : tasks) { - if(!undoneTaskIds.contains(task.getId())) { - XxlJobLogger.log(task.getId()+"巡检任务已完成,无需推送短信"); - return; - } - XxlJobLogger.log(task.getId()+"开始推送消息!"); - // 移动端消息推送 : 使用 用户id做TAG,前端注册用户id为TAG - PushInfoVO pushInfoVO = new PushInfoVO(); - pushInfoVO.setTenantId(task.getTenantId()); - PushPlatform platform = PushPlatform.all(); - Map> audienceMap = new HashMap<>(); - audienceMap.put(PushAudienceType.TAG, Collections.singletonList(task.getUserId().toString())); - PushAudience audience = new PushAudience(false, audienceMap); - PushInfo pushInfo = new PushInfo(jgPushCode - , title - , "任务“"+ task.getPlanName() + "”的计划执行时间是:" + df.format(task.getPlanStartTime())+ " —— " + df.format(task.getPlanEndTime()) - , "" - , null - , platform - , audience); - pushInfoVO.setPushInfo(pushInfo); - - Map smsMap = new HashMap<>(3); - smsMap.put("one", task.getPlanName()); - if(sendFlag == BEGIN_SEND_FLAG){ - smsMap.put("two", df.format(task.getPlanStartTime())); - } else if(sendFlag == END_SEND_FLAG){ - smsMap.put("two", df.format(task.getPlanEndTime())); - } //smsMap.put("three", df.format(task.getPlanEndTime())); - - - String jsonParam = JSON.toJSONString(smsMap); - - User user = UserCache.getUser(task.getUserId()); - String userPhone = Func.isNotEmpty(user) ? user.getPhone() : null; - log.info("------------ 发送短信 用户手机号 = " + userPhone); - - String finalTemplateCode = templateCode; - XxlJobLogger.log(task.getId()+"开始推送短信!"); - ThreadFactory threadFactory = Executors.defaultThreadFactory(); - ThreadPoolExecutor pool = new ThreadPoolExecutor(5, 5, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingDeque(), threadFactory); - pool.execute(() -> { - if(Func.isNotEmpty(userPhone)){ - // 发送短信 - R success = smsClient.sendMessage(task.getTenantId(), finalTemplateCode, jsonParam, userPhone); - log.info("msg -- 用户手机号:" + userPhone + " ; 短信内容:" + jsonParam + " ; TenantId:" + task.getTenantId() + " ; finalTemplateCode:" + finalTemplateCode + ";返回信息 = " + (Func.isNotEmpty(success)?success.toString(): "返回为空")); - } - //推送消息给移动端 - pushClient.tenantPush(pushInfoVO); - log.info("msg -- 推送信息完成" ); - }); - - //把已发送的数据移除 - // redisTemplate.opsForZSet().remove(key, task); - log.info("已推送、发送短信后 --------------- key = " + key + " ---- size = " + redisTemplate.opsForZSet().size(key)); - } - } - } - -} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/TaskResultService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/TaskResultService.java deleted file mode 100644 index 960f773..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/TaskResultService.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.hnac.hzims.scheduled.service.inspect; - -import com.hnac.hzinfo.inspect.task.entity.TaskResultEntity; -import org.springblade.core.mp.base.BaseService; - -/** - * @author ysj - */ -public interface TaskResultService extends BaseService { - -} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/TaskService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/TaskService.java index 4e3aa2b..6d25531 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/TaskService.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/TaskService.java @@ -11,7 +11,5 @@ import java.util.List; */ public interface TaskService extends BaseService { - void inspectTaskDistribute(String param); - DutyInspectTaskVO task(String start, String end, List areas); } \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/TaskUserService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/TaskUserService.java deleted file mode 100644 index 558a4c6..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/TaskUserService.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.hnac.hzims.scheduled.service.inspect; - -import com.hnac.hzinfo.inspect.task.entity.TaskUserEntity; -import org.springblade.core.mp.base.BaseService; - -import java.util.List; - -/** - * @author ysj - */ -public interface TaskUserService extends BaseService { - -} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/TaskVideoManager.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/TaskVideoManager.java deleted file mode 100644 index bb53251..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/TaskVideoManager.java +++ /dev/null @@ -1,98 +0,0 @@ -package com.hnac.hzims.scheduled.service.inspect; - -import com.hnac.hzinfo.inspect.ai.vo.VideoReturnDTO; -import com.hnac.hzinfo.inspect.plan.PlanContants; -import com.hnac.hzinfo.inspect.task.entity.TaskEntity; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.stereotype.Component; - -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - - -/** - * 视频巡检任务 - * 提醒列表使用redis缓存 - * @Author: py - */ -@Component -public class TaskVideoManager { - - /** - * 视频巡检任务列表 - */ - final static String VIDEO_TASK_LIST = "hzinfo:video:tasks"; - - /** - * 视频巡检 AI识别结果列表 - */ - final static String VIDEO_TASK_AI_RESULT= "hzinfo:video:ai:results"; - - @Autowired - private RedisTemplate redisTemplate; - - /** - * 把AI识别结果加入redis缓存中 - */ - public void addAiResultToMap(VideoReturnDTO returnDTO){ - redisTemplate.opsForHash().put(VIDEO_TASK_AI_RESULT, returnDTO.getVideo(), returnDTO); - } - - /** - * 从redis缓存中取出AI识别结果 - */ - public VideoReturnDTO getAiResultFromMap(String video){ - if(redisTemplate.opsForHash().hasKey(VIDEO_TASK_AI_RESULT, video)){ - return (VideoReturnDTO)redisTemplate.opsForHash().get(VIDEO_TASK_AI_RESULT, video); - } - return null; - } - - - - /** - * 把任务加入redis提醒缓存列表中 - */ - public void addTaskToVideoCacheList(TaskEntity task){ - if(task.getAutoVideo().equals(PlanContants.InspectTypeEnum.VIDEO.getVal())){ - redisTemplate.opsForHash().put(VIDEO_TASK_LIST, task.getId(), task); - } - } - - - /** - * 把任务加入redis提醒缓存列表中 - */ - public void deleteTaskFromCacheList(TaskEntity task){ - redisTemplate.opsForHash().delete(VIDEO_TASK_LIST, task.getId()); - } - - - /** - * - */ - public void deleteTaskFromCacheList(String taskId){ - redisTemplate.opsForHash().delete(VIDEO_TASK_LIST, taskId); - } - - /** - * 从缓存中取出当前时间加一分钟之前的所有数据 - */ - public List getTasksFromCacheList(){ - List tasks = new ArrayList<>(); - HashMap map = (HashMap) redisTemplate.opsForHash().entries(VIDEO_TASK_LIST); - map.forEach((id, task) ->{ - if(task.getPlanStartTime().isBefore(LocalDateTime.now().plusMinutes(1L))){ - tasks.add(task); - deleteTaskFromCacheList(id); - } - }); - return tasks; - } - - - -} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/TemplateProjectService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/TemplateProjectService.java deleted file mode 100644 index d67b8df..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/TemplateProjectService.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.hnac.hzims.scheduled.service.inspect; - - -import com.hnac.hzinfo.inspect.obj.entity.TemplateProjectEntity; -import org.springblade.core.mp.base.BaseService; - -/** - * @author ysj - */ -public interface TemplateProjectService extends BaseService{ - -} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/TemplateService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/TemplateService.java deleted file mode 100644 index f0e8005..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/TemplateService.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.hnac.hzims.scheduled.service.inspect; - -import com.hnac.hzinfo.inspect.obj.entity.TemplateEntity; -import org.springblade.core.mp.base.BaseService; - -/** - * @author ysj - */ -public interface TemplateService extends BaseService { - -} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/ContentServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/ContentServiceImpl.java deleted file mode 100644 index b182d6e..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/ContentServiceImpl.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.hnac.hzims.scheduled.service.inspect.impl; - -import com.baomidou.dynamic.datasource.annotation.DS; -import com.hnac.hzims.scheduled.mapper.inspect.ContentMapper; -import com.hnac.hzims.scheduled.service.inspect.ContentService; -import com.hnac.hzinfo.inspect.obj.entity.ContentEntity; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.mp.base.BaseServiceImpl; -import org.springframework.stereotype.Service; - -/** - * @author ysj - */ -@Service -@Slf4j -@AllArgsConstructor -@DS("inspect") -public class ContentServiceImpl extends BaseServiceImpl implements ContentService { - -} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/ObjectServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/ObjectServiceImpl.java deleted file mode 100644 index c34fed9..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/ObjectServiceImpl.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.hnac.hzims.scheduled.service.inspect.impl; - -import com.baomidou.dynamic.datasource.annotation.DS; -import com.hnac.hzims.scheduled.mapper.inspect.ObjectMapper; -import com.hnac.hzims.scheduled.service.inspect.ObjectService; -import com.hnac.hzinfo.inspect.obj.entity.ObjectEntity; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.mp.base.BaseServiceImpl; -import org.springframework.stereotype.Service; - - -/** - * @author ysj - */ -@Service -@Slf4j -@AllArgsConstructor -@DS("inspect") -public class ObjectServiceImpl extends BaseServiceImpl implements ObjectService { - -} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/ObjectUserServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/ObjectUserServiceImpl.java deleted file mode 100644 index 8f09fa0..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/ObjectUserServiceImpl.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.hnac.hzims.scheduled.service.inspect.impl; - -import com.baomidou.dynamic.datasource.annotation.DS; -import com.hnac.hzims.scheduled.mapper.inspect.ObjectUserMapper; -import com.hnac.hzims.scheduled.service.inspect.ObjectUserService; -import com.hnac.hzinfo.inspect.obj.entity.ObjectUserEntity; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.mp.base.BaseServiceImpl; -import org.springframework.stereotype.Service; - -/** - * @author ysj - */ -@Service -@Slf4j -@AllArgsConstructor -@DS("inspect") -public class ObjectUserServiceImpl extends BaseServiceImpl implements ObjectUserService { - -} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/PlanObjectTemplateServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/PlanObjectTemplateServiceImpl.java deleted file mode 100644 index 4e63cdc..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/PlanObjectTemplateServiceImpl.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.hnac.hzims.scheduled.service.inspect.impl; - -import com.baomidou.dynamic.datasource.annotation.DS; -import com.hnac.hzims.scheduled.mapper.inspect.PlanObjectTemplateMapper; -import com.hnac.hzims.scheduled.service.inspect.PlanObjectTemplateService; -import com.hnac.hzinfo.inspect.plan.entity.PlanObjectTemplateEntity; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.mp.base.BaseServiceImpl; -import org.springframework.stereotype.Service; - -/** - * @author ysj - */ -@Service -@Slf4j -@AllArgsConstructor -@DS("inspect") -public class PlanObjectTemplateServiceImpl extends BaseServiceImpl implements PlanObjectTemplateService { - -} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/PlanOrgServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/PlanOrgServiceImpl.java deleted file mode 100644 index 4606dad..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/PlanOrgServiceImpl.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.hnac.hzims.scheduled.service.inspect.impl; - -import com.hnac.hzims.scheduled.mapper.inspect.PlanOrgMapper; -import com.hnac.hzims.scheduled.service.inspect.PlanOrgService; -import com.hnac.hzinfo.inspect.plan.entity.PlanOrgEntity; -import org.springblade.core.mp.base.BaseServiceImpl; -import org.springframework.stereotype.Service; - -/** - * @author ysj - */ -@Service -public class PlanOrgServiceImpl extends BaseServiceImpl implements PlanOrgService { - -} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/PlanPositionServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/PlanPositionServiceImpl.java deleted file mode 100644 index 2cff9b7..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/PlanPositionServiceImpl.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.hnac.hzims.scheduled.service.inspect.impl; - -import com.baomidou.dynamic.datasource.annotation.DS; -import com.hnac.hzims.scheduled.mapper.inspect.PlanPositionMapper; -import com.hnac.hzims.scheduled.service.inspect.PlanPositionService; -import com.hnac.hzinfo.inspect.plan.entity.PlanPositionEntity; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.mp.base.BaseServiceImpl; -import org.springframework.stereotype.Service; - - -/** - * @author ysj - */ -@Service -@Slf4j -@AllArgsConstructor -@DS("inspect") -public class PlanPositionServiceImpl extends BaseServiceImpl implements PlanPositionService { - -} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/PlanUserServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/PlanUserServiceImpl.java deleted file mode 100644 index 6364750..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/PlanUserServiceImpl.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.hnac.hzims.scheduled.service.inspect.impl; - -import com.baomidou.dynamic.datasource.annotation.DS; -import com.hnac.hzims.scheduled.mapper.inspect.PlanUserMapper; -import com.hnac.hzims.scheduled.service.inspect.PlanUserService; -import com.hnac.hzinfo.inspect.plan.entity.PlanUserEntity; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.mp.base.BaseServiceImpl; -import org.springframework.stereotype.Service; - -/** - * @author ysj - */ -@Service -@Slf4j -@AllArgsConstructor -@DS("inspect") -public class PlanUserServiceImpl extends BaseServiceImpl implements PlanUserService { - -} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/ProjectContentServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/ProjectContentServiceImpl.java deleted file mode 100644 index d71a052..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/ProjectContentServiceImpl.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.hnac.hzims.scheduled.service.inspect.impl; - -import com.baomidou.dynamic.datasource.annotation.DS; -import com.hnac.hzims.scheduled.mapper.inspect.ProjectContentMapper; -import com.hnac.hzims.scheduled.service.inspect.ProjectContentService; -import com.hnac.hzinfo.inspect.obj.entity.ProjectContentEntity; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.mp.base.BaseServiceImpl; -import org.springframework.stereotype.Service; - - -/** - * @author ysj - */ -@Service -@Slf4j -@AllArgsConstructor -@DS("inspect") -public class ProjectContentServiceImpl extends BaseServiceImpl implements ProjectContentService { - -} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/ProjectServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/ProjectServiceImpl.java deleted file mode 100644 index 6da2ded..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/ProjectServiceImpl.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.hnac.hzims.scheduled.service.inspect.impl; - -import com.baomidou.dynamic.datasource.annotation.DS; -import com.hnac.hzims.scheduled.mapper.inspect.ProjectMapper; -import com.hnac.hzims.scheduled.service.inspect.ProjectService; -import com.hnac.hzinfo.inspect.obj.entity.ProjectEntity; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.mp.base.BaseServiceImpl; -import org.springframework.stereotype.Service; - - -/** - * @author ysj - */ -@Service -@Slf4j -@AllArgsConstructor -@DS("inspect") -public class ProjectServiceImpl extends BaseServiceImpl implements ProjectService { - -} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/TaskObjectProjectContentServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/TaskObjectProjectContentServiceImpl.java deleted file mode 100644 index f9eb13a..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/TaskObjectProjectContentServiceImpl.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.hnac.hzims.scheduled.service.inspect.impl; - -import com.baomidou.dynamic.datasource.annotation.DS; -import com.hnac.hzims.scheduled.mapper.inspect.TaskObjectProjectContentMapper; -import com.hnac.hzims.scheduled.service.inspect.TaskObjectProjectContentService; -import com.hnac.hzinfo.inspect.task.entity.TaskObjectProjectContentEntity; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.mp.base.BaseServiceImpl; -import org.springframework.stereotype.Service; - -/** - * @author ysj - */ -@Service -@Slf4j -@AllArgsConstructor -@DS("inspect") -public class TaskObjectProjectContentServiceImpl extends BaseServiceImpl implements TaskObjectProjectContentService { - -} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/TaskObjectProjectServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/TaskObjectProjectServiceImpl.java deleted file mode 100644 index 7eeaf59..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/TaskObjectProjectServiceImpl.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.hnac.hzims.scheduled.service.inspect.impl; - -import com.baomidou.dynamic.datasource.annotation.DS; -import com.hnac.hzims.scheduled.mapper.inspect.TaskObjectProjectMapper; -import com.hnac.hzims.scheduled.service.inspect.TaskObjectProjectService; -import com.hnac.hzinfo.inspect.task.entity.TaskObjectProjectEntity; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.mp.base.BaseServiceImpl; -import org.springframework.stereotype.Service; - -/** - * @author ysj - */ -@Service -@Slf4j -@AllArgsConstructor -@DS("inspect") -public class TaskObjectProjectServiceImpl extends BaseServiceImpl implements TaskObjectProjectService { - -} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/TaskObjectServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/TaskObjectServiceImpl.java deleted file mode 100644 index 6fdb9b1..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/TaskObjectServiceImpl.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.hnac.hzims.scheduled.service.inspect.impl; - -import com.baomidou.dynamic.datasource.annotation.DS; -import com.hnac.hzims.scheduled.mapper.inspect.TaskObjectMapper; -import com.hnac.hzims.scheduled.service.inspect.TaskObjectService; -import com.hnac.hzinfo.inspect.task.entity.TaskObjectEntity; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.mp.base.BaseServiceImpl; -import org.springframework.stereotype.Service; - -/** - * @author ysj - */ -@Service -@Slf4j -@AllArgsConstructor -@DS("inspect") -public class TaskObjectServiceImpl extends BaseServiceImpl implements TaskObjectService { - -} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/TaskPlanServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/TaskPlanServiceImpl.java deleted file mode 100644 index 9aaa84a..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/TaskPlanServiceImpl.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.hnac.hzims.scheduled.service.inspect.impl; - -import com.baomidou.dynamic.datasource.annotation.DS; -import com.hnac.hzims.scheduled.mapper.inspect.TaskPlanMapper; -import com.hnac.hzims.scheduled.service.inspect.TaskPlanService; -import com.hnac.hzinfo.inspect.plan.entity.PlanEntity; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.mp.base.BaseServiceImpl; -import org.springframework.stereotype.Service; - -/** - * @author ysj - */ -@Service -@Slf4j -@AllArgsConstructor -@DS("inspect") -public class TaskPlanServiceImpl extends BaseServiceImpl implements TaskPlanService { - -} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/TaskResultServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/TaskResultServiceImpl.java deleted file mode 100644 index 11f66c0..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/TaskResultServiceImpl.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.hnac.hzims.scheduled.service.inspect.impl; - -import com.baomidou.dynamic.datasource.annotation.DS; -import com.hnac.hzims.scheduled.mapper.inspect.TaskResultMapper; -import com.hnac.hzims.scheduled.service.inspect.TaskResultService; -import com.hnac.hzinfo.inspect.task.entity.TaskResultEntity; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.mp.base.BaseServiceImpl; -import org.springframework.stereotype.Service; - -/** - * @author ysj - */ -@Service -@Slf4j -@AllArgsConstructor -@DS("inspect") -public class TaskResultServiceImpl extends BaseServiceImpl implements TaskResultService { - -} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/TaskServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/TaskServiceImpl.java index 8a47963..a0f0c99 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/TaskServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/TaskServiceImpl.java @@ -1,45 +1,17 @@ package com.hnac.hzims.scheduled.service.inspect.impl; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.google.common.collect.Lists; -import com.hnac.hzims.operational.duty.vo.ImsDutyMainFeignVO; import com.hnac.hzims.scheduled.mapper.inspect.TaskMapper; -import com.hnac.hzims.scheduled.service.inspect.*; -import com.hnac.hzims.scheduled.service.operation.business.DutyMainService; -import com.hnac.hzinfo.inspect.obj.entity.*; -import com.hnac.hzinfo.inspect.plan.PlanContants; -import com.hnac.hzinfo.inspect.plan.entity.*; -import com.hnac.hzinfo.inspect.task.TaskContants; -import com.hnac.hzinfo.inspect.task.entity.*; +import com.hnac.hzims.scheduled.service.inspect.TaskService; +import com.hnac.hzinfo.inspect.task.entity.TaskEntity; import com.hnac.hzinfo.inspect.task.vo.DutyInspectTaskVO; -import com.xxl.job.core.log.XxlJobLogger; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.springblade.core.log.exception.ServiceException; import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.tool.utils.CollectionUtil; -import org.springblade.core.tool.utils.DateUtil; -import org.springblade.core.tool.utils.Func; -import org.springblade.core.tool.utils.ObjectUtil; -import org.springblade.system.user.entity.User; -import org.springblade.system.user.feign.IUserClient; import org.springframework.stereotype.Service; -import java.time.DayOfWeek; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import java.time.temporal.WeekFields; -import java.util.ArrayList; -import java.util.LinkedList; import java.util.List; import java.util.stream.Collectors; @@ -52,687 +24,6 @@ import java.util.stream.Collectors; @DS("inspect") public class TaskServiceImpl extends BaseServiceImpl implements TaskService { - private final TaskPlanService planService; - - private final ObjectService objectService; - - private final PlanOrgService planOrgService; - - private final ContentService contentService; - - private final ProjectService projectService; - - private final TemplateService templateService; - - private final DutyMainService dutyMainService; - - private final PlanUserService planUserService; - - private final TaskUserService taskUserService; - - private final ObjectUserService objectUserService; - - private final TaskResultService taskResultService; - - private final TaskObjectService taskObjectService; - - private final PlanPositionService planPostionService; - - private final ProjectContentService projectContentService; - - private final TemplateProjectService templateProjectService; - - private final TaskObjectProjectService taskObjectProjectService; - - private final PlanObjectTemplateService planObjectTemplateService; - - private final TaskObjectProjectContentService taskObjectProjectContentService; - - private final TaskVideoManager taskVideoManager; - - private final TaskRemindManager remindCacheManager; - - private final IUserClient userClient; - - /** - * 巡检任务派发 - * @param param - */ - @Override - public void inspectTaskDistribute(String param) { - // 清理无效任务 - this.close(); - - // 派发任务状态前置修改 - this.status(); - - // 遍历派发任务 - this.distribute(); - } - - - /** - * 清理无效任务 - */ - private void close() { - // 关闭超过计划结束时间 、已审核 、派发中的巡检计划 - UpdateWrapper plan = new UpdateWrapper<>(); - plan.lambda().set(PlanEntity::getStatus, Integer.valueOf(PlanContants.PlanStatusEnum.FINISH_STATUS.getStatus())) - .in(PlanEntity::getStatus, Integer.valueOf(PlanContants.PlanStatusEnum.PAUSE_STATUS.getStatus()), Integer.valueOf(PlanContants.PlanStatusEnum.CHECK_STATUS.getStatus()), Integer.valueOf(PlanContants.PlanStatusEnum.UNDERWAY_STATUS.getStatus())) - .lt(PlanEntity::getEndTime, LocalDate.now()); - this.planService.update(plan); - //关闭超过计划结束时间的巡检任务 - UpdateWrapper task = new UpdateWrapper<>(); - task.lambda().set(TaskEntity::getStatus, Integer.valueOf(TaskContants.TaskStatusEnum.UNFINISH_STATUS.getStatus())) - .ne(TaskEntity::getStatus, Integer.valueOf(TaskContants.TaskStatusEnum.FINISH_STATUS.getStatus())) - .lt(TaskEntity::getPlanEndTime, LocalDate.now()); - this.update(task); - } - - /** - * 派发状态前置 : 已审核计划 且 已过计划开始时间 - */ - private void status() { - UpdateWrapper plan = new UpdateWrapper<>(); - plan.lambda().set(PlanEntity::getStatus, Integer.valueOf(PlanContants.PlanStatusEnum.UNDERWAY_STATUS.getStatus())) - .eq(PlanEntity::getStatus, Integer.valueOf(PlanContants.PlanStatusEnum.CHECK_STATUS.getStatus())) - .le(PlanEntity::getStartTime, LocalDate.now()); - this.planService.update(plan); - } - - /** - * 派发任务 - */ - private void distribute() { - // 查询需要派发任务列表 - List plans = planService.list(Wrappers.lambdaQuery() - .eq(PlanEntity::getStatus,Integer.valueOf(PlanContants.PlanStatusEnum.UNDERWAY_STATUS.getStatus()))); - if(CollectionUtil.isEmpty(plans)){ - return; - } - plans.forEach(plan->{ - if(PlanContants.PlanCycleEnum.NEVER_CYCLE.getCycle().equals(plan.getCycle())){//计划周期每次,只需要派发一次任务 - plan.setStatus(Integer.valueOf(PlanContants.PlanStatusEnum.FINISH_STATUS.getStatus())); - this.planService.updateById(plan); - } - if(PlanContants.PlanMethodEnum.SEIZE.getMethod().equals(plan.getMethod())){ - // 抢占模式 - this.seize(plan); - }else if(PlanContants.PlanMethodEnum.CONCURRENT.getMethod().equals(plan.getMethod())){ - // 并发模式 - this.concurrent(plan); - } - }); - } - - - /** - * 抢占模式 - * @param plan - */ - private void seize(PlanEntity plan) { - // 计划班次模式 - if("4".equals(plan.getType())){ - this.seizeClass(plan); - } - // 其他模式 - this.seizeOther(plan); - } - - /** - * 并发模式 - * @param plan - */ - private void concurrent(PlanEntity plan) { - // 计划班次模式 - if("4".equals(plan.getType())){ - this.concurrentClass(plan); - } - // 其他模式 - this.concurrentOther(plan); - } - - /** - * 抢占-班次模式 - * @param plan - */ - private void seizeClass(PlanEntity plan) { - List taskUserList = Lists.newArrayList(); - - if(Func.isEmpty(plan.getExecTimeJson())){ - XxlJobLogger.log("seizeClass_巡检计划未设置值班班次: plan = " + plan); - return; - } - JSONArray array = JSONArray.parseArray(plan.getExecTimeJson()); - for (int index = 0; index < plan.getTaskTimesADay(); index++) { - // 取巡检任务执行开始、结束时间、是否下一天 - JSONObject time = array.getJSONObject(index); - plan.setExecStartTime(time.get("execStartTime").toString()); - plan.setExecEndTime(time.get("execEndTime").toString()); - if(time.containsKey("isNextDay")){ - plan.setIsNextDay(time.getBoolean("isNextDay")); - } - // 保存巡检任务 - TaskEntity task = this.saveTask(plan,1); - if(ObjectUtil.isEmpty(task) || !time.containsKey("classId")){ - XxlJobLogger.log("seizeClass_任务执行时间json数据不包含classId"); - continue; - } - // 查询值班数据 - ImsDutyMainFeignVO main = dutyMainService.mainPerson(time.getLong("classId"), DateUtil.format(LocalDate.now(),DateUtil.PATTERN_DATE)); - if(ObjectUtil.isNotEmpty(main) && CollectionUtil.isNotEmpty(main.getPersons())){ - plan.setDutyId(main.getMainId()); - main.getPersons().forEach(persons->{ - // 任务用户关联记录 - TaskUserEntity taskUser = TaskUserEntity.builder().taskId(task.getId()).userId(persons).claimStatus(TaskContants.ClaimStatusEnum.UN_COLLECT.getStatus()).build(); - taskUser.setTenantId(plan.getTenantId()); - taskUserList.add(taskUser); - //添加到提醒cache - task.setUserId(persons); - remindCacheManager.addTaskToCacheList(task); - taskVideoManager.addTaskToVideoCacheList(task); - }); - } - String reason = this.saveTaskObject(plan,task); - if(reason.equals(StringUtils.EMPTY)){ - LocalDateTime now = LocalDateTime.now(); - reason = plan.getName() + now.getYear() + "年" + now.getMonthValue() + "月" + now.getDayOfMonth() + "日的任务派发成功"; - } - XxlJobLogger.log(reason); - TaskResultEntity taskResultEntity = TaskResultEntity.builder().planId(task.getPlanId()).batchNumber(task.getBatchNumber()).reason(reason).build(); - taskResultEntity.setTenantId(plan.getTenantId()); - taskResultService.save(taskResultEntity); - } - if(taskUserList.size()>0){ - taskUserService.saveBatch(taskUserList); - } - } - - - /** - * 抢占-其他模式 - * @param plan - */ - private void seizeOther(PlanEntity plan) { - List users = this.getUsersByPlan(plan); - List taskUserList = Lists.newArrayList(); - - JSONArray timeJsonArray = null; - if(Func.isNotEmpty(plan.getExecTimeJson())){ - timeJsonArray = JSON.parseArray(plan.getExecTimeJson()); - } - for (int j = 0; j < plan.getTaskTimesADay(); j++) { - if(Func.isNotEmpty(timeJsonArray)){ - JSONObject time = timeJsonArray.getJSONObject(j); - plan.setExecStartTime(time.get("execStartTime").toString()); - plan.setExecEndTime(time.get("execEndTime").toString()); - if(time.containsKey("isNextDay")){ - plan.setIsNextDay(time.getBoolean("isNextDay")); - } - } else { - plan.setExecStartTime("00:00:00"); - plan.setExecEndTime("23:59:59"); - } - TaskEntity task = this.saveTask(plan,1); - if(task==null){continue;} - for(PlanUserEntity user:users){ - TaskUserEntity taskUser = TaskUserEntity.builder().taskId(task.getId()).userId(user.getUserId()).claimStatus(TaskContants.ClaimStatusEnum.UN_COLLECT.getStatus()).build(); - taskUser.setTenantId(plan.getTenantId()); - taskUserList.add(taskUser); - //添加到提醒cache - task.setUserId(user.getUserId()); - remindCacheManager.addTaskToCacheList(task); - taskVideoManager.addTaskToVideoCacheList(task); - } - String reason = this.saveTaskObject(plan,task); - if(reason.equals(StringUtils.EMPTY)){ - LocalDateTime now = LocalDateTime.now(); - reason = plan.getName() + now.getYear() + "年" + now.getMonthValue() + "月" + now.getDayOfMonth() + "日的任务派发成功"; - } - XxlJobLogger.log(reason); - TaskResultEntity taskResultEntity = TaskResultEntity.builder().planId(task.getPlanId()).batchNumber(task.getBatchNumber()).reason(reason).build(); - taskResultEntity.setTenantId(plan.getTenantId()); - taskResultService.save(taskResultEntity); - } - - if(taskUserList.size()>0){ - taskUserService.saveBatch(taskUserList); - } else { - XxlJobLogger.log("没有用户: plan = " + plan); - XxlJobLogger.log("SeizeTaskService...没有任务用户: plan = " + plan); - } - } - - - /** - * 并发-班次模式 - * @param plan - */ - private void concurrentClass(PlanEntity plan) { - List taskUserList = Lists.newArrayList(); - - LocalDateTime now = LocalDateTime.now(); - String defaultReason = plan.getName() + now.getYear() + "年" + now.getMonthValue() + "月" + now.getDayOfMonth() + "日的任务派发成功"; - JSONArray timeJsonArray; - if (Func.isNotEmpty(plan.getExecTimeJson())) { - timeJsonArray = JSON.parseArray(plan.getExecTimeJson()); - } else { - XxlJobLogger.log("巡检计划未设置值班班次: plan = " + plan); - return; - } - for (int j = 0; j < plan.getTaskTimesADay(); j++) { - JSONObject time = timeJsonArray.getJSONObject(j); - plan.setExecStartTime(time.get("execStartTime").toString()); - plan.setExecEndTime(time.get("execEndTime").toString()); - if (time.containsKey("isNextDay")) { - plan.setIsNextDay(time.getBoolean("isNextDay")); - } - - //获取值班用户 - if (time.containsKey("classId")) { - Long classId = time.getLong("classId"); - DateTimeFormatter dfShort = DateTimeFormatter.ofPattern("yyyy-MM-dd"); - ImsDutyMainFeignVO mainPerson = dutyMainService.mainPerson(classId, dfShort.format(LocalDate.now())); - List ids = mainPerson.getPersons(); - plan.setDutyId(mainPerson.getMainId()); - if (Func.isNotEmpty(ids)) { - for (Long id : ids) { - TaskEntity task = saveTask(plan, ids.size()); - if (task == null) { - continue; - } - TaskUserEntity taskUser = TaskUserEntity.builder().taskId(task.getId()).userId(id).claimStatus(TaskContants.ClaimStatusEnum.UN_COLLECT.getStatus()).build(); - taskUser.setTenantId(plan.getTenantId()); - taskUserList.add(taskUser); - String reason = saveTaskObject(plan, task); - if (reason.equals(StringUtils.EMPTY)) { - reason = defaultReason; - } - - XxlJobLogger.log(reason); - TaskResultEntity taskResultEntity = TaskResultEntity.builder().planId(task.getPlanId()).batchNumber(task.getBatchNumber()).reason(reason).build(); - taskResultEntity.setTenantId(plan.getTenantId()); - taskResultService.save(taskResultEntity); - - //添加到提醒cache - task.setUserId(id); - remindCacheManager.addTaskToCacheList(task); - taskVideoManager.addTaskToVideoCacheList(task); - } - } else { - XxlJobLogger.log("获取该班次值班人员为空, plan = " + plan); - return; - } - } else { - XxlJobLogger.log("巡检计划未设置值班班次, plan = " + plan); - return; - } - } - if (taskUserList.size() > 0) { - taskUserService.saveBatch(taskUserList); - } - } - - /** - * 并发其他模式 - * @param plan - */ - private void concurrentOther(PlanEntity plan) { - LocalDateTime now = LocalDateTime.now(); - String defaultReason = plan.getName() + now.getYear() + "年" + now.getMonthValue() + "月" + now.getDayOfMonth() + "日的任务派发成功"; - List users = this.getUsersByPlan(plan); - List taskUserList = Lists.newArrayList(); - - JSONArray timeJsonArray = null; - if (Func.isNotEmpty(plan.getExecTimeJson())) { - timeJsonArray = JSON.parseArray(plan.getExecTimeJson()); - } - for (PlanUserEntity user : users) { - for (int j = 0; j < plan.getTaskTimesADay(); j++) { - if (Func.isNotEmpty(timeJsonArray)) { - JSONObject time = timeJsonArray.getJSONObject(j); - plan.setExecStartTime(time.get("execStartTime").toString()); - plan.setExecEndTime(time.get("execEndTime").toString()); - if (time.containsKey("isNextDay")) { - plan.setIsNextDay(time.getBoolean("isNextDay")); - } - } else { - plan.setExecStartTime("00:00:00"); - plan.setExecEndTime("23:59:59"); - } - TaskEntity task = saveTask(plan, users.size()); - if (task == null) { - continue; - } - TaskUserEntity taskUser = TaskUserEntity.builder().taskId(task.getId()).userId(user.getId()).claimStatus(TaskContants.ClaimStatusEnum.UN_COLLECT.getStatus()).build(); - taskUser.setTenantId(plan.getTenantId()); - taskUserList.add(taskUser); - String reason = saveTaskObject(plan, task); - if (reason.equals(StringUtils.EMPTY)) { - reason = defaultReason; - } - XxlJobLogger.log(reason); - - TaskResultEntity taskResultEntity = TaskResultEntity.builder().planId(task.getPlanId()).batchNumber(task.getBatchNumber()).reason(reason).build(); - taskResultEntity.setTenantId(plan.getTenantId()); - taskResultService.save(taskResultEntity); - - //添加到提醒cache - task.setUserId(user.getUserId()); - remindCacheManager.addTaskToCacheList(task); - taskVideoManager.addTaskToVideoCacheList(task); - } - } - if (taskUserList.size() > 0) { - taskUserService.saveBatch(taskUserList); - } else { - log.error("ConcurrentTaskServcie...没有任务用户: plan = " + plan); - XxlJobLogger.log("ConcurrentTaskServcie...没有任务用户: plan = " + plan); - } - } - - /** - * 根据巡检计划返回与计划有关的所有用户 - * @param plan 巡检计划实例 - * @return 计划相关用户集合 - */ - public List getUsersByPlan(PlanEntity plan) { - List res = new LinkedList<>(); - if(PlanContants.PlanTypeEnum.USER_TYPE.getType().equals(plan.getType()) || PlanContants.PlanTypeEnum.FREE_TYPE.getType().equals(plan.getType())){ - QueryWrapper planUserQw = new QueryWrapper<>(); - planUserQw.lambda().eq(PlanUserEntity::getPlanId, plan.getId()); - res.addAll(planUserService.list(planUserQw)); - }else if(PlanContants.PlanTypeEnum.POSITION_TYPE.getType().equals(plan.getType())){ - QueryWrapper planPositionEntityQueryWrapper = new QueryWrapper<>(); - planPositionEntityQueryWrapper.lambda().eq(PlanPositionEntity::getPlanId, plan.getId()); - planPostionService.list(planPositionEntityQueryWrapper).forEach(entity->{ - //获取该机构下所有用户列表 - List users = new ArrayList<>(); - List positionUsers = userClient.userListByPosition(entity.getPositionId()).getData(); - if(CollectionUtil.isNotEmpty(positionUsers)){ - users = positionUsers.stream().filter(user->user.getCreateDept().toString().contains(entity.getCreateDept().toString())).collect(Collectors.toList()); - } - XxlJobLogger.log("岗位信息:" + entity + "; 获取到的user:{}",users.stream().map(User::getName).collect(Collectors.joining(","))); - for(User u:users){ - res.add(PlanUserEntity.builder().planId(plan.getId()).userId(u.getId()).build()); - } - }); - }else if(PlanContants.PlanTypeEnum.ORG_TYPE.getType().equals(plan.getType())){ - QueryWrapper planOrgEntityQueryWrapper = new QueryWrapper<>(); - planOrgEntityQueryWrapper.lambda().eq(PlanOrgEntity::getPlanId, plan.getId()); - planOrgService.list(planOrgEntityQueryWrapper).forEach(entity->{ - List users = userClient.userListByDeptId(entity.getOrgId()).getData(); - for(User u:users){ - res.add(PlanUserEntity.builder().planId(plan.getId()).userId(u.getId()).build()); - } - }); - }else if(PlanContants.PlanTypeEnum.CLASS_TYPE.getType().equals(plan.getType())){ - XxlJobLogger.log("巡检计划为班次时,有单独的处理流程,不应该跑到该分支下面来, plan = " + plan); - JSONArray timeJsonArray; - if(Func.isNotEmpty(plan.getExecTimeJson())){ - timeJsonArray = JSON.parseArray(plan.getExecTimeJson()); - } - else{ - throw new ServiceException("巡检计划未设置值班班次: plan = " + plan); - } - for(int i=0;i ids = mainPerson.getPersons(); - log.info("--计划为:{};人员ID为:{}--",plan.getName(),ids.stream().map(String::valueOf).collect(Collectors.joining(","))); - plan.setDutyId(mainPerson.getMainId()); - if(Func.isNotEmpty(ids)){ - for (Long id : ids) { - res.add(PlanUserEntity.builder().planId(plan.getId()).userId(id).build()); - } - } else { - XxlJobLogger.log("获取该班次值班人员为空, plan = " + plan); - } - } - } - } - //设置租户 - return res.stream().distinct().peek(entity-> entity.setTenantId(plan.getTenantId())).collect(Collectors.toList()); - } - - /** - * 保存巡检任务 - * @param plan 巡检计划 - * @param totalTaskNum 任务数 : 抢占任务只生成一个 - * @return 巡检任务实例 - */ - public TaskEntity saveTask(PlanEntity plan,int totalTaskNum) { - totalTaskNum = plan.getTaskTimesADay() * totalTaskNum; - TaskEntity task = new TaskEntity(); - LocalDate now = LocalDate.now(); - DateTimeFormatter dfShort = DateTimeFormatter.ofPattern("yyyy-MM-dd "); - DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); - - if(PlanContants.PlanCycleEnum.NEVER_CYCLE.getCycle().equals(plan.getCycle())) { - task.setBatchNumber(now.getYear()+ "_" +now.getMonthValue()+ "_" +now.getDayOfMonth() + "N"); - task.setPlanEndTime(LocalDateTime.parse(dfShort.format(plan.getEndTime())+plan.getExecEndTime(), df)); - }else if(PlanContants.PlanCycleEnum.EVERYDAY_CYCLE.getCycle().equals(plan.getCycle())) { - task.setBatchNumber(now.getYear()+ "_" +now.getMonthValue()+ "_" +now.getDayOfMonth()); - if(Func.isNotEmpty(plan.getIsNextDay()) && plan.getIsNextDay()){ - task.setPlanEndTime(LocalDateTime.parse(dfShort.format(now.plusDays(1L)) + plan.getExecEndTime(), df)); - } else { - task.setPlanEndTime(LocalDateTime.parse(dfShort.format(now) + plan.getExecEndTime(), df)); - } - }else if(PlanContants.PlanCycleEnum.EVERYWEEK_CYCLE.getCycle().equals(plan.getCycle())) { - WeekFields weekFields = WeekFields.of(DayOfWeek.MONDAY,1); - int weeks = now.get(weekFields.weekOfYear()); - task.setBatchNumber(now.getYear()+ "_" +now.getMonthValue() + "_" +weeks + "W"); - task.setPlanEndTime(LocalDateTime.parse(dfShort.format(now.plusWeeks(1)) + plan.getExecEndTime(), df)); - }else if(PlanContants.PlanCycleEnum.EVERYMONTH_CYCLE.getCycle().equals(plan.getCycle())) { - task.setBatchNumber(now.getYear()+ "_" +now.getMonthValue()); - task.setPlanEndTime(LocalDateTime.parse(dfShort.format(now.plusMonths(1))+plan.getExecEndTime(), df)); - }else if(PlanContants.PlanCycleEnum.EVERYQUARTER_CYCLE.getCycle().equals(plan.getCycle())) { - task.setBatchNumber(now.getYear()+ "_" +now.getMonthValue() + "Q"); - task.setPlanEndTime(LocalDateTime.parse(dfShort.format(now.plusMonths(3)) + plan.getExecEndTime(), df)); - }else if(PlanContants.PlanCycleEnum.EVERYYEAR_CYCLE.getCycle().equals(plan.getCycle())){ - task.setBatchNumber(String.valueOf(now.getYear())); - task.setPlanEndTime(LocalDateTime.parse(dfShort.format(now.plusYears(1))+plan.getExecEndTime(), df)); - } - if(PlanContants.PlanCycleEnum.NEVER_CYCLE.getCycle().equals(plan.getCycle())) { - task.setPlanStartTime(LocalDateTime.parse(dfShort.format(plan.getStartTime()) + plan.getExecStartTime(), df)); - } else { - task.setPlanStartTime(LocalDateTime.parse(dfShort.format(now) + plan.getExecStartTime(), df)); - } - task.setDutyId(plan.getDutyId()); - task.setPlanId(plan.getId()); - task.setPlanName(plan.getName()); - task.setType(plan.getType()); - task.setCycle(plan.getCycle()); - task.setStatus(Integer.valueOf(TaskContants.TaskStatusEnum.INIT_STATUS.getStatus())); - task.setTenantId(plan.getTenantId()); - task.setCreateUser(plan.getCreateUser()); - task.setCreateDept(plan.getCreateDept()); - task.setAutoVideo(plan.getAutoVideo()); - task.setMessageTemplateId(plan.getMessageTemplateId()); - task.setMethod(plan.getMethod()); - task.setEndRemindFlag(true); - task.setStartRemindFlag(true); - task.setStartRemindTime(task.getPlanStartTime().minusMinutes(plan.getStartRemind())); - task.setEndRemindTime(task.getPlanEndTime().minusMinutes(plan.getEndRemind())); - int taskCount = this.count(Wrappers.query().lambda().eq(TaskEntity::getPlanId,task.getPlanId()).eq(TaskEntity::getBatchNumber, task.getBatchNumber())); - XxlJobLogger.log("该计划已生成计划批次:{},数量:{}",task.getBatchNumber(),taskCount); - if(taskCount >= totalTaskNum){ - log.info("计划id={}本周期batchNumber={}的任务已生成",plan.getId(),task.getBatchNumber()); - return null; - } - this.save(task); - return task; - } - - /** - * 保存巡检对象数据 - * @param plan 巡检计划实例 - * @param task 巡检任务实例 - * @return - */ - public String saveTaskObject(PlanEntity plan, TaskEntity task) { - String result = StringUtils.EMPTY; - List taskObjectList = Lists.newArrayList(); - // 自由模式 - if(PlanContants.PlanTypeEnum.FREE_TYPE.getType().equals(plan.getType())){ - // 查询计划用户 - List planUsers = planUserService.list(Wrappers.query().lambda().eq(PlanUserEntity::getPlanId,plan.getId())); - if(CollectionUtil.isEmpty(planUsers)){ - return result; - } - for(PlanUserEntity planUser : planUsers){ - // 查询巡检对象用户 - List objectUsers= objectUserService.list(Wrappers.query().lambda().eq(ObjectUserEntity::getUserId,planUser.getUserId())); - if(CollectionUtil.isEmpty(objectUsers)){ - break; - } - for (ObjectUserEntity objectUser : objectUsers){ - List existEntity = taskObjectList.stream().filter(taskObjectEntity -> objectUser.getObjectId().equals(taskObjectEntity.getObjectId())).collect(Collectors.toList()); - if(ObjectUtil.isNotEmpty(existEntity)){ - break; - } - // 保存巡检对象 - result = saveTaskObject(taskObjectList,task,objectUser.getObjectId(),objectUser.getTemplateId()); - if(!result.equals(StringUtils.EMPTY)){ - break; - } - } - } - }else{ - List templates = planObjectTemplateService.list(Wrappers.query().lambda().eq(PlanObjectTemplateEntity::getPlanId,plan.getId())); - for (PlanObjectTemplateEntity template : templates) { - result = saveTaskObject(taskObjectList,task,template.getObjectId(),template.getTemplateId()); - if(!result.equals(StringUtils.EMPTY)){ - break; - } - } - } - if(taskObjectList.size()>0 && result.equals(StringUtils.EMPTY)){ - taskObjectService.saveBatch(taskObjectList); - } - return result; - } - - /** - * 保存巡检对象 - * @param taskObjectList - * @param task - * @param objectId - * @param templateId - * @return - */ - private String saveTaskObject(List taskObjectList,TaskEntity task,Long objectId,Long templateId){ - String result = StringUtils.EMPTY; - ObjectEntity io = objectService.getById(objectId); - if(io == null) { - return "巡检对象id="+objectId+"找不到记录"; - } - TemplateEntity templateInfo = templateService.getById(templateId); - if(templateInfo == null) { - return "巡检模板id="+templateId+"找不到记录"; - } - TaskObjectEntity ito = new TaskObjectEntity(); - ito.setTaskId(task.getId()); - ito.setObjectId(objectId); - ito.setCode(io.getCode()); - ito.setName(io.getName()); - ito.setAddress(io.getAddress()); - ito.setLttd(io.getLttd()); - ito.setLgtd(io.getLgtd()); - ito.setCreateUser(task.getCreateUser()); - ito.setCreateDept(task.getCreateDept()); - ito.setCreateTime(task.getCreateTime()); - ito.setDuplicateRecord(templateInfo.getDuplicateRecord()); - ito.setTenantId(task.getTenantId()); - ito.setStatus(TaskContants.StatusEnum.INIT_STATUS.getStatus()); - taskObjectList.add(ito); - List projects = templateProjectService.list(Wrappers.query().lambda().eq(TemplateProjectEntity::getTemplateId,templateId)); - for (TemplateProjectEntity project : projects) { - result = saveTaskObjectProject(task, objectId, project); - if(!result.equals(StringUtils.EMPTY)){ - break; - } - } - return result; - } - - /** - * 从巡检任务、巡检计划对象模板、巡检模板项目获取信息插入巡检任务项目表以及对应的历史数据表 - * @param objectId 巡检计划对象模板实例 - * @param project 巡检模板项目实例 - * @return - */ - private String saveTaskObjectProject(TaskEntity task, Long objectId, TemplateProjectEntity project) { - String result = StringUtils.EMPTY; - ProjectEntity ip = projectService.getById(project.getProjectId()); - if(ip == null) { - return "巡检项目id="+project.getProjectId()+"找不到记录"; - } - TaskObjectProjectEntity itop = new TaskObjectProjectEntity(); - itop.setObjectId(objectId); - itop.setProjectId(ip.getId()); - itop.setTaskId(task.getId()); - itop.setName(ip.getName()); - itop.setCode(ip.getCode()); - itop.setDescription(ip.getDescription()); - itop.setCreateTime(project.getCreateTime()); - itop.setTenantId(task.getTenantId()); - itop.setCreateUser(task.getCreateUser()); - itop.setCreateDept(task.getCreateDept()); - itop.setStatus(TaskContants.StatusEnum.INIT_STATUS.getStatus()); - taskObjectProjectService.save(itop); - List contents = projectContentService.list(Wrappers.query().lambda().eq(ProjectContentEntity::getProjectId,project.getProjectId())); - for (ProjectContentEntity content : contents) { - result = saveTaskObjectProjectContent(task, objectId, content); - if(!result.equals(StringUtils.EMPTY)){ - break; - } - } - return result; - } - - /** - * 从巡检任务、巡检计划对象模板、巡检项目内容获取信息插入巡检任务内容表以及对应的历史数据表 - * @param objectId 巡检计划对象模板实例 - * @param content 巡检项目内容实例 - * @return - */ - private String saveTaskObjectProjectContent(TaskEntity task, Long objectId, ProjectContentEntity content) { - ContentEntity ioc = contentService.getById(content.getContentId()); - if(ioc == null) {return "巡检内容id="+content.getContentId()+"找不到记录";} - TaskObjectProjectContentEntity itopc = new TaskObjectProjectContentEntity(); - itopc.setTaskId(task.getId()); - itopc.setObjectId(objectId); - itopc.setProjectId(content.getProjectId()); - itopc.setContentId(content.getContentId()); - itopc.setCode(ioc.getCode()); - itopc.setName(ioc.getName()); - itopc.setDescription(ioc.getDescription()); - itopc.setCheckType(ioc.getCheckType()); - itopc.setRecordType(ioc.getRecordType()); - itopc.setCreateTime(content.getCreateTime()); - itopc.setTenantId(task.getTenantId()); - itopc.setCreateUser(task.getCreateUser()); - itopc.setCreateDept(task.getCreateDept()); - itopc.setCheckTypeSon(ioc.getCheckTypeSon()); - itopc.setCameraAddr(ioc.getCameraAddr()); - itopc.setCameraId(ioc.getCameraId()); - itopc.setClockId(ioc.getClockId()); - itopc.setOtherParam(ioc.getOtherParam()); - itopc.setStatus(TaskContants.StatusEnum.INIT_STATUS.getStatus()); - itopc.setDictType(ioc.getDictType()); - taskObjectProjectContentService.save(itopc); - return StringUtils.EMPTY; - } - /** * 时间区间机构的巡检任务数据查询 * @param start diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/TaskUserServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/TaskUserServiceImpl.java deleted file mode 100644 index baf26c8..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/TaskUserServiceImpl.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.hnac.hzims.scheduled.service.inspect.impl; - -import com.baomidou.dynamic.datasource.annotation.DS; -import com.hnac.hzims.scheduled.mapper.inspect.TaskUserMapper; -import com.hnac.hzims.scheduled.service.inspect.TaskUserService; -import com.hnac.hzinfo.inspect.task.entity.TaskUserEntity; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.mp.base.BaseServiceImpl; -import org.springframework.stereotype.Service; - -import java.util.List; - -/** - * @author ysj - */ -@Service -@Slf4j -@AllArgsConstructor -@DS("inspect") -public class TaskUserServiceImpl extends BaseServiceImpl implements TaskUserService { - -} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/TemplateProjectServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/TemplateProjectServiceImpl.java deleted file mode 100644 index f970386..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/TemplateProjectServiceImpl.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.hnac.hzims.scheduled.service.inspect.impl; - -import com.baomidou.dynamic.datasource.annotation.DS; -import com.hnac.hzims.scheduled.mapper.inspect.TemplateProjectMapper; -import com.hnac.hzims.scheduled.service.inspect.TemplateProjectService; -import com.hnac.hzinfo.inspect.obj.entity.TemplateProjectEntity; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.mp.base.BaseServiceImpl; -import org.springframework.stereotype.Service; - -/** - * @author ysj - */ -@Service -@Slf4j -@AllArgsConstructor -@DS("inspect") -public class TemplateProjectServiceImpl extends BaseServiceImpl implements TemplateProjectService { - -} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/TemplateServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/TemplateServiceImpl.java deleted file mode 100644 index f4b5b41..0000000 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/inspect/impl/TemplateServiceImpl.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.hnac.hzims.scheduled.service.inspect.impl; - -import com.baomidou.dynamic.datasource.annotation.DS; -import com.hnac.hzims.scheduled.mapper.inspect.TemplateMapper; -import com.hnac.hzims.scheduled.service.inspect.TemplateService; -import com.hnac.hzinfo.inspect.obj.entity.TemplateEntity; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.mp.base.BaseServiceImpl; -import org.springframework.stereotype.Service; - -/** - * @author ysj - */ -@Service -@Slf4j -@AllArgsConstructor -@DS("inspect") -public class TemplateServiceImpl extends BaseServiceImpl implements TemplateService { -} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/business/MaintenanceService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/business/MaintenanceService.java index 2e2de53..963d895 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/business/MaintenanceService.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/business/MaintenanceService.java @@ -13,8 +13,6 @@ import java.util.List; */ public interface MaintenanceService extends BaseService { - void maintenanceTaskDistribute(String param); - Integer maintenanceCount(List areas); MaintainVo maintain(String start, String end, List areas); diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/business/impl/MaintenanceServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/business/impl/MaintenanceServiceImpl.java index b2597db..fd7c052 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/business/impl/MaintenanceServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/business/impl/MaintenanceServiceImpl.java @@ -1,44 +1,23 @@ package com.hnac.hzims.scheduled.service.operation.business.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.hnac.hzims.message.dto.PlanMsgRecordDto; -import com.hnac.hzims.message.entity.config.MessageTemplateEntity; -import com.hnac.hzims.message.fegin.IMessageClient; -import com.hnac.hzims.operational.duty.entity.ImsDutyMainEntity; import com.hnac.hzims.operational.main.vo.MaintainVo; import com.hnac.hzims.operational.main.vo.RegularWorkVO; -import com.hnac.hzims.operational.maintenance.constants.MaintenanceConstant; -import com.hnac.hzims.operational.maintenance.entity.OperMaintenancePlanEntity; import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity; -import com.hnac.hzims.operational.maintenance.vo.OperMaintenanceTaskEntityVo; import com.hnac.hzims.scheduled.mapper.operation.MaintenanceMapper; -import com.hnac.hzims.scheduled.service.operation.business.MaintenancePlanService; import com.hnac.hzims.scheduled.service.operation.business.MaintenanceService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang.StringUtils; import org.springblade.core.mp.base.BaseServiceImpl; -import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.*; -import org.springblade.flow.core.feign.IFlowClient; -import org.springframework.beans.BeanUtils; -import org.springframework.jdbc.datasource.DataSourceTransactionManager; +import org.springblade.core.tool.utils.CollectionUtil; import org.springframework.stereotype.Service; -import org.springframework.transaction.TransactionDefinition; -import org.springframework.transaction.TransactionStatus; -import org.springframework.transaction.support.DefaultTransactionDefinition; -import java.beans.Transient; -import java.time.*; -import java.time.format.DateTimeFormatter; -import java.util.*; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ThreadPoolExecutor; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.util.Date; +import java.util.List; import java.util.stream.Collectors; -import java.util.stream.Stream; - -import static org.springblade.core.tool.utils.DateUtil.PATTERN_DATE; /** * @author ysj @@ -48,157 +27,6 @@ import static org.springblade.core.tool.utils.DateUtil.PATTERN_DATE; @Slf4j public class MaintenanceServiceImpl extends BaseServiceImpl implements MaintenanceService { - private final MaintenancePlanService planService; - - private final DutyMainServiceImpl dutyMainService; - - private final IFlowClient flowClient; - - private final IMessageClient messageClient; - - private final DataSourceTransactionManager manager; - - private final ThreadPoolExecutor executor; - - /** - * 日常维护任务派发 - * @param param - */ - @Override - @Transient - public void maintenanceTaskDistribute(String param) { - // 开始时间 - Date start = DateUtil.parse(DateUtil.formatDate(DateUtil.now()), DateUtil.PATTERN_DATE); - // 结束时间 - Date end = DateUtil.parse(DateUtil.formatDate(DateUtil.plusDays(start, 1)), DateUtil.PATTERN_DATE); - // 查询日常维护计划 - List plans = planService.list(Wrappers.lambdaQuery() - .ge(OperMaintenancePlanEntity::getDisposeTime,start) - .lt(OperMaintenancePlanEntity::getDisposeTime,end) - .isNotNull(OperMaintenancePlanEntity::getCreateTaskTime) - ); - // 遍历计划列表生成相应任务 - if(CollectionUtil.isEmpty(plans)){ - return; - } - plans.forEach(plan -> { - // 生成日常任务对象 - OperMaintenanceTaskEntity task = BeanUtil.copy(plan,OperMaintenanceTaskEntity.class); - if(StringUtil.isEmpty(task.getEmCode())){ - this.taskDistribute(task,plan); - }else{ - for (String code : plan.getEmCode().split(",")) { - task.setEmCode(code); - this.taskDistribute(task,plan); - } - } - }); - } - - /** - * 日常维护任务派发 - * @param task - * @param plan - */ - private void taskDistribute(OperMaintenanceTaskEntity task, OperMaintenancePlanEntity plan) { - DefaultTransactionDefinition defaultTransactionDefinition = new DefaultTransactionDefinition(); - defaultTransactionDefinition.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); - TransactionStatus transaction = manager.getTransaction(defaultTransactionDefinition); - task.setId(null); - task.setCreateTime(new Date()); - task.setUpdateTime(new Date()); - task.setPlanId(plan.getId()); - task.setTaskCode(UUID.randomUUID().toString()); - if (task.getRefLibraryId() != 0) { - task.setCreateTime(DateUtil.now()); - } - if(ObjectUtil.isNotEmpty(plan.getDisposer())){ - task.setDisposer(plan.getDisposer().toString()); - } - //补充计划结束时间 - Instant instant = task.getDisposeTime().toInstant(); - ZoneId zoneId = ZoneId.systemDefault(); - LocalDateTime disposeTime = instant.atZone(zoneId).toLocalDateTime(); - task.setPlanEndTime(disposeTime.plusHours(task.getHours())); - //获取值班人员 - if (ObjectUtil.isNotEmpty(plan.getMaintenanceModel()) && plan.getMaintenanceModel() == 2) { - //查询值班信息 - LambdaQueryWrapper dutyWrapper = new LambdaQueryWrapper<>(); - dutyWrapper.eq(ImsDutyMainEntity::getDutyDate, DateTimeFormatter.ofPattern(PATTERN_DATE).format(disposeTime)); - dutyWrapper.eq(ImsDutyMainEntity::getClassId, plan.getImsDutyClassId()); - ImsDutyMainEntity entity = dutyMainService.getOne(dutyWrapper); - if (ObjectUtil.isEmpty(entity) || StringUtils.isEmpty(entity.getDutyPersonIds())) { - log.error("计划ID为:{}未查询到排班记录", plan.getId()); - return; - } - String userId = entity.getDutyPersonIds(); - task.setDisposer(userId.replaceAll("\\^", ",")); - } - this.save(task); - // 事务提交 - manager.commit(transaction); - //启动流程 - String processInstanceId = this.startProcess(plan.getProcDefId(), task); - //推送消息 - CompletableFuture operMaintenanceTaskEntityCompletableFuture = - CompletableFuture.runAsync(() -> { - task.setProcessInstanceId(processInstanceId); - this.updateById(task); - plan.setCreateTaskTime(new Date()); - planService.updateById(plan); - //推送消息 - this.pushTaskMessage(task.getId()); - }, executor); - //启动队列 - try { - CompletableFuture.allOf(operMaintenanceTaskEntityCompletableFuture).get(); - } catch (Exception e) { - e.printStackTrace(); - } - } - - /** - * 开启一个流程实例 - **/ - private String startProcess(String processDefinitionKey, OperMaintenanceTaskEntity taskEntity) { - OperMaintenanceTaskEntityVo operMaintenanceTaskEntityVo = new OperMaintenanceTaskEntityVo(); - BeanUtils.copyProperties(taskEntity, operMaintenanceTaskEntityVo); - Map params = new HashMap<>(); - params.put("taskId", taskEntity.getId()); - List userIdList = Stream.of(taskEntity.getDisposer().split(",")).collect(Collectors.toList()); - String taskUsers = userIdList.stream().filter(StringUtils::isNotBlank).map("taskUser_"::concat).collect(Collectors.joining(",")); - params.put("initUserIds", taskUsers); - params.put("operMaintenanceTaskEntityVo", operMaintenanceTaskEntityVo); - return flowClient.startProcessInstanceContainNameByKey(processDefinitionKey, String.valueOf(taskEntity.getId()), taskEntity.getTitle(), params).getData().getProcessInstanceId(); - } - - /** - * 推送消息 - */ - private void pushTaskMessage(Long taskId) { - OperMaintenanceTaskEntity task = this.getById(taskId); - if(ObjectUtil.isEmpty(task)){ - return; - } - // 根据消息模板Id查询模板 - R result = messageClient.getMsgTemplateById(task.getMessageTemplateId()); - if (result.isSuccess() && ObjectUtil.isNotEmpty(result.getData())) { - Func.toLongList(",", task.getDisposer()).forEach(userId -> { - //推送消息 - ZoneId zoneId = ZoneId.systemDefault(); - PlanMsgRecordDto msg = new PlanMsgRecordDto(); - msg.setTemplateId(task.getMessageTemplateId()); - msg.setCreateUser(task.getCreateUser()); - msg.setPlanTime(LocalDateTime.ofInstant(task.getDisposeTime().toInstant(), zoneId)); - msg.setTaskId(task.getId()); - msg.setDeptId(task.getCreateDept()); - msg.setReceiver(userId); - msg.setContent("距离任务执行时间已不满一小时,请及时处理"); - messageClient.planSendMessage(msg); - }); - } - } - /** * 获取日常维护数量 * @param departList diff --git a/hzims-service/hzims-scheduled/src/main/resources/mapper/inspect/ObjectMapper.xml b/hzims-service/hzims-scheduled/src/main/resources/mapper/inspect/InspectContentMapper.xml similarity index 66% rename from hzims-service/hzims-scheduled/src/main/resources/mapper/inspect/ObjectMapper.xml rename to hzims-service/hzims-scheduled/src/main/resources/mapper/inspect/InspectContentMapper.xml index d50799a..f7e3e04 100644 --- a/hzims-service/hzims-scheduled/src/main/resources/mapper/inspect/ObjectMapper.xml +++ b/hzims-service/hzims-scheduled/src/main/resources/mapper/inspect/InspectContentMapper.xml @@ -1,5 +1,5 @@ - + diff --git a/hzims-service/hzims-scheduled/src/main/resources/mapper/inspect/ContentMapper.xml b/hzims-service/hzims-scheduled/src/main/resources/mapper/inspect/InspectObjectMapper.xml similarity index 66% rename from hzims-service/hzims-scheduled/src/main/resources/mapper/inspect/ContentMapper.xml rename to hzims-service/hzims-scheduled/src/main/resources/mapper/inspect/InspectObjectMapper.xml index e68eb88..1963f43 100644 --- a/hzims-service/hzims-scheduled/src/main/resources/mapper/inspect/ContentMapper.xml +++ b/hzims-service/hzims-scheduled/src/main/resources/mapper/inspect/InspectObjectMapper.xml @@ -1,5 +1,5 @@ - + diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/HistoryAbnormalAlarmServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/HistoryAbnormalAlarmServiceImpl.java index 906fd0e..554173d 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/HistoryAbnormalAlarmServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/HistoryAbnormalAlarmServiceImpl.java @@ -35,6 +35,7 @@ import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.ObjectUtil; import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; import java.lang.reflect.Field; @@ -42,6 +43,7 @@ import java.math.BigDecimal; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.*; +import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; /** @@ -59,6 +61,8 @@ public class HistoryAbnormalAlarmServiceImpl extends BaseServiceImpl wrapper = Wrappers.lambdaQuery(); wrapper.eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE); @@ -266,6 +274,7 @@ public class HistoryAbnormalAlarmServiceImpl extends BaseServiceImpl org.springblade - blade-starter-datascope - ${bladex.project.version} - - - org.springblade blade-system-api ${bladex.project.version}