Browse Source

添加sn号更改接口

李进 2 years ago
parent
commit
ce96160e7f

+ 4 - 2
device-api-service/src/main/java/com/xy/config/DeviceThreadPoolConfig.java

@@ -17,11 +17,13 @@ public class DeviceThreadPoolConfig {
     @DynamicTp
     @Bean(DEVICE_COMMON_POLL)
     public ThreadPoolTaskExecutor deviceCommonPoll() {
+        int coreSize = 15;
         return ThreadPoolUtils.newPoll()
                 .name(DEVICE_COMMON_POLL)
-                .coreSize(10)
-                .maxSize(200)
+                .coreSize(coreSize)
+                .maxSize(coreSize * 2)
                 .keepAlive(60)
+                .queueSize(coreSize * 10)
                 .builder();
     }
 

+ 26 - 8
device-api-service/src/main/java/com/xy/service/DeviceInfoServiceImpl.java

@@ -83,23 +83,41 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
             return R.ok();
         }
         DeviceInfoDto.Vo deviceInfo = copy(DeviceInfoDto.Vo.class, list.get(0));
-        ThreadPoolUtils.excPoll(DeviceThreadPoolConfig.DEVICE_COMMON_POLL, 3)
-                .execute(() -> {
+        int num = 0;
+        if (obj.getIsSysinfo()) {
+            num++;
+        }
+        if (obj.getIsStatus()) {
+            num++;
+        }
+        if (obj.getIsRegister()) {
+            num++;
+        }
+        if (num > 0) {
+            ThreadPoolUtils.Execute execute = ThreadPoolUtils.excPoll(DeviceThreadPoolConfig.DEVICE_COMMON_POLL, num);
+            if (obj.getIsSysinfo()) {
+                execute.execute(() -> {
                     //系统信息
                     DeviceSysinfoDto.Vo deviceSysinfo = deviceSysinfoService.get(new DeviceSysinfoDto.Vo().setDeviceId(deviceInfo.getDeviceId())).getData();
                     deviceInfo.setDeviceSysinfo(deviceSysinfo);
-                })
-                .execute(() -> {
+                });
+            }
+            if (obj.getIsStatus()) {
+                execute.execute(() -> {
                     //状态信息
                     DeviceStatusDto.Vo deviceStatus = deviceStatusService.obj(new DeviceStatusDto.Vo().setDeviceId(deviceInfo.getDeviceId())).getData();
                     deviceInfo.setDeviceStatus(deviceStatus);
-                })
-                .execute(() -> {
+                });
+            }
+            if (obj.getIsRegister()) {
+                execute.execute(() -> {
                     //注册信息
                     DeviceRegisterDto.Vo deviceRegister = deviceRegisterService.obj(new DeviceRegisterDto.Vo().setDeviceId(deviceInfo.getDeviceId())).getData();
                     deviceInfo.setDeviceRegister(deviceRegister);
-                })
-                .end();
+                });
+            }
+            execute.end();
+        }
         return R.ok(deviceInfo);
     }
 

+ 10 - 1
device-api/src/main/java/com/xy/dto/DeviceInfoDto.java

@@ -41,12 +41,21 @@ public class DeviceInfoDto {
 
         @ApiModelProperty("门id 0=1号门 1=2号门")
         private Integer door;
+
+        @ApiModelProperty("是否需要系统信息")
+        private Boolean isSysinfo = false;
+
+        @ApiModelProperty("是否需要状态信息")
+        private Boolean isStatus = false;
+
+        @ApiModelProperty("是否需要注册信息")
+        private Boolean isRegister = false;
     }
 
     @Data
     @Accessors(chain = true)
     public static class ListDto {
-        @ApiModelProperty(value = "设备id批量查", required = false)
+        @ApiModelProperty(value = "设备id批量查")
         private List<Long> deviceIds;
     }