Selaa lähdekoodia

1. 资源不能用时进入线边库等待资源可用重新进行后续逻辑
2. 打标机处理完成后不释放资源,后续节点检查机器人是否可用时直接判断机器人可用,防止抢占死锁
3. 资源释放如果是机器人的动作时,等到机器人放完成后释放资源,防止抢占死锁
4. 增加如果进入线边库逻辑时,等到线边库取出重新放到目标设备时资源释放
5. 操作工人工时管理问题修改

yejian 3 vuotta sitten
vanhempi
commit
2e95ede7ab

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

@@ -779,12 +779,13 @@ public class TaskWorkNode {
         String paramKey = zone.getNo() + "_plc";
         String instructionUrl = (null == msgUtil.redis_get(ParameterKey.PARAMETERS)? "": ((Map<String,String>)msgUtil.redis_get(ParameterKey.PARAMETERS)).get(paramKey).toString());
 
-        // TODO 后续删除代码,目前条用模拟接口
-        if("framework".equals(zone.getNo())){
-            instructionUrl = instructionUrl.replace("8086","8083");
-        }else{
-            instructionUrl = instructionUrl.replace("8081","8083");
-        }
+
+//        // TODO 后续删除代码,目前条用模拟接口
+//        if("framework".equals(zone.getNo())){
+//            instructionUrl = instructionUrl.replace("8086","8083");
+//        }else{
+//            instructionUrl = instructionUrl.replace("8081","8083");
+//        }
 
         int count = Integer.parseInt(dataMap.get(taskNode.getId().toString() + "count") == null ? "0" : dataMap.get(taskNode.getId().toString() + "count").toString());
         BomProcedure bomProcedure = bomProcedureMapper.selectOne(Wraps.<BomProcedure>lbQ().eq(BomProcedure::getId,task.getProcedureId()));
@@ -830,8 +831,6 @@ public class TaskWorkNode {
 
                 ProductionresourcePosition po = logical(robotList,dataMap);
 
-
-
                 //机器人手抓没被锁定,并且有空闲未知
                 if (po != null) {
                     // 线边库轮询判断后续节点目标地址是否时接驳位
@@ -918,6 +917,7 @@ public class TaskWorkNode {
                 dataMap.put("result", true);
             }
             if (count == 3) {
+                targetStorge = msgUtil.redis_get(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_STORE + taskNode.getId())==null?null:(Storge)msgUtil.redis_get(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_STORE + taskNode.getId());
                 Map locationMap = new HashMap();
                 locationMap.put("location", targetStorge.getPointId());
                 dataMap.put("Data", locationMap);
@@ -939,6 +939,7 @@ public class TaskWorkNode {
                 dataMap.put(DemoLineConstant.DEMOLINE_STOCK_TYPE, DemoLineConstant.DEMOLINE_STOCK_TYPE_ALL_CRK);
                 dataMap.put("result", true);
             } else if (count == 5) {
+                targetStorge = msgUtil.redis_get(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_STORE + taskNode.getId())==null?null:(Storge)msgUtil.redis_get(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_STORE + taskNode.getId());;
                 dataMap.put("method", "SendFlexibleWire");
                 //出入库类型
                 dataMap.put(DemoLineConstant.DEMOLINE_STOCK_TYPE, DemoLineConstant.DEMOLINE_STOCK_TYPE_ALL_CRK);

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

@@ -30,7 +30,11 @@ import com.github.zuihou.business.productionReadyCenter.entity.*;
 import com.github.zuihou.business.productionReadyCenter.service.*;
 import com.github.zuihou.business.productionResourceCenter.dao.ProductionresourceBizMapper;
 import com.github.zuihou.business.productionResourceCenter.dao.ProductionresourcePositionMapper;
-import com.github.zuihou.business.productionResourceCenter.entity.*;
+import com.github.zuihou.business.productionResourceCenter.dao.ResourceBusinessMapper;
+import com.github.zuihou.business.productionResourceCenter.entity.Productionresource;
+import com.github.zuihou.business.productionResourceCenter.entity.ProductionresourcePosition;
+import com.github.zuihou.business.productionResourceCenter.entity.ResourceAutoCode;
+import com.github.zuihou.business.productionResourceCenter.entity.ResourceBusiness;
 import com.github.zuihou.business.productionResourceCenter.service.ProductionresourcePositionService;
 import com.github.zuihou.business.productionResourceCenter.service.ResourceAutoCodeService;
 import com.github.zuihou.business.productionResourceCenter.service.ResourceBusinessService;
@@ -38,7 +42,10 @@ import com.github.zuihou.business.productionResourceCenter.service.ZZoneService;
 import com.github.zuihou.business.util.DynamicRabbitMq;
 import com.github.zuihou.business.util.ManualTaskOperatorUtil;
 import com.github.zuihou.business.util.MsgUtil;
-import com.github.zuihou.common.constant.*;
+import com.github.zuihou.common.constant.BizConstant;
+import com.github.zuihou.common.constant.CacheKey;
+import com.github.zuihou.common.constant.CodeRuleModule;
+import com.github.zuihou.common.constant.DictionaryKey;
 import com.github.zuihou.common.util.StringUtil;
 import com.github.zuihou.context.BaseContextHandler;
 import com.github.zuihou.database.mybatis.conditions.Wraps;
@@ -49,7 +56,6 @@ import com.github.zuihou.tenant.entity.ProductionlineUser;
 import com.github.zuihou.tenant.service.CodeRuleService;
 import com.github.zuihou.tenant.service.ProductionlineService;
 import com.github.zuihou.tenant.service.ProductionlineUserService;
-import com.github.zuihou.tenant.service.ProductionresourceService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
@@ -69,7 +75,6 @@ import java.util.stream.Collectors;
 
 import static com.github.zuihou.utils.BizAssert.isFalse;
 import static java.util.stream.Collectors.groupingBy;
-import static java.util.stream.Collectors.toList;
 
 /**
  * <p>
@@ -194,7 +199,7 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
     private WorkpieceService workpieceService;
 
     @Autowired
-    private ResourceBusinessService resourceBusinessService;
+    private ResourceBusinessMapper resourceBusinessMapper;
 
     @Autowired
     private ResourceAutoCodeService resourceAutoCodeService;
@@ -324,8 +329,9 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
             int i = 1;
             for (TTask t : taskList) {
                 //taskList里面包含了所有的一次勾选的所有任务
-                if(!key.equals(t.getCompleteBatchNo()))
+                if(!key.equals(t.getCompleteBatchNo())){
                     continue;
+                }
 
                 //取出resrouceId
                 Long resourceBusinessId = t.getResourceBusinessId();
@@ -760,8 +766,9 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
     @Override
     public R<String> BomProcedureMeterialStock(TaskNode taskNode, AutoNode autoNode, TTask task, String uniqueCode) {
         //如果没有分配到资源,则不做出入库,这种情况基本是异常情况
-        if (task.getProcedureMeterialId() == null)
+        if (task.getProcedureMeterialId() == null){
             return R.success(uniqueCode);
+        }
 
         //只出入库任务选择的原材料
         List<BomProcedureMeterial> meterialList = bomProcedureMeterialService.list(Wraps.<BomProcedureMeterial>lbQ().eq(BomProcedureMeterial::getId, task.getProcedureMeterialId()));
@@ -823,8 +830,9 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
     @Override
     public R<String> BomProcedureTrayStock(TaskNode taskNode, AutoNode autoNode, TTask task, String uniqueCode) {
         //如果没有分配到资源,则不做出入库,这种情况基本是异常情况
-        if (task.getProcedureTrayGroupId() == null)
+        if (task.getProcedureTrayGroupId() == null){
             return R.success(uniqueCode);
+        }
 
         List<BomProcedureTray> procedureTrayList = procedureTrayService.list(Wraps.<BomProcedureTray>lbQ().eq(BomProcedureTray::getGroupId, task.getProcedureTrayGroupId()));
         List<TTaskStockUniqueCode> stockUniqueCodeList = new ArrayList<TTaskStockUniqueCode>();
@@ -1019,7 +1027,7 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
         //查询质检码
         List<TTaskTestMeterialCode> testMeterialCodeList = taskTestMeterialCodeMapper.selectList(Wraps.<TTaskTestMeterialCode>lbQ().eq(TTaskTestMeterialCode::getTaskNodeId, taskNode.getId()));
 
-        //原材料列表
+        // 原材料列表
         Map<Long, List<TTaskStockUniqueCode>> meterialMap = null;
         Map<Long, List<TTaskTestMeterialCode>> testMeterialMap = null;
         if (meterialCodeList != null) {
@@ -1051,8 +1059,9 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
         //验证,必须有一个不为空,验证的其中一个
         List<BomProcedureMeterial> metiralList = bean.getMeterialList();
         List<BomProcedureTray> trayList = bean.getProcedureTrayList();
-        if ((metiralList == null || metiralList.size() == 0) && (trayList == null || trayList.size() == 0))
+        if ((metiralList == null || metiralList.size() == 0) && (trayList == null || trayList.size() == 0)){
             return "";
+        }
 
         String uniqueCode = "";
         if (metiralList != null && metiralList.size() > 0) {//验证的是入产线编码校验结果原材料
@@ -1100,8 +1109,9 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
         List<BomProcedureMeterial> metiralList = bean.getMeterialList();
         List<BomProcedureTray> trayList = bean.getProcedureTrayList();
 
-        if ((metiralList == null || metiralList.size() == 0) && (trayList == null || trayList.size() == 0))
+        if ((metiralList == null || metiralList.size() == 0) && (trayList == null || trayList.size() == 0)){
             return list;
+        }
 
 
         //获取当前任务,当前节点的上料站库位
@@ -1141,8 +1151,9 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
         List<BomProcedureMeterial> metiralList = bean.getMeterialList();
         List<BomProcedureTray> trayList = bean.getProcedureTrayList();
 
-        if ((metiralList == null || metiralList.size() == 0) && (trayList == null || trayList.size() == 0))
+        if ((metiralList == null || metiralList.size() == 0) && (trayList == null || trayList.size() == 0)){
             return "";
+        }
 
         //获取当前任务,当前节点的上料站库位
         //获取当前节点的设备库位
@@ -1199,8 +1210,9 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
         List<BomProcedureMeterial> metiralList = bean.getMeterialList();
         List<BomProcedureTray> trayList = bean.getProcedureTrayList();
 
-        if ((metiralList == null || metiralList.size() == 0) && (trayList == null || trayList.size() == 0))
+        if ((metiralList == null || metiralList.size() == 0) && (trayList == null || trayList.size() == 0)){
             return "";
+        }
         //获取当前任务,当前节点的上料站库位
         //获取当前节点的设备库位
         Long storgeId = getStorgeIdByTaskNode(bean);
@@ -1299,7 +1311,12 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
     @Override
     public R taskNodeCallback(TaskNodeCallBackDTO bean) {
         log.info("指令回调参数======================" + JSONObject.toJSONString(bean));
-
+        BaseContextHandler.setTenant("0000");
+        String taskId = bean.getTaskId() == null ? "" : bean.getTaskId().toString();
+        TTask task = taskService.getById(taskId);
+        if(null == task){
+            return R.fail("任务不存在");
+        }
         String uid = bean.getUid() == null ? "" : bean.getUid().toString();
 
         //验证是否重复回调
@@ -1309,8 +1326,6 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
             return null;
         }
 
-
-        BaseContextHandler.setTenant("0000");
         //取出参数
         String code = bean.getCode();
         String msg = bean.getMsg()!=null? bean.getMsg() : "指令操作失败";
@@ -1329,13 +1344,13 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
         //接口不让传多余参数,只能从缓存传
         String jsonParam = msgUtil.redis_get(YunjianConstant.YUNJIAN_CALLBACK_PARAM+"_" + taskNodeId)==null?"":msgUtil.redis_get(YunjianConstant.YUNJIAN_CALLBACK_PARAM+"_" + taskNodeId).toString();
         //把三坐标检测结果追加进去
-        if(StringUtil.isNotEmpty(jsonParam)){
-            JSONObject callBackJsonParam = JSONObject.parseObject(jsonParam);
-            if(StringUtil.isNotEmpty(bean.getResult())){
-                callBackJsonParam.put("result",bean.getResult());
-            }
-            jsonParam = callBackJsonParam.toJSONString();
-        }
+//        if(StringUtil.isNotEmpty(jsonParam)){
+//            JSONObject callBackJsonParam = JSONObject.parseObject(jsonParam);
+//            if(StringUtil.isNotEmpty(bean.getResult())){
+//                callBackJsonParam.put("result",bean.getResult());
+//            }
+//            jsonParam = callBackJsonParam.toJSONString();
+//        }
 
         Object taskInfoObject = msgUtil.redis_get(taskNodeId);
         if(null != taskInfoObject){
@@ -1350,13 +1365,10 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
 
         }
 
-        String taskId = bean.getTaskId() == null ? "" : bean.getTaskId().toString();
         String bizCallBackData = jsonParam;
         //把当前id存放入缓存
         msgUtil.redis_set(uid, uid, 1, TimeUnit.HOURS);
 
-        TTask task = taskService.getById(taskId);
-
         List<TaskNode> taskNodeList = baseMapper.selectList(Wraps.<TaskNode>lbQ().eq(TaskNode::getCompleteBatchNo, task.getCompleteBatchNo()).orderByAsc(TaskNode::getCompleteBatchSort));
 
         Map<Long, TaskNode> taskNodeMap = taskNodeList.stream().collect(Collectors.toMap(TaskNode::getId, t -> t));
@@ -1400,6 +1412,7 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
         //处理出库入库
         R<String> r = demoLineStock(taskNode, task, callBackJson,currWorkpiece);
 
+
         updateBizStatus(taskNode, task, taskNodeList, lg, callBackJson, r,currWorkpiece);
 
         //websocket推送TODO临时注释
@@ -1470,7 +1483,7 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
                 orderMapper.updateAllById(order);
             }
             //解锁相关资源
-            unlockResource(taskNode, task);
+            unlockResource(taskNode, task, callBackJson);
 
             //更新订单表里的完成数量等等字段,一个任务执行完的时候更相信
             if (n == taskNodeList.size() - 1) {
@@ -1514,8 +1527,9 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
      * @return
      */
     private boolean isLastTask(int n, TaskNode taskNode, List<TaskNode> taskNodeList) {
-        if (n == taskNodeList.size() - 1)
+        if (n == taskNodeList.size() - 1){
             return true;
+        }
         //这里不会数组越界,当n=len-1得时候不会再有推送或回调
         TaskNode nextTaskNode = taskNodeList.get(n + 1);
 
@@ -1555,18 +1569,96 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
      * @param taskNode
      * @param task
      */
-    public void unlockResource(TaskNode taskNode, TTask task) {
+    public void unlockResource(TaskNode taskNode, TTask task, JSONObject callBackJson) {
         //WMS出货
 //        if(DemoLineConstant.DEMOLINE_OP01_01.equals(taskNode.getNodeNo())||DemoLineConstant.DEMOLINE_OP01_02.equals(taskNode.getNodeNo())
 //                ||DemoLineConstant.DEMOLINE_OP01_03.equals(taskNode.getNodeNo())||DemoLineConstant.DEMOLINE_OP01_04.equals(taskNode.getNodeNo())
 //                ||DemoLineConstant.DEMOLINE_OP01_06.equals(taskNode.getNodeNo())||DemoLineConstant.DEMOLINE_OP01_07.equals(taskNode.getNodeNo())
 //                ||DemoLineConstant.DEMOLINE_OP02_01.equals(taskNode.getNodeNo())||DemoLineConstant.DEMOLINE_OP02_02.equals(taskNode.getNodeNo())){
-        //删除当前节点的锁定
-        List<Storge> storgeList = storgeService.list(Wraps.<Storge>lbQ().eq(Storge::getCampId, taskNode.getId()));
-        if (CollectionUtil.isNotEmpty(storgeList)) {
-            storgeService.unlockStorgeList(storgeList);
+        log.info("节点{}回调后释放资源,回调业务参数{}", taskNode.getId(), callBackJson);
+
+        Storge targetStorge = msgUtil.redis_get(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_STORE + taskNode.getId()) == null ? null : (Storge) msgUtil.redis_get(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_STORE + taskNode.getId());
+
+        ResourceBusiness resourceBusiness = resourceBusinessMapper.selectById(task.getResourceBusinessId());
+        String robotType = callBackJson.getString(YunjianConstant.YUNJIAN_ROBORT_CACHE_FLAG);
+        String robotStepKey = taskNode.getId() + "count";
+        String robotStep = callBackJson.getString(robotStepKey);
+
+        String xbkFlag = callBackJson.getString(YunjianConstant.YUNJIAN_XBKFLAG);
+
+        if(StringUtils.isNotBlank(xbkFlag)){
+
+            if(StringUtils.isBlank(robotStep)){
+                // 放到线边库后释放资源
+                logger.info("节点{}开始释放线边库逻辑占用的资源锁", taskNode.getId());
+                List<Storge> storgeList = storgeService.list(Wraps.<Storge>lbQ().eq(Storge::getCampId, taskNode.getId()));
+                List<String> storgePoints = storgeList.stream().map(p -> p.getPointId()).collect(Collectors.toList());
+                if (CollectionUtil.isNotEmpty(storgeList)) {
+                    logger.info("节点{}开始释放占用的资源{}", taskNode.getId(),storgePoints.toString());
+                    storgeService.unlockStorgeList(storgeList);
+                }
+            }else{
+                // 线边库暂存放到设备上释放资源
+                if(StringUtils.isNotBlank(robotType)){
+                    if("5".equals(robotStep)){
+                        logger.info("节点{}线边库暂存后放到设备完成后释放占用的资源", taskNode.getId());
+                        List<Storge> storgeList = storgeService.list(Wraps.<Storge>lbQ().eq(Storge::getCampId, taskNode.getId()));
+                        List<String> storgePoints = storgeList.stream().map(p -> p.getPointId()).collect(Collectors.toList());
+                        if (CollectionUtil.isNotEmpty(storgeList)) {
+                            logger.info("节点{}开始释放占用的资源{}", taskNode.getId(),storgePoints.toString());
+                            storgeService.unlockStorgeList(storgeList);
+                        }
+                    }
+                }else{
+                    if("1".equals(robotStep)){
+                        logger.info("节点{}线边库暂存后放到设备完成后释放占用的资源", taskNode.getId());
+                        List<Storge> storgeList = storgeService.list(Wraps.<Storge>lbQ().eq(Storge::getCampId, taskNode.getId()));
+                        List<String> storgePoints = storgeList.stream().map(p -> p.getPointId()).collect(Collectors.toList());
+                        if (CollectionUtil.isNotEmpty(storgeList)) {
+                            logger.info("节点{}开始释放占用的资源{}", taskNode.getId(),storgePoints.toString());
+                            storgeService.unlockStorgeList(storgeList);
+                        }
+                    }
+                }
+
+            }
+
+
+        }else{
+            if(StringUtils.isNotBlank(robotType)){
+                // 有缓存位机器人,走到最后一步才释放资源
+                if("1".equals(robotType) && "2".equals(robotStep)){
+                    logger.info("节点{}开始判断需要释放占用的资源锁", taskNode.getId());
+                    List<Storge> storgeList = storgeService.list(Wraps.<Storge>lbQ().eq(Storge::getCampId, taskNode.getId()));
+                    List<String> storgePoints = storgeList.stream().map(p -> p.getPointId()).collect(Collectors.toList());
+                    if (CollectionUtil.isNotEmpty(storgeList)) {
+                        logger.info("节点{}开始释放占用的资源{}", taskNode.getId(),storgePoints.toString());
+                        storgeService.unlockStorgeList(storgeList);
+                    }
+                }
+            }else{
+                //删除当前节点的锁定
+                if(!"打标业务".equals(resourceBusiness.getName())){
+                    logger.info("节点{}开始判断需要释放占用的资源锁", taskNode.getId());
+                    List<Storge> storgeList = storgeService.list(Wraps.<Storge>lbQ().eq(Storge::getCampId, taskNode.getId()));
+                    List<String> storgePoints = storgeList.stream().map(p -> p.getPointId()).collect(Collectors.toList());
+                    if (CollectionUtil.isNotEmpty(storgeList)) {
+                        logger.info("节点{}开始释放占用的资源{}", taskNode.getId(),storgePoints.toString());
+                        storgeService.unlockStorgeList(storgeList);
+                    }
+                }else{
+                    // 只释放非机器人资源
+                    if(null != targetStorge){
+                        List<Storge> storgeList = new ArrayList<>();
+                        storgeList.add(targetStorge);
+                        logger.info("节点{}开始释放打标的资源{}", taskNode.getId(),targetStorge.getPointId().toString());
+                        storgeService.unlockStorgeList(storgeList);
+                    }
+                }
+
+            }
         }
-//        }
+
     }
 
     /**

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

@@ -207,8 +207,11 @@ public class WorkpieceServiceImpl extends SuperServiceImpl<WorkpieceMapper, TWor
         Map existResource = new HashedMap();
         for(TWorkpiece workpiece:list){
             Map<String,String> map = new<String,String> HashMap();
+            List<String> taskStatus = new ArrayList<>();
+            taskStatus.add("1");
+            taskStatus.add("2");
             // 查找工件第一个任务信息及所在设备
-            TTask task = tTaskMapper.selectOne(Wraps.<TTask>lbQ().eq(TTask::getStatus,"1").orderByAsc(TTask::getProcedureSort).last("limit 1"));
+            TTask task = tTaskMapper.selectOne(Wraps.<TTask>lbQ().in(TTask::getStatus,taskStatus).orderByAsc(TTask::getProcedureSort).last("limit 1"));
             if(!existResource.containsKey(task.getResourceId())){
                 existResource.put(task.getResourceId(),task.getResourceId());
                 // 查找设备点位信息,先判断库位信息是否有数据,如果库位信息有数据,直接用库位信息表里面的点位,可能移动到线边库,如果没有直接显示在工序目标设备的点位上

+ 2 - 1
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionResourceCenter/service/ProductionresourcePositionService.java

@@ -72,7 +72,8 @@ public interface ProductionresourcePositionService extends SuperService<Producti
 
     List<ProductionresourcePosition> getFreeProductionresourceAgvPositionByNos(String [] noArr);
 
-    List<ProductionresourcePosition>getFreeProductionresourcePositionByIds(String [] idArr);
+    List<ProductionresourcePosition> getFreeProductionresourcePositionByIds(String [] idArr);
+    List<ProductionresourcePosition> getProductionresourcePositionByIds(String [] idArr);
 
     /**
      * 根据设备编号获取放满位置

+ 7 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionResourceCenter/service/impl/ProductionresourcePositionServiceImpl.java

@@ -312,6 +312,13 @@ public class ProductionresourcePositionServiceImpl extends SuperServiceImpl<Prod
         List<ProductionresourcePosition>list = baseMapper.getPPList(sxlzmap);
         return list;
     }
+    @Override
+    public List<ProductionresourcePosition> getProductionresourcePositionByIds(String[] idArr) {
+        Map sxlzmap = new HashMap();
+        sxlzmap.put("resourceIdStr",StringUtil.changeIdsArrToSubQueryStr(idArr));
+        List<ProductionresourcePosition>list = baseMapper.getPPList(sxlzmap);
+        return list;
+    }
 
     @Override
     public List<ProductionresourcePosition> getFullProductionresourcePositionByNos(String[] noArr) {

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

@@ -3,7 +3,6 @@ package com.github.zuihou.business.productionResourceCenter.service.impl;
 
 import cn.hutool.core.collection.CollectionUtil;
 import com.alibaba.fastjson.JSONObject;
-import com.github.zuihou.base.R;
 import com.github.zuihou.business.DemoLine.DemoCacheKey;
 import com.github.zuihou.business.DemoLine.DemoLineConstant;
 import com.github.zuihou.business.DemoLine.YunjianConstant;
@@ -12,9 +11,8 @@ import com.github.zuihou.business.edgeLibrary.dao.StorgeMapper;
 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.dao.TTaskMapper;
 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;
 import com.github.zuihou.business.operationManagementCenter.service.WorkpieceService;
@@ -27,11 +25,13 @@ import com.github.zuihou.business.productionReadyCenter.entity.BomProcedureTray;
 import com.github.zuihou.business.productionReadyCenter.service.BomProcedureTrayService;
 import com.github.zuihou.business.productionResourceCenter.dao.*;
 import com.github.zuihou.business.productionResourceCenter.entity.*;
-import com.github.zuihou.business.productionResourceCenter.service.*;
+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;
-import com.github.zuihou.common.constant.DictionaryType;
 import com.github.zuihou.common.constant.ParameterKey;
 import com.github.zuihou.common.util.StringUtil;
 import com.github.zuihou.database.mybatis.conditions.Wraps;
@@ -40,7 +40,9 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.*;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
@@ -58,6 +60,10 @@ public class RobotNodeServiceImpl implements NodeOperationService {
 
     @Autowired
     private TaskNodeService taskNodeService;
+    @Autowired
+    private TTaskMapper tTaskMapper;
+    @Autowired
+    private ResourceBusinessMapper resourceBusinessMapper;
 
     @Autowired
     private StorgeService storgeService;
@@ -148,8 +154,22 @@ public class RobotNodeServiceImpl implements NodeOperationService {
         if(StringUtil.isNotEmpty(moduleName)) {
             //List<Module> modules = moduleService.list(new QueryWrapper<Module>().like("name", moduleName));
             if(zoneProductionresource!=null){
-                deviceArr = new String[] {zoneProductionresource.getResourceId().toString()};
-                robotList = productionresourcePositionService.getFreeProductionresourcePositionByIds(deviceArr);
+                TaskNode beforTaskNode = taskNodeService.getNextNTaskNode(taskNode,-1);
+                if(null != beforTaskNode){
+                    TTask beforTask = tTaskMapper.selectById(beforTaskNode.getTaskId());
+                    ResourceBusiness resourceBusiness = resourceBusinessMapper.selectById(beforTask.getResourceBusinessId());
+                    // 打标因为不释放机器人资源,后续工序机器人人节点不判断机器人是否为空
+                    if("打标业务".equals(resourceBusiness.getName())){
+                        deviceArr = new String[] {zoneProductionresource.getResourceId().toString()};
+                        robotList = productionresourcePositionService.getProductionresourcePositionByIds(deviceArr);
+                    }else{
+                        deviceArr = new String[] {zoneProductionresource.getResourceId().toString()};
+                        robotList = productionresourcePositionService.getFreeProductionresourcePositionByIds(deviceArr);
+                    }
+                }else{
+                    deviceArr = new String[] {zoneProductionresource.getResourceId().toString()};
+                    robotList = productionresourcePositionService.getFreeProductionresourcePositionByIds(deviceArr);
+                }
             }
         }
         //jbwArr = modules.stream().map(Module::getNo).toArray(String[]::new);
@@ -339,6 +359,7 @@ public class RobotNodeServiceImpl implements NodeOperationService {
                             dataMap.put("data", locationMap);
                             dataMap.put("method", "MoveRobotPosition");
                             dataMap.put("result", true);
+                            // dataMap.put("bizType", targetxbk);
                             // begin modify by yejian on 20220520 for 解决资源抢占时机器人是空闲状态但是实际上面有料不能操作的时候请求指令接口返回失败后进入死循环问题
                             // TODO 后续可改成信号对接判断,先如果返回失败释放资源进去队列重新轮训
                             // 返回内容中记录当前任务占用资源

+ 2 - 1
imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/statisticalAnalysis/ProductLinePerformanceController.java

@@ -20,6 +20,7 @@ import com.github.zuihou.business.operationManagementCenter.dto.TaskNodeUpdateDT
 import com.github.zuihou.business.operationManagementCenter.entity.TaskNode;
 import com.github.zuihou.business.productionReadyCenter.entity.MToolClamp;
 import com.github.zuihou.business.statisticalAnalysis.ProductLinePerformanceService;
+import com.github.zuihou.common.util.DateUtil;
 import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
 import com.github.zuihou.database.mybatis.conditions.query.QueryWrap;
 import com.github.zuihou.log.annotation.SysLog;
@@ -73,7 +74,7 @@ public class ProductLinePerformanceController extends SuperController<ProductLin
             statisticalBeginDate = com.github.zuihou.common.util.DateUtil.beginMonthTime(SearchDate);
             statisticalEndDate = com.github.zuihou.common.util.DateUtil.endMonthTime(SearchDate);
         }
-        wrapper.between(TaskNode::getStartTime,statisticalBeginDate,statisticalEndDate).between(TaskNode::getEndTime,statisticalBeginDate,statisticalEndDate);
+        wrapper.between(TaskNode::getStartTime,DateUtil.stringToDate7(statisticalBeginDate),DateUtil.stringToDate7(statisticalEndDate)).between(TaskNode::getEndTime,DateUtil.stringToDate7(statisticalBeginDate),DateUtil.stringToDate7(statisticalEndDate));
         page.orders().remove(0);
         baseService.pageList(page, wrapper);
     }

+ 1 - 1
imcs-admin-boot/imcs-common/src/main/java/com/github/zuihou/common/constant/DictionaryKey.java

@@ -16,7 +16,7 @@ public interface DictionaryKey {
     //线边库最大库位数
     final Integer RESOURCE_MAX_NUM = 20;
     //指定接口URL地址
-    final String INSTRUCTION_URL = "http://192.168.170.248:8081/";
+    final String INSTRUCTION_URL = "http://106.15.38.8:8090/";
     //PLC
     String INTERFACETYPE_PLC = "01";
     //生产加工接口

+ 3 - 0
imcs-admin-boot/imcs-common/src/main/java/com/github/zuihou/common/constant/DictionaryType.java

@@ -152,4 +152,7 @@ public class DictionaryType {
     private DictionaryType() {
     }
 
+    public static final String OCCUPY_RESOURCE = "occupyResources";
+
+
 }

+ 1 - 1
imcs-admin-boot/imcs-common/src/main/java/com/github/zuihou/common/util/DateUtil.java

@@ -540,7 +540,7 @@ public class DateUtil {
 		String dt = null;
 		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
 		dt = sdf.format(date);
-		dt = dt + "-"+ cn.hutool.core.date.DateUtil.endOfMonth(new Date()).dayOfMonth() + " 00:00:00";
+		dt = dt + "-"+ cn.hutool.core.date.DateUtil.endOfMonth(new Date()).dayOfMonth() + " 23:59:59";
 		return dt;
 	}