浏览代码

bug修复

hecheng 3 年之前
父节点
当前提交
a109966ce1

+ 4 - 0
zd-modules/zd-netty/src/main/java/com/zd/netty/constant/RfidConstants.java

@@ -14,6 +14,10 @@ public class RfidConstants{
         throw new IllegalStateException("RfidConstants class");
     }
 
+    public static final String ALL_TYPE="0";
+    public static final String BOTTLE_TYPE="1";
+    public static final String CHEMICAL_TYPE="2";
+
 
     static final List<Map<Integer,String>> LIST =new ArrayList<>();
 

+ 20 - 14
zd-modules/zd-netty/src/main/java/com/zd/netty/service/impl/SendServiceImpl.java

@@ -7,9 +7,12 @@ import com.zd.system.api.domain.InventoryTag;
 import com.zd.system.api.laboratory.domain.RemoteLabHardware;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
 
 import javax.annotation.Resource;
 
+import static com.zd.netty.constant.RfidConstants.*;
+
 @Slf4j
 @Service(value = "sendService")
 public class SendServiceImpl implements ISendService {
@@ -28,10 +31,7 @@ public class SendServiceImpl implements ISendService {
             int antId = tag.getAntId();
             String uniformPower = hardware.getUniformPower();
             String[] uniformPowers = uniformPower.split(",");
-            Integer channels = hardware.getChannels();
-            for (int i = 1; i <= channels; i++) {
-                handleTag(tag, antId, uniformPowers, i);
-            }
+            handleTag(tag, antId, uniformPowers);
         } else {
             try {
                 bottleService.remoteAdd(tag);
@@ -46,23 +46,29 @@ public class SendServiceImpl implements ISendService {
         }
     }
 
-    private void handleTag(InventoryTag tag, int antId, String[] uniformPowers, int i) {
+    private void handleTag(InventoryTag tag, int antId, String[] uniformPowers) {
         // 判断有设备配置和触发的天线编码等与配置天线编号
-        if (uniformPowers.length > 0 && antId == i + 1) {
+        if (uniformPowers.length > 0) {
             String tempUniformPower = uniformPowers[antId - 1];
-            String[] tempUniformPowers = tempUniformPower.split(":");
-            if (tempUniformPowers.length > 1) {
-                String temp = tempUniformPowers[1];
-                if ("0".equals(temp) || "1".equals(temp)) {
-                    bottleService.remoteAdd(tag);
-                }
-                if ("0".equals(temp) || "2".equals(temp)) {
-                    remoteStockService.rfidCheck(tag);
+            if (StringUtils.hasLength(tempUniformPower)) {
+                String[] tempUniformPowers = tempUniformPower.split(":");
+                if (tempUniformPowers.length > 1) {
+                    String temp = tempUniformPowers[1];
+                    sendTag(tag, temp);
                 }
             }
         }
     }
 
+    private void sendTag(InventoryTag tag, String temp) {
+        if (ALL_TYPE.equals(temp) || BOTTLE_TYPE.equals(temp)) {
+            bottleService.remoteAdd(tag);
+        }
+        if (ALL_TYPE.equals(temp) || CHEMICAL_TYPE.equals(temp)) {
+            remoteStockService.rfidCheck(tag);
+        }
+    }
+
     @Override
     public void sendError(String msg) {
         log.info(msg);