From ad2697fec86e0bfcc6e3ba20af7f973ccbb5abe7 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期二, 12 一月 2021 16:12:22 +0800
Subject: [PATCH] #物料

---
 src/main/java/com/zy/core/thread/SiemensCrnThread.java |   94 +++++++++++-----------------------------------
 1 files changed, 23 insertions(+), 71 deletions(-)

diff --git a/src/main/java/com/zy/core/thread/SiemensCrnThread.java b/src/main/java/com/zy/core/thread/SiemensCrnThread.java
index fb5bced..77fbbc0 100644
--- a/src/main/java/com/zy/core/thread/SiemensCrnThread.java
+++ b/src/main/java/com/zy/core/thread/SiemensCrnThread.java
@@ -243,72 +243,15 @@
             log.error("鍫嗗灈鏈哄啓鍏ュ懡浠や负绌�");
             return false;
         }
-        if (command.getTaskNo() == 0) {
+        if (command.getTaskNo() == 0 && command.getAckFinish() == 0) {
             command.setTaskNo((short) 9999);
-        }
-        // 浠g悊
-        switch (command.getSourcePosX()) {
-            case 1:
-                command.setSourcePosX((short) 4);
-                break;
-            case 2:
-                command.setSourcePosX((short) 3);
-                break;
-            case 3:
-                command.setSourcePosX((short) 2);
-                break;
-            case 4:
-                command.setSourcePosX((short) 1);
-                break;
-            case 5:
-                command.setSourcePosX((short) 4);
-                break;
-            case 6:
-                command.setSourcePosX((short) 3);
-                break;
-            case 7:
-                command.setSourcePosX((short) 2);
-                break;
-            case 8:
-                command.setSourcePosX((short) 1);
-                break;
-            default:
-                log.info("{}鍙峰爢鍨涙満涓嬫柟鍛戒护閿欒锛屾簮鎺掞細{}", command.getCrnNo(), command.getSourcePosX());
-        }
-        switch (command.getDestinationPosX()) {
-            case 1:
-                command.setDestinationPosX((short) 4);
-                break;
-            case 2:
-                command.setDestinationPosX((short) 3);
-                break;
-            case 3:
-                command.setDestinationPosX((short) 2);
-                break;
-            case 4:
-                command.setDestinationPosX((short) 1);
-                break;
-            case 5:
-                command.setDestinationPosX((short) 4);
-                break;
-            case 6:
-                command.setDestinationPosX((short) 3);
-                break;
-            case 7:
-                command.setDestinationPosX((short) 2);
-                break;
-            case 8:
-                command.setDestinationPosX((short) 1);
-                break;
-            default:
-                log.info("{}鍙峰爢鍨涙満涓嬫柟鍛戒护閿欒锛岀洰鏍囨帓锛歿}", command.getCrnNo(), command.getSourcePosX());
         }
         command.setCrnNo(slave.getId());
         short[] array = new short[9];
-        if (!command.getTaskModeType().equals(CrnTaskModeType.CLEAR)) {
+        if (command.getAckFinish() == 0) {
             array[0] = 5;
         } else {
-            array[0] = 7;
+            array[0] = 0;
         }
         array[1] = command.getSourcePosZ();
         array[2] = command.getSourcePosY();
@@ -319,15 +262,21 @@
         array[7] = command.getSourceStaNo();
         array[8] = command.getDestinationStaNo();
         // 浣滀笟淇℃伅
-        OperateResult result = siemensNet.Write("DB10.0", array);
-        // 浠诲姟鍙�
-        OperateResult result1 = siemensNet.Write("DB10.24", command.getTaskNo());
-        // 缁撴潫浣�
-        OperateResult result2 = siemensNet.Write("DB10.28.1", true);
-        if (result.IsSuccess && result1.IsSuccess && result2.IsSuccess) {
+        OperateResult result = siemensNet.Write("DB1000.0", array);
+        // 浠诲姟鍙� + 瀹屾垚浣�
+        short[] array2 = new short[2];
+        array2[0] = command.getTaskNo();
+        array2[1] = command.getAckFinish();
+        OperateResult result1 = siemensNet.Write("DB1000.24", array2);
 
-            try {
-                // 鏃ュ織璁板綍
+        // 缁撴潫浣�
+        if (command.getAckFinish() == 0) {
+            OperateResult result2 = siemensNet.Write("DB1000.28.1", true);
+        }
+
+        // 鏃ュ織璁板綍
+        try {
+            if (command.getAckFinish() != 1) {
                 BasCrnOptService bean = SpringUtils.getBean(BasCrnOptService.class);
                 BasCrnOpt basCrnOpt = new BasCrnOpt(
                         command.getTaskNo().intValue(),    // 浠诲姟鍙�
@@ -337,17 +286,20 @@
                         command.getSourcePosX().intValue(),    // 婧愭帓
                         command.getSourcePosY().intValue(),    // 婧愬垪
                         command.getSourcePosZ().intValue(),    // 婧愬眰
-                        command.getSourceStaNo().intValue(),    // 婧愮珯
+                        null,    // 婧愮珯
                         command.getDestinationPosX().intValue(),    // 鐩爣鎺�
                         command.getDestinationPosY().intValue(),    // 鐩爣鍒�
                         command.getDestinationPosZ().intValue(),    // 鐩爣灞�
-                        command.getDestinationStaNo().intValue(),    // 鐩爣绔�
+                        null,    // 鐩爣绔�
                         null,    // 鍝嶅簲缁撴灉
                         null,    // 淇敼鏃堕棿
                         null    // 淇敼浜哄憳
                 );
                 bean.insert(basCrnOpt);
-            } catch (Exception ignore) {}
+            }
+        } catch (Exception ignore) {}
+
+        if (result.IsSuccess && result1.IsSuccess) {
 
             log.info("鍫嗗灈鏈哄懡浠や笅鍙慬id:{}] >>>>> {}", slave.getId(), JSON.toJSON(command));
             OutputQueue.CRN.offer(MessageFormat.format("銆恵0}銆慬id:{1}] >>>>> 鍛戒护涓嬪彂锛� {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(command)));

--
Gitblit v1.9.1