|
@@ -20,8 +20,10 @@ import com.github.zuihou.business.operationManagementCenter.service.TaskNodeServ
|
|
|
import com.github.zuihou.business.operationManagementCenter.service.WorkpieceService;
|
|
|
import com.github.zuihou.business.productionReadyCenter.dao.AAutoNodeLogMapper;
|
|
|
import com.github.zuihou.business.productionReadyCenter.dao.BBomMapper;
|
|
|
+import com.github.zuihou.business.productionReadyCenter.dao.BomProcedureMapper;
|
|
|
import com.github.zuihou.business.productionReadyCenter.entity.AAutoNodeLog;
|
|
|
import com.github.zuihou.business.productionReadyCenter.entity.BBom;
|
|
|
+import com.github.zuihou.business.productionReadyCenter.entity.BomProcedure;
|
|
|
import com.github.zuihou.business.productionReadyCenter.service.AAutoNodeLogService;
|
|
|
import com.github.zuihou.business.productionReadyCenter.service.BomProcedureProductionresourceService;
|
|
|
import com.github.zuihou.business.productionResourceCenter.dao.ProductionresourceBizMapper;
|
|
@@ -141,6 +143,8 @@ public class TaskWorkNode {
|
|
|
private ProductionresourcePositionMapper productionresourcePositionMapper;
|
|
|
@Autowired
|
|
|
private BBomMapper bBomMapper;
|
|
|
+ @Autowired
|
|
|
+ private BomProcedureMapper bomProcedureMapper;
|
|
|
|
|
|
|
|
|
//总控端口
|
|
@@ -680,7 +684,10 @@ public class TaskWorkNode {
|
|
|
public Map checkXbkCon(TaskNode taskNode, TTask task, Map<String, Object> dataMap) {
|
|
|
ZZone zone = dataMap.get("zone") == null ? null : (ZZone) dataMap.get("zone");
|
|
|
int count = Integer.parseInt(dataMap.get(taskNode.getId().toString() + "count") == null ? "0" : dataMap.get(taskNode.getId().toString() + "count").toString());
|
|
|
-
|
|
|
+ BomProcedure bomProcedure = bomProcedureMapper.selectOne(Wraps.<BomProcedure>lbQ().eq(BomProcedure::getId,task.getProcedureId()));
|
|
|
+ BBom bom = bBomMapper.selectById(task.getBomId());
|
|
|
+ Long bomZzoneId = bom.getZoneId();
|
|
|
+ ZZone bomzZone = zoneService.getById(bomZzoneId);
|
|
|
|
|
|
// 判断该节点使用那条线的plc
|
|
|
Map<String, String> plcInfo = DictionaryKey.PLC_CATEGORY.get(zone.getNo());
|
|
@@ -706,9 +713,9 @@ public class TaskWorkNode {
|
|
|
|
|
|
if (count == 0) {//第一步的时候锁定资源
|
|
|
//判断机器人是否为空
|
|
|
+ robotList = productionresourcePositionService.getFreeProductionresourcePositionByIds(new String[]{taskNode.getResourceId().toString()});
|
|
|
Map<String, List<ProductionresourcePosition>> jqrMap = robotList.stream().collect(groupingBy(ProductionresourcePosition::getPointId));
|
|
|
|
|
|
- robotList = productionresourcePositionService.getFreeProductionresourcePositionByIds(new String[]{taskNode.getResourceId().toString()});
|
|
|
// //目标地址和类型
|
|
|
// targetStorge = workpieceService.getWorkPieceTargetStock(taskNode.getId());
|
|
|
|
|
@@ -721,37 +728,44 @@ public class TaskWorkNode {
|
|
|
ProductionresourcePosition po = logical(robotList,dataMap);
|
|
|
//机器人手抓没被锁定,并且有空闲未知
|
|
|
if (po != null) {
|
|
|
- Map returnMap = getTargetStorge(nextTaskNode, taskNode.getFindAgvFlag(), zone);
|
|
|
+ Map returnMap = getTargetStorge(nextTaskNode, taskNode.getFindAgvFlag(), zone,bomProcedure.getType(),bomzZone);
|
|
|
targetStorge = returnMap.get("store") == null ? null : (Storge) returnMap.get("store");
|
|
|
|
|
|
- jqrStorge = storgeService.getById(jqrMap.get(DemoLineConstant.DEMOLINE_RJQR_ZS).get(0).getStorgeId());
|
|
|
- jqrStorge.setCompleteBatchNo(task.getCompleteBatchNo());
|
|
|
- storgeService.lockStorge(jqrStorge, taskNode.getId());
|
|
|
- //锁定一个缓存位
|
|
|
- List<ProductionresourcePosition> hcwList = jqrMap.get(jqrMap.keySet().stream().filter(p -> !DemoLineConstant.DEMOLINE_RJQR_ZS.equals(p)).findFirst().get());
|
|
|
- Storge hcwStorge = storgeService.getById(hcwList.get(0).getStorgeId());
|
|
|
- hcwStorge.setCompleteBatchNo(task.getCompleteBatchNo());
|
|
|
- storgeService.lockStorge(hcwStorge, taskNode.getId());
|
|
|
-
|
|
|
- //锁定目标库位
|
|
|
- targetStorge.setCompleteBatchNo(task.getCompleteBatchNo());
|
|
|
- storgeService.lockStorge(targetStorge, taskNode.getId());
|
|
|
-
|
|
|
- //抓手缓存
|
|
|
- msgUtil.redis_set(DemoCacheKey.YUNJIAN_CAMP + "_" + YunjianConstant.YUNJIAN_JXS + taskNode.getId(), jqrStorge, 1, TimeUnit.DAYS);
|
|
|
- //缓存位缓存
|
|
|
- msgUtil.redis_set(DemoCacheKey.YUNJIAN_CAMP + "_" + YunjianConstant.YUNJIAN_HCW + taskNode.getId(), hcwStorge, 1, TimeUnit.DAYS);
|
|
|
- //目标缓存
|
|
|
- msgUtil.redis_set(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_STORE + taskNode.getId(), targetStorge, 1, TimeUnit.DAYS);
|
|
|
-
|
|
|
- //满足条件--机器人空闲,设备或线边库有一个空闲
|
|
|
- Map locationMap = new HashMap();
|
|
|
- locationMap.put("location", startStore.getPointId());
|
|
|
- dataMap.put("data", locationMap);
|
|
|
-
|
|
|
- dataMap.put("method", "MoveRobotPosition");
|
|
|
+ if(null != targetStorge){
|
|
|
+ jqrStorge = storgeService.getById(jqrMap.get(DemoLineConstant.DEMOLINE_RJQR_ZS).get(0).getStorgeId());
|
|
|
+ jqrStorge.setCompleteBatchNo(task.getCompleteBatchNo());
|
|
|
+ storgeService.lockStorge(jqrStorge, taskNode.getId());
|
|
|
+ //锁定一个缓存位
|
|
|
+ List<ProductionresourcePosition> hcwList = jqrMap.get(jqrMap.keySet().stream().filter(p -> !DemoLineConstant.DEMOLINE_RJQR_ZS.equals(p)).findFirst().get());
|
|
|
+ Storge hcwStorge = storgeService.getById(hcwList.get(0).getStorgeId());
|
|
|
+ hcwStorge.setCompleteBatchNo(task.getCompleteBatchNo());
|
|
|
+ storgeService.lockStorge(hcwStorge, taskNode.getId());
|
|
|
+
|
|
|
+ //锁定目标库位
|
|
|
+ targetStorge.setCompleteBatchNo(task.getCompleteBatchNo());
|
|
|
+ storgeService.lockStorge(targetStorge, taskNode.getId());
|
|
|
+
|
|
|
+ //抓手缓存
|
|
|
+ msgUtil.redis_set(DemoCacheKey.YUNJIAN_CAMP + "_" + YunjianConstant.YUNJIAN_JXS + taskNode.getId(), jqrStorge, 1, TimeUnit.DAYS);
|
|
|
+ //缓存位缓存
|
|
|
+ msgUtil.redis_set(DemoCacheKey.YUNJIAN_CAMP + "_" + YunjianConstant.YUNJIAN_HCW + taskNode.getId(), hcwStorge, 1, TimeUnit.DAYS);
|
|
|
+ //目标缓存
|
|
|
+ msgUtil.redis_set(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_STORE + taskNode.getId(), targetStorge, 1, TimeUnit.DAYS);
|
|
|
+
|
|
|
+ //满足条件--机器人空闲,设备或线边库有一个空闲
|
|
|
+ Map locationMap = new HashMap();
|
|
|
+ locationMap.put("location", startStore.getPointId());
|
|
|
+ dataMap.put("data", locationMap);
|
|
|
+
|
|
|
+ dataMap.put("method", "MoveRobotPosition");
|
|
|
+ dataMap.put("result", true);
|
|
|
+ }else{
|
|
|
+ dataMap.put("result", false);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ dataMap.put("result", false);
|
|
|
}
|
|
|
- dataMap.put("result", po != null);
|
|
|
+
|
|
|
} else if (count == 1) {
|
|
|
jqrStorge = (Storge) msgUtil.redis_get(DemoCacheKey.YUNJIAN_CAMP + "_" + YunjianConstant.YUNJIAN_JXS + taskNode.getId());
|
|
|
dataMap.put("method", "GetFlexibleWire");
|
|
@@ -822,40 +836,49 @@ public class TaskWorkNode {
|
|
|
|
|
|
if (count == 0) {//第一步的时候锁定资源
|
|
|
//目标地址和类型
|
|
|
- Map returnMap = getTargetStorge(taskNode, taskNode.getFindAgvFlag(), zone);
|
|
|
- targetStorge = returnMap.get("store") == null ? null : (Storge) returnMap.get("store");
|
|
|
robotList = productionresourcePositionService.getFreeProductionresourcePositionByIds(new String[]{taskNode.getResourceId().toString()});
|
|
|
|
|
|
dataMap.put("method", "GetServoStacker");
|
|
|
- ProductionresourcePosition po = logical(robotList, targetStorge, dataMap);
|
|
|
+ ProductionresourcePosition po = logical(robotList,dataMap);
|
|
|
if (po != null) {
|
|
|
- //目标地址和类型
|
|
|
- jqrStorge = storgeService.getById(robotList.get(0).getStorgeId());
|
|
|
- Storge startStore = workpieceService.getWorkPieceStock(taskNode.getCompleteBatchNo(), false);
|
|
|
-
|
|
|
- dataMap.put("fromStorge", startStore);
|
|
|
-
|
|
|
- Map locationMap = new HashMap();
|
|
|
- locationMap.put("location", startStore.getPointId());
|
|
|
- dataMap.put("data", locationMap);
|
|
|
- //出入库类型
|
|
|
- dataMap.put(DemoLineConstant.DEMOLINE_STOCK_TYPE, DemoLineConstant.DEMOLINE_STOCK_TYPE_ALL_CRK);
|
|
|
- //目的地为机器人手臂
|
|
|
- dataMap.put("toStorge", jqrStorge);
|
|
|
- //锁定机器人
|
|
|
- jqrStorge.setCompleteBatchNo(task.getCompleteBatchNo());
|
|
|
- storgeService.lockStorge(jqrStorge, taskNode.getId());
|
|
|
-
|
|
|
- //锁定目标库位
|
|
|
- targetStorge.setCompleteBatchNo(task.getCompleteBatchNo());
|
|
|
- storgeService.lockStorge(targetStorge, taskNode.getId());
|
|
|
-
|
|
|
- //抓手缓存
|
|
|
- msgUtil.redis_set(DemoCacheKey.YUNJIAN_CAMP + "_" + YunjianConstant.YUNJIAN_JXS + taskNode.getId(), jqrStorge, 1, TimeUnit.DAYS);
|
|
|
- //目标缓存
|
|
|
- msgUtil.redis_set(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_STORE + taskNode.getId(), targetStorge, 1, TimeUnit.DAYS);
|
|
|
+
|
|
|
+ Map returnMap = getTargetStorge(taskNode, taskNode.getFindAgvFlag(), zone,bomProcedure.getType(),bomzZone);
|
|
|
+ targetStorge = returnMap.get("store") == null ? null : (Storge) returnMap.get("store");
|
|
|
+
|
|
|
+ if(null != targetStorge){
|
|
|
+ //目标地址和类型
|
|
|
+ jqrStorge = storgeService.getById(robotList.get(0).getStorgeId());
|
|
|
+ Storge startStore = workpieceService.getWorkPieceStock(taskNode.getCompleteBatchNo(), false);
|
|
|
+
|
|
|
+ dataMap.put("fromStorge", startStore);
|
|
|
+
|
|
|
+ Map locationMap = new HashMap();
|
|
|
+ locationMap.put("location", startStore.getPointId());
|
|
|
+ dataMap.put("data", locationMap);
|
|
|
+ //出入库类型
|
|
|
+ dataMap.put(DemoLineConstant.DEMOLINE_STOCK_TYPE, DemoLineConstant.DEMOLINE_STOCK_TYPE_ALL_CRK);
|
|
|
+ //目的地为机器人手臂
|
|
|
+ dataMap.put("toStorge", jqrStorge);
|
|
|
+ //锁定机器人
|
|
|
+ jqrStorge.setCompleteBatchNo(task.getCompleteBatchNo());
|
|
|
+ storgeService.lockStorge(jqrStorge, taskNode.getId());
|
|
|
+
|
|
|
+ //锁定目标库位
|
|
|
+ targetStorge.setCompleteBatchNo(task.getCompleteBatchNo());
|
|
|
+ storgeService.lockStorge(targetStorge, taskNode.getId());
|
|
|
+
|
|
|
+ //抓手缓存
|
|
|
+ msgUtil.redis_set(DemoCacheKey.YUNJIAN_CAMP + "_" + YunjianConstant.YUNJIAN_JXS + taskNode.getId(), jqrStorge, 1, TimeUnit.DAYS);
|
|
|
+ //目标缓存
|
|
|
+ msgUtil.redis_set(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_STORE + taskNode.getId(), targetStorge, 1, TimeUnit.DAYS);
|
|
|
+ dataMap.put("result", true);
|
|
|
+ }else{
|
|
|
+ dataMap.put("result", false);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ dataMap.put("result", false);
|
|
|
}
|
|
|
- dataMap.put("result", po != null);
|
|
|
+
|
|
|
} else if (count == 1) {
|
|
|
targetStorge = msgUtil.redis_get(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_STORE + taskNode.getId()) == null ? null : (Storge) msgUtil.redis_get(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_STORE + taskNode.getId());
|
|
|
dataMap.put("method", "SendServoStacker");
|
|
@@ -874,56 +897,129 @@ public class TaskWorkNode {
|
|
|
return dataMap;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- public Map getTargetStorge(TaskNode taskNode, String findAgvFlag, ZZone zZone) {
|
|
|
+ public Map getTargetStorge(TaskNode taskNode, String findAgvFlag, ZZone zZone,String bomProcedureType, ZZone bomzZone) {
|
|
|
Map returnMap = new HashMap();
|
|
|
Storge targetStorge = null;
|
|
|
- Storge agvEndStationStorge = null;
|
|
|
Long resourceId = taskNode.getTargetResourceId();
|
|
|
+ String xbkFlag = "";
|
|
|
+
|
|
|
+ if("1".equals(findAgvFlag)){ //需要提前锁定下个接驳位
|
|
|
+ // begin modify by yejian on 20220513 for agv动态查找满足抽检一个工序需多次调度agv问题
|
|
|
+ // 先找到处理节点下一节点agv起点地址
|
|
|
|
|
|
- if ("1".equals(findAgvFlag)) {//需要提前锁定下个接驳位
|
|
|
- //获取接驳位。
|
|
|
+ TaskNode lastAgvTaskNode = taskNodeService.getNextNTaskNode(taskNode,1);;
|
|
|
Map map = storgeService.getPlateStorgeByNo(zZone);
|
|
|
- targetStorge = map.get("storge") == null ? null : (Storge) map.get("storge");
|
|
|
- String targetResourceId = map.get("resourceId") == null ? null : (String) map.get("resourceId");
|
|
|
- //对面产线接驳位不为空TODO
|
|
|
- String[] jbwArr = DictionaryKey.YJ_ZONE_JBW.get(zZone.getName()).split(",");
|
|
|
+
|
|
|
+
|
|
|
+ targetStorge = map.get("storge") ==null?null:(Storge)map.get("storge");
|
|
|
+ String targetResourceId = map.get("resourceId") ==null?null:(String)map.get("resourceId");
|
|
|
+ // 在向下找agv终点位子
|
|
|
+ // 下一个节点机器人所属产线
|
|
|
+ TaskNode afterLastAgvTaskNode = taskNodeService.getNextNTaskNode(lastAgvTaskNode,1);
|
|
|
+ ZZoneProductionresource zoneProductionresource = zZoneProductionresourceMapper.selectOne(Wraps.<ZZoneProductionresource>lbQ().eq(ZZoneProductionresource::getResourceId,afterLastAgvTaskNode.getResourceId()));
|
|
|
+ //获取产线ID
|
|
|
+ Long agvGoalZoneId = zoneProductionresource.getZoneId();
|
|
|
+ ZZone agvGoalZone = zoneService.getById(agvGoalZoneId);
|
|
|
+ String[] jbwArr = DictionaryKey.YJ_ZONE_JBW.get(agvGoalZone.getName()).split(",");
|
|
|
List<ProductionresourcePosition> jbwBList = productionresourcePositionService.getFreeProductionresourceAgvPositionByNos(jbwArr);
|
|
|
+ logger.info("节点{},查询线边库轮询终点接驳位接驳位数量{}",taskNode.getId(),jbwBList);
|
|
|
+ if(targetStorge!=null&&CollectionUtil.isNotEmpty(jbwBList)){
|
|
|
|
|
|
- if (targetStorge != null && CollectionUtil.isNotEmpty(jbwBList)) {
|
|
|
ProductionresourcePosition position = null;
|
|
|
for(ProductionresourcePosition productionresourcePosition : jbwBList){
|
|
|
position = productionresourcePosition;
|
|
|
break;
|
|
|
}
|
|
|
+ logger.info("节点{},查询线边库轮询终点接驳位{}",taskNode.getId(),position);
|
|
|
if(null!=position){
|
|
|
- agvEndStationStorge = storgeService.getById(position.getStorgeId());
|
|
|
-
|
|
|
//更新到targetresourceid
|
|
|
- TaskNode lastAgvTaskNode = taskNodeService.getNextNTaskNode(taskNode,1);
|
|
|
-// TaskNode lastOperationTaskNode = taskNodeService.getOne(Wraps.<TaskNode>lbQ().eq(TaskNode::getTaskId, taskNode.getTaskId()).orderByDesc(TaskNode::getCompleteBatchSort).last("limit 1"));
|
|
|
+// TaskNode nextTaskNode = taskNodeService.getNextNTaskNode(taskNode,1);
|
|
|
taskNode.setTargetResourceId(Long.parseLong(targetResourceId));
|
|
|
lastAgvTaskNode.setTargetResourceId(position.getResourceId());
|
|
|
lastAgvTaskNode.setResourceId(taskNode.getTargetResourceId());
|
|
|
taskNodeService.updateById(taskNode);
|
|
|
taskNodeService.updateById(lastAgvTaskNode);
|
|
|
+ logger.info("节点{},更新线边库轮询相应节点接驳位信息完成",taskNode.getId());
|
|
|
}
|
|
|
- returnMap.put("store", targetStorge);
|
|
|
+
|
|
|
+ returnMap.put("store",targetStorge);
|
|
|
+ returnMap.put("targetxbk","0");
|
|
|
+
|
|
|
+ }else{//需要放到线边库
|
|
|
+ xbkFlag = "1";
|
|
|
}
|
|
|
- } else {
|
|
|
- //目标设备
|
|
|
- if (resourceId != null) {
|
|
|
- List<ProductionresourcePosition> targetList = productionresourcePositionService.getFreeProductionresourcePositionByIds(new String[]{resourceId.toString()});
|
|
|
- if (CollectionUtil.isNotEmpty(targetList)) {
|
|
|
- targetStorge = storgeService.getById(targetList.get(0).getStorgeId());
|
|
|
- returnMap.put("store", targetStorge);
|
|
|
+ }else {
|
|
|
+ //
|
|
|
+ if(bomProcedureType.equals("下料")){
|
|
|
+ // 下料特殊处理,动态查找可用立库位子存放下料后的子盘夹具
|
|
|
+ Long storgeId = getLikuStockInList();
|
|
|
+ targetStorge = storgeService.getById(storgeId);
|
|
|
+ returnMap.put("store",targetStorge);
|
|
|
+ returnMap.put("targetxbk","0");
|
|
|
+ }else{
|
|
|
+ //目标设备
|
|
|
+ if(resourceId!=null){
|
|
|
+ List<ProductionresourcePosition> targetList = productionresourcePositionService.getFreeProductionresourcePositionByIds(new String[] {resourceId.toString()});
|
|
|
+ logger.info("节点{},查找目标设备可用信息{}",taskNode.getId(),targetList);
|
|
|
+ if(CollectionUtil.isNotEmpty(targetList)){
|
|
|
+ targetStorge = storgeService.getById(targetList.get(0).getStorgeId());
|
|
|
+ returnMap.put("store",targetStorge);
|
|
|
+ returnMap.put("targetxbk","0");
|
|
|
+
|
|
|
+ if("1".equals(bomzZone.getRunMode())){//自动模式下,
|
|
|
+ TaskNode nextTaskNode = taskNodeService.getNextNTaskNode(taskNode,1);
|
|
|
+ if("04".equals(nextTaskNode.getInterfaceType())){//上料、下料、翻面
|
|
|
+ xbkFlag = "1";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{//需要放到线边库
|
|
|
+ xbkFlag = "1";
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- returnMap.put("agvEndStationStorge", agvEndStationStorge);
|
|
|
+
|
|
|
+ if("1".equals(xbkFlag)){//最终放到线边库中
|
|
|
+
|
|
|
+ returnMap.put("targetxbk","1");
|
|
|
+ }
|
|
|
return returnMap;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 立库获取终点位置,取空库位的数据
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private long getLikuStockInList(){
|
|
|
+ List <StockInfo> returnList = null;
|
|
|
+
|
|
|
+ List<Productionresource> productionresources = productionresourceBizMapper.selectList(Wraps.<Productionresource>lbQ().like(Productionresource::getName,"立库"));
|
|
|
+ List<Long> productionresourceIds = productionresources.stream().map(t->t.getId()).collect(Collectors.toList());
|
|
|
+
|
|
|
+ if(CollectionUtil.isEmpty(productionresourceIds)){
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ String resourceIds = "";
|
|
|
+ for(int i = 0; i < productionresourceIds.size(); i++){
|
|
|
+ if(i == productionresourceIds.size() - 1){
|
|
|
+ resourceIds = resourceIds + productionresourceIds.get(i);
|
|
|
+ }else{
|
|
|
+ resourceIds = resourceIds + productionresourceIds.get(i)+ ",";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Map queryMap = new HashMap();
|
|
|
+ queryMap.put("resourceIds",resourceIds);
|
|
|
+
|
|
|
+ // 判断夹具是否有可用的,查询330个库位信息中是否还有夹具
|
|
|
+
|
|
|
+ List<Long> allStockList = stockInfoMapper.getAvailableStorge(queryMap);
|
|
|
+ if(allStockList.size() > 0){
|
|
|
+ return allStockList.get(0);
|
|
|
+ }else{
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 设备动态逻辑判断处理
|
|
|
*
|