Browse Source

bug修复

wudingsheng 3 tháng trước cách đây
mục cha
commit
90ee629f73

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

@@ -364,6 +364,99 @@ public class MachineNodeServiceImpl implements NodeOperationService {
                      map.put("result", true);
                  }
 
+                break;
+            case "smu50":
+                Productionresource productionresource2 =  productionresourceBizMapper.selectOne(Wraps.<Productionresource>lbQ().eq(Productionresource::getId,taskNode.getTargetResourceId()));
+                map.put("url",productionresource2.getIp());
+                map.put("port",productionresource2.getPort());
+                if ("1".equals(functionType)) {
+                    //程序文件上传
+                    List<BomProcedureProgram>procedureProgramList = bomProcedureProgramMapper.selectList(Wraps.<BomProcedureProgram>lbQ().eq(BomProcedureProgram::getProcedureId,task.getProcedureId()));
+
+                    List<Map<String, String>> fileList = new ArrayList<Map<String, String>>();
+                    if (procedureProgramList != null && procedureProgramList.size() > 0) {
+                        //文件上传只允许单个文件
+                        procedureProgramList.forEach(i -> {
+                            Map<String, String> m = new HashMap<>();
+                            String filePath = i.getFilePath().replace(uriPath, storagePath);
+                            m.put("fileName", filePath.replace("/", "\\"));
+                            fileList.add(m);
+                        });
+                        //map.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "uploadProgram");
+                        map.put("method", "UploadFile");
+                        JSONObject data = new JSONObject();
+                        data.put("fileName", fileList.get(0).get("fileName"));
+                        msgUtil.redis_set("UploadFile_Path"+"_"+task.getId(), uriPath+","+storagePath+","+fileList.get(0).get("fileName"), 1, TimeUnit.DAYS);
+                        Module module  = moduleService.getOne(new LbqWrapper<Module>().eq(Module::getId, productionresource2.getModuleId()));
+                        data.put("remotePath", module.getCncFilePath());
+                        //msgUtil.redis_set(DemoCacheKey.DEMOLINE_PROGRAME_NAMES + task.getCompleteBatchNo(), fileName, 1, TimeUnit.DAYS);
+                        /*if(productionresource.getModeSpecification().contains("HEIDENHAIN")){
+                            //缓存程序编号信息
+                            JSONObject uploadInfo = new JSONObject();
+                            uploadInfo.put("url",  productionresource.getIp());
+                            uploadInfo.put("port", productionresource.getPort());
+                            uploadInfo.put("data", data);
+                            msgUtil.redis_set(DemoLineConstant.DEMOLINE_HEIDENHAIN_FILE_URL+"_"+task.getId(), uploadInfo.toJSONString(), 30, TimeUnit.DAYS);
+                            data.put("fileName", "");
+                        }
+
+                        if(productionresource.getModeSpecification().contains("HELLER"))  data.put("HELLER","HELLER"); //内部调用标识*/
+                        map.put("data", data);
+                        map.put("result", true);
+                    }
+                }
+                else if ("2".equals(functionType)) {
+                    if("执行清洗".equals(taskNode.getNodeName())){
+                        map.put("method", "StartCleanMachine");
+                        map.put("url",plcInfo.get("url"));
+                        map.put("port",plcInfo.get("port"));
+                        map.put("result", true);
+                        map.remove("data");
+                    }else{
+                        //执行加工程序,分多次执行
+                        //String zoneNo = msgUtil.redis_get(DemoCacheKey.DEMOLINE_WORKOP_ZONE + task.getCompleteBatchNo()) == null ? ""
+                        //       : msgUtil.redis_get(DemoCacheKey.DEMOLINE_WORKOP_ZONE + task.getCompleteBatchNo()).toString();
+                        //map.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "execProgram");
+                        //当前执行数量
+                        //String fileName = msgUtil.redis_get(DemoCacheKey.DEMOLINE_PROGRAME_NAMES + task.getCompleteBatchNo()) == null ? "" : msgUtil.redis_get(DemoCacheKey.DEMOLINE_PROGRAME_NAMES + task.getCompleteBatchNo()).toString();
+                        List<BomProcedureProgram> procedureProgramList = bomProcedureProgramMapper.selectList(Wraps.<BomProcedureProgram>lbQ().eq(BomProcedureProgram::getProcedureId,task.getProcedureId()));
+                        //执行程序默认按单文件处理
+                        //String fileName = "";
+                        //String fileNames[] = fileName.split(",");
+                        JSONObject data = new JSONObject();
+                        data.put("remotePath", procedureProgramList.get(0).getSubmittedFileName());
+
+                        map.put("data", data);
+                        map.put("method", "StartNCProgram");
+                        map.put("result", true);
+                    }
+                }
+                else if ("3".equals(functionType)){
+                    // 加工前写入工件坐标系 根据taskid查找工件三坐标测量的工件坐标系,可能存在装夹一次未果的情况,所以取最后一条数据
+                    // TODO 工件坐标系根据机场不同系统,不同通讯协议调用不同的接口
+                    OrderQuality orderQuality = orderQualityMapper.selectOne(Wraps.<OrderQuality>lbQ().eq(OrderQuality::getProcedureId,task.getProcedureId()).eq(OrderQuality::getWorkpieceId,task.getCompleteBatchNo()));
+                    if(null == orderQuality){
+                        // 简单处理的方式,直接将坐标偏移全部设置成0
+                        queryMap.put("x", "0");
+                        queryMap.put("y", "0");
+                        queryMap.put("z", "0");
+                        queryMap.put("a", "0");
+                        queryMap.put("b", "0");
+                        queryMap.put("c", "0");
+                    }else{
+                        queryMap.put("x", String.valueOf(orderQuality.getSketchyXaxisOffset()));
+                        queryMap.put("y", String.valueOf(orderQuality.getSketchyYaxisOffset()));
+                        queryMap.put("z", String.valueOf(orderQuality.getSketchyZaxisOffset()));
+                        queryMap.put("a", String.valueOf(orderQuality.getSketchyAaxisOffset()));
+                        queryMap.put("b", String.valueOf(orderQuality.getSketchyBaxisOffset()));
+                        queryMap.put("c", String.valueOf(orderQuality.getSketchyCaxisOffset()));
+                    }
+
+                    map.put("method", "SendLinShift");
+                    map.put("data", queryMap);
+                    map.put("result", true);
+                }
+
                 break;
             case "smg80":
                 Productionresource productionresource1 =  productionresourceBizMapper.selectOne(Wraps.<Productionresource>lbQ().eq(Productionresource::getId,taskNode.getTargetResourceId()));

+ 26 - 22
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionResourceCenter/strategy/impl/CacheRobotStrategy.java

@@ -46,10 +46,7 @@ import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
@@ -200,21 +197,26 @@ public class CacheRobotStrategy implements RobotStrategy {
                 returnMap.put("result", false);
             }
             Object jqrPriotyFlag = msgUtil.redis_get(DemoLineConstant.JQR_HCW_PART_PRIOTY_EXEC_FLAG + taskNode.getId());
-            if(ObjectUtil.isNotEmpty(jqrPriotyFlag)){
+            if (ObjectUtil.isNotEmpty(jqrPriotyFlag)) {
                 returnMap.put("result", false);
                 return returnMap;
             }
-
-            TWorkpiece workpiece = workpieceList.stream().filter(item->!item.getTaskNodeId().equals(taskNode.getId())).collect(Collectors.toList()).get(0);
-            Object hcwStorgeFlag = msgUtil.redis_get(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_HCW_XBK_FLAG + workpiece.getTaskNodeId());
-            if(ObjectUtil.isEmpty(hcwStorgeFlag)){
-                Object hcwPriotyFlag = msgUtil.redis_get(DemoLineConstant.JQR_HCW_PART_PRIOTY_EXEC_FLAG + workpiece.getTaskNodeId());
-                TTask task = taskService.getById(taskNode.getTaskId());
-                //判断交换位目标设备是否与暂存位任务设备一致
-                if(ObjectUtil.isEmpty(hcwPriotyFlag) && taskNode.getTargetResourceId().equals(task.getResourceId())) {
-                    msgUtil.redis_set(DemoLineConstant.JQR_HCW_PART_PRIOTY_EXEC_FLAG + workpiece.getTaskNodeId(), "1");
-                    returnMap.put("result", false);
-                    return returnMap;
+            Optional<TWorkpiece> optionalWorkpiece = workpieceList.stream()
+                    .filter(item -> !item.getTaskNodeId().equals(taskNode.getId()))
+                    .findFirst();
+            //TWorkpiece workpiece = workpieceList.stream().filter(item->!item.getTaskNodeId().equals(taskNode.getId())).collect(Collectors.toList()).get(0);
+            if (optionalWorkpiece.isPresent()) {
+                TWorkpiece workpiece = optionalWorkpiece.get();
+                Object hcwStorgeFlag = msgUtil.redis_get(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_HCW_XBK_FLAG + workpiece.getTaskNodeId());
+                if (ObjectUtil.isEmpty(hcwStorgeFlag)) {
+                    Object hcwPriotyFlag = msgUtil.redis_get(DemoLineConstant.JQR_HCW_PART_PRIOTY_EXEC_FLAG + workpiece.getTaskNodeId());
+                    TTask task = taskService.getById(taskNode.getTaskId());
+                    //判断交换位目标设备是否与暂存位任务设备一致
+                    if (ObjectUtil.isEmpty(hcwPriotyFlag) && taskNode.getTargetResourceId().equals(task.getResourceId())) {
+                        msgUtil.redis_set(DemoLineConstant.JQR_HCW_PART_PRIOTY_EXEC_FLAG + workpiece.getTaskNodeId(), "1");
+                        returnMap.put("result", false);
+                        return returnMap;
+                    }
                 }
             }
         }
@@ -254,12 +256,14 @@ public class CacheRobotStrategy implements RobotStrategy {
             //已在暂存位上工装没有暂存位缓存时限制正常接入
             ProductionresourcePosition hcwStorgePosition = productionresourcePositionService.getOne(new LbqWrapper<ProductionresourcePosition>().eq(ProductionresourcePosition::getResourceId, taskNode.getResourceId()).ne(ProductionresourcePosition::getPointId, DemoLineConstant.DEMOLINE_RJQR_ZS).ne(ProductionresourcePosition::getStorgeId, hcwStorge.getId()).last("limit 1"));
             TWorkpiece tWorkpiece = workpieceService.getOne(new LbqWrapper<TWorkpiece>().eq(TWorkpiece::getIsEnd, "0").eq(TWorkpiece::getStorgeId, hcwStorgePosition.getStorgeId()).last("limit 1"));
-            Object preHcwXbkFlag = msgUtil.redis_get(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_HCW_XBK_FLAG + tWorkpiece.getTaskNodeId());
-            if(ObjectUtil.isEmpty(preHcwXbkFlag)){
-                returnMap.put("msg", "已暂存位工装数据无缓存数据");
-                returnMap.put("result", false);
-                taskNodeService.freeLock(taskNode.getCompleteBatchNo());
-                return returnMap;
+            if(tWorkpiece!=null){
+                Object preHcwXbkFlag = msgUtil.redis_get(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_HCW_XBK_FLAG + tWorkpiece.getTaskNodeId());
+                if(ObjectUtil.isEmpty(preHcwXbkFlag)){
+                    returnMap.put("msg", "已暂存位工装数据无缓存数据");
+                    returnMap.put("result", false);
+                    taskNodeService.freeLock(taskNode.getCompleteBatchNo());
+                    return returnMap;
+                }
             }
             targetStorge = hcwStorge;
             returnMap.put(YunjianConstant.YUNJIAN_XBKFLAG, "1");