|
|
@ -3,6 +3,7 @@ package com.hnac.hzims.operational.maintenance.scheduled; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
|
|
|
import com.hnac.hzims.equipment.entity.EmInfoEntity; |
|
|
|
import com.hnac.hzims.equipment.feign.IEmInfoClient; |
|
|
|
import com.hnac.hzims.equipment.feign.IEmInfoClient; |
|
|
|
import com.hnac.hzims.operational.constants.FlowKeyConstants; |
|
|
|
import com.hnac.hzims.operational.constants.FlowKeyConstants; |
|
|
|
import com.hnac.hzims.operational.constants.RedisKeyConstants; |
|
|
|
import com.hnac.hzims.operational.constants.RedisKeyConstants; |
|
|
@ -61,6 +62,7 @@ public class MaintenanceTaskSchedule { |
|
|
|
private final IFlowClient flowClient; |
|
|
|
private final IFlowClient flowClient; |
|
|
|
private final IImsDutyMainService dutyMainService; |
|
|
|
private final IImsDutyMainService dutyMainService; |
|
|
|
private final RedisTemplate redisTemplate; |
|
|
|
private final RedisTemplate redisTemplate; |
|
|
|
|
|
|
|
private final IEmInfoClient emInfoClient; |
|
|
|
|
|
|
|
|
|
|
|
@XxlJob(GENERATE_MAINTENANCE_TASK_SCHEDULE) |
|
|
|
@XxlJob(GENERATE_MAINTENANCE_TASK_SCHEDULE) |
|
|
|
public ReturnT<String> execute(String param) throws Exception { |
|
|
|
public ReturnT<String> execute(String param) throws Exception { |
|
|
@ -87,24 +89,24 @@ 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 -> |
|
|
|
String disposerName = Optional.ofNullable(plan.getDisposer()).map(UserCache::getUser).map(User::getName).orElse(null); |
|
|
|
{ |
|
|
|
taskEntity.setDisposerName(disposerName); |
|
|
|
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())); |
|
|
|
if(StringUtil.isNotBlank(plan.getEmCode())){ |
|
|
|
if(StringUtil.isNotBlank(plan.getEmCode())){ |
|
|
|
String[] emCodeList = plan.getEmCode().split(","); |
|
|
|
List<String> emCodeList = Func.toStrList(",", plan.getEmCode()); |
|
|
|
for(String emCode : emCodeList){ |
|
|
|
emCodeList.stream().filter(StringUtil::isNotBlank).forEach(emCode -> { |
|
|
|
|
|
|
|
EmInfoEntity emInfoEntity = emInfoClient.getByCode(emCode); |
|
|
|
|
|
|
|
if(ObjectUtil.isEmpty(emInfoEntity)) { |
|
|
|
|
|
|
|
log.error( "[{}]设备编号未查询到相关设备,生成任务失败!",emCode); |
|
|
|
|
|
|
|
XxlJobLogger.log("[" + emCode + "]设备编号未查询到相关设备,生成任务失败!"); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
taskEntity.setEmCode(emCode); |
|
|
|
taskEntity.setEmCode(emCode); |
|
|
|
|
|
|
|
taskEntity.setEmName(emInfoEntity.getName()); |
|
|
|
this.createTask(taskEntity,plan); |
|
|
|
this.createTask(taskEntity,plan); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
this.createTask(taskEntity,plan); |
|
|
|
this.createTask(taskEntity,plan); |
|
|
@ -139,7 +141,7 @@ public class MaintenanceTaskSchedule { |
|
|
|
Instant instant = task.getDisposeTime().toInstant(); |
|
|
|
Instant instant = task.getDisposeTime().toInstant(); |
|
|
|
ZoneId zoneId = ZoneId.systemDefault(); |
|
|
|
ZoneId zoneId = ZoneId.systemDefault(); |
|
|
|
LocalDateTime disposeTime = instant.atZone(zoneId).toLocalDateTime(); |
|
|
|
LocalDateTime disposeTime = instant.atZone(zoneId).toLocalDateTime(); |
|
|
|
task.setPlanEndTime(disposeTime.plusHours(task.getHours())); |
|
|
|
task.setPlanEndTime(disposeTime.plusHours(task.getPeriod())); |
|
|
|
// 当模式为班次时
|
|
|
|
// 当模式为班次时
|
|
|
|
Integer maintenanceModel = plan.getMaintenanceModel(); |
|
|
|
Integer maintenanceModel = plan.getMaintenanceModel(); |
|
|
|
if(Func.isNotEmpty(maintenanceModel) && maintenanceModel == 2 ) { |
|
|
|
if(Func.isNotEmpty(maintenanceModel) && maintenanceModel == 2 ) { |
|
|
@ -149,20 +151,11 @@ 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<Long> userIdList = Func.toLongList("\\^", userId); |
|
|
|
List<String> list = Arrays.asList(split); |
|
|
|
String disposerName = userIdList.stream().map(UserCache::getUser).filter(Func::isNotEmpty) |
|
|
|
String disposerName= list.stream().map(s->{ |
|
|
|
.map(User::getName).filter(StringUtil::isNotBlank).collect(Collectors.joining(",")); |
|
|
|
User user = UserCache.getUser(Long.valueOf(s)); |
|
|
|
task.setDisposerName(Optional.ofNullable(disposerName).filter(StringUtil::isNotBlank).orElse(null)); |
|
|
|
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()+"的日常维护计划未获取到值班人员,未生成任务。"); |
|
|
@ -205,5 +198,4 @@ public class MaintenanceTaskSchedule { |
|
|
|
R<BladeFlow> flowResult = flowClient.startProcessInstanceContainNameByKey(FlowKeyConstants.MAINTENANCE_TASK_FLOW_KEY, String.valueOf(task.getId()), task.getTitle(), params); |
|
|
|
R<BladeFlow> flowResult = flowClient.startProcessInstanceContainNameByKey(FlowKeyConstants.MAINTENANCE_TASK_FLOW_KEY, String.valueOf(task.getId()), task.getTitle(), params); |
|
|
|
return Optional.ofNullable(flowResult).filter(r -> r.isSuccess()).map(R::getData).map(BladeFlow::getProcessInstanceId).orElse(null); |
|
|
|
return Optional.ofNullable(flowResult).filter(r -> r.isSuccess()).map(R::getData).map(BladeFlow::getProcessInstanceId).orElse(null); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|