Browse Source

Merge remote-tracking branch 'origin/master'

zhongwei
liwen 9 months ago
parent
commit
fa60c3cc6c
  1. 2
      hzims-service/equipment/src/main/resources/db/2.0.0.sql
  2. 22
      hzims-service/hzims-middle/src/main/resources/db/1.0.0.sql
  3. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskRemindHandler.java
  4. 47
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/MaintenanceServiceImpl.java

2
hzims-service/equipment/src/main/resources/db/2.0.0.sql

@ -33,3 +33,5 @@ update hzims_em_definition set type = '2' where type = '0';
-- 修改故障诊断任务表的字符集
ALTER TABLE hzims_fdp_task CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
insert into `bladex`.`blade_dict` (`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_sealed`, `is_deleted`, `dict_type`, `app_id`, `app_code`) values (1633016338171637774, 1633016108671905794, 'devicetype', '4', '海康视频', 2, '', 0, 0, 0, -1, 'hzims-equipment');

22
hzims-service/hzims-middle/src/main/resources/db/1.0.0.sql

@ -128,16 +128,12 @@ CREATE TABLE IF NOT EXISTS `PROCESS_DICT` (
) ENGINE = INNODB AUTO_INCREMENT = 10 CHARACTER SET = UTF8 COLLATE = UTF8_GENERAL_CI COMMENT = '工作流字典表' ROW_FORMAT = DYNAMIC;
-- 初始化流程配置記錄
INSERT INTO `PROCESS_DICT` (`DICT_CODE`, `DICT_SORT`, `DICT_KEY`, `DICT_VALUE`, `DICT_LABEL`, `DICT_TYPE`, `IS_DEFAULT`, `STATUS`, `CREATE_DEPT`, `CREATE_TIME`, `UPDATE_TIME`, `REMARK`) VALUES (1, 0, 'NETWORKING', 'WORKTICKETFLOW', '工作票', '两票管理', 'Y', 0, NULL, '2023-06-05 09:43:47', '2023-06-12 10:04:30', '第一种工作票 第二种工作票');
INSERT INTO `PROCESS_DICT` (`DICT_CODE`, `DICT_SORT`, `DICT_KEY`, `DICT_VALUE`, `DICT_LABEL`, `DICT_TYPE`, `IS_DEFAULT`, `STATUS`, `CREATE_DEPT`, `CREATE_TIME`, `UPDATE_TIME`, `REMARK`) VALUES (2, 0, 'MOREACTIONBANKDIRECT', 'STANDARDTICKETFLOW', '操作票', '两票管理', 'Y', 0, NULL, '2023-06-06 14:15:39', '2023-06-06 14:15:52', '操作票');
INSERT INTO `PROCESS_DICT` (`DICT_CODE`, `DICT_SORT`, `DICT_KEY`, `DICT_VALUE`, `DICT_LABEL`, `DICT_TYPE`, `IS_DEFAULT`, `STATUS`, `CREATE_DEPT`, `CREATE_TIME`, `UPDATE_TIME`, `REMARK`) VALUES (3, 0, 'MACHINERY', 'WORKTICKETFLOWMACHINERY', '机械工作票', '两票管理', 'Y', 0, NULL, '2023-06-12 10:04:56', '2023-06-12 10:07:52', '水力机械工作票');
INSERT INTO `PROCESS_DICT` (`DICT_CODE`, `DICT_SORT`, `DICT_KEY`, `DICT_VALUE`, `DICT_LABEL`, `DICT_TYPE`, `IS_DEFAULT`, `STATUS`, `CREATE_DEPT`, `CREATE_TIME`, `UPDATE_TIME`, `REMARK`) VALUES (4, 0, 'MAINTENANCE', 'MAINTENANCE_TEST', '日常维护流程', '日常维护', 'Y', 0, NULL, '2023-06-14 15:06:39', '2023-06-14 15:06:41', '日常维护');
INSERT INTO `PROCESS_DICT` (`DICT_CODE`, `DICT_SORT`, `DICT_KEY`, `DICT_VALUE`, `DICT_LABEL`, `DICT_TYPE`, `IS_DEFAULT`, `STATUS`, `CREATE_DEPT`, `CREATE_TIME`, `UPDATE_TIME`, `REMARK`) VALUES (5, 0, 'DEFECTCHECK', 'DEFECTCHECK', '消缺流程', '', 'Y', 0, NULL, '2023-06-16 17:01:01', '2023-06-26 11:36:54', '消缺流程');
INSERT INTO `PROCESS_DICT` (`DICT_CODE`, `DICT_SORT`, `DICT_KEY`, `DICT_VALUE`, `DICT_LABEL`, `DICT_TYPE`, `IS_DEFAULT`, `STATUS`, `CREATE_DEPT`, `CREATE_TIME`, `UPDATE_TIME`, `REMARK`) VALUES (6, 6, 'OVERHAUL_PLAN', 'OVERHAUL_PLAN', '检修计划V4', '检修计划', 'Y', 0, NULL, '2023-06-16 17:01:01', '2023-06-16 17:04:01', '检修计划流程');
INSERT INTO `PROCESS_DICT` (`DICT_CODE`, `DICT_SORT`, `DICT_KEY`, `DICT_VALUE`, `DICT_LABEL`, `DICT_TYPE`, `IS_DEFAULT`, `STATUS`, `CREATE_DEPT`, `CREATE_TIME`, `UPDATE_TIME`, `REMARK`) VALUES (7, 7, 'OVERHAUL_TASK', 'OVERHAUL_TASK', '检修任务V4', '检修任务', 'Y', 0, NULL, '2023-06-16 17:01:01', '2023-06-16 17:04:01', '检修任务流程');
INSERT INTO `PROCESS_DICT` (`DICT_CODE`, `DICT_SORT`, `DICT_KEY`, `DICT_VALUE`, `DICT_LABEL`, `DICT_TYPE`, `IS_DEFAULT`, `STATUS`, `CREATE_DEPT`, `CREATE_TIME`, `UPDATE_TIME`, `REMARK`) VALUES (8, 8, 'DUTY_REC', 'DUTY_REC', '交接班V4', '交接班', 'Y', 0, NULL, '2023-07-25 18:35:01', '2023-07-25 18:35:01', '交接班流程');
INSERT INTO `PROCESS_DICT` (`DICT_CODE`, `DICT_SORT`, `DICT_KEY`, `DICT_VALUE`, `DICT_LABEL`, `DICT_TYPE`, `IS_DEFAULT`, `STATUS`, `CREATE_DEPT`, `CREATE_TIME`, `UPDATE_TIME`, `REMARK`) VALUES (9, 9, 'WORK_TASK', 'WORK_TASK', '工作任务单V4', '工作任务单', 'Y', 0, NULL, '2023-07-25 18:35:01', '2024-01-09 14:48:18', '工作任务单流程');
INSERT INTO `PROCESS_DICT` (`DICT_CODE`, `DICT_SORT`, `DICT_KEY`, `DICT_VALUE`, `DICT_LABEL`, `DICT_TYPE`, `IS_DEFAULT`, `STATUS`, `CREATE_DEPT`, `CREATE_TIME`, `UPDATE_TIME`, `REMARK`) VALUES (10, 10, 'OFFLINEWORKTICKET', 'OFFLINEWORKTICKET', '线下工作票', '线下工作票', 'Y', 0, NULL, '2023-12-28 16:35:10', '2023-12-28 16:35:14', '线下工作票流程');
INSERT INTO `PROCESS_DICT` (`DICT_CODE`, `DICT_SORT`, `DICT_KEY`, `DICT_VALUE`, `DICT_LABEL`, `DICT_TYPE`, `IS_DEFAULT`, `STATUS`, `CREATE_DEPT`, `CREATE_TIME`, `UPDATE_TIME`, `REMARK`) VALUES (11, 11, 'DEALALARM', 'DEALALARM', '告警处理流程', '告警处理流程', 'Y', 0, NULL, '2024-02-19 16:56:10', '2024-02-19 16:56:34', '告警处理流程');
INSERT INTO `PROCESS_DICT` (`DICT_CODE`, `DICT_SORT`, `DICT_KEY`, `DICT_VALUE`, `DICT_LABEL`, `DICT_TYPE`, `IS_DEFAULT`, `STATUS`, `CREATE_DEPT`, `CREATE_TIME`, `UPDATE_TIME`, `REMARK`) VALUES (12, 12, 'HIDDENDANGERCHECK', 'HIDDENDANGERCHECK', '隐患排查', '隐患排查', 'Y', 0, NULL, '2023-07-25 18:35:01', '2023-07-25 18:35:01', '隐患排查流程');
INSERT INTO `PROCESS_DICT` (`DICT_CODE`, `DICT_SORT`, `DICT_KEY`, `DICT_VALUE`, `DICT_LABEL`, `DICT_TYPE`, `IS_DEFAULT`, `STATUS`, `CREATE_DEPT`, `CREATE_TIME`, `UPDATE_TIME`, `REMARK`) VALUES (13, 13, 'HAZARD_RISK', 'HAZARD_RISK', '风险排查', '风险排查', 'Y', 0, NULL, '2023-07-25 18:35:01', '2023-09-19 22:35:40', '风险排查流程');
INSERT INTO `hzims-middle`.`process_dict` (`dict_code`, `dict_sort`, `dict_key`, `dict_value`, `dict_label`, `dict_type`, `is_default`, `status`, `create_dept`, `create_time`, `update_time`, `remark`) VALUES (1, 0, 'networking', 'workTicketFlow', '工作票', '两票管理', 'Y', 0, NULL, '2023-06-05 09:43:47', '2023-06-12 10:04:30', '第一种工作票 第二种工作票');
INSERT INTO `hzims-middle`.`process_dict` (`dict_code`, `dict_sort`, `dict_key`, `dict_value`, `dict_label`, `dict_type`, `is_default`, `status`, `create_dept`, `create_time`, `update_time`, `remark`) VALUES (2, 0, 'moreActionBankDirect', 'standardTicketFlow', '操作票', '两票管理', 'Y', 0, NULL, '2023-06-06 14:15:39', '2023-06-06 14:15:52', '操作票');
INSERT INTO `hzims-middle`.`process_dict` (`dict_code`, `dict_sort`, `dict_key`, `dict_value`, `dict_label`, `dict_type`, `is_default`, `status`, `create_dept`, `create_time`, `update_time`, `remark`) VALUES (3, 0, 'machinery', 'workTicketFlowmachinery', '机械工作票', '两票管理', 'Y', 0, NULL, '2023-06-12 10:04:56', '2023-06-12 10:07:52', '水力机械工作票');
INSERT INTO `hzims-middle`.`process_dict` (`dict_code`, `dict_sort`, `dict_key`, `dict_value`, `dict_label`, `dict_type`, `is_default`, `status`, `create_dept`, `create_time`, `update_time`, `remark`) VALUES (4, 0, 'maintenance', 'maintenance_test', '日常维护流程', '日常维护', 'Y', 0, NULL, '2023-06-14 15:06:39', '2023-06-14 15:06:41', '日常维护');
INSERT INTO `hzims-middle`.`process_dict` (`dict_code`, `dict_sort`, `dict_key`, `dict_value`, `dict_label`, `dict_type`, `is_default`, `status`, `create_dept`, `create_time`, `update_time`, `remark`) VALUES (5, 0, 'defectCheck', 'defectCheck', '消缺流程', '', 'Y', 0, NULL, '2023-06-16 17:01:01', '2023-06-26 11:36:54', '消缺流程');
INSERT INTO `hzims-middle`.`process_dict` (`dict_code`, `dict_sort`, `dict_key`, `dict_value`, `dict_label`, `dict_type`, `is_default`, `status`, `create_dept`, `create_time`, `update_time`, `remark`) VALUES (6, 6, 'overhaul_plan', 'overhaul_plan', '检修计划v4', '检修计划', 'Y', 0, NULL, '2023-06-16 17:01:01', '2023-06-16 17:04:01', '检修计划流程');
INSERT INTO `hzims-middle`.`process_dict` (`dict_code`, `dict_sort`, `dict_key`, `dict_value`, `dict_label`, `dict_type`, `is_default`, `status`, `create_dept`, `create_time`, `update_time`, `remark`) VALUES (7, 7, 'overhaul_task', 'overhaul_task', '检修任务v4', '检修任务', 'Y', 0, NULL, '2023-06-16 17:01:01', '2023-06-16 17:04:01', '检修任务流程');
INSERT INTO `hzims-middle`.`process_dict` (`dict_code`, `dict_sort`, `dict_key`, `dict_value`, `dict_label`, `dict_type`, `is_default`, `status`, `create_dept`, `create_time`, `update_time`, `remark`) VALUES (8, 8, 'duty_rec', 'duty_rec', '交接班v4', '交接班', 'Y', 0, NULL, '2023-07-25 18:35:01', '2023-07-25 18:35:01', '交接班流程');
INSERT INTO `hzims-middle`.`process_dict` (`dict_code`, `dict_sort`, `dict_key`, `dict_value`, `dict_label`, `dict_type`, `is_default`, `status`, `create_dept`, `create_time`, `update_time`, `remark`) VALUES (9, 9, 'workTicketFlowmachinery', 'workTicketFlowmachinery', '水力机械工作票流程', '水力机械工作票', 'Y', 0, NULL, '2023-11-20 11:03:29', '2023-11-20 11:03:29', '水力机械工作票流程');

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskRemindHandler.java

@ -56,7 +56,7 @@ public class MaintenanceTaskRemindHandler {
XxlJobLogger.log("开始执行id为{}的任务", Optional.ofNullable(operMaintenanceTaskEntity.getId()).orElse(0L));
//日常维护任务到期消息提醒,提醒对象:执行人、项目经理角色 取出
this.sendMessage(taskEntity);
redisTemplate.opsForZSet().remove(RedisKeyConstants.MAINTENANCE_TASK_DELAY_LIST,operMaintenanceTaskEntity);
redisTemplate.opsForZSet().remove(RedisKeyConstants.REMIND_TASK_END_LIST,operMaintenanceTaskEntity);
}
});
}

47
hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/MaintenanceServiceImpl.java

@ -1,5 +1,6 @@
package com.hnac.hzims.operational.maintenance.service.impl;
import cn.hutool.core.stream.CollectorUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
@ -18,6 +19,7 @@ import com.hnac.hzims.operational.duty.entity.ImsDutyMainEntity;
import com.hnac.hzims.operational.duty.service.IImsDutyMainService;
import com.hnac.hzims.operational.maintenance.entity.OperMaintenancePlanEntity;
import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity;
import com.hnac.hzims.operational.maintenance.scheduled.MaintenanceTaskSchedule;
import com.hnac.hzims.operational.maintenance.service.IOperMaintenancePlanService;
import com.hnac.hzims.operational.maintenance.service.IOperMaintenanceTaskService;
import com.hnac.hzims.operational.maintenance.service.MaintenanceService;
@ -40,11 +42,9 @@ import org.springframework.beans.BeanUtils;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.*;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.ThreadPoolExecutor;
@ -72,12 +72,9 @@ public class MaintenanceServiceImpl implements MaintenanceService {
private final List<TemplateService> templateService;
private final IFlowClient flowClient;
private final ISysClient sysClient;
private final MaintenanceTaskSchedule taskSchedule;
private final ThreadPoolExecutor executor;
private final DataSourceTransactionManager dataSourceTransactionManager;
/**
* 日常维护生成任务
*
@ -87,33 +84,16 @@ public class MaintenanceServiceImpl implements MaintenanceService {
// @Transactional(rollbackFor = Exception.class)
public void createTask(List<String> ids) {
try {
//获取日常维护计划
LambdaQueryWrapper<OperMaintenancePlanEntity> planEntityLambdaQueryWrapper = new LambdaQueryWrapper<>();
planEntityLambdaQueryWrapper.in(BaseEntity::getId, ids);
List<OperMaintenancePlanEntity> planEntities = maintenancePlanService.list(planEntityLambdaQueryWrapper);
//筛选当月没生成任务的计划
List<OperMaintenancePlanEntity> finalPlanEntities = planEntities.stream().
filter(planEntity -> ObjectUtil.isEmpty(planEntity.getCreateTaskTime()) ||
!DateUtil.judgeSameDay(DateUtil.DateToLocalDateTime(planEntity.getCreateTaskTime()), LocalDate.now()))
LambdaQueryWrapper<OperMaintenancePlanEntity> wrapper = Wrappers.<OperMaintenancePlanEntity>lambdaQuery()
.in(OperMaintenancePlanEntity::getId, ids);
List<OperMaintenancePlanEntity> planList = maintenancePlanService.list(wrapper);
LocalDateTime minDate = LocalDateTime.of(LocalDate.now(), LocalTime.MIN);
List<OperMaintenancePlanEntity> generatePlanList = planList.stream().filter(plan -> Func.isEmpty(plan.getCreateTaskTime()) || minDate.isAfter(DateUtil.DateToLocalDateTime(plan.getCreateTaskTime())))
.collect(Collectors.toList());
if (CollectionUtil.isEmpty(finalPlanEntities)) {
Assert.isTrue(CollectionUtil.isNotEmpty(generatePlanList), () -> {
throw new ServiceException("所选计划当天已生成任务");
}
for (OperMaintenancePlanEntity finalPlanEntity : finalPlanEntities) {
// 通过计划生成任务
Boolean taskByPlan = this.createTaskByPlan(finalPlanEntity);
if (taskByPlan) {
//更新任务派发时间
LambdaUpdateWrapper<OperMaintenancePlanEntity> planEntityLambdaUpdateWrapper = new LambdaUpdateWrapper<>();
planEntityLambdaUpdateWrapper.set(OperMaintenancePlanEntity::getCreateTaskTime, new Date());
planEntityLambdaUpdateWrapper.eq(OperMaintenancePlanEntity::getId, finalPlanEntity.getId());
boolean update = maintenancePlanService.update(planEntityLambdaUpdateWrapper);
if (!update) {
log.error("maintenance:generateTask 更新任务派发失败");
throw new ServiceException("更新任务派发失败");
}
}
}
});
generatePlanList.forEach(plan -> taskSchedule.generateTaskByPlan(plan));
} catch (Exception e) {
e.printStackTrace();
}
@ -316,6 +296,7 @@ public class MaintenanceServiceImpl implements MaintenanceService {
* @param finalPlanEntity
*/
@Override
@Deprecated
// @Transactional(rollbackFor = Exception.class)
public Long fillTask(OperMaintenanceTaskEntity taskEntity, OperMaintenancePlanEntity finalPlanEntity, Boolean flag) {
// DefaultTransactionDefinition = new DefaultTransactionDefinition();

Loading…
Cancel
Save