Sfoglia il codice sorgente

新增测试文件和修复业务bug

oyq28 3 anni fa
parent
commit
5ee2efc706

+ 193 - 0
imcs-admin-boot/imcs-authority-server/src/test/java/com/github/zuihou/node/ReviseNodeTest.java

@@ -0,0 +1,193 @@
+package com.github.zuihou.node;
+
+
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
+import com.github.benmanes.caffeine.cache.CacheLoader;
+import com.github.benmanes.caffeine.cache.Caffeine;
+import com.github.benmanes.caffeine.cache.LoadingCache;
+import com.github.zuihou.business.operationManagementCenter.entity.TTask;
+import com.github.zuihou.business.operationManagementCenter.entity.TaskNode;
+import com.github.zuihou.business.operationManagementCenter.service.OrderService;
+import com.github.zuihou.business.operationManagementCenter.service.TaskNodeService;
+import com.github.zuihou.business.operationManagementCenter.service.TaskService;
+import com.github.zuihou.business.productionReadyCenter.entity.BomProcedure;
+import com.github.zuihou.business.productionReadyCenter.service.BomProcedureService;
+import com.github.zuihou.business.productionResourceCenter.dao.ProductionresourceBizMapper;
+import com.github.zuihou.business.productionResourceCenter.entity.Productionresource;
+import com.github.zuihou.business.productionResourceCenter.entity.ResourceAutoCode;
+import com.github.zuihou.business.productionResourceCenter.service.ResourceAutoCodeService;
+import com.github.zuihou.common.constant.CodeRuleModule;
+import com.github.zuihou.common.constant.DictionaryKey;
+import com.github.zuihou.context.BaseContextHandler;
+import com.github.zuihou.database.mybatis.conditions.Wraps;
+import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
+import com.github.zuihou.tenant.service.CodeRuleService;
+import lombok.extern.slf4j.Slf4j;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
+
+import static java.util.stream.Collectors.groupingBy;
+
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+@RunWith(SpringJUnit4ClassRunner.class)
+@Slf4j
+public class ReviseNodeTest {
+
+    @Autowired
+    private TaskService taskService;
+
+    @Autowired
+    private TaskNodeService taskNodeService;
+
+    @Autowired
+    private ResourceAutoCodeService resourceAutoCodeService;
+
+    @Autowired
+    private CodeRuleService codeRuleService;
+
+    @Autowired
+    private ProductionresourceBizMapper productionresourceBizMapper;
+
+    @Autowired
+    private BomProcedureService bomProcedureService;
+
+    @Before
+    public void setTenant() {
+        BaseContextHandler.setUserId(3L);
+        BaseContextHandler.setTenant("0000");
+    }
+
+    private Long getResourceIdByAutoCode(String resourceType){
+        String robotName = DictionaryKey.YJ_ROBOT_NODES.get(resourceType);
+        //String robotName = DictionaryKey.LINE_ROBOT_NODES.get(resourceType);
+        Productionresource productionresource =  productionresourceBizMapper.selectOne(new LbqWrapper<Productionresource>().eq(Productionresource::getName, robotName));
+        return productionresource.getId();
+    }
+
+    @Test
+    public void test() {
+        //变更订单任务节点
+        TTask task = taskService.getById(1592136380245344256L);
+        List<TaskNode> oldNodeList =  taskNodeService.list(new LbqWrapper<TaskNode>().eq(TaskNode::getTaskId,"1592136380245344256"));
+        List<Long> oldIds = oldNodeList.stream().map(n->n.getId()).collect(Collectors.toList());
+        List<TaskNode> taskNodeList = new ArrayList<TaskNode>();
+        int begin = 0;
+        if(oldNodeList.size()>0) {
+            //TaskNode oldNode = oldNodeList.get(0);
+            //begin = oldNode.getCompleteBatchSort();
+
+            Long resourceBusinessId = task.getResourceBusinessId();
+
+            List<ResourceAutoCode> resourceAutoCodeList = resourceAutoCodeService.list(new LbqWrapper<ResourceAutoCode>().eq(ResourceAutoCode::getBusinessId, resourceBusinessId));
+            Map<Long, List<ResourceAutoCode>> resourceAutoCodeMap = resourceAutoCodeList.stream().collect(groupingBy(ResourceAutoCode::getBusinessId));
+            List<ResourceAutoCode> autoCodeList = resourceAutoCodeMap.get(resourceBusinessId);
+
+            List<ResourceAutoCode> parentResourceAutoCodeList = autoCodeList.stream().filter(a -> a.getParentId().longValue() == 0L).collect(Collectors.toList());
+
+            for (int parentCount = 0; parentCount < parentResourceAutoCodeList.size(); parentCount++) { //父节点
+                ResourceAutoCode pautoCode = parentResourceAutoCodeList.get(parentCount);
+                List<ResourceAutoCode> childResourceAutoCodeList = autoCodeList.stream().filter(a -> pautoCode.getId().toString().equals(a.getParentId().toString())).collect(Collectors.toList());
+                List<ResourceAutoCode> agvlist = childResourceAutoCodeList.stream().filter(a -> "2".equals(a.getCategory())).collect(Collectors.toList());
+                for (int count = 0; count < childResourceAutoCodeList.size(); count++) { //子节点
+                    ResourceAutoCode autoCode = childResourceAutoCodeList.get(count);
+                    ResourceAutoCode nextAutoCode = null;
+                    if (count < childResourceAutoCodeList.size() - 1) {
+                        nextAutoCode = childResourceAutoCodeList.get(count + 1);
+                    }
+                    TaskNode taskNode = new TaskNode();
+                    // 包含agv动作
+                    if (count == 0 && agvlist.size() > 0) {
+                        taskNode.setFindAgvFlag("1");
+                    } else {
+                        taskNode.setFindAgvFlag("0");
+                    }
+//                    taskNode.setAutoNode(autoNode).setAutoNodeCode(autoNode.getCode()).setCompleteBatchNo(t.getCompleteBatchNo())
+//                            .setNodeNo(autoNode.getNodeNo()).setExeStatus("1").setPrority(autoCode.getWeight());
+                    taskNode.setTaskId(task.getId()).setOrderId(task.getOrderId())
+                            .setTaskNodeNo(codeRuleService.getBillCode(CodeRuleModule.CODE_RULE_TASK_NODE));
+                    taskNode.setAutoNode(autoCode).setNodeNo(autoCode.getNo()).setCompleteBatchNo(task.getCompleteBatchNo())
+                            .setExeStatus("1").setPrority(autoCode.getWeight()).setNodeName(autoCode.getName()).setProcedureId(task.getProcedureId());
+//                    if (autoNode.getInterfaceType() != null) {
+//                        taskNode.setInterfaceType(autoNode.getInterfaceType().getKey());
+//                    }
+                    //String taskType = bpMap.get(t.getProcedureId()).getType();
+                    //依据设备类型判断调用接口类型
+                    String taskType = bomProcedureService.getOne(new LbqWrapper<BomProcedure>().eq(BomProcedure::getId, task.getProcedureId())).getType();
+                    if ("1".equals(taskNode.getAutoNode().getCategory())) {
+                        taskNode.setInterfaceType(DictionaryKey.INTERFACETYPE_PLC);
+                        //加工设备的设备ID来源于加工任务设备
+                        taskNode.setResourceId(task.getResourceId());
+                        taskNode.setTargetResourceId(task.getResourceId());
+                    } else if ("3".equals(taskNode.getAutoNode().getCategory())) {
+                        String command = autoCode.getCommand();
+                        taskNode.setInterfaceType(DictionaryKey.INTERFACETYPE_PLC);
+                        //根据配置确定操作设备ID
+                        //String resourceType = autoCode.getResourceId()!=null? autoCode.getResourceId().toString() : null;
+                        // 放,判断后一个动作节点是否是agv搬运,如果是,这个targetResourceId设置成空
+                        if ("2".equals(command)) {
+                            // 最后一个节点
+                            if (count == childResourceAutoCodeList.size() - 1) {
+                                taskNode.setTargetResourceId(task.getResourceId());
+                            } else {
+                                if (null == nextAutoCode.getResourceId()) {
+                                    taskNode.setTargetResourceId(null);
+                                }
+                            }
+                        }
+
+                        if (null != autoCode.getResourceId()) {
+                            taskNode.setResourceId(getResourceIdByAutoCode(autoCode.getResourceId().toString()));
+                        }
+                    } else if ("2".equals(taskNode.getAutoNode().getCategory())) {
+                        taskNode.setInterfaceType(DictionaryKey.INTERFACETYPE_AGV);
+                    } else if ("4".equals(taskNode.getAutoNode().getCategory())) {
+                        taskNode.setInterfaceType(DictionaryKey.INTERFACETYPE_WMS);
+
+                        if ("上料".equals(taskType)) {
+                            taskNode.setNodeType("1");
+                            taskNode.setResourceId(task.getResourceId());
+                        } else if ("下料".equals(taskType)) {
+                            taskNode.setNodeType("2");
+                            taskNode.setResourceId(task.getResourceId());
+                        } else if ("翻面".equals(taskType)) {
+                            taskNode.setNodeType("4");
+                            taskNode.setResourceId(task.getResourceId());
+                        } else {
+                            taskNode.setNodeType("0");
+                        }
+                    }
+                    //taskNode.setCompleteBatchSort(i);
+                    taskNodeList.add(taskNode);
+                }
+            }
+
+            taskNodeList.forEach(System.out::println);
+        }
+
+
+            //修正节点序列
+        UpdateWrapper<TaskNode> updateWrapper = new UpdateWrapper<TaskNode>();
+        int sort = taskNodeList.size()-oldNodeList.size();
+        updateWrapper.lambda().eq(TaskNode::getOrderId, task.getOrderId()).ge(TaskNode::getCompleteBatchSort, begin+ oldNodeList.size()).setSql("complete_batch_sort = complete_batch_sort + "+sort);
+
+//        boolean bool= taskNodeService.update(updateWrapper);
+//        //新增新节点
+//        taskNodeService.saveBatch(taskNodeList);
+//        //删除旧节点
+//        taskNodeService.removeByIds(oldIds);
+    }
+
+}

+ 206 - 0
imcs-admin-boot/imcs-authority-server/src/test/java/com/github/zuihou/node/StockInfoTest.java

@@ -0,0 +1,206 @@
+package com.github.zuihou.node;
+
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.collection.CollectionUtil;
+import com.github.zuihou.base.R;
+import com.github.zuihou.business.edgeLibrary.dao.StockInfoMapper;
+import com.github.zuihou.business.edgeLibrary.entity.StockInfo;
+import com.github.zuihou.business.operationManagementCenter.dao.TaskNodeMapper;
+import com.github.zuihou.business.operationManagementCenter.entity.TTask;
+import com.github.zuihou.business.operationManagementCenter.entity.TaskNode;
+import com.github.zuihou.business.operationManagementCenter.service.TaskNodeService;
+import com.github.zuihou.business.operationManagementCenter.service.TaskService;
+import com.github.zuihou.business.productionReadyCenter.entity.BomProcedureTray;
+import com.github.zuihou.business.productionReadyCenter.service.BomProcedureTrayService;
+import com.github.zuihou.business.productionResourceCenter.dao.ProductionresourceBizMapper;
+import com.github.zuihou.business.productionResourceCenter.dao.ProductionresourcePositionMapper;
+import com.github.zuihou.business.productionResourceCenter.entity.Productionresource;
+import com.github.zuihou.business.productionResourceCenter.entity.ProductionresourcePosition;
+import com.github.zuihou.common.constant.DictionaryKey;
+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.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import static java.util.stream.Collectors.groupingBy;
+
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+@RunWith(SpringJUnit4ClassRunner.class)
+@Slf4j
+public class StockInfoTest {
+
+    @Autowired
+    private ProductionresourceBizMapper productionresourceBizMapper;
+
+    @Autowired
+    private ProductionresourcePositionMapper productionresourcePositionMapper;
+
+    @Autowired
+    private BomProcedureTrayService procedureTrayService;
+
+    @Autowired
+    private StockInfoMapper stockInfoMapper;
+
+    @Autowired
+    private TaskService taskService;
+
+    @Autowired
+    private TaskNodeService taskNodeService;
+
+    @Autowired
+    private TaskNodeMapper taskNodeMapper;
+
+    @Before
+    public void setTenant() {
+        BaseContextHandler.setUserId(3L);
+        BaseContextHandler.setTenant("0000");
+    }
+
+
+    @Test
+    public void test() {
+        TTask task = taskService.getById("1601028032724729857");
+        List<StockInfo> returnList = null;
+        List<StockInfo> oneTray = null;
+
+        List<Productionresource> productionresources = productionresourceBizMapper.selectList(Wraps.<Productionresource>lbQ().like(Productionresource::getCode, DictionaryKey.YJ_ZONE_XBK.get("plateAndClamp")));
+        List<Long> productionresourceIds = productionresources.stream().map(t->t.getId()).collect(Collectors.toList());
+        List<ProductionresourcePosition> startProductionresourcePositions = productionresourcePositionMapper.selectList(Wraps.<ProductionresourcePosition>lbQ().in(ProductionresourcePosition::getResourceId, productionresourceIds).eq(ProductionresourcePosition::getStatus,"0"));
+        List<Long> startProductionresourcePositionIds = startProductionresourcePositions.stream().map(t->t.getStorgeId()).collect(Collectors.toList());
+
+        List<BomProcedureTray>trayList = procedureTrayService.list(Wraps.<BomProcedureTray>lbQ().in(BomProcedureTray::getProcedureId, task.getProcedureId()));
+        List<Long>trayIdList = trayList.stream().map(t->t.getTrayId()).collect(Collectors.toList());
+        // 判断夹具是否有可用的,查询330个库位信息中是否还有夹具
+
+        List<StockInfo> allStockInfos = stockInfoMapper.selectList(Wraps.<StockInfo>lbQ().in(StockInfo::getGoodsId,trayIdList).in(StockInfo::getStorgeId,startProductionresourcePositionIds).orderByAsc(StockInfo::getWeight, StockInfo::getStorgeId));
+        if(CollectionUtil.isNotEmpty(allStockInfos)) {
+            //List<StockInfo> stockInfoList = stockInfoMapper.selectList(new LbqWrapper<StockInfo>().eq(StockInfo::getStorgeId, allStockList.get(0).getStorgeId()));
+            //List<StockInfo> allStockInfos = stockInfoMapper.selectList(Wraps.<StockInfo>lbQ().in(StockInfo::getStorgeId,allStockList.get(0).getStorgeId()).orderByAsc(StockInfo::getGoodsType));
+            if(allStockInfos.size() == 2){
+                boolean bool = allStockInfos.get(0).getStorgeId().equals(allStockInfos.get(1).getStorgeId());
+                if(bool){
+                    returnList = allStockInfos;
+                }else{
+                    returnList = stockInfoMapper.selectList(new LbqWrapper<StockInfo>().eq(StockInfo::getStorgeId, allStockInfos.get(1).getStorgeId()));
+                }
+            }else if(allStockInfos.size() == 1){
+                if(allStockInfos.get(0).getGoodsType().equals("2")){
+                    returnList = stockInfoMapper.selectList(new LbqWrapper<StockInfo>().eq(StockInfo::getStorgeId, allStockInfos.get(0).getStorgeId()));;
+                }else{
+                    returnList = allStockInfos;
+                }
+            }
+        /*
+        if(CollectionUtil.isNotEmpty(allStockList)){
+            Map<Long,List<StockInfo>>map = allStockList.stream().collect(groupingBy(StockInfo::getStorgeId));
+            Long k = null;
+            for(Long key:map.keySet()){
+                k = key;
+                //优先有托盘夹具的
+                List<StockInfo> stockInfoList = map.get(key);
+                if(stockInfoList!=null && stockInfoList.size()>0){
+                    List<StockInfo> allStockInfos = stockInfoMapper.selectList(Wraps.<StockInfo>lbQ().in(StockInfo::getStorgeId,stockInfoList.get(0).getStorgeId()).orderByAsc(StockInfo::getGoodsType));
+                    if(allStockInfos.size() == 2){
+                        boolean bool = allStockInfos.get(0).getStorgeId().equals(allStockInfos.get(1).getStorgeId());
+                        if(bool){
+                            returnList = stockInfoList;
+                        }else{
+                            returnList = stockInfoMapper.selectList(new LbqWrapper<StockInfo>().eq(StockInfo::getStorgeId, allStockInfos.get(1).getStorgeId()));
+                        }
+                        break;
+                    }else if(allStockInfos.size() == 1){
+                        if(allStockInfos.get(0).getGoodsType().equals("2")){
+                            oneTray = stockInfoMapper.selectList(new LbqWrapper<StockInfo>().eq(StockInfo::getStorgeId, allStockInfos.get(0).getStorgeId()));;
+                        }else{
+                            oneTray = stockInfoList;
+                        }
+                    }
+                }
+            }
+            //只有托盘的
+            if(returnList == null){
+                returnList = oneTray;
+            } */
+            returnList.stream().forEach(System.out::println);
+        }
+    }
+
+    /*
+    @Test
+    public void test2(){
+        TaskNode hisTask = taskNodeService.getById("1598617863466070021");
+
+        List<BomProcedureTray>trayList = procedureTrayService.list(Wraps.<BomProcedureTray>lbQ().eq(BomProcedureTray::getProcedureId, hisTask.getProcedureId()));
+        List<Long> trayIdList = trayList.stream().map(t->t.getTrayId()).collect(Collectors.toList());
+
+        TaskNode beforeNode = taskNodeService.getNextNTaskNode(hisTask, (hisTask.getCompleteBatchSort()-1)*(-1));
+        List<BomProcedureTray> oldTrayList = procedureTrayService.list(Wraps.<BomProcedureTray>lbQ().eq(BomProcedureTray::getProcedureId, beforeNode.getProcedureId()));
+        List<Long> oldTrayIdList = oldTrayList.stream().map(t->t.getTrayId()).collect(Collectors.toList());
+
+        System.out.println(CollectionUtil.join(trayIdList,"").toString());
+        System.out.println(CollectionUtil.join(oldTrayIdList,"").toString());
+        if(CollectionUtil.join(trayIdList,"").toString().equals(CollectionUtil.join(oldTrayIdList,"").toString())){
+            return;
+        }
+        List<TaskNode> allNodes = this.getFanManNodes(hisTask);
+        allNodes.stream().forEach(System.out::println);
+
+        /*
+        List<TaskNode> taskNodeList = taskNodeMapper.selectList(Wraps.<TaskNode>lbQ().eq(TaskNode::getCompleteBatchNo, hisTask.getCompleteBatchNo()).orderByAsc(TaskNode::getCompleteBatchSort));
+        TaskNode firstTaskNode = taskNodeList.get(0);
+        List<BomProcedureTray> firsttrayList = procedureTrayService.list(Wraps.<BomProcedureTray>lbQ().in(BomProcedureTray::getProcedureId, firstTaskNode.getProcedureId()));
+        List<Long> firsttrayIdList = firsttrayList.stream().map(t->t.getTrayId()).collect(Collectors.toList());
+
+        //判断翻面得托盘工装和翻面前得是否一致
+        if(containAll(trayIdList,firsttrayIdList)){
+            return;
+        }
+    }   */
+
+    private List<TaskNode> getFanManNodes(TaskNode taskNode) {
+        List<TaskNode> headNodes = new ArrayList<TaskNode>();
+        List<TaskNode> tailNodes = new ArrayList<TaskNode>();
+        //获取最终回立库的两个节点
+        List<TaskNode> backStockNodes = taskNodeService.list(new LbqWrapper<TaskNode>().gt(TaskNode::getCompleteBatchSort,
+                taskNode.getCompleteBatchSort()).eq(TaskNode::getCompleteBatchNo, taskNode.getCompleteBatchNo()).orderByDesc(TaskNode::getCompleteBatchSort).last("limit 2"));
+
+        Collections.reverse(backStockNodes);
+        backStockNodes.stream().forEach(node -> {
+            TaskNode backNode = new TaskNode();
+            BeanUtil.copyProperties(node, backNode, "id");
+            backNode.setProcedureId(taskNode.getProcedureId()).setTaskId(taskNode.getTaskId()).setNodeType("4");
+            tailNodes.add(backNode);
+        });
+
+        //重建最初获取工装节点
+        List<TaskNode> switchNodes = taskNodeService.list(new LbqWrapper<TaskNode>().lt(TaskNode::getCompleteBatchSort,
+                taskNode.getCompleteBatchSort()).eq(TaskNode::getCompleteBatchNo, taskNode.getCompleteBatchNo()).orderByAsc(TaskNode::getCompleteBatchSort).last("limit 3"));
+        switchNodes.stream().forEach(node -> {
+            TaskNode headNode = new TaskNode();
+            BeanUtil.copyProperties(node, headNode, "id");
+            headNode.setProcedureId(taskNode.getProcedureId()).setTaskId(taskNode.getTaskId()).setExeStatus("1").setExeResult(null).setStartTime(null).setEndTime(null).setFeedback("");
+            if(!headNode.getNodeType().equals("1")){
+                headNode.setNodeType("4");
+            }
+            headNodes.add(headNode);
+        });
+
+        tailNodes.addAll(headNodes);
+        for (int count = 0; count < tailNodes.size(); count++) {
+            tailNodes.get(count).setCompleteBatchSort(taskNode.getCompleteBatchSort() + (count + 1)).setPrority(count + 2).setTaskNodeNo(taskNode.getTaskNodeNo() + "_" + (count + 1));
+        }
+        return tailNodes;
+    }
+}

+ 59 - 0
imcs-admin-boot/imcs-authority-server/src/test/java/com/github/zuihou/node/StockTest.java

@@ -0,0 +1,59 @@
+package com.github.zuihou.node;
+
+
+import com.github.zuihou.base.R;
+import com.github.zuihou.business.edgeLibrary.service.StockInfoService;
+import com.github.zuihou.business.operationManagementCenter.entity.TTask;
+import com.github.zuihou.business.operationManagementCenter.service.TaskService;
+import com.github.zuihou.business.productionReadyCenter.entity.BomProcedureMeterial;
+import com.github.zuihou.business.productionReadyCenter.entity.BomProcedureTray;
+import com.github.zuihou.business.productionReadyCenter.service.BomProcedureMeterialService;
+import com.github.zuihou.business.productionReadyCenter.service.BomProcedureTrayService;
+import com.github.zuihou.context.BaseContextHandler;
+import com.github.zuihou.database.mybatis.conditions.Wraps;
+import lombok.extern.slf4j.Slf4j;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import java.util.List;
+
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+@RunWith(SpringJUnit4ClassRunner.class)
+@Slf4j
+public class StockTest {
+
+    @Autowired
+    private StockInfoService stockInfoService;
+
+    @Autowired
+    private BomProcedureMeterialService bomProcedureMeterialService;
+
+    @Autowired
+    private BomProcedureTrayService procedureTrayService;
+
+    @Autowired
+    private TaskService taskService;
+
+    @Before
+    public void setTenant() {
+        BaseContextHandler.setUserId(3L);
+        BaseContextHandler.setTenant("0000");
+    }
+
+    @Test
+    public void test() {
+        TTask task = taskService.getById("1594953595105574912");
+        String srcStorgeId="1496718669625950208";
+        String targetStorgeId = "1497080777182019584";
+
+        List<BomProcedureMeterial> meterialList = bomProcedureMeterialService.list(Wraps.<BomProcedureMeterial>lbQ().eq(BomProcedureMeterial::getId, task.getProcedureMeterialId()));
+        //临时代码 材料为空
+        if(meterialList.size()==0) return;
+
+        R<String> rkresult = stockInfoService.meterialStockIn(meterialList.get(0), Long.parseLong(targetStorgeId), "K&DD_202215181036&TASK_20221519490861&kT_DH001&KT001&000001", task.getCompleteBatchNo());
+    }
+}

+ 68 - 0
imcs-admin-boot/imcs-authority-server/src/test/java/com/github/zuihou/node/redisTest.java

@@ -0,0 +1,68 @@
+package com.github.zuihou.node;
+
+import com.alibaba.fastjson.JSONObject;
+import com.github.zuihou.business.DemoLine.DemoCacheKey;
+import com.github.zuihou.business.DemoLine.DemoLineConstant;
+import com.github.zuihou.business.DemoLine.YunjianConstant;
+import com.github.zuihou.business.edgeLibrary.entity.Storge;
+import com.github.zuihou.business.edgeLibrary.service.StorgeService;
+import com.github.zuihou.business.util.MsgUtil;
+import com.github.zuihou.common.util.StringUtil;
+import com.github.zuihou.context.BaseContextHandler;
+import lombok.extern.slf4j.Slf4j;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.web.client.RestTemplate;
+import org.junit.Test;
+
+import java.util.concurrent.TimeUnit;
+
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+@RunWith(SpringJUnit4ClassRunner.class)
+@Slf4j
+public class redisTest {
+    @Autowired
+    private RedisTemplate<String,Object> redisTemplate;
+
+    @Autowired
+    private StorgeService storgeService;
+
+    @Autowired
+    private MsgUtil msgUtil;
+
+    @Before
+    public void setTenant() {
+        BaseContextHandler.setUserId(3L);
+        BaseContextHandler.setTenant("0000");
+    }
+
+    @Test
+    public void init(){
+
+        //Storge storge = storgeService.getById(1496714685607575552L);
+        //msgUtil.redis_set(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_STORE + "1602427292660363270",storge);
+    }
+
+    @Test
+    public void test(){
+
+        JSONObject bizJsonObject = new JSONObject();
+        long taskNodeId = 1603326479451975683L;
+
+        //此数据用来业务回传
+        bizJsonObject.put(DemoLineConstant.DEMOLINE_STOCK_TYPE, "DEMOLINE_STOCK_TYPE_TRAY_CRK");
+        bizJsonObject.put("srcPosition", "1496685676429574144");
+        bizJsonObject.put("targetPostion", "1496714517546008576");
+        bizJsonObject.put("aimStorge", "");
+        bizJsonObject.put("bizType", "1");
+        bizJsonObject.put("handMode", "0");
+        bizJsonObject.put(taskNodeId+"count", "0");
+        msgUtil.redis_set(YunjianConstant.YUNJIAN_CALLBACK_PARAM + "_" + taskNodeId, bizJsonObject.toJSONString(), 1, TimeUnit.DAYS);
+
+    }
+}

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

@@ -511,7 +511,7 @@ public class StockInfoServiceImpl extends SuperServiceImpl<StockInfoMapper, Stoc
         infoBean.setSpecId(stockInfo.getSpecId());
         infoBean.setGoodsType("5");
         infoBean.setNum(1);
-        infoBean.setCompleteBatchNo(stockInfo.getCompleteBatchNo());
+        //infoBean.setCompleteBatchNo(stockInfo.getCompleteBatchNo());
         infoBean.setUniqueCode(stockInfo.getUniqueCode());
         save(infoBean);
         //库存日志
@@ -526,7 +526,7 @@ public class StockInfoServiceImpl extends SuperServiceImpl<StockInfoMapper, Stoc
      */
     @Override
     public R<StockInfo> plateStockOut(Long storgeId,String completeBatchNo) {
-        List<StockInfo>list = baseMapper.selectList(Wraps.<StockInfo>lbQ().eq(StockInfo::getStorgeId,storgeId));
+        List<StockInfo>list = baseMapper.selectList(Wraps.<StockInfo>lbQ().eq(StockInfo::getStorgeId,storgeId).eq(StockInfo::getGoodsType, "5"));
         if(list==null||list.size()==0){
             return R.fail("没有此产品");
         }

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

@@ -889,8 +889,8 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
         }
 
         List<BomProcedureTray> procedureTrayList =
-                procedureTrayService.list(Wraps.<BomProcedureTray>lbQ().eq(BomProcedureTray::getGroupId,
-                        task.getProcedureTrayGroupId()));
+                procedureTrayService.list(Wraps.<BomProcedureTray>lbQ().eq(BomProcedureTray::getProcedureId,
+                        task.getProcedureId()));
         List<TTaskStockUniqueCode> stockUniqueCodeList = new ArrayList<TTaskStockUniqueCode>();
         TWorkpiece currWorkpiece = workpieceService.getWorkPiece(taskNode.getId());
         List<StockInfo> stockInfoList = this.getConnectTray(procedureTrayList, currWorkpiece.getIsReload());
@@ -1874,7 +1874,6 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
      * @param callBackJson
      */
     public R<String> demoLineStock(TaskNode taskNode, TTask task, JSONObject callBackJson, TWorkpiece currWorkpiece) {
-
         //没有回传参数,直接不需要出入库操作
         String stockType = callBackJson.getString(DemoLineConstant.DEMOLINE_STOCK_TYPE);
         //如果没有起始、终点,则不需要出入库处理
@@ -1923,8 +1922,21 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
             // 毛料出库
             if (meterialList != null && meterialList.size() > 0) {
 
+                //List<StockInfo> trayList = stockInfoService.list(new LbqWrapper<StockInfo>().eq(StockInfo::getStorgeId, ));
                 R<String> ckresult = stockInfoService.meterialStockOut(meterialList.get(0),
                         Long.parseLong(srcStorgeId), task.getCompleteBatchNo());
+
+                List<BomProcedureTray> trayList =
+                        procedureTrayService.list(Wraps.<BomProcedureTray>lbQ().eq(BomProcedureTray::getProcedureId,
+                                task.getProcedureId()).orderByAsc(BomProcedureTray::getBizType));
+                if (trayList != null && trayList.size() > 0) {
+                    //毛料出库 清空子盘工装的批次信息
+                    List<StockInfo> stockInfoList = this.getConnectTray(trayList, currWorkpiece.getIsReload());
+                    stockInfoList.stream().forEach(stockInfo -> {
+                        stockInfo.setCompleteBatchNo("");
+                    });
+                    stockInfoService.saveBatch(stockInfoList);
+                }
                 return ckresult;
             }
         }
@@ -1939,8 +1951,8 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
 
             }
             List<BomProcedureTray> trayList =
-                    procedureTrayService.list(Wraps.<BomProcedureTray>lbQ().eq(BomProcedureTray::getGroupId,
-                            task.getProcedureTrayGroupId()).orderByAsc(BomProcedureTray::getBizType));
+                    procedureTrayService.list(Wraps.<BomProcedureTray>lbQ().eq(BomProcedureTray::getProcedureId,
+                            task.getProcedureId()).orderByAsc(BomProcedureTray::getBizType));
             R<String> result = null;
             if (trayList != null && trayList.size() > 0) {
                 List<StockInfo> stockInfoList = this.getConnectTray(trayList, currWorkpiece.getIsReload());
@@ -1975,8 +1987,8 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
 //            List<BomProcedureTray> trayList = procedureTrayService.list(Wraps.<BomProcedureTray>lbQ().eq
 //            (BomProcedureTray::getId,task.ge()));
             List<BomProcedureTray> trayList =
-                    procedureTrayService.list(Wraps.<BomProcedureTray>lbQ().eq(BomProcedureTray::getGroupId,
-                            task.getProcedureTrayGroupId()).orderByAsc(BomProcedureTray::getBizType));
+                    procedureTrayService.list(Wraps.<BomProcedureTray>lbQ().eq(BomProcedureTray::getProcedureId,
+                            task.getProcedureId()).orderByAsc(BomProcedureTray::getBizType));
             R<String> result = null;
             if (trayList != null && trayList.size() > 0) {
                 List<StockInfo> stockInfoList = this.getConnectTray(trayList, currWorkpiece.getIsReload());
@@ -2005,8 +2017,8 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
                         ckresult.getData(), task.getCompleteBatchNo());
             }
             List<BomProcedureTray> trayList =
-                    procedureTrayService.list(Wraps.<BomProcedureTray>lbQ().eq(BomProcedureTray::getGroupId,
-                            task.getProcedureTrayGroupId()).orderByAsc(BomProcedureTray::getBizType));
+                    procedureTrayService.list(Wraps.<BomProcedureTray>lbQ().eq(BomProcedureTray::getProcedureId,
+                            task.getProcedureId()).orderByAsc(BomProcedureTray::getBizType));
             R<String> result = null;
             if (trayList != null && trayList.size() > 0) {
                 List<StockInfo> stockInfoList = this.getConnectTray(trayList, currWorkpiece.getIsReload());
@@ -2044,8 +2056,8 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
                         ckresult.getData(), task.getCompleteBatchNo());
             }
             List<BomProcedureTray> trayList =
-                    procedureTrayService.list(Wraps.<BomProcedureTray>lbQ().eq(BomProcedureTray::getGroupId,
-                            task.getProcedureTrayGroupId()).orderByAsc(BomProcedureTray::getBizType));
+                    procedureTrayService.list(Wraps.<BomProcedureTray>lbQ().eq(BomProcedureTray::getProcedureId,
+                            task.getProcedureId()).orderByAsc(BomProcedureTray::getBizType));
             R<String> result = null;
             if (trayList != null && trayList.size() > 0) {
                 List<StockInfo> stockInfoList = this.getConnectTray(trayList, currWorkpiece.getIsReload());
@@ -2087,8 +2099,8 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
             }
 
             List<BomProcedureTray> trayList =
-                    procedureTrayService.list(Wraps.<BomProcedureTray>lbQ().eq(BomProcedureTray::getGroupId,
-                            task.getProcedureTrayGroupId()).orderByAsc(BomProcedureTray::getBizType));
+                    procedureTrayService.list(Wraps.<BomProcedureTray>lbQ().eq(BomProcedureTray::getProcedureId,
+                            task.getProcedureId()).orderByAsc(BomProcedureTray::getBizType));
             R<String> result = null;
             if (trayList != null && trayList.size() > 0) {
                 List<StockInfo> stockInfoList = this.getConnectTray(trayList, currWorkpiece.getIsReload());
@@ -2778,9 +2790,9 @@ planId));
     private List<StockInfo> getConnectTray(List<BomProcedureTray> bomProcedureTrayList, int isReload){
         List<StockInfo> stockInfoList = null;
         List<Long> trayIds = bomProcedureTrayList.stream().map(tray->tray.getTrayId()).collect(Collectors.toList());
-        stockInfoList = stockInfoService.list(new LbqWrapper<StockInfo>().in(StockInfo::getGoodsId, trayIds).orderByAsc(StockInfo::getGoodsType));
+        stockInfoList = stockInfoService.list(new LbqWrapper<StockInfo>().in(StockInfo::getGoodsId, trayIds).in(StockInfo::getGoodsType, "1,2").last("limit 2").orderByAsc(StockInfo::getGoodsType));
 
-        if(CollectionUtil.isNotEmpty(stockInfoList) && stockInfoList.size()==2) {
+        if(CollectionUtil.isNotEmpty(stockInfoList)) {
             boolean bool = stockInfoList.get(0).getStorgeId().equals(stockInfoList.get(1).getStorgeId());
             if (!bool) {
                 //已经换装,以工装作为点位参考
@@ -2795,37 +2807,4 @@ planId));
         return stockInfoList;
     }
 
-    /**
-     * 立库获取终点位置,取空库位的数据
-     * @return
-     */
-    private long getLikuStockInList(){
-        List <StockInfo> returnList = null;
-
-        List<Productionresource> productionresources = productionresourceBizMapper.selectList(Wraps.<Productionresource>lbQ().like(Productionresource::getCode,DictionaryKey.YJ_ZONE_XBK.get("plateAndClamp")));
-        List<Long> productionresourceIds = productionresources.stream().map(t->t.getId()).collect(Collectors.toList());
-
-        if(CollectionUtil.isEmpty(productionresourceIds)){
-            return -1;
-        }
-        String resourceIds = "";
-        for(int i = 0; i < productionresourceIds.size(); i++){
-            if(i == productionresourceIds.size() - 1){
-                resourceIds = resourceIds + productionresourceIds.get(i);
-            }else{
-                resourceIds = resourceIds + productionresourceIds.get(i)+ ",";
-            }
-        }
-        Map queryMap = new HashMap();
-        queryMap.put("resourceIds",resourceIds);
-
-        // 判断夹具是否有可用的,查询330个库位信息中是否还有夹具
-
-        List<Long> allStockList = stockInfoMapper.getAvailableStorge(queryMap);
-        if(allStockList.size() > 0){
-            return allStockList.get(0);
-        }else{
-            return -1;
-        }
-    }
 }

+ 1 - 1
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionReadyCenter/service/impl/BomProcedureVersionServiceImpl.java

@@ -613,7 +613,7 @@ public class BomProcedureVersionServiceImpl extends SuperServiceImpl<BomProcedur
             // 来自上一工序
             // 查找上一个工序的托盘夹具
             BomProcedureVersion currBomProcedure = baseMapper.selectOne(Wraps.<BomProcedureVersion>lbQ().eq(BomProcedureVersion::getId,bean.getId()));
-            BomProcedureVersion preBomProcedure = baseMapper.selectOne(Wraps.<BomProcedureVersion>lbQ().eq(BomProcedureVersion::getBomId,currBomProcedure.getBomId()).gt(BomProcedureVersion::getSort,currBomProcedure.getSort()).orderByAsc(BomProcedureVersion::getSort).last("limit 1"));
+            BomProcedureVersion preBomProcedure = baseMapper.selectOne(Wraps.<BomProcedureVersion>lbQ().eq(BomProcedureVersion::getVersionId,currBomProcedure.getVersionId()).gt(BomProcedureVersion::getSort,currBomProcedure.getSort()).orderByAsc(BomProcedureVersion::getSort).last("limit 1"));
 
             BomProcedureTrayGroup preBomProcedureTrayGroup = bomProcedureTrayGroupService.getOne(Wraps.<BomProcedureTrayGroup>lbQ().eq(BomProcedureTrayGroup::getProcedureId,preBomProcedure.getId()));
             BomProcedureTrayGroup currGroupBean = new BomProcedureTrayGroup();

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

@@ -654,7 +654,7 @@ public class RobotNodeServiceImpl implements NodeOperationService {
                         // 查询机器人缓存位上面是否存在物料并且目标地址是否当前机器所在位子
                         List<ProductionresourcePosition> jrqHcwWorkpieceInfos = productionresourcePositionService.getFullProductionresourcePositionByIds(deviceArr);
                         List<Long> jrqHcwStorgeIds = jrqHcwWorkpieceInfos.stream().mapToLong(ProductionresourcePosition::getStorgeId).boxed().collect(Collectors.toList());
-                        List<Storge> jrqHcwStorges = storgeMapper.selectList(Wraps.<Storge>lbQ().in(Storge::getId,jrqHcwStorgeIds));
+                        List<Storge> jrqHcwStorges = jrqHcwStorgeIds.size()==0 ? new ArrayList<Storge>() : storgeMapper.selectList(Wraps.<Storge>lbQ().in(Storge::getId,jrqHcwStorgeIds));
                         log.info("节点{}当前缓存位数工件信息{}",taskNode.getId(),jrqHcwStorges.toString());
                         boolean hasJqrhcwPartFlag = false;
                         String jrqHcwPartPoint =  msgUtil.redis_get(deviceArr[0] + "postion") == null ? "": String.valueOf(msgUtil.redis_get(deviceArr[0] + "postion"));