|
|
@@ -24,6 +24,7 @@ import com.github.zuihou.business.productionResourceCenter.service.Productionres
|
|
|
import com.github.zuihou.business.util.MsgUtil;
|
|
|
import com.github.zuihou.common.constant.DictionaryKey;
|
|
|
import com.github.zuihou.common.util.DateUtil;
|
|
|
+import com.github.zuihou.context.BaseContextHandler;
|
|
|
import com.github.zuihou.database.mybatis.conditions.Wraps;
|
|
|
import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
|
|
|
import com.google.common.collect.Maps;
|
|
|
@@ -74,6 +75,7 @@ public class AsyncServiceImpl implements AsyncService {
|
|
|
@Async
|
|
|
public Boolean asyncTaskSchedule() {
|
|
|
log.warn("[线边库加工设备重调度]");
|
|
|
+ BaseContextHandler.setTenant("0000");
|
|
|
LbqWrapper<Productionresource> lbqWrapper = new LbqWrapper<Productionresource>();
|
|
|
lbqWrapper.eq(Productionresource::getStatus, "1").eq(Productionresource::getOnlineStatus, "1").isNotNull(Productionresource::getModeSpecification);
|
|
|
//获取当前处于空闲状态的设备(排除正在加工以及报错的机床)
|
|
|
@@ -94,7 +96,7 @@ public class AsyncServiceImpl implements AsyncService {
|
|
|
//获取线边库加工零件批次号
|
|
|
List<String> completeBatchNos = stockInfoService.list(new LbqWrapper<StockInfo>().eq(StockInfo::getGoodsType, "4").in(StockInfo::getStorgeId, storgeIds)).stream().map(StockInfo::getCompleteBatchNo).collect(Collectors.toList());
|
|
|
|
|
|
- List<TaskNode> taskNodeList = completeBatchNos.size() > 0 ? taskNodeService.list(new LbqWrapper<TaskNode>().eq(TaskNode::getExeStatus, "2").in(TaskNode::getTargetResourceId, macResourceIds).in(TaskNode::getCompleteBatchNo, completeBatchNos).eq(TaskNode::getNodeName, "放本序设备").orderByAsc(TaskNode::getStartTime)) : Lists.newArrayList();
|
|
|
+ List<TaskNode> taskNodeList = completeBatchNos.size() > 0 ? taskNodeService.list(new LbqWrapper<TaskNode>().eq(TaskNode::getExeStatus, "2").in(TaskNode::getCompleteBatchNo, completeBatchNos).eq(TaskNode::getNodeName, "放本序设备").orderByAsc(TaskNode::getStartTime)) : Lists.newArrayList();
|
|
|
// 2. 判断线边库任务节点是否存在
|
|
|
if (taskNodeList != null && taskNodeList.size() > 0) {
|
|
|
List<Long> ids = taskNodeList.stream().map(TaskNode::getTaskId).distinct().collect(Collectors.toList());
|
|
|
@@ -103,19 +105,26 @@ public class AsyncServiceImpl implements AsyncService {
|
|
|
List<Long> procedureIdList = taskList.stream().map(TTask::getProcedureId).collect(Collectors.toList());
|
|
|
Map<Long, List<BomProcedureProductionresource>> procedureCntMap = bomProcedureProductionresourceService.list(new LambdaQueryWrapper<BomProcedureProductionresource>().in(BomProcedureProductionresource::getProcedureId, procedureIdList)).stream().collect(Collectors.groupingBy(BomProcedureProductionresource::getProcedureId));
|
|
|
//获取工艺配置中允许变换加工设备的任务
|
|
|
- final List<Long> procedureIdFinalList = procedureCntMap.entrySet().stream().filter(item->item.getValue().size()>1).map(Map.Entry::getKey).collect(Collectors.toList());
|
|
|
- if(procedureIdList.size()>1){
|
|
|
+ final List<Long> procedureIdFinalList = procedureCntMap.entrySet().stream().filter(item->{
|
|
|
+ List<Long> tempIds = item.getValue().stream().map(BomProcedureProductionresource::getResourceId).filter(item2->macResourceIds.contains(item2)).collect(Collectors.toList());
|
|
|
+ return item.getValue().size()>1 && tempIds.size()>0;
|
|
|
+ }).map(Map.Entry::getKey).collect(Collectors.toList());
|
|
|
+ if(procedureIdFinalList.size()>0){
|
|
|
taskList = taskList.stream().filter(item->procedureIdFinalList.contains(item.getProcedureId())).collect(Collectors.toList());
|
|
|
}
|
|
|
//3. 判断自动调度任务是否存在
|
|
|
if(taskList.size()>0){
|
|
|
//以加工机床分类判断是否某类线边库任务已经执行动态调度
|
|
|
Map<Integer, List<TTask>> taskMaps = taskList.stream().collect(Collectors.groupingBy(item->{
|
|
|
- String deviceType = devicesMap.get(item.getResourceId());
|
|
|
- return DictionaryKey.YJ_DEVICE_TYPE.get(deviceType);
|
|
|
+ Productionresource productionresource = productionresourceBizMapper.selectById(item.getResourceId());
|
|
|
+ return DictionaryKey.YJ_DEVICE_TYPE.get(productionresource.getModeSpecification());
|
|
|
}));
|
|
|
//过滤已经执行动态调度
|
|
|
- List<Integer> upDeviceTypes = DictionaryKey.YJ_DEVICE_TYPE.entrySet().stream().filter(map -> !taskMaps.containsKey(map.getValue())).distinct().map(Map.Entry::getValue).collect(Collectors.toList());
|
|
|
+ List<Integer> upDeviceTypes = DictionaryKey.YJ_DEVICE_TYPE.entrySet().stream().filter(map -> {
|
|
|
+ if(!taskMaps.containsKey(map.getValue())) return true;
|
|
|
+ List<TTask> dataList = taskMaps.get(map.getValue()).stream().filter(tTask->tTask.getIsReload()>0).collect(Collectors.toList());
|
|
|
+ return dataList.size() == 0? true : false;
|
|
|
+ }).distinct().map(Map.Entry::getValue).collect(Collectors.toList());
|
|
|
//3.判断是否有品牌机床可以执行调度 =0表明所有品牌机床都已执行了动态调度
|
|
|
if(upDeviceTypes.size()>0){
|
|
|
//获取可以去允许机床品牌的任务,并按时间升序获取等待时间最长任务
|
|
|
@@ -164,7 +173,6 @@ public class AsyncServiceImpl implements AsyncService {
|
|
|
dyChangedInfo.put("time", DateUtil.formatTime(new Date()));
|
|
|
|
|
|
msgUtil.redis_set(DemoLineConstant.DEMOLINE_RESOURCE_DY_CHANGE + "_" + runTask.getId(), dyChangedInfo.toJSONString(), 1, TimeUnit.DAYS);
|
|
|
- msgUtil.redis_del(YunjianConstant.YUNJIAN_XBK_SCHEDULE);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
@@ -173,8 +181,8 @@ public class AsyncServiceImpl implements AsyncService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
}
|
|
|
+ msgUtil.redis_del(YunjianConstant.YUNJIAN_XBK_SCHEDULE);
|
|
|
return true;
|
|
|
}
|
|
|
}
|