@@ -1,5 +1,6 @@ | |||
package com.tuoheng.admin.controller; | |||
import com.tuoheng.admin.entity.request.warningrecord.QueryWarningRecordByEmergencyMissionIdRequest; | |||
import com.tuoheng.admin.entity.request.warningrecord.QueryWarningRecordListByWarningIdRequest; | |||
import com.tuoheng.admin.service.warningrecord.IWarningRecordService; | |||
import com.tuoheng.common.utils.JsonResult; | |||
@@ -29,4 +30,12 @@ public class WarningRecordController { | |||
return warningRecordService.getListByWarningId(request); | |||
} | |||
/** | |||
* 根据应急任务ID查询预警记录 | |||
*/ | |||
@GetMapping("/one/by/emergencyMissionId") | |||
public JsonResult getOneByEmergencyMissionId(QueryWarningRecordByEmergencyMissionIdRequest request) { | |||
return warningRecordService.getOneByEmergencyMissionId(request); | |||
} | |||
} |
@@ -0,0 +1,24 @@ | |||
package com.tuoheng.admin.entity.request.warningrecord; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Data; | |||
import java.io.Serializable; | |||
/** | |||
* 查询预警记录列表请求实体 | |||
* | |||
* @author: qiujinyang | |||
*/ | |||
@Data | |||
public class QueryWarningRecordByEmergencyMissionIdRequest implements Serializable { | |||
private static final long serialVersionUID = 1L; | |||
@ApiModelProperty(value = "租户Id", hidden = true) | |||
private Integer tenantId; | |||
@ApiModelProperty(value = "预警Id", hidden = true) | |||
private Integer emergencyMissionId; | |||
} |
@@ -1,5 +1,6 @@ | |||
package com.tuoheng.admin.service.warningrecord; | |||
import com.tuoheng.admin.entity.request.warningrecord.QueryWarningRecordByEmergencyMissionIdRequest; | |||
import com.tuoheng.admin.entity.request.warningrecord.QueryWarningRecordListByWarningIdRequest; | |||
import com.tuoheng.common.utils.JsonResult; | |||
@@ -20,6 +21,14 @@ public interface IWarningRecordService { | |||
*/ | |||
JsonResult getListByWarningId(QueryWarningRecordListByWarningIdRequest request); | |||
/** | |||
* 根据应急任务ID查询预警记录 | |||
* | |||
* @param request 预警记录 | |||
* @return 预警记录集合 | |||
*/ | |||
JsonResult getOneByEmergencyMissionId(QueryWarningRecordByEmergencyMissionIdRequest request); | |||
/** | |||
* 查询预警记录 | |||
* |
@@ -1,6 +1,8 @@ | |||
package com.tuoheng.admin.service.warningrecord; | |||
import com.tuoheng.admin.entity.request.warningrecord.QueryWarningRecordByEmergencyMissionIdRequest; | |||
import com.tuoheng.admin.entity.request.warningrecord.QueryWarningRecordListByWarningIdRequest; | |||
import com.tuoheng.admin.service.warningrecord.query.QueryWarningRecordByEmergencyMissionIdService; | |||
import com.tuoheng.admin.service.warningrecord.query.QueryWarningRecordListByWarningIdService; | |||
import com.tuoheng.common.utils.JsonResult; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
@@ -19,6 +21,9 @@ public class WarningRecordServiceImpl implements IWarningRecordService { | |||
@Autowired | |||
private QueryWarningRecordListByWarningIdService queryWarningRecordListByWarningIdService; | |||
@Autowired | |||
private QueryWarningRecordByEmergencyMissionIdService queryWarningRecordByEmergencyMissionIdService; | |||
/** | |||
* 查询预警记录列表 | |||
* | |||
@@ -30,6 +35,17 @@ public class WarningRecordServiceImpl implements IWarningRecordService { | |||
return queryWarningRecordListByWarningIdService.getListByWarningId(request); | |||
} | |||
/** | |||
* 根据应急任务ID查询预警记录 | |||
* | |||
* @param request 预警记录 | |||
* @return 预警记录 | |||
*/ | |||
@Override | |||
public JsonResult getOneByEmergencyMissionId(QueryWarningRecordByEmergencyMissionIdRequest request) { | |||
return queryWarningRecordByEmergencyMissionIdService.getOneByEmergencyMissionId(request); | |||
} | |||
/** | |||
* 查询预警记录 | |||
* |
@@ -0,0 +1,81 @@ | |||
package com.tuoheng.admin.service.warningrecord.query; | |||
import cn.hutool.core.util.ObjectUtil; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.tuoheng.admin.conver.WarningRecordConverMapper; | |||
import com.tuoheng.admin.entity.domain.ThMission; | |||
import com.tuoheng.admin.entity.domain.WarningRecord; | |||
import com.tuoheng.admin.entity.request.warningrecord.QueryWarningRecordByEmergencyMissionIdRequest; | |||
import com.tuoheng.admin.entity.vo.warning.WarningRecordVo; | |||
import com.tuoheng.admin.enums.MarkEnum; | |||
import com.tuoheng.admin.mapper.ThMissionMapper; | |||
import com.tuoheng.admin.mapper.WarningMapper; | |||
import com.tuoheng.admin.mapper.WarningRecordMapper; | |||
import com.tuoheng.common.exception.ServiceException; | |||
import com.tuoheng.common.utils.JsonResult; | |||
import com.tuoheng.system.entity.User; | |||
import com.tuoheng.system.utils.ShiroUtils; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import java.util.List; | |||
/** | |||
* 根据应急任务ID查询预警记录业务层处理 | |||
* | |||
* @author wanjing | |||
* @team tuoheng | |||
* @date 2022-11-22 | |||
*/ | |||
@Slf4j | |||
@Service | |||
public class QueryWarningRecordByEmergencyMissionIdService { | |||
@Autowired | |||
private WarningMapper warningMapper; | |||
@Autowired | |||
private WarningRecordMapper warningRecordMapper; | |||
@Autowired | |||
private ThMissionMapper missionMapper; | |||
public JsonResult getOneByEmergencyMissionId(QueryWarningRecordByEmergencyMissionIdRequest request) { | |||
// log.info("进入根据预警ID查询预警记录列表业务"); | |||
User user = ShiroUtils.getUserInfo(); | |||
Integer tenantId = user.getTenantId(); | |||
request.setTenantId(tenantId); | |||
JsonResult result = this.check(tenantId, request); | |||
if (0 != result.getCode()) { | |||
log.info("进入根据应急任务ID查询预警记录列表业务:校验失败:{}", result.getMsg()); | |||
return result; | |||
} | |||
WarningRecord warningRecord = (WarningRecord) result.getData(); | |||
return JsonResult.success(warningRecord); | |||
} | |||
/** | |||
* 检查参数 | |||
* | |||
* @param tenantId | |||
* @param request | |||
* @return | |||
*/ | |||
private JsonResult check(Integer tenantId, QueryWarningRecordByEmergencyMissionIdRequest request) { | |||
// 判断预警id是否为空 | |||
if (ObjectUtil.isNull(request.getEmergencyMissionId())) { | |||
throw new ServiceException("应急任务ID为空"); | |||
} | |||
WarningRecord warningRecord = warningRecordMapper.selectOne(new LambdaQueryWrapper<WarningRecord>() | |||
.eq(WarningRecord::getEmergencyMissionId, request.getEmergencyMissionId()) | |||
.eq(WarningRecord::getTenantId, tenantId) | |||
.eq(WarningRecord::getMark, MarkEnum.VALID.getCode())); | |||
if (ObjectUtil.isNull(warningRecord)) { | |||
throw new ServiceException("预警记录不存在"); | |||
} | |||
return JsonResult.success(warningRecord); | |||
} | |||
} |