|
|
@@ -0,0 +1,54 @@ |
|
|
|
package com.tuoheng.admin.service.accident; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
|
|
|
import com.tuoheng.admin.entity.Accident; |
|
|
|
import com.tuoheng.admin.enums.AccidentStatusEnum; |
|
|
|
import com.tuoheng.admin.enums.FlagEnum; |
|
|
|
import com.tuoheng.admin.enums.MarkEnum; |
|
|
|
import com.tuoheng.admin.mapper.AccidentMapper; |
|
|
|
import com.tuoheng.admin.utils.CurrentUserUtil; |
|
|
|
import com.tuoheng.common.core.exception.ServiceException; |
|
|
|
import com.tuoheng.common.core.utils.JsonResult; |
|
|
|
import com.tuoheng.common.core.utils.StringUtils; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import javax.sql.rowset.serial.SerialException; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
/** |
|
|
|
* @Author ChengWang |
|
|
|
* @Date 2023/3/14 |
|
|
|
*/ |
|
|
|
@Slf4j |
|
|
|
@Service |
|
|
|
public class AccidentNoticeService { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private AccidentMapper accidentMapper; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 告警弹窗通知下发 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public JsonResult notice() { |
|
|
|
//当前登录用户 |
|
|
|
String tenantId = CurrentUserUtil.getTenantId(); |
|
|
|
if(StringUtils.isEmpty(tenantId)){ |
|
|
|
throw new ServiceException("当前用户租户id为空"); |
|
|
|
} |
|
|
|
//查询应急表是否有应急数据 |
|
|
|
List<Accident> accidentList = accidentMapper.selectList(new LambdaQueryWrapper<Accident>() |
|
|
|
.eq(Accident::getTenantId, tenantId) |
|
|
|
.eq(Accident::getStatus, AccidentStatusEnum.UNTREATED.getCode()) |
|
|
|
.eq(Accident::getFlag, FlagEnum.INSPECTION_ACCIDENT.getCode()) |
|
|
|
.eq(Accident::getMark, MarkEnum.VALID.getCode())); |
|
|
|
if(CollectionUtils.isEmpty(accidentList) || accidentList.size() == 0){ |
|
|
|
return JsonResult.success("巡检任务无应急记录产生"); |
|
|
|
} |
|
|
|
return JsonResult.success(accidentList); |
|
|
|
} |
|
|
|
} |