|
@@ -46,12 +46,15 @@ import org.apache.commons.lang.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
+import java.util.Comparator;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
+import static java.util.stream.Collectors.groupingBy;
|
|
|
|
+
|
|
@Component("CACHE")
|
|
@Component("CACHE")
|
|
@Slf4j
|
|
@Slf4j
|
|
public class CacheRobotStrategy implements RobotStrategy {
|
|
public class CacheRobotStrategy implements RobotStrategy {
|
|
@@ -108,7 +111,6 @@ public class CacheRobotStrategy implements RobotStrategy {
|
|
|
|
|
|
com.github.zuihou.business.productionResourceCenter.entity.Productionresource robot = productionresourceBizMapper.selectById(taskNode.getResourceId());
|
|
com.github.zuihou.business.productionResourceCenter.entity.Productionresource robot = productionresourceBizMapper.selectById(taskNode.getResourceId());
|
|
ZZoneProductionresource zoneProductionresource = zZoneProductionresourceMapper.selectOne(Wraps.<ZZoneProductionresource>lbQ().eq(ZZoneProductionresource::getResourceId, taskNode.getResourceId()));
|
|
ZZoneProductionresource zoneProductionresource = zZoneProductionresourceMapper.selectOne(Wraps.<ZZoneProductionresource>lbQ().eq(ZZoneProductionresource::getResourceId, taskNode.getResourceId()));
|
|
- List<ProductionresourcePosition> robotList = productionresourcePositionService.getFreeProductionresourcePositionByIds(new String[]{taskNode.getResourceId().toString()});
|
|
|
|
ZZone zZone = zoneService.getOne(new LbqWrapper<ZZone>().eq(ZZone::getName, zoneName).last("limit 1"));
|
|
ZZone zZone = zoneService.getOne(new LbqWrapper<ZZone>().eq(ZZone::getName, zoneName).last("limit 1"));
|
|
Plan orderPlan = planService.getById(task.getPlanId());
|
|
Plan orderPlan = planService.getById(task.getPlanId());
|
|
BBom bom = bBomMapper.selectById(task.getBomId());
|
|
BBom bom = bBomMapper.selectById(task.getBomId());
|
|
@@ -124,7 +126,7 @@ public class CacheRobotStrategy implements RobotStrategy {
|
|
robotInfo.put("bomzZone", bomzZone);
|
|
robotInfo.put("bomzZone", bomzZone);
|
|
robotInfo.put("plcInfo", plcInfo);
|
|
robotInfo.put("plcInfo", plcInfo);
|
|
robotInfo.put("singleRunFlag", orderPlan.getSingleRunFlag());
|
|
robotInfo.put("singleRunFlag", orderPlan.getSingleRunFlag());
|
|
- robotInfo.put("robotList", robotList);
|
|
|
|
|
|
+ //robotInfo.put("robotList", robotList);
|
|
//robotInfo.put("xbkList", xbkList);
|
|
//robotInfo.put("xbkList", xbkList);
|
|
|
|
|
|
return robotInfo;
|
|
return robotInfo;
|
|
@@ -156,7 +158,7 @@ public class CacheRobotStrategy implements RobotStrategy {
|
|
Storge targetStorge = !returnMap.containsKey("store") ? null : (Storge) returnMap.get("store");
|
|
Storge targetStorge = !returnMap.containsKey("store") ? null : (Storge) returnMap.get("store");
|
|
Long targetStorgeResourceId = !returnMap.containsKey("storeResourceId") ? null : Long.valueOf(returnMap.get("storeResourceId").toString());
|
|
Long targetStorgeResourceId = !returnMap.containsKey("storeResourceId") ? null : Long.valueOf(returnMap.get("storeResourceId").toString());
|
|
|
|
|
|
- if (targetStorge == null) {
|
|
|
|
|
|
+ if (ObjectUtil.isEmpty(targetStorge)) {
|
|
dataMap.put("result", false);
|
|
dataMap.put("result", false);
|
|
dataMap.put("resultmsg","目标点位不满足,线边库不符合要求存放");
|
|
dataMap.put("resultmsg","目标点位不满足,线边库不符合要求存放");
|
|
return dataMap;
|
|
return dataMap;
|
|
@@ -164,7 +166,7 @@ public class CacheRobotStrategy implements RobotStrategy {
|
|
String targetXbk = !returnMap.containsKey("targetxbk") ? null : returnMap.get("targetxbk").toString();
|
|
String targetXbk = !returnMap.containsKey("targetxbk") ? null : returnMap.get("targetxbk").toString();
|
|
|
|
|
|
//处理机器人库位
|
|
//处理机器人库位
|
|
- List<ProductionresourcePosition> robotList = (List<ProductionresourcePosition>) robotInfo.get("robotList");
|
|
|
|
|
|
+ List<ProductionresourcePosition> robotList = productionresourcePositionService.list(Wraps.<ProductionresourcePosition>lbQ().eq(ProductionresourcePosition::getResourceId, taskNode.getResourceId()));
|
|
Map putMap = this.robotPut(returnMap, taskNode, startStore, targetStorge, robotList, targetXbk, targetStorgeResourceId);
|
|
Map putMap = this.robotPut(returnMap, taskNode, startStore, targetStorge, robotList, targetXbk, targetStorgeResourceId);
|
|
return putMap;
|
|
return putMap;
|
|
}
|
|
}
|
|
@@ -178,20 +180,23 @@ public class CacheRobotStrategy implements RobotStrategy {
|
|
|
|
|
|
//锁定机器人抓手
|
|
//锁定机器人抓手
|
|
Storge jqrStorge = null;
|
|
Storge jqrStorge = null;
|
|
- try {
|
|
|
|
- jqrStorge = storgeService.getById(jqrMap.get(DemoLineConstant.DEMOLINE_RJQR_ZS).get(0).getStorgeId());
|
|
|
|
-
|
|
|
|
- if(jqrStorge == null){
|
|
|
|
- throw new BizException("没有查询到可执行的关节机器人");
|
|
|
|
- }
|
|
|
|
- }catch (Exception e){
|
|
|
|
- throw new BizException("没有查询到可执行的关节机器人");
|
|
|
|
|
|
+ List<ProductionresourcePosition> jqrList = jqrMap.get(DemoLineConstant.DEMOLINE_RJQR_ZS);
|
|
|
|
+ if(jqrList.size() == 0){
|
|
|
|
+ returnMap.put("result", false);
|
|
|
|
+ return returnMap;
|
|
|
|
+ }else {
|
|
|
|
+ jqrStorge = storgeService.getById(jqrList.get(0).getStorgeId());
|
|
|
|
+ if (null == jqrStorge) {
|
|
|
|
+ returnMap.put("result", false);
|
|
|
|
+ return returnMap;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
jqrStorge.setCompleteBatchNo(taskNode.getCompleteBatchNo());
|
|
jqrStorge.setCompleteBatchNo(taskNode.getCompleteBatchNo());
|
|
storgeService.lockStorge(jqrStorge, taskNode.getId());
|
|
storgeService.lockStorge(jqrStorge, taskNode.getId());
|
|
|
|
|
|
- List<ProductionresourcePosition> hcwList = jqrMap.get(jqrMap.keySet().stream().filter(p -> !DemoLineConstant.DEMOLINE_RJQR_ZS.equals(p) && !DemoLineConstant.DEMOLINE_RJQR_SIX.equals(p)).findFirst().get());
|
|
|
|
|
|
+ //List<ProductionresourcePosition> hcwList = jqrMap.get(jqrMap.keySet().stream().filter(p -> !DemoLineConstant.DEMOLINE_RJQR_ZS.equals(p) && !DemoLineConstant.DEMOLINE_RJQR_SIX.equals(p)).findFirst().get());
|
|
|
|
+ List<ProductionresourcePosition> hcwList = robotList.stream().filter(p -> !DemoLineConstant.DEMOLINE_RJQR_ZS.equals(p.getPointId()) && !DemoLineConstant.DEMOLINE_RJQR_SIX.equals(p.getPointId())).collect(Collectors.toList());
|
|
if (hcwList.size() == 0) {
|
|
if (hcwList.size() == 0) {
|
|
//限定抓手交换功能
|
|
//限定抓手交换功能
|
|
boolean hasJqrhcwPartFlag = false;
|
|
boolean hasJqrhcwPartFlag = false;
|
|
@@ -225,10 +230,14 @@ public class CacheRobotStrategy implements RobotStrategy {
|
|
storgeService.lockStorge(hcwStorge, taskNode.getId());
|
|
storgeService.lockStorge(hcwStorge, taskNode.getId());
|
|
storgeService.lockStorge(startStorge, taskNode.getId());
|
|
storgeService.lockStorge(startStorge, taskNode.getId());
|
|
|
|
|
|
- if (hcwList.size() > 1) {
|
|
|
|
|
|
+ //暂存位线边库判断
|
|
|
|
+ if (hcwList.size() > 1 && targetXbk.equals("1")) {
|
|
//锁定暂存缓存位库位
|
|
//锁定暂存缓存位库位
|
|
targetStorge = hcwStorge;
|
|
targetStorge = hcwStorge;
|
|
msgUtil.redis_set(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_HCW_XBK_FLAG + taskNode.getId(), "1");
|
|
msgUtil.redis_set(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_HCW_XBK_FLAG + taskNode.getId(), "1");
|
|
|
|
+ returnMap.put(YunjianConstant.YUNJIAN_XBKFLAG, "1");
|
|
|
|
+ returnMap.put(YunjianConstant.YUNJIAN_HCW_XBKFLAG, "1");
|
|
|
|
+ msgUtil.redis_set(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_STORE + taskNode.getId(), targetStorge, 10, TimeUnit.DAYS);
|
|
} else {
|
|
} else {
|
|
//锁定目标线边库库位
|
|
//锁定目标线边库库位
|
|
targetStorge.setCompleteBatchNo(taskNode.getCompleteBatchNo());
|
|
targetStorge.setCompleteBatchNo(taskNode.getCompleteBatchNo());
|
|
@@ -239,6 +248,8 @@ public class CacheRobotStrategy implements RobotStrategy {
|
|
} else {
|
|
} else {
|
|
//目标是线边库
|
|
//目标是线边库
|
|
msgUtil.redis_set(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_XBK_FLAG + taskNode.getId(), targetXbk, 10, TimeUnit.DAYS);
|
|
msgUtil.redis_set(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_XBK_FLAG + taskNode.getId(), targetXbk, 10, TimeUnit.DAYS);
|
|
|
|
+ returnMap.put(YunjianConstant.YUNJIAN_XBKFLAG, "1");
|
|
|
|
+ returnMap.remove(taskNode.getId().toString()+"count");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// 放入线边库或机器人缓存位
|
|
// 放入线边库或机器人缓存位
|
|
@@ -271,12 +282,14 @@ public class CacheRobotStrategy implements RobotStrategy {
|
|
locationMap.put("destLocation", targetStorge.getPointId()); //机器人缓存位
|
|
locationMap.put("destLocation", targetStorge.getPointId()); //机器人缓存位
|
|
locationMap.put("taskType", DictionaryKey.TASK_TYPE.get("CARRY"));
|
|
locationMap.put("taskType", DictionaryKey.TASK_TYPE.get("CARRY"));
|
|
locationMap.put("carryType", "1");
|
|
locationMap.put("carryType", "1");
|
|
|
|
+ returnMap.put(YunjianConstant.YUNJIAN_ROBORT_CACHE_FLAG, "1");
|
|
returnMap.put("data", locationMap);
|
|
returnMap.put("data", locationMap);
|
|
returnMap.put("method", "RobotAction");
|
|
returnMap.put("method", "RobotAction");
|
|
returnMap.put("result", true);
|
|
returnMap.put("result", true);
|
|
returnMap.put("fromStorge", startStorge);
|
|
returnMap.put("fromStorge", startStorge);
|
|
returnMap.put("toStorge", targetStorge);
|
|
returnMap.put("toStorge", targetStorge);
|
|
|
|
|
|
|
|
+
|
|
// 机器人移动到redis记录实时位子
|
|
// 机器人移动到redis记录实时位子
|
|
msgUtil.redis_set(taskNode.getResourceId() + "postion", startStorge.getPointId());
|
|
msgUtil.redis_set(taskNode.getResourceId() + "postion", startStorge.getPointId());
|
|
|
|
|
|
@@ -302,12 +315,22 @@ public class CacheRobotStrategy implements RobotStrategy {
|
|
}
|
|
}
|
|
TTask task = taskService.getById(taskNode.getTaskId());
|
|
TTask task = taskService.getById(taskNode.getTaskId());
|
|
BomProcedure bomProcedure = bomProcedureMapper.selectOne(Wraps.<BomProcedure>lbQ().eq(BomProcedure::getId,task.getProcedureId()));
|
|
BomProcedure bomProcedure = bomProcedureMapper.selectOne(Wraps.<BomProcedure>lbQ().eq(BomProcedure::getId,task.getProcedureId()));
|
|
- String zoneName = robotInfo.get("zoneName").toString();
|
|
|
|
|
|
+ ZZone zZone = (ZZone) robotInfo.get("zZone");
|
|
|
|
+ String zoneName = zZone.getName();
|
|
List<ProductionresourcePosition> xbkList = productionresourcePositionService.getFreeProductionresourcePositionByNos(DictionaryKey.YJ_ZONE_XBK.get(zoneName).split(","));
|
|
List<ProductionresourcePosition> xbkList = productionresourcePositionService.getFreeProductionresourcePositionByNos(DictionaryKey.YJ_ZONE_XBK.get(zoneName).split(","));
|
|
|
|
|
|
Map returnMap = this.robotTarget(taskNode, robotInfo, xbkList, bomProcedure, dataMap);
|
|
Map returnMap = this.robotTarget(taskNode, robotInfo, xbkList, bomProcedure, dataMap);
|
|
//线边库处理
|
|
//线边库处理
|
|
- return returnMap;
|
|
|
|
|
|
+ Storge targetStorge = !returnMap.containsKey("store") ? null : (Storge) returnMap.get("store");
|
|
|
|
+ Long targetStorgeResourceId = !returnMap.containsKey("storeResourceId") ? null : Long.valueOf(returnMap.get("storeResourceId").toString());
|
|
|
|
+ String targetXbk = !returnMap.containsKey("targetxbk") ? null : returnMap.get("targetxbk").toString();
|
|
|
|
+ if (ObjectUtil.isNotEmpty(targetXbk) && targetXbk.equals("1")) {
|
|
|
|
+ dataMap.put("result", false);
|
|
|
|
+ return dataMap;
|
|
|
|
+ }
|
|
|
|
+ Storge startStore = workpieceService.getWorkPieceStock(taskNode.getCompleteBatchNo(), false);
|
|
|
|
+ Map putMap = this.robotPut(returnMap, taskNode, startStore, targetStorge, robotList, targetXbk, targetStorgeResourceId);
|
|
|
|
+ return putMap;
|
|
}
|
|
}
|
|
|
|
|
|
public Map robotTarget(TaskNode taskNode, Map robotInfo, List<ProductionresourcePosition> xbkList, BomProcedure bomProcedure, Map<String, Object> returnMap) {
|
|
public Map robotTarget(TaskNode taskNode, Map robotInfo, List<ProductionresourcePosition> xbkList, BomProcedure bomProcedure, Map<String, Object> returnMap) {
|
|
@@ -427,5 +450,4 @@ public class CacheRobotStrategy implements RobotStrategy {
|
|
return returnMap;
|
|
return returnMap;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
}
|
|
}
|