From f3a5d0eaa481c6f565e54bde2f1690aa94cec580 Mon Sep 17 00:00:00 2001
From: liuhaonan <konodioda2333@vip.qq.com>
Date: 星期五, 01 四月 2022 14:23:31 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 ximon-admin/src/main/java/com/sandu/ximon/admin/service/C3ChargingService.java |  174 ++++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 134 insertions(+), 40 deletions(-)

diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/C3ChargingService.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/C3ChargingService.java
index 767b4cc..1f0e7e9 100644
--- a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/C3ChargingService.java
+++ b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/C3ChargingService.java
@@ -5,6 +5,7 @@
 import com.sandu.common.execption.BusinessException;
 import com.sandu.common.object.BaseConditionVO;
 import com.sandu.common.service.impl.BaseServiceImpl;
+import com.sandu.ximon.dao.bo.C3ChargingBo;
 import com.sandu.ximon.admin.manager.iot.frame.A5Frame;
 import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5C3HeartbeatReportInnerFrame;
 import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5C3OperationReportInnerFrame;
@@ -15,9 +16,7 @@
 import com.sandu.ximon.admin.manager.iot.rrpc.mainboard.MainBoardInvokeSyncService;
 import com.sandu.ximon.admin.param.C3ChargingAddParam;
 import com.sandu.ximon.admin.param.C3ChargingParam;
-import com.sandu.ximon.dao.domain.C3mCharging;
-import com.sandu.ximon.dao.domain.C3mChargingCharge;
-import com.sandu.ximon.dao.domain.PoleBinding;
+import com.sandu.ximon.dao.domain.*;
 import com.sandu.ximon.dao.mapper.C3mChargingMapper;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
@@ -34,27 +33,50 @@
 @Slf4j
 @AllArgsConstructor
 public class C3ChargingService extends BaseServiceImpl<C3mChargingMapper, C3mCharging> {
-
+    private C3mChargingMapper c3mChargingMapper;
     private final C3mChargingChargeService c3mChargingChargeService;
     private final PoleBindingService bindingService;
+    private final PoleService poleService;
 
     /**
      * 淇濆瓨涓婃姤C3鍏呯數璁惧蹇冭烦鏁版嵁
      *
      * @return 鏄惁鎴愬姛
      */
-    public boolean saveReportData(String deviceName, A5C3HeartbeatReportInnerFrame.HeartBeatDataPackage heartBeatDataPackage) {
-        C3mCharging one = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getMcuUdid, deviceName));
+    public boolean updateReportState(String deviceName, String c3Mac, String statusBit, String deviceTemperature) {
+        C3mCharging one = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getPoleDevicesCode, deviceName));
+        if (one != null) {
+            one.setStatusBit(Integer.valueOf(statusBit));
+            one.setDeviceTemperature(deviceTemperature);
+            one.setPoleDevicesCode(deviceName);
+            one.setC3Mac(c3Mac);
+
+//            List<C3mChargingCharge> list = c3mChargingChargeService.list(Wrappers.lambdaQuery(C3mChargingCharge.class).eq(C3mChargingCharge::getC3Id, one.getC3Id()));
+//            if (list.size() == 0) {//璐圭巼琛ㄤ腑娌℃湁姝ゅ厖鐢垫々鏁版嵁鏃�  娣诲姞榛樿璐圭巼
+//                c3mChargingChargeService.initCharge((one.getC3Id()).intValue());
+//            }
+            return updateById(one);
+        } else {
+            return false;
+        }
+    }
+
+    /**
+     * 淇濆瓨涓婃姤C3鍏呯數璁惧蹇冭烦鏁版嵁
+     *
+     * @return 鏄惁鎴愬姛
+     */
+    public boolean saveReporEquipment(String deviceName, String mcuUdid, String c3Mac) {
+        C3mCharging one = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getMcuUdid, mcuUdid));
         if (one == null) {
             //灏嗚澶囦俊鎭坊鍔犲埌鍏呯數妗╄澶囪〃
             C3mCharging c3mCharging = new C3mCharging();
-            c3mCharging.setMcuUdid(deviceName);
-            c3mCharging.setC3Mac(heartBeatDataPackage.getC3Mac());
-            c3mCharging.setStatusBit(Integer.valueOf(heartBeatDataPackage.getStatusBit()));
-            c3mCharging.setDeviceTemperature(heartBeatDataPackage.getDeviceTemperature());
+            c3mCharging.setMcuUdid(mcuUdid);
+            c3mCharging.setPoleDevicesCode(deviceName);
+            c3mCharging.setC3Mac(c3Mac);
             boolean flag = save(c3mCharging);
             //璁剧疆璐圭巼
-            C3mCharging c3mCharging1 = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getMcuUdid, deviceName));
+            C3mCharging c3mCharging1 = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getMcuUdid, mcuUdid));
             List<C3mChargingCharge> list = c3mChargingChargeService.list(Wrappers.lambdaQuery(C3mChargingCharge.class).eq(C3mChargingCharge::getC3Id, c3mCharging1.getC3Id()));
             if (list.size() == 0) {//璐圭巼琛ㄤ腑娌℃湁姝ゅ厖鐢垫々鏁版嵁鏃�  娣诲姞榛樿璐圭巼
                 c3mChargingChargeService.initCharge((c3mCharging1.getC3Id()).intValue());
@@ -62,13 +84,18 @@
 
             return flag;
         } else {
-            one.setStatusBit(Integer.valueOf(heartBeatDataPackage.getStatusBit()));
-            one.setDeviceTemperature(heartBeatDataPackage.getDeviceTemperature());
-            List<C3mChargingCharge> list = c3mChargingChargeService.list(Wrappers.lambdaQuery(C3mChargingCharge.class).eq(C3mChargingCharge::getC3Id, one.getC3Id()));
+            //灏嗚澶囦俊鎭坊鍔犲埌鍏呯數妗╄澶囪〃
+            one.setPoleDevicesCode(deviceName);
+            one.setC3Mac(c3Mac);
+            boolean flag = updateById(one);
+            //璁剧疆璐圭巼
+            C3mCharging c3mCharging1 = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getMcuUdid, mcuUdid));
+            List<C3mChargingCharge> list = c3mChargingChargeService.list(Wrappers.lambdaQuery(C3mChargingCharge.class).eq(C3mChargingCharge::getC3Id, c3mCharging1.getC3Id()));
             if (list.size() == 0) {//璐圭巼琛ㄤ腑娌℃湁姝ゅ厖鐢垫々鏁版嵁鏃�  娣诲姞榛樿璐圭巼
-                c3mChargingChargeService.initCharge((one.getC3Id()).intValue());
+                c3mChargingChargeService.initCharge((c3mCharging1.getC3Id()).intValue());
             }
-            return updateById(one);
+
+            return flag;
         }
     }
 
@@ -77,9 +104,20 @@
      *
      * @return
      */
-    public List<C3mCharging> getC3ChargingList(BaseConditionVO baseConditionVO) {
+    public List<C3ChargingBo> getC3ChargingListByKeyword(BaseConditionVO baseConditionVO, C3ChargingParam c3ChargingParam) {
         PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
-        return list();
+        if (c3ChargingParam == null) {
+            c3ChargingParam = new C3ChargingParam();
+        }
+
+        //鍏抽敭瀛楀幓闄ょ┖鏍�
+        if (c3ChargingParam.getKeyword() != null) {
+            c3ChargingParam.setKeyword(c3ChargingParam.getKeyword().trim());
+        }
+
+        List<C3ChargingBo> c3ChargingBoList
+                = c3mChargingMapper.listC3mChargingDto(c3ChargingParam.getKeyword());
+        return c3ChargingBoList;
     }
 
     /**
@@ -100,7 +138,7 @@
         if (c3mCharging == null) {
             throw new BusinessException("C3鍏呯數妗╃‖浠秏cu_udid涓嶅瓨鍦�");
         }
-        CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getMcuUdid(), a5Frame);
+        CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame);
         System.out.println(commonFrame + "            -----commonFrame");
 
 
@@ -133,7 +171,8 @@
         if (c3mCharging == null) {
             throw new BusinessException("C3鍏呯數妗╃‖浠秏cu_udid涓嶅瓨鍦�");
         }
-        CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getMcuUdid(), a5Frame);
+        CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame);
+
         System.out.println(commonFrame + "            -----commonFrame");
 
         A5C3OperationReportInnerFrame operationReportInnerFrame = new A5C3OperationReportInnerFrame().transformFrame(commonFrame.getPayload());
@@ -162,7 +201,36 @@
         if (c3mCharging == null) {
             throw new BusinessException("C3鍏呯數妗╃‖浠秏cu_udid涓嶅瓨鍦�");
         }
-        CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getMcuUdid(), a5Frame);
+        CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame);
+
+        System.out.println(commonFrame + "            -----commonFrame");
+
+        A5C3OperationReportInnerFrame operationReportInnerFrame = new A5C3OperationReportInnerFrame().transformFrame(commonFrame.getPayload());
+
+        if (operationReportInnerFrame.isValidate()) {
+            return operationReportInnerFrame.getState();
+        } else {
+            throw new BusinessException("鏁版嵁鏍¢獙閿欒锛岃閲嶆柊璇锋眰");
+        }
+    }
+
+    /**
+     * 浜岀淮鐮�
+     *
+     * @param c3Mac
+     */
+    public String QrCode(String c3Mac, String qrCodeData) {
+        C3QrCodeReqInnerFrame c3QrCodeReqInnerFrame = new C3QrCodeReqInnerFrame(c3Mac, qrCodeData);
+
+        A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_C3_DATA.getCode(), c3QrCodeReqInnerFrame);
+        System.out.println(a5Frame + "            -----a5Frame");
+
+        C3mCharging c3mCharging = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getC3Mac, c3Mac));
+        if (c3mCharging == null) {
+            throw new BusinessException("C3鍏呯數妗╃‖浠秏cu_udid涓嶅瓨鍦�");
+        }
+        CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame);
+
         System.out.println(commonFrame + "            -----commonFrame");
 
         A5C3OperationReportInnerFrame operationReportInnerFrame = new A5C3OperationReportInnerFrame().transformFrame(commonFrame.getPayload());
@@ -190,7 +258,8 @@
         if (c3mCharging == null) {
             throw new BusinessException("C3鍏呯數妗╃‖浠秏cu_udid涓嶅瓨鍦�");
         }
-        CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getMcuUdid(), a5Frame);
+        CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame);
+
         System.out.println(commonFrame + "            -----commonFrame");
 
         A5C3QueryReportInnerFrame a5C3QueryReportInnerFrame = new A5C3QueryReportInnerFrame().transformFrame(commonFrame.getPayload());
@@ -218,7 +287,8 @@
         if (c3mCharging == null) {
             throw new BusinessException("C3鍏呯數妗╃‖浠秏cu_udid涓嶅瓨鍦�");
         }
-        CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getMcuUdid(), a5Frame);
+        CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame);
+
         System.out.println(commonFrame + "            -----commonFrame");
 
         A5C3QueryReportInnerFrame queryReportInnerFrame = new A5C3QueryReportInnerFrame().transformFrame(commonFrame.getPayload());
@@ -246,7 +316,8 @@
         if (c3mCharging == null) {
             throw new BusinessException("C3鍏呯數妗╃‖浠秏cu_udid涓嶅瓨鍦�");
         }
-        CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getMcuUdid(), a5Frame);
+        CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame);
+
         System.out.println(commonFrame + "            -----commonFrame");
 
         A5C3QueryReportInnerFrame queryReportInnerFrame = new A5C3QueryReportInnerFrame().transformFrame(commonFrame.getPayload());
@@ -274,7 +345,8 @@
         if (c3mCharging == null) {
             throw new BusinessException("C3鍏呯數妗╃‖浠秏cu_udid涓嶅瓨鍦�");
         }
-        CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getMcuUdid(), a5Frame);
+        CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame);
+
         System.out.println(commonFrame + "            -----commonFrame");
 
         A5C3QueryReportInnerFrame queryReportInnerFrame = new A5C3QueryReportInnerFrame().transformFrame(commonFrame.getPayload());
@@ -302,7 +374,8 @@
         if (c3mCharging == null) {
             throw new BusinessException("C3鍏呯數妗╃‖浠秏cu_udid涓嶅瓨鍦�");
         }
-        CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getMcuUdid(), a5Frame);
+        CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame);
+
         System.out.println(commonFrame + "            -----commonFrame");
 
         A5C3QueryReportInnerFrame queryReportInnerFrame = new A5C3QueryReportInnerFrame().transformFrame(commonFrame.getPayload());
@@ -330,7 +403,8 @@
         if (c3mCharging == null) {
             throw new BusinessException("C3鍏呯數妗╃‖浠秏cu_udid涓嶅瓨鍦�");
         }
-        CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getMcuUdid(), a5Frame);
+        CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame);
+
         System.out.println(commonFrame + "            -----commonFrame");
 
         A5C3HeartbeatReportInnerFrame heartbeatReportInnerFrame = new A5C3HeartbeatReportInnerFrame().transformFrame(commonFrame.getPayload());
@@ -362,7 +436,8 @@
         if (c3mCharging == null) {
             throw new BusinessException("C3鍏呯數妗╃‖浠秏cu_udid涓嶅瓨鍦�");
         }
-        CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getMcuUdid(), a5Frame);
+        CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame);
+
         System.out.println(commonFrame + "            -----commonFrame");
 
         A5C3OperationReportInnerFrame operationReportInnerFrame = new A5C3OperationReportInnerFrame().transformFrame(commonFrame.getPayload());
@@ -392,7 +467,8 @@
         if (c3mCharging == null) {
             throw new BusinessException("C3鍏呯數妗╃‖浠秏cu_udid涓嶅瓨鍦�");
         }
-        CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getMcuUdid(), a5Frame);
+        CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame);
+
         System.out.println(commonFrame + "            -----commonFrame");
 
         A5C3OperationReportInnerFrame operationReportInnerFrame = new A5C3OperationReportInnerFrame().transformFrame(commonFrame.getPayload());
@@ -415,21 +491,34 @@
             throw new BusinessException("鍦板潃淇℃伅閿欒锛�");
         }
 
+        C3mCharging c3mCharging = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getC3Mac, c3Mac));
+        if (c3mCharging == null) {
+            throw new BusinessException("C3MAC鍦板潃涓嶅瓨鍦�");
+        }
+
+        if (getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getC3Mac, address)) != null) {
+            throw new BusinessException("鏂扮殑鍦板潃淇℃伅宸插瓨鍦紒");
+        }
+
         C3SetAddressReqInnerFrame setAddressReqInnerFrame =
                 new C3SetAddressReqInnerFrame(c3Mac, address);
 
         A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_C3_DATA.getCode(), setAddressReqInnerFrame);
         System.out.println(a5Frame + "            -----a5Frame");
 
-        C3mCharging c3mCharging = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getC3Mac, c3Mac));
-        if (c3mCharging == null) {
-            throw new BusinessException("C3鍏呯數妗╃‖浠秏cu_udid涓嶅瓨鍦�");
-        }
-        CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getMcuUdid(), a5Frame);
+
+        CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame);
+
         System.out.println(commonFrame + "            -----commonFrame");
 
         A5C3OperationReportInnerFrame operationReportInnerFrame = new A5C3OperationReportInnerFrame().transformFrame(commonFrame.getPayload());
         if (operationReportInnerFrame.isValidate()) {
+            if ("鎿嶄綔鎴愬姛".equals(operationReportInnerFrame.getState())) {
+                //淇敼鎴愬姛闇�瑕佹洿鏀规暟鎹簱鏁版嵁
+                C3mCharging one = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getC3Mac, c3Mac));
+                one.setC3Mac(address);
+                updateById(one);
+            }
             return operationReportInnerFrame.getState();
         } else {
             throw new BusinessException("鏁版嵁鏍¢獙閿欒锛岃閲嶆柊璇锋眰");
@@ -455,7 +544,8 @@
         if (c3mCharging == null) {
             throw new BusinessException("C3鍏呯數妗╃‖浠秏cu_udid涓嶅瓨鍦�");
         }
-        CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getMcuUdid(), a5Frame);
+        CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame);
+
         System.out.println(commonFrame + "            -----commonFrame");
 
         A5C3OperationReportInnerFrame operationReportInnerFrame = new A5C3OperationReportInnerFrame().transformFrame(commonFrame.getPayload());
@@ -485,7 +575,8 @@
         if (c3mCharging == null) {
             throw new BusinessException("C3鍏呯數妗╃‖浠秏cu_udid涓嶅瓨鍦�");
         }
-        CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getMcuUdid(), a5Frame);
+        CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame);
+
         System.out.println(commonFrame + "            -----commonFrame");
 
         A5C3OperationReportInnerFrame operationReportInnerFrame = new A5C3OperationReportInnerFrame().transformFrame(commonFrame.getPayload());
@@ -515,7 +606,8 @@
         if (c3mCharging == null) {
             throw new BusinessException("C3鍏呯數妗╃‖浠秏cu_udid涓嶅瓨鍦�");
         }
-        CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getMcuUdid(), a5Frame);
+        CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame);
+
         System.out.println(commonFrame + "            -----commonFrame");
 
         A5C3OperationReportInnerFrame operationReportInnerFrame = new A5C3OperationReportInnerFrame().transformFrame(commonFrame.getPayload());
@@ -542,7 +634,9 @@
         if (c3mCharging == null) {
             throw new BusinessException("C3鍏呯數妗╃‖浠秏cu_udid涓嶅瓨鍦�");
         }
-        CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getMcuUdid(), a5Frame);
+        CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame);
+//        CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC("32313243305008ff1a06ffff", a5Frame);
+
         System.out.println(commonFrame + "            -----commonFrame");
 
         A5C3OperationReportInnerFrame operationReportInnerFrame = new A5C3OperationReportInnerFrame().transformFrame(commonFrame.getPayload());
@@ -556,7 +650,7 @@
 
     public boolean addC3Charging(C3ChargingAddParam c3ChargingAddParam) {
         C3mCharging one = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getMcuUdid, c3ChargingAddParam.getMcuUdid()));
-        if(one != null){
+        if (one != null) {
             throw new BusinessException("纭欢璁惧宸插瓨鍦紒");
         }
 
@@ -574,7 +668,7 @@
 
     public boolean updateC3ChargingName(C3ChargingAddParam c3ChargingAddParam) {
         C3mCharging one = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getC3Id, c3ChargingAddParam.getC3Id()));
-        if(one == null){
+        if (one == null) {
             throw new BusinessException("纭欢璁惧涓嶅瓨鍦紒");
         }
 

--
Gitblit v1.9.3