licailing il y a 4 ans
Parent
commit
8b6c683362

+ 43 - 16
src/main/java/com/izouma/wenlvju/service/ExamRoomService.java

@@ -40,10 +40,10 @@ public class ExamRoomService {
         String uri = "https://open.ys7.com/api/lapp/device/list";
         String accessToken = ezvizTokenService.getToken();
         String send = "accessToken=" + accessToken + "&pageStart=0&pageSize=50";
-        log.info("萤石查看设备--->" + send);
+        log.info("萤石查看设备列表--->" + send);
 
         String body = HttpRequest.post(uri).send(send).body();
-        log.info("萤石查看设备返回--->" + body);
+        log.info("萤石查看设备列表返回--->" + body);
 
         JSONObject json = JSONObject.parseObject(body);
         if (!"200".equals(json.getString("code"))) {
@@ -66,21 +66,29 @@ public class ExamRoomService {
      */
     public void addDevice(String deviceSerial, String validateCode) {
         Set<String> devices = this.showDevice().keySet();
-        if (devices.contains(deviceSerial)) {
-            return;
-        }
-
-        String uri = "https://open.ys7.com/api/lapp/device/add";
         String accessToken = ezvizTokenService.getToken();
-        String send = "accessToken=" + accessToken + "&deviceSerial=" + deviceSerial + "&validateCode=" + validateCode;
-        log.info("萤石添加设备--->" + send);
 
-        String body = HttpRequest.post(uri).send(send).body();
-        log.info("萤石添加设备返回--->" + body);
+        if (!devices.contains(deviceSerial)) {
+            String uri = "https://open.ys7.com/api/lapp/device/add";
 
-        JSONObject json = JSONObject.parseObject(body);
-        if (!"200".equals(json.getString("code"))) {
-            throw new BusinessException(json.getString("msg"));
+            String send = "accessToken=" + accessToken + "&deviceSerial=" + deviceSerial + "&validateCode=" + validateCode;
+            log.info("萤石添加设备--->" + send);
+
+            String body = HttpRequest.post(uri).send(send).body();
+            log.info("萤石添加设备返回--->" + body);
+
+            JSONObject json = JSONObject.parseObject(body);
+            if (!"200".equals(json.getString("code"))) {
+                throw new BusinessException(json.getString("msg"));
+            }
+        }
+
+        JSONObject info = this.info(deviceSerial, accessToken);
+        JSONObject data = JSONObject.parseObject(info.getString("data"));
+        Integer isEncrypt = data.getInteger("isEncrypt");
+        if (isEncrypt == 1) {
+            // 解密设备
+            this.encryptOff(deviceSerial, validateCode, accessToken);
         }
     }
 
@@ -104,6 +112,25 @@ public class ExamRoomService {
         }
     }
 
+    /*
+    查询单个设备
+    */
+    public JSONObject info(String deviceSerial, String accessToken) {
+        String uri = "https://open.ys7.com/api/lapp/device/info";
+
+        String send = "accessToken=" + accessToken + "&deviceSerial=" + deviceSerial;
+        log.info("萤石设备查询--->" + send);
+
+        String body = HttpRequest.post(uri).send(send).body();
+        log.info("萤石设备查询返回--->" + body);
+
+        JSONObject json = JSONObject.parseObject(body);
+        if (!"200".equals(json.getString("code"))) {
+            throw new BusinessException(json.getString("msg"));
+        }
+        return json;
+    }
+
     /*
     开启设备加密
      */
@@ -128,10 +155,10 @@ public class ExamRoomService {
     /*
     关闭设备加密
      */
-    public void encryptOff(String deviceSerial, String validateCode) {
+    public void encryptOff(String deviceSerial, String validateCode, String accessToken) {
 
         String uri = "https://open.ys7.com/api/lapp/device/encrypt/off";
-        String accessToken = ezvizTokenService.getToken();
+//        String accessToken = ezvizTokenService.getToken();
         String send = "accessToken=" + accessToken + "&deviceSerial=" + deviceSerial + "&validateCode=" + validateCode;
         log.info("萤石关闭设备加密--->" + send);
 

+ 1 - 1
src/main/java/com/izouma/wenlvju/service/performance/ProgrammeAwardService.java

@@ -57,7 +57,7 @@ public class ProgrammeAwardService {
                     .collect(Collectors.toList());
         }
 
-        List<Programme> programmeList = programmeRepo.findAllByPerformanceIdAndStatus(performanceId, 3);
+        List<Programme> programmeList = programmeRepo.findAllByPerformanceIdAndStatus(performanceId, 2);
         List<ArtType> artTypes = all.stream()
                 .filter(artType -> ObjectUtil.isNull(artType.getParent()))
                 .collect(Collectors.toList());

+ 24 - 3
src/main/vue/src/views/performance/ProgrammeAwardList.vue

@@ -50,6 +50,7 @@
                     <el-input-number
                         v-else
                         v-model="row.percentage"
+                        :precision="2"
                         size="mini"
                         label=""
                         :min="0"
@@ -57,6 +58,7 @@
                         :step="1"
                         :controls="true"
                         controls-position="both"
+                        @change="changePercentage(row)"
                     >
                     </el-input-number>
                 </template>
@@ -70,10 +72,11 @@
                         size="mini"
                         label=""
                         :min="0"
-                        :max="100"
+                        :max="row.programmeNum"
                         :step="1"
                         :controls="true"
                         controls-position="both"
+                        @change="changeNum(row)"
                     >
                     </el-input-number>
                 </template>
@@ -131,7 +134,7 @@ export default {
             performances: [],
             tableData: [],
             tableHeight: 200,
-            columnKeys: ['specialty', 'programmeNum'],
+            columnKeys: ['specialty'],
             canEdit: false
         };
     },
@@ -264,7 +267,7 @@ export default {
 
             return _map;
         },
-        getInfo(mapInfo = new Map(), keys = ['programmeNum']) {
+        getInfo(mapInfo = new Map(), keys = ['specialty']) {
             let info = {};
             keys.forEach(item => {
                 if (mapInfo.has(item)) {
@@ -297,6 +300,24 @@ export default {
                     };
                 }
             }
+        },
+        changePercentage(row) {
+            row.num = (row.programmeNum * row.percentage) / 100;
+            if (typeof row.remainder == 'undefined') {
+                row.remainder = row.programmeNum - row.num;
+            } else {
+                row.remainder = row.remainder - row.num;
+            }
+            console.log(row.remainder);
+        },
+        changeNum(row) {
+            row.percentage = (row.num / row.programmeNum) * 100;
+            if (typeof row.remainder == 'undefined') {
+                row.remainder = row.programmeNum - row.num;
+            } else {
+                row.remainder = row.remainder - row.num;
+            }
+            console.log(row.remainder);
         }
     }
 };

+ 3 - 3
src/test/java/com/izouma/wenlvju/service/ExamRoomServiceTest.java

@@ -19,8 +19,8 @@ public class ExamRoomServiceTest extends ApplicationTests {
 
     @Test
     public void addDevice() {
-        ExamRoom examRoom = examRoomRepo.findById(874L).orElseThrow(null);
-        examRoomService.addDevice(examRoom.getDeviceSerial(), examRoom.getValidateCode());
+//        ExamRoom examRoom = examRoomRepo.findById(874L).orElseThrow(null);
+        examRoomService.addDevice("G05342208", "YEIACL");
 
     }
 
@@ -38,7 +38,7 @@ public class ExamRoomServiceTest extends ApplicationTests {
     @Test
     public void off() {
         ExamRoom examRoom = examRoomRepo.findById(874L).orElseThrow(null);
-        examRoomService.encryptOff(examRoom.getDeviceSerial(), examRoom.getValidateCode());
+        examRoomService.encryptOff(examRoom.getDeviceSerial(), examRoom.getValidateCode(), "");
     }
 
     @Test