Browse Source

Merge remote-tracking branch 'origin/master'

zhongwei
yang_shj 1 year ago
parent
commit
0969867dd4
  1. 36
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/ThreadConfig.java
  2. 294
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/MaintenanceServiceImpl.java
  3. 4
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceMonitorServiceImpl.java
  4. 32
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/propperties/ThreadPoolConfigProperties.java
  5. 415
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java

36
hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/ThreadConfig.java

@ -0,0 +1,36 @@
package com.hnac.hzims.operational.config;
import com.hnac.hzims.operational.propperties.ThreadPoolConfigProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/**
* @Author WL
* @Version v1.0
* @Serial 1.0
* @Date 2023/5/10 12:49
*/
@Configuration
public class ThreadConfig {
@Autowired
private ThreadPoolConfigProperties threadPoolConfigProperties;
@Bean
public ThreadPoolExecutor threadPoolExecutor() {
return new ThreadPoolExecutor(threadPoolConfigProperties.getCorePoolSize(),
threadPoolConfigProperties.getMaxSize(),
threadPoolConfigProperties.getKeepAliveTime(),
TimeUnit.SECONDS,
new LinkedBlockingDeque<>(threadPoolConfigProperties.getCapacity()),
Executors.defaultThreadFactory(),
new ThreadPoolExecutor.AbortPolicy());
}
}

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

@ -37,8 +37,12 @@ import org.springblade.system.feign.ISysClient;
import org.springblade.system.user.cache.UserCache; import org.springblade.system.user.cache.UserCache;
import org.springblade.system.user.entity.User; import org.springblade.system.user.entity.User;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.DefaultTransactionDefinition;
import java.time.Instant; import java.time.Instant;
import java.time.LocalDate; import java.time.LocalDate;
@ -46,6 +50,9 @@ import java.time.LocalDateTime;
import java.time.ZoneId; import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
@ -71,6 +78,11 @@ public class MaintenanceServiceImpl implements MaintenanceService {
private final IFlowClient flowClient; private final IFlowClient flowClient;
private final ISysClient sysClient; private final ISysClient sysClient;
private final ThreadPoolExecutor executor;
private final DataSourceTransactionManager dataSourceTransactionManager;
/** /**
* 日常维护生成任务 * 日常维护生成任务
* *
@ -79,33 +91,31 @@ public class MaintenanceServiceImpl implements MaintenanceService {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void createTask(List<String> ids) { public void createTask(List<String> ids) {
//获取日常维护计划 try {
LambdaQueryWrapper<OperMaintenancePlanEntity> planEntityLambdaQueryWrapper = new LambdaQueryWrapper<>(); //获取日常维护计划
planEntityLambdaQueryWrapper.in(BaseEntity::getId, ids); LambdaQueryWrapper<OperMaintenancePlanEntity> planEntityLambdaQueryWrapper = new LambdaQueryWrapper<>();
List<OperMaintenancePlanEntity> planEntities = maintenancePlanService planEntityLambdaQueryWrapper.in(BaseEntity::getId, ids);
.list(planEntityLambdaQueryWrapper); List<OperMaintenancePlanEntity> planEntities = maintenancePlanService.list(planEntityLambdaQueryWrapper);
//筛选当月没生成任务的计划 //筛选当月没生成任务的计划
List<OperMaintenancePlanEntity> finalPlanEntities = planEntities.stream().filter(planEntity -> List<OperMaintenancePlanEntity> finalPlanEntities = planEntities.stream().filter(planEntity -> ObjectUtil.isEmpty(planEntity.getCreateTaskTime()) || !DateUtil.judgeSameDay(DateUtil.DateToLocalDateTime(planEntity.getCreateTaskTime()), LocalDate.now())).collect(Collectors.toList());
ObjectUtil.isEmpty(planEntity.getCreateTaskTime()) if (CollectionUtil.isEmpty(finalPlanEntities)) {
|| !DateUtil.judgeSameDay( throw new ServiceException("所选计划当天已生成任务");
DateUtil.DateToLocalDateTime(planEntity.getCreateTaskTime()), LocalDate.now())
).collect(Collectors.toList());
if (CollectionUtil.isEmpty(finalPlanEntities)) {
throw new ServiceException("所选计划当天已生成任务");
}
for (OperMaintenancePlanEntity finalPlanEntity : finalPlanEntities) {
// 通过计划生成任务
this.createTaskByPlan(finalPlanEntity);
//更新任务派发时间
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("更新任务派发失败");
} }
for (OperMaintenancePlanEntity finalPlanEntity : finalPlanEntities) {
// 通过计划生成任务
this.createTaskByPlan(finalPlanEntity);
//更新任务派发时间
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("更新任务派发失败");
}
}
} catch (Exception e) {
e.printStackTrace();
} }
} }
@ -117,107 +127,108 @@ public class MaintenanceServiceImpl implements MaintenanceService {
@Override @Override
@Transactional(rollbackFor = RuntimeException.class) @Transactional(rollbackFor = RuntimeException.class)
public void findPending(ProcessWorkFlowResponse response) { public void findPending(ProcessWorkFlowResponse response) {
log.info("获取businessKey: {}", response.getBusinessKey());
log.info("获取taskId: {} ", response.getTaskId());
log.info("获取下一个审批人是: {} ", response.getNextStepOperator());
log.info("获取下一个用户Id是: {} ", response.getUserId());
log.info("获取当前任务名称是: {} ", response.getTaskName());
log.info("获取根据handleType区分是用户还是候选组角色: {}", response.getHandleType());
//json转换表单
String formData = JSON.toJSONString(response.getVariables());
log.info("获取表单的数据:{}", formData);
OperMaintenanceTaskEntityVo standardTicketInfoVo = null;
try { try {
JSONObject jsonObject = JSONObject.parseObject(formData); log.info("获取businessKey: {}", response.getBusinessKey());
standardTicketInfoVo = JSONObject.parseObject(jsonObject.getString("operMaintenanceTaskEntityVo"), log.info("获取taskId: {} ", response.getTaskId());
new TypeReference<OperMaintenanceTaskEntityVo>(){}); log.info("获取下一个审批人是: {} ", response.getNextStepOperator());
// standardTicketInfoVo = (OperMaintenanceTaskEntityVo) jsonObject.get("operMaintenanceTaskEntityVo"); log.info("获取下一个用户Id是: {} ", response.getUserId());
// standardTicketInfoVo = JSONObject.toJavaObject(jsonObject, OperMaintenanceTaskEntityVo.class); log.info("获取当前任务名称是: {} ", response.getTaskName());
} catch (Exception e) { log.info("获取根据handleType区分是用户还是候选组角色: {}", response.getHandleType());
log.error("获取表单出现异常了~~~~"); //json转换表单
throw new IllegalArgumentException(e.getMessage()); String formData = JSON.toJSONString(response.getVariables());
} log.info("获取表单的数据:{}", formData);
//1.查询日常维护信息 OperMaintenanceTaskEntityVo standardTicketInfoVo = null;
Long id = NumberUtils.toLong(response.getBusinessKey()); try {
OperMaintenanceTaskEntity dbOperMaintenanceTaskEntity = taskService.getById(id); JSONObject jsonObject = JSONObject.parseObject(formData);
if (ObjectUtils.isEmpty(dbOperMaintenanceTaskEntity)) { standardTicketInfoVo = JSONObject.parseObject(jsonObject.getString("operMaintenanceTaskEntityVo"), new TypeReference<OperMaintenanceTaskEntityVo>() {
log.error("获取日常维护数据不存在"); });
return; // standardTicketInfoVo = (OperMaintenanceTaskEntityVo) jsonObject.get("operMaintenanceTaskEntityVo");
} // standardTicketInfoVo = JSONObject.toJavaObject(jsonObject, OperMaintenanceTaskEntityVo.class);
OperMaintenanceTaskEntity entity = new OperMaintenanceTaskEntity(); } catch (Exception e) {
BeanUtils.copyProperties(standardTicketInfoVo, entity); log.error("获取表单出现异常了~~~~");
entity.setId(id); throw new IllegalArgumentException(e.getMessage());
//填充日常维护信息
saveOperMaintenanceTaskEntity(entity, response);
entity.setProcessInstanceId(response.getProcessInstanceId());
taskService.updateById(entity);
//推送消息
if (response.getTaskId() != null) {
// MessagePushRecordDto message = new MessagePushRecordDto();
// message.setBusinessClassify("business");
// message.setBusinessKey(MessageConstants.BusinessClassifyEnum.OPERATIONTICKETMESSAGE.getKey());
// message.setSubject(MessageConstants.BusinessClassifyEnum.OPERATIONTICKETMESSAGE.getDescription());
// message.setTaskId(entity.getId());
// message.setTenantId("200000");
// message.setTypes(Arrays.asList(MessageConstants.APP_PUSH, MessageConstants.WS_PUSH));
// message.setPushType(MessageConstants.IMMEDIATELY);
// //您有一张工作票待审批,工作内容:*****,审批环节:*****;
// String countent =
// "您有一条日常维护任务待审批,工作内容:".concat(entity.getTitle())
// .concat(",审批环节:")
// .concat(response.getTaskName());
// message.setContent(countent);
// message.setDeptId(entity.getCreateDept());
// R<String> deptName = sysClient.getDeptName(entity.getCreateDept());
// if (deptName.isSuccess()) {
// message.setDeptName(deptName.getData());
// }
// String userIds = response.getUserId();
// if (com.hnac.hzims.common.logs.utils.StringUtils.isBlank(userIds)) {
// log.error("推送的消息不能为空哦,{}", userIds);
// return;
// }
// String[] split = userIds.split(",");
// for (String userId : split) {
// message.setPusher(userId);
// User user = UserCache.getUser(NumberUtils.toLong(userId));
// if (ObjectUtils.isNotEmpty(user)) {
// message.setPusherName(user.getName());
// }
// message.setAccount(userId);
// message.setCreateUser(NumberUtils.toLong(userId));
// messageClient.sendMessage(message);
// }
BusinessMessageDTO businessMessageDTO = new BusinessMessageDTO();
businessMessageDTO.setBusinessClassify("business");
businessMessageDTO.setBusinessKey(MessageConstants.BusinessClassifyEnum.ROUTINEMAINTENANCE.getKey());
businessMessageDTO.setSubject(MessageConstants.BusinessClassifyEnum.ROUTINEMAINTENANCE.getDescription());
businessMessageDTO.setTaskId(dbOperMaintenanceTaskEntity.getId());
businessMessageDTO.setTenantId("200000");
//您有一张工作票待审批,工作内容:*****,审批环节:*****;
String countent =
"您有一条日常维护任务待审批,工作内容:".concat(dbOperMaintenanceTaskEntity.getTitle())
.concat(",审批环节:")
.concat(response.getTaskName());
businessMessageDTO.setContent(countent);
businessMessageDTO.setDeptId(dbOperMaintenanceTaskEntity.getCreateDept());
R<String> deptName = sysClient.getDeptName(dbOperMaintenanceTaskEntity.getCreateDept());
if (deptName.isSuccess()) {
businessMessageDTO.setDeptName(deptName.getData());
} }
String userIds = response.getUserId(); //1.查询日常维护信息
businessMessageDTO.setUserIds(userIds); Long id = NumberUtils.toLong(response.getBusinessKey());
businessMessageDTO.setCreateUser(dbOperMaintenanceTaskEntity.getCreateUser()); OperMaintenanceTaskEntity dbOperMaintenanceTaskEntity = taskService.getById(id);
if (ObjectUtils.isEmpty(dbOperMaintenanceTaskEntity)) {
log.error("获取日常维护数据不存在");
return;
}
OperMaintenanceTaskEntity entity = new OperMaintenanceTaskEntity();
BeanUtils.copyProperties(standardTicketInfoVo, entity);
entity.setId(id);
//填充日常维护信息
saveOperMaintenanceTaskEntity(entity, response);
entity.setProcessInstanceId(response.getProcessInstanceId());
taskService.updateById(entity);
//推送消息
if (response.getTaskId() != null) {
// MessagePushRecordDto message = new MessagePushRecordDto();
// message.setBusinessClassify("business");
// message.setBusinessKey(MessageConstants.BusinessClassifyEnum.OPERATIONTICKETMESSAGE.getKey());
// message.setSubject(MessageConstants.BusinessClassifyEnum.OPERATIONTICKETMESSAGE.getDescription());
// message.setTaskId(entity.getId());
// message.setTenantId("200000");
// message.setTypes(Arrays.asList(MessageConstants.APP_PUSH, MessageConstants.WS_PUSH));
// message.setPushType(MessageConstants.IMMEDIATELY);
// //您有一张工作票待审批,工作内容:*****,审批环节:*****;
// String countent =
// "您有一条日常维护任务待审批,工作内容:".concat(entity.getTitle())
// .concat(",审批环节:")
// .concat(response.getTaskName());
// message.setContent(countent);
// message.setDeptId(entity.getCreateDept());
// R<String> deptName = sysClient.getDeptName(entity.getCreateDept());
// if (deptName.isSuccess()) {
// message.setDeptName(deptName.getData());
// }
// String userIds = response.getUserId();
// if (com.hnac.hzims.common.logs.utils.StringUtils.isBlank(userIds)) {
// log.error("推送的消息不能为空哦,{}", userIds);
// return;
// }
// String[] split = userIds.split(",");
// for (String userId : split) {
// message.setPusher(userId);
// User user = UserCache.getUser(NumberUtils.toLong(userId));
// if (ObjectUtils.isNotEmpty(user)) {
// message.setPusherName(user.getName());
// }
// message.setAccount(userId);
// message.setCreateUser(NumberUtils.toLong(userId));
// messageClient.sendMessage(message);
// }
BusinessMessageDTO businessMessageDTO = new BusinessMessageDTO();
businessMessageDTO.setBusinessClassify("business");
businessMessageDTO.setBusinessKey(MessageConstants.BusinessClassifyEnum.ROUTINEMAINTENANCE.getKey());
businessMessageDTO.setSubject(MessageConstants.BusinessClassifyEnum.ROUTINEMAINTENANCE.getDescription());
businessMessageDTO.setTaskId(dbOperMaintenanceTaskEntity.getId());
businessMessageDTO.setTenantId("200000");
//您有一张工作票待审批,工作内容:*****,审批环节:*****;
String countent = "您有一条日常维护任务待审批,工作内容:".concat(dbOperMaintenanceTaskEntity.getTitle()).concat(",审批环节:").concat(response.getTaskName());
businessMessageDTO.setContent(countent);
businessMessageDTO.setDeptId(dbOperMaintenanceTaskEntity.getCreateDept());
R<String> deptName = sysClient.getDeptName(dbOperMaintenanceTaskEntity.getCreateDept());
if (deptName.isSuccess()) {
businessMessageDTO.setDeptName(deptName.getData());
}
String userIds = response.getUserId();
businessMessageDTO.setUserIds(userIds);
businessMessageDTO.setCreateUser(dbOperMaintenanceTaskEntity.getCreateUser());
log.info("================================================"); log.info("================================================");
log.info("businessMessageDTO = " + businessMessageDTO); log.info("businessMessageDTO = " + businessMessageDTO);
log.info("================================================"); log.info("================================================");
R booleanR = messageClient.sendAppAndWsMsgByUsers(businessMessageDTO); R booleanR = messageClient.sendAppAndWsMsgByUsers(businessMessageDTO);
if (!booleanR.isSuccess()) { if (!booleanR.isSuccess()) {
throw new ServiceException("消息推送失败"); throw new ServiceException("消息推送失败");
}
log.info("推送成功~");
} }
log.info("推送成功~"); } catch (Exception e) {
e.printStackTrace();
} }
} }
@ -281,6 +292,9 @@ public class MaintenanceServiceImpl implements MaintenanceService {
* @param finalPlanEntity * @param finalPlanEntity
*/ */
private void fillTask(OperMaintenanceTaskEntity taskEntity, OperMaintenancePlanEntity finalPlanEntity) { private void fillTask(OperMaintenanceTaskEntity taskEntity, OperMaintenancePlanEntity finalPlanEntity) {
DefaultTransactionDefinition defaultTransactionDefinition = new DefaultTransactionDefinition();
defaultTransactionDefinition.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
TransactionStatus transaction = dataSourceTransactionManager.getTransaction(defaultTransactionDefinition);
taskEntity.setId(null); taskEntity.setId(null);
taskEntity.setCreateTime(new Date()); taskEntity.setCreateTime(new Date());
taskEntity.setUpdateTime(new Date()); taskEntity.setUpdateTime(new Date());
@ -299,8 +313,7 @@ public class MaintenanceServiceImpl implements MaintenanceService {
if (ObjectUtil.isNotEmpty(finalPlanEntity.getMaintenanceModel()) && finalPlanEntity.getMaintenanceModel() == 2) { if (ObjectUtil.isNotEmpty(finalPlanEntity.getMaintenanceModel()) && finalPlanEntity.getMaintenanceModel() == 2) {
//查询值班信息 //查询值班信息
LambdaQueryWrapper<ImsDutyMainEntity> entityLambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<ImsDutyMainEntity> entityLambdaQueryWrapper = new LambdaQueryWrapper<>();
entityLambdaQueryWrapper.eq(ImsDutyMainEntity::getDutyDate, entityLambdaQueryWrapper.eq(ImsDutyMainEntity::getDutyDate, DateTimeFormatter.ofPattern(PATTERN_DATE).format(disposeTime));
DateTimeFormatter.ofPattern(PATTERN_DATE).format(disposeTime));
entityLambdaQueryWrapper.eq(ImsDutyMainEntity::getClassId, finalPlanEntity.getImsDutyClassId()); entityLambdaQueryWrapper.eq(ImsDutyMainEntity::getClassId, finalPlanEntity.getImsDutyClassId());
ImsDutyMainEntity entity = mainService.getOne(entityLambdaQueryWrapper); ImsDutyMainEntity entity = mainService.getOne(entityLambdaQueryWrapper);
if (ObjectUtil.isNotEmpty(entity) && StringUtils.isNotEmpty(entity.getDutyPersonIds())) { if (ObjectUtil.isNotEmpty(entity) && StringUtils.isNotEmpty(entity.getDutyPersonIds())) {
@ -312,16 +325,26 @@ public class MaintenanceServiceImpl implements MaintenanceService {
} }
} }
taskService.save(taskEntity); taskService.save(taskEntity);
//生成工作流实例 dataSourceTransactionManager.commit(transaction);
//启动流程
String processInstanceId = this.startProcess(finalPlanEntity.getProcDefId(), taskEntity); String processInstanceId = this.startProcess(finalPlanEntity.getProcDefId(), taskEntity);
taskEntity.setProcessInstanceId(processInstanceId);
taskService.updateById(taskEntity);
finalPlanEntity.setCreateTaskTime(new Date());
maintenancePlanService.updateById(finalPlanEntity);
taskEntity = taskService.getById(taskEntity.getId());
//推送消息 //推送消息
this.pushTaskMessage(taskEntity); CompletableFuture<Void> operMaintenanceTaskEntityCompletableFuture =
CompletableFuture.runAsync(() -> {
taskEntity.setProcessInstanceId(processInstanceId);
taskService.updateById(taskEntity);
finalPlanEntity.setCreateTaskTime(new Date());
maintenancePlanService.updateById(finalPlanEntity);
OperMaintenanceTaskEntity maintenanceTask = taskService.getById(taskEntity.getId());
//推送消息
this.pushTaskMessage(maintenanceTask);
}, executor);
//启动队列
try {
CompletableFuture.allOf(operMaintenanceTaskEntityCompletableFuture).get();
} catch (Exception e) {
e.printStackTrace();
}
} }
@ -343,10 +366,7 @@ public class MaintenanceServiceImpl implements MaintenanceService {
params.put("initUserIds", taskUsers); params.put("initUserIds", taskUsers);
params.put("operMaintenanceTaskEntityVo", operMaintenanceTaskEntityVo); params.put("operMaintenanceTaskEntityVo", operMaintenanceTaskEntityVo);
return flowClient.startProcessInstanceContainNameByKey(processDefinitionKey, return flowClient.startProcessInstanceContainNameByKey(processDefinitionKey, String.valueOf(taskEntity.getId()), taskEntity.getTitle(), params).getData().getProcessInstanceId();
String.valueOf(taskEntity.getId()), taskEntity.getTitle(), params)
.getData()
.getProcessInstanceId();
} }

4
hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceMonitorServiceImpl.java

@ -21,6 +21,8 @@ import org.springframework.stereotype.Service;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.YearMonth;
import java.time.temporal.TemporalAdjusters;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -46,7 +48,7 @@ public class OperMaintenanceMonitorServiceImpl implements IOperMaintenanceMonito
// Date startTime = DateUtil.parse(DateUtil.format(DateUtil.now(), "yyyy-MM") + "-01", DateUtil.PATTERN_DATE); // Date startTime = DateUtil.parse(DateUtil.format(DateUtil.now(), "yyyy-MM") + "-01", DateUtil.PATTERN_DATE);
eq(OperMaintenancePlanEntity::getIsDeleted, 0L); eq(OperMaintenancePlanEntity::getIsDeleted, 0L);
ge(OperMaintenancePlanEntity::getDisposeTime, startDate); ge(OperMaintenancePlanEntity::getDisposeTime, startDate);
lt(OperMaintenancePlanEntity::getDisposeTime, startDate.withDayOfMonth(startDate.getMonth().maxLength())); lt(OperMaintenancePlanEntity::getDisposeTime, startDate.with(TemporalAdjusters.lastDayOfMonth()));
}}); }});
//获取列表班次ID集合 //获取列表班次ID集合

32
hzims-service/operational/src/main/java/com/hnac/hzims/operational/propperties/ThreadPoolConfigProperties.java

@ -0,0 +1,32 @@
package com.hnac.hzims.operational.propperties;
import lombok.Data;
import org.springframework.context.annotation.Configuration;
/**
*
* @Author WL
* @Version v1.0
* @Serial 1.0
* @Date 2023/5/10 12:51
*/
@Configuration
@Data
public class ThreadPoolConfigProperties {
/**
* 核心数
*/
private Integer corePoolSize = 20;
/**
* 最大数
*/
private Integer maxSize = 200;
/**
* 存活时间
*/
private Integer keepAliveTime = 20;
/**
* 容量
*/
private Integer capacity = 10000;
}

415
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java

@ -249,234 +249,239 @@ public class TicketProcessServiceImpl implements TicketProcessService {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void findPending(ProcessWorkFlowResponse response) { public void findPending(ProcessWorkFlowResponse response) {
log.info("获取待处理的数据 {}", response);
log.info("获取businessKey: {}", response.getBusinessKey());
log.info("获取taskId: {}", response.getTaskId());
log.info("获取下一个审批人是: {}", response.getNextStepOperator());
log.info("获取下一个用户Id是: {}", response.getUserId());
log.info("获取当前任务名称是: {}", response.getTaskName());
log.info("获取根据handleType区分是用户还是候选组角色: {}", response.getHandleType());
//json转换表单
String formData = JSON.toJSONString(response.getVariables());
log.info("获取表单的数据:{}", formData);
FristWorkTicketVo fristWorkFlowResponse = null;
try { try {
fristWorkFlowResponse = JSONObject.parseObject(formData, FristWorkTicketVo.class); log.info("获取待处理的数据 {}", response);
} catch (Exception e) { log.info("获取businessKey: {}", response.getBusinessKey());
log.error("获取表单出现异常了~~~~"); log.info("获取taskId: {}", response.getTaskId());
throw new IllegalArgumentException(e.getMessage()); log.info("获取下一个审批人是: {}", response.getNextStepOperator());
} log.info("获取下一个用户Id是: {}", response.getUserId());
//获取表单数据 log.info("获取当前任务名称是: {}", response.getTaskName());
WorkTicketVo workTicketVo = fristWorkFlowResponse.getWorkTicketVo(); log.info("获取根据handleType区分是用户还是候选组角色: {}", response.getHandleType());
WorkTicketInfoEntity workTicket = workTicketVo.getWorkTicket(); //json转换表单
//2.流程处理 String formData = JSON.toJSONString(response.getVariables());
String businessKey = response.getBusinessKey(); log.info("获取表单的数据:{}", formData);
WorkTicketInfoEntity workTicketInfo = ticketInfoService.getById(businessKey); FristWorkTicketVo fristWorkFlowResponse = null;
if (ObjectUtils.isEmpty(workTicketInfo)) { try {
log.error("获取工作票的数据为不存在"); fristWorkFlowResponse = JSONObject.parseObject(formData, FristWorkTicketVo.class);
return; } catch (Exception e) {
} log.error("获取表单出现异常了~~~~");
//更新工作票 throw new IllegalArgumentException(e.getMessage());
workTicket.setId(workTicketInfo.getId()); }
//保存流程描述 //获取表单数据
workTicket.setCreateDept(workTicketInfo.getCreateDept()); WorkTicketVo workTicketVo = fristWorkFlowResponse.getWorkTicketVo();
workTicket.setCreateUser(workTicketInfo.getCreateUser()); WorkTicketInfoEntity workTicket = workTicketVo.getWorkTicket();
workTicket.setTenantId(workTicketInfo.getTenantId()); //2.流程处理
saveWorkTicket(workTicket, response); String businessKey = response.getBusinessKey();
//工作流ID WorkTicketInfoEntity workTicketInfo = ticketInfoService.getById(businessKey);
workTicket.setProcessInstanceId(response.getProcessInstanceId()); if (ObjectUtils.isEmpty(workTicketInfo)) {
workTicketInfoService.updateById(workTicket); log.error("获取工作票的数据为不存在");
//更新安全措施 return;
List<WorkTicketSafetyMeasureEntity> safetyMeasuresList = workTicketVo.getSafetyMeasuresList(); }
if (CollectionUtils.isNotEmpty(safetyMeasuresList)) { //更新工作票
log.info("获取安全措施的数据:{}", safetyMeasuresList); workTicket.setId(workTicketInfo.getId());
for (WorkTicketSafetyMeasureEntity item : safetyMeasuresList) { //保存流程描述
if (ObjectUtils.isNotEmpty(item.getId())) { workTicket.setCreateDept(workTicketInfo.getCreateDept());
workTicketSafetyMeasureService.updateById(item); workTicket.setCreateUser(workTicketInfo.getCreateUser());
} else { workTicket.setTenantId(workTicketInfo.getTenantId());
item.setTicketId(workTicketInfo.getId()); saveWorkTicket(workTicket, response);
workTicketSafetyMeasureService.save(item); //工作流ID
workTicket.setProcessInstanceId(response.getProcessInstanceId());
workTicketInfoService.updateById(workTicket);
//更新安全措施
List<WorkTicketSafetyMeasureEntity> safetyMeasuresList = workTicketVo.getSafetyMeasuresList();
if (CollectionUtils.isNotEmpty(safetyMeasuresList)) {
log.info("获取安全措施的数据:{}", safetyMeasuresList);
for (WorkTicketSafetyMeasureEntity item : safetyMeasuresList) {
if (ObjectUtils.isNotEmpty(item.getId())) {
workTicketSafetyMeasureService.updateById(item);
} else {
item.setTicketId(workTicketInfo.getId());
workTicketSafetyMeasureService.save(item);
}
} }
} }
} // 第二种 工作票工作任务组
// 第二种 工作票工作任务组 List<WorkTicketContentEntity> workTicketContentDtoList = workTicketVo.getWorkTicketContentDtoList();
List<WorkTicketContentEntity> workTicketContentDtoList = workTicketVo.getWorkTicketContentDtoList(); if (CollectionUtils.isNotEmpty(workTicketContentDtoList)) {
if (CollectionUtils.isNotEmpty(workTicketContentDtoList)) { log.info("获取工作票工作任务组:{}", workTicketContentDtoList);
log.info("获取工作票工作任务组:{}", workTicketContentDtoList); workTicketContentDtoList.forEach(item -> {
workTicketContentDtoList.forEach(item -> { if (ObjectUtils.isEmpty(item.getId())) {
if (ObjectUtils.isEmpty(item.getId())) { contentService.save(item);
contentService.save(item); } else {
contentService.updateById(item);
}
});
}
// 工作票延期
WorkTicketDelayEntity workTicketDelay = workTicketVo.getWorkTicketDelay();
if (ObjectUtils.isNotEmpty(workTicketDelay) && "延期".equals(workTicket.getInput())) {
WorkTicketDelayEntity workTicketDelayEntity = workTicketDelayService.selectByTicketId(workTicketInfo.getId());
log.info("获取工作票延期:{}", workTicketDelay);
workTicketDelay.setCreateDept(workTicketInfo.getCreateDept());
workTicketDelay.setTicketId(workTicketInfo.getId());
workTicketDelay.setTenantId(workTicketInfo.getTenantId());
if (ObjectUtils.isEmpty(workTicketDelayEntity)) {
log.info("正在保存工作票延期");
workTicketDelayService.save(workTicketDelay);
} else { } else {
contentService.updateById(item); log.info("正在更新工作票延期");
workTicketDelayService.updateByTicketId(workTicketDelay);
} }
});
}
// 工作票延期
WorkTicketDelayEntity workTicketDelay = workTicketVo.getWorkTicketDelay();
if (ObjectUtils.isNotEmpty(workTicketDelay) && "延期".equals(workTicket.getInput())) {
WorkTicketDelayEntity workTicketDelayEntity = workTicketDelayService.selectByTicketId(workTicketInfo.getId());
log.info("获取工作票延期:{}", workTicketDelay);
workTicketDelay.setCreateDept(workTicketInfo.getCreateDept());
workTicketDelay.setTicketId(workTicketInfo.getId());
workTicketDelay.setTenantId(workTicketInfo.getTenantId());
if (ObjectUtils.isEmpty(workTicketDelayEntity)) {
log.info("正在保存工作票延期");
workTicketDelayService.save(workTicketDelay);
} else {
log.info("正在更新工作票延期");
workTicketDelayService.updateByTicketId(workTicketDelay);
} }
}
//工作结束 //工作结束
WorkTicketFinish workTicketFinish = workTicketVo.getWorkTicketFinish(); WorkTicketFinish workTicketFinish = workTicketVo.getWorkTicketFinish();
log.info("工作结束==============>" + (workTicket.getFlowStatus().intValue())); log.info("工作结束==============>" + (workTicket.getFlowStatus().intValue()));
if (ObjectUtils.isNotEmpty(workTicketFinish)) { if (ObjectUtils.isNotEmpty(workTicketFinish)) {
WorkTicketFinish ticketFinish = workTicketFinishService.selectByTicketId(workTicketInfo.getId()); WorkTicketFinish ticketFinish = workTicketFinishService.selectByTicketId(workTicketInfo.getId());
log.info("获取工作结束:{}", workTicketFinish); log.info("获取工作结束:{}", workTicketFinish);
if (ObjectUtils.isEmpty(workTicketFinish.getId()) || ObjectUtils.isEmpty(ticketFinish)) { if (ObjectUtils.isEmpty(workTicketFinish.getId()) || ObjectUtils.isEmpty(ticketFinish)) {
log.info("获取工作结束保存成功"); log.info("获取工作结束保存成功");
workTicketFinish.setTicketId(workTicketInfo.getId()); workTicketFinish.setTicketId(workTicketInfo.getId());
workTicketFinishService.save(workTicketFinish); workTicketFinishService.save(workTicketFinish);
} else { } else {
log.info("获取工作结束更新成功"); log.info("获取工作结束更新成功");
workTicketDelay.setInitialTime(LocalDateTime.now()); workTicketDelay.setInitialTime(LocalDateTime.now());
workTicketFinishService.updateByTicketId(workTicketFinish); workTicketFinishService.updateByTicketId(workTicketFinish);
}
} }
}
// 工作开始时间和结束时间 // 工作开始时间和结束时间
// List<WorkTicketOperateTimeEntity> workTicketOperateTimeEntities = workTicketVo.getWorkTicketOperateTimeEntities(); // List<WorkTicketOperateTimeEntity> workTicketOperateTimeEntities = workTicketVo.getWorkTicketOperateTimeEntities();
// if (CollectionUtils.isNotEmpty(workTicketOperateTimeEntities)) { // if (CollectionUtils.isNotEmpty(workTicketOperateTimeEntities)) {
// log.info("工作开始时间和结束时间:{}", workTicketFinish); // log.info("工作开始时间和结束时间:{}", workTicketFinish);
// workTicketOperateTimeService.saveBatch(workTicketOperateTimeEntities); // workTicketOperateTimeService.saveBatch(workTicketOperateTimeEntities);
// } // }
//工作票负责人变更 //工作票负责人变更
WorkTicketPrincipalChangeEntity workTicketPrincipalChange = workTicketVo.getWorkTicketPrincipalChange(); WorkTicketPrincipalChangeEntity workTicketPrincipalChange = workTicketVo.getWorkTicketPrincipalChange();
if (ObjectUtils.isNotEmpty(workTicketPrincipalChange) && "转移".equals(workTicket.getInput())) { if (ObjectUtils.isNotEmpty(workTicketPrincipalChange) && "转移".equals(workTicket.getInput())) {
log.info("工作票负责人变更: {}", workTicketPrincipalChange); log.info("工作票负责人变更: {}", workTicketPrincipalChange);
//原来的负责人 //原来的负责人
User user = UserCache.getUser(workTicketPrincipalChange.getInitialPrincipal()); User user = UserCache.getUser(workTicketPrincipalChange.getInitialPrincipal());
//新的负责人 //新的负责人
User newUser = UserCache.getUser(workTicketPrincipalChange.getChangePrincipal()); User newUser = UserCache.getUser(workTicketPrincipalChange.getChangePrincipal());
workTicketPrincipalChange.setCreateDept(workTicketInfo.getCreateDept()); workTicketPrincipalChange.setCreateDept(workTicketInfo.getCreateDept());
workTicketPrincipalChange.setTicketId(workTicketInfo.getId()); workTicketPrincipalChange.setTicketId(workTicketInfo.getId());
workTicketPrincipalChange.setTenantId(workTicketInfo.getTenantId()); workTicketPrincipalChange.setTenantId(workTicketInfo.getTenantId());
if (workTicketPrincipalChange.getFlowCode() == null) { if (workTicketPrincipalChange.getFlowCode() == null) {
workTicketPrincipalChange.setFlowCode(IdWorker.getIdStr()); workTicketPrincipalChange.setFlowCode(IdWorker.getIdStr());
} }
WorkTicketPrincipalChangeEntity workTicketPrincipalChangeEntity = workTicketPrincipalChangeService.selectByTicketId(workTicket.getId()); WorkTicketPrincipalChangeEntity workTicketPrincipalChangeEntity = workTicketPrincipalChangeService.selectByTicketId(workTicket.getId());
if (ObjectUtils.isEmpty(workTicketPrincipalChangeEntity)) { if (ObjectUtils.isEmpty(workTicketPrincipalChangeEntity)) {
log.info("工作票负责人保存变更"); log.info("工作票负责人保存变更");
workTicketPrincipalChangeService.save(workTicketPrincipalChange); workTicketPrincipalChangeService.save(workTicketPrincipalChange);
} else { } else {
log.info("工作票负责人更新变更"); log.info("工作票负责人更新变更");
workTicketPrincipalChangeService.updateByTicketId(workTicketPrincipalChange); workTicketPrincipalChangeService.updateByTicketId(workTicketPrincipalChange);
}
log.info("工作负责人变更 原来的负责人 {},变更为 {}", user.getName(), newUser.getName());
workTicket.setPrincipal(workTicketPrincipalChange.getChangePrincipal());
workTicket.setPrincipalName(newUser.getName());
//更新工作票
workTicketInfoService.updateById(workTicket);
} }
log.info("工作负责人变更 原来的负责人 {},变更为 {}", user.getName(), newUser.getName());
workTicket.setPrincipal(workTicketPrincipalChange.getChangePrincipal());
workTicket.setPrincipalName(newUser.getName());
//更新工作票
workTicketInfoService.updateById(workTicket);
}
//工作票危险点分析及控制措施票 //工作票危险点分析及控制措施票
if (workTicket.getIsHazard()) { if (workTicket.getIsHazard()) {
List<TicketInfoDanger> ticketInfoDangers = workTicketVo.getTicketInfoDangers(); List<TicketInfoDanger> ticketInfoDangers = workTicketVo.getTicketInfoDangers();
if (CollectionUtils.isNotEmpty(ticketInfoDangers)) { if (CollectionUtils.isNotEmpty(ticketInfoDangers)) {
List<TicketInfoDanger> collect = ticketInfoDangers.stream().map(item -> { List<TicketInfoDanger> collect = ticketInfoDangers.stream().map(item -> {
item.setTicketId(workTicketInfo.getId()); item.setTicketId(workTicketInfo.getId());
return item; return item;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
System.out.println("工作票危险点分析及控制措施票 : " + collect); System.out.println("工作票危险点分析及控制措施票 : " + collect);
ticketInfoDangerService.saveBatch(collect); ticketInfoDangerService.saveBatch(collect);
}
} }
}
if (response.getTaskId() != null || response.getUserId() != null) { if (response.getTaskId() != null || response.getUserId() != null) {
//推送消息 //推送消息
// try { // try {
// MessagePushRecordDto message = new MessagePushRecordDto(); // MessagePushRecordDto message = new MessagePushRecordDto();
// message.setBusinessClassify("business"); // message.setBusinessClassify("business");
// message.setBusinessKey(MessageConstants.BusinessClassifyEnum.TICKETMESSAGE.getKey()); // message.setBusinessKey(MessageConstants.BusinessClassifyEnum.TICKETMESSAGE.getKey());
// message.setSubject(MessageConstants.BusinessClassifyEnum.TICKETMESSAGE.getDescription()); // message.setSubject(MessageConstants.BusinessClassifyEnum.TICKETMESSAGE.getDescription());
// message.setTaskId(workTicketInfo.getId()); // message.setTaskId(workTicketInfo.getId());
// message.setTenantId("200000"); // message.setTenantId("200000");
// message.setTypes(Arrays.asList(MessageConstants.APP_PUSH, MessageConstants.WS_PUSH)); // message.setTypes(Arrays.asList(MessageConstants.APP_PUSH, MessageConstants.WS_PUSH));
// message.setPushType(MessageConstants.IMMEDIATELY); // message.setPushType(MessageConstants.IMMEDIATELY);
// //您有一张工作票待审批,工作内容:*****,审批环节:*****; // //您有一张工作票待审批,工作内容:*****,审批环节:*****;
// String countent = // String countent =
// "您有一张工作票待审批,工作内容: ".concat(workTicketInfo.getWorkContent()) // "您有一张工作票待审批,工作内容: ".concat(workTicketInfo.getWorkContent())
// .concat(",审批环节: ") // .concat(",审批环节: ")
// .concat(response.getTaskName()); // .concat(response.getTaskName());
// message.setContent(countent); // message.setContent(countent);
// message.setDeptId(workTicketInfo.getCreateDept()); // message.setDeptId(workTicketInfo.getCreateDept());
// message.setCreateDept(workTicketInfo.getCreateDept()); // message.setCreateDept(workTicketInfo.getCreateDept());
// R<String> deptName = sysClient.getDeptName(workTicketInfo.getCreateDept()); // R<String> deptName = sysClient.getDeptName(workTicketInfo.getCreateDept());
// if (deptName.isSuccess()) { // if (deptName.isSuccess()) {
// message.setDeptName(deptName.getData()); // message.setDeptName(deptName.getData());
// } // }
// String userIds = response.getUserId(); // String userIds = response.getUserId();
// if (StringUtils.isBlank(userIds)) { // if (StringUtils.isBlank(userIds)) {
// log.error("推送的消息不能为空哦,{}", userIds); // log.error("推送的消息不能为空哦,{}", userIds);
// return; // return;
// } // }
// String[] split = userIds.split(","); // String[] split = userIds.split(",");
// for (String userId : split) { // for (String userId : split) {
// message.setPusher(userId); // message.setPusher(userId);
// User user = UserCache.getUser(NumberUtils.toLong(userId)); // User user = UserCache.getUser(NumberUtils.toLong(userId));
// if (ObjectUtils.isNotEmpty(user)) { // if (ObjectUtils.isNotEmpty(user)) {
// message.setPusherName(user.getName()); // message.setPusherName(user.getName());
// } // }
// message.setAccount(userId); // message.setAccount(userId);
// message.setCreateUser(NumberUtils.toLong(userId)); // message.setCreateUser(NumberUtils.toLong(userId));
// messageClient.sendMessage(message); // messageClient.sendMessage(message);
// log.info("推送消息成功,用户名称{},消息{}", user.getName(), message); // log.info("推送消息成功,用户名称{},消息{}", user.getName(), message);
// } // }
// } catch (Exception e) { // } catch (Exception e) {
// e.printStackTrace(); // e.printStackTrace();
// } // }
BusinessMessageDTO businessMessageDTO = new BusinessMessageDTO(); BusinessMessageDTO businessMessageDTO = new BusinessMessageDTO();
businessMessageDTO.setBusinessClassify("business"); businessMessageDTO.setBusinessClassify("business");
businessMessageDTO.setBusinessKey(MessageConstants.BusinessClassifyEnum.TICKETMESSAGE.getKey()); businessMessageDTO.setBusinessKey(MessageConstants.BusinessClassifyEnum.TICKETMESSAGE.getKey());
businessMessageDTO.setSubject(MessageConstants.BusinessClassifyEnum.TICKETMESSAGE.getDescription()); businessMessageDTO.setSubject(MessageConstants.BusinessClassifyEnum.TICKETMESSAGE.getDescription());
businessMessageDTO.setTaskId(workTicketInfo.getId()); businessMessageDTO.setTaskId(workTicketInfo.getId());
businessMessageDTO.setTenantId("200000"); businessMessageDTO.setTenantId("200000");
//您有一张工作票待审批,工作内容:*****,审批环节:*****; //您有一张工作票待审批,工作内容:*****,审批环节:*****;
String countent = String countent =
"您有一张工作票待审批,工作内容: ".concat(workTicketInfo.getWorkContent()) "您有一张工作票待审批,工作内容: ".concat(workTicketInfo.getWorkContent())
.concat(",审批环节: ") .concat(",审批环节: ")
.concat(response.getTaskName()); .concat(response.getTaskName());
businessMessageDTO.setContent(countent); businessMessageDTO.setContent(countent);
businessMessageDTO.setDeptId(workTicketInfo.getCreateDept()); businessMessageDTO.setDeptId(workTicketInfo.getCreateDept());
R<String> deptName = sysClient.getDeptName(workTicketInfo.getCreateDept()); R<String> deptName = sysClient.getDeptName(workTicketInfo.getCreateDept());
if (deptName.isSuccess()) { if (deptName.isSuccess()) {
businessMessageDTO.setDeptName(deptName.getData()); businessMessageDTO.setDeptName(deptName.getData());
} }
String userIds = response.getUserId(); String userIds = response.getUserId();
businessMessageDTO.setUserIds(userIds); businessMessageDTO.setUserIds(userIds);
businessMessageDTO.setCreateUser(workTicketInfo.getCreateUser()); businessMessageDTO.setCreateUser(workTicketInfo.getCreateUser());
System.out.println("======================================================"); System.out.println("======================================================");
System.out.println("businessMessageDTO = " + businessMessageDTO); System.out.println("businessMessageDTO = " + businessMessageDTO);
System.out.println("======================================================"); System.out.println("======================================================");
R booleanR = messageClient.sendAppAndWsMsgByUsers(businessMessageDTO); R booleanR = messageClient.sendAppAndWsMsgByUsers(businessMessageDTO);
if (!booleanR.isSuccess()) { if (!booleanR.isSuccess()) {
throw new ServiceException("消息推送失败"); throw new ServiceException("消息推送失败");
}
log.info("推送成功~");
} }
log.info("推送成功~"); } catch (Exception e) {
e.printStackTrace();
} }
} }

Loading…
Cancel
Save