Browse Source

增加:执行人姓名

zhongwei
ty 7 months ago
parent
commit
a86b43f606
  1. 25
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskSchedule.java

25
hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskSchedule.java

@ -21,6 +21,7 @@ import com.xxl.job.core.handler.annotation.XxlJob;
import com.xxl.job.core.log.XxlJobLogger; import com.xxl.job.core.log.XxlJobLogger;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springblade.core.log.logger.BladeLogger; import org.springblade.core.log.logger.BladeLogger;
import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.secure.utils.AuthUtil;
@ -28,6 +29,8 @@ import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.*; import org.springblade.core.tool.utils.*;
import org.springblade.flow.core.entity.BladeFlow; import org.springblade.flow.core.entity.BladeFlow;
import org.springblade.flow.core.feign.IFlowClient; import org.springblade.flow.core.feign.IFlowClient;
import org.springblade.system.user.cache.UserCache;
import org.springblade.system.user.entity.User;
import org.springblade.system.user.feign.IUserClient; import org.springblade.system.user.feign.IUserClient;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
@ -84,6 +87,15 @@ public class MaintenanceTaskSchedule {
OperMaintenanceTaskEntity taskEntity = BeanUtil.copy(plan,OperMaintenanceTaskEntity.class); OperMaintenanceTaskEntity taskEntity = BeanUtil.copy(plan,OperMaintenanceTaskEntity.class);
taskEntity.setPlanId(plan.getId()); taskEntity.setPlanId(plan.getId());
taskEntity.setDisposer(Optional.ofNullable(plan.getDisposer()).map(String::valueOf).orElse(null)); taskEntity.setDisposer(Optional.ofNullable(plan.getDisposer()).map(String::valueOf).orElse(null));
taskEntity.setDisposerName(Optional.ofNullable(plan.getDisposer()).map(s ->
{
User user = UserCache.getUser(s);
if (ObjectUtil.isNotEmpty(user)){
return user.getName();
}else {
return "";
}
}).filter(s->StringUtils.isNotBlank(s)).orElse(null));
LocalDateTime disposeTime = taskEntity.getDisposeTime().toInstant() LocalDateTime disposeTime = taskEntity.getDisposeTime().toInstant()
.atZone(ZoneId.systemDefault()).toLocalDateTime(); .atZone(ZoneId.systemDefault()).toLocalDateTime();
taskEntity.setPlanEndTime(disposeTime.plusHours(taskEntity.getHours())); taskEntity.setPlanEndTime(disposeTime.plusHours(taskEntity.getHours()));
@ -137,7 +149,20 @@ public class MaintenanceTaskSchedule {
ImsDutyMainEntity entity = dutyMainService.getOne(dutyQuery); ImsDutyMainEntity entity = dutyMainService.getOne(dutyQuery);
if (ObjectUtil.isNotEmpty(entity) && StringUtils.isNotEmpty(entity.getDutyPersonIds())) { if (ObjectUtil.isNotEmpty(entity) && StringUtils.isNotEmpty(entity.getDutyPersonIds())) {
String userId = entity.getDutyPersonIds(); String userId = entity.getDutyPersonIds();
String[] split = userId.split("\\^");
task.setDisposer(userId.replaceAll("\\^", ",")); task.setDisposer(userId.replaceAll("\\^", ","));
if (ArrayUtils.isNotEmpty(split)){
List<String> list = Arrays.asList(split);
String disposerName= list.stream().map(s->{
User user = UserCache.getUser(Long.valueOf(s));
if (ObjectUtil.isNotEmpty(user)){
return user.getName();}
return "";
}).filter(s->StringUtils.isNotBlank(s)).collect(Collectors.joining(","));
if (StringUtils.isNotBlank(disposerName)) {
task.setDisposerName(disposerName);
}
}
} }
else { else {
XxlJobLogger.log("ID为:"+plan.getId()+"的日常维护计划未获取到值班人员,未生成任务。"); XxlJobLogger.log("ID为:"+plan.getId()+"的日常维护计划未获取到值班人员,未生成任务。");

Loading…
Cancel
Save