ソースを参照

add 病人信息缓存
add 设备信息缓存

18339543638 3 年 前
コミット
9719faa50a

+ 5 - 5
coffee-system/src/main/java/com/coffee/bus/controller/BusDeviceRegisteredController.java → coffee-system/src/main/java/com/coffee/bus/controller/BusDeviceController.java

@@ -1,8 +1,8 @@
 package com.coffee.bus.controller;
 
 import com.baomidou.mybatisplus.core.mapper.Mapper;
-import com.coffee.bus.entity.BusDeviceRegisteredEntity;
-import com.coffee.bus.service.LocalBusDeviceRegisteredService;
+import com.coffee.bus.entity.BusDeviceEntity;
+import com.coffee.bus.service.LocalBusDeviceService;
 import com.coffee.common.crud.BaseService;
 import com.coffee.common.crud.controller.BaseCrudController;
 import io.swagger.annotations.Api;
@@ -21,8 +21,8 @@ import org.springframework.web.bind.annotation.RestController;
 @AllArgsConstructor
 @RequestMapping("/bus/device/reg")
 @Api(tags = "经销商设备注册",description = "统一权限前缀(device:reg),device:reg:add")
-public class BusDeviceRegisteredController extends BaseCrudController<BusDeviceRegisteredEntity, String> {
-    private final LocalBusDeviceRegisteredService deviceRegisteredService;
+public class BusDeviceController extends BaseCrudController<BusDeviceEntity, String> {
+    private final LocalBusDeviceService deviceRegisteredService;
 
 
     /**
@@ -36,7 +36,7 @@ public class BusDeviceRegisteredController extends BaseCrudController<BusDeviceR
 
 
     @Override
-    public BaseService<? extends Mapper<BusDeviceRegisteredEntity>, BusDeviceRegisteredEntity, String> getService() {
+    public BaseService<? extends Mapper<BusDeviceEntity>, BusDeviceEntity, String> getService() {
         return deviceRegisteredService;
     }
 }

+ 2 - 2
coffee-system/src/main/java/com/coffee/bus/entity/BusDeviceRegisteredEntity.java → coffee-system/src/main/java/com/coffee/bus/entity/BusDeviceEntity.java

@@ -30,10 +30,10 @@ import java.util.Set;
  */
 @EqualsAndHashCode(callSuper = true)
 @Data
-@TableName(value = "bus_device_registered",autoResultMap = true)
+@TableName(value = "bus_device",autoResultMap = true)
 @ApiModel(value="设备注册管理", description="设备注册管理实体类")
 @ToString
-public class BusDeviceRegisteredEntity extends TenantGenericEntity<String,String> {
+public class BusDeviceEntity extends TenantGenericEntity<String,String> {
 
 
     @ApiModelProperty(value = "设备唯一id")

+ 2 - 2
coffee-system/src/main/java/com/coffee/bus/mapper/BusDeviceRegisteredMapper.java → coffee-system/src/main/java/com/coffee/bus/mapper/BusDeviceMapper.java

@@ -1,7 +1,7 @@
 package com.coffee.bus.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.coffee.bus.entity.BusDeviceRegisteredEntity;
+import com.coffee.bus.entity.BusDeviceEntity;
 import org.apache.ibatis.annotations.Mapper;
 
 /**
@@ -12,6 +12,6 @@ import org.apache.ibatis.annotations.Mapper;
  * @createTime 2022年03月19日 09:15:00
  */
 @Mapper
-public interface BusDeviceRegisteredMapper extends BaseMapper<BusDeviceRegisteredEntity> {
+public interface BusDeviceMapper extends BaseMapper<BusDeviceEntity> {
 
 }

+ 5 - 6
coffee-system/src/main/java/com/coffee/bus/registry/device/ClusterDeviceRegistry.java

@@ -3,12 +3,11 @@ package com.coffee.bus.registry.device;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.toolkit.IdWorker;
-import com.coffee.bus.entity.BusDeviceRegisteredEntity;
+import com.coffee.bus.entity.BusDeviceEntity;
 import com.coffee.bus.entity.BusPumpEntity;
 import com.coffee.bus.registry.RegistryConstant;
 import com.coffee.bus.registry.device.bean.DeviceBasicInfo;
-import com.coffee.bus.service.LocalBusDeviceRegisteredService;
+import com.coffee.bus.service.LocalBusDeviceService;
 import com.coffee.bus.service.LocalBusPumpService;
 import com.coffee.common.redis.RedisUtils;
 import lombok.AllArgsConstructor;
@@ -28,7 +27,7 @@ import java.util.Map;
 public class ClusterDeviceRegistry implements DeviceRegistry {
     private final RedisUtils redisUtils;
     private final LocalBusPumpService pumpService;
-    private final LocalBusDeviceRegisteredService deviceRegisteredService;
+    private final LocalBusDeviceService deviceRegisteredService;
     @Override
     public DeviceOperator getDevice(String deviceId) {
         if(StrUtil.isEmpty(deviceId)){
@@ -39,8 +38,8 @@ public class ClusterDeviceRegistry implements DeviceRegistry {
         if(result==null||result.size()==0){
             //从数据库中获取数据
             BusPumpEntity pump = pumpService.getOne(new QueryWrapper<BusPumpEntity>().lambda().eq(BusPumpEntity::getDeviceId, deviceId));
-            BusDeviceRegisteredEntity registeredDevice = deviceRegisteredService.getOne(new QueryWrapper<BusDeviceRegisteredEntity>().lambda()
-                    .eq(BusDeviceRegisteredEntity::getDeviceId, deviceId));
+            BusDeviceEntity registeredDevice = deviceRegisteredService.getOne(new QueryWrapper<BusDeviceEntity>().lambda()
+                    .eq(BusDeviceEntity::getDeviceId, deviceId));
             if(registeredDevice==null){
                 return DeviceOperator.of(new DeviceBasicInfo(),redisUtils);
             }

+ 2 - 2
coffee-system/src/main/java/com/coffee/bus/registry/device/bean/DeviceBasicInfo.java

@@ -1,6 +1,6 @@
 package com.coffee.bus.registry.device.bean;
 
-import com.coffee.bus.entity.BusDeviceRegisteredEntity;
+import com.coffee.bus.entity.BusDeviceEntity;
 import com.coffee.bus.entity.BusPumpEntity;
 import com.coffee.bus.registry.CacheInfo;
 import com.coffee.bus.registry.RegistryConstant;
@@ -90,7 +90,7 @@ public class DeviceBasicInfo implements CacheInfo {
         return new DeviceBasicInfo(key,deviceId,null,null,null);
     }
 
-    public static DeviceBasicInfo of(String key,BusPumpEntity pump, BusDeviceRegisteredEntity deviceRegistered) {
+    public static DeviceBasicInfo of(String key,BusPumpEntity pump, BusDeviceEntity deviceRegistered) {
         return new DeviceBasicInfo(key,pump.getDeviceId(), pump.getAlias(),deviceRegistered.getEnable(),pump.getTenantId(),pump.getId(),pump.getStartTime(),pump.getRegisterTime());
     }
 

+ 6 - 10
coffee-system/src/main/java/com/coffee/bus/service/LocalBusDeviceRegisteredService.java → coffee-system/src/main/java/com/coffee/bus/service/LocalBusDeviceService.java

@@ -1,18 +1,14 @@
 package com.coffee.bus.service;
 
 import com.coffee.bus.registry.device.DeviceRegistry;
-import com.coffee.bus.entity.BusDeviceRegisteredEntity;
-import com.coffee.bus.mapper.BusDeviceRegisteredMapper;
+import com.coffee.bus.entity.BusDeviceEntity;
+import com.coffee.bus.mapper.BusDeviceMapper;
 import com.coffee.common.crud.BaseService;
-import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 
-import javax.annotation.Resource;
-import java.io.Serializable;
-
 /**
  * @author lifang
  * @version 1.0.0
@@ -22,24 +18,24 @@ import java.io.Serializable;
  */
 @Service
 @Slf4j
-public class LocalBusDeviceRegisteredService  extends BaseService<BusDeviceRegisteredMapper, BusDeviceRegisteredEntity,String> {
+public class LocalBusDeviceService extends BaseService<BusDeviceMapper, BusDeviceEntity,String> {
 
     @Autowired
     @Lazy
     private DeviceRegistry deviceRegistry;
     @Override
-    public void validateBeforeSave(BusDeviceRegisteredEntity entity) {
+    public void validateBeforeSave(BusDeviceEntity entity) {
 
     }
 
     @Override
-    public void validateBeforeUpdate(BusDeviceRegisteredEntity entity) {
+    public void validateBeforeUpdate(BusDeviceEntity entity) {
 
     }
 
     @Override
     public void validateBeforeDelete(String id) {
-        BusDeviceRegisteredEntity registeredEntity = this.getById(id);
+        BusDeviceEntity registeredEntity = this.getById(id);
         deviceRegistry.unRegister(registeredEntity.getDeviceId());
     }
 

+ 2 - 2
coffee-system/src/main/java/com/coffee/bus/websocket/listener/DeviceInfoListener.java

@@ -166,12 +166,12 @@ public class DeviceInfoListener {
         deviceOperator.updateRunId(pump.getId());
     }
 
-    @Scheduled(cron = "0/10 * * * * ?")
+    @Scheduled(cron = "0/50 * * * * ?")
     public void send(){
 //        List<BusPumpEntity> list = deviceRunInfoService.list();
 //        list.forEach(pump->{
 
-        ThreadUtil.concurrencyTest(30,()->  {
+        ThreadUtil.concurrencyTest(5,()->  {
             BusPumpEntity pump = new BusPumpEntity();
             pump.setDeviceId("123");
             pump.setPatientCode("456");