diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/dataobject/alarm/AlarmDataDO.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/dataobject/alarm/AlarmDataDO.java index acf60c8..2bbc377 100644 --- a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/dataobject/alarm/AlarmDataDO.java +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/dataobject/alarm/AlarmDataDO.java @@ -88,4 +88,8 @@ public class AlarmDataDO extends BaseDO { * 报警类型 */ private Integer alarmType; + /** + * 租户编号 + */ + private Long tenantId; } diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/dataobject/alarm/AlarmRulesDO.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/dataobject/alarm/AlarmRulesDO.java index f51055a..081be56 100644 --- a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/dataobject/alarm/AlarmRulesDO.java +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/dataobject/alarm/AlarmRulesDO.java @@ -89,4 +89,8 @@ public class AlarmRulesDO extends BaseDO { * 排序 */ private Integer sort; + /** + * 租户编号 + */ + 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/alarm/EquipAlarmDataDO.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/dataobject/alarm/EquipAlarmDataDO.java index 3e457bb..2d7c3d5 100644 --- a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/dataobject/alarm/EquipAlarmDataDO.java +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/dataobject/alarm/EquipAlarmDataDO.java @@ -61,5 +61,8 @@ public class EquipAlarmDataDO extends BaseDO { * 机床分析状态(0:正常,1:磨损中,2:磨损严重) */ private Integer equipAnalyseStatus; - + /** + * 租户编号 + */ + private Long tenantId; } diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/alarm/AlarmDataServiceImpl.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/alarm/AlarmDataServiceImpl.java index 9a4079b..c855aae 100644 --- a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/alarm/AlarmDataServiceImpl.java +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/alarm/AlarmDataServiceImpl.java @@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.inspur.framework.tenant.core.aop.TenantIgnore; import com.inspur.module.system.dal.dataobject.alarm.AlarmDataDTO; import com.inspur.module.system.dal.dataobject.alarm.EquipAlarmDataDO; +import com.inspur.module.system.dal.dataobject.equip.EquipInfoDO; +import com.inspur.module.system.service.equip.EquipInfoService; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -41,10 +43,18 @@ public class AlarmDataServiceImpl implements AlarmDataService { @Resource private EquipAlarmDataService equipAlarmDataService; + @Resource + private EquipInfoService equipInfoService; + @Override public Long createAlarmData(AlarmDataSaveReqVO createReqVO) { // 插入 AlarmDataDO alarmData = BeanUtils.toBean(createReqVO, AlarmDataDO.class); + if(Objects.nonNull(alarmData.getEquipId())){ + EquipInfoDO equipInfo = equipInfoService.getEquipInfo(alarmData.getEquipId()); + Optional tenantIdOptional = Optional.ofNullable(equipInfo.getTenantId()); + tenantIdOptional.ifPresent(alarmData::setTenantId); + } alarmDataMapper.insert(alarmData); // 返回 return alarmData.getAlarmDataId(); diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/alarm/AlarmRulesServiceImpl.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/alarm/AlarmRulesServiceImpl.java index 8afa4e5..f80a862 100644 --- a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/alarm/AlarmRulesServiceImpl.java +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/alarm/AlarmRulesServiceImpl.java @@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.inspur.framework.tenant.core.aop.TenantIgnore; import com.inspur.module.system.dal.dataobject.alarm.AlarmRulesDTO; +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; @@ -17,6 +19,8 @@ import com.inspur.framework.common.util.object.BeanUtils; import com.inspur.module.system.dal.mysql.alarm.AlarmRulesMapper; import java.util.List; +import java.util.Objects; +import java.util.Optional; import static com.inspur.framework.common.exception.util.ServiceExceptionUtil.exception; import static com.inspur.module.system.enums.ErrorCodeConstants.*; @@ -36,11 +40,19 @@ public class AlarmRulesServiceImpl implements AlarmRulesService { @Resource private StringRedisTemplate stringRedisTemplate; + @Resource + private EquipInfoService equipInfoService; + @Override public String createAlarmRules(AlarmRulesSaveReqVO createReqVO) { // 插入 AlarmRulesDO alarmRules = BeanUtils.toBean(createReqVO, AlarmRulesDO.class); alarmRules.setStatus(0);//默认开启 + if(Objects.nonNull(alarmRules.getEquipId())){ + EquipInfoDO equipInfo = equipInfoService.getEquipInfo(alarmRules.getEquipId()); + Optional tenantIdOptional = Optional.ofNullable(equipInfo.getTenantId()); + tenantIdOptional.ifPresent(alarmRules::setTenantId); + } alarmRulesMapper.insert(alarmRules); stringRedisTemplate.delete(createReqVO.getEquipId()); // 返回 diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/alarm/EquipAlarmDataServiceImpl.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/alarm/EquipAlarmDataServiceImpl.java index 75dcc8c..b018c57 100644 --- a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/alarm/EquipAlarmDataServiceImpl.java +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/alarm/EquipAlarmDataServiceImpl.java @@ -8,8 +8,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.inspur.framework.tenant.core.aop.TenantIgnore; import com.inspur.module.system.dal.dataobject.alarm.AlarmRulesDO; import com.inspur.module.system.dal.dataobject.alarm.EquipAlarmDataDTO; +import com.inspur.module.system.dal.dataobject.equip.EquipInfoDO; import com.inspur.module.system.dal.dataobject.maintenance.MaintenanceOrderDO; import com.inspur.module.system.dal.mysql.maintenance.MaintenanceOrderMapper; +import com.inspur.module.system.service.equip.EquipInfoService; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -45,10 +47,18 @@ public class EquipAlarmDataServiceImpl implements EquipAlarmDataService { @Resource private MaintenanceOrderMapper maintenanceOrderMapper; + @Resource + private EquipInfoService equipInfoService; + @Override public String createEquipAlarmData(EquipAlarmDataSaveReqVO createReqVO) { // 插入 EquipAlarmDataDO equipAlarmData = BeanUtils.toBean(createReqVO, EquipAlarmDataDO.class); + if(Objects.nonNull(equipAlarmData.getEquipId())){ + EquipInfoDO equipInfo = equipInfoService.getEquipInfo(equipAlarmData.getEquipId()); + Optional tenantIdOptional = Optional.ofNullable(equipInfo.getTenantId()); + tenantIdOptional.ifPresent(equipAlarmData::setTenantId); + } equipAlarmDataMapper.insert(equipAlarmData); // 返回 return equipAlarmData.getEquipAlarmId();