Prechádzať zdrojové kódy

立库托盘夹具判断条件修改。

姚云青 3 rokov pred
rodič
commit
70dcf18154

+ 3 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/DemoLine/DemoLineConstant.java

@@ -241,6 +241,9 @@ public interface DemoLineConstant {
     String DEMOLINE_STOCK_TYPE = "DEMOLINE_STOCK_TYPE";
     //原料入库
     String DEMOLINE_STOCK_TYPE_METERIAL_RK = "DEMOLINE_STOCK_TYPE_METERIAL_RK";
+
+    //原料入库
+    String DEMOLINE_STOCK_TYPE_METERIAL_JIAJU_RK = "DEMOLINE_STOCK_TYPE_METERIAL_JIAJU_RK";
     //原料出库
     String DEMOLINE_STOCK_TYPE_METERIAL_CK = "DEMOLINE_STOCK_TYPE_METERIAL_CK";
     //原料出入库

+ 18 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/operationManagementCenter/service/impl/TaskNodeServiceImpl.java

@@ -1678,6 +1678,24 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
             //WMS只要把原材料入库
             R<String> rkresult = stockInfoService.handStockIn(task.getCompleteBatchNo());
             return rkresult;
+        }else if (DemoLineConstant.DEMOLINE_STOCK_TYPE_METERIAL_JIAJU_RK.equals(stockType)) {//原材料和夹具入库
+            List<BomProcedureMeterial> meterialList = bomProcedureMeterialService.list(Wraps.<BomProcedureMeterial>lbQ().eq(BomProcedureMeterial::getId, task.getProcedureMeterialId()));
+            if (meterialList != null && meterialList.size() > 0) {//只有入库
+                //WMS只要把原材料入库
+                R<String> rkresult = stockInfoService.meterialStockIn(meterialList.get(0), Long.parseLong(targetStorgeId), "", task.getCompleteBatchNo());
+            }
+
+            List<BomProcedureTray> trayList = procedureTrayService.list(Wraps.<BomProcedureTray>lbQ().eq(BomProcedureTray::getGroupId, task.getProcedureTrayGroupId()));
+            R<String> result = null;
+            if (trayList != null && trayList.size() > 0) {
+                for (BomProcedureTray tray : trayList) {
+                    if("1".equals(tray.getBizType())){//托盘不用入库
+                        break;
+                    }
+                    result = stockInfoService.procedureTrayStockIn(tray, Long.parseLong(targetStorgeId), result.getData(), task.getCompleteBatchNo());
+                }
+            }
+            return result;
         }
         return R.success("");
     }

+ 17 - 6
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/operationManagementCenter/service/impl/TaskServiceImpl.java

@@ -1089,13 +1089,24 @@ public class TaskServiceImpl extends SuperServiceImpl<TTaskMapper, TTask> implem
 //            jsonObject.put("srcPosition", jbwFromStorge.getId());
 
             Storge currstorge = workpieceService.getWorkPieceStock(taskNode.getCompleteBatchNo(), false);
-            jsonObject.put("targetPostion", currstorge.getId());
-            jsonObject.put("srcPosition", "");
-            //入库
-            jsonObject.put(DemoLineConstant.DEMOLINE_STOCK_TYPE, DemoLineConstant.DEMOLINE_STOCK_TYPE_METERIAL_RK);
-            //节点完成业务
-            taskNodeService.taskNodeCallbackBiz(taskNode, tTask, taskNodeList, lg, jsonObject.toJSONString());
+            if(currstorge!=null){
+                jsonObject.put("targetPostion", currstorge.getId());
+                jsonObject.put("srcPosition", "");
+
+                //查询库位里有托盘夹具,还是只有托盘
+                List<StockInfo>stockInfoList = stockInfoMapper.selectList(Wraps.<StockInfo>lbQ().eq(StockInfo::getStorgeId, currstorge.getId()));
+                if(CollectionUtil.isNotEmpty(stockInfoList)&&stockInfoList.size()==2){//有托盘和夹具
+                    //入库
+                    jsonObject.put(DemoLineConstant.DEMOLINE_STOCK_TYPE, DemoLineConstant.DEMOLINE_STOCK_TYPE_METERIAL_RK);
+                }
 
+                if(CollectionUtil.isNotEmpty(stockInfoList)&&stockInfoList.size()==1){//有托盘
+                    //入库
+                    jsonObject.put(DemoLineConstant.DEMOLINE_STOCK_TYPE, DemoLineConstant.DEMOLINE_STOCK_TYPE_METERIAL_JIAJU_RK);
+                }
+                //节点完成业务
+                taskNodeService.taskNodeCallbackBiz(taskNode, tTask, taskNodeList, lg, jsonObject.toJSONString());
+            }
         }
         return  R.success();
     }

+ 54 - 92
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionResourceCenter/service/impl/RobotNodeServiceImpl.java

@@ -13,6 +13,7 @@ import com.github.zuihou.business.edgeLibrary.entity.StockInfo;
 import com.github.zuihou.business.edgeLibrary.entity.Storge;
 import com.github.zuihou.business.edgeLibrary.service.StorgeService;
 import com.github.zuihou.business.operationManagementCenter.entity.TTask;
+import com.github.zuihou.business.operationManagementCenter.entity.TTaskTestDetail;
 import com.github.zuihou.business.operationManagementCenter.entity.TWorkpiece;
 import com.github.zuihou.business.operationManagementCenter.entity.TaskNode;
 import com.github.zuihou.business.operationManagementCenter.service.TaskNodeService;
@@ -37,9 +38,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
@@ -200,94 +199,12 @@ public class RobotNodeServiceImpl implements NodeOperationService {
         // 查找工件所属产线
         // 根据工序判断需要做什么任务
 
-
-        List<StockInfo> flikustockInfos = null;//获取初始立库库存
-
         //当需要锁定agv开始、结束的接驳位库位
         Storge agvStartStationStorge = null;
         Storge agvEndStationStorge = null;
         // 人工序只有上下料
-        if(taskNode.getCompleteBatchSort()==1){
-//            BBom bom = bBomMapper.selectOne(Wraps.<BBom>lbQ().eq(BBom::getId,task.getBomId()));
-            List<Productionresource> productionresources = productionresourceBizMapper.selectList(Wraps.<Productionresource>lbQ().like(Productionresource::getName,"立库"));
-            List<Long> productionresourceIds = productionresources.stream().map(t->t.getId()).collect(Collectors.toList());
-            List<ProductionresourcePosition> startProductionresourcePositions = productionresourcePositionMapper.selectList(Wraps.<ProductionresourcePosition>lbQ().in(ProductionresourcePosition::getResourceId, productionresourceIds));
-            List<Long> startProductionresourcePositionIds = startProductionresourcePositions.stream().map(t->t.getStorgeId()).collect(Collectors.toList());
-
-            List<BomProcedureTray>trayList = procedureTrayService.list(Wraps.<BomProcedureTray>lbQ().in(BomProcedureTray::getProcedureId, task.getProcedureId()));
-            List<Long>trayIdList = trayList.stream().map(t->t.getTrayId()).collect(Collectors.toList());
-            // 判断夹具是否有可用的,查询330个库位信息中是否还有夹具
-            flikustockInfos = stockInfoMapper.selectList(Wraps.<StockInfo>lbQ().in(StockInfo::getGoodsId,trayIdList).in(StockInfo::getStorgeId,startProductionresourcePositionIds).orderByAsc(StockInfo::getStorgeId));
-//            if(flikustockInfos.size() <= 0){
-//                map.put("result", false);
-//                map.put("msg", DictionaryKey.NodeException.RUNNING_FALSE);
-//                return map;
-//            }
-            // 按照顺序将托盘移动到上下料站
-            // 获取抓取托盘起点及放设备重点
-//            StockInfo metetailStockInfo = flikustockInfos.get(0);
-//            currStore = storgeMapper.selectById(metetailStockInfo.getStorgeId());
-//        }else{
-//            // 先判断上一指令是否为是否为设备指令,在判断工序最后一个指令是agv动作时锁定锁定agv接驳位
-//            TaskNode beforTaskNode = taskNodeService.getNextNTaskNode(taskNode,-1);
-//            TaskNode nextTaskNode = taskNodeService.getNextNTaskNode(taskNode,1);
-//            TaskNode lastOperationTaskNode = taskNodeService.getOne(Wraps.<TaskNode>lbQ().eq(TaskNode::getTaskId,taskNode.getTaskId()).orderByDesc(TaskNode::getCompleteBatchSort).last("limit 1"));
-//
-//            beforTaskNode.setAutoNode(resourceAutoCodeMapper.selectById(beforTaskNode.getAutoNode().getId()));
-//            //前序是设备序并且最后一个节点是agv搬运,锁定agv相关库位信息
-//            if(beforTaskNode.getTaskId().equals(taskNode.getTaskId()) && "1".equals(beforTaskNode.getAutoNode().getCategory()) && null == lastOperationTaskNode.getResourceId()){
-//                ProductionresourcePosition startProductionresourcePosition = null;
-//                ProductionresourcePosition endProductionresourcePosition = null;
-//                // 判断agv接驳位是可用
-//                ZZoneProductionresource zZoneProductionresource = zZoneProductionresourceMapper.selectOne(Wraps.<ZZoneProductionresource>lbQ().eq(ZZoneProductionresource::getResourceId,taskNode.getResourceId()));
-//                Map queryParams = new HashMap();
-//                queryParams.put("zoneId",zZoneProductionresource.getZoneId());
-//                queryParams.put("resourceName","接驳");
-//                List<Productionresource> agvStartStationsResources = productionresourceBizMapper.selectResouces(queryParams);
-//                Productionresource startAgvStation = null;
-//                Productionresource endAgvStation = null;
-//                // 遍历开始接驳位判断是否有可用的接驳位
-//                for(Productionresource agvStation : agvStartStationsResources){
-//                    startProductionresourcePosition = productionresourcePositionMapper.selectOne(Wraps.<ProductionresourcePosition>lbQ().eq(ProductionresourcePosition::getResourceId, agvStation.getId()));
-//                    List<StockInfo> agvStationMeterails = stockInfoMapper.selectList(Wraps.<StockInfo>lbQ().eq(StockInfo::getStorgeId,startProductionresourcePosition.getStorgeId()));
-//                    List<String> meterails = agvStationMeterails.stream().map(p -> p.getGoodsType()).collect(Collectors.toList());
-//                    agvStartStationStorge = storgeService.getById(startProductionresourcePosition.getStorgeId());
-//                    // 有托板但是没有托盘认为可放
-//                    if(meterails.contains("5") && !meterails.contains("2") && agvEndStationStorge.getStatus().equals("1")){
-//                        endAgvStation = agvStation;
-//                        break;
-//                    }
-//                }
-//
-//                if (null != agvStartStationStorge && null != agvEndStationStorge){
-////                    storgeService.lockStorge(agvStartStationStorge, nextTaskNode.getId());
-////                    storgeService.lockStorge(agvEndStationStorge, lastOperationTaskNode.getId());
-//                    // 将agv相关的节点的目标节点地址更新进tasknode表
-//                    nextTaskNode.setTargetResourceId(startAgvStation.getId());
-//                    lastOperationTaskNode.setTargetResourceId(endAgvStation.getId());
-//                    taskNodeService.updateById(nextTaskNode);
-//                    taskNodeService.updateById(lastOperationTaskNode);
-//                    dataMap.put("bizType","agv");
-//                }else{
-////                    // 获取机器人操作线边库
-////                    xbkArr = new String[]{DictionaryKey.YJ_ZONE_XBK.get(zoneName)};
-////                    xbkList = productionresourcePositionService.getFreeProductionresourcePositionByNos(xbkArr);
-////                    if(CollectionUtil.isNotEmpty(xbkList)){
-////                        ProductionresourcePosition position = xbkList.get(0);
-////                        // TODO 应该需要合并到getTargetStorge 方法中
-//////                    targetStorge = storgeService.getById(position.getStorgeId());
-////                        map.put("bizType","xbk");
-////                    }
-//                }
-//            }
-        }
 
-        //目标地址判断
-//        if(map.containsKey("useXbk")){
-//            //目标地址是线边库
-//            map.put("result", false);
-//            return map;
-//        }
+
 
         switch(zoneName){
             case "质量中心机器人":
@@ -299,26 +216,26 @@ public class RobotNodeServiceImpl implements NodeOperationService {
             case "柔性线机器人":
                 //操作柔性线边库 具有取、移动、放三种指令
                 //取放加工设备  设备存在缓存位
-                dataMap = this.commandHandle(dataMap,flikustockInfos,agvStartStationStorge,functionName);
+                dataMap = this.commandHandle(dataMap,agvStartStationStorge,functionName);
                 dataMap.put("deviceUrl", ZK_ip_rxx);
                 break;
             case "智能单元机器人":
                 //操作智能单元线边库 具有取、移动、放三种指令
                 //取放加工设备 无缓存位处理
-                dataMap = this.commandHandle(dataMap , flikustockInfos,agvStartStationStorge,functionName);
+                dataMap = this.commandHandle(dataMap ,agvStartStationStorge,functionName);
                 dataMap.put("deviceUrl", ZK_ip_zndy);
                 break;
             case "舱体类加工单元":
                 //操作舱体线边库 具有取、移动、放三种指令
                 //取放加工设备
-                dataMap = this.commandHandle(dataMap,flikustockInfos,agvStartStationStorge, functionName);
+                dataMap = this.commandHandle(dataMap,agvStartStationStorge, functionName);
                 break;
             case "智能生产保障系统":
-                dataMap = this.commandHandle(dataMap,flikustockInfos, agvStartStationStorge,functionName);
+                dataMap = this.commandHandle(dataMap, agvStartStationStorge,functionName);
                 dataMap.put("deviceUrl", ZK_ip_rxx);
                 break;
             case "框体类加工单元":
-                dataMap = this.commandHandle(dataMap,flikustockInfos,agvStartStationStorge, functionName);
+                dataMap = this.commandHandle(dataMap,agvStartStationStorge, functionName);
                 dataMap.put("deviceUrl", ZK_ip_rxx);
                 break;
         }
@@ -347,7 +264,7 @@ public class RobotNodeServiceImpl implements NodeOperationService {
     }
 
     //机器人功能操作
-    private Map<String, Object>  commandHandle(Map<String, Object> dataMap, List<StockInfo>flikustockInfos, Storge agvStartStationStorge,String functionName){
+    private Map<String, Object>  commandHandle(Map<String, Object> dataMap, Storge agvStartStationStorge,String functionName){
         TaskNode taskNode = (TaskNode) dataMap.get("taskNode");
         TTask task = (TTask) dataMap.get("task");
         int count = Integer.parseInt(dataMap.get(taskNode.getId().toString() + "count") == null ? "0" : dataMap.get(taskNode.getId().toString() + "count").toString());
@@ -355,6 +272,13 @@ public class RobotNodeServiceImpl implements NodeOperationService {
         Storge startStore = workpieceService.getWorkPieceStock(taskNode.getCompleteBatchNo(), false);
         //目的库位
         Storge jqrStorge = null;
+
+        List<StockInfo>flikustockInfos = null;
+
+
+        if(taskNode.getCompleteBatchSort()==1){
+            flikustockInfos = this.getLikuStockList(task);
+        }
         //缓存位判断处理
         if ("取".equals(functionName)) {
             if(BizConstant.ROBOT_TYPE_CACHE.equals(zoneService.getRobotTypebyZone(zoneName))){
@@ -691,4 +615,42 @@ public class RobotNodeServiceImpl implements NodeOperationService {
         return robotList.get(0);
     }
 
+
+    /**
+     * 立库获取起点位置,优先取有托盘夹具的数据
+     * @param task
+     * @return
+     */
+    private List<StockInfo>getLikuStockList(TTask task){
+        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());
+        List<ProductionresourcePosition> startProductionresourcePositions = productionresourcePositionMapper.selectList(Wraps.<ProductionresourcePosition>lbQ().in(ProductionresourcePosition::getResourceId, productionresourceIds));
+        List<Long> startProductionresourcePositionIds = startProductionresourcePositions.stream().map(t->t.getStorgeId()).collect(Collectors.toList());
+
+        List<BomProcedureTray>trayList = procedureTrayService.list(Wraps.<BomProcedureTray>lbQ().in(BomProcedureTray::getProcedureId, task.getProcedureId()));
+        List<Long>trayIdList = trayList.stream().map(t->t.getTrayId()).collect(Collectors.toList());
+        // 判断夹具是否有可用的,查询330个库位信息中是否还有夹具
+        List<StockInfo> allStockList = stockInfoMapper.selectList(Wraps.<StockInfo>lbQ().in(StockInfo::getGoodsId,trayIdList).in(StockInfo::getStorgeId,startProductionresourcePositionIds).orderByAsc(StockInfo::getStorgeId));
+        if(CollectionUtil.isNotEmpty(allStockList)){
+            Map<Long,List<StockInfo>>map = allStockList.stream().collect(groupingBy(StockInfo::getStorgeId));
+            Long k = null;
+            for(Long key:map.keySet()){
+                k = key;
+                //优先有托盘夹具的
+                List<StockInfo> stockInfoList = map.get(key);
+                if(stockInfoList!=null&&stockInfoList.size()==2){
+                    returnList = stockInfoList;
+                    break;
+                }
+            }
+            //只有托盘的
+            if(returnList==null){//取齐总一个
+                returnList = map.get(k);
+            }
+        }
+        return returnList;
+    }
+
 }