Quellcode durchsuchen

零件追溯,自动化节点联调问题修改

yejian vor 3 Jahren
Ursprung
Commit
4d9f709c0b

+ 2 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/edgeLibrary/dao/StockInfoMapper.java

@@ -57,4 +57,6 @@ public interface StockInfoMapper extends SuperMapper<StockInfo> {
     int selectSumInStockByProductId(Map queryMap);
 
     String selectMaxNoByProductId(Map queryMap);
+
+    List<Long> getAvailableStorge(Map queryMap);
 }

+ 69 - 65
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/mq/TaskWorkNode.java

@@ -425,62 +425,66 @@ public class TaskWorkNode {
      * @throws Exception
      */
     public Map checkCon(TaskNode taskNode, TTask task, Map<String, Object> dataMap) {
-//        Map map = getCheckCon(taskNode, task, dataMap);
-//        boolean b = (boolean) map.get("result");
-//        if (!b) {
-//            Thread.sleep(10000);
-//            return checkCon(taskNode, task, dataMap);
-//        } else {
-//            return map;
-//        }
-        logger.info("异步消息获取执行状态:");
-        //单线程化线程池
-        //初始化执行次数(默认10次) 10次后按超时处理
-        ExecutorService pool = Executors.newSingleThreadExecutor();
-        List<CompletableFuture<Map>> futures = new ArrayList<CompletableFuture<Map>>();
-
-        List<Map> retList = new ArrayList<Map>();
-        int[] nums = IntStream.range(0, 9).toArray();
-
-        CompletableFuture<Map> future = CompletableFuture.supplyAsync(() -> {
-            Map<String, Object> threadMap = getCheckCon(taskNode, task, dataMap);
-            boolean bool= (Boolean) threadMap.get("result");
-            return bool? threadMap: null;
-        }, pool).handle((result, ex) -> {
-            if (null != ex) {
-                return null;
-            } else {
-                if(null!=result){
-                   retList.add((Map)result);
-                }
-                return result;
-            }
-        });
-
-        if (null == future.join()){
-            //开启异步串行调用
-            for (int i : nums) {
-                logger.info("节点:" + taskNode.getId() + "进行第" + i + "次异步轮询条件查询");
-                future = future.thenApply(map -> {
-                    Map<String, Object> threadMap = null;
-                    try {
-                        TimeUnit.SECONDS.sleep(5 * i);
-                        threadMap = getCheckCon(taskNode, task, dataMap);
-                    } catch (InterruptedException ie) {
-                        ie.printStackTrace();
-                    }
-                    boolean bool= (Boolean) threadMap.get("result");
-                    return bool? threadMap: null;
-                });
-                if (null != future.join()) {
-                    boolean bool = (Boolean) future.join().get("result");
-                    if (bool) {
-                        retList.add((Map) future.join());
-                        break;
-                    }
-                }
+        Map map = getCheckCon(taskNode, task, dataMap);
+        boolean b = (boolean) map.get("result");
+        if (!b) {
+            try {
+                Thread.sleep(10000);
+            } catch (InterruptedException e) {
+                e.printStackTrace();
             }
+            return checkCon(taskNode, task, dataMap);
+        } else {
+            return map;
         }
+//        logger.info("异步消息获取执行状态:");
+//        //单线程化线程池
+//        //初始化执行次数(默认10次) 10次后按超时处理
+//        ExecutorService pool = Executors.newSingleThreadExecutor();
+//        List<CompletableFuture<Map>> futures = new ArrayList<CompletableFuture<Map>>();
+//
+//        List<Map> retList = new ArrayList<Map>();
+//        int[] nums = IntStream.range(0, 9).toArray();
+//
+//        CompletableFuture<Map> future = CompletableFuture.supplyAsync(() -> {
+//            Map<String, Object> threadMap = getCheckCon(taskNode, task, dataMap);
+//            boolean bool= (Boolean) threadMap.get("result");
+//            return bool? threadMap: null;
+//        }, pool).handle((result, ex) -> {
+//            if (null != ex) {
+//                return null;
+//            } else {
+//                if(null!=result){
+//                   retList.add((Map)result);
+//                }
+//                return result;
+//            }
+//        });
+//
+//        if (null == future.join()){
+//            //开启异步串行调用
+//            for (int i : nums) {
+//                logger.info("节点:" + taskNode.getId() + "进行第" + i + "次异步轮询条件查询");
+//                future = future.thenApply(map -> {
+//                    Map<String, Object> threadMap = null;
+//                    try {
+//                        TimeUnit.SECONDS.sleep(5 * i);
+//                        threadMap = getCheckCon(taskNode, task, dataMap);
+//                    } catch (InterruptedException ie) {
+//                        ie.printStackTrace();
+//                    }
+//                    boolean bool= (Boolean) threadMap.get("result");
+//                    return bool? threadMap: null;
+//                });
+//                if (null != future.join()) {
+//                    boolean bool = (Boolean) future.join().get("result");
+//                    if (bool) {
+//                        retList.add((Map) future.join());
+//                        break;
+//                    }
+//                }
+//            }
+//        }
 
          /*
          CompletableFuture.anyOf(futures.toArray(new CompletableFuture[futures.size()])).whenComplete((res, ex)->{
@@ -489,17 +493,17 @@ public class TaskWorkNode {
              }
          }); */
 
-        if (retList.size() == 0) {
-            logger.error("节点:" + taskNode.getId() + "条件判断超时");
-            //return checkCon(taskNode, task, dataMap);
-            //pool.shutdown();
-            //throw new BizException("执行异常或判断超时");
-            return null;
-        } else {
-            pool.shutdown();
-            logger.info("条件判断成功");
-            return retList.get(0);
-        }
+//        if (retList.size() == 0) {
+//            logger.error("节点:" + taskNode.getId() + "条件判断超时");
+//            //return checkCon(taskNode, task, dataMap);
+//            //pool.shutdown();
+//            //throw new BizException("执行异常或判断超时");
+//            return null;
+//        } else {
+//            pool.shutdown();
+//            logger.info("条件判断成功");
+//            return retList.get(0);
+//        }
     }
 
     /**

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

@@ -1481,6 +1481,7 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
                     //计划完成
                     Plan plan = planMapper.selectById(task.getPlanId());
                     plan.setProduceStatus("3");
+                    plan.setPlanStatus("3");
                     planMapper.updateById(plan);
 
                     //订单完成

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

@@ -267,6 +267,8 @@ public class RobotNodeServiceImpl implements NodeOperationService {
     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");
+        BomProcedure bomProcedure = bomProcedureMapper.selectOne(Wraps.<BomProcedure>lbQ().eq(BomProcedure::getId,task.getProcedureId()));
+
         int count = Integer.parseInt(dataMap.get(taskNode.getId().toString() + "count") == null ? "0" : dataMap.get(taskNode.getId().toString() + "count").toString());
 
         Storge startStore = workpieceService.getWorkPieceStock(taskNode.getCompleteBatchNo(), false);
@@ -298,7 +300,7 @@ public class RobotNodeServiceImpl implements NodeOperationService {
                     }
 
                     //目标库位,可能是
-                    Map returnMap = getTargetStorge(nextTaskNode,taskNode.getFindAgvFlag());
+                    Map returnMap = getTargetStorge(nextTaskNode,taskNode.getFindAgvFlag(),bomProcedure.getType());
                     //目标地址和类型
                     Storge targetStorge = returnMap.get("store")==null?null:(Storge)returnMap.get("store");
                     String targetxbk = returnMap.get("targetxbk")==null?null:(String)returnMap.get("targetxbk");
@@ -372,7 +374,7 @@ public class RobotNodeServiceImpl implements NodeOperationService {
                 }
             }else if (BizConstant.ROBOT_TYPE_NOCACHE.equals(zoneService.getRobotTypebyZone(zoneName))) {
                 TaskNode nextTaskNode = taskNodeService.getNextNTaskNode(taskNode, 1);
-                Map returnMap = getTargetStorge(nextTaskNode,taskNode.getFindAgvFlag());
+                Map returnMap = getTargetStorge(nextTaskNode,taskNode.getFindAgvFlag(),bomProcedure.getType());
 
                 //获取当前位置
                 if(CollectionUtil.isNotEmpty(flikustockInfos)){//
@@ -519,7 +521,7 @@ public class RobotNodeServiceImpl implements NodeOperationService {
 
 
 
-    public Map getTargetStorge(TaskNode taskNode,String findAgvFlag){
+    public Map getTargetStorge(TaskNode taskNode,String findAgvFlag,String bomProcedureType){
         Map returnMap = new HashMap();
         Storge targetStorge = null;
         Storge agvEndStationStorge = null;
@@ -562,15 +564,23 @@ public class RobotNodeServiceImpl implements NodeOperationService {
                 xbkFlag = "1";
             }
         }else {
-            //目标设备
-            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("targetxbk","0");
-                }else{//需要放到线边库
-                    xbkFlag = "1";
+            if(bomProcedureType.equals("下料")){
+                // 下料特殊处理,动态查找可用立库位子存放下料后的子盘夹具
+                Long storgeId = getLikuStockInList();
+                targetStorge = storgeService.getById(storgeId);
+                returnMap.put("store",targetStorge);
+                returnMap.put("targetxbk","0");
+            }else{
+                //目标设备
+                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("targetxbk","0");
+                    }else{//需要放到线边库
+                        xbkFlag = "1";
+                    }
                 }
             }
         }
@@ -661,4 +671,39 @@ public class RobotNodeServiceImpl implements NodeOperationService {
         return returnList;
     }
 
+    /**
+     * 立库获取终点位置,取空库位的数据
+     * @param task
+     * @return
+     */
+    private long getLikuStockInList(){
+        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());
+
+        if(CollectionUtil.isEmpty(productionresourceIds)){
+            return -1;
+        }
+        String resourceIds = "";
+        for(int i = 0; i < productionresourceIds.size(); i++){
+            if(i == productionresourceIds.size() - 1){
+                resourceIds = resourceIds + productionresourceIds.get(i);
+            }else{
+                resourceIds = resourceIds + productionresourceIds.get(i)+ ",";
+            }
+        }
+        Map queryMap = new HashMap();
+        queryMap.put("resourceIds",resourceIds);
+
+        // 判断夹具是否有可用的,查询330个库位信息中是否还有夹具
+
+        List<Long> allStockList = stockInfoMapper.getAvailableStorge(queryMap);
+        if(allStockList.size() > 0){
+            return allStockList.get(0);
+        }else{
+            return -1;
+        }
+    }
+
 }

+ 10 - 0
imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/edgeLibrary/StockInfoMapper.xml

@@ -191,4 +191,14 @@
         select max(CONVERT(ifnull(unique_code,0), UNSIGNED INTEGER)) from imcs_s_stock_log where goods_id = #{goodsId} and opt_type = #{type}
     </select>
 
+    <select id="getAvailableStorge" resultType="java.lang.Long">
+        SELECT
+          ippp.storge_id
+        FROM imcs_p_productionresource_position ippp
+          LEFT JOIN imcs_s_stock_info issi
+            ON ippp.storge_id = issi.storge_id
+        WHERE ippp.resource_id IN (${resourceIds})
+        AND issi.storge_id IS NULL
+        ORDER BY ippp.storge_id
+    </select>
 </mapper>

+ 2 - 2
imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/operationManagementCenter/PlanMapper.xml

@@ -116,8 +116,8 @@
         AND ioop.order_id = ipp.order_id
         AND ioop.bom_id = ippp.bom_id
         AND ibb.id = ippp.bom_id
-        <if test="orderId != null and orderId != ''">
-            and ioop.order_id = #{orderId}
+        <if test="planId != null and planId != ''">
+            and ipp.id = #{planId}
         </if>
     </select>
 

+ 2 - 6
imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/operationManagementCenter/TaskBizMapper.xml

@@ -38,10 +38,7 @@
 
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
-        id,create_time,update_time,update_user,
-        order_id,order_no, plan_id,plan_no, resource_id, procedure_id,procedure_name, task_no, status, expect_start_time, expect_end_time, start_time, end_time,orderName,
-        prority, draft_flag, executor_id, executor_type, executor_name,procedure_meterial_id, procedure_tray_group_id, procedure_program_id, task_batch_no,process,bom_batch_no,
-        overtimeStatus,bomDesc,procedure_no,planTime,ratedWorkHours,actualTime,resourceDesc,content,prepareWorkHours,bomNo,procedureDesc,ip,port,resourceName
+        id, start_time, end_time, procedure_no, resourceName
     </sql>
 
     <!-- 分页 -->
@@ -49,10 +46,9 @@
         select
         <include refid="Base_Column_List"/>
         from (
-            select a.*,(select itp.name as resourceName from imcs_tenant_productionresource itp where itp.id= a.resource_id )
+            select a.*,(select itp.name  from imcs_tenant_productionresource itp where itp.id= a.resource_id ) as resourceName
             from imcs_t_task a
             where 1=1
-            and a.complete_batch_no = #{completeBatchNo}
         )
         s ${ew.customSqlSegment}
     </select>

+ 5 - 0
imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/operationManagementCenter/dto/TTaskPageDTO.java

@@ -25,6 +25,8 @@ import lombok.experimental.Accessors;
 import com.github.zuihou.common.constant.DictionaryType;
 import java.io.Serializable;
 
+import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;
+
 /**
  * <p>
  * 实体类
@@ -155,4 +157,7 @@ public class TTaskPageDTO implements Serializable {
     @Length(max = 32, message = "任务批次号长度不能超过32")
     private String taskBatchNo;
 
+    @ApiModelProperty(value = "完整产品加工批次号(一个bom的完整流程的批次号)")
+    @Length(max = 36, message = "完整产品加工批次号(一个bom的完整流程的批次号)长度不能超过36")
+    private String completeBatchNo;
 }

+ 7 - 0
imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/operationManagementCenter/dto/TWorkpiecePageDTO.java

@@ -1,6 +1,8 @@
 package com.github.zuihou.business.operationManagementCenter.dto;
 
 import java.time.LocalDateTime;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.github.zuihou.base.entity.Entity;
 import com.baomidou.mybatisplus.annotation.TableField;
@@ -20,6 +22,8 @@ import lombok.experimental.Accessors;
 import com.github.zuihou.common.constant.DictionaryType;
 import java.io.Serializable;
 
+import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;
+
 /**
  * <p>
  * 实体类
@@ -71,4 +75,7 @@ public class TWorkpiecePageDTO implements Serializable {
     @Length(max = 32, message = "长度不能超过64")
     private String planNo;
 
+    @ApiModelProperty(value = "计划id")
+    private Long planId;
+
 }