Pārlūkot izejas kodu

后台业务代码调整和更新

oyq28 2 gadi atpakaļ
vecāks
revīzija
9cf3da1a7a

+ 7 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/edgeLibrary/service/StorgeService.java

@@ -9,6 +9,7 @@ import com.github.zuihou.business.edgeLibrary.dto.StorgeUpdateDTO;
 import com.github.zuihou.business.edgeLibrary.entity.Storge;
 import com.github.zuihou.business.edgeLibrary.entity.StorgeType;
 import com.github.zuihou.business.operationManagementCenter.entity.TTask;
+import com.github.zuihou.business.operationManagementCenter.entity.TaskNode;
 import com.github.zuihou.business.productionResourceCenter.entity.Tool;
 import com.github.zuihou.business.productionResourceCenter.entity.ZZone;
 import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
@@ -119,4 +120,10 @@ public interface StorgeService extends SuperCacheService<Storge> {
      */
     boolean isHeightLimit(String completeBatchNo);
 
+    /**
+     * 三坐标取放点位处理
+     * @return
+     */
+    boolean szbStockHandle(boolean isFetched, TaskNode taskNode);
+
 }

+ 74 - 2
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/edgeLibrary/service/impl/StorgeServiceImpl.java

@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.github.zuihou.authority.entity.common.DictionaryItem;
 import com.github.zuihou.base.service.SuperCacheServiceImpl;
@@ -21,6 +22,7 @@ import com.github.zuihou.business.edgeLibrary.service.StockInfoService;
 import com.github.zuihou.business.edgeLibrary.service.StorgeService;
 import com.github.zuihou.business.operationManagementCenter.entity.TTask;
 import com.github.zuihou.business.operationManagementCenter.entity.TWorkpiece;
+import com.github.zuihou.business.operationManagementCenter.entity.TaskNode;
 import com.github.zuihou.business.operationManagementCenter.service.WorkpieceService;
 import com.github.zuihou.business.productionReadyCenter.dao.BomProcedureTrayMapper;
 import com.github.zuihou.business.productionReadyCenter.entity.BomProcedureTray;
@@ -34,6 +36,7 @@ import com.github.zuihou.business.productionResourceCenter.entity.Productionreso
 import com.github.zuihou.business.productionResourceCenter.entity.ProductionresourcePosition;
 import com.github.zuihou.business.productionResourceCenter.entity.ZZone;
 import com.github.zuihou.business.productionResourceCenter.service.ProductionresourcePositionService;
+import com.github.zuihou.business.productionResourceCenter.service.impl.RobotNodeServiceImpl;
 import com.github.zuihou.business.util.MsgUtil;
 import com.github.zuihou.common.constant.BizConstant;
 import com.github.zuihou.common.constant.DictionaryKey;
@@ -46,6 +49,8 @@ import com.github.zuihou.injection.annonation.InjectionResult;
 import com.github.zuihou.utils.BeanPlusUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Service;
@@ -108,6 +113,8 @@ public class StorgeServiceImpl extends SuperCacheServiceImpl<StorgeMapper, Storg
     @Autowired
     private TrayService trayService;
 
+    private static Logger logger = LoggerFactory.getLogger(StorgeServiceImpl.class);
+
     @Override
     protected String getRegion() {
         return TENANT;
@@ -223,9 +230,13 @@ public class StorgeServiceImpl extends SuperCacheServiceImpl<StorgeMapper, Storg
      */
     @Override
     public Storge unlockStorge(Storge storge) {
+        /*
         storge.setCampId(null);
         storge.setLockStatus("1");
-        this.updateById(storge);
+        this.updateById(storge); */
+        LambdaUpdateWrapper<Storge> lambdaUpdateWrapper = new LambdaUpdateWrapper<Storge>();
+        lambdaUpdateWrapper.set(Storge::getLockStatus, "1").set(Storge::getCampId, null).set(Storge::getCompleteBatchNo,"").eq(Storge::getId, storge.getId());
+        baseMapper.update(null,  lambdaUpdateWrapper);
         return storge;
     }
     /**
@@ -235,12 +246,17 @@ public class StorgeServiceImpl extends SuperCacheServiceImpl<StorgeMapper, Storg
      */
     @Override
     public List<Storge> unlockStorgeList(List<Storge> storgeList) {
+        /*
         storgeList.forEach(t->{
             t.setLockStatus("1");
             t.setCampId(null);
             t.setCompleteBatchNo("");
         });
-        this.saveOrUpdateBatch(storgeList);
+        this.saveOrUpdateBatch(storgeList); */
+        List<Long> ids = storgeList.stream().map(Storge::getId).collect(toList());
+        LambdaUpdateWrapper<Storge> lambdaUpdateWrapper = new LambdaUpdateWrapper<Storge>();
+        lambdaUpdateWrapper.set(Storge::getLockStatus, "1").set(Storge::getCampId, null).set(Storge::getCompleteBatchNo,"").in(Storge::getId, ids);
+        baseMapper.update(null,  lambdaUpdateWrapper);
         return storgeList;
     }
 
@@ -586,4 +602,60 @@ public class StorgeServiceImpl extends SuperCacheServiceImpl<StorgeMapper, Storg
         Tray tray = trayService.getById(stockInfo.getGoodsId());
         return tray.getHeightLimit().equals(1) ? true : false;
     }
+
+    /**
+     *
+     * 三坐标取放处理
+     * @param isFetched
+     * @param taskNode
+     * @return
+     */
+    @Override
+    public boolean szbStockHandle(boolean isFetched, TaskNode taskNode){
+        List<Storge> storgeList = baseMapper.selectList(new LbqWrapper<Storge>().in(Storge::getPointId, Arrays.asList(DictionaryKey.ZEISS_LOCATION.get("M"), DictionaryKey.ZEISS_LOCATION.get("L"))));
+        List<StockInfo> mPointList = stockInfoMapper.selectList(new LbqWrapper<StockInfo>().eq(StockInfo::getStorgeId, storgeList.get(0).getId()).eq(StockInfo::getCompleteBatchNo, taskNode.getCompleteBatchNo()));
+        List<StockInfo> lPointList = stockInfoMapper.selectList(new LbqWrapper<StockInfo>().eq(StockInfo::getStorgeId, storgeList.get(1).getId()).eq(StockInfo::getCompleteBatchNo, taskNode.getCompleteBatchNo()));
+
+        JSONObject params = new JSONObject();
+        //三坐标中间位取操作
+        if(isFetched) {
+            String fetchStatus = msgUtil.getCcsData("/api/GetMiddleThreeCoordinates", params, taskNode);
+            JSONObject fetchObject = JSONObject.parseObject(fetchStatus);
+            logger.warn("三坐标节点{}取查询接口返回{}", taskNode.getId(), fetchObject.toJSONString());
+            //判断三坐标是否可取
+            if (null != fetchObject && fetchObject.containsKey("result") && StringUtils.isNotEmpty(fetchObject.getString("result")) && !fetchObject.getString("result").trim().equals("false")) {
+                if (mPointList.size() > 0) return true;
+                // M位可取但无零件工装且L位有零件工装
+                if (lPointList.size() > 0 && mPointList.size() == 0) {
+                    List<Long> ids = lPointList.stream().map(StockInfo::getId).collect(toList());
+                    LambdaUpdateWrapper<StockInfo> lambdaUpdateWrapper = new LambdaUpdateWrapper<StockInfo>();
+                    //虚拟缓存位点位更新成为M点位
+                    lambdaUpdateWrapper.set(StockInfo::getStorgeId, storgeList.get(0).getId()).in(StockInfo::getId, ids);
+                    stockInfoMapper.update(null, lambdaUpdateWrapper);
+                    logger.warn("三坐标节点{}取操作,虚拟缓存位点位更新成为M点位", taskNode.getId());
+                    return true;
+                }
+            }
+        }else{
+            //三坐标中间放操作
+            String sendStatus = msgUtil.getCcsData("/api/QueryThreeCoordinatesFreePos", params, taskNode);
+            JSONObject sendObject = JSONObject.parseObject(sendStatus);
+            logger.warn("三坐标节点{}放查询接口返回{}", taskNode.getId(), sendObject.toJSONString());
+            if (null != sendObject && sendObject.containsKey("result") && StringUtils.isNotEmpty(sendObject.getString("result")) && !sendObject.getString("result").trim().equals("false")) {
+                if (mPointList.size() == 0) return true;
+                // M位可放但有零件工装更新到虚拟L位
+                if (mPointList.size() > 0 && lPointList.size() == 0) {
+                    List<Long> ids = mPointList.stream().map(StockInfo::getId).collect(toList());
+                    LambdaUpdateWrapper<StockInfo> lambdaUpdateWrapper = new LambdaUpdateWrapper<StockInfo>();
+                    //M点位更新为L虚拟点位
+                    lambdaUpdateWrapper.set(StockInfo::getStorgeId, storgeList.get(1).getId()).in(StockInfo::getId, ids);
+                    stockInfoMapper.update(null, lambdaUpdateWrapper);
+                    logger.warn("三坐标节点{}放操作,M点位更新为L虚拟点位", taskNode.getId());
+                    return true;
+                }
+            }
+        }
+        logger.warn("三坐标节点{}取放条件不通过", taskNode.getId());
+        return false;
+    }
 }

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

@@ -428,8 +428,7 @@ public class TaskWorkNode {
                                             ret.put("result","true");
                                             returnData = ret.toJSONString();
                                         }
-                                    } **/
-
+                                    }
                                    if(resourceBusiness.getName().indexOf("三坐标")>-1 && "SendServoStacker".equals(method)){
                                          // 判断三坐标质检或者三坐标偏置量检测 假放节点
                                          specialCallBackMyselfFlag = true;
@@ -439,7 +438,8 @@ public class TaskWorkNode {
                                          JSONObject ret = new JSONObject();
                                          ret.put("result","true");
                                          returnData = ret.toJSONString();
-                                   }else if("打标业务".equals(resourceBusiness.getName()) && "SendServoStacker".equals(method)){
+                                   }else **/
+                                       if("打标业务".equals(resourceBusiness.getName()) && "SendServoStacker".equals(method)){
                                         // 打标业务无需放
                                         specialCallBackMyselfFlag = true;
                                         String jsonParam = getRequestParam(conMap);
@@ -1190,7 +1190,7 @@ public class TaskWorkNode {
 
                         dataMap.put("fromStorge", startStore);
 
-                        Map locationMap = new HashMap();
+                        Map locationMap = returnMap.containsKey("data")? (Map)returnMap.get("data"):new HashMap();
                         locationMap.put("location", startStore.getPointId());
                         dataMap.put("data", locationMap);
                         //出入库类型
@@ -1237,6 +1237,27 @@ public class TaskWorkNode {
                 dataMap.put("fromStorge", startStore);
 
                 Map locationMap = new HashMap();
+
+                BomProcedure procedure = bomProcedureService.getById(task.getProcedureId());
+                if("1".equals(procedure.getThreeDimensionalConf()) || "1".equals(procedure.getThreeDimensionalDeviationConf())) {
+                    locationMap.put("workId", taskNode.getCompleteBatchNo());
+                    locationMap.put("procedureNo", task.getProcedureNo());
+                    if("1".equals(procedure.getThreeDimensionalConf())){
+                        locationMap.put("workProgramName", procedure.getThreeDimensionalPrograme());
+                    }else if("1".equals(procedure.getThreeDimensionalDeviationConf())){
+                        locationMap.put("workProgramName", procedure.getThreeDimensionalDeviationPrograme());
+                    }
+                    //三坐标放虚拟点位处理
+                    boolean bool = storgeService.szbStockHandle(false, taskNode);
+                    //三坐标条件不满足
+                    if(!bool && (targetStorge.getPointId().equals("373") || targetStorge.getPointId().equals("372"))){
+                        logger.warn("三坐标节点{}线边库放操作执行条件不满足", taskNode.getId());
+                        dataMap.put("result", false);
+                        return dataMap;
+                    }
+                    locationMap.put("stationId", "M");
+                }
+
                 locationMap.put("location", targetStorge.getPointId());
                 dataMap.put("data", locationMap);
                 dataMap.put(DemoLineConstant.DEMOLINE_STOCK_TYPE, DemoLineConstant.DEMOLINE_STOCK_TYPE_ALL_CRK);
@@ -1405,6 +1426,7 @@ public class TaskWorkNode {
                             // 判断是工件坐标系还是质量测量
                             if("1".equals(procedure.getThreeDimensionalConf()) || "1".equals(procedure.getThreeDimensionalDeviationConf())){
                                 // 质量检测
+                                /*
                                 // 查询三坐标滑台是否可用,通过接口查询
                                 //组装接口参数
                                 HttpHeaders headers = new HttpHeaders();
@@ -1424,13 +1446,15 @@ public class TaskWorkNode {
                                 String instructionUrl = (null == msgUtil.redis_get(ParameterKey.PARAMETERS)? "": ((Map<String,String>)msgUtil.redis_get(ParameterKey.PARAMETERS)).get(paramKey).toString());
                                 String requestUrl = instructionUrl + "/api/" + "QueryThreeCoordinatesFreePos";
                                 String canPutInfo = restTemplate.postForObject(requestUrl, formEntity, String.class);
-                                logger.error("三坐标允许放{}", canPutInfo);
-                                JSONObject canPutInfoObject = JSONObject.parseObject(canPutInfo);
-                                if("false".equals(canPutInfoObject.getString("result"))){
+                                logger.warn("三坐标允许放{}", requestUrl);
+                                logger.warn("三坐标允许放{}", jsonObject.toJSONString());
+                                logger.warn("三坐标允许放{}", canPutInfo);
+                                JSONObject canPutInfoObject = JSONObject.parseObject(canPutInfo); */
+                                boolean bool = storgeService.szbStockHandle(false, taskNode);
+                                if(!bool){
                                     targetList = null;
                                 }else{
-                                    String putLocation = canPutInfoObject.getString("result");
-                                    String putPoint = DictionaryKey.ZEISS_LOCATION.get(putLocation);
+                                    String putPoint = DictionaryKey.ZEISS_LOCATION.get("M");
                                     targetList = productionresourcePositionService.list(Wraps.<ProductionresourcePosition>lbQ().eq(ProductionresourcePosition::getResourceId, taskNode.getTargetResourceId()).eq(ProductionresourcePosition::getPointId,putPoint));
                                 }
                             }else{

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

@@ -1415,7 +1415,7 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
      */
     @Override
     public R taskNodeCallback(TaskNodeCallBackDTO bean) {
-        log.info("[CCS指令回调]回调参数======================" + JSONObject.toJSONString(bean));
+        log.warn("[CCS指令回调]回调参数======================" + JSONObject.toJSONString(bean));
 
         BaseContextHandler.setTenant("0000");
         String taskId = bean.getTaskId() == null ? "" : bean.getTaskId().toString();
@@ -1529,7 +1529,7 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
         //回调的参数
         JSONObject callBackJson = JSONObject.parseObject(bizCallBackData);
 
-        logger.info("节点:{}回调:{}", taskNode.getId(), callBackJson);
+        logger.warn("节点:{}回调:{}", taskNode.getId(), callBackJson);
 
         //获取当前自动化节点的顺序
         int n = taskNode.getCompleteBatchSort() - 1;
@@ -1931,7 +1931,9 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
         String targetStorgeId = "";
         String stationId = callBackJson.getString("stationId");
         if (StringUtils.isNotBlank(stationId)) {
-            String getPoint = DictionaryKey.ZEISS_LOCATION.get(stationId);
+            //三坐标检测位与虚拟位切换
+            int count = storgeService.count(new LbqWrapper<Storge>().eq(Storge::getPointId, DictionaryKey.ZEISS_LOCATION.get("L")));
+            String getPoint = (count == 0)? DictionaryKey.ZEISS_LOCATION.get("L"): DictionaryKey.ZEISS_LOCATION.get("M");
             ProductionresourcePosition productionresourcePosition =
                     productionresourcePositionService.getOne(Wraps.<ProductionresourcePosition>lbQ().eq(ProductionresourcePosition::getResourceId, taskNode.getTargetResourceId()).eq(ProductionresourcePosition::getPointId, getPoint));
             targetStorgeId = String.valueOf(productionresourcePosition.getStorgeId());

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

@@ -373,7 +373,8 @@ public class MachineNodeServiceImpl implements NodeOperationService {
                     // 判断是工件坐标系还是质量测量
                     if("1".equals(procedure.getThreeDimensionalConf())){
                         /*data.put("workId", task.getCompleteBatchNo() + "-" + task.getProcedureNo());*/
-                        data.put("workId", task.getCompleteBatchNo() + "_" + taskNode.getId());
+                        //data.put("workId", task.getCompleteBatchNo() + "_" + taskNode.getId());
+                        data.put("workId", taskNode.getCompleteBatchNo());
                         data.put("procedureNo",task.getProcedureNo());
                         /*data.put("workType", procedure.getThreeDimensionalPrograme());*/
                         data.put("workProgramName", procedure.getThreeDimensionalPrograme());

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

@@ -4,6 +4,7 @@ package com.github.zuihou.business.productionResourceCenter.service.impl;
 import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.util.IdUtil;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.github.zuihou.authority.entity.auth.RoleOrg;
 import com.github.zuihou.authority.entity.common.DictionaryItem;
 import com.github.zuihou.authority.entity.core.Org;
@@ -19,6 +20,7 @@ import com.github.zuihou.business.edgeLibrary.entity.Storge;
 import com.github.zuihou.business.edgeLibrary.service.StorgeService;
 import com.github.zuihou.business.externalApi.service.AgvHikOrderInfoService;
 import com.github.zuihou.business.externalApi.service.ExternalApiService;
+import com.github.zuihou.business.mq.TaskWorkNode;
 import com.github.zuihou.business.operationManagementCenter.dao.PlanMapper;
 import com.github.zuihou.business.operationManagementCenter.dao.PlanProductMapper;
 import com.github.zuihou.business.operationManagementCenter.dao.TTaskMapper;
@@ -51,7 +53,10 @@ import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
 import com.github.zuihou.database.mybatis.conditions.query.QueryWrap;
 import com.google.common.collect.Maps;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.compress.utils.Lists;
 import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpEntity;
 import org.springframework.http.HttpHeaders;
@@ -164,7 +169,7 @@ public class RobotNodeServiceImpl implements NodeOperationService {
 
     private List<ProductionresourcePosition> jbwList;
 
-
+    private static Logger logger = LoggerFactory.getLogger(RobotNodeServiceImpl.class);
 
     private Long zoneId;
 
@@ -559,7 +564,7 @@ public class RobotNodeServiceImpl implements NodeOperationService {
                 ProductionresourcePosition po = logical(robotList,flikustockInfos,taskNode);
                 log.info("节点{}检查机器人资源条件返回{}",taskNode.getId(),po);
                 if (po!=null) {
-                    List<TTask> highLevelTaskNode = new ArrayList<>();
+                    /* List<TTask> highLevelTaskNode = new ArrayList<>();
                     if(taskNode.getCompleteBatchSort() == 1){
                         List<TaskNode> sameMachineTaskNodes = taskNodeService.list(Wraps.<TaskNode>lbQ().eq(TaskNode::getExeStatus,"2").ne(TaskNode::getId,taskNode.getId()).eq(TaskNode::getResourceId,taskNode.getResourceId()));
                         if(sameMachineTaskNodes.size() > 0){
@@ -567,46 +572,59 @@ public class RobotNodeServiceImpl implements NodeOperationService {
                             //highLevelTaskNode = tTaskMapper.selectList(Wraps.<TTask>lbQ().lt(TTask::getExpectStartTime,task.getExpectStartTime()).in(TTask::getId,taskIds));
                         }
                     }
-                    log.info("节点{}查找是否有高于自己优先级的任务集合{}",taskNode.getId(), highLevelTaskNode.size());
-                    if(highLevelTaskNode.size() > 0){
+                    log.info("节点{}查找是否有高于自己优先级的任务集合{}",taskNode.getId(), highLevelTaskNode.size());  */
+                    //三坐标完成取
+                    TaskNode beforeTaskNode = taskNodeService.getNextNTaskNode(taskNode, -1);
+                    boolean isSzbFetch = beforeTaskNode != null && ("3".equals(beforeTaskNode.getNodeType()) || "5".equals(beforeTaskNode.getNodeType()));
+                    if (isSzbFetch) {
+                        String resultData = msgUtil.getCcsData("/api/GetMiddleWorkIdThreeCoordinates", new JSONObject(), taskNode);
+                        JSONObject jsonObject = JSONObject.parseObject(resultData);
+                        if (null != jsonObject && jsonObject.containsKey("result") && StringUtils.isNotEmpty(jsonObject.getString("result")) && jsonObject.getString("result").trim().equals(taskNode.getCompleteBatchNo())) {
+                            boolean bool = storgeService.szbStockHandle(true, taskNode);
+                            if(!bool){
+                                dataMap.put("result", false);
+                            }
+                        } else {
+                            dataMap.put("result", false);
+                        }
+                    }
 
-                        dataMap.put("result", false);
-                    }else{
-                        Map returnMap = null;
+                    if(!dataMap.containsKey("result")) {
                         //String bizType = dataMap.get("bizType")==null?"":dataMap.get("bizType").toString();
                         //if("4".equals(taskNode.getNodeType()) && !StringUtils.contains(taskNode.getNodeName(), "翻面")){
                         //    returnMap = getFanmianTargetStorge(taskNode,dataMap);
                         //}else {
-                            returnMap = getTargetStorge(nextTaskNode,taskNode.getFindAgvFlag(),bomProcedure.getType());
+                        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");
-                        log.info("节点{}检查目标库位是否满足返回{}",taskNode.getId(),targetStorge.getPointId());
+                        Storge targetStorge = returnMap.get("store") == null ? null : (Storge) returnMap.get("store");
+                        String targetxbk = returnMap.get("targetxbk") == null ? null : (String) returnMap.get("targetxbk");
+                        log.info("节点{}检查目标库位是否满足返回{}", taskNode.getId(), targetStorge.getPointId());
 
                         // 立库取子盘到人工上下料站资源不可用时不能进入线边库
-                        if(taskNode.getCompleteBatchSort()==1 && "1".equals(targetxbk)){
+                        if (taskNode.getCompleteBatchSort() == 1 && "1".equals(targetxbk)) {
                             dataMap.put("result", false);
-                        }else{
-                            if(null != targetStorge){
+                        } else {
+                            if (null != targetStorge) {
+                                //判断当前节点是否三坐标取操作
+                                Map locationMap = new HashMap();
                                 jqrStorge = storgeService.getById(robotList.get(0).getStorgeId());
 
                                 dataMap.put("fromStorge", startStore);
 
-                                Map locationMap = new HashMap();
-                                locationMap.put("location",startStore.getPointId());
+                                locationMap.put("location", startStore.getPointId());
                                 dataMap.put("data", locationMap);
                                 // TODO 有问题,需要区分是否是第一步上料
                                 //出入库类型
-                                if(taskNode.getCompleteBatchSort()==1){//TODO 条件后续再丰富
+                                if (taskNode.getCompleteBatchSort() == 1) {//TODO 条件后续再丰富
                                     dataMap.put(DemoLineConstant.DEMOLINE_STOCK_TYPE, DemoLineConstant.DEMOLINE_STOCK_TYPE_TRAY_CRK);
-                                }else if(returnMap.containsKey(DemoLineConstant.DEMOLINE_STOCK_TYPE)){
+                                } else if (returnMap.containsKey(DemoLineConstant.DEMOLINE_STOCK_TYPE)) {
                                     dataMap.put(DemoLineConstant.DEMOLINE_STOCK_TYPE, returnMap.get(DemoLineConstant.DEMOLINE_STOCK_TYPE));
-                                }else {
+                                } else {
                                     dataMap.put(DemoLineConstant.DEMOLINE_STOCK_TYPE, DemoLineConstant.DEMOLINE_STOCK_TYPE_ALL_CRK);
                                 }
-                                if(returnMap.containsKey("isReload")){
+                                if (returnMap.containsKey("isReload")) {
                                     dataMap.put("isReload", returnMap.get("isReload").toString());
                                 }
 
@@ -633,12 +651,12 @@ public class RobotNodeServiceImpl implements NodeOperationService {
                                 msgUtil.redis_set(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_XBK_FLAG + nextTaskNode.getId(), targetxbk, 1, TimeUnit.DAYS);
 
                                 dataMap.put("result", true);
-                            }else{
+                            } else {
                                 dataMap.put("result", false);
                             }
                         }
                     }
-                }else{
+                }else {
                     dataMap.put("result", false);
                 }
             }
@@ -675,18 +693,19 @@ public class RobotNodeServiceImpl implements NodeOperationService {
                         log.info("节点{}当前机器人所在位子{}",taskNode.getId(),jrqHcwPartPoint);
 
                         for(Storge jqrHcwStorge : jrqHcwStorges){
-                            long jqrHcwStorgeTaskNodeId = jqrHcwStorge.getCampId();
+                            Long jqrHcwStorgeTaskNodeId = jqrHcwStorge.getCampId();
+                            if(null==jqrHcwStorgeTaskNodeId) break;
                             TaskNode jqrHcwStorgeTaskNode = taskNodeService.getById(jqrHcwStorgeTaskNodeId);
                             //当前节点零件和缓存位上的零件不相同
                             if(!jqrHcwStorgeTaskNode.getCompleteBatchNo().equals(taskNode.getCompleteBatchNo())){
                                 //缓存位目标设备的点位
                                 ProductionresourcePosition jqrHcwStorgeTaskNodeResource = productionresourcePositionMapper.selectOne(Wraps.<ProductionresourcePosition>lbQ().eq(ProductionresourcePosition::getResourceId,jqrHcwStorgeTaskNode.getTargetResourceId()));
-                                log.info("jqrHcwStorgeTaskNode.getCompleteBatchNo()={}",jqrHcwStorgeTaskNode.getCompleteBatchNo());
-                                log.info("taskNode.getCompleteBatchNo()={}",taskNode.getCompleteBatchNo());
+                                log.warn("jqrHcwStorgeTaskNode.getCompleteBatchNo()={}",jqrHcwStorgeTaskNode.getCompleteBatchNo());
+                                log.warn("taskNode.getCompleteBatchNo()={}",taskNode.getCompleteBatchNo());
 
                                 // 查询缓存位工件目标地址是否是机器人当前位子
-                                log.info("jqrHcwStorgeTaskNodeResource.getPointId()={}",jqrHcwStorgeTaskNodeResource.getPointId());
-                                log.info("jrqHcwPartPoint={}",jrqHcwPartPoint);
+                                log.warn("jqrHcwStorgeTaskNodeResource.getPointId()={}",jqrHcwStorgeTaskNodeResource.getPointId());
+                                log.warn("jrqHcwPartPoint={}",jrqHcwPartPoint);
                                 if(jqrHcwStorgeTaskNodeResource.getPointId().equals(jrqHcwPartPoint)){
                                     hasJqrhcwPartFlag = true;
                                     msgUtil.redis_set(DemoLineConstant.JQR_HCW_PART_PRIOTY_EXEC_FLAG + jqrHcwStorgeTaskNodeId,"1");
@@ -711,7 +730,7 @@ public class RobotNodeServiceImpl implements NodeOperationService {
                                 // 机器人移动到redis记录实时位子
                                 msgUtil.redis_set(taskNode.getResourceId()+"postion",targetStorge.getPointId());
                             }else{
-                                log.info("节点{}并发抢占框体机器人移动条件不满足", taskNode.getId());
+                                log.warn("节点{}并发抢占框体机器人移动条件不满足", taskNode.getId());
                                 dataMap.put("result", false);
                             }
                         }
@@ -777,7 +796,6 @@ public class RobotNodeServiceImpl implements NodeOperationService {
                         if ("1".equals(procedure.getThreeDimensionalConf()) || "1".equals(procedure.getThreeDimensionalDeviationConf())) {
                             // 质量检测
 //                            dataMap.put("method", "SendThreeCoordinates");
-                            dataMap.put("method", "SendServoStacker");
                             locationMap.put("workId", taskNode.getCompleteBatchNo());
                             locationMap.put("procedureNo", task.getProcedureNo());
                             if("1".equals(procedure.getThreeDimensionalConf())){
@@ -785,17 +803,23 @@ public class RobotNodeServiceImpl implements NodeOperationService {
                             }else if("1".equals(procedure.getThreeDimensionalDeviationConf())){
                                 locationMap.put("workProgramName", procedure.getThreeDimensionalDeviationPrograme());
                             }
-                            locationMap.put("stationId", DictionaryKey.ZEISS_LOCATION.entrySet().stream().collect(Collectors.toMap(entity-> entity.getValue(),entity-> entity.getKey())).get(targetStorge.getPointId()));
-                        } else {
-                            dataMap.put("method", "SendServoStacker");
+                            //三坐标放虚拟点位处理
+                            boolean bool = storgeService.szbStockHandle(false, taskNode);
+                            //三坐标条件不满足
+                            if(!bool && (targetStorge.getPointId().equals("373") || targetStorge.getPointId().equals("372"))){
+                                log.warn("三坐标节点{}放操作执行条件不满足", taskNode.getId());
+                                dataMap.put("result", false);
+                                return dataMap;
+                            }
+                            locationMap.put("stationId", "M");
                         }
+                            dataMap.put("method", "SendServoStacker");
                     }
                 }
 
                 dataMap.put("toStorge", targetStorge);
                 dataMap.put("fromStorge", currentStore);
 
-
                 locationMap.put("location",targetStorge.getPointId());
                 dataMap.put("data", locationMap);
 
@@ -1121,6 +1145,7 @@ public class RobotNodeServiceImpl implements NodeOperationService {
                         if("1".equals(procedure.getThreeDimensionalConf()) || "1".equals(procedure.getThreeDimensionalDeviationConf())){
                             // 质量检测
                             // 查询三坐标滑台是否可用,通过接口查询
+                            /*
                             //组装接口参数
                             HttpHeaders headers = new HttpHeaders();
                             headers.setContentType(MediaType.parseMediaType("application/json;charset=UTF-8"));
@@ -1138,13 +1163,14 @@ public class RobotNodeServiceImpl implements NodeOperationService {
                             String requestUrl = instructionUrl + "/api/" + "QueryThreeCoordinatesFreePos";
                             // TODO 先写死测试
                             String canPutInfo = restTemplate.postForObject(requestUrl, formEntity, String.class);
-                            /*String canPutInfo ="{\"result\":\"L\"}";*/
+                            String canPutInfo ="{\"result\":\"L\"}";
                             JSONObject canPutInfoObject = JSONObject.parseObject(canPutInfo);
-                            if("false".equals(canPutInfoObject.getString("result"))){
+                             */
+                            boolean bool = storgeService.szbStockHandle(false, taskNode);
+                            if(!bool){
                                 targetList = null;
                             }else{
-                                String putLocation = canPutInfoObject.getString("result");
-                                String putPoint = DictionaryKey.ZEISS_LOCATION.get(putLocation);
+                                String putPoint = DictionaryKey.ZEISS_LOCATION.get("M");
                                 targetList = productionresourcePositionService.list(Wraps.<ProductionresourcePosition>lbQ().eq(ProductionresourcePosition::getResourceId, taskNode.getTargetResourceId()).eq(ProductionresourcePosition::getPointId,putPoint));
                             }
                         }else{

+ 49 - 51
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/util/MsgUtil.java

@@ -29,6 +29,7 @@ import com.github.zuihou.common.constant.ParameterKey;
 import com.github.zuihou.common.util.DateUtil;
 import com.github.zuihou.common.util.SmbShareFileUtil;
 import com.github.zuihou.database.mybatis.conditions.Wraps;
+import com.github.zuihou.exception.BizException;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.usermodel.Cell;
@@ -183,33 +184,13 @@ public class MsgUtil implements ApplicationContextAware {
                 //如果是三坐标检测
                 if("3".equals(taskNode.getNodeType())){
                     // TODO 后续改成动态拼接
-                    //组装接口参数
-                    ZZoneProductionresource zoneProductionresource = zZoneProductionresourceMapper.selectOne(Wraps.<ZZoneProductionresource>lbQ().eq(ZZoneProductionresource::getResourceId,taskNode.getResourceId()));
-                    long zoneId = zoneProductionresource.getZoneId();
-                    ZZone zZone = zoneService.getById(zoneId);
-                    Map<String, String> plcInfo = DictionaryKey.PLC_CATEGORY.get(zZone.getNo());
-
-                    HttpHeaders headers = new HttpHeaders();
-                    headers.setContentType(MediaType.parseMediaType("application/json;charset=UTF-8"));
                     JSONObject jsonParam = new JSONObject();
-                    jsonParam.put("tagname","DB200.38");
-                    jsonParam.put("ip",plcInfo.get("url"));
-                    HttpEntity<String> formEntity = new HttpEntity<String>(jsonParam.toJSONString(), headers);
-
-                    //动态调用接口和新增指令执行时间
-                    plcInfo = DictionaryKey.PLC_CATEGORY.get(zZone.getNo());
-                    String paramKey = zZone.getNo() + "_plc";
-                    String plcUrl = (null == msgUtil.redis_get(ParameterKey.PARAMETERS)? "": ((Map<String,String>)msgUtil.redis_get(ParameterKey.PARAMETERS)).get(paramKey).toString());
-                    // TODO 改成虚拟端口,后续删除
-                    plcUrl = plcUrl.replace("8081","8083");
-
-
-                    String instructionUrl = plcUrl + "/api/GetTagValue";
-                    System.out.println("instructionUrl=" + instructionUrl);
-                    System.out.println("jsonParam=" + jsonParam);
-                    String returnData = restTemplate.postForObject(instructionUrl, formEntity, String.class);
+                    jsonParam.put("tagname","DB200.20");
+                    String instructionUrl = "/api/GetTagValue";
+                    String returnData = this.getCcsData(instructionUrl, jsonParam, taskNode);
+
                     //报告检测结果
-                    int measuringResult = (returnData=="1")? 0 : 1;
+                    int measuringResult = (returnData.trim().equals("1"))? 0 : 1;
                     String measuringResultFile = filePath + taskNode.getCompleteBatchNo() + "_" + task.getProcedureNo() + ".csv";
                     List<String> fileContents = new ArrayList<>();
                     OrderQuality orderQuality = new OrderQuality();
@@ -304,41 +285,22 @@ public class MsgUtil implements ApplicationContextAware {
                 if("3".equals(taskNode.getNodeType())){
                     // TODO 后续改成动态拼接
                     //组装接口参数
-                    ZZoneProductionresource zoneProductionresource = zZoneProductionresourceMapper.selectOne(Wraps.<ZZoneProductionresource>lbQ().eq(ZZoneProductionresource::getResourceId,taskNode.getResourceId()));
-                    long zoneId = zoneProductionresource.getZoneId();
-                    ZZone zZone = zoneService.getById(zoneId);
-                    Map<String, String> plcInfo = DictionaryKey.PLC_CATEGORY.get(zZone.getNo());
-
-                    HttpHeaders headers = new HttpHeaders();
-                    headers.setContentType(MediaType.parseMediaType("application/json;charset=UTF-8"));
                     JSONObject jsonParam = new JSONObject();
-                    jsonParam.put("tagname","DB200.38");
-                    jsonParam.put("ip",plcInfo.get("url"));
-                    HttpEntity<String> formEntity = new HttpEntity<String>(jsonParam.toJSONString(), headers);
-
-                    //动态调用接口和新增指令执行时间
-                    plcInfo = DictionaryKey.PLC_CATEGORY.get(zZone.getNo());
-                    String paramKey = zZone.getNo() + "_plc";
-                    String plcUrl = (null == msgUtil.redis_get(ParameterKey.PARAMETERS)? "": ((Map<String,String>)msgUtil.redis_get(ParameterKey.PARAMETERS)).get(paramKey).toString());
-                    // TODO 改成虚拟端口,后续删除
-                    plcUrl = plcUrl.replace("8081","8083");
-
-                    String instructionUrl = plcUrl + "/api/GetTagValue";
-                    System.out.println("instructionUrl=" + instructionUrl);
-                    System.out.println("jsonParam=" + jsonParam);
-                    String returnData = restTemplate.postForObject(instructionUrl, formEntity, String.class);
+                    jsonParam.put("tagname","DB200.20");
+                    String instructionUrl = "/api/GetTagValue";
+                    String returnData = this.getCcsData(instructionUrl, jsonParam, taskNode);
                     //获取检测结果
-                    int measuringResult = returnData=="1" ? 0 : 1;
-                    //_pdfFileGraphic
+                    int measuringResult = returnData.trim().equals("1") ? 0 : 1;
                     //String measuringResultFile = filePath + bomProcedure.getThreeDimensionalPrograme() + "_" + taskNode.getProcedureNo() + "_" + task.getCompleteBatchNo() + "_" + taskNode.getId() +".pdf";
                     String date = DateUtil.dateToString0(new Date(), "yyyy-M-dd");
                     String measuringResultFile = SmbShareFileUtil.findNewMeasuringFiles(fileIp,userName,password,filePath + date + "/");
                     //List<String> fileContents = new ArrayList<>();
+                    logger.warn("获取检测结果文件路径{}", measuringResultFile);
                     OrderQuality orderQuality = new OrderQuality();
                     TTaskTestUnqualifiedBom taskTestUnqualifiedBom =  new TTaskTestUnqualifiedBom();
 
                     TWorkpiece workpiece = workpieceMapper.selectOne(Wraps.<TWorkpiece>lbQ().eq(TWorkpiece::getCompleteBatchNo,task.getCompleteBatchNo()));
-                    logger.info("三坐标测量结果{}", measuringResult);
+                    logger.warn("三坐标测量结果{}", measuringResult);
                     if(measuringResult == 0){
                         //fileContents.add("OK");
                         orderQuality.setOkFlag("OK");
@@ -368,7 +330,7 @@ public class MsgUtil implements ApplicationContextAware {
 
 
                     if(1 == measuringResult){
-                        logger.info("三坐标测量失败直接下料");
+                        logger.warn("三坐标测量失败直接下料");
 
                         // 清楚当前节点工序的redis暂存值
                         List<TaskNode> operationTaskNodes = taskNodeService.list(Wraps.<TaskNode>lbQ().eq(TaskNode::getTaskId, taskNode.getTaskId()));
@@ -617,6 +579,42 @@ public class MsgUtil implements ApplicationContextAware {
         dynamicRabbitMq.sendMsg(taskNode.getResourceId().toString(),jsonObject.toString());
     }
 
+    /**
+     * CCS数据接口调用
+     *
+     * @param instructionUrl
+     * @return
+     */
+    public String getCcsData(String instructionUrl, JSONObject jsonParam, TaskNode taskNode){
+
+        ZZoneProductionresource zoneProductionresource = zZoneProductionresourceMapper.selectOne(Wraps.<ZZoneProductionresource>lbQ().eq(ZZoneProductionresource::getResourceId,taskNode.getResourceId()));
+        long zoneId = zoneProductionresource.getZoneId();
+        ZZone zZone = zoneService.getById(zoneId);
+        Map<String, String> plcInfo = DictionaryKey.PLC_CATEGORY.get(zZone.getNo());
+        jsonParam.put("url", plcInfo.get("url"));
+        jsonParam.put("ip", plcInfo.get("url"));
+        jsonParam.put("port", jsonParam.containsKey("port")? jsonParam.get("port").toString(): plcInfo.get("port"));
+
+        //动态调用接口和新增指令执行时间
+        String paramKey = zZone.getNo() + "_plc";
+        String plcUrl = (null == msgUtil.redis_get(ParameterKey.PARAMETERS)? "": ((Map<String,String>)msgUtil.redis_get(ParameterKey.PARAMETERS)).get(paramKey).toString());
+        instructionUrl = plcUrl + instructionUrl;
+
+        HttpHeaders headers = new HttpHeaders();
+        headers.setContentType(MediaType.parseMediaType("application/json;charset=UTF-8"));
+        HttpEntity<String> formEntity = new HttpEntity<String>(jsonParam.toJSONString(), headers);
+        logger.warn("调用CCS接口地址{}", instructionUrl);
+        logger.warn("调用CCS接口传参{}", jsonParam.toJSONString());
+        String returnData = null;
+        try{
+            returnData = restTemplate.postForObject(instructionUrl, formEntity, String.class);
+        }
+        catch(BizException ex){
+            logger.error("接口{}数据远程调用失败", instructionUrl);
+        }
+        return returnData;
+    }
+
     public void pushDetailTask(TTask task) {
         Map<String, Object> rmap = new HashMap<>();
         rmap.put("id", task.getResourceId());