|
@@ -38,6 +38,7 @@ import com.github.zuihou.business.util.CommonUtil;
|
|
|
import com.github.zuihou.business.util.MsgUtil;
|
|
|
import com.github.zuihou.common.constant.DictionaryKey;
|
|
|
import com.github.zuihou.common.constant.ParameterKey;
|
|
|
+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.github.zuihou.database.mybatis.conditions.query.QueryWrap;
|
|
@@ -54,6 +55,7 @@ import java.util.*;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
+import static com.github.zuihou.common.constant.CacheKey.TENANT;
|
|
|
import static java.util.stream.Collectors.groupingBy;
|
|
|
|
|
|
@Component("CACHE")
|
|
@@ -110,6 +112,10 @@ public class CacheRobotStrategy implements RobotStrategy {
|
|
|
@Autowired
|
|
|
private StockInfoMapper stockInfoMapper;
|
|
|
|
|
|
+ private final static String ROBOT_POINT1="{\"1\":131,\"4\":448}";
|
|
|
+ private final static String ROBOT_POINT2="{\"1\":132,\"4\":449}";
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public Map robotInfo(TaskNode taskNode, String zoneName) {
|
|
|
Map<String, Object> robotInfo = Maps.newConcurrentMap();
|
|
@@ -179,6 +185,7 @@ public class CacheRobotStrategy implements RobotStrategy {
|
|
|
|
|
|
@Override
|
|
|
public Map robotPut(Map returnMap, TaskNode taskNode, Storge startStorge, Storge targetStorge, List<ProductionresourcePosition> robotList, String targetXbk, Long targetStorgeResourceId) {
|
|
|
+ BaseContextHandler.setTenant("0000");
|
|
|
|
|
|
Map<String, List<ProductionresourcePosition>> jqrMap = robotList.stream().collect(Collectors.groupingBy(ProductionresourcePosition::getPointId));
|
|
|
|
|
@@ -250,7 +257,8 @@ public class CacheRobotStrategy implements RobotStrategy {
|
|
|
if(startStorge==null){
|
|
|
throw new RuntimeException("库位不满足,没用查询到可用子盘");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
|
|
|
//暂存库位作为库位起始位不需重复锁定暂存位
|
|
|
ProductionresourcePosition startPosition = productionresourcePositionService.getOne(new LbqWrapper<ProductionresourcePosition>().eq(ProductionresourcePosition::getStorgeId, startStorge.getId()).last("limit 1"));
|
|
@@ -335,16 +343,17 @@ public class CacheRobotStrategy implements RobotStrategy {
|
|
|
}
|
|
|
|
|
|
// 根据起始点位,获取点位属于的类型
|
|
|
- Productionresource locationStorgeType = null;
|
|
|
+ /* Productionresource locationStorgeType = null;
|
|
|
Productionresource ltargetStorgeType = null;
|
|
|
if(!startStorge.getPointId().isEmpty()){
|
|
|
locationStorgeType = productionresourceService.findOneByPointId(startStorge.getPointId());
|
|
|
}
|
|
|
if(!targetStorge.getPointId().isEmpty()){
|
|
|
ltargetStorgeType = productionresourceService.findOneByPointId(targetStorge.getPointId());
|
|
|
- }
|
|
|
+ }*/
|
|
|
+
|
|
|
+
|
|
|
|
|
|
- //
|
|
|
startStorge.setCompleteBatchNo(taskNode.getCompleteBatchNo());
|
|
|
storgeService.lockStorge(startStorge, taskNode.getId());
|
|
|
//锁定抓手
|
|
@@ -358,8 +367,8 @@ public class CacheRobotStrategy implements RobotStrategy {
|
|
|
Map locationMap = new HashMap();
|
|
|
/* locationMap.put("locationDevice", locationStorgeType==null?"": locationStorgeType.getCode()); //当前区域
|
|
|
locationMap.put("destLocationDevice", ltargetStorgeType ==null?"": ltargetStorgeType.getCode()); //目的区域*/
|
|
|
- locationMap.put("location", CommonUtil.getLocationValue(startStorge.getPointId(),latheTypeCode)); //零件当前位置
|
|
|
- locationMap.put("destLocation", CommonUtil.getLocationValue(targetStorge.getPointId(),latheTypeCode)); //机器人缓存位
|
|
|
+ locationMap.put("location", CommonUtil.getLocationValue(startStorge.getPointId(),latheTypeCode).toString()); //零件当前位置
|
|
|
+ locationMap.put("destLocation", CommonUtil.getLocationValue(targetStorge.getPointId(),latheTypeCode).toString()); //机器人缓存位
|
|
|
locationMap.put("taskType", DictionaryKey.TASK_TYPE.get("CARRY"));
|
|
|
locationMap.put("carryType", "1");
|
|
|
locationMap.put("rfidType",latheTypeCode);//子盘类型
|
|
@@ -410,7 +419,7 @@ public class CacheRobotStrategy implements RobotStrategy {
|
|
|
String targetXbk = !returnMap.containsKey("targetxbk") ? null : returnMap.get("targetxbk").toString();
|
|
|
String xbkCount = dataMap.containsKey(taskNode.getId()+"count")? dataMap.get(taskNode.getId()+"count").toString(): null;
|
|
|
//线边库移动判断暂存位是否有空余位置
|
|
|
- if(targetXbk.equals("0") && robotList.size() == 1 && (!startStore.getPointId().contains("220") && !startStore.getPointId().contains("221") )){
|
|
|
+ if(targetXbk.equals("0") && robotList.size() == 1 && (!startStore.getPointId().contains(ROBOT_POINT1) && !startStore.getPointId().contains(ROBOT_POINT2) )){
|
|
|
dataMap.put("result", false);
|
|
|
dataMap.put("resultMsg", "条件判断不通过,暂存位无空闲位置,节点名字"+task.getProcedureName()+ taskNode.getNodeName()+"节点id:"+taskNode.getId());
|
|
|
return dataMap;
|
|
@@ -427,7 +436,7 @@ public class CacheRobotStrategy implements RobotStrategy {
|
|
|
}
|
|
|
//线边库位置条件不满足
|
|
|
//当前库位不在暂存位上,在线边库上
|
|
|
- if(!startStore.getPointId().contains("220") && !startStore.getPointId().contains("221") ){
|
|
|
+ if(!startStore.getPointId().contains(ROBOT_POINT1) && !startStore.getPointId().contains(ROBOT_POINT2) ){
|
|
|
dataMap.put("result", false);
|
|
|
dataMap.put("resultMsg", "条件判断不通过,线边库临时暂存, 等待目标位置释放,节点名字"+ task.getProcedureName()+"-"+ taskNode.getNodeName()+"节点id:"+taskNode.getId());
|
|
|
return dataMap;
|
|
@@ -523,9 +532,10 @@ public class CacheRobotStrategy implements RobotStrategy {
|
|
|
//查询起始库位托盘类型,根据托盘拉丁类型选择线边库库位
|
|
|
//TODO 根据产线查适配线边库库位
|
|
|
|
|
|
- StorgeType xbkStorgeType = storgeTypeService.getOne(Wraps.<StorgeType>lbQ().eq(StorgeType::getName, "线边库"));
|
|
|
- List<Storge> list = storgeService.list(Wraps.<Storge>lbQ().eq(Storge::getLatheTypeCode, latheTypeCode).eq(Storge::getStorgeTypeId,xbkStorgeType.getId()).orderByAsc(Storge::getPointId));
|
|
|
- targetStorge = storgeService.getById(list.get(0));
|
|
|
+ //StorgeType xbkStorgeType = storgeTypeService.getOne(Wraps.<StorgeType>lbQ().eq(StorgeType::getName, "线边库"));
|
|
|
+ //List<Storge> list = storgeService.list(Wraps.<Storge>lbQ().eq(Storge::getLatheTypeCode, latheTypeCode).eq(Storge::getStorgeTypeId,xbkStorgeType.getId()).orderByAsc(Storge::getPointId));
|
|
|
+ List<ProductionresourcePosition> collect = xbkList.stream().filter(vo -> vo.getLatheTypeCode().equals(latheTypeCode) || "0".equals(vo.getLatheTypeCode())).collect(Collectors.toList());
|
|
|
+ targetStorge = storgeService.getById(collect.get(0).getStorgeId());
|
|
|
returnMap.put("store", targetStorge);
|
|
|
returnMap.put("targetxbk", "0");
|
|
|
} else {
|
|
@@ -563,9 +573,9 @@ public class CacheRobotStrategy implements RobotStrategy {
|
|
|
//筛选 拉丁类型相同并且工艺设备绑定库位
|
|
|
List<Storge> collect1 = list.stream().filter(p -> p.getLatheTypeCode().equals(latheTypeCode) && bomProcedureProductionresource.getStorgeId() != null && p.getId().equals(bomProcedureProductionresource.getStorgeId())).collect(Collectors.toList());
|
|
|
if(CollectionUtil.isNotEmpty(collect1)){
|
|
|
- Storge storge =collect1.get(0);
|
|
|
- returnMap.put("storeResourceId", storge.getResourceId());
|
|
|
- returnMap.put("store", storge);
|
|
|
+ targetStorge =collect1.get(0);
|
|
|
+ returnMap.put("storeResourceId", targetStorge.getResourceId());
|
|
|
+ returnMap.put("store", targetStorge);
|
|
|
returnMap.put("targetxbk", "0");
|
|
|
}else{
|
|
|
xbkFlag = "1";
|
|
@@ -592,8 +602,14 @@ public class CacheRobotStrategy implements RobotStrategy {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ Integer resourceStockInfoCount=0;
|
|
|
+ if(targetStorge!=null){
|
|
|
+ //一个机床有多个库位,只准一个机床有一个子盘
|
|
|
+ resourceStockInfoCount = stockInfoMapper.verifyResourceStockInfo(targetStorge.getId());
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
- if ("1".equals(xbkFlag)) {
|
|
|
+ if ("1".equals(xbkFlag) || resourceStockInfoCount > 0) {
|
|
|
ProductionresourcePosition position = xbkList.get(0);
|
|
|
targetStorge = storgeService.getById(position.getStorgeId());
|
|
|
returnMap.put("storeResourceId", position.getResourceId());
|