根据任务id查询巡查信息

master
wany 2024-08-30 13:36:20 +08:00
parent 2a23016a9d
commit f57a9b4446
7 changed files with 88 additions and 28 deletions

View File

@ -13,6 +13,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
/**
* :
* author: xusan
@ -20,7 +21,7 @@ import org.springframework.web.bind.annotation.*;
*/
@Tag(name = "巡检任务")
@RestController
@RequestMapping(value="/inspectTask")
@RequestMapping(value="/inspect/task")
public class InspectTaskController {
@Autowired
@ -57,4 +58,6 @@ public class InspectTaskController {
return R.ok(service.startInspect(id));
}
}

View File

@ -1,16 +1,14 @@
package com.gunshi.project.xyt.controller;
import com.gunshi.core.result.R;
import com.gunshi.project.xyt.entity.vo.InspectTaskDetailVo;
import com.gunshi.project.xyt.model.InspectTaskDetail;
import com.gunshi.project.xyt.service.InspectTaskDetailService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
@ -33,5 +31,9 @@ public class InspectTaskDetailController {
return R.ok(service.getByTaskId(taskId));
}
@Operation(summary = "巡查任务详情-巡查信息")
@GetMapping("/info")
public R<List<InspectTaskDetailVo>> inspectInfo(@Schema(name = "taskId",description = "任务id") @RequestParam(name = "taskId") Long taskId) {
return R.ok(service.inspectInfo(taskId));
}
}

View File

@ -0,0 +1,38 @@
package com.gunshi.project.xyt.entity.vo;
import com.gunshi.project.xyt.model.FileAssociations;
import com.gunshi.project.xyt.model.InspectTaskDetail;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.List;
/**
* @Author xusan
* @Date 2023/7/4 10:28
* @Notes
**/
@Data
public class InspectTaskDetailVo extends InspectTaskDetail {
@Schema(description="巡查点名称")
private String name;
@Schema(description="巡检项描述")
private String itemDesc;
@Schema(description="巡检项问题描述")
private String itemProblemDesc;
@Schema(description="处理建议")
private String handleSuggestion;
@Schema(description="子集")
private List<InspectTaskDetailVo> children;
@Schema(description = "巡查图片")
private List<FileAssociations> inspectPics;
@Schema(description = "巡查视频")
private List<FileAssociations> inspectVideos;
}

View File

@ -1,8 +1,13 @@
package com.gunshi.project.xyt.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gunshi.project.xyt.entity.vo.InspectTaskDetailVo;
import com.gunshi.project.xyt.model.InspectTaskDetail;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/**
* :
@ -12,4 +17,13 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface InspectTaskDetailMapper extends BaseMapper<InspectTaskDetail> {
@Select("""
<script>
select t1.*,t2.name,t3.item_desc as itemDesc,t3.problem_desc as itemProblemDesc,t3.handle_suggestion as handleSuggestion from public.inspect_task_detail t1
left join public.inspect_point t2 on t1.point_id = t2.id
left join public.inspect_item t3 on t1.item_id = t3.id
where t1.task_id = #{id}
</script>
""")
List<InspectTaskDetailVo> inspectInfo(@Param("id") Long id);
}

View File

@ -44,4 +44,5 @@ public interface InspectTaskMapper extends BaseMapper<InspectTask> {
</script>
""")
Page<InspectTask> pageQuery(Page<InspectTask> page,@Param("obj") InspectTaskPageSo pageSo);
}

View File

@ -3,13 +3,17 @@ package com.gunshi.project.xyt.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gunshi.project.xyt.entity.vo.InspectTaskDetailVo;
import com.gunshi.project.xyt.mapper.InspectTaskDetailMapper;
import com.gunshi.project.xyt.model.InspectTaskDetail;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* :
@ -42,6 +46,21 @@ public class InspectTaskDetailService extends ServiceImpl<InspectTaskDetailMappe
public List<InspectTaskDetail> getByTaskId(Long taskId) {
return this.list(new QueryWrapper<InspectTaskDetail>().eq("task_id",taskId));
}
public List<InspectTaskDetailVo> inspectInfo(Long id) {
List<InspectTaskDetailVo> res = new ArrayList<>();
List<InspectTaskDetailVo> list = this.baseMapper.inspectInfo(id);
Map<Long, List<InspectTaskDetailVo>> map = list.stream().collect(Collectors.groupingBy(InspectTaskDetailVo::getPointId));
map.entrySet().forEach(t->{
InspectTaskDetailVo vo = new InspectTaskDetailVo();
Long pointId = t.getKey();
vo.setPointId(pointId);
vo.setName(t.getValue().get(0).getName());
vo.setChildren(t.getValue());
res.add(vo);
});
return res;
}
}

View File

@ -1,12 +1,10 @@
package com.gunshi.project.xyt.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gunshi.project.xyt.entity.so.InspectTaskPageSo;
import com.gunshi.project.xyt.entity.vo.InspectTaskDetailVo;
import com.gunshi.project.xyt.mapper.InspectTaskMapper;
import com.gunshi.project.xyt.model.InspectTask;
import lombok.extern.slf4j.Slf4j;
@ -14,8 +12,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;
/**
* :
@ -58,26 +56,9 @@ public class InspectTaskService extends ServiceImpl<InspectTaskMapper, InspectTa
}
public Page<InspectTask> pageQuery(InspectTaskPageSo page) {
// LambdaQueryWrapper<InspectTask> query = Wrappers.lambdaQuery();
// if (ObjectUtils.isNotNull(page.getStatus())) {
// query.eq(InspectTask::getStatus, page.getStatus());
// }
// if (ObjectUtils.isNotNull(page.getTaskType())) {
// query.eq(InspectTask::getTaskType, page.getTaskType());
// }
// if(page.getDateTimeRangeSo() != null && page.getDateTimeRangeSo().getStart() != null){
// query.ge(InspectTask::getCreateTime,page.getDateTimeRangeSo().getStart());
// }
// if(page.getDateTimeRangeSo() != null && page.getDateTimeRangeSo().getEnd() != null){
// query.le(InspectTask::getCreateTime,page.getDateTimeRangeSo().getEnd());
// }
// query.orderByDesc(InspectTask::getCreateTime);
// Page<InspectTask> res = this.page(page.getPageSo().toPage(), query);
return this.baseMapper.pageQuery(page.getPageSo().toPage(),page);
}
public Boolean startInspect(Long id) {
InspectTask task = this.getById(id);
if (Objects.isNull(task)) {
@ -86,6 +67,8 @@ public class InspectTaskService extends ServiceImpl<InspectTaskMapper, InspectTa
task.setStatus(1);
return this.updateById(task);
}
}