|
@@ -1,31 +1,201 @@
|
|
|
package com.github.zuihou.business.productionResourceCenter.strategy.impl;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.github.zuihou.business.DemoLine.DemoCacheKey;
|
|
|
+import com.github.zuihou.business.DemoLine.DemoLineConstant;
|
|
|
+import com.github.zuihou.business.DemoLine.YunjianConstant;
|
|
|
import com.github.zuihou.business.edgeLibrary.entity.StockInfo;
|
|
|
import com.github.zuihou.business.edgeLibrary.entity.Storge;
|
|
|
-import com.github.zuihou.business.operationManagementCenter.entity.TaskNode;
|
|
|
+import com.github.zuihou.business.edgeLibrary.service.StorgeService;
|
|
|
+import com.github.zuihou.business.operationManagementCenter.entity.*;
|
|
|
+import com.github.zuihou.business.operationManagementCenter.service.*;
|
|
|
+import com.github.zuihou.business.productionReadyCenter.dao.BBomMapper;
|
|
|
+import com.github.zuihou.business.productionReadyCenter.entity.BBom;
|
|
|
import com.github.zuihou.business.productionReadyCenter.entity.BomProcedure;
|
|
|
+import com.github.zuihou.business.productionResourceCenter.dao.ProductionresourceBizMapper;
|
|
|
+import com.github.zuihou.business.productionResourceCenter.dao.ZZoneProductionresourceMapper;
|
|
|
+import com.github.zuihou.business.productionResourceCenter.entity.Productionresource;
|
|
|
import com.github.zuihou.business.productionResourceCenter.entity.ProductionresourcePosition;
|
|
|
+import com.github.zuihou.business.productionResourceCenter.entity.ZZone;
|
|
|
+import com.github.zuihou.business.productionResourceCenter.entity.ZZoneProductionresource;
|
|
|
+import com.github.zuihou.business.productionResourceCenter.service.ProductionresourcePositionService;
|
|
|
+import com.github.zuihou.business.productionResourceCenter.service.ZZoneService;
|
|
|
import com.github.zuihou.business.productionResourceCenter.strategy.RobotStrategy;
|
|
|
+import com.github.zuihou.business.util.MsgUtil;
|
|
|
+import com.github.zuihou.common.constant.DictionaryKey;
|
|
|
+import com.github.zuihou.common.util.StringUtil;
|
|
|
+import com.github.zuihou.database.mybatis.conditions.Wraps;
|
|
|
+import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
|
|
|
+import com.github.zuihou.tenant.service.ProductionresourceService;
|
|
|
+import com.google.common.collect.Maps;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Component("TOOLROBOT")
|
|
|
public class ToolRobotStrategy implements RobotStrategy {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ZZoneProductionresourceMapper zZoneProductionresourceMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TaskNodeService taskNodeService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TaskService taskService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ZZoneService zoneService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PlanService planService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ProductionresourceService productionresourceService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private BBomMapper bBomMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private MsgUtil msgUtil;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private StorgeService storgeService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private WorkpieceService workpieceService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ProductionresourceBizMapper productionresourceBizMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ProductionresourcePositionService productionresourcePositionService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private OrderTaskService orderTaskService;
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public Map robotInfo(TaskNode taskNode, String zoneName) {
|
|
|
- return null;
|
|
|
+ // 天轨机器人初始化
|
|
|
+ Map<String, Object> robotInfo = Maps.newConcurrentMap();
|
|
|
+ TTask task = taskService.getById(taskNode.getTaskId());
|
|
|
+ //获取天轨机器人
|
|
|
+ //com.github.zuihou.business.productionResourceCenter.entity.Productionresource robot = productionresourceBizMapper.selectById(taskNode.getResourceId());
|
|
|
+ Productionresource cutToolRobot = productionresourceBizMapper.selectOne(new LbqWrapper<Productionresource>().likeRight(Productionresource::getCode, "jqr2").last("limit 1"));
|
|
|
+ ZZone zZone = zoneService.getOne(new LbqWrapper<ZZone>().eq(ZZone::getName, zoneName).last("limit 1"));
|
|
|
+ BBom bom = bBomMapper.selectById(task.getBomId());
|
|
|
+ OrderTask orderTask = orderTaskService.getById(task.getOrderId());
|
|
|
+
|
|
|
+ Map plcInfo = DictionaryKey.PLC_CATEGORY.get(zZone.getNo());
|
|
|
+
|
|
|
+ robotInfo.put("robot", cutToolRobot);
|
|
|
+ robotInfo.put("zZone", zZone);
|
|
|
+ robotInfo.put("bom", bom);
|
|
|
+ robotInfo.put("plcInfo", plcInfo);
|
|
|
+ robotInfo.put("orderTask", orderTask);
|
|
|
+ robotInfo.put("singleRunFlag", "1");
|
|
|
+ return robotInfo;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Map robotCheck(TaskNode taskNode, Map robotInfo, List<StockInfo> flikustockInfos, BomProcedure bomProcedure,Map<String, Object> dataMap) {
|
|
|
- return null;
|
|
|
+ public Map robotCheck(TaskNode taskNode, Map robotInfo, List<StockInfo> flikustockInfos, BomProcedure bomProcedure,Map<String, Object> returnMap) {
|
|
|
+ Map<String, Object> dataMap = Maps.newConcurrentMap();
|
|
|
+ dataMap.put(taskNode.getId().toString() + "count", 0);
|
|
|
+ dataMap.put(YunjianConstant.YUNJIAN_ROBORT_CACHE_FLAG, "0");
|
|
|
+ Storge startStore = null;
|
|
|
+ OrderTask orderTask = (OrderTask) robotInfo.get("orderTask");
|
|
|
+ if (CollectionUtil.isNotEmpty(flikustockInfos)) {
|
|
|
+ //刀具线边库查询
|
|
|
+ startStore = storgeService.getById(flikustockInfos.get(0).getStorgeId());
|
|
|
+ }else {
|
|
|
+ //硬件设备库位
|
|
|
+ List<ProductionresourcePosition> storgeList = productionresourcePositionService.getFreeProductionresourcePositionByIds(new String[]{taskNode.getResourceId().toString()});
|
|
|
+ startStore = storgeService.getById(storgeList.get(0).getStorgeId());
|
|
|
+ }
|
|
|
+ //CCS判断取条件是否满足
|
|
|
+ boolean bool = true;
|
|
|
+ if(!bool){
|
|
|
+ msgUtil.createWarnLog("刀具节点起始位取条件不满足","DataException");
|
|
|
+ dataMap.put("result", false);
|
|
|
+ dataMap.put("resultmsg","刀具节点起始位取条件不满足");
|
|
|
+ return dataMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ //处理目标库位
|
|
|
+ returnMap = this.robotTarget(taskNode, robotInfo, null, bomProcedure,returnMap);
|
|
|
+
|
|
|
+ Storge targetStorge = !returnMap.containsKey("store") ? null : (Storge) returnMap.get("store");
|
|
|
+ Long targetStorgeResourceId = !returnMap.containsKey("storeResourceId") ? null : Long.valueOf(returnMap.get("storeResourceId").toString());
|
|
|
+
|
|
|
+ if (ObjectUtil.isEmpty(targetStorge)) {
|
|
|
+ dataMap.put("result", false);
|
|
|
+ dataMap.put("resultmsg","目标点位不满足,线边库不符合要求存放");
|
|
|
+ return dataMap;
|
|
|
+ }
|
|
|
+ //String targetXbk = !returnMap.containsKey("targetxbk") ? null : returnMap.get("targetxbk").toString();
|
|
|
+
|
|
|
+ //处理机器人库位
|
|
|
+ List<ProductionresourcePosition> robotList = productionresourcePositionService.getFreeProductionresourcePositionByIds(new String[]{taskNode.getResourceId().toString()});
|
|
|
+ Map putMap = this.robotPut(returnMap, taskNode, startStore, targetStorge, robotList, null, targetStorgeResourceId);
|
|
|
+ return putMap;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Map robotPut(Map dataMap, TaskNode taskNode, Storge startStorge, Storge endStorge, List<ProductionresourcePosition> robotList, String targetxbk, Long targetStorgeResourceId) {
|
|
|
- return null;
|
|
|
+ public Map robotPut(Map returnMap, TaskNode taskNode, Storge startStorge, Storge targetStorge, List<ProductionresourcePosition> robotList, String targetxbk, Long targetStorgeResourceId) {
|
|
|
+ Map<String, List<ProductionresourcePosition>> jqrMap = robotList.stream().collect(Collectors.groupingBy(ProductionresourcePosition::getPointId));
|
|
|
+ Storge jqrStorge = null;
|
|
|
+ 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());
|
|
|
+ storgeService.lockStorge(jqrStorge, taskNode.getId());
|
|
|
+ targetStorge.setCompleteBatchNo(taskNode.getCompleteBatchNo());
|
|
|
+ storgeService.lockStorge(targetStorge, taskNode.getId());
|
|
|
+
|
|
|
+ msgUtil.redis_set(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_STORE + taskNode.getId(), targetStorge, 10, TimeUnit.DAYS);
|
|
|
+
|
|
|
+ returnMap.put(DemoLineConstant.DEMOLINE_STOCK_TYPE, DemoLineConstant.DEMOLINE_STOCK_TYPE_ALL_CRK);
|
|
|
+ returnMap.put("taskType", DictionaryKey.TASK_TYPE.get("CARRY")); //移动类型
|
|
|
+ // 根据起始点位,获取点位属于的类型
|
|
|
+
|
|
|
+ Map locationMap = new HashMap();
|
|
|
+ locationMap.put("location", startStorge.getPointId()); //零件当前位置
|
|
|
+ locationMap.put("destLocation", targetStorge.getPointId()); //机器人缓存位
|
|
|
+
|
|
|
+ TTask task = taskService.getById(taskNode.getTaskId());
|
|
|
+ OrderTask orderTask = orderTaskService.getOne(new LbqWrapper<OrderTask>().eq(OrderTask::getOrderId, task.getOrderId()).last("LIMIT 1"));
|
|
|
+ if(StringUtil.isNotEmpty(orderTask.getCutStartNo()) && !orderTask.getCutStartNo().equals("0")) {
|
|
|
+ locationMap.put("locationNo", ""); //起始刀位号
|
|
|
+ }
|
|
|
+ if(StringUtil.isNotEmpty(orderTask.getCutGoalNo()) && !orderTask.getCutGoalNo().equals("0")) {
|
|
|
+ locationMap.put("destLocationNo", ""); //目的刀位号
|
|
|
+ }
|
|
|
+
|
|
|
+ locationMap.put("taskType", DictionaryKey.TASK_TYPE.get("CARRY"));
|
|
|
+ locationMap.put("carryType", "1");
|
|
|
+ returnMap.put(YunjianConstant.YUNJIAN_ROBORT_CACHE_FLAG, "1");
|
|
|
+ returnMap.put("data", locationMap);
|
|
|
+ returnMap.put("method", "RobotAction");
|
|
|
+ returnMap.put("result", true);
|
|
|
+ returnMap.put("fromStorge", startStorge);
|
|
|
+ returnMap.put("toStorge", targetStorge);
|
|
|
+
|
|
|
+ return returnMap;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -33,4 +203,31 @@ public class ToolRobotStrategy implements RobotStrategy {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ //获取目标地址
|
|
|
+ public Map robotTarget(TaskNode taskNode, Map robotInfo, List<ProductionresourcePosition> xbkList, BomProcedure bomProcedure, Map<String, Object> returnMap) {
|
|
|
+ List<ProductionresourcePosition> targetList = null;
|
|
|
+ Long targetResourceId = taskNode.getTargetResourceId();
|
|
|
+ if(targetResourceId == null){
|
|
|
+ msgUtil.createWarnLog("刀具节点目标位数据为空","DataException");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ targetList = productionresourcePositionService.getFreeProductionresourcePositionByIds(new String[]{targetResourceId.toString()});
|
|
|
+ if(CollectionUtil.isEmpty(targetList)){
|
|
|
+ msgUtil.createWarnLog("刀具节点目标位被占用","DataException");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ //CCS判断目标位点位是否允许放置判断
|
|
|
+ boolean bool = true;
|
|
|
+ if(!bool){
|
|
|
+ msgUtil.createWarnLog("刀具节点目标位放置条件不满足","DataException");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ Storge targetStorge = storgeService.getById(targetList.get(0).getStorgeId());
|
|
|
+ returnMap.put("storeResourceId", targetList.get(0).getResourceId());
|
|
|
+ returnMap.put("store", targetStorge);
|
|
|
+ returnMap.put("targetxbk", "0");
|
|
|
+
|
|
|
+ return returnMap;
|
|
|
+ }
|
|
|
+
|
|
|
}
|