|
|
@@ -3,7 +3,12 @@ package com.nb.web.service.bus.service;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.hutool.core.util.RandomUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import cn.hutool.crypto.digest.DigestUtil;
|
|
|
+import cn.hutool.http.HttpUtil;
|
|
|
+import cn.hutool.json.JSONObject;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
@@ -21,6 +26,7 @@ import com.nb.web.service.bus.hospital.his.strategy.HisStrategyEnum;
|
|
|
import com.nb.web.service.bus.mapper.BusHospitalMapper;
|
|
|
import com.nb.web.service.bus.service.constant.LocalBusConAlarmService;
|
|
|
import com.nb.web.service.bus.service.constant.LocalBusConMixService;
|
|
|
+import com.nb.web.service.bus.service.dto.IotHospitalAddDTO;
|
|
|
import com.nb.web.service.bus.utils.CodeUtils;
|
|
|
import com.nb.core.cache.ConfigStorage;
|
|
|
import com.nb.core.cache.manager.ConfigStorageManager;
|
|
|
@@ -142,61 +148,78 @@ public class LocalBusHospitalService extends BaseService<BusHospitalMapper, BusH
|
|
|
|
|
|
@Override
|
|
|
public void postSave(BusHospitalEntity entity) {
|
|
|
- CompletableFuture.runAsync(()->{
|
|
|
- List<BusHospitalConfigEntity> configs =
|
|
|
- configService.list(new QueryWrapper<BusHospitalConfigEntity>().lambda()
|
|
|
- .or()
|
|
|
- .eq(BusHospitalConfigEntity::getTenantId, 1));
|
|
|
- configs.forEach(config->{
|
|
|
- config.setId(null);
|
|
|
- config.setTenantId(entity.getId());
|
|
|
- });
|
|
|
- configService.saveBatch(configs);
|
|
|
-
|
|
|
- //设置默认更新策略
|
|
|
- HisUpdateEntity updateConfig = entity.getUpdateConfig();
|
|
|
- if(updateConfig!=null){
|
|
|
- hospitalManagerRegister.get(entity.getId()).refreshUpdateConfig(updateConfig);
|
|
|
- }
|
|
|
|
|
|
- //设置默认管理员角色
|
|
|
- SysRole sysRole = new SysRole();
|
|
|
- sysRole.setTenantId(entity.getId());
|
|
|
- sysRole.setRoleName("超级管理员");
|
|
|
- sysRole.setDataScope("1");
|
|
|
- sysRole.setRoleCode("admin");
|
|
|
- sysRole.setRemarks("超级管理员角色,不可编辑,不可删除");
|
|
|
- sysRoleService.save(sysRole);
|
|
|
- nameCache.setConfig(entity.getId(),entity.getName());
|
|
|
+ List<BusHospitalConfigEntity> configs =
|
|
|
+ configService.list(new QueryWrapper<BusHospitalConfigEntity>().lambda()
|
|
|
+ .or()
|
|
|
+ .eq(BusHospitalConfigEntity::getTenantId, 1));
|
|
|
+ configs.forEach(config->{
|
|
|
+ config.setId(null);
|
|
|
+ config.setTenantId(entity.getId());
|
|
|
+ });
|
|
|
+ configService.saveBatch(configs);
|
|
|
|
|
|
- //设置默认常量信息
|
|
|
- List<BusConMixEntity> drugCons = conMixService.list(new QueryWrapper<BusConMixEntity>()
|
|
|
- .lambda().eq(BusConMixEntity::getTenantId, "1")
|
|
|
- .eq(BusConMixEntity::getType, ConstantMixEnum.drugCate));
|
|
|
- if(CollUtil.isNotEmpty(drugCons)){
|
|
|
- conMixService.saveBatch(drugCons.stream().peek(mix->{
|
|
|
- mix.setId(null);
|
|
|
- mix.setTenantId(entity.getId());
|
|
|
- }).collect(Collectors.toSet()));
|
|
|
- }
|
|
|
+ //设置默认更新策略
|
|
|
+ HisUpdateEntity updateConfig = entity.getUpdateConfig();
|
|
|
+ if(updateConfig!=null){
|
|
|
+ hospitalManagerRegister.get(entity.getId()).refreshUpdateConfig(updateConfig);
|
|
|
+ }
|
|
|
|
|
|
- //设置默认报警原因
|
|
|
- List<BusConAlarmEntity> alarmCauses = conAlarmService.list(new QueryWrapper<BusConAlarmEntity>()
|
|
|
- .lambda().eq(BusConAlarmEntity::getTenantId, "1"));
|
|
|
- if (CollUtil.isNotEmpty(alarmCauses)) {
|
|
|
- conAlarmService.saveBatch(alarmCauses.stream().peek(alarmCause->{
|
|
|
- alarmCause.setId(null);
|
|
|
- alarmCause.setTenantId(entity.getId());
|
|
|
- }).collect(Collectors.toSet()));
|
|
|
- }
|
|
|
- })
|
|
|
- .whenComplete((i,e)->{
|
|
|
- if(e!=null){
|
|
|
- log.error("新增医院默认配置失败,",e);
|
|
|
- }
|
|
|
- });
|
|
|
+ //设置默认管理员角色
|
|
|
+ SysRole sysRole = new SysRole();
|
|
|
+ sysRole.setTenantId(entity.getId());
|
|
|
+ sysRole.setRoleName("超级管理员");
|
|
|
+ sysRole.setDataScope("1");
|
|
|
+ sysRole.setRoleCode("admin");
|
|
|
+ sysRole.setRemarks("超级管理员角色,不可编辑,不可删除");
|
|
|
+ sysRoleService.save(sysRole);
|
|
|
+ nameCache.setConfig(entity.getId(),entity.getName());
|
|
|
+
|
|
|
+ //设置默认常量信息
|
|
|
+ List<BusConMixEntity> drugCons = conMixService.list(new QueryWrapper<BusConMixEntity>()
|
|
|
+ .lambda().eq(BusConMixEntity::getTenantId, "1")
|
|
|
+ .eq(BusConMixEntity::getType, ConstantMixEnum.drugCate));
|
|
|
+ if(CollUtil.isNotEmpty(drugCons)){
|
|
|
+ conMixService.saveBatch(drugCons.stream().peek(mix->{
|
|
|
+ mix.setId(null);
|
|
|
+ mix.setTenantId(entity.getId());
|
|
|
+ }).collect(Collectors.toSet()));
|
|
|
+ }
|
|
|
+
|
|
|
+ //设置默认报警原因
|
|
|
+ List<BusConAlarmEntity> alarmCauses = conAlarmService.list(new QueryWrapper<BusConAlarmEntity>()
|
|
|
+ .lambda().eq(BusConAlarmEntity::getTenantId, "1"));
|
|
|
+ if (CollUtil.isNotEmpty(alarmCauses)) {
|
|
|
+ conAlarmService.saveBatch(alarmCauses.stream().peek(alarmCause->{
|
|
|
+ alarmCause.setId(null);
|
|
|
+ alarmCause.setTenantId(entity.getId());
|
|
|
+ }).collect(Collectors.toSet()));
|
|
|
+ };
|
|
|
+
|
|
|
+ sendIotAddHospital(entity);
|
|
|
}
|
|
|
|
|
|
+ private void sendIotAddHospital(BusHospitalEntity source){
|
|
|
+ IotHospitalAddDTO sendMsg = new IotHospitalAddDTO();
|
|
|
+ sendMsg.setCode(source.getCode());
|
|
|
+ sendMsg.setUsername(source.getName());
|
|
|
+ sendMsg.setMobile(RandomUtil.randomNumbers(11));
|
|
|
+ sendMsg.setEmail(source.getEmail());
|
|
|
+ sendMsg.setRegionCode(source.getAreaCode());
|
|
|
+ String content= new StringBuffer(sendMsg.getUsername()).append("&").append("yunzhineng").toString();
|
|
|
+ sendMsg.setMd5(DigestUtil.md5Hex(content));
|
|
|
+ try {
|
|
|
+ String post = HttpUtil.post("https://iot.tuoren.com/forward-service/open/addUser", JSONUtil.toJsonStr(sendMsg));
|
|
|
+ JSONObject jsonObject = JSONUtil.parseObj(post);
|
|
|
+ if("1".equals(jsonObject.getStr("code"))){
|
|
|
+ throw new RuntimeException("新增失败,"+jsonObject.getStr("msg"));
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("iot.tuoren.com : 医院["+ source.getName()+"]新增失败",e);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
@Override
|
|
|
public void postUpdate(BusHospitalEntity entity) {
|
|
|
hospitalManagerRegister.refresh(entity.getId(),true,null!=entity.getScript());
|