From 69cd9f59a0fabf12f8c9147fcba7f69817a870b3 Mon Sep 17 00:00:00 2001
From: jiazx0107@163.com <jiazx0107@163.com>
Date: 星期一, 06 十一月 2023 23:40:59 +0800
Subject: [PATCH] 更新仓内抓拍2

---
 igds-inout/src/main/java/com/ld/igds/inout/manager/InoutEventControlManager.java |  331 +++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 225 insertions(+), 106 deletions(-)

diff --git a/igds-inout/src/main/java/com/ld/igds/inout/manager/InoutEventControlManager.java b/igds-inout/src/main/java/com/ld/igds/inout/manager/InoutEventControlManager.java
index c4c35af..cf0c7a3 100644
--- a/igds-inout/src/main/java/com/ld/igds/inout/manager/InoutEventControlManager.java
+++ b/igds-inout/src/main/java/com/ld/igds/inout/manager/InoutEventControlManager.java
@@ -10,6 +10,7 @@
 import com.ld.igds.file.CoreFileService;
 import com.ld.igds.inout.ApiInoutManager;
 import com.ld.igds.inout.ApiInoutService;
+import com.ld.igds.inout.InoutApiConstant;
 import com.ld.igds.inout.InoutConstant;
 import com.ld.igds.inout.dto.*;
 import com.ld.igds.inout.service.InoutService;
@@ -28,7 +29,6 @@
 import org.springframework.stereotype.Component;
 
 import javax.annotation.Resource;
-import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 
@@ -68,20 +68,16 @@
 
         //濡傛灉浣跨敤鐨勬槸鍦扮鎻掍欢鑾峰彇锛屽垯闇�瑕佽皟鏁磋澶囦负鍦扮鎻掍欢淇℃伅
         if (ProtocolEnum.TCP_FZZY_WEIGHT.getCode().equals(param.getProtocol())) {
-
             InoutConf conf = this.getInoutConf(param.getCompanyId(), param.getDeptId(), param.getSort(), InoutConstant.CONF_TYPE_70);
             if (null == conf) {
                 param.setErrorMsg("娌℃湁鑾峰彇鍒板綋鍓嶅崗璁彃浠堕厤缃厤缃俊鎭紝鑾峰彇澶辫触");
                 return param;
             }
-
-
             param.setIp(conf.getIp());
             param.setPort(conf.getPort());
             param.setProtocol(conf.getProtocol());
 
             return apiInoutManager.getApiService(param.getProtocol()).getPlateNum(param);
-
         }
 
         return apiInoutManager.getApiService(param.getProtocol()).getPlateNum(param);
@@ -95,6 +91,20 @@
      * @return
      */
     public ApiInoutData getIcCardNum(ApiInoutData param) {
+
+        //濡傛灉浣跨敤鐨勬槸鍦扮鎻掍欢鑾峰彇锛屽垯闇�瑕佽皟鏁磋澶囦负鍦扮鎻掍欢淇℃伅
+        if (ProtocolEnum.TCP_FZZY_WEIGHT.getCode().equals(param.getProtocol())) {
+            InoutConf conf = this.getInoutConf(param.getCompanyId(), param.getDeptId(), param.getSort(), InoutConstant.CONF_TYPE_70);
+            if (null == conf) {
+                param.setErrorMsg("娌℃湁鑾峰彇鍒板綋鍓嶅崗璁彃浠堕厤缃厤缃俊鎭紝鑾峰彇澶辫触");
+                return param;
+            }
+            param.setIp(conf.getIp());
+            param.setPort(conf.getPort());
+            param.setProtocol(conf.getProtocol());
+
+            return apiInoutManager.getApiService(param.getProtocol()).getIcCardNum(param);
+        }
 
         return apiInoutManager.getApiService(param.getProtocol()).getIcCardNum(param);
     }
@@ -116,27 +126,7 @@
     }
 
 
-    /**
-     * @param param
-     * @return
-     */
-    public String noticeWeightDone(ApiInoutData param) {
-        //鑾峰彇绉伴噸涓绘帶鍣ㄩ厤缃�
-        InoutConf conf = getWeightGateway(param.getCompanyId(), param.getDeptId(), param.getSort());
 
-        if (null == conf) {
-            return "绉伴噸涓绘帶鏈厤缃紝鏀寔澶辫触";
-        }
-
-        ApiInoutData apiData = new ApiInoutData(conf);
-        apiData.setPlateNum(param.getPlateNum());
-        apiData.setTime(new Date());
-
-        ApiInoutService inoutApiService = apiInoutManager.getApiService(conf.getProtocol());
-
-        // return inoutApiService.noticeWeightDone(apiData); TODO
-        return null;
-    }
 
     /**
      * 鍑哄叆搴撴姄鎷�
@@ -174,73 +164,73 @@
      *
      * @param snapImgDto
      */
-    private void noticeGatewayWeightInfo(SnapImgDto snapImgDto) {
-
-        log.debug("-------------鐢ㄦ埛纭绉伴噸----閫氱煡绉伴噸缃戝叧----{}", snapImgDto.getWeight());
-        InoutConf conf = this.getWeightGateway(snapImgDto.getCompanyId(), snapImgDto.getDeptId(), snapImgDto.getSort());
-
-        if (null == conf) {
-            log.info("-------------鐢ㄦ埛纭绉伴噸----閫氱煡绉伴噸缃戝叧---鏈厤缃綉鍏�----");
-            return;
-        }
-
-        ApiInoutData apiData = new ApiInoutData(conf);
-        apiData.setTime(new Date());
-        apiData.setRepeat(2);
-        apiData.setWeight(snapImgDto.getWeight());
-        apiData.setPlateNum(snapImgDto.getPlateNum());
-        //绉伴噸淇℃伅鏆傛椂鍙栨秷鎾斁
-//        apiData.setMsg("褰撳墠绉伴噸锛�" + apiData.getWeight() + "鍗冨厠");
-        apiData.setMsg("绉伴噸宸插畬鎴�");
-
-//        apiInoutManager.getApiService(apiData.getProtocol()).noticeWeightDone(apiData);
-      //  apiInoutManager.getApiService(apiData.getProtocol()).noticeRadio(apiData);
-    }
+//    private void noticeGatewayWeightInfo(SnapImgDto snapImgDto) {
+//
+//        log.debug("-------------鐢ㄦ埛纭绉伴噸----閫氱煡绉伴噸缃戝叧----{}", snapImgDto.getWeight());
+//        InoutConf conf = this.getWeightGateway(snapImgDto.getCompanyId(), snapImgDto.getDeptId(), snapImgDto.getSort());
+//
+//        if (null == conf) {
+//            log.info("-------------鐢ㄦ埛纭绉伴噸----閫氱煡绉伴噸缃戝叧---鏈厤缃綉鍏�----");
+//            return;
+//        }
+//
+//        ApiInoutData apiData = new ApiInoutData(conf);
+//        apiData.setTime(new Date());
+//        apiData.setRepeat(2);
+//        apiData.setWeight(snapImgDto.getWeight());
+//        apiData.setPlateNum(snapImgDto.getPlateNum());
+//        //绉伴噸淇℃伅鏆傛椂鍙栨秷鎾斁
+////        apiData.setMsg("褰撳墠绉伴噸锛�" + apiData.getWeight() + "鍗冨厠");
+//        apiData.setMsg("绉伴噸宸插畬鎴�");
+//
+////        apiInoutManager.getApiService(apiData.getProtocol()).noticeWeightDone(apiData);
+//        //  apiInoutManager.getApiService(apiData.getProtocol()).noticeRadio(apiData);
+//    }
 
     /**
      * 鏂板鐧藉悕鍗曠粰浣忔帶鍒跺櫒锛岄渶瑕佹敞鎰忕殑鏄紝鐧昏鏃跺�欎笉纭浣跨敤鍝釜鍦扮绯荤粺锛屽鏋滅郴缁熼厤缃涓富鎺у櫒锛岄渶瑕佸悓姝ュ叏閮ㄦ帹閫�
      *
      * @param imgDto
      */
-    private void noticeGatewayAddWhitePlate(SnapImgDto imgDto) {
+//    private void noticeGatewayAddWhitePlate(SnapImgDto imgDto) {
+//
+//        List<InoutConf> list = this.getWeightGateway(imgDto.getCompanyId(), imgDto.getDeptId());
+//
+//        if (null == list || list.isEmpty()) {
+//            log.info("-------------绉伴噸缃戝叧澧炲姞鐧藉悕鍗�----娌℃湁鑾峰彇鍒扮綉鍏抽厤缃�-----鍙栨秷鎵ц---");
+//            return;
+//        }
+//
+//        log.debug("-------------鐧昏瀹屾垚锛屽鍔犺溅鐗岀櫧鍚嶅崟-----------{}", imgDto.getPlateNum());
+//
+//        ApiInoutService inoutApiService = apiInoutManager.getApiService(list.get(0).getProtocol());
+//
+//        ApiInoutData apiData;
+//        for (InoutConf conf : list) {
+//            apiData = new ApiInoutData(conf);
+//            apiData.setPlateNum(imgDto.getPlateNum());
+//            // inoutApiService.addWhitePlate(apiData);
+//        }
+//    }
 
-        List<InoutConf> list = this.getWeightGateway(imgDto.getCompanyId(), imgDto.getDeptId());
-
-        if (null == list || list.isEmpty()) {
-            log.info("-------------绉伴噸缃戝叧澧炲姞鐧藉悕鍗�----娌℃湁鑾峰彇鍒扮綉鍏抽厤缃�-----鍙栨秷鎵ц---");
-            return;
-        }
-
-        log.debug("-------------鐧昏瀹屾垚锛屽鍔犺溅鐗岀櫧鍚嶅崟-----------{}", imgDto.getPlateNum());
-
-        ApiInoutService inoutApiService = apiInoutManager.getApiService(list.get(0).getProtocol());
-
-        ApiInoutData apiData;
-        for (InoutConf conf : list) {
-            apiData = new ApiInoutData(conf);
-            apiData.setPlateNum(imgDto.getPlateNum());
-            // inoutApiService.addWhitePlate(apiData);
-        }
-    }
-
-    public void noticeProgressComplete(InoutData data) {
-        log.debug("-----------------閫氱煡绉伴噸涓绘帶--------娴佺▼缁撴潫鍒犻櫎鐧藉悕鍗�");
-        List<InoutConf> list = this.getWeightGateway(data.getCompanyId(), data.getDeptId());
-
-        if (null == list || list.isEmpty()) {
-            return;
-        }
-
-        ApiInoutService inoutApiService = apiInoutManager.getApiService(list.get(0).getProtocol());
-
-        ApiInoutData apiData;
-        for (InoutConf conf : list) {
-            apiData = new ApiInoutData(conf);
-            apiData.setPlateNum(data.getPlateNum());
-
-            // inoutApiService.delWhitePlate(apiData); TODO
-        }
-    }
+//    public void noticeProgressComplete(InoutData data) {
+//        log.debug("-----------------閫氱煡绉伴噸涓绘帶--------娴佺▼缁撴潫鍒犻櫎鐧藉悕鍗�");
+//        List<InoutConf> list = this.getWeightGateway(data.getCompanyId(), data.getDeptId());
+//
+//        if (null == list || list.isEmpty()) {
+//            return;
+//        }
+//
+//        ApiInoutService inoutApiService = apiInoutManager.getApiService(list.get(0).getProtocol());
+//
+//        ApiInoutData apiData;
+//        for (InoutConf conf : list) {
+//            apiData = new ApiInoutData(conf);
+//            apiData.setPlateNum(data.getPlateNum());
+//
+//            // inoutApiService.delWhitePlate(apiData); TODO
+//        }
+//    }
 
     /**
      * 璋冪敤鎺ュ彛杩涜鎶撴媿
@@ -266,6 +256,10 @@
         req.setPlayType(conf.getPlayType());
         req.setSerSn(null == snapSer ? null : snapSer.getSn());
         req.setBizId(param.getBizId());
+        //鑻ヤ负鍑哄叆搴撶О閲嶆姄鎷嶏紝鍒欎笉浼犻�掍笟鍔′富閿�傚湪鍑哄叆搴撲笟鍔℃彁浜ゆ椂淇濆瓨鏂囦欢淇℃伅
+        if(InoutConstant.PROGRESS_WEIGHT_TAG.equals(conf.getInoutProgress())){
+            req.setBizId(null);
+        }
         req.setCameraName(conf.getName());
 
         req.setMediaAddr(CameraUtil.updateMediaAddr(conf.getMediaAddr(), conf.getLoginId(),
@@ -361,26 +355,6 @@
         return inoutCommonService.getCacheInoutConf(ContextUtil.getCompanyId(), ContextUtil.subDeptId(null), id);
     }
 
-
-    /**
-     * @Desc: 鑾峰彇绉伴噸缃戝叧璁惧
-     * @author: Andy
-     * @update-time: 2022/11/26
-     */
-    public List<InoutConf> getWeightGateway(String companyId, String deptId) {
-        List<InoutConf> list = inoutCommonService.getCacheInoutConf(companyId, deptId);
-        if (null == list || list.isEmpty()) return null;
-
-        List<InoutConf> result = new ArrayList<>();
-
-        for (InoutConf conf : list) {
-            if (InoutConstant.CONF_TYPE_70.equals(conf.getType())) {
-                result.add(conf);
-            }
-        }
-        return result;
-    }
-
     /**
      * @Desc: 鑾峰彇绉伴噸缃戝叧璁惧
      * @author: Andy
@@ -398,6 +372,80 @@
         }
         return null;
     }
+
+
+    /**
+     * 琚姩鏀跺埌杞︾墝璇嗗埆缁撴灉锛屼簨浠�
+     *
+     * @param data
+     */
+    @Async
+    public void onReceivePlateNum(ApiInoutData data) {
+
+        InoutConf conf = this.getInoutConfBySn(data.getCompanyId(), data.getDeptId(), data.getSn());
+        if (null == conf) {
+            log.error("娌℃湁鑾峰彇鍒板嚭鍏ュ簱閰嶇疆CONF锛�"+data.toString());
+            return;
+        }
+        log.info(conf.toString());
+        if (0 == conf.getInOrder()) return;
+
+        data = new ApiInoutData(conf);
+        log.info(data.toString());
+        ApiInoutService inoutApiService = null;
+        InoutConf gateconf = null;
+        //鑾峰彇杞︾墝淇℃伅锛屽紑闂告満
+        if (InoutApiConstant.DEVICE_CODE_1002 == data.getDeviceCode()) {
+            gateconf = this.getWeightGateway(data.getCompanyId(), data.getDeptId(), null);
+            if (null == gateconf) {
+                log.info("----------娌℃湁鑾峰彇鍒扮О閲嶆帶鍒跺櫒--------------");
+            }
+            data = new ApiInoutData(gateconf);
+            //寮�鍏ュ彛澶勯亾闂�
+            inoutApiService = apiInoutManager.getApiService(gateconf.getProtocol());
+            data.setDeviceCode(InoutApiConstant.DEVICE_CODE_2002);
+            data.setActionCode(InoutApiConstant.ACTION_CODE_1);
+            inoutApiService.gateControl(data);
+        }
+
+        if (InoutApiConstant.DEVICE_CODE_1003 == data.getDeviceCode()) {
+            gateconf = this.getWeightGateway(data.getCompanyId(), data.getDeptId(), null);
+            if (null == gateconf) {
+                log.info("----------娌℃湁鑾峰彇鍒扮О閲嶆帶鍒跺櫒--------------");
+            }
+            //寮�鍏ュ彛澶勯亾闂�
+            data = new ApiInoutData(gateconf);
+            inoutApiService = apiInoutManager.getApiService(gateconf.getProtocol());
+            data.setDeviceCode(InoutApiConstant.DEVICE_CODE_2003);
+            data.setActionCode(InoutApiConstant.ACTION_CODE_1);
+            inoutApiService.gateControl(data);
+        }
+
+    }
+
+    /**
+     * 鍑哄叆搴撶О閲嶉〉闈㈠垵濮嬪寲锛屽鏋滄湁SDK杞︾墝璇嗗埆锛岄渶瑕佽繘琛屽垵濮嬪寲鎿嶄綔
+     *
+     * @param listInoutConf
+     * @param sort
+     */
+    @Async
+    public void initInoutWeight(List<InoutConf> listInoutConf, String sort) {
+
+        //鑾峰彇杞︾墝閰嶇疆淇℃伅
+        if (null == listInoutConf) return;
+
+        ApiInoutData apiInoutData;
+        ApiInoutService inoutApiService;
+        for (InoutConf conf : listInoutConf) {
+            if (InoutConstant.PROGRESS_WEIGHT_TAG.equals(conf.getInoutProgress())&&InoutConstant.CONF_TYPE_10.equals(conf.getType()) && sort.equals(conf.getSort())) {
+                apiInoutData = new ApiInoutData(conf);
+                inoutApiService = apiInoutManager.getApiService(conf.getProtocol());
+                inoutApiService.initLpr(apiInoutData);
+            }
+        }
+    }
+
 
     /**
      * 鍑哄叆搴撶櫥璁板畬鎴愯Е鍙戜簨浠讹紝榛樿涓哄紓姝ュ鐞�
@@ -420,14 +468,66 @@
      */
     @Async
     public void onInoutWeight(InoutData data, String curProgress, String nextProgress) {
+        //鑾峰彇鍦扮鎺у埗鍣�
+        InoutConf conf = this.getWeightGateway(data.getCompanyId(), data.getDeptId(), null);
+        if (null == conf) {
+            log.info("----------绉伴噸瀹屾垚浜嬩欢锛屾病鏈夎幏鍙栧埌绉伴噸鎺у埗鍣�--------------");
+        }
 
-        //1銆侀�氱煡绉伴噸鏄剧ず灞�
+        //1銆侀�氱煡绉伴噸鏄剧ず灞忥紝璁惧缂栧彿6001
+        ApiInoutData apiData = new ApiInoutData(conf);
+        apiData.setTime(new Date());
+        apiData.setDeviceCode(InoutApiConstant.DEVICE_CODE_6001);
+        ApiInoutService inoutApiService = apiInoutManager.getApiService(conf.getProtocol());
+        inoutApiService.noticeLed(apiData, data);
 
         //2銆佽闊抽�氱煡
+        apiData.setDeviceCode(InoutApiConstant.DEVICE_CODE_8001);
+        inoutApiService.noticeRadio(apiData, data);
 
         //3銆佸紑闂告満
+        if (InoutConstant.TYPE_IN.equals(data.getType())) {
+            //缁撶畻閲嶉噺澶т簬0琛ㄧず浜屾绉伴噸
+            if (data.getNetWeight() > 0) {
+                apiData.setDeviceCode(InoutApiConstant.DEVICE_CODE_2002);
+            } else {
+                apiData.setDeviceCode(InoutApiConstant.DEVICE_CODE_2003);
+            }
+            apiData.setActionCode(InoutApiConstant.ACTION_CODE_1);
+
+            inoutApiService.gateControl(apiData);
+        } else {
+            //缁撶畻閲嶉噺澶т簬0琛ㄧず浜屾绉伴噸
+            if (data.getNetWeight() > 0) {
+                apiData.setDeviceCode(InoutApiConstant.DEVICE_CODE_2002);
+            } else {
+                apiData.setDeviceCode(InoutApiConstant.DEVICE_CODE_2003);
+            }
+            apiData.setActionCode(InoutApiConstant.ACTION_CODE_1);
+            inoutApiService.gateControl(apiData);
+        }
 
         //4銆佸紑绾㈢豢鐏�
+        if (InoutConstant.TYPE_IN.equals(data.getType())) {
+            //缁撶畻閲嶉噺澶т簬0琛ㄧず浜屾绉伴噸
+            if (data.getNetWeight() > 0) {
+                apiData.setDeviceCode(InoutApiConstant.DEVICE_CODE_7001);
+            } else {
+                apiData.setDeviceCode(InoutApiConstant.DEVICE_CODE_7002);
+            }
+            apiData.setActionCode(InoutApiConstant.ACTION_CODE_1);
+
+            inoutApiService.lightControl(apiData);
+        } else {
+            //缁撶畻閲嶉噺澶т簬0琛ㄧず浜屾绉伴噸
+            if (data.getNetWeight() > 0) {
+                apiData.setDeviceCode(InoutApiConstant.DEVICE_CODE_7002);
+            } else {
+                apiData.setDeviceCode(InoutApiConstant.DEVICE_CODE_7001);
+            }
+            apiData.setActionCode(InoutApiConstant.ACTION_CODE_1);
+            inoutApiService.lightControl(apiData);
+        }
 
     }
 
@@ -618,5 +718,24 @@
         return result;
     }
 
+    private InoutConf getInoutConfBySn(String companyId, String deptId, String sn) {
+
+        if (null == sn) return null;
+
+        // 鑾峰彇鍑哄叆搴撻厤缃俊鎭�
+        List<InoutConf> listInoutConf = inoutCommonService.getCacheInoutConf(companyId, deptId);
+
+        if (null == listInoutConf) return null;
+
+        for (InoutConf conf : listInoutConf) {
+
+            if (null == conf.getSn()) continue;
+
+            if (sn.equals(conf.getSn())) return conf;
+        }
+
+        return null;
+    }
+
 
 }

--
Gitblit v1.9.3