Эх сурвалжийг харах

Merge remote-tracking branch 'origin/master' into master

laoyao 3 жил өмнө
parent
commit
4e95b48c0a
11 өөрчлөгдсөн 215 нэмэгдсэн , 296 устгасан
  1. 0 28
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/externalApi/service/ManualTaskInfoService.java
  2. 0 103
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/externalApi/service/impl/ManualTaskInfoServiceImpl.java
  3. 2 2
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/operationManagementCenter/service/TaskNodeService.java
  4. 2 0
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/operationManagementCenter/service/WorkpieceService.java
  5. 17 11
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/operationManagementCenter/service/impl/TaskNodeServiceImpl.java
  6. 160 71
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/operationManagementCenter/service/impl/WorkpieceServiceImpl.java
  7. 2 2
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/util/ManualTaskOperatorUtil.java
  8. 1 3
      imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/productionResourceCenter/ProductionresourcePositionMapper.xml
  9. 0 70
      imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/externalApi/ManualControl.java
  10. 2 2
      imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/operationManagementCenter/TaskNodeController.java
  11. 29 4
      imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/operationManagementCenter/WorkpieceController.java

+ 0 - 28
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/externalApi/service/ManualTaskInfoService.java

@@ -1,28 +0,0 @@
-package com.github.zuihou.business.externalApi.service;
-
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.github.zuihou.base.R;
-import com.github.zuihou.base.service.SuperCacheService;
-import com.github.zuihou.business.externalApi.dto.ManualInfo;
-import com.github.zuihou.business.externalApi.entity.AgvOrderInfo;
-import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
-
-/**
- * <p>
- * 业务接口
- * 手动模式任务
- * </p>
- *
- * @author imcs
- * @date 2022-02-21
- */
-public interface ManualTaskInfoService {
-    /**
-     * 执行手动任务
-     * @param manualInfo
-     * @return
-     */
-    R executeManualTask(ManualInfo manualInfo) throws Exception;
-
-
-}

+ 0 - 103
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/externalApi/service/impl/ManualTaskInfoServiceImpl.java

@@ -1,103 +0,0 @@
-package com.github.zuihou.business.externalApi.service.impl;
-
-import com.alibaba.fastjson.JSONObject;
-import com.github.zuihou.base.R;
-import com.github.zuihou.business.externalApi.dto.ManualInfo;
-import com.github.zuihou.business.externalApi.service.ManualTaskInfoService;
-import com.github.zuihou.business.util.ManualTaskOperatorUtil;
-import com.github.zuihou.business.util.MsgUtil;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.MediaType;
-import org.springframework.stereotype.Service;
-import org.springframework.web.client.RestTemplate;
-
-import java.util.*;
-
-/**
- * <p>
- * 业务实现类
- * 手动模式任务管理
- * </p>
- *
- * @author imcs
- * @date 2022-02-21
- */
-@Slf4j
-@Service
-public class ManualTaskInfoServiceImpl implements ManualTaskInfoService {
-
-    @Autowired
-    private RestTemplate restTemplate;
-    @Autowired
-    private MsgUtil msgUtil;
-
-    private static LinkedList<String> robotTaskNodes = new LinkedList<>();
-    static {
-        robotTaskNodes.add("move");
-        robotTaskNodes.add("get");
-        robotTaskNodes.add("put");
-        robotTaskNodes.add("move");
-        robotTaskNodes.add("get");
-        robotTaskNodes.add("put");
-    }
-    private static LinkedList<String> robotNoMoveTaskNodes = new LinkedList<String>();
-    static {
-        robotNoMoveTaskNodes.add("get");
-        robotNoMoveTaskNodes.add("put");
-    }
-
-    @Override
-    public R executeManualTask(ManualInfo manualInfo) throws Exception {
-
-        // 查找当前任务所属产线,并且找出产线所需运输设备的点位及占用状态
-        String unit = manualInfo.getDeviceUnit();
-        if("capsule".equals(unit)){
-            // 舱体(智能单元)
-        }else if("framework".equals(unit)){
-            // 框体(柔性线)
-        }else if("safeguard".equals(unit)){
-            // 保障平台(质量中心)
-        }
-
-        Map<String,Object> processInfo =  ManualTaskOperatorUtil.judgeFirstProcessInfo(robotTaskNodes, robotNoMoveTaskNodes,manualInfo);
-        JSONObject returnDataObject = new JSONObject();
-
-        // 组装参数
-        String returnData = "";
-        //组装接口参数
-        HttpHeaders headers = new HttpHeaders();
-        headers.setContentType(MediaType.parseMediaType("application/json;charset=UTF-8"));
-
-        //回调参数构建
-        String jsonParam = ManualTaskOperatorUtil.getRequestParam(processInfo.get("location").toString(),manualInfo,processInfo.get("deviceUrl").toString(),processInfo.get("devicePort").toString());
-
-        HttpEntity<String> formEntity = new HttpEntity<String>(jsonParam, headers);
-        //调用接口
-        try {
-            returnData = restTemplate.postForObject(processInfo.get("hostSyetemTaskUrl").toString(), formEntity, String.class);
-            returnDataObject = JSONObject.parseObject(returnData);
-            log.error("调用上位机执行指令返回" + returnData);
-            if("true".equals(returnDataObject.get("result"))){
-                // 放入redis,方便回调的时候判断是否是最后一个结点,如果是最后一个结点不在做任何逻辑,更新相应的库位信息
-                Map<String, Object> currentTask = new HashMap<String, Object>();
-                List<String> taskNodes = (List<String>) processInfo.get("taskNodes");
-                currentTask.put("taskNodes",taskNodes);
-                currentTask.put("taskInfo",manualInfo);
-                JSONObject redisTask = new JSONObject();
-                redisTask.putAll(currentTask);
-                msgUtil.redis_set(manualInfo.getManualId(),redisTask.toJSONString());
-            }else{
-                return R.fail(returnDataObject.getString("msg"));
-            }
-        }catch (Exception e) {
-            e.printStackTrace();
-            log.error("调用接口发生异常" + e.getMessage());
-            return R.fail(returnDataObject.getString("msg"));
-        }
-        return R.success(returnDataObject);
-    }
-
-}

+ 2 - 2
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/operationManagementCenter/service/TaskNodeService.java

@@ -103,7 +103,7 @@ public interface TaskNodeService extends SuperService<TaskNode> {
 
     String taskNodeStockTran(TaskNode bean);
 
-    String taskNodeCallback(TaskNodeCallBackDTO bean);
+    R taskNodeCallback(TaskNodeCallBackDTO bean);
 
     /**
      * 获取后N节点
@@ -120,7 +120,7 @@ public interface TaskNodeService extends SuperService<TaskNode> {
     void taskNodeCallbackBiz(TaskNode taskNode,TTask task,List<TaskNode>taskNodeList,AAutoNodeLog lg, String bizCallBackData);
 
 
-     R<String> handModeStock(JSONObject callBackJson);
+     R<String> handModeStock(TaskNodeCallBackDTO bean);
 
 
     R handModeStockOut(Map conMap);

+ 2 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/operationManagementCenter/service/WorkpieceService.java

@@ -6,6 +6,7 @@ import com.github.zuihou.base.service.SuperService;
 import com.github.zuihou.business.edgeLibrary.entity.Shelves;
 import com.github.zuihou.business.edgeLibrary.entity.StockInfo;
 import com.github.zuihou.business.edgeLibrary.entity.Storge;
+import com.github.zuihou.business.externalApi.dto.ManualInfo;
 import com.github.zuihou.business.operationManagementCenter.entity.PlanProduct;
 import com.github.zuihou.business.operationManagementCenter.entity.TTask;
 import com.github.zuihou.business.operationManagementCenter.entity.TWorkpiece;
@@ -74,4 +75,5 @@ public interface WorkpieceService extends SuperService<TWorkpiece> {
     public TWorkpiece getWorkPiece(Long taskNodeId);
 
 
+    R executeManualTask(ManualInfo manualInfo) throws Exception;
 }

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

@@ -1207,7 +1207,7 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
      * @return
      */
     @Override
-    public String taskNodeCallback(TaskNodeCallBackDTO bean) {
+    public R taskNodeCallback(TaskNodeCallBackDTO bean) {
         log.info("回调参数======================" + JSONObject.toJSONString(bean));
         BaseContextHandler.setTenant("0000");
         //取出参数
@@ -1220,7 +1220,7 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
 
         String handModeFlag = bean.getHandModeFlag();
         if("1".equals(handModeFlag)){//手动模式是特殊处理
-            return  handModeStock(JSONObject.parseObject(bizCallBackData)).getData();
+            return  handModeStock(bean);
         }
 
 
@@ -1255,7 +1255,7 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
             lg.setFeedback(msg);
             autoNodeLogMapper.updateAllById(lg);
         }
-        return null;
+        return R.success();
     }
 
 
@@ -1566,13 +1566,19 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
 
     /**
      *
-     * @param callBackJson
+     * @param bean
      * @return
      */
     @Override
-    public R<String> handModeStock(JSONObject callBackJson) {
+    public R handModeStock(TaskNodeCallBackDTO bean) {
+
+        String manualId =  String.valueOf(bean.getTaskId());
+        Object taskInfoObject = msgUtil.redis_get(manualId);
 
-        String manualId =  callBackJson.getString("taskId");
+
+        if(null == taskInfoObject){
+            return R.fail("任务号不存在");
+        }
         String taskInfos = msgUtil.redis_get(manualId).toString();
         JSONObject taskInfosObject = JSONObject.parseObject(taskInfos);
         List<String> taskNodes = JSONArray.parseArray(taskInfosObject.getString("taskNodes"),String.class);
@@ -1580,7 +1586,7 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
 
         if(manualInfo.getNextTaskNodeIndex() > taskNodes.size() -1){
             // 最后一个结点,更新库位信息
-            return R.success("");
+            return R.success();
         }else{
             // 继续执行后续结点
             Map<String,Object> processInfo =  ManualTaskOperatorUtil.judgeProcessInfo((LinkedList<String>) taskNodes,manualInfo);
@@ -1700,8 +1706,8 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
         List<ProductionresourcePosition> list = productionresourcePositionMapper.getStorgeIdByResource(queryMap);
         R result = R.success();
         for(ProductionresourcePosition p:list){
-            if("1".equals(category)){//托盘夹具
-                // 查询当前子盘夹具使用的数量,根据出入库日志查询当前的子盘夹具最大数量和库存数量进行比较进行累加
+            if("2".equals(category)){//托盘夹具
+                // 查询当前子盘使用的数量,根据出入库日志查询当前的子盘最大数量和库存数量进行比较进行累加
                 Tray tray = trayMapper.selectById(goodsId);
                 int maxTrayNo = stockLogMapper.selectMaxNoByProductId(queryMap);
                 int sumTray = stockInfoMapper.selectSumInStockByProductId(queryMap);
@@ -1712,8 +1718,8 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
                     return R.fail("当前托盘数量已用完");
                 }
                 result = stockInfoService.procedureTrayStockIn(uniqueCode, Long.valueOf(goodsId), list.get(0).getStorgeId());
-            }else if("2".equals(p.getCategory())){
-                // 查询当前子盘夹具使用的数量,根据出入库日志查询当前的子盘夹具最大数量和库存数量进行比较进行累加
+            }else if("1".equals(p.getCategory())){
+                // 查询当前夹具使用的数量,根据出入库日志查询当前的夹具最大数量和库存数量进行比较进行累加
                 MToolClamp mToolClamp = mToolClampMapper.selectById(goodsId);
                 int maxMToolClampNo = stockLogMapper.selectMaxNoByProductId(queryMap);
                 int sumMToolClamp = stockInfoMapper.selectSumInStockByProductId(queryMap);

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

@@ -8,9 +8,9 @@ import com.github.zuihou.base.R;
 import com.github.zuihou.base.service.SuperServiceImpl;
 import com.github.zuihou.business.edgeLibrary.dao.StorgeMapper;
 import com.github.zuihou.business.edgeLibrary.entity.Storge;
+import com.github.zuihou.business.externalApi.dto.ManualInfo;
 import com.github.zuihou.business.mq.HandModeWorkNode;
 import com.github.zuihou.business.operationManagementCenter.dao.WorkpieceMapper;
-import com.github.zuihou.business.operationManagementCenter.entity.OrderQuality;
 import com.github.zuihou.business.operationManagementCenter.entity.TWorkpiece;
 import com.github.zuihou.business.operationManagementCenter.entity.TaskNode;
 import com.github.zuihou.business.operationManagementCenter.service.TaskNodeService;
@@ -28,22 +28,24 @@ import com.github.zuihou.business.productionResourceCenter.entity.Productionreso
 import com.github.zuihou.business.productionResourceCenter.entity.ZZone;
 import com.github.zuihou.business.productionResourceCenter.entity.ZZoneProductionresource;
 import com.github.zuihou.business.productionResourceCenter.service.ProductionresourcePositionService;
+import com.github.zuihou.business.util.ManualTaskOperatorUtil;
+import com.github.zuihou.business.util.MsgUtil;
 import com.github.zuihou.common.util.StringUtil;
 import com.github.zuihou.context.BaseContextHandler;
 import com.github.zuihou.database.mybatis.conditions.Wraps;
 import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
 import org.springframework.stereotype.Service;
+import org.springframework.web.client.RestTemplate;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.stream.Collectors;
 
 import static java.util.stream.Collectors.groupingBy;
-import static java.util.stream.Collectors.mapping;
 
 /**
  * <p>
@@ -88,6 +90,26 @@ public class WorkpieceServiceImpl extends SuperServiceImpl<WorkpieceMapper, TWor
     @Autowired
     private ZZoneProductionresourceMapper zZoneProductionresourceMapper;
 
+    @Autowired
+    private RestTemplate restTemplate;
+    @Autowired
+    private MsgUtil msgUtil;
+
+    private static LinkedList<String> robotTaskNodes = new LinkedList<>();
+    static {
+        robotTaskNodes.add("move");
+        robotTaskNodes.add("get");
+        robotTaskNodes.add("put");
+        robotTaskNodes.add("move");
+        robotTaskNodes.add("get");
+        robotTaskNodes.add("put");
+    }
+    private static LinkedList<String> robotNoMoveTaskNodes = new LinkedList<String>();
+    static {
+        robotNoMoveTaskNodes.add("get");
+        robotNoMoveTaskNodes.add("put");
+    }
+
     @Override
     public IPage<TWorkpiece> pageList(IPage page, LbqWrapper<TWorkpiece> wrapper) {
         return baseMapper.pageList(page, wrapper);
@@ -200,82 +222,97 @@ public class WorkpieceServiceImpl extends SuperServiceImpl<WorkpieceMapper, TWor
         zZoneWrapper.eq("status",1);
         List<ZZone> zZones = zZoneMapper.selectList(zZoneWrapper);
         Map<String, Object> retStockInfo = new HashMap<String, Object>();
+        List<Map> returnList = new ArrayList<>();
+
+        zZoneWrapper = new QueryWrapper<ZZone>();
+        zZoneWrapper.like("name","保障");
+        ZZone safeguardZone = zZoneMapper.selectOne(zZoneWrapper);
+
+        List<ZZoneProductionresource> safeguardResources = zZoneProductionresourceMapper.selectList(Wraps.<ZZoneProductionresource>lbQ().eq(ZZoneProductionresource::getZoneId,safeguardZone.getId()));
+        List<Long> safeguardResourceLists = safeguardResources.stream().map(p -> p.getResourceId()).collect(Collectors.toList());
+
         for(ZZone zZone : zZones){
+
             // TODO 代码先判断死,后面再调整映射关系优化
+            String zZoneName = zZone.getName();
+            String zZoneCode = "";
+            if(zZoneName.contains("舱体")){
+                zZoneCode = "capsule";
+            }else if(zZoneName.contains("框体")){
+                zZoneCode = "framework";
+            }else{
+                zZoneCode = "safeguard";
+            }
             // 查询产线设备
             List<ZZoneProductionresource> zZoneProductionresources = zZoneProductionresourceMapper.selectList(Wraps.<ZZoneProductionresource>lbQ().eq(ZZoneProductionresource::getZoneId,zZone.getId()));
-            // 遍历产线设备
-            List zonePoints = new ArrayList();
 
             for(ZZoneProductionresource zZoneProductionresource : zZoneProductionresources){
-                Map map = new HashMap();
-                map.put("resourceId",zZoneProductionresource.getResourceId());
-                List<ProductionresourcePosition> list = productionresourcePositionMapper.getProductlineStockInfo(map);
-                Map<String, List<ProductionresourcePosition>> pointMap = list.stream().collect(groupingBy(ProductionresourcePosition::getPointId));
-                Map<String, Object> resourcePoint = new HashMap<>();
-                List<Map> returnList = new ArrayList<>();
-                for(String key : pointMap.keySet()){
-                    Map returnMap = new HashMap();
-                    List<ProductionresourcePosition> subList = pointMap.get(key);
-                    if(CollectionUtil.isEmpty(subList)){
-                        continue;
-                    }
-                    ProductionresourcePosition position0 = subList.get(0);
-                    returnMap.put("pointId",key);
-                    returnMap.put("storgeId",position0.getStorgeId());
-                    returnMap.put("name",position0.getName());
-                    returnMap.put("lockStatus",position0.getLockStatus());
-                    returnMap.put("resourceId",position0.getResourceId());
-                    List<Map>l = new ArrayList<>();
-                    for(ProductionresourcePosition p:subList){
-                        if(p.getGoodsId()!=null){
-                            Map m = new HashMap();
-                            m.put("goodsName",p.getGoodsName());
-                            m.put("goodsId",p.getGoodsId());
-                            m.put("uniqueCode",p.getUniqueCode());
-                            m.put("storgeId",p.getStorgeId());
-                            m.put("category",p.getCategory());
-                            if("5".equals(p.getCategory())){//如果是托板。
-                                List<Map> childL = new ArrayList<>();
-                                //根据托盘ID,找到对应的点位
-                                Map queryMap = new HashMap();
-                                queryMap.put("plateId",p.getGoodsId()==null?"":p.getGoodsId().toString());
-                                List<ProductionresourcePosition> childList = productionresourcePositionMapper.getProductlineStockInfo(queryMap);
-                                for(ProductionresourcePosition c:childList){
-                                    Map childMap = new HashMap();
-                                    childMap.put("pointId",c.getPointId());
-                                    childMap.put("goodsName",c.getGoodsName());
-                                    childMap.put("goodsId",c.getGoodsId());
-                                    childMap.put("storgeId",c.getStorgeId());
-                                    childMap.put("category",c.getCategory());
-                                    childL.add(childMap);
-                                }
-                                m.put("childList",childL);
-                            }
-                            l.add(m);
+                if(("capsule".equals(zZoneCode) || "framework".equals(zZoneCode))  && !safeguardResourceLists.contains(zZoneProductionresource.getResourceId())){
+
+                    processStockInfo(returnList, zZoneCode, zZoneProductionresource);
+                }else if("safeguard".equals(zZoneCode)){
+                    processStockInfo(returnList, zZoneCode, zZoneProductionresource);
+                }
+            }
+        }
+
+        retStockInfo.put("data",returnList);
+        return retStockInfo;
+
+    }
+
+    private void processStockInfo(List<Map> returnList, String zZoneCode, ZZoneProductionresource zZoneProductionresource) {
+        Map map = new HashMap();
+        map.put("resourceId", zZoneProductionresource.getResourceId());
+        List<ProductionresourcePosition> list = productionresourcePositionMapper.getProductlineStockInfo(map);
+        Map<String, List<ProductionresourcePosition>> pointMap = list.stream().collect(groupingBy(ProductionresourcePosition::getPointId));
+        for (String key : pointMap.keySet()) {
+            Map returnMap = new HashMap();
+            List<ProductionresourcePosition> subList = pointMap.get(key);
+            if (CollectionUtil.isEmpty(subList)) {
+                continue;
+            }
+            ProductionresourcePosition position0 = subList.get(0);
+            returnMap.put("unitename", zZoneCode);
+            returnMap.put("pointId", key);
+            returnMap.put("storgeId", position0.getStorgeId());
+            returnMap.put("name", position0.getName());
+            returnMap.put("lockStatus", position0.getLockStatus());
+            returnMap.put("resourceId", position0.getResourceId());
+            List<Map> l = new ArrayList<>();
+            for (ProductionresourcePosition p : subList) {
+                if (p.getGoodsId() != null) {
+                    Map m = new HashMap();
+                    m.put("goodsName", p.getGoodsName());
+                    m.put("goodsId", p.getGoodsId());
+                    m.put("uniqueCode", p.getUniqueCode());
+                    m.put("storgeId", p.getStorgeId());
+                    m.put("category", p.getCategory());
+                    if ("5".equals(p.getCategory())) {//如果是托板。
+                        List<Map> childL = new ArrayList<>();
+                        //根据托盘ID,找到对应的点位
+                        Map queryMap = new HashMap();
+                        queryMap.put("plateId", p.getGoodsId() == null ? "" : p.getGoodsId().toString());
+                        List<ProductionresourcePosition> childList = productionresourcePositionMapper.getProductlineStockInfo(queryMap);
+                        for (ProductionresourcePosition c : childList) {
+                            Map childMap = new HashMap();
+                            childMap.put("pointId", c.getPointId());
+                            childMap.put("goodsName", c.getGoodsName());
+                            childMap.put("goodsId", c.getGoodsId());
+                            childMap.put("storgeId", c.getStorgeId());
+                            childMap.put("category", c.getCategory());
+                            childL.add(childMap);
                         }
+                        m.put("childList", childL);
                     }
-                    if(CollectionUtil.isNotEmpty(l)){
-                        returnMap.put("goodsList",l);
-                    }
-                    returnList.add(returnMap);
+                    l.add(m);
                 }
-
-                resourcePoint.put(zZoneProductionresource.getResourceId().toString(), returnList);
-                zonePoints.add(resourcePoint);
             }
-
-            String zZoneName = zZone.getName();
-            if(zZoneName.contains("生产单元")){
-                retStockInfo.put("capsule",zonePoints);
-            }else if(zZoneName.contains("柔性")){
-                retStockInfo.put("framework",zonePoints);
-            }else{
-                retStockInfo.put("safeguard",zonePoints);
+            if (CollectionUtil.isNotEmpty(l)) {
+                returnMap.put("goodsList", l);
             }
+            returnList.add(returnMap);
         }
-        return retStockInfo;
-
     }
 
     @Override
@@ -294,7 +331,8 @@ public class WorkpieceServiceImpl extends SuperServiceImpl<WorkpieceMapper, TWor
         callBackJson.put("srcPosition",startPointId);
         callBackJson.put("targetPostion",endPointId);
         callBackJson.put("goodsId",goodsId);
-        return taskNodeService.handModeStock(callBackJson).getData();
+//        return taskNodeService.handModeStock(callBackJson).getData();
+        return null;
     }
 
 
@@ -402,4 +440,55 @@ public class WorkpieceServiceImpl extends SuperServiceImpl<WorkpieceMapper, TWor
         }
         return tWorkpiece;
     }
+
+    @Override
+    public R executeManualTask(ManualInfo manualInfo) throws Exception {
+
+        // 查找当前任务所属产线,并且找出产线所需运输设备的点位及占用状态
+        String unit = manualInfo.getDeviceUnit();
+        if("capsule".equals(unit)){
+            // 舱体(智能单元)
+        }else if("framework".equals(unit)){
+            // 框体(柔性线)
+        }else if("safeguard".equals(unit)){
+            // 保障平台(质量中心)
+        }
+
+        Map<String,Object> processInfo =  ManualTaskOperatorUtil.judgeFirstProcessInfo(robotTaskNodes, robotNoMoveTaskNodes,manualInfo);
+        JSONObject returnDataObject = new JSONObject();
+
+        // 组装参数
+        String returnData = "";
+        //组装接口参数
+        HttpHeaders headers = new HttpHeaders();
+        headers.setContentType(MediaType.parseMediaType("application/json;charset=UTF-8"));
+
+        //回调参数构建
+        String jsonParam = ManualTaskOperatorUtil.getRequestParam(processInfo.get("location").toString(),manualInfo,processInfo.get("deviceUrl").toString(),processInfo.get("devicePort").toString());
+
+        HttpEntity<String> formEntity = new HttpEntity<String>(jsonParam, headers);
+        //调用接口
+        try {
+            returnData = restTemplate.postForObject(processInfo.get("hostSyetemTaskUrl").toString(), formEntity, String.class);
+            returnDataObject = JSONObject.parseObject(returnData);
+            log.error("调用上位机执行指令返回" + returnData);
+            if("true".equals(returnDataObject.get("result"))){
+                // 放入redis,方便回调的时候判断是否是最后一个结点,如果是最后一个结点不在做任何逻辑,更新相应的库位信息
+                Map<String, Object> currentTask = new HashMap<String, Object>();
+                List<String> taskNodes = (List<String>) processInfo.get("taskNodes");
+                currentTask.put("taskNodes",taskNodes);
+                currentTask.put("taskInfo",manualInfo);
+                JSONObject redisTask = new JSONObject();
+                redisTask.putAll(currentTask);
+                msgUtil.redis_set(manualInfo.getManualId(),redisTask.toJSONString());
+            }else{
+                return R.fail(returnDataObject.getString("msg"));
+            }
+        }catch (Exception e) {
+            e.printStackTrace();
+            log.error("调用接口发生异常" + e.getMessage());
+            return R.fail(returnDataObject.getString("msg"));
+        }
+        return R.success(returnDataObject);
+    }
 }

+ 2 - 2
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/util/ManualTaskOperatorUtil.java

@@ -100,14 +100,14 @@ public class ManualTaskOperatorUtil {
                 // 保障平台(质量中心) 代码先写死,6个动作,后续根据resource_code表中获取
                 // 执行第一个任务
                 int currentIndex = 0;
-                String taskType = robotNoMoveTaskNodes.get(currentIndex);
+                String taskType = robotTaskNodes.get(currentIndex);
                 int nextTaskNodeIndex = currentIndex +1;
                 if("get".equals(taskType)){
                     String hostSyetemTaskUrl = hostSyetemUrl + "/api/GetIntelligenceUnit";
                     String deviceUrl = ZK_ip_zndy;
                     String devicePort = ZK_ip_zndy_port;
                     String location = manualInfo.getStartpointId();
-                    setProcessInfo(robotNoMoveTaskNodes, processInfo, hostSyetemTaskUrl, location, deviceUrl, devicePort);
+                    setProcessInfo(robotTaskNodes, processInfo, hostSyetemTaskUrl, location, deviceUrl, devicePort);
                 }
                 manualInfo.setNextTaskNodeIndex(nextTaskNodeIndex);
             }

+ 1 - 3
imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/productionResourceCenter/ProductionresourcePositionMapper.xml

@@ -104,11 +104,9 @@
                   FROM imcs_t_plate itp
                   WHERE itp.id = i.goods_id) END) AS goodsName
         FROM zuihou_base_yj_0000.imcs_p_productionresource_position p,
-             zuihou_base_yj_0000.imcs_s_storge s,
-             zuihou_base_yj_0000.imcs_s_stock_info i
+             zuihou_base_yj_0000.imcs_s_storge s left join zuihou_base_yj_0000.imcs_s_stock_info i on (p.storge_id = i.storge_id)
         WHERE 1=1
         AND p.storge_id = s.id
-        AND p.storge_id = i.storge_id
         AND p.resource_id = #{resourceId}
     </select>
 

+ 0 - 70
imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/externalApi/ManualControl.java

@@ -1,70 +0,0 @@
-package com.github.zuihou.business.controller.externalApi;
-
-
-import cn.hutool.core.date.DatePattern;
-import cn.hutool.core.date.DateUtil;
-import com.alibaba.fastjson.JSONObject;
-import com.github.zuihou.base.R;
-import com.github.zuihou.business.externalApi.dto.ManualInfo;
-import com.github.zuihou.business.externalApi.entity.AgvOrderDetailInfo;
-import com.github.zuihou.business.externalApi.entity.AgvOrderInfo;
-import com.github.zuihou.business.externalApi.service.ManualTaskInfoService;
-import com.github.zuihou.common.constant.ParameterKey;
-import com.github.zuihou.common.enums.AgvActionEnum;
-import com.github.zuihou.common.enums.AgvLocationRelationEnum;
-import com.github.zuihou.common.util.StringUtil;
-import com.github.zuihou.context.BaseContextHandler;
-import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
-import com.github.zuihou.log.annotation.SysLog;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.MediaType;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.List;
-import java.util.Map;
-
-/**
- * <p>
- * 前端控制器
- * 手动模式交互
- * </p>
- *
- * @author imcs
- * @date 2022-02-21
- */
-@Slf4j
-@Validated
-@RestController
-@RequestMapping("/manual")
-@Api(value = "manual", tags = "手动模式")
-@SysLog(enabled = true)
-public class ManualControl {
-
-    @Autowired
-    private ManualTaskInfoService manualTaskInfoService;
-
-    @ApiOperation(value = "手动任务", notes = "手动任务")
-    @PostMapping("/manualTask")
-    public R manualTask(@RequestBody ManualInfo manualInfo) {
-        log.info("开始执行手动任务,参数是{}", manualInfo.toString());
-        try {
-            return manualTaskInfoService.executeManualTask(manualInfo);
-        } catch (Exception e) {
-            e.printStackTrace();
-            return R.fail("执行手动任务发生异常:" + e.getMessage());
-        }finally {
-            log.info("结束执行手动任务,参数是{}", manualInfo.toString());
-        }
-    }
-}

+ 2 - 2
imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/operationManagementCenter/TaskNodeController.java

@@ -155,8 +155,8 @@ public class TaskNodeController extends SuperController<TaskNodeService, Long, T
 
     @ApiOperation(value = "任务回调", notes = "任务回调")
     @PostMapping("/taskNodeCallback")
-    public R<String> taskNodeCallback(@RequestBody TaskNodeCallBackDTO bean) {
-        return success(baseService.taskNodeCallback(bean));
+    public R taskNodeCallback(@RequestBody TaskNodeCallBackDTO bean) {
+        return baseService.taskNodeCallback(bean);
     }
 
 }

+ 29 - 4
imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/operationManagementCenter/WorkpieceController.java

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.github.zuihou.base.R;
 import com.github.zuihou.base.controller.SuperController;
 import com.github.zuihou.base.request.PageParams;
+import com.github.zuihou.business.externalApi.dto.ManualInfo;
 import com.github.zuihou.business.operationManagementCenter.dto.*;
 import com.github.zuihou.business.operationManagementCenter.entity.Plan;
 import com.github.zuihou.business.operationManagementCenter.entity.TTask;
@@ -84,7 +85,7 @@ public class WorkpieceController extends SuperController<WorkpieceService, Long,
      * 下载远程质检报告
      *
      * @param response  文件下载
-     * @param id  文件名对应ID值
+     * @param map  文件名对应ID值
      * @throws IOException
      */
     @ApiOperation(value = "下载远程质检报告", notes = "下载远程质检报告")
@@ -224,7 +225,31 @@ public class WorkpieceController extends SuperController<WorkpieceService, Long,
     }
 
 
-    /**
-     *
-     */
+    @ApiOperation(value = "手动任务", notes = "手动任务")
+    @PostMapping("/manualTask")
+    public R manualTask(@RequestBody ManualInfo manualInfo) {
+        log.info("开始执行手动任务,参数是{}", manualInfo.toString());
+        try {
+            return baseService.executeManualTask(manualInfo);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return R.fail("执行手动任务发生异常:" + e.getMessage());
+        }finally {
+            log.info("结束执行手动任务,参数是{}", manualInfo.toString());
+        }
+    }
+
+    @ApiOperation(value = "产线状态", notes = "产线状态")
+    @PostMapping("/productLineRunMode")
+    public R productLineRunMode(@RequestBody ManualInfo manualInfo) {
+        log.info("开始执行手动任务,参数是{}", manualInfo.toString());
+        try {
+            return baseService.executeManualTask(manualInfo);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return R.fail("执行手动任务发生异常:" + e.getMessage());
+        }finally {
+            log.info("结束执行手动任务,参数是{}", manualInfo.toString());
+        }
+    }
 }