@@ -1,6 +1,5 @@ | |||
package com.tuoheng.admin.controller; | |||
import com.tuoheng.admin.entity.Inspection; | |||
import com.tuoheng.admin.request.inspection.AddInspectionRequest; | |||
import com.tuoheng.admin.request.inspection.EditInspectionRequest; | |||
import com.tuoheng.admin.request.inspection.QueryInspectionPageListRequest; | |||
@@ -35,12 +34,21 @@ public class InspectionController { | |||
} | |||
/** | |||
* 获取巡检任务详细信息 | |||
* 获取巡检任务信息信息 | |||
*/ | |||
@GetMapping(value = "/{id}") | |||
@GetMapping(value = "/info/{id}") | |||
public JsonResult getInfo(@PathVariable("id") String id) { | |||
log.info("进入查询任务详情接口, id={}", id); | |||
return iInspectionService.selectOneById(id); | |||
return iInspectionService.getInspectionInfo(id); | |||
} | |||
/** | |||
* 获取巡检任务详情信息 | |||
*/ | |||
@GetMapping(value = "/details/{id}") | |||
public JsonResult getDetails(@PathVariable("id") String id) { | |||
log.info("进入查询任务详情接口, id={}", id); | |||
return iInspectionService.getInspectionDetails(id); | |||
} | |||
/** |
@@ -0,0 +1,49 @@ | |||
package com.tuoheng.admin.enums.code.inspection; | |||
/** | |||
* 查询巡检任务详情返回码 | |||
* 模块代码:23(公路管理) | |||
* 接口代码:06 (查询巡检任务详情) | |||
* | |||
* @author wanjing | |||
* @team tuoheng | |||
* @date 2022-12-01 | |||
*/ | |||
public enum QueryInspectionDetailsByIdCodeEnum { | |||
QUERY_IS_FAILED(1230600, "获取数据失败"), | |||
INSPECTION_ID_IS_NULL(1230601, "任务id为空"), | |||
INSPECTION_IS_NOT_EXIST(1230602, "任务不存在"); | |||
/** | |||
* 错误码 | |||
*/ | |||
private int code; | |||
/** | |||
* 错误信息 | |||
*/ | |||
private String msg; | |||
QueryInspectionDetailsByIdCodeEnum(int code, String msg){ | |||
this.code = code; | |||
this.msg = msg; | |||
} | |||
public int getCode() { | |||
return code; | |||
} | |||
public void setCode(int code) { | |||
this.code = code; | |||
} | |||
public String getMsg() { | |||
return msg; | |||
} | |||
public void setMsg(String msg) { | |||
this.msg = msg; | |||
} | |||
} |
@@ -3,13 +3,13 @@ package com.tuoheng.admin.enums.code.inspection; | |||
/** | |||
* 查询巡检任务详情返回码 | |||
* 模块代码:23(公路管理) | |||
* 接口代码:05 (查询巡检任务详情) | |||
* 接口代码:05 (查询巡检任务信息) | |||
* | |||
* @author wanjing | |||
* @team tuoheng | |||
* @date 2022-11-24 | |||
*/ | |||
public enum QueryInspectionByIdCodeEnum { | |||
public enum QueryInspectionInfoByIdCodeEnum { | |||
QUERY_IS_FAILED(1230500, "获取数据失败"), | |||
INSPECTION_ID_IS_NULL(1230501, "任务id为空"), | |||
@@ -25,7 +25,7 @@ public enum QueryInspectionByIdCodeEnum { | |||
*/ | |||
private String msg; | |||
QueryInspectionByIdCodeEnum(int code, String msg){ | |||
QueryInspectionInfoByIdCodeEnum(int code, String msg){ | |||
this.code = code; | |||
this.msg = msg; | |||
} |
@@ -24,12 +24,20 @@ public interface IInspectionService { | |||
JsonResult selectPageList(QueryInspectionPageListRequest queryInspectionRequest); | |||
/** | |||
* 查询巡检任务 | |||
* 查询巡检任务信息 | |||
* | |||
* @param id 巡检任务Id | |||
* @return 巡检任务 | |||
*/ | |||
JsonResult selectOneById(String id); | |||
JsonResult getInspectionInfo(String id); | |||
/** | |||
* 查询巡检任务详情 | |||
* | |||
* @param id 巡检任务Id | |||
* @return 巡检任务详情 | |||
*/ | |||
JsonResult getInspectionDetails(String id); | |||
/** | |||
* 查询巡检任务列表 |
@@ -9,10 +9,7 @@ import com.tuoheng.admin.request.inspection.QueryInspectionPageListRequest; | |||
import com.tuoheng.admin.service.inspection.add.AddInspectionService; | |||
import com.tuoheng.admin.service.inspection.delete.DeleteInspectionService; | |||
import com.tuoheng.admin.service.inspection.query.QueryInspectionByIdService; | |||
import com.tuoheng.admin.service.inspection.query.QueryInspectionListService; | |||
import com.tuoheng.admin.service.inspection.query.QueryInspectionPageListService; | |||
import com.tuoheng.admin.service.inspection.query.QueryVideoService; | |||
import com.tuoheng.admin.service.inspection.query.*; | |||
import com.tuoheng.admin.service.inspection.update.UpdateInspectionService; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import lombok.extern.slf4j.Slf4j; | |||
@@ -41,6 +38,9 @@ public class InspectionServiceImpl implements IInspectionService { | |||
@Autowired | |||
private QueryInspectionByIdService queryInspectionByIdService; | |||
@Autowired | |||
private QueryInspectionDetailsByIdService queryInspectionDetailsByIdService; | |||
@Autowired | |||
private AddInspectionService addinspectionService; | |||
@@ -68,14 +68,25 @@ public class InspectionServiceImpl implements IInspectionService { | |||
} | |||
/** | |||
* 查询巡检任务详情 | |||
* 查询巡检任务信息 | |||
* | |||
* @param id 巡检任务id | |||
* @return 巡检任务 | |||
*/ | |||
@Override | |||
public JsonResult selectOneById(String id) { | |||
return queryInspectionByIdService.getInfo(id); | |||
public JsonResult getInspectionInfo(String id) { | |||
return queryInspectionByIdService.getInspectionInfo(id); | |||
} | |||
/** | |||
* 查询巡检任务详情 | |||
* | |||
* @param id 巡检任务id | |||
* @return 巡检任务 | |||
*/ | |||
@Override | |||
public JsonResult getInspectionDetails(String id) { | |||
return queryInspectionDetailsByIdService.getInspectionDetails(id); | |||
} | |||
/** |
@@ -1,27 +1,18 @@ | |||
package com.tuoheng.admin.service.inspection.query; | |||
import cn.hutool.core.collection.CollectionUtil; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.tuoheng.admin.conver.InspectionConverMapper; | |||
import com.tuoheng.admin.entity.Inspection; | |||
import com.tuoheng.admin.entity.InspectionHistory; | |||
import com.tuoheng.admin.enums.InspectionStatusEnum; | |||
import com.tuoheng.admin.enums.code.inspection.QueryInspectionByIdCodeEnum; | |||
import com.tuoheng.admin.mapper.DeptMapper; | |||
import com.tuoheng.admin.mapper.InspectionFileMapper; | |||
import com.tuoheng.admin.enums.code.inspection.QueryInspectionInfoByIdCodeEnum; | |||
import com.tuoheng.admin.mapper.InspectionHistoryMapper; | |||
import com.tuoheng.admin.mapper.InspectionMapper; | |||
import com.tuoheng.admin.vo.InspectionDetailsVo; | |||
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 java.util.List; | |||
/** | |||
* 根据Id查询巡检任务详情业务层处理 | |||
* 根据Id查询巡检任务业务层处理 | |||
* | |||
* @author wanjing | |||
* @team tuoheng | |||
@@ -37,28 +28,17 @@ public class QueryInspectionByIdService { | |||
@Autowired | |||
private InspectionHistoryMapper inspectionHistoryMapper; | |||
public JsonResult getInfo(String id) { | |||
log.info("进入查询巡检任务详情业务"); | |||
public JsonResult getInspectionInfo(String id) { | |||
log.info("进入查询巡检任务信息业务"); | |||
JsonResult result = this.check(id); | |||
if (0 != result.getCode()) { | |||
log.info("进入查询巡检任务详情业务:校验失败:{}", result.getMsg()); | |||
log.info("进入查询巡检任务信息业务:校验失败:{}", result.getMsg()); | |||
return result; | |||
} | |||
Inspection inspection = (Inspection) result.getData(); | |||
InspectionDetailsVo inspectionDetailsVo = InspectionConverMapper.INSTANCE.fromInspectionToInspectionDetailsVo(inspection); | |||
// 任务失败,查询任务失败记录 | |||
if (InspectionStatusEnum.FLIGHT_FAILED.getCode() == inspection.getStatus()) { | |||
List<InspectionHistory> inspectionHistoryList = this.getInspectionHistoryList(id); | |||
if (CollectionUtil.isEmpty(inspectionHistoryList)) { | |||
log.info("该任务没有失败记录"); | |||
} else { | |||
inspectionDetailsVo.setInspectionHistoryList(inspectionHistoryList); | |||
} | |||
} | |||
return JsonResult.success(inspectionDetailsVo); | |||
return JsonResult.success(inspection); | |||
} | |||
/** | |||
@@ -69,7 +49,7 @@ public class QueryInspectionByIdService { | |||
private JsonResult check(String id) { | |||
// 判断任务id是否为空 | |||
if (StringUtils.isEmpty(id)) { | |||
return JsonResult.error(QueryInspectionByIdCodeEnum.INSPECTION_ID_IS_NULL.getCode(), QueryInspectionByIdCodeEnum.INSPECTION_ID_IS_NULL.getMsg()); | |||
return JsonResult.error(QueryInspectionInfoByIdCodeEnum.INSPECTION_ID_IS_NULL.getCode(), QueryInspectionInfoByIdCodeEnum.INSPECTION_ID_IS_NULL.getMsg()); | |||
} | |||
// 判断任务是否存在 | |||
@@ -78,21 +58,9 @@ public class QueryInspectionByIdService { | |||
.eq(Inspection::getMark, 1)); | |||
if (null == inspection) { | |||
return JsonResult.error(QueryInspectionByIdCodeEnum.INSPECTION_IS_NOT_EXIST.getCode(), QueryInspectionByIdCodeEnum.INSPECTION_IS_NOT_EXIST.getMsg()); | |||
return JsonResult.error(QueryInspectionInfoByIdCodeEnum.INSPECTION_IS_NOT_EXIST.getCode(), QueryInspectionInfoByIdCodeEnum.INSPECTION_IS_NOT_EXIST.getMsg()); | |||
} | |||
return JsonResult.success(inspection); | |||
} | |||
/** | |||
* 检查参数 | |||
* @param id | |||
* @return | |||
*/ | |||
private List<InspectionHistory> getInspectionHistoryList(String id) { | |||
List<InspectionHistory> inspectionHistoryList = inspectionHistoryMapper.selectList(new LambdaQueryWrapper<InspectionHistory>() | |||
.eq(InspectionHistory::getInspectionId, id) | |||
.eq(InspectionHistory::getMark, 1)); | |||
return inspectionHistoryList; | |||
} | |||
} |
@@ -0,0 +1,98 @@ | |||
package com.tuoheng.admin.service.inspection.query; | |||
import cn.hutool.core.collection.CollectionUtil; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.tuoheng.admin.conver.InspectionConverMapper; | |||
import com.tuoheng.admin.entity.Inspection; | |||
import com.tuoheng.admin.entity.InspectionHistory; | |||
import com.tuoheng.admin.enums.InspectionStatusEnum; | |||
import com.tuoheng.admin.enums.code.inspection.QueryInspectionDetailsByIdCodeEnum; | |||
import com.tuoheng.admin.mapper.InspectionHistoryMapper; | |||
import com.tuoheng.admin.mapper.InspectionMapper; | |||
import com.tuoheng.admin.vo.InspectionDetailsVo; | |||
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 java.util.List; | |||
/** | |||
* 根据Id查询巡检任务详情业务层处理 | |||
* | |||
* @author wanjing | |||
* @team tuoheng | |||
* @date 2022-11-25 | |||
*/ | |||
@Slf4j | |||
@Service | |||
public class QueryInspectionDetailsByIdService { | |||
@Autowired | |||
private InspectionMapper inspectionMapper; | |||
@Autowired | |||
private InspectionHistoryMapper inspectionHistoryMapper; | |||
public JsonResult getInspectionDetails(String id) { | |||
log.info("进入查询巡检任务详情业务"); | |||
JsonResult result = this.check(id); | |||
if (0 != result.getCode()) { | |||
log.info("进入查询巡检任务详情业务:校验失败:{}", result.getMsg()); | |||
return result; | |||
} | |||
Inspection inspection = (Inspection) result.getData(); | |||
InspectionDetailsVo inspectionDetailsVo = InspectionConverMapper.INSTANCE.fromInspectionToInspectionDetailsVo(inspection); | |||
// 任务失败,查询任务失败记录 | |||
if (InspectionStatusEnum.FLIGHT_FAILED.getCode() == inspection.getStatus()) { | |||
List<InspectionHistory> inspectionHistoryList = this.getInspectionHistoryList(id); | |||
if (CollectionUtil.isEmpty(inspectionHistoryList)) { | |||
log.info("该任务没有失败记录"); | |||
} else { | |||
inspectionDetailsVo.setInspectionHistoryList(inspectionHistoryList); | |||
} | |||
} | |||
return JsonResult.success(inspectionDetailsVo); | |||
} | |||
/** | |||
* 检查参数 | |||
* | |||
* @param id | |||
* @return | |||
*/ | |||
private JsonResult check(String id) { | |||
// 判断任务id是否为空 | |||
if (StringUtils.isEmpty(id)) { | |||
return JsonResult.error(QueryInspectionDetailsByIdCodeEnum.INSPECTION_ID_IS_NULL.getCode(), QueryInspectionDetailsByIdCodeEnum.INSPECTION_ID_IS_NULL.getMsg()); | |||
} | |||
// 判断任务是否存在 | |||
Inspection inspection = inspectionMapper.selectOne(new LambdaQueryWrapper<Inspection>() | |||
.eq(Inspection::getId, id) | |||
.eq(Inspection::getMark, 1)); | |||
if (null == inspection) { | |||
return JsonResult.error(QueryInspectionDetailsByIdCodeEnum.INSPECTION_IS_NOT_EXIST.getCode(), QueryInspectionDetailsByIdCodeEnum.INSPECTION_IS_NOT_EXIST.getMsg()); | |||
} | |||
return JsonResult.success(inspection); | |||
} | |||
/** | |||
* 检查参数 | |||
* | |||
* @param id | |||
* @return | |||
*/ | |||
private List<InspectionHistory> getInspectionHistoryList(String id) { | |||
List<InspectionHistory> inspectionHistoryList = inspectionHistoryMapper.selectList(new LambdaQueryWrapper<InspectionHistory>() | |||
.eq(InspectionHistory::getInspectionId, id) | |||
.eq(InspectionHistory::getMark, 1)); | |||
return inspectionHistoryList; | |||
} | |||
} |