Browse Source

租户信息的新增

2024年9月26日16:09:25
thing_master
lishuai 1 year ago
parent
commit
cf4e70f3e5
  1. 18
      modules/thing/src/main/java/com/thing/sys/tenant/service/impl/SysTenantDetailServiceImpl.java

18
modules/thing/src/main/java/com/thing/sys/tenant/service/impl/SysTenantDetailServiceImpl.java

@ -13,6 +13,8 @@ import com.thing.common.core.enumeration.*;
import com.thing.common.core.exception.ErrorCode;
import com.thing.common.core.exception.SysException;
import com.thing.common.core.utils.ConvertUtils;
import com.thing.common.core.utils.DateTimeUtils;
import com.thing.common.core.utils.TokenGenerator;
import com.thing.common.core.web.response.PageData;
import com.thing.common.orm.service.impl.BaseServiceImpl;
import com.thing.common.orm.utils.IdGenerator;
@ -44,8 +46,10 @@ import com.thing.sys.tenant.mapper.SysTenantGroupMapper;
import com.thing.sys.tenant.mapper.SysTenantMapper;
import com.thing.sys.tenant.service.SysTenantDetailService;
import com.thing.sys.tenant.service.SysTenantGroupService;
import com.thing.thing.cache.service.ThingCache;
import com.thing.thing.context.service.ThingManageContextService;
import com.thing.thing.entity.entity.IotThingEntity;
import com.thing.thing.model.entity.IotThingModelEntity;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.context.ApplicationEventPublisher;
@ -87,6 +91,7 @@ public class SysTenantDetailServiceImpl extends BaseServiceImpl<SysTenantDetailM
private final SysIndustryTypeService sysIndustryTypeService;
private final ThingManageContextService thingManageContextService;
private final ThingCache thingCache;
private final ApplicationEventPublisher applicationEventPublisher;
@ -395,7 +400,7 @@ public class SysTenantDetailServiceImpl extends BaseServiceImpl<SysTenantDetailM
IotThingEntity iotThingEntity = new IotThingEntity()
.setCode(item.getCode())
.setName(item.getCode())
.setRealType("1")
.setRealType("0")
.setEnableStatus("1")
.setTemplateMark(TemplateMark.NO.getValue())
.setType("默认物类型");
@ -406,13 +411,20 @@ public class SysTenantDetailServiceImpl extends BaseServiceImpl<SysTenantDetailM
if(CollectionUtil.isNotEmpty(codes)){
//修改分配企业数
thingManageContextService.updateModelAuthNumByCodes(codes);
}
}
}
try {
// 保存企业物至物管理表
thingManageContextService.saveModel(Collections.singletonList(thingCode));
IotThingModelEntity modelEntity = new IotThingModelEntity()
.setCode(thingCode)
.setToken(TokenGenerator.generateValue())
.setRealType("0")
.setGateway(GateWayStatus.NO_GATE_WAY.getValue())
.setStatus(ThingStatus.NOT_CONNECTED.getCode())
.setOrigin(QueueOriginType.MQTT_CLIENT.name())
.setStatusTs(DateTimeUtils.getCurrentTime());
thingManageContextService.saveOneModel(modelEntity);
} catch (Exception e) {
throw new SysException("保存失败,请检查数据源配置");
}

Loading…
Cancel
Save