diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/admin/gatewayinfo/vo/GatewayInfoSaveReqVO.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/admin/gatewayinfo/vo/GatewayInfoSaveReqVO.java index 9117824..bff040b 100644 --- a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/admin/gatewayinfo/vo/GatewayInfoSaveReqVO.java +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/admin/gatewayinfo/vo/GatewayInfoSaveReqVO.java @@ -49,4 +49,6 @@ public class GatewayInfoSaveReqVO { @Schema(description = "机床网关编号") private String gatewayCode; + + private Integer tenantId; } diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/dataobject/gatewayinfo/GatewayCardInfoDO.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/dataobject/gatewayinfo/GatewayCardInfoDO.java index 6b30a5b..2c5ce61 100644 --- a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/dataobject/gatewayinfo/GatewayCardInfoDO.java +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/dataobject/gatewayinfo/GatewayCardInfoDO.java @@ -56,4 +56,8 @@ public class GatewayCardInfoDO extends BaseDO { */ private String msgType; + /** + * 租户编号 + */ + private Long tenantId; } \ No newline at end of file diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/dataobject/gatewayinfo/GatewayCardParamsDO.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/dataobject/gatewayinfo/GatewayCardParamsDO.java index a790d0a..6df6c5e 100644 --- a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/dataobject/gatewayinfo/GatewayCardParamsDO.java +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/dataobject/gatewayinfo/GatewayCardParamsDO.java @@ -52,4 +52,8 @@ public class GatewayCardParamsDO extends BaseDO { */ private String paramMappingName; + /** + * 租户编号 + */ + private Long tenantId; } \ No newline at end of file diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/dataobject/gatewayinfo/GatewayInfoDO.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/dataobject/gatewayinfo/GatewayInfoDO.java index 4d3a332..23c0b10 100644 --- a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/dataobject/gatewayinfo/GatewayInfoDO.java +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/dataobject/gatewayinfo/GatewayInfoDO.java @@ -78,4 +78,8 @@ public class GatewayInfoDO extends BaseDO { */ private String gatewayCode; + /** + * 租户编号 + */ + private Long tenantId; } diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/gatewayinfo/GatewayCardInfoServiceImpl.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/gatewayinfo/GatewayCardInfoServiceImpl.java index a1584d5..d7f7b3b 100644 --- a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/gatewayinfo/GatewayCardInfoServiceImpl.java +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/gatewayinfo/GatewayCardInfoServiceImpl.java @@ -1,7 +1,10 @@ package com.inspur.module.system.service.gatewayinfo; +import com.inspur.framework.common.util.string.StrUtils; +import com.inspur.module.system.dal.dataobject.equip.EquipInfoDO; import com.inspur.module.system.dal.dataobject.gatewayinfo.GatewayCardParamsDO; import com.inspur.module.system.dal.mysql.gatewayinfo.GatewayCardParamsMapper; +import com.inspur.module.system.service.equip.EquipInfoService; import org.springframework.stereotype.Component; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -37,10 +40,18 @@ public class GatewayCardInfoServiceImpl implements GatewayCardInfoService { @Resource private GatewayCardParamsMapper gatewayCardParamsMapper; + @Resource + private EquipInfoService equipInfoService; + @Override public String createGatewayCardInfo(GatewayCardInfoSaveReqVO createReqVO) { // 插入 GatewayCardInfoDO gatewayCardInfo = BeanUtils.toBean(createReqVO, GatewayCardInfoDO.class); + if(Objects.nonNull(gatewayCardInfo.getEquipId())){ + EquipInfoDO equipInfo = equipInfoService.getEquipInfo(gatewayCardInfo.getEquipId()); + Optional tenantIdOptional = Optional.ofNullable(equipInfo.getTenantId()); + tenantIdOptional.ifPresent(gatewayCardInfo::setTenantId); + } gatewayCardInfoMapper.insert(gatewayCardInfo); // 返回 return gatewayCardInfo.getGatewayId(); diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/gatewayinfo/GatewayCardParamsServiceImpl.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/gatewayinfo/GatewayCardParamsServiceImpl.java index 6355f34..45471b2 100644 --- a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/gatewayinfo/GatewayCardParamsServiceImpl.java +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/gatewayinfo/GatewayCardParamsServiceImpl.java @@ -1,5 +1,7 @@ package com.inspur.module.system.service.gatewayinfo; +import com.inspur.module.system.dal.dataobject.equip.EquipInfoDO; +import com.inspur.module.system.service.equip.EquipInfoService; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -8,6 +10,7 @@ import org.springframework.transaction.annotation.Transactional; import java.util.*; import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; import com.inspur.module.system.controller.admin.gatewayinfo.vo.*; import com.inspur.module.system.dal.dataobject.gatewayinfo.GatewayCardParamsDO; @@ -35,10 +38,18 @@ public class GatewayCardParamsServiceImpl implements GatewayCardParamsService { @Resource private StringRedisTemplate stringRedisTemplate; + @Resource + private EquipInfoService equipInfoService; + @Override public String createGatewayCardParams(GatewayCardParamsSaveReqVO createReqVO) { // 插入 GatewayCardParamsDO gatewayCardParams = BeanUtils.toBean(createReqVO, GatewayCardParamsDO.class); + if(Objects.nonNull(gatewayCardParams.getEquipId())){ + EquipInfoDO equipInfo = equipInfoService.getEquipInfo(gatewayCardParams.getEquipId()); + Optional tenantIdOptional = Optional.ofNullable(equipInfo.getTenantId()); + tenantIdOptional.ifPresent(gatewayCardParams::setTenantId); + } gatewayCardParamsMapper.insert(gatewayCardParams); // 返回 return gatewayCardParams.getChannelId(); @@ -53,10 +64,16 @@ public class GatewayCardParamsServiceImpl implements GatewayCardParamsService { return true; } String gatewayId = paramsList.get(0).getGatewayId(); + String equipId = paramsList.get(0).getEquipId(); if(Boolean.TRUE.equals(stringRedisTemplate.hasKey("cardmapping_" + gatewayId))){ stringRedisTemplate.delete("cardmapping_" + gatewayId); } List gatewayCardParamsList = BeanUtils.toBean(paramsList, GatewayCardParamsDO.class); + if(Objects.nonNull(equipId)){ + EquipInfoDO equipInfo = equipInfoService.getEquipInfo(equipId); + Optional tenantIdOptional = Optional.ofNullable(equipInfo.getTenantId()); + gatewayCardParamsList = gatewayCardParamsList.stream().peek(cardParamInfo -> tenantIdOptional.ifPresent(cardParamInfo::setTenantId)).collect(Collectors.toList()); + } return gatewayCardParamsMapper.insertBatch(gatewayCardParamsList); } diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/gatewayinfo/GatewayInfoServiceImpl.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/gatewayinfo/GatewayInfoServiceImpl.java index e852678..1c465c5 100644 --- a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/gatewayinfo/GatewayInfoServiceImpl.java +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/gatewayinfo/GatewayInfoServiceImpl.java @@ -2,9 +2,11 @@ package com.inspur.module.system.service.gatewayinfo; import com.inspur.framework.common.util.json.JsonUtils; import com.inspur.framework.tenant.core.aop.TenantIgnore; +import com.inspur.module.system.dal.dataobject.equip.EquipInfoDO; import com.inspur.module.system.dal.dataobject.gatewayinfo.GatewayCardInfoDO; import com.inspur.module.system.dal.dataobject.gatewayinfo.GatewayCardParamsDO; import com.inspur.module.system.dal.dataobject.gatewayinfo.GatewayInfoDetailsDTO; +import com.inspur.module.system.service.equip.EquipInfoService; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Service; @@ -43,6 +45,9 @@ public class GatewayInfoServiceImpl implements GatewayInfoService { @Resource private GatewayCardParamsService gatewayCardParamsService; + @Resource + private EquipInfoService equipInfoService; + @Resource private StringRedisTemplate stringRedisTemplate; @@ -61,6 +66,11 @@ public class GatewayInfoServiceImpl implements GatewayInfoService { createReqVO.setStatus(0);//默认正常 // 插入 GatewayInfoDO gatewayInfo = BeanUtils.toBean(createReqVO, GatewayInfoDO.class); + if(Objects.nonNull(gatewayInfo.getEquipId())){ + EquipInfoDO equipInfo = equipInfoService.getEquipInfo(gatewayInfo.getEquipId()); + Optional tenantIdOptional = Optional.ofNullable(equipInfo.getTenantId()); + tenantIdOptional.ifPresent(gatewayInfo::setTenantId); + } gatewayInfoMapper.insert(gatewayInfo); // 返回 return gatewayInfo.getGatewayId(); diff --git a/imt-ui/src/views/system/gatewayinfo/index.vue b/imt-ui/src/views/system/gatewayinfo/index.vue index 240627a..56d4710 100644 --- a/imt-ui/src/views/system/gatewayinfo/index.vue +++ b/imt-ui/src/views/system/gatewayinfo/index.vue @@ -376,6 +376,7 @@ export default { cardLoading: false, expandGateway: {}, expandRowKeys: [], + selectedGatewayId: null, }; }, created() { @@ -401,7 +402,12 @@ export default { }, async getCardList(id) { try { - this.cardQueryParams.gatewayId = id; + if (id) { + this.cardQueryParams.gatewayId = id; + } else { + this.cardQueryParams.gatewayId = this.selectedGatewayId; + } + this.cardLoading = true; const res = await GatewayCardInfoApi.getGatewayCardInfoPage( this.cardQueryParams @@ -413,6 +419,7 @@ export default { } }, openCardForm(id, row) { + this.selectedGatewayId = row.gatewayId; this.$refs["cardFormRef"].open(id, row, this.expandGateway); }, async handleCardDelete(row) { @@ -422,7 +429,7 @@ export default { ); try { await GatewayCardInfoApi.deleteGatewayCardInfo(cardId); - await this.getList(); + await this.getCardList(row.gatewayId); this.$modal.msgSuccess("删除成功"); } catch {} },