|
@@ -1,6 +1,11 @@
|
|
|
package cn.tr.module.airway.service.impl;
|
|
package cn.tr.module.airway.service.impl;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.tr.core.exception.TRExcCode;
|
|
import cn.tr.core.exception.TRExcCode;
|
|
|
|
|
+import cn.tr.module.airway.dto.BizDeviceAutoRegisterDTO;
|
|
|
|
|
+import cn.tr.module.airway.utils.AESUtil;
|
|
|
|
|
+import cn.tr.module.api.sys.tenant.SysTenantApi;
|
|
|
|
|
+import cn.tr.module.api.sys.tenant.SysTenantPojo;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
@@ -11,6 +16,8 @@ import cn.tr.module.airway.repository.BizDeviceRepository;
|
|
|
import cn.tr.module.airway.po.BizDevicePO;
|
|
import cn.tr.module.airway.po.BizDevicePO;
|
|
|
import cn.tr.module.airway.dto.BizDeviceDTO;
|
|
import cn.tr.module.airway.dto.BizDeviceDTO;
|
|
|
import cn.tr.module.airway.dto.BizDeviceQueryDTO;
|
|
import cn.tr.module.airway.dto.BizDeviceQueryDTO;
|
|
|
|
|
+
|
|
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
import cn.tr.module.airway.service.IBizDeviceService;
|
|
import cn.tr.module.airway.service.IBizDeviceService;
|
|
|
import cn.tr.module.airway.mapper.BizDeviceMapper;
|
|
import cn.tr.module.airway.mapper.BizDeviceMapper;
|
|
@@ -25,6 +32,8 @@ public class BizDeviceServiceImpl implements IBizDeviceService {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private BizDeviceRepository baseRepository;
|
|
private BizDeviceRepository baseRepository;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private SysTenantApi tenantApi;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 根据条件查询安卓设备
|
|
* 根据条件查询安卓设备
|
|
@@ -88,5 +97,34 @@ public class BizDeviceServiceImpl implements IBizDeviceService {
|
|
|
throw new ServiceException(TRExcCode.SYSTEM_ERROR_B0001,"请选择要删除的数据");
|
|
throw new ServiceException(TRExcCode.SYSTEM_ERROR_B0001,"请选择要删除的数据");
|
|
|
}
|
|
}
|
|
|
return baseRepository.deleteBatchIds(ids);
|
|
return baseRepository.deleteBatchIds(ids);
|
|
|
- };
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Boolean autoRegisterOrUpdate(BizDeviceAutoRegisterDTO source) {
|
|
|
|
|
+ String encryptData = source.getEncryptData();
|
|
|
|
|
+ String hospitalCode = source.getHospitalCode();
|
|
|
|
|
+ SysTenantPojo tenant = tenantApi.selectByCode(hospitalCode);
|
|
|
|
|
+ if(ObjectUtil.isNull(tenant)){
|
|
|
|
|
+ throw new ServiceException(TRExcCode.SYSTEM_ERROR_B0001,"医院编码不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ try {
|
|
|
|
|
+ BizDeviceAutoRegisterDTO parseBean = AESUtil.decryptDataParseBody(encryptData, tenant.getPassword().getBytes(StandardCharsets.UTF_8), BizDeviceAutoRegisterDTO.class);
|
|
|
|
|
+ BizDevicePO device = BizDeviceMapper.INSTANCE.convertPO(parseBean);
|
|
|
|
|
+ device.setTenantId(tenant.getTenantId());
|
|
|
|
|
+ BizDevicePO exist = baseRepository.selectOne(new LambdaQueryWrapper<BizDevicePO>()
|
|
|
|
|
+ .eq(BizDevicePO::getDeviceCode, device.getDeviceCode())
|
|
|
|
|
+ .last("limit 1"));
|
|
|
|
|
+ if(ObjectUtil.isNotNull(exist)){
|
|
|
|
|
+ device.setId(exist.getId());
|
|
|
|
|
+ baseRepository.updateById(device);
|
|
|
|
|
+ }else {
|
|
|
|
|
+ baseRepository.insert(device);
|
|
|
|
|
+ }
|
|
|
|
|
+ }catch (Exception e){
|
|
|
|
|
+ throw new ServiceException(TRExcCode.SYSTEM_ERROR_B0001,"医院密码错误");
|
|
|
|
|
+ }
|
|
|
|
|
+ return Boolean.TRUE;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ ;
|
|
|
}
|
|
}
|