巡检问题处理分页查询

master
wany 2024-08-30 15:29:38 +08:00
parent f57a9b4446
commit eb082c1cfb
9 changed files with 208 additions and 6 deletions

View File

@ -1,6 +1,9 @@
package com.gunshi.project.xyt.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gunshi.core.result.R;
import com.gunshi.project.xyt.entity.so.InspectProblemPageSo;
import com.gunshi.project.xyt.entity.vo.InspectProblemVo;
import com.gunshi.project.xyt.entity.vo.InspectTaskDetailVo;
import com.gunshi.project.xyt.model.InspectTaskDetail;
import com.gunshi.project.xyt.service.InspectTaskDetailService;
@ -8,6 +11,7 @@ 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.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@ -18,7 +22,7 @@ import java.util.List;
*/
@Tag(name = "巡查信息")
@RestController
@RequestMapping(value="/inspectTaskDetail")
@RequestMapping(value="/inspect/detail")
public class InspectTaskDetailController {
@Autowired
@ -36,4 +40,10 @@ public class InspectTaskDetailController {
public R<List<InspectTaskDetailVo>> inspectInfo(@Schema(name = "taskId",description = "任务id") @RequestParam(name = "taskId") Long taskId) {
return R.ok(service.inspectInfo(taskId));
}
@Operation(summary = "巡检问题处理分页")
@PostMapping("/page")
public R<Page<InspectProblemVo>> page(@RequestBody @Validated InspectProblemPageSo page) {
return R.ok(service.pageQuery(page));
}
}

View File

@ -0,0 +1,37 @@
package com.gunshi.project.xyt.entity.so;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.gunshi.db.dto.DateTimeRangeSo;
import com.gunshi.db.dto.PageSo;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
/**
* Description:
* Created by wanyan on 2024/3/19
*
* @author wanyan
* @version 1.0
*/
@Data
@Schema(description = "分页查询对象")
public class InspectProblemPageSo {
@NotNull(message = "分页参数不能为空")
@Schema(description = "分页参数")
private PageSo pageSo;
@Schema(description="巡查人id")
@NotNull(message = "巡查人id不能为空")
@JsonSerialize(using = ToStringSerializer.class)
private Long inspectUserId;
@Schema(description="是否处理0否 1是)")
private Integer isHandle;
@Schema(description = "时间范围")
private DateTimeRangeSo dateTimeRangeSo;
}

View File

@ -1,5 +1,7 @@
package com.gunshi.project.xyt.entity.so;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.gunshi.db.dto.DateTimeRangeSo;
import com.gunshi.db.dto.PageSo;
import io.swagger.v3.oas.annotations.media.Schema;
@ -21,6 +23,11 @@ public class InspectTaskPageSo {
@Schema(description = "分页参数")
private PageSo pageSo;
@Schema(description="创建人id")
@NotNull(message = "创建人id不能为空")
@JsonSerialize(using = ToStringSerializer.class)
private Long createUserId;
@Schema(description="状态0未完成 1进行中 2已完成")
private Integer status;

View File

@ -0,0 +1,54 @@
package com.gunshi.project.xyt.entity.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.gunshi.core.dateformat.DateFormatString;
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.Date;
import java.util.List;
/**
* @Author xusan
* @Date 2023/7/4 10:28
* @Notes
**/
@Data
public class InspectProblemVo extends InspectTaskDetail {
@Schema(description="任务标题")
private String taskTitle;
@Schema(description="巡查点名称")
private String name;
@Schema(description="巡检项描述")
private String itemDesc;
@Schema(description="巡查人id")
@JsonSerialize(using = ToStringSerializer.class)
private Long inspectUserId;
@Schema(description="巡查人")
private String inspectUserName;
@Schema(description="巡查完成时间")
@JsonFormat(pattern = DateFormatString.YYYY_MM_DD_HH_MM_SS, timezone = "GMT+8")
private Date finishTime;
@Schema(description = "巡查图片")
private List<FileAssociations> inspectPics;
@Schema(description = "巡查视频")
private List<FileAssociations> inspectVideos;
@Schema(description = "处理图片")
private List<FileAssociations> handlePics;
@Schema(description = "处理视频")
private List<FileAssociations> handleVideos;
}

View File

@ -35,4 +35,10 @@ public class InspectTaskDetailVo extends InspectTaskDetail {
@Schema(description = "巡查视频")
private List<FileAssociations> inspectVideos;
@Schema(description = "处理图片")
private List<FileAssociations> handlePics;
@Schema(description = "处理视频")
private List<FileAssociations> handleVideos;
}

View File

@ -1,6 +1,9 @@
package com.gunshi.project.xyt.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gunshi.project.xyt.entity.so.InspectProblemPageSo;
import com.gunshi.project.xyt.entity.vo.InspectProblemVo;
import com.gunshi.project.xyt.entity.vo.InspectTaskDetailVo;
import com.gunshi.project.xyt.model.InspectTaskDetail;
import org.apache.ibatis.annotations.Mapper;
@ -26,4 +29,28 @@ public interface InspectTaskDetailMapper extends BaseMapper<InspectTaskDetail> {
</script>
""")
List<InspectTaskDetailVo> inspectInfo(@Param("id") Long id);
@Select("""
<script>
select t1.*,t2.name,t3.item_desc,t4.task_title,t4.inspect_user_id,t4.inspect_user_name,t4.finish_time 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
left join public.inspect_task t4 on t1.task_id =t4.id
<where>
<if test="obj.inspectUserId != null ">
t1.inspect_user_id = #{obj.inspectUserId}
</if>
<if test="obj.isHandle != null ">
t1.is_handle = #{obj.isHandle}
</if>
<if test="obj.dateTimeRangeSo != null and obj.dateTimeRangeSo.start != null">
and t4.finish_time <![CDATA[>=]]> #{obj.dateTimeRangeSo.start}
</if>
<if test="obj.dateTimeRangeSo != null and obj.dateTimeRangeSo.end != null">
and t4.finish_time <![CDATA[<=]]> #{obj.dateTimeRangeSo.end}
</if>
</where>
</script>
""")
Page<InspectProblemVo> pageQuery(Page<InspectProblemVo> page,@Param("obj") InspectProblemPageSo page1);
}

View File

@ -21,6 +21,9 @@ public interface InspectTaskMapper extends BaseMapper<InspectTask> {
with m1 as (
select t.* from public.inspect_task t
<where>
<if test="obj.createUserId != null ">
t.create_user_id = #{obj.createUserId}
</if>
<if test="obj.status != null ">
t.status = #{obj.status}
</if>

View File

@ -2,11 +2,15 @@ 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.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gunshi.project.xyt.entity.so.InspectProblemPageSo;
import com.gunshi.project.xyt.entity.vo.InspectProblemVo;
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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -25,6 +29,8 @@ import java.util.stream.Collectors;
@Transactional(rollbackFor = Exception.class)
public class InspectTaskDetailService extends ServiceImpl<InspectTaskDetailMapper, InspectTaskDetail>
{
@Autowired
private FileAssociationsService fileService;
public void saveDetail(List<InspectTaskDetail> items, Long taskId) {
items.stream().forEach(o->{
@ -55,12 +61,64 @@ public class InspectTaskDetailService extends ServiceImpl<InspectTaskDetailMappe
InspectTaskDetailVo vo = new InspectTaskDetailVo();
Long pointId = t.getKey();
vo.setPointId(pointId);
vo.setName(t.getValue().get(0).getName());
vo.setChildren(t.getValue());
List<InspectTaskDetailVo> value = t.getValue();
vo.setName(value.get(0).getName());
fillFile(value);
vo.setChildren(value);
res.add(vo);
});
return res;
}
private void fillFile(List<InspectTaskDetailVo> value) {
for (InspectTaskDetailVo record : value) {
record.setInspectPics(fileService.queryFileList(record.getId().toString(),getGroupId(),getPicType()));
record.setInspectVideos(fileService.queryFileList(record.getId().toString(),getGroupId(),getVideoType()));
if(record.getIsHandle() == 1){
record.setHandlePics(fileService.queryFileList(record.getId().toString(),getGroupId(),getHandlePicType()));
record.setHandleVideos(fileService.queryFileList(record.getId().toString(),getGroupId(),getHandleVideoType()));
}
}
}
public Page<InspectProblemVo> pageQuery(InspectProblemPageSo page) {
Page<InspectProblemVo> res = this.baseMapper.pageQuery(page.getPageSo().toPage(),page);
if (res.getRecords() != null) {
fillAttach(res.getRecords());
}
return res;
}
private void fillAttach(List<InspectProblemVo> records) {
for (InspectProblemVo record : records) {
record.setInspectPics(fileService.queryFileList(record.getId().toString(),getGroupId(),getPicType()));
record.setInspectVideos(fileService.queryFileList(record.getId().toString(),getGroupId(),getVideoType()));
if(record.getIsHandle() == 1){
record.setHandlePics(fileService.queryFileList(record.getId().toString(),getGroupId(),getHandlePicType()));
record.setHandleVideos(fileService.queryFileList(record.getId().toString(),getGroupId(),getHandleVideoType()));
}
}
}
public String getGroupId() {
return "inspectTask";
}
private String getPicType() {
return "inspectPic";
}
private String getVideoType() {
return "inspectVideo";
}
private String getHandlePicType() {
return "handlePic";
}
private String getHandleVideoType() {
return "handleVideo";
}
}

View File

@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.core.toolkit.IdWorker;
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;
@ -12,8 +11,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.stream.Collectors;
import java.util.Date;
import java.util.Objects;
/**
* :
@ -64,6 +63,7 @@ public class InspectTaskService extends ServiceImpl<InspectTaskMapper, InspectTa
if (Objects.isNull(task)) {
throw new IllegalArgumentException("当前数据不存在");
}
task.setReceiveTime(new Date());
task.setStatus(1);
return this.updateById(task);
}