Ver código fonte

Merge branch 'master' of http://106.15.38.8:3000/yaoyq/imcs-yj-be

oyq28 4 anos atrás
pai
commit
d836d2cfb5
20 arquivos alterados com 898 adições e 168 exclusões
  1. 6 0
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/edgeLibrary/dao/StockInfoMapper.java
  2. 8 0
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/edgeLibrary/dao/StockLogMapper.java
  3. 9 4
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/edgeLibrary/service/StockInfoService.java
  4. 22 15
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/edgeLibrary/service/impl/StockInfoServiceImpl.java
  5. 28 0
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/externalApi/service/ManualTaskInfoService.java
  6. 103 0
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/externalApi/service/impl/ManualTaskInfoServiceImpl.java
  7. 7 2
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/operationManagementCenter/service/TaskNodeService.java
  8. 9 4
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/operationManagementCenter/service/WorkpieceService.java
  9. 146 74
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/operationManagementCenter/service/impl/TaskNodeServiceImpl.java
  10. 97 59
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/operationManagementCenter/service/impl/WorkpieceServiceImpl.java
  11. 13 0
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionResourceCenter/dao/ProductionresourcePositionMapper.java
  12. 1 0
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionResourceCenter/service/impl/MachineNodeServiceImpl.java
  13. 249 0
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/util/ManualTaskOperatorUtil.java
  14. 4 0
      imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/edgeLibrary/StockInfoMapper.xml
  15. 4 0
      imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/edgeLibrary/StockLogMapper.xml
  16. 30 0
      imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/productionResourceCenter/ProductionresourcePositionMapper.xml
  17. 70 0
      imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/externalApi/ManualControl.java
  18. 30 9
      imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/operationManagementCenter/WorkpieceController.java
  19. 60 0
      imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/externalApi/dto/ManualInfo.java
  20. 2 1
      imcs-admin-boot/imcs-common/src/main/java/com/github/zuihou/common/properties/IgnoreTokenProperties.java

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

@@ -46,4 +46,10 @@ public interface StockInfoMapper extends SuperMapper<StockInfo> {
 
     List<StockInfo>getListByGoodsId(Map map);
 
+    /**
+     *
+     * @param queryMap
+     * @return
+     */
+    int selectSumInStockByProductId(Map queryMap);
 }

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

@@ -9,6 +9,8 @@ import com.github.zuihou.business.edgeLibrary.entity.StockLog;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 
+import java.util.Map;
+
 /**
  * <p>
  * Mapper 接口
@@ -26,4 +28,10 @@ public interface StockLogMapper extends SuperMapper<StockLog> {
      */
     IPage<StockLog> pageList(IPage page, @Param("name")String name,@Param(Constants.WRAPPER) Wrapper<StockLog> queryWrapper);
 
+    /**
+     * 根据产品id查询当前已使用最大编号
+     * @param queryMap
+     * @return
+     */
+    int selectMaxNoByProductId(Map queryMap);
 }

+ 9 - 4
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/edgeLibrary/service/StockInfoService.java

@@ -12,6 +12,7 @@ import com.github.zuihou.business.productionReadyCenter.entity.MToolClamp;
 import com.github.zuihou.business.productionReadyCenter.entity.Tray;
 import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
 
+import java.math.BigDecimal;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
@@ -101,20 +102,22 @@ public interface StockInfoService extends SuperService<StockInfo> {
 
     /**
      * 从系统外部(不是库存)入库
-     * @param tray
+     * @param uniqueCode
+     * @param productId
      * @param storgeId
      * @return
      */
-    R<String> procedureTrayStockIn(Tray tray, Long storgeId);
+    R procedureTrayStockIn(BigDecimal uniqueCode, Long productId, Long storgeId);
 
 
     /**
      * 从系统外部(不是库存)入库
-     * @param clamp
+     * @param uniqueCode
+     * @param productId
      * @param storgeId
      * @return
      */
-    R<String> procedureToolClampStockIn(MToolClamp clamp, Long storgeId);
+    R procedureToolClampStockIn(BigDecimal uniqueCode, Long productId, Long storgeId);
 
     /**
      * 托盘出库
@@ -161,4 +164,6 @@ public interface StockInfoService extends SuperService<StockInfo> {
     LinkedHashMap<String,List<Map>>  demoLineStock(Map map);
 
     LinkedHashMap <String,Map <String,List<Map>>> demoLineAllStock();
+
+    R manualStockOut(String goodsId, Long storgeId);
 }

+ 22 - 15
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/edgeLibrary/service/impl/StockInfoServiceImpl.java

@@ -36,6 +36,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.math.BigDecimal;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -408,20 +409,14 @@ public class StockInfoServiceImpl extends SuperServiceImpl<StockInfoMapper, Stoc
     }
 
     @Override
-    public R<String> procedureTrayStockIn(Tray tray, Long storgeId) {
+    public R procedureTrayStockIn(BigDecimal uniqueCode, Long goodsId, Long storgeId) {
         StockInfo infoBean = new StockInfo();
         infoBean.setStorgeId(storgeId);
         infoBean.setLockStatus("1");
-        //Tray tray = trayService.getById(bomProcedureTray.getTrayId());
-        infoBean.setGoodsId(tray.getId());
+        infoBean.setGoodsId(goodsId);
         infoBean.setGoodsType("2");
-        infoBean.setSpecId(tray.getId());
         infoBean.setNum(1);
-//        if(StringUtil.isEmpty(uniqueCode)){
-//            //根据编码规则
-//            uniqueCode = codeRuleService.getBillCode(CodeRuleModule.CODE_RULE_UNIQUE);
-//        }
-        infoBean.setUniqueCode("");
+        infoBean.setUniqueCode(String.valueOf(uniqueCode));
         infoBean.setCompleteBatchNo("");
         save(infoBean);
         //库存日志
@@ -431,21 +426,19 @@ public class StockInfoServiceImpl extends SuperServiceImpl<StockInfoMapper, Stoc
 
 
     @Override
-    public R<String> procedureToolClampStockIn(MToolClamp clamp, Long storgeId) {
+    public R procedureToolClampStockIn(BigDecimal uniqueCode, Long goodsId, Long storgeId) {
         StockInfo infoBean = new StockInfo();
         infoBean.setStorgeId(storgeId);
         infoBean.setLockStatus("1");
-        //MToolMeterial meterial = toolMeterialService.getById(bomProcedureTray.getTrayId());
-        infoBean.setGoodsId(clamp.getId());
+        infoBean.setGoodsId(goodsId);
         infoBean.setGoodsType("1");
-        infoBean.setSpecId(clamp.getId());
         infoBean.setNum(1);
-        infoBean.setUniqueCode("");
+        infoBean.setUniqueCode(String.valueOf(uniqueCode));
         infoBean.setCompleteBatchNo("");
         save(infoBean);
         //库存日志
         stockLogService.saveLog(infoBean,BizConstant.STOCK_TYPE_IN);
-        return R.success("");
+        return R.success();
     }
 
     @Override
@@ -537,6 +530,7 @@ public class StockInfoServiceImpl extends SuperServiceImpl<StockInfoMapper, Stoc
     }
 
     //示范线库位展示
+    @Override
     public LinkedHashMap<String,List<Map>> demoLineStock(Map map) {
         Map <String,List<Map>> m = new LinkedHashMap<String,List<Map>>();
         LinkedHashMap <String,List<Map>> returnMap = new LinkedHashMap<String,List<Map>>();
@@ -627,4 +621,17 @@ public class StockInfoServiceImpl extends SuperServiceImpl<StockInfoMapper, Stoc
         }
         return R.success("");
     }
+
+    @Override
+    public R manualStockOut(String goodsId, Long storgeId) {
+        List<StockInfo>list  = baseMapper.selectList(Wraps.<StockInfo>lbQ().eq(StockInfo::getStorgeId,storgeId).eq(StockInfo::getUniqueCode,goodsId));
+        if(list==null||list.size()==0){
+            return R.fail("没有库存");
+        }
+        StockInfo stockInfo = list.get(0);
+        baseMapper.deleteById(stockInfo.getId());
+        //库存日志
+        stockLogService.saveLog(stockInfo,BizConstant.STOCK_TYPE_OUT);
+        return R.success();
+    }
 }

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

@@ -0,0 +1,28 @@
+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;
+
+
+}

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

@@ -0,0 +1,103 @@
+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);
+    }
+
+}

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

@@ -123,9 +123,14 @@ public interface TaskNodeService extends SuperService<TaskNode> {
      R<String> handModeStock(JSONObject callBackJson);
 
 
-    R<String> handModeStockOut(Map conMap);
+    R handModeStockOut(Map conMap);
 
-    R<String> handModeStockIn(Map conMap);
+    /**
+     * 手动模式下(非订单)添加子盘夹具
+     * @param conMap
+     * @return
+     */
+    R handModeStockIn(Map conMap);
 
 
     /**

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

@@ -1,6 +1,7 @@
 package com.github.zuihou.business.operationManagementCenter.service;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.github.zuihou.base.R;
 import com.github.zuihou.base.service.SuperService;
 import com.github.zuihou.business.edgeLibrary.entity.Shelves;
 import com.github.zuihou.business.edgeLibrary.entity.StockInfo;
@@ -37,7 +38,7 @@ public interface WorkpieceService extends SuperService<TWorkpiece> {
 
     public List getOrderInfo();
 
-    public List<Map> getAllStockInfo();
+    public Map getAllStockInfo();
 
     //执行非订单物品
     public String execute(Map map);
@@ -46,12 +47,16 @@ public interface WorkpieceService extends SuperService<TWorkpiece> {
     public String handMove(Map map);
 
 
-    public String delete(Map map);
+    public R delete(Map map);
 
     public String lock(Map map);
 
-
-    public String add(Map map);
+    /**
+     * 添加子盘夹具
+     * @param map
+     * @return
+     */
+    public R add(Map map);
 
 
     public List<MToolClamp>toolClamplist();

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

@@ -2,6 +2,7 @@ package com.github.zuihou.business.operationManagementCenter.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollectionUtil;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -10,18 +11,18 @@ import com.github.zuihou.base.service.SuperServiceImpl;
 import com.github.zuihou.business.DemoLine.DemoCacheKey;
 import com.github.zuihou.business.DemoLine.DemoLineConstant;
 import com.github.zuihou.business.edgeLibrary.dao.StockInfoMapper;
+import com.github.zuihou.business.edgeLibrary.dao.StockLogMapper;
 import com.github.zuihou.business.edgeLibrary.entity.StockInfo;
 import com.github.zuihou.business.edgeLibrary.entity.Storge;
 import com.github.zuihou.business.edgeLibrary.service.StockInfoService;
 import com.github.zuihou.business.edgeLibrary.service.StorgeService;
+import com.github.zuihou.business.externalApi.dto.ManualInfo;
 import com.github.zuihou.business.mq.TaskWorkNode;
 import com.github.zuihou.business.operationManagementCenter.dao.*;
 import com.github.zuihou.business.operationManagementCenter.dto.TaskNodeCallBackDTO;
 import com.github.zuihou.business.operationManagementCenter.entity.*;
 import com.github.zuihou.business.operationManagementCenter.service.*;
-import com.github.zuihou.business.productionReadyCenter.dao.AAutoNodeLogMapper;
-import com.github.zuihou.business.productionReadyCenter.dao.AutoNodeMapper;
-import com.github.zuihou.business.productionReadyCenter.dao.BBomMapper;
+import com.github.zuihou.business.productionReadyCenter.dao.*;
 import com.github.zuihou.business.productionReadyCenter.entity.*;
 import com.github.zuihou.business.productionReadyCenter.service.*;
 import com.github.zuihou.business.productionResourceCenter.dao.ProductionresourcePositionMapper;
@@ -32,6 +33,7 @@ import com.github.zuihou.business.productionResourceCenter.service.ResourceAutoC
 import com.github.zuihou.business.productionResourceCenter.service.ResourceBusinessService;
 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.BizConstant;
 import com.github.zuihou.common.constant.CacheKey;
@@ -51,8 +53,13 @@ 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;
+import org.springframework.http.MediaType;
 import org.springframework.stereotype.Service;
+import org.springframework.web.client.RestTemplate;
 
+import java.math.BigDecimal;
 import java.text.NumberFormat;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
@@ -162,6 +169,9 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
     @Autowired
     private MsgUtil msgUtil;
 
+    @Autowired
+    private RestTemplate restTemplate;
+
     //总控IP
     private String ZK_ip = "192.168.1.41";
 
@@ -188,6 +198,12 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
 
     @Autowired
     private ZZoneService zoneService;
+    @Autowired
+    private StockLogMapper stockLogMapper;
+    @Autowired
+    private TrayMapper trayMapper;
+    @Autowired
+    private MToolClampMapper mToolClampMapper;
 
     private static Logger logger = LoggerFactory.getLogger(TaskNodeServiceImpl.class);
 
@@ -537,6 +553,7 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
         JSONObject jsonObject = new JSONObject();
         //下料直接操作结束
         if (BizConstant.TASK_NODE_MANUALNODE_CUTTING.equals(taskNode.getAutoNodeCode())) {
+
             //下料,需要手动把物料放到接驳位B
             Storge sxlzstorge = (Storge) msgUtil.redis_get(DemoCacheKey.DEMOLINE_CIRCULATION_STORAGE + "_" + task.getCompleteBatchNo());
             jsonObject.put("srcPosition", sxlzstorge.getId());
@@ -552,6 +569,13 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
             this.taskNodeCallbackBiz(taskNode, task, taskNodeList, lg, jsonObject.toJSONString());
             return taskNode;
         } else {//上料
+
+            // TODO 调用CCS读取写入rfid信息
+            // 拼接写入rfid的信息
+            // 当前托盘的id
+
+
+
             Storge jbwFromStorge = (Storge) msgUtil.redis_get(DemoCacheKey.DEMOLINE_CIRCULATION_STORAGE + "_" + task.getCompleteBatchNo());
             //2、取出上下料站
             Storge sxlzstorge = (Storge) msgUtil.redis_get(DemoCacheKey.DEMOLINE_CAMP + "_" + DemoLineConstant.SXLZ + taskNode.getId());
@@ -1545,64 +1569,73 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
      * @param callBackJson
      * @return
      */
+    @Override
     public R<String> handModeStock(JSONObject callBackJson) {
-        String srcStorgeId = callBackJson.getString("srcPosition");
-        String targetStorgeId = callBackJson.getString("targetPostion");
-        String goodsId = callBackJson.getString("goodsId");
-        Map queryMap = new HashMap();
-        queryMap.put("pointId", srcStorgeId);
-        List<ProductionresourcePosition> list = productionresourcePositionMapper.getPPList(queryMap);
 
-        List<ProductionresourcePosition> targetlist = productionresourcePositionMapper.selectList(Wraps.<ProductionresourcePosition>lbQ().eq(ProductionresourcePosition::getPointId, targetStorgeId));
+        String manualId =  callBackJson.getString("taskId");
+        String taskInfos = msgUtil.redis_get(manualId).toString();
+        JSONObject taskInfosObject = JSONObject.parseObject(taskInfos);
+        List<String> taskNodes = JSONArray.parseArray(taskInfosObject.getString("taskNodes"),String.class);
+        ManualInfo manualInfo = JSONObject.parseObject(taskInfosObject.getString("taskInfo"),ManualInfo.class);
 
-        R<String> result =  R.success("");;
-
-        if(CollectionUtil.isEmpty(targetlist))
-            return result;
-
-
-        for(ProductionresourcePosition p:list){
-            String stockGoodsId = p.getGoodsId()==null?"":p.getGoodsId().toString();
-            if(!goodsId.equals(stockGoodsId))
-                continue;
-
-            if("1".equals(p.getCategory())||"2".equals(p.getCategory())){//托盘夹具
-                BomProcedureTray tray = new BomProcedureTray();
-                tray.setTrayId(p.getGoodsId());
-                result = stockInfoService.procedureTrayStockOut(tray, p.getStorgeId());
-                if (result.getIsSuccess()) {
-                    result = stockInfoService.procedureTrayStockIn(tray, targetlist.get(0).getStorgeId(), result.getData(), "");
-                }
-            }
-
-            if("4".equals(p.getCategory())){//原材料
-                BomProcedureMeterial meterial = new BomProcedureMeterial();
-                meterial.setMeterialId(p.getGoodsId());
-                R<String> ckresult = stockInfoService.meterialStockOut(meterial,  p.getStorgeId(), "");
-                R<String> rkresult = null;
-                if (ckresult.getIsSuccess()) {
-                    rkresult = stockInfoService.meterialStockIn(meterial, targetlist.get(0).getStorgeId(), ckresult.getData(),"");
+        if(manualInfo.getNextTaskNodeIndex() > taskNodes.size() -1){
+            // 最后一个结点,更新库位信息
+            return R.success("");
+        }else{
+            // 继续执行后续结点
+            Map<String,Object> processInfo =  ManualTaskOperatorUtil.judgeProcessInfo((LinkedList<String>) taskNodes,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);
+                if("true".equals(returnDataObject.get("result"))){
+                    // 放入redis,方便回调的时候判断是否是最后一个结点,如果是最后一个结点不在做任何逻辑,更新相应的库位信息
+                    Map<String, Object> currentTask = new HashMap<String, Object>();
+                    List<String> remindTaskNodes = (List<String>) processInfo.get("remindTaskNodes");
+                    currentTask.put("taskNodes",remindTaskNodes);
+                    currentTask.put("taskInfo",manualInfo);
+                    JSONObject redisTask = new JSONObject();
+                    redisTask.putAll(currentTask);
+                    msgUtil.redis_set(manualInfo.getManualId(),redisTask.toJSONString());
                 }
+            }catch (Exception e) {
+                e.printStackTrace();
+                JSONObject errJsonObject = new JSONObject();
+                errJsonObject.put("msg", e.getMessage());
+                returnData = errJsonObject.toJSONString();
+                log.error("调用接口发生异常" + e.getMessage());
+                return R.fail(returnDataObject.getString("msg"));
             }
-            if (!result.getIsSuccess()) {
-                break;
-            }
+            return R.success(returnDataObject.getString("msg"));
         }
-        return result;
-    }
-
-
-    @Override
-    public R<String> handModeStockOut(Map conMap) {
-        String pointId = conMap.get("pointId")==null?"":conMap.get("pointId").toString();
-        String category = conMap.get("category")==null?"":conMap.get("category").toString();
-        String goodsId = conMap.get("goodsId")==null?"":conMap.get("goodsId").toString();
-        Map queryMap = new HashMap();
-        queryMap.put("pointId", pointId);
-        List<ProductionresourcePosition> list = productionresourcePositionMapper.getPPList(queryMap);
-
-        R<String> result = R.success("");
 
+//        String srcStorgeId = callBackJson.getString("srcPosition");
+//        String targetStorgeId = callBackJson.getString("targetPostion");
+//        String goodsId = callBackJson.getString("goodsId");
+//        Map queryMap = new HashMap();
+//        queryMap.put("pointId", srcStorgeId);
+//        List<ProductionresourcePosition> list = productionresourcePositionMapper.getPPList(queryMap);
+//
+//        List<ProductionresourcePosition> targetlist = productionresourcePositionMapper.selectList(Wraps.<ProductionresourcePosition>lbQ().eq(ProductionresourcePosition::getPointId, targetStorgeId));
+//
+//        R<String> result =  R.success("");;
+//
+//        if(CollectionUtil.isEmpty(targetlist))
+//            return result;
+//
+//
 //        for(ProductionresourcePosition p:list){
 //            String stockGoodsId = p.getGoodsId()==null?"":p.getGoodsId().toString();
 //            if(!goodsId.equals(stockGoodsId))
@@ -1612,46 +1645,85 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
 //                BomProcedureTray tray = new BomProcedureTray();
 //                tray.setTrayId(p.getGoodsId());
 //                result = stockInfoService.procedureTrayStockOut(tray, p.getStorgeId());
+//                if (result.getIsSuccess()) {
+//                    result = stockInfoService.procedureTrayStockIn(tray, targetlist.get(0).getStorgeId(), result.getData(), "");
+//                }
 //            }
 //
 //            if("4".equals(p.getCategory())){//原材料
 //                BomProcedureMeterial meterial = new BomProcedureMeterial();
 //                meterial.setMeterialId(p.getGoodsId());
-//                result = stockInfoService.meterialStockOut(meterial,  p.getStorgeId(), "");
+//                R<String> ckresult = stockInfoService.meterialStockOut(meterial,  p.getStorgeId(), "");
+//                R<String> rkresult = null;
+//                if (ckresult.getIsSuccess()) {
+//                    rkresult = stockInfoService.meterialStockIn(meterial, targetlist.get(0).getStorgeId(), ckresult.getData(),"");
+//                }
 //            }
 //            if (!result.getIsSuccess()) {
 //                break;
 //            }
 //        }
-        return result;
-    }
+//        return result;
 
 
+    }
+
     @Override
-    public R<String> handModeStockIn(Map conMap) {
-        String pointId = conMap.get("pointId")==null?"":conMap.get("pointId").toString();
-        String category = conMap.get("category")==null?"":conMap.get("category").toString();
-        String goodsId = conMap.get("goodsId")==null?"":conMap.get("goodsId").toString();
+    public R handModeStockOut(Map conMap) {
+        String resourceId = conMap.get("resourceId").toString();
+        String pointId = conMap.get("pointId").toString();
+        String category = conMap.get("category").toString();
+        String goodsId = conMap.get("goodsId").toString();
         Map queryMap = new HashMap();
         queryMap.put("pointId", pointId);
-        List<ProductionresourcePosition> list = productionresourcePositionMapper.getPPList(queryMap);
+        queryMap.put("resourceId", resourceId);
+        List<ProductionresourcePosition> list = productionresourcePositionMapper.getStorgeIdByResource(queryMap);
+        R result = R.success();
+        ProductionresourcePosition productionresourcePosition = list.get(0);
+        return stockInfoService.manualStockOut(goodsId, productionresourcePosition.getStorgeId());
+    }
 
-        R<String> result = R.success("");
 
-        for(ProductionresourcePosition p:list){
+    @Override
+    public R handModeStockIn(Map conMap) {
+        String pointId = conMap.get("pointId").toString();
+        String category = conMap.get("category").toString();
+        String goodsId = conMap.get("goodsId").toString();
+        String resourceId = conMap.get("resourceId").toString();
 
+        Map queryMap = new HashMap();
+        queryMap.put("pointId", pointId);
+        queryMap.put("resourceId", resourceId);
+        queryMap.put("goodsId", goodsId);
+        queryMap.put("type", BizConstant.STOCK_TYPE_IN);
+
+        List<ProductionresourcePosition> list = productionresourcePositionMapper.getStorgeIdByResource(queryMap);
+        R result = R.success();
+        for(ProductionresourcePosition p:list){
             if("1".equals(category)){//托盘夹具
-                Tray tray = new Tray();
-                tray.setId(Long.parseLong(goodsId));
-                result = stockInfoService.procedureTrayStockIn(tray, list.get(0).getStorgeId());
+                // 查询当前子盘夹具使用的数量,根据出入库日志查询当前的子盘夹具最大数量和库存数量进行比较进行累加
+                Tray tray = trayMapper.selectById(goodsId);
+                int maxTrayNo = stockLogMapper.selectMaxNoByProductId(queryMap);
+                int sumTray = stockInfoMapper.selectSumInStockByProductId(queryMap);
+                BigDecimal uniqueCode;
+                if(sumTray < tray.getNum()){
+                    uniqueCode = BigDecimal.valueOf(maxTrayNo).add(new BigDecimal(1));
+                }else{
+                    return R.fail("当前托盘数量已用完");
+                }
+                result = stockInfoService.procedureTrayStockIn(uniqueCode, Long.valueOf(goodsId), list.get(0).getStorgeId());
             }else if("2".equals(p.getCategory())){
-                MToolClamp clamp = new MToolClamp();
-                clamp.setId(Long.parseLong(goodsId));
-                result = stockInfoService.procedureToolClampStockIn(clamp, list.get(0).getStorgeId());
-            }
-
-            if (!result.getIsSuccess()) {
-                break;
+                // 查询当前子盘夹具使用的数量,根据出入库日志查询当前的子盘夹具最大数量和库存数量进行比较进行累加
+                MToolClamp mToolClamp = mToolClampMapper.selectById(goodsId);
+                int maxMToolClampNo = stockLogMapper.selectMaxNoByProductId(queryMap);
+                int sumMToolClamp = stockInfoMapper.selectSumInStockByProductId(queryMap);
+                BigDecimal uniqueCode;
+                if(sumMToolClamp < mToolClamp.getNum()){
+                    uniqueCode = BigDecimal.valueOf(maxMToolClampNo).add(new BigDecimal(1));;
+                }else{
+                    return R.fail("当前夹具数量已用完");
+                }
+                result = stockInfoService.procedureToolClampStockIn(uniqueCode, Long.valueOf(goodsId), list.get(0).getStorgeId());
             }
         }
         return result;

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

@@ -2,12 +2,15 @@ package com.github.zuihou.business.operationManagementCenter.service.impl;
 
 import cn.hutool.core.collection.CollectionUtil;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+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.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;
@@ -19,7 +22,11 @@ import com.github.zuihou.business.productionReadyCenter.service.MToolClampServic
 import com.github.zuihou.business.productionReadyCenter.service.TrayService;
 import com.github.zuihou.business.productionResourceCenter.dao.ProductionresourceBizMapper;
 import com.github.zuihou.business.productionResourceCenter.dao.ProductionresourcePositionMapper;
+import com.github.zuihou.business.productionResourceCenter.dao.ZZoneMapper;
+import com.github.zuihou.business.productionResourceCenter.dao.ZZoneProductionresourceMapper;
 import com.github.zuihou.business.productionResourceCenter.entity.ProductionresourcePosition;
+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.common.util.StringUtil;
 import com.github.zuihou.context.BaseContextHandler;
@@ -33,8 +40,10 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 import static java.util.stream.Collectors.groupingBy;
+import static java.util.stream.Collectors.mapping;
 
 /**
  * <p>
@@ -74,6 +83,10 @@ public class WorkpieceServiceImpl extends SuperServiceImpl<WorkpieceMapper, TWor
 
     @Autowired
     private BBomMapper bomMapper;
+    @Autowired
+    private ZZoneMapper zZoneMapper;
+    @Autowired
+    private ZZoneProductionresourceMapper zZoneProductionresourceMapper;
 
     @Override
     public IPage<TWorkpiece> pageList(IPage page, LbqWrapper<TWorkpiece> wrapper) {
@@ -179,63 +192,89 @@ public class WorkpieceServiceImpl extends SuperServiceImpl<WorkpieceMapper, TWor
     }
 
     @Override
-    public List<Map> getAllStockInfo() {
+    public Map getAllStockInfo() {
         BaseContextHandler.setTenant("0000");
-        Map map = new HashMap();
-//        map.put("fullFlag","1");
-//        map.put("goodsName","1");
-        List<ProductionresourcePosition> list = productionresourcePositionMapper.getPPList(map);
-        Map<String, List<ProductionresourcePosition>> pointMap = list.stream().collect(groupingBy(ProductionresourcePosition::getPointId));
-
-        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());
-            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("storgeId",p.getStorgeId());
-                    m.put("resourceId",p.getResourceId());
-                    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.getPPList(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("resourceId",c.getResourceId());
-                            childMap.put("category",c.getCategory());
-                            childL.add(childMap);
+
+        // 查询产线列表、遍历产线查询设备资源
+        QueryWrapper<ZZone> zZoneWrapper = new QueryWrapper<ZZone>();
+        zZoneWrapper.eq("status",1);
+        List<ZZone> zZones = zZoneMapper.selectList(zZoneWrapper);
+        Map<String, Object> retStockInfo = new HashMap<String, Object>();
+        for(ZZone zZone : zZones){
+            // TODO 代码先判断死,后面再调整映射关系优化
+            // 查询产线设备
+            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);
                         }
-                        m.put("childList",childL);
                     }
-                    l.add(m);
+                    if(CollectionUtil.isNotEmpty(l)){
+                        returnMap.put("goodsList",l);
+                    }
+                    returnList.add(returnMap);
                 }
+
+                resourcePoint.put(zZoneProductionresource.getResourceId().toString(), returnList);
+                zonePoints.add(resourcePoint);
             }
-            if(CollectionUtil.isNotEmpty(l)){
-                returnMap.put("goodsList",l);
+
+            String zZoneName = zZone.getName();
+            if(zZoneName.contains("生产单元")){
+                retStockInfo.put("capsule",zonePoints);
+            }else if(zZoneName.contains("柔性")){
+                retStockInfo.put("framework",zonePoints);
+            }else{
+                retStockInfo.put("safeguard",zonePoints);
             }
-            returnList.add(returnMap);
         }
-
-        return returnList;
+        return retStockInfo;
 
     }
 
@@ -260,19 +299,19 @@ public class WorkpieceServiceImpl extends SuperServiceImpl<WorkpieceMapper, TWor
 
 
     @Override
-    public String delete(Map conMap) {
+    public R delete(Map conMap) {
         BaseContextHandler.setTenant("0000");
-        return taskNodeService.handModeStockOut(conMap).getData();
+        return taskNodeService.handModeStockOut(conMap);
     }
 
-
     @Override
     public String  lock(Map map) {
         BaseContextHandler.setTenant("0000");
-        String pointId = map.get("pointId")==null?"":map.get("pointId").toString();
-        String lockType = map.get("lockType")==null?"":map.get("lockType").toString();
+        String resourceId = map.get("resourceId").toString();
+        String pointId = map.get("pointId").toString();
+        String lockType = map.get("lockType").toString();
 
-        List<ProductionresourcePosition> pointList = productionresourcePositionMapper.selectList(Wraps.<ProductionresourcePosition>lbQ().eq(ProductionresourcePosition::getPointId, pointId));
+        List<ProductionresourcePosition> pointList = productionresourcePositionMapper.selectList(Wraps.<ProductionresourcePosition>lbQ().eq(ProductionresourcePosition::getPointId, pointId).eq(ProductionresourcePosition::getResourceId ,resourceId));
         if(CollectionUtil.isEmpty(pointList)){
             return "";
         }
@@ -280,7 +319,6 @@ public class WorkpieceServiceImpl extends SuperServiceImpl<WorkpieceMapper, TWor
         //获取
         List<Storge> list = storgeMapper.selectList(Wraps.<Storge>lbQ().eq(Storge::getId, position.getStorgeId()));
 
-
         if(CollectionUtil.isEmpty(list)){
             return "";
         }
@@ -301,9 +339,9 @@ public class WorkpieceServiceImpl extends SuperServiceImpl<WorkpieceMapper, TWor
 
 
     @Override
-    public String add(Map map) {
+    public R add(Map map) {
         BaseContextHandler.setTenant("0000");
-        return taskNodeService.handModeStockIn(map).getData();
+        return taskNodeService.handModeStockIn(map);
     }
 
 

+ 13 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionResourceCenter/dao/ProductionresourcePositionMapper.java

@@ -28,4 +28,17 @@ public interface ProductionresourcePositionMapper extends SuperMapper<Production
 
     List<ProductionresourcePosition> getPPList(Map map);
 
+    /**
+     * 根据设备查找库位ID
+     * @param queryMap
+     * @return
+     */
+    List<ProductionresourcePosition> getStorgeIdByResource(Map queryMap);
+
+    /**
+     * 根据产线查询产线内所以点位信息
+     * @param map
+     * @return
+     */
+    List<ProductionresourcePosition> getProductlineStockInfo(Map map);
 }

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

@@ -312,6 +312,7 @@ public class MachineNodeServiceImpl implements NodeOperationService {
                     map.put("result", true);
                 } else if ("writeOffset".equals(functionName)){
                      // 加工前写入工件坐标系 根据taskid查找工件三坐标测量的工件坐标系,可能存在装夹一次未果的情况,所以取最后一条数据
+                     // TODO 工件坐标系根据机场不同系统,不同通讯协议调用不同的接口
                      QueryWrapper<OrderQuality> orderQualityWrapper = new QueryWrapper<OrderQuality>();
                      orderQualityWrapper.in("taskId", task.getId());
                      orderQualityWrapper.in("measuringType", "2");

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

@@ -0,0 +1,249 @@
+package com.github.zuihou.business.util;
+
+import com.alibaba.fastjson.JSONObject;
+import com.github.zuihou.business.externalApi.dto.ManualInfo;
+
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 手动模式下参数组装
+ */
+public class ManualTaskOperatorUtil {
+    /**
+     * 上位机系统地址
+     */
+    private static String hostSyetemUrl = "http://192.168.10.155:63570";
+    /**
+     * agv运输
+     */
+    private static String agvURL = "http://localhost:9099/api/authority/mock/mockWms";
+    //质量中心
+    private static String ZK_ip_zlzx = "192.168.170.61";
+    //柔性
+    private static String ZK_ip_rxx = "192.168.170.71";
+    //智能单元
+    private static String ZK_ip_zndy = "192.168.170.81";
+
+    // 质量中心PLC端口
+    private static String ZK_ip_zlzx_port = "102";
+    // 柔性线端口
+    private  static String ZK_ip_rxx_port = "102";
+    // 智能单元端口
+    private static String ZK_ip_zndy_port = "102";
+
+    /**
+     * 组装参数
+     * @param location
+     * @param manualInfo
+     * @param deviceUrl
+     * @param devicePort
+     * @return
+     */
+    public static String getRequestParam(String location, ManualInfo manualInfo, String deviceUrl, String devicePort){
+        JSONObject jsonParam = new JSONObject();
+        jsonParam.put("url",deviceUrl);
+        jsonParam.put("port",devicePort);
+        jsonParam.put("taskId",manualInfo.getManualId());
+        jsonParam.put("taskNodeId",manualInfo.getManualId());
+
+        JSONObject data = new JSONObject();
+        data.put("location",location);
+        jsonParam.put("data",data);
+        return jsonParam.toJSONString();
+    }
+
+    /**
+     * 处理手动模式首次任务结点信息
+     * @param robotTaskNodes
+     * @param robotNoMoveTaskNodes
+     * @param manualInfo
+     * @return
+     */
+    public static Map<String,Object> judgeFirstProcessInfo(LinkedList<String> robotTaskNodes,LinkedList<String> robotNoMoveTaskNodes , ManualInfo manualInfo){
+        Map<String,Object> processInfo = new HashMap<String,Object>();
+        String unit = manualInfo.getDeviceUnit();
+        String manualType = manualInfo.getManualIdType();
+        if("general".equals(manualType)){
+            if("capsule".equals(unit)){
+                // 舱体(智能单元) 代码先写死,6个动作,后续根据resource_code表中获取
+                // 执行第一个任务
+                int currentIndex = 0;
+                String taskType = robotNoMoveTaskNodes.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);
+                }
+                manualInfo.setNextTaskNodeIndex(nextTaskNodeIndex);
+
+            }else if("framework".equals(unit)){
+                int currentIndex = 0;
+                String taskType = robotNoMoveTaskNodes.get(currentIndex);
+                int nextTaskNodeIndex = currentIndex +1;
+                if("move".equals(taskType)){
+                    String hostSyetemTaskUrl = hostSyetemUrl + "/api/MoveRobotPosition";
+                    String deviceUrl = ZK_ip_zndy;
+                    String devicePort = ZK_ip_zndy_port;
+                    String location = manualInfo.getStartpointId();
+                    setProcessInfo(robotNoMoveTaskNodes, processInfo, hostSyetemTaskUrl, location, deviceUrl, devicePort);
+                }
+                if(nextTaskNodeIndex < robotNoMoveTaskNodes.size() -1){
+                    manualInfo.setNextTaskNodeIndex(nextTaskNodeIndex + 1);
+                }
+            }else if("safeguard".equals(unit)){
+                // 保障平台(质量中心) 代码先写死,6个动作,后续根据resource_code表中获取
+                // 执行第一个任务
+                int currentIndex = 0;
+                String taskType = robotNoMoveTaskNodes.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);
+                }
+                manualInfo.setNextTaskNodeIndex(nextTaskNodeIndex);
+            }
+        }else{
+            // 设备相关
+        }
+        return processInfo;
+    }
+
+    /**
+     * 处理手动模式回调任务结点信息
+     * @param taskNodes
+     * @param manualInfo
+     * @return
+     */
+    public static Map<String,Object> judgeProcessInfo(LinkedList<String> taskNodes, ManualInfo manualInfo){
+        String unit = manualInfo.getDeviceUnit();
+        String manualType = manualInfo.getManualIdType();
+        Map<String,Object> processInfo = new HashMap<String,Object>();
+        if("general".equals(manualType)){
+            if("capsule".equals(unit)){
+                int currentIndex = manualInfo.getNextTaskNodeIndex();
+                int nextTaskNodeIndex = currentIndex +1;
+                String taskType = taskNodes.get(currentIndex);
+                // 舱体(智能单元) 代码先写死,6个动作,后续根据resource_code表中获取
+                // 执行第一个任务
+                if("get".equals(taskType)){
+                    String hostSyetemTaskUrl = hostSyetemUrl + "/api/GetIntelligenceUnit";
+                    String deviceUrl = ZK_ip_zndy;
+                    String deviceUrlPort = ZK_ip_zndy_port;
+                    String location = manualInfo.getStartpointId();
+                    setProcessInfo(taskNodes, processInfo, hostSyetemTaskUrl, location, deviceUrl, deviceUrlPort);
+                }else if("put".equals(taskType)){
+                    String hostSyetemTaskUrl = hostSyetemUrl + "/api/SendIntelligenceUnit";
+                    String deviceUrl = ZK_ip_zndy;
+                    String deviceUrlPort = ZK_ip_zndy_port;
+                    String location = manualInfo.getEndpointId();
+                    setProcessInfo(taskNodes, processInfo, hostSyetemTaskUrl, location, deviceUrl, deviceUrlPort);
+                }
+                manualInfo.setNextTaskNodeIndex(nextTaskNodeIndex);
+            }else if("framework".equals(unit)){
+                int currentIndex = manualInfo.getNextTaskNodeIndex();
+                int nextTaskNodeIndex = currentIndex +1;
+                String taskType = taskNodes.get(currentIndex);
+
+                if(taskNodes.size() == 6){
+                    // 舱体(柔性线) 代码先写死,6个动作,后续根据resource_code表中获取
+                    // 执行第一个任务
+                    if("get".equals(taskType) && currentIndex == 1){
+                        String hostSyetemTaskUrl = hostSyetemUrl + "/api/GetIntelligenceUnit";
+                        String deviceUrl = ZK_ip_rxx;
+                        String deviceUrlPort = ZK_ip_rxx_port;
+                        String location = manualInfo.getStartpointId();
+                        setProcessInfo(taskNodes, processInfo, hostSyetemTaskUrl, location, deviceUrl, deviceUrlPort);
+                    }else if("put".equals(taskType) && currentIndex == 2){
+                        String hostSyetemTaskUrl = hostSyetemUrl + "/api/SendIntelligenceUnit";
+                        String deviceUrl = ZK_ip_rxx;
+                        String deviceUrlPort = ZK_ip_rxx_port;
+                        String location = manualInfo.getStartpointId();
+                        setProcessInfo(taskNodes, processInfo, hostSyetemTaskUrl, location, deviceUrl, deviceUrlPort);
+                    }else if("move".equals(taskType) && currentIndex == 3){
+                        String hostSyetemTaskUrl = hostSyetemUrl + "/api/MoveRobotPosition";
+                        String deviceUrl = ZK_ip_rxx;
+                        String deviceUrlPort = ZK_ip_rxx_port;
+                        String location = manualInfo.getStartpointId();
+                        setProcessInfo(taskNodes, processInfo, hostSyetemTaskUrl, location, deviceUrl, deviceUrlPort);
+                    }if("get".equals(taskType) && currentIndex == 4){
+                        String hostSyetemTaskUrl = hostSyetemUrl + "/api/GetIntelligenceUnit";
+                        String deviceUrl = ZK_ip_rxx;
+                        String deviceUrlPort = ZK_ip_rxx_port;
+                        String location = manualInfo.getStartpointId();
+                        setProcessInfo(taskNodes, processInfo, hostSyetemTaskUrl, location, deviceUrl, deviceUrlPort);
+                    }else if("put".equals(taskType) && currentIndex == 5){
+                        String hostSyetemTaskUrl = hostSyetemUrl + "/api/SendIntelligenceUnit";
+                        String deviceUrl = ZK_ip_rxx;
+                        String deviceUrlPort = ZK_ip_rxx_port;
+                        String location = manualInfo.getStartpointId();
+                        setProcessInfo(taskNodes, processInfo, hostSyetemTaskUrl, location, deviceUrl, deviceUrlPort);
+                    }
+                    manualInfo.setNextTaskNodeIndex(nextTaskNodeIndex);
+                }else if(taskNodes.size() == 3){
+                    if("get".equals(taskType)){
+                        String hostSyetemTaskUrl = hostSyetemUrl + "/api/GetIntelligenceUnit";
+                        String deviceUrl = ZK_ip_rxx;
+                        String deviceUrlPort = ZK_ip_rxx_port;
+                        String location = manualInfo.getStartpointId();
+                        setProcessInfo(taskNodes, processInfo, hostSyetemTaskUrl, location, deviceUrl, deviceUrlPort);
+                    }else if("put".equals(taskType)){
+                        String hostSyetemTaskUrl = hostSyetemUrl + "/api/SendIntelligenceUnit";
+                        String location = manualInfo.getEndpointId();
+                        String deviceUrl = ZK_ip_rxx;
+                        String deviceUrlPort = ZK_ip_rxx_port;
+                        setProcessInfo(taskNodes, processInfo, hostSyetemTaskUrl, location, deviceUrl, deviceUrlPort);
+                    }
+                }
+            }else if("safeguard".equals(unit)){
+                int currentIndex = manualInfo.getNextTaskNodeIndex();
+                int nextTaskNodeIndex = currentIndex +1;
+                String taskType = taskNodes.get(currentIndex);
+                // 保障平台(质量中心)
+                // 执行第一个任务
+                if("get".equals(taskType)){
+                    String hostSyetemTaskUrl = hostSyetemUrl + "/api/GetIntelligenceUnit";
+                    String deviceUrl = ZK_ip_zlzx;
+                    String deviceUrlPort = ZK_ip_zlzx_port;
+                    String location = manualInfo.getStartpointId();
+                    setProcessInfo(taskNodes, processInfo, hostSyetemTaskUrl, location, deviceUrl, deviceUrlPort);
+                }else if("put".equals(taskType) && currentIndex == 2){
+                    String hostSyetemTaskUrl = hostSyetemUrl + "/api/SendIntelligenceUnit";
+                    String deviceUrl = ZK_ip_zlzx;
+                    String deviceUrlPort = ZK_ip_zlzx_port;
+                    String location = manualInfo.getEndpointId();
+                    setProcessInfo(taskNodes, processInfo, hostSyetemTaskUrl, location, deviceUrl, deviceUrlPort);
+                }
+                manualInfo.setNextTaskNodeIndex(nextTaskNodeIndex);
+            }
+        }else{
+            // 设备相关
+        }
+        return processInfo;
+    }
+
+    /**
+     *
+     * @param taskNodes
+     * @param processInfo
+     * @param hostSyetemTaskUrl
+     * @param location
+     * @param deviceUrl
+     * @param devicePort
+     */
+    private static void setProcessInfo(LinkedList<String> taskNodes, Map<String, Object> processInfo, String hostSyetemTaskUrl, String location, String deviceUrl, String devicePort) {
+        processInfo.put("hostSyetemTaskUrl", hostSyetemTaskUrl);
+        processInfo.put("deviceUrl", deviceUrl);
+        processInfo.put("devicePort", devicePort);
+        processInfo.put("location", location);
+        processInfo.put("remindTaskNodes", taskNodes);
+    }
+}

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

@@ -143,4 +143,8 @@
         )r
     </select>
 
+    <select id="selectSumInStockByProductId" resultType="java.lang.Integer">
+        select sum(id) from imcs_s_stock_info where goods_id = #{goodsId}
+    </select>
+
 </mapper>

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

@@ -54,4 +54,8 @@
         ) s ${ew.customSqlSegment}
     </select>
 
+    <select id="selectMaxNoByProductId" resultType="java.lang.Integer">
+        select max(id) from imcs_s_stock_log where goods_id = #{goodsId} and opt_type = #{type}
+    </select>
+
 </mapper>

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

@@ -81,5 +81,35 @@
             and p.point_id = #{pointId}
         </if>
     </select>
+    <select id="getStorgeIdByResource" resultType="com.github.zuihou.business.productionResourceCenter.entity.ProductionresourcePosition">
+        select * from imcs_p_productionresource_position where resource_id = #{resourceId} and point_id = #{pointId}
+    </select>
+    <select id="getProductlineStockInfo" resultType="com.github.zuihou.business.productionResourceCenter.entity.ProductionresourcePosition">
+        SELECT
+          p.*,
+          s.lock_status lockStatus,
+          i.goods_id goodsId,
+          i.goods_type category,
+          i.complete_batch_no completeBatchNo,
+          s.complete_batch_no campCompleteBatchNo,
+          i.unique_code uniqueCode,
+          (CASE i.goods_type WHEN '1' THEN (SELECT
+                    imfc.name
+                  FROM imcs_m_frock_clamp imfc
+                  WHERE imfc.id = i.goods_id) WHEN '2' THEN (SELECT
+                    itt.name
+                  FROM imcs_t_tray itt
+                  WHERE itt.id = i.goods_id)  WHEN '5' THEN (SELECT
+                    itp.name
+                  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
+        WHERE 1=1
+        AND p.storge_id = s.id
+        AND p.storge_id = i.storge_id
+        AND p.resource_id = #{resourceId}
+    </select>
 
 </mapper>

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

@@ -0,0 +1,70 @@
+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());
+        }
+    }
+}

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

@@ -29,6 +29,7 @@ import jcifs.smb.NtlmPasswordAuthentication;
 import jcifs.smb.SmbFile;
 import jcifs.smb.SmbFileInputStream;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.http.HttpEntity;
@@ -144,9 +145,9 @@ public class WorkpieceController extends SuperController<WorkpieceService, Long,
 
     @ApiOperation(value = "获取所有有库位的点位", notes = "获取所有有库位的点位")
     @PostMapping("/handMode/getAllStockInfo")
-    public R<List<Map>>  getAllStockInfo() {
-        List<Map>list  = baseService.getAllStockInfo();
-        return success(list);
+    public R<Map>  getAllStockInfo() {
+        Map data = baseService.getAllStockInfo();
+        return success(data);
     }
 
 
@@ -157,6 +158,8 @@ public class WorkpieceController extends SuperController<WorkpieceService, Long,
     }
 
 
+
+
     @ApiOperation(value = "手动执行(非订单)", notes = "手动执行(非订单)")
     @PostMapping("/handMode/execute")
     public R<String>  execute(@RequestBody Map map) {
@@ -171,15 +174,24 @@ public class WorkpieceController extends SuperController<WorkpieceService, Long,
     }
 
 
-    @ApiOperation(value = "添加", notes = "删除(非订单)")
+    @ApiOperation(value = "添加子盘夹具", notes = "删除(非订单)")
     @PostMapping("/handMode/add")
-    public R<String>  add(@RequestBody Map map) {
-        return success(baseService.add(map));
+    public R add(@RequestBody Map map) {
+        // 判断请求参数是否完整
+        String pointId = map.get("pointId")==null?"":map.get("pointId").toString();
+        String category = map.get("category")==null?"":map.get("category").toString();
+        String goodsId = map.get("goodsId")==null?"":map.get("goodsId").toString();
+        String resourceId = map.get("resourceId")==null?"":map.get("resourceId").toString();
+        if(StringUtils.isBlank(pointId) || StringUtils.isBlank(category) || StringUtils.isBlank(goodsId) || StringUtils.isBlank(resourceId)){
+            return R.fail("请求参数不完整");
+        }
+
+        return baseService.add(map);
     }
 
-    @ApiOperation(value = "删除(非订单)", notes = "删除(非订单)")
+    @ApiOperation(value = "删除子盘夹具(非订单)", notes = "删除(非订单)")
     @PostMapping("/handMode/delete")
-    public R<String>  delete(@RequestBody Map map) {
+    public R delete(@RequestBody Map map) {
         return success(baseService.delete(map));
     }
 
@@ -187,6 +199,13 @@ public class WorkpieceController extends SuperController<WorkpieceService, Long,
     @ApiOperation(value = "锁定(非订单)", notes = "锁定(非订单)")
     @PostMapping("/handMode/lock")
     public R<String>  lock(@RequestBody Map map) {
+        // 判断请求参数是否完整
+        String pointId = map.get("pointId")==null?"":map.get("pointId").toString();
+        String lockType = map.get("lockType")==null?"":map.get("lockType").toString();
+        String resourceId = map.get("resourceId")==null?"":map.get("resourceId").toString();
+        if(StringUtils.isBlank(pointId) || StringUtils.isBlank(resourceId) || StringUtils.isBlank(lockType)){
+            return R.fail("请求参数不完整");
+        }
         return success(baseService.lock(map));
     }
 
@@ -198,7 +217,6 @@ public class WorkpieceController extends SuperController<WorkpieceService, Long,
         return success(baseService.toolClamplist());
     }
 
-
     @ApiOperation(value = "查询托盘", notes = "查询托盘")
     @PostMapping("/handMode/traylist")
     public R<List<Tray>> traylist() {
@@ -206,4 +224,7 @@ public class WorkpieceController extends SuperController<WorkpieceService, Long,
     }
 
 
+    /**
+     *
+     */
 }

+ 60 - 0
imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/externalApi/dto/ManualInfo.java

@@ -0,0 +1,60 @@
+package com.github.zuihou.business.externalApi.dto;
+
+import io.swagger.annotations.ApiModel;
+import lombok.*;
+import lombok.experimental.Accessors;
+
+/**
+ * <p>
+ * 实体类
+ * 手动模式任务信息
+ * </p>
+ *
+ * @author imcs
+ * @since 2022-02-21
+ */
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@Accessors(chain = true)
+@ToString(callSuper = true)
+@EqualsAndHashCode(callSuper = false)
+@Builder
+@ApiModel(value = "ManualInfo", description = "手动模式任务信息")
+public class ManualInfo {
+    /**
+     * 手动任务id
+     */
+    private String manualId;
+    /**
+     * 起点位置
+     */
+    private String startpointId;
+    /**
+     * 结束位置
+     */
+    private String endpointId;
+    /**
+     * 起点动作
+     */
+    private String startoperation;
+    /**
+     * 终点动作
+     */
+    private String endoperation;
+    /**
+     * 协议类型
+     */
+    private String manualIdType;
+
+    /**
+     * 设备单元
+     */
+    private String deviceUnit;
+
+    /**
+     * 下一指令需要
+     */
+    private int nextTaskNodeIndex;
+
+}

+ 2 - 1
imcs-admin-boot/imcs-common/src/main/java/com/github/zuihou/common/properties/IgnoreTokenProperties.java

@@ -41,7 +41,8 @@ public class IgnoreTokenProperties {
             "/workpiece/handMode/**",
             "/tray/**",
             "/mToolClamp/**",
-            "/wms/**"
+            "/wms/**",
+            "/manual/**"
 
     );