|
|
@@ -13,6 +13,7 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.nb.aliyun.api.service.AliyunIotSdk;
|
|
|
+import com.nb.core.Value;
|
|
|
import com.nb.web.api.entity.BusClinicEntity;
|
|
|
import com.nb.web.api.entity.BusInfusionHistoryEntity;
|
|
|
import com.nb.web.api.feign.IDeviceClient;
|
|
|
@@ -32,6 +33,7 @@ import com.nb.common.crud.BaseService;
|
|
|
import com.nb.core.exception.CustomException;
|
|
|
import com.nb.core.utils.ExceptionUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.redisson.api.RMapCache;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -395,58 +397,13 @@ public class LocalBusDeviceService extends BaseService<BusDeviceMapper, BusDevic
|
|
|
.in(BusDeviceEntity::getDeviceId,deviceIds)
|
|
|
.set(BusDeviceEntity::getTenantId,afterTenantId));
|
|
|
//对进行中的输注进行换绑,其他医院切换到主医院不进行输注换绑
|
|
|
- if ("1".equals(afterTenantId)) {
|
|
|
- operators
|
|
|
- .stream()
|
|
|
- .filter(Objects::nonNull)
|
|
|
- .forEach(deviceOperator -> deviceOperator.getCache().clear());
|
|
|
- return;
|
|
|
- }else {
|
|
|
- operators
|
|
|
- .stream()
|
|
|
- .filter(Objects::nonNull)
|
|
|
- .forEach(deviceOperator -> deviceOperator.getCache().remove(DeviceKeyConstant.TENANT_ID));
|
|
|
- }
|
|
|
- List<PatientMonitorResult> results = patientService.selectAll(new PatientMonitorQuery());
|
|
|
- if(CollectionUtil.isEmpty(results)){
|
|
|
- return;
|
|
|
- }
|
|
|
- Map<String, PatientMonitorResult> deviceIdMap = results
|
|
|
+ operators
|
|
|
.stream()
|
|
|
- .collect(Collectors.groupingBy(PatientMonitorResult::getDeviceId, Collectors.collectingAndThen(Collectors.toList(), CollectionUtil::getFirst)));
|
|
|
- //输注信息需要变化的设备
|
|
|
- Collection<String> changeDeviceIds = CollectionUtil.intersection(deviceIdMap.keySet(), deviceIds);
|
|
|
- if(CollectionUtil.isEmpty(changeDeviceIds)){
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- List<PatientMonitorResult> patientMonitorResults = results
|
|
|
- .stream()
|
|
|
- .filter(patientMonitorResult -> changeDeviceIds.contains(patientMonitorResult.getDeviceId()))
|
|
|
- .collect(Collectors.toList());
|
|
|
- //输注切换
|
|
|
- infusionHistoryService.update(new UpdateWrapper<BusInfusionHistoryEntity>().lambda()
|
|
|
- .in(BusInfusionHistoryEntity::getId,patientMonitorResults
|
|
|
- .stream()
|
|
|
- .map(PatientMonitorResult::getInfusionId)
|
|
|
- .collect(Collectors.toList()))
|
|
|
- .set(BusInfusionHistoryEntity::getTenantId,afterTenantId));
|
|
|
-
|
|
|
-
|
|
|
- //病人切换
|
|
|
- patientService.update(new UpdateWrapper<BusPatientEntity>().lambda()
|
|
|
- .in(BusPatientEntity::getId,patientMonitorResults
|
|
|
- .stream()
|
|
|
- .map(PatientMonitorResult::getPatientId)
|
|
|
- .collect(Collectors.toList()))
|
|
|
- .set(BusPatientEntity::getTenantId,afterTenantId));
|
|
|
-
|
|
|
- //临床切换
|
|
|
- clinicService.update(new UpdateWrapper<BusClinicEntity>().lambda()
|
|
|
- .in(BusClinicEntity::getId,patientMonitorResults
|
|
|
- .stream()
|
|
|
- .map(PatientMonitorResult::getClinicId)
|
|
|
- .collect(Collectors.toList()))
|
|
|
- .set(BusClinicEntity::getTenantId,afterTenantId));
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .forEach(deviceOperator -> {
|
|
|
+ RMapCache<String, Value> cache = deviceOperator.getCache();
|
|
|
+ cache.remove(DeviceKeyConstant.TENANT_ID);
|
|
|
+ cache.put(DeviceKeyConstant.CLASSIFY,Value.simple(DeviceKeyConstant.DEFAULT_CLASSIFY));
|
|
|
+ });
|
|
|
}
|
|
|
}
|