|
@@ -16,10 +16,12 @@ import com.github.zuihou.business.operationManagementCenter.service.WorkpieceSer
|
|
|
import com.github.zuihou.business.productionResourceCenter.dao.ProductionresourcePositionMapper;
|
|
|
import com.github.zuihou.business.productionResourceCenter.entity.ProductionresourcePosition;
|
|
|
import com.github.zuihou.business.productionResourceCenter.entity.ResourceAutoCode;
|
|
|
+import com.github.zuihou.business.productionResourceCenter.entity.ZZone;
|
|
|
import com.github.zuihou.business.productionResourceCenter.entity.ZZoneProductionresource;
|
|
|
import com.github.zuihou.business.productionResourceCenter.service.NodeOperationService;
|
|
|
import com.github.zuihou.business.productionResourceCenter.service.ProductionresourcePositionService;
|
|
|
import com.github.zuihou.business.productionResourceCenter.service.ZZoneProductionresourceService;
|
|
|
+import com.github.zuihou.business.productionResourceCenter.service.ZZoneService;
|
|
|
import com.github.zuihou.business.util.MsgUtil;
|
|
|
import com.github.zuihou.common.constant.BizConstant;
|
|
|
import com.github.zuihou.common.constant.DictionaryKey;
|
|
@@ -28,6 +30,7 @@ import com.github.zuihou.database.mybatis.conditions.Wraps;
|
|
|
import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
|
|
|
import com.github.zuihou.tenant.entity.Module;
|
|
|
import com.github.zuihou.tenant.entity.Productionresource;
|
|
|
+import com.github.zuihou.tenant.entity.TenantResource;
|
|
|
import com.github.zuihou.tenant.service.ModuleService;
|
|
|
import com.github.zuihou.tenant.service.ProductionresourceService;
|
|
|
import com.google.common.collect.Maps;
|
|
@@ -80,6 +83,9 @@ public class RobotNodeServiceImpl implements NodeOperationService {
|
|
|
@Autowired
|
|
|
private ZZoneProductionresourceService zZoneProductionresourceService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ZZoneService zoneService;
|
|
|
+
|
|
|
private Map<String, Object> map = Maps.newHashMap();
|
|
|
|
|
|
private String ZK_ip_zlzx = "192.168.170.61";
|
|
@@ -96,13 +102,19 @@ public class RobotNodeServiceImpl implements NodeOperationService {
|
|
|
|
|
|
private String[] xbkArr;
|
|
|
|
|
|
- private List<ProductionresourcePosition> deviceList;
|
|
|
+ private List<ProductionresourcePosition> robotList;
|
|
|
+
|
|
|
+ private List<ProductionresourcePosition> targetList;
|
|
|
|
|
|
private List<ProductionresourcePosition> xbkList;
|
|
|
|
|
|
private List<ProductionresourcePosition> jbwList;
|
|
|
|
|
|
- private Long zone_id;
|
|
|
+ private Long zoneId;
|
|
|
+
|
|
|
+ private String zoneName;
|
|
|
+
|
|
|
+ private ZZone zZone;
|
|
|
|
|
|
@Override
|
|
|
public void initResource(TaskNode taskNode, TTask task, Map dataMap) {
|
|
@@ -110,29 +122,29 @@ public class RobotNodeServiceImpl implements NodeOperationService {
|
|
|
//this.sxlzIdArr = new String[] {DemoLineConstant.JQR1};
|
|
|
String moduleName = dataMap.get("moduleName") == null ? "" : dataMap.get("moduleName").toString();
|
|
|
String robotType = dataMap.get("robotType") == null ? "" : dataMap.get("robotType").toString();
|
|
|
- if(StringUtil.isNotEmpty(moduleName) && StringUtil.isNotEmpty(robotType)) {
|
|
|
+ if(StringUtil.isNotEmpty(moduleName)) {
|
|
|
//List<Module> modules = moduleService.list(new QueryWrapper<Module>().like("name", moduleName));
|
|
|
- Productionresource productionresource = productionresourceService.getOne(new QueryWrapper<Productionresource>().eq("name", robotType));
|
|
|
+ Productionresource productionresource = productionresourceService.getOne(new QueryWrapper<Productionresource>().eq("id", taskNode.getResourceId()));
|
|
|
if(productionresource!=null){
|
|
|
deviceArr = new String[] {productionresource.getId().toString()};
|
|
|
- deviceList = productionresourcePositionService.getFreeProductionresourcePositionByIds(deviceArr);
|
|
|
+ robotList = productionresourcePositionService.getFreeProductionresourcePositionByIds(deviceArr);
|
|
|
}
|
|
|
}
|
|
|
//获取机器人操作线边库
|
|
|
- xbkArr = dataMap.get("robotType")!=null? new String[]{
|
|
|
- DictionaryKey.YJ_ZONE_XBK.get(dataMap.get("robotType").toString())
|
|
|
- }: new String[]{DemoLineConstant.NODE_RESOURCE_ZLZX_XBK};
|
|
|
+ xbkArr = new String[]{DictionaryKey.YJ_ZONE_XBK.get(zoneName)};
|
|
|
xbkList = productionresourcePositionService.getFreeProductionresourcePositionByNos(xbkArr);
|
|
|
//jbwArr = modules.stream().map(Module::getNo).toArray(String[]::new);
|
|
|
// 获取机器人抓取、放可操作的接驳位(依据产线 待定)
|
|
|
- List<Productionresource> dataList = productionresourceService.list(new QueryWrapper<Productionresource>().like("name", robotType));
|
|
|
- if(dataList.size()>0) {
|
|
|
- jbwArr = dataList.stream().map(Productionresource::getId).toArray(String[]::new);
|
|
|
- jbwList = productionresourcePositionService.getFreeProductionresourcePositionByIds(jbwArr);
|
|
|
- }
|
|
|
+// List<Productionresource> dataList = productionresourceService.list(new QueryWrapper<Productionresource>().like("name", robotType));
|
|
|
+// if(dataList.size()>0) {
|
|
|
+// jbwArr = dataList.stream().map(Productionresource::getId).toArray(String[]::new);
|
|
|
+// jbwList = productionresourcePositionService.getFreeProductionresourcePositionByIds(jbwArr);
|
|
|
+// }
|
|
|
//获取产线ID
|
|
|
ZZoneProductionresource zZoneProductionresource = zZoneProductionresourceService.getOne(new LbqWrapper<ZZoneProductionresource>().eq(ZZoneProductionresource::getResourceId, taskNode.getResourceId()));
|
|
|
- zone_id = zZoneProductionresource.getZoneId();
|
|
|
+ zoneId = zZoneProductionresource.getZoneId();
|
|
|
+ zZone = zoneService.getById(zoneId);
|
|
|
+ zoneName = zoneService.getById(zoneId).getName();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -154,57 +166,57 @@ public class RobotNodeServiceImpl implements NodeOperationService {
|
|
|
}
|
|
|
String functionName = DictionaryKey.ROBOT_ACTION.get(resourceAutoCode.getCommand());
|
|
|
//设备条件判断
|
|
|
- ProductionresourcePosition productionresourcePosition = this.logical(deviceList, true);
|
|
|
- boolean bool = productionresourcePosition!=null ? true : false;
|
|
|
- if(!bool){
|
|
|
- map.put("result", false);
|
|
|
- return map;
|
|
|
- }
|
|
|
+ String count = dataMap.get(taskNode.getId().toString() + "count") == null ? "0" : dataMap.get(taskNode.getId().toString() + "count").toString();
|
|
|
+// ProductionresourcePosition productionresourcePosition = this.logical(robotList, count);
|
|
|
+
|
|
|
+// boolean bool = productionresourcePosition!=null ? true : false;
|
|
|
+// if(!bool){
|
|
|
+// map.put("result", false);
|
|
|
+// return map;
|
|
|
+// }
|
|
|
//开始库位
|
|
|
- Storge startStore = workpieceService.getWorkPieceStock(taskNode.getId(), false);
|
|
|
+ Storge currStore = workpieceService.getWorkPieceStock(taskNode.getId(), false);
|
|
|
//目的库位
|
|
|
- Storge jqrStorge = storgeService.getById(deviceList.get(0).getStorgeId());
|
|
|
+ Storge jqrStorge = storgeService.getById(robotList.get(0).getStorgeId());
|
|
|
//目标地址判断
|
|
|
- if(map.containsKey("useXbk")){
|
|
|
- //目标地址是线边库
|
|
|
- map.put("result", false);
|
|
|
- return map;
|
|
|
- }
|
|
|
+// if(map.containsKey("useXbk")){
|
|
|
+// //目标地址是线边库
|
|
|
+// map.put("result", false);
|
|
|
+// return map;
|
|
|
+// }
|
|
|
|
|
|
- switch(robotType){
|
|
|
+ switch(zoneName){
|
|
|
case "质量中心机器人":
|
|
|
//操作质量中心边库 具有取、移动、放三种指令
|
|
|
- //取放上下料站
|
|
|
- //取放三坐标
|
|
|
+ //取放上下料站
|
|
|
+ //取放三坐标
|
|
|
map.put("deviceUrl", ZK_ip_zlzx);
|
|
|
break;
|
|
|
case "柔性线机器人":
|
|
|
//操作柔性线边库 具有取、移动、放三种指令
|
|
|
- //取放加工设备 设备存在缓存位
|
|
|
- String count = dataMap.get(taskNode.getId().toString() + "count") == null ? "0" : dataMap.get(taskNode.getId().toString() + "count").toString();
|
|
|
- map = this.commandHandle(map, startStore, jqrStorge, functionName, count);
|
|
|
+ //取放加工设备 设备存在缓存位
|
|
|
+ map = this.commandHandle(map, currStore, jqrStorge, functionName, count);
|
|
|
map.put("deviceUrl", ZK_ip_rxx);
|
|
|
break;
|
|
|
case "智能单元机器人":
|
|
|
//操作智能单元线边库 具有取、移动、放三种指令
|
|
|
//取放加工设备 无缓存位处理
|
|
|
- map = this.commandHandle(map, startStore, jqrStorge, functionName);
|
|
|
+ map = this.commandHandle(map, currStore, jqrStorge, functionName);
|
|
|
map.put("deviceUrl", ZK_ip_zndy);
|
|
|
break;
|
|
|
- case "舱体线机器人":
|
|
|
+ case "舱体类加工单元":
|
|
|
//操作舱体线边库 具有取、移动、放三种指令
|
|
|
- //本机存在缓存库位 (取->缓存库位->放->目标库位)
|
|
|
-
|
|
|
+ //取放加工设备
|
|
|
+ map = this.commandHandle(map, currStore, jqrStorge, functionName, count);
|
|
|
break;
|
|
|
- case "伺服舵机":
|
|
|
+ case "智能生产保障系统":
|
|
|
//操作三个线边库 只具有取、放两种动作
|
|
|
- //本机无缓存库位 (取->放->目标库位)
|
|
|
|
|
|
|
|
|
break;
|
|
|
- case "框体线机器人":
|
|
|
+ case "框体类加工单元":
|
|
|
//操作框体线边库 具有取、移动、放三种指令
|
|
|
- //本机存在缓存库位 (取->缓存库位->放->目标库位)
|
|
|
+ //取放加工设备
|
|
|
|
|
|
break;
|
|
|
}
|
|
@@ -235,151 +247,218 @@ public class RobotNodeServiceImpl implements NodeOperationService {
|
|
|
private Map<String, Object> commandHandle(Map<String, Object> dataMap, Storge startStore, Storge jqrStorge, String... params){
|
|
|
TaskNode taskNode = (TaskNode) dataMap.get("taskNode");
|
|
|
TTask task = (TTask) dataMap.get("task");
|
|
|
- //缓存位判断处理
|
|
|
- if (params[1]!= null) {
|
|
|
- //int count = dataMap.get(taskNode.getId().toString() + "count") == null ? 0 : Integer.parseInt(dataMap.get(taskNode.getId().toString() + "count").toString());
|
|
|
- int count = Integer.parseInt(params[1]);
|
|
|
- //执行到第几步
|
|
|
- dataMap.put(taskNode.getId().toString() + "count", count);
|
|
|
- dataMap.put(DemoLineConstant.DEMOLINE_RXJQR_FLAG, "1");
|
|
|
- dataMap.put("zkIp", ZK_ip_rxx);
|
|
|
-
|
|
|
- if (count == 0) {//第一步的时候锁定资源
|
|
|
- //判断机器人是否为空
|
|
|
- Map<String, List<ProductionresourcePosition>> jqrMap = deviceList.stream().collect(groupingBy(ProductionresourcePosition::getPointId));
|
|
|
+ int count = Integer.parseInt(params[1]);
|
|
|
|
|
|
+ //缓存位判断处理
|
|
|
+ if ("取".equals(params[0])) {
|
|
|
+ if(BizConstant.ROBOT_TYPE_CACHE.equals(zoneService.getRobotTypebyZone(zoneName))){
|
|
|
+ //执行到第几步
|
|
|
+ dataMap.put(taskNode.getId().toString() + "count", count);
|
|
|
+ dataMap.put(DemoLineConstant.DEMOLINE_RXJQR_FLAG, "1");
|
|
|
+ dataMap.put("zkIp", ZK_ip_rxx);
|
|
|
+
|
|
|
+ if (count == 0) {//第一步的时候锁定资源
|
|
|
+ //判断机器人是否为空
|
|
|
+ Map<String, List<ProductionresourcePosition>> jqrMap = robotList.stream().collect(groupingBy(ProductionresourcePosition::getPointId));
|
|
|
+
|
|
|
+ TaskNode nextTaskNode = taskNodeService.getNextNTaskNode(taskNode, 1);
|
|
|
+ //目标库位,可能是
|
|
|
+ Map returnMap = getTargetStorge(nextTaskNode);
|
|
|
+
|
|
|
+ //目标地址和类型
|
|
|
+ Storge targetStorge = returnMap.get("store")==null?null:(Storge)returnMap.get("store");
|
|
|
+ String type = returnMap.get("type")==null?null:(String)returnMap.get("store");
|
|
|
+
|
|
|
+ //机器人手抓没被锁定,并且有空闲未知
|
|
|
+ if (logical(robotList,targetStorge)!=null) {
|
|
|
+ jqrStorge = storgeService.getById(jqrMap.get(DemoLineConstant.DEMOLINE_RJQR_ZS).get(0).getStorgeId());
|
|
|
+ jqrStorge.setCompleteBatchNo(task.getCompleteBatchNo());
|
|
|
+ storgeService.lockStorge(jqrStorge, nextTaskNode.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, nextTaskNode.getId());
|
|
|
+
|
|
|
+ //锁定目标库位
|
|
|
+ targetStorge.setCompleteBatchNo(task.getCompleteBatchNo());
|
|
|
+ storgeService.lockStorge(targetStorge, nextTaskNode.getId());
|
|
|
+
|
|
|
+ //抓手缓存
|
|
|
+ msgUtil.redis_set(DemoCacheKey.DEMOLINE_CAMP + "_" + DemoLineConstant.JQR3 + nextTaskNode.getId(), jqrStorge, 1, TimeUnit.DAYS);
|
|
|
+ msgUtil.redis_set(DemoCacheKey.DEMOLINE_CAMP + "_" + DemoLineConstant.JQR3 + taskNode.getId(), jqrStorge, 1, TimeUnit.DAYS);
|
|
|
+ //缓存位缓存
|
|
|
+ msgUtil.redis_set(DemoCacheKey.DEMOLINE_CAMP + "_" + DemoLineConstant.DEMOLINE_RJQR_HCW + nextTaskNode.getId(), hcwStorge, 1, TimeUnit.DAYS);
|
|
|
+ msgUtil.redis_set(DemoCacheKey.DEMOLINE_CAMP + "_" + DemoLineConstant.DEMOLINE_RJQR_HCW + taskNode.getId(), hcwStorge, 1, TimeUnit.DAYS);
|
|
|
+ //目标缓存
|
|
|
+ msgUtil.redis_set(DemoCacheKey.DEMOLINE_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_STORE + nextTaskNode.getId(), targetStorge, 1, TimeUnit.DAYS);
|
|
|
+
|
|
|
+ //满足条件--机器人空闲,设备或线边库有一个空闲
|
|
|
+ dataMap.put("Data", startStore);
|
|
|
+ dataMap.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "moveMaterial");
|
|
|
+ }
|
|
|
+ dataMap.put("result", logical(robotList,targetStorge));
|
|
|
+ } else if (count == 1) {
|
|
|
+ jqrStorge = (Storge) msgUtil.redis_get(DemoCacheKey.DEMOLINE_CAMP + "_" + DemoLineConstant.JQR3 + taskNode.getId());
|
|
|
+ dataMap.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "fetchMaterial");
|
|
|
+ Storge currentStore = workpieceService.getWorkPieceStock(taskNode.getId(), false);
|
|
|
+ dataMap.put("fromStorge", currentStore);
|
|
|
+ dataMap.put("Data", currentStore);
|
|
|
+ //出入库类型
|
|
|
+ dataMap.put(DemoLineConstant.DEMOLINE_STOCK_TYPE, DemoLineConstant.DEMOLINE_STOCK_TYPE_ALL_CRK);
|
|
|
+ //目的地为机器人手臂
|
|
|
+ map.put("toStorge", jqrStorge);
|
|
|
+ dataMap.put("result", true);
|
|
|
+ } else if (count == 2) {
|
|
|
+ Storge currentStore = workpieceService.getWorkPieceStock(taskNode.getId(), false);
|
|
|
+ dataMap.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "putMaterial");
|
|
|
+ dataMap.put("fromStorge", currentStore);
|
|
|
+ //出入库类型
|
|
|
+ dataMap.put(DemoLineConstant.DEMOLINE_STOCK_TYPE, DemoLineConstant.DEMOLINE_STOCK_TYPE_ALL_CRK);
|
|
|
+ //目的地为机器人手臂
|
|
|
+ Storge hcwStorge = (Storge) msgUtil.redis_get(DemoCacheKey.DEMOLINE_CAMP + "_" + DemoLineConstant.DEMOLINE_RJQR_HCW + taskNode.getId());
|
|
|
+ dataMap.put("Data", hcwStorge);
|
|
|
+ dataMap.put("toStorge", hcwStorge);
|
|
|
+ dataMap.put("result", true);
|
|
|
+ }
|
|
|
+ }else if (BizConstant.ROBOT_TYPE_NOCACHE.equals(zoneService.getRobotTypebyZone(zoneName))) {
|
|
|
TaskNode nextTaskNode = taskNodeService.getNextNTaskNode(taskNode, 1);
|
|
|
- //机器人手抓没被锁定,并且有空闲未知
|
|
|
- if (CollectionUtil.isNotEmpty(deviceList) && deviceList.size() > 1 && jqrMap.containsKey(DemoLineConstant.DEMOLINE_RJQR_ZS)) {
|
|
|
+ Map returnMap = getTargetStorge(nextTaskNode);
|
|
|
|
|
|
- jqrStorge = storgeService.getById(jqrMap.get(DemoLineConstant.DEMOLINE_RJQR_ZS).get(0).getStorgeId());
|
|
|
+ //目标地址和类型
|
|
|
+ Storge targetStorge = returnMap.get("store")==null?null:(Storge)returnMap.get("store");
|
|
|
+ String type = returnMap.get("type")==null?null:(String)returnMap.get("store");
|
|
|
+
|
|
|
+ dataMap.put("zkIp", ZK_ip_zndy);
|
|
|
+ dataMap.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "fetchMaterial");
|
|
|
+ if (logical(robotList,targetStorge)!=null) {
|
|
|
+ dataMap.put("fromStorge", startStore);
|
|
|
+ dataMap.put("Data", startStore);
|
|
|
+ //出入库类型
|
|
|
+ dataMap.put(DemoLineConstant.DEMOLINE_STOCK_TYPE, DemoLineConstant.DEMOLINE_STOCK_TYPE_ALL_CRK);
|
|
|
+ //目的地为机器人手臂
|
|
|
+ dataMap.put("toStorge", jqrStorge);
|
|
|
+ //锁定机器人
|
|
|
jqrStorge.setCompleteBatchNo(task.getCompleteBatchNo());
|
|
|
storgeService.lockStorge(jqrStorge, nextTaskNode.getId());
|
|
|
-// //去掉抓手
|
|
|
-// jqrMap.remove(DemoLineConstant.DEMOLINE_RJQR_ZS);
|
|
|
- //锁定一个缓存位
|
|
|
- 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, nextTaskNode.getId());
|
|
|
+
|
|
|
+ //锁定目标库位
|
|
|
+ targetStorge.setCompleteBatchNo(task.getCompleteBatchNo());
|
|
|
+ storgeService.lockStorge(targetStorge, nextTaskNode.getId());
|
|
|
|
|
|
//抓手缓存
|
|
|
msgUtil.redis_set(DemoCacheKey.DEMOLINE_CAMP + "_" + DemoLineConstant.JQR3 + nextTaskNode.getId(), jqrStorge, 1, TimeUnit.DAYS);
|
|
|
msgUtil.redis_set(DemoCacheKey.DEMOLINE_CAMP + "_" + DemoLineConstant.JQR3 + taskNode.getId(), jqrStorge, 1, TimeUnit.DAYS);
|
|
|
- //缓存位缓存
|
|
|
- msgUtil.redis_set(DemoCacheKey.DEMOLINE_CAMP + "_" + DemoLineConstant.DEMOLINE_RJQR_HCW + nextTaskNode.getId(), hcwStorge, 1, TimeUnit.DAYS);
|
|
|
- msgUtil.redis_set(DemoCacheKey.DEMOLINE_CAMP + "_" + DemoLineConstant.DEMOLINE_RJQR_HCW + taskNode.getId(), hcwStorge, 1, TimeUnit.DAYS);
|
|
|
-
|
|
|
- //满足条件--机器人空闲,设备或线边库有一个空闲
|
|
|
- startStore = workpieceService.getWorkPieceStock(taskNode.getId(), false);
|
|
|
- dataMap.put("Data", startStore);
|
|
|
- dataMap.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "moveMaterial");
|
|
|
+ //目标缓存
|
|
|
+ msgUtil.redis_set(DemoCacheKey.DEMOLINE_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_STORE + nextTaskNode.getId(), targetStorge, 1, TimeUnit.DAYS);
|
|
|
+ map.put("result", true);
|
|
|
}
|
|
|
- dataMap.put("result", (CollectionUtil.isNotEmpty(deviceList)) && jqrMap.containsKey(DemoLineConstant.DEMOLINE_RJQR_ZS));
|
|
|
- } else if (count == 1) {
|
|
|
- jqrStorge = (Storge) msgUtil.redis_get(DemoCacheKey.DEMOLINE_CAMP + "_" + DemoLineConstant.JQR3 + taskNode.getId());
|
|
|
- dataMap.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "fetchMaterial");
|
|
|
- Storge currentStore = workpieceService.getWorkPieceStock(taskNode.getId(), false);
|
|
|
- dataMap.put("fromStorge", currentStore);
|
|
|
- dataMap.put("Data", currentStore);
|
|
|
- //出入库类型
|
|
|
- dataMap.put(DemoLineConstant.DEMOLINE_STOCK_TYPE, DemoLineConstant.DEMOLINE_STOCK_TYPE_ALL_CRK);
|
|
|
- //目的地为机器人手臂
|
|
|
- map.put("toStorge", jqrStorge);
|
|
|
- dataMap.put("result", true);
|
|
|
- } else if (count == 2) {
|
|
|
- Storge currentStore = workpieceService.getWorkPieceStock(taskNode.getId(), false);
|
|
|
- dataMap.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "putMaterial");
|
|
|
- dataMap.put("fromStorge", currentStore);
|
|
|
- //出入库类型
|
|
|
- dataMap.put(DemoLineConstant.DEMOLINE_STOCK_TYPE, DemoLineConstant.DEMOLINE_STOCK_TYPE_ALL_CRK);
|
|
|
- //目的地为机器人手臂
|
|
|
- Storge hcwStorge = (Storge) msgUtil.redis_get(DemoCacheKey.DEMOLINE_CAMP + "_" + DemoLineConstant.DEMOLINE_RJQR_HCW + taskNode.getId());
|
|
|
- dataMap.put("Data", hcwStorge);
|
|
|
- dataMap.put("toStorge", hcwStorge);
|
|
|
- dataMap.put("result", true);
|
|
|
}
|
|
|
-
|
|
|
- }
|
|
|
- else if ("取".equals(params[0])) {
|
|
|
- dataMap.put("zkIp", ZK_ip_zndy);
|
|
|
- dataMap.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "fetchMaterial");
|
|
|
- TaskNode nextTaskNode = taskNodeService.getNextNTaskNode(taskNode, 1);
|
|
|
- //if (CollectionUtil.isNotEmpty(jqrList)) {
|
|
|
- dataMap.put("fromStorge", startStore);
|
|
|
- dataMap.put("Data", startStore);
|
|
|
- //出入库类型
|
|
|
- dataMap.put(DemoLineConstant.DEMOLINE_STOCK_TYPE, DemoLineConstant.DEMOLINE_STOCK_TYPE_ALL_CRK);
|
|
|
- //目的地为机器人手臂
|
|
|
- dataMap.put("toStorge", jqrStorge);
|
|
|
- //锁定机器人
|
|
|
- jqrStorge.setCompleteBatchNo(task.getCompleteBatchNo());
|
|
|
- storgeService.lockStorge(jqrStorge, nextTaskNode.getId());
|
|
|
- //}
|
|
|
- //
|
|
|
+ }else if ("放".equals(params[0])) {
|
|
|
+ Object targetStorge = msgUtil.redis_get(DemoCacheKey.DEMOLINE_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_STORE + taskNode.getId());
|
|
|
+ //执行到第几步
|
|
|
+ map.put(taskNode.getId().toString()+"count",count);
|
|
|
+ map.put(DemoLineConstant.DEMOLINE_RXJQR_FLAG, "1");
|
|
|
+ map.put("zkIp",ZK_ip_rxx);
|
|
|
+ if(BizConstant.ROBOT_TYPE_CACHE.equals(zoneService.getRobotTypebyZone(zoneName))){
|
|
|
+ if(count==0) {
|
|
|
+ map.put("Data", targetStorge);
|
|
|
+ map.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "moveMaterial");
|
|
|
+ }else if(count == 1){//从缓存位拿出来
|
|
|
+ map.put(DemoLineConstant.DEMOLINE_BIZ_TYPE,"fetchMaterial");
|
|
|
+ Storge hcwStorge = (Storge)msgUtil.redis_get(DemoCacheKey.DEMOLINE_CAMP + "_" + DemoLineConstant.DEMOLINE_RJQR_HCW + taskNode.getId());
|
|
|
+ map.put("Data", hcwStorge);
|
|
|
+ map.put("fromStorge", hcwStorge);
|
|
|
+ Storge handStorge = (Storge)msgUtil.redis_get(DemoCacheKey.DEMOLINE_CAMP + "_" + DemoLineConstant.JQR3 + taskNode.getId());
|
|
|
+ map.put("toStorge", handStorge);
|
|
|
+ //出入库类型
|
|
|
+ map.put(DemoLineConstant.DEMOLINE_STOCK_TYPE,DemoLineConstant.DEMOLINE_STOCK_TYPE_ALL_CRK);
|
|
|
+ }else if(count == 2){
|
|
|
+ map.put(DemoLineConstant.DEMOLINE_BIZ_TYPE,"putMaterial");
|
|
|
+ //出入库类型
|
|
|
+ map.put(DemoLineConstant.DEMOLINE_STOCK_TYPE,DemoLineConstant.DEMOLINE_STOCK_TYPE_ALL_CRK);
|
|
|
+ map.put("Data", targetStorge);
|
|
|
+ map.put("toStorge", targetStorge);
|
|
|
+
|
|
|
+ Storge handStorge = (Storge)msgUtil.redis_get(DemoCacheKey.DEMOLINE_CAMP + "_" + DemoLineConstant.JQR3 + taskNode.getId());
|
|
|
+ map.put("fromStorge", handStorge);
|
|
|
+ }
|
|
|
+ }else if (BizConstant.ROBOT_TYPE_NOCACHE.equals(zoneService.getRobotTypebyZone(zoneName))) {
|
|
|
+ map.put("zkIp",ZK_ip_zndy);
|
|
|
+ map.put(DemoLineConstant.DEMOLINE_BIZ_TYPE,"putMaterial");
|
|
|
+ map.put("toStorge", targetStorge);
|
|
|
+ map.put("Data", targetStorge);
|
|
|
+ }
|
|
|
map.put("result", true);
|
|
|
}
|
|
|
- else if ("放".equals(params[0])) {
|
|
|
- //判断目标位置是否空闲
|
|
|
- String actionTarget = taskNode.getAutoNode().getTargetId().toString();
|
|
|
- //1是本设备 2是接驳位
|
|
|
- List<ProductionresourcePosition> targetList = "1".equals(actionTarget)? productionresourcePositionService.getFreeProductionresourcePositionByNos(new String[]{taskNode.getNodeNo()}) : jbwList;
|
|
|
- ProductionresourcePosition productionresourcePosition = this.logical(targetList, true);
|
|
|
- boolean bool = productionresourcePosition!=null ? true : false;
|
|
|
- if(!bool){
|
|
|
- dataMap.put("result", false);
|
|
|
- return dataMap;
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 判断机器人是否可用
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public boolean checkRobot(){
|
|
|
+ if(BizConstant.ROBOT_TYPE_NOCACHE.equals(zoneService.getRobotTypebyZone(zoneName))){
|
|
|
+ return CollectionUtil.isNotEmpty(robotList) && robotList.size() == 1;
|
|
|
+ }else if(BizConstant.ROBOT_TYPE_CACHE.equals(zoneService.getRobotTypebyZone(zoneName))){//手抓必须空闲。
|
|
|
+ Map<String, List<ProductionresourcePosition>> jqrMap = robotList.stream().collect(groupingBy(ProductionresourcePosition::getPointId));
|
|
|
+ return CollectionUtil.isNotEmpty(robotList) && robotList.size() >1&&jqrMap.containsKey(DemoLineConstant.DEMOLINE_RJQR_ZS);
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public Map getTargetStorge(TaskNode taskNode){
|
|
|
+ Map returnMap = new HashMap();
|
|
|
+ Storge targetStorge = null;
|
|
|
+ Long resourceId = taskNode.getResourceId();
|
|
|
+ //目标设备
|
|
|
+ if(resourceId!=null){
|
|
|
+ targetList = productionresourcePositionService.getFreeProductionresourcePositionByIds(new String[] {resourceId.toString()});
|
|
|
+ if(CollectionUtil.isNotEmpty(targetList)){
|
|
|
+ targetStorge = storgeService.getById(targetList.get(0).getStorgeId());
|
|
|
+ returnMap.put("store",targetStorge);
|
|
|
+ returnMap.put("type","resource");
|
|
|
+
|
|
|
}
|
|
|
- boolean isXbk = dataMap.containsKey("useXbk");
|
|
|
- Storge targetStorge = storgeService.getById(productionresourcePosition.getStorgeId());
|
|
|
- targetStorge.setCompleteBatchNo(task.getCompleteBatchNo());
|
|
|
- if(isXbk){
|
|
|
- dataMap.put("result", false);
|
|
|
- }else{
|
|
|
- //锁定设备
|
|
|
- storgeService.lockStorge(targetStorge, taskNode.getId());
|
|
|
- dataMap.put("result", true);
|
|
|
+ }else{//放到线边库
|
|
|
+ Map map = storgeService.getPlateStorgeByNo(zZone);
|
|
|
+ targetStorge = map.get("storge") ==null?null:(Storge)map.get("storge");
|
|
|
+ if(targetStorge!=null){
|
|
|
+ returnMap.put("store",targetStorge);
|
|
|
+ returnMap.put("type","xbk");
|
|
|
}
|
|
|
}
|
|
|
- return map;
|
|
|
+ return returnMap;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 设备动态逻辑判断处理
|
|
|
*
|
|
|
- * @param deviceList
|
|
|
- * @param useXbk
|
|
|
+ * @param robotList
|
|
|
* @return
|
|
|
*/
|
|
|
- private ProductionresourcePosition logical(List<ProductionresourcePosition> deviceList, boolean useXbk){
|
|
|
+ private ProductionresourcePosition logical(List<ProductionresourcePosition> robotList,Storge targetStorge){
|
|
|
//设备不存在
|
|
|
- if(deviceList == null || deviceList.size() == 0){
|
|
|
+ if(checkRobot()){
|
|
|
map.put("msg", DictionaryKey.NodeException.NO_RESOURCE);
|
|
|
return null;
|
|
|
}
|
|
|
//资源临界判断
|
|
|
- int current_running_num = storgeService.getstorgeByZone(zone_id.toString());
|
|
|
+ int current_running_num = storgeService.getstorgeByZone(zoneId.toString());
|
|
|
if(current_running_num == DictionaryKey.RESOURCE_MAX_NUM){
|
|
|
map.put("msg", DictionaryKey.NodeException.NO_RESOURCE);
|
|
|
return null;
|
|
|
}
|
|
|
- deviceList = deviceList.stream().filter(position->position.getStatus()=="1" && position.getLockStatus()=="1").collect(Collectors.toList());
|
|
|
- //设备被锁定
|
|
|
- if(deviceList.size() == 0) {
|
|
|
- if(useXbk){
|
|
|
- if(xbkList.size() == 0){
|
|
|
- map.put("msg", DictionaryKey.NodeException.RESOURCE_LOCK);
|
|
|
- return null;
|
|
|
- }
|
|
|
- map.put("useXbk", true);
|
|
|
- return xbkList.get(0);
|
|
|
- }
|
|
|
- map.put("msg", DictionaryKey.NodeException.RESOURCE_LOCK);
|
|
|
+
|
|
|
+ if(targetStorge==null){
|
|
|
+ map.put("msg", DictionaryKey.NodeException.NO_RESOURCE);
|
|
|
return null;
|
|
|
}
|
|
|
- //设备托盘、夹具条件不满足 待定
|
|
|
|
|
|
- return deviceList.get(0);
|
|
|
+ return robotList.get(0);
|
|
|
}
|
|
|
|
|
|
}
|