设备报警和报警数据根据设备进行租户id赋值

This commit is contained in:
zhangjunwen 2024-10-21 11:03:22 +08:00
parent cfbec64bab
commit d2defd6fd0
6 changed files with 44 additions and 1 deletions

View File

@ -88,4 +88,8 @@ public class AlarmDataDO extends BaseDO {
* 报警类型 * 报警类型
*/ */
private Integer alarmType; private Integer alarmType;
/**
* 租户编号
*/
private Long tenantId;
} }

View File

@ -89,4 +89,8 @@ public class AlarmRulesDO extends BaseDO {
* 排序 * 排序
*/ */
private Integer sort; private Integer sort;
/**
* 租户编号
*/
private Long tenantId;
} }

View File

@ -61,5 +61,8 @@ public class EquipAlarmDataDO extends BaseDO {
* 机床分析状态0正常1磨损中2磨损严重 * 机床分析状态0正常1磨损中2磨损严重
*/ */
private Integer equipAnalyseStatus; private Integer equipAnalyseStatus;
/**
* 租户编号
*/
private Long tenantId;
} }

View File

@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.inspur.framework.tenant.core.aop.TenantIgnore; 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.AlarmDataDTO;
import com.inspur.module.system.dal.dataobject.alarm.EquipAlarmDataDO; 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 org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -41,10 +43,18 @@ public class AlarmDataServiceImpl implements AlarmDataService {
@Resource @Resource
private EquipAlarmDataService equipAlarmDataService; private EquipAlarmDataService equipAlarmDataService;
@Resource
private EquipInfoService equipInfoService;
@Override @Override
public Long createAlarmData(AlarmDataSaveReqVO createReqVO) { public Long createAlarmData(AlarmDataSaveReqVO createReqVO) {
// 插入 // 插入
AlarmDataDO alarmData = BeanUtils.toBean(createReqVO, AlarmDataDO.class); AlarmDataDO alarmData = BeanUtils.toBean(createReqVO, AlarmDataDO.class);
if(Objects.nonNull(alarmData.getEquipId())){
EquipInfoDO equipInfo = equipInfoService.getEquipInfo(alarmData.getEquipId());
Optional<Long> tenantIdOptional = Optional.ofNullable(equipInfo.getTenantId());
tenantIdOptional.ifPresent(alarmData::setTenantId);
}
alarmDataMapper.insert(alarmData); alarmDataMapper.insert(alarmData);
// 返回 // 返回
return alarmData.getAlarmDataId(); return alarmData.getAlarmDataId();

View File

@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.inspur.framework.tenant.core.aop.TenantIgnore; import com.inspur.framework.tenant.core.aop.TenantIgnore;
import com.inspur.module.system.dal.dataobject.alarm.AlarmRulesDTO; 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.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; 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 com.inspur.module.system.dal.mysql.alarm.AlarmRulesMapper;
import java.util.List; 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.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.inspur.module.system.enums.ErrorCodeConstants.*; import static com.inspur.module.system.enums.ErrorCodeConstants.*;
@ -36,11 +40,19 @@ public class AlarmRulesServiceImpl implements AlarmRulesService {
@Resource @Resource
private StringRedisTemplate stringRedisTemplate; private StringRedisTemplate stringRedisTemplate;
@Resource
private EquipInfoService equipInfoService;
@Override @Override
public String createAlarmRules(AlarmRulesSaveReqVO createReqVO) { public String createAlarmRules(AlarmRulesSaveReqVO createReqVO) {
// 插入 // 插入
AlarmRulesDO alarmRules = BeanUtils.toBean(createReqVO, AlarmRulesDO.class); AlarmRulesDO alarmRules = BeanUtils.toBean(createReqVO, AlarmRulesDO.class);
alarmRules.setStatus(0);//默认开启 alarmRules.setStatus(0);//默认开启
if(Objects.nonNull(alarmRules.getEquipId())){
EquipInfoDO equipInfo = equipInfoService.getEquipInfo(alarmRules.getEquipId());
Optional<Long> tenantIdOptional = Optional.ofNullable(equipInfo.getTenantId());
tenantIdOptional.ifPresent(alarmRules::setTenantId);
}
alarmRulesMapper.insert(alarmRules); alarmRulesMapper.insert(alarmRules);
stringRedisTemplate.delete(createReqVO.getEquipId()); stringRedisTemplate.delete(createReqVO.getEquipId());
// 返回 // 返回

View File

@ -8,8 +8,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.inspur.framework.tenant.core.aop.TenantIgnore; 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.AlarmRulesDO;
import com.inspur.module.system.dal.dataobject.alarm.EquipAlarmDataDTO; 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.dataobject.maintenance.MaintenanceOrderDO;
import com.inspur.module.system.dal.mysql.maintenance.MaintenanceOrderMapper; import com.inspur.module.system.dal.mysql.maintenance.MaintenanceOrderMapper;
import com.inspur.module.system.service.equip.EquipInfoService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -45,10 +47,18 @@ public class EquipAlarmDataServiceImpl implements EquipAlarmDataService {
@Resource @Resource
private MaintenanceOrderMapper maintenanceOrderMapper; private MaintenanceOrderMapper maintenanceOrderMapper;
@Resource
private EquipInfoService equipInfoService;
@Override @Override
public String createEquipAlarmData(EquipAlarmDataSaveReqVO createReqVO) { public String createEquipAlarmData(EquipAlarmDataSaveReqVO createReqVO) {
// 插入 // 插入
EquipAlarmDataDO equipAlarmData = BeanUtils.toBean(createReqVO, EquipAlarmDataDO.class); EquipAlarmDataDO equipAlarmData = BeanUtils.toBean(createReqVO, EquipAlarmDataDO.class);
if(Objects.nonNull(equipAlarmData.getEquipId())){
EquipInfoDO equipInfo = equipInfoService.getEquipInfo(equipAlarmData.getEquipId());
Optional<Long> tenantIdOptional = Optional.ofNullable(equipInfo.getTenantId());
tenantIdOptional.ifPresent(equipAlarmData::setTenantId);
}
equipAlarmDataMapper.insert(equipAlarmData); equipAlarmDataMapper.insert(equipAlarmData);
// 返回 // 返回
return equipAlarmData.getEquipAlarmId(); return equipAlarmData.getEquipAlarmId();