解决白蚁普查分页查询报错;增加白蚁防治图片墙;巡检任务分成查询修改;开始巡检
parent
f3f189749d
commit
2a23016a9d
|
|
@ -51,4 +51,10 @@ public class InspectTaskController {
|
||||||
return R.ok(service.pageQuery(page));
|
return R.ok(service.pageQuery(page));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "开始巡检")
|
||||||
|
@GetMapping("/startInspect/{id}")
|
||||||
|
public R<Boolean> startInspect(@Schema(name = "id") @PathVariable("id") Long id) {
|
||||||
|
return R.ok(service.startInspect(id));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -17,7 +17,7 @@ import java.util.List;
|
||||||
* author: xusan
|
* author: xusan
|
||||||
* date: 2024-08-28 10:29:58
|
* date: 2024-08-28 10:29:58
|
||||||
*/
|
*/
|
||||||
@Tag(name = "白蚁防治宣传")
|
@Tag(name = "白蚁防治宣传资料")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping(value="/termite/adver")
|
@RequestMapping(value="/termite/adver")
|
||||||
public class TermiteAdverController extends AbstractCommonFileController{
|
public class TermiteAdverController extends AbstractCommonFileController{
|
||||||
|
|
|
||||||
|
|
@ -1,34 +1,49 @@
|
||||||
package com.gunshi.project.xyt.controller;
|
package com.gunshi.project.xyt.controller;
|
||||||
|
|
||||||
import com.gunshi.core.result.R;
|
import com.gunshi.core.result.R;
|
||||||
import com.gunshi.file.model.FileDescriptor;
|
import com.gunshi.project.xyt.model.TermiteAdverPic;
|
||||||
import com.gunshi.project.xyt.mapper.TermiteSurveyMapper;
|
import com.gunshi.project.xyt.service.TermiteAdverPicService;
|
||||||
|
import com.gunshi.project.xyt.validate.markers.Insert;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 描述: 白蚁防治宣传
|
* 描述: 白蚁防治宣传图片墙
|
||||||
* author: xusan
|
* author: xusan
|
||||||
* date: 2024-08-28 10:29:58
|
* date: 2024-08-29 17:33:09
|
||||||
*/
|
*/
|
||||||
@Tag(name = "白蚁防治宣传")
|
@Tag(name = "白蚁防治宣传图片墙")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping(value="/termite/pic")
|
@RequestMapping(value="/termite/pic")
|
||||||
public class TermiteAdverPicController extends AbstractCommonFileController{
|
public class TermiteAdverPicController extends AbstractCommonFileController{
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TermiteSurveyMapper termiteSurveyMapper;
|
private TermiteAdverPicService service;
|
||||||
|
|
||||||
@Operation(summary = "宣传图片")
|
|
||||||
@GetMapping("/list")
|
@Operation(summary = "新增")
|
||||||
public R<List<FileDescriptor>> list() {
|
@PostMapping("/insert")
|
||||||
return R.ok(termiteSurveyMapper.queryFileList(getGroupId()));
|
public R<TermiteAdverPic> insert(@Validated(Insert.class) @RequestBody TermiteAdverPic dto) {
|
||||||
|
return R.ok(service.saveData(dto));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Operation(summary = "删除")
|
||||||
|
@GetMapping("/del/{id}")
|
||||||
|
public R<Boolean> del(@Schema(name = "id") @PathVariable("id") Serializable id) {
|
||||||
|
return R.ok(service.delData(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "列表")
|
||||||
|
@PostMapping("/list")
|
||||||
|
public R<List<TermiteAdverPic>> list() {
|
||||||
|
return R.ok(service.queryList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ public class InspectTaskPageSo {
|
||||||
@Schema(description = "分页参数")
|
@Schema(description = "分页参数")
|
||||||
private PageSo pageSo;
|
private PageSo pageSo;
|
||||||
|
|
||||||
@Schema(description="状态(1未完成 2进行中 3已完成)")
|
@Schema(description="状态(0未完成 1进行中 2已完成)")
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
@Schema(description="任务类型(1日常巡查 2特别检查 3汛前巡检)")
|
@Schema(description="任务类型(1日常巡查 2特别检查 3汛前巡检)")
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ public class TermiteSurveyPageSo {
|
||||||
private PageSo pageSo;
|
private PageSo pageSo;
|
||||||
|
|
||||||
@Schema(description="年份")
|
@Schema(description="年份")
|
||||||
private Integer year;
|
private String year;
|
||||||
|
|
||||||
@Schema(description="危害情况(0无危害 1有危害)")
|
@Schema(description="危害情况(0无危害 1有危害)")
|
||||||
private Integer isHarm;
|
private Integer isHarm;
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,12 @@
|
||||||
package com.gunshi.project.xyt.mapper;
|
package com.gunshi.project.xyt.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.gunshi.project.xyt.entity.so.InspectTaskPageSo;
|
||||||
import com.gunshi.project.xyt.model.InspectTask;
|
import com.gunshi.project.xyt.model.InspectTask;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 描述: 巡检任务
|
* 描述: 巡检任务
|
||||||
|
|
@ -12,4 +16,32 @@ import org.apache.ibatis.annotations.Mapper;
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface InspectTaskMapper extends BaseMapper<InspectTask> {
|
public interface InspectTaskMapper extends BaseMapper<InspectTask> {
|
||||||
|
|
||||||
|
@Select("""
|
||||||
|
<script>
|
||||||
|
with m1 as (
|
||||||
|
select t.* from public.inspect_task t
|
||||||
|
<where>
|
||||||
|
<if test="obj.status != null ">
|
||||||
|
t.status = #{obj.status}
|
||||||
|
</if>
|
||||||
|
<if test="obj.taskType != null ">
|
||||||
|
and t.task_type = #{obj.taskType}
|
||||||
|
</if>
|
||||||
|
<if test="obj.dateTimeRangeSo != null and obj.dateTimeRangeSo.start != null">
|
||||||
|
and t.create_time <![CDATA[>=]]> #{obj.dateTimeRangeSo.start}
|
||||||
|
</if>
|
||||||
|
<if test="obj.dateTimeRangeSo != null and obj.dateTimeRangeSo.end != null">
|
||||||
|
and t.create_time <![CDATA[<=]]> #{obj.dateTimeRangeSo.end}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
),
|
||||||
|
m2 as (select task_id,count(is_normal) as problemNum from inspect_task_detail where is_normal = 0 GROUP BY task_id),
|
||||||
|
m3 as (select task_id,count(is_handle) as handleNum from inspect_task_detail where is_handle = 0 GROUP BY task_id)
|
||||||
|
select m1.*,m2.problemNum,m3.handleNum from m1
|
||||||
|
left join m2 on m1.id = m2.task_id
|
||||||
|
left join m3 on m1.id = m3.task_id
|
||||||
|
order by m1.create_time desc
|
||||||
|
</script>
|
||||||
|
""")
|
||||||
|
Page<InspectTask> pageQuery(Page<InspectTask> page,@Param("obj") InspectTaskPageSo pageSo);
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
package com.gunshi.project.xyt.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.gunshi.project.xyt.model.TermiteAdverPic;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 描述: 白蚁防治宣传图片墙
|
||||||
|
* author: xusan
|
||||||
|
* date: 2024-08-29 17:33:09
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface TermiteAdverPicMapper extends BaseMapper<TermiteAdverPic> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -29,11 +29,14 @@ public interface TermiteSurveyMapper extends BaseMapper<TermiteSurvey> {
|
||||||
left join m2 on m1.id = m2.survey_id
|
left join m2 on m1.id = m2.survey_id
|
||||||
left join m3 on m1.id = m3.survey_id
|
left join m3 on m1.id = m3.survey_id
|
||||||
<where>
|
<where>
|
||||||
<if test="obj.year != null ">
|
<if test="obj.year != null and obj.year != ''">
|
||||||
m1.year = #{obj.year}
|
m1.year = #{obj.year}
|
||||||
</if>
|
</if>
|
||||||
<if test="obj.isHarm != null ">
|
<if test="obj.isHarm != null and obj.isHarm == 1">
|
||||||
m2.harmNum > 0
|
and m2.harmNum > 0
|
||||||
|
</if>
|
||||||
|
<if test="obj.isHarm != null and obj.isHarm == 0">
|
||||||
|
and m2.harmNum is null
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
order by m1.report_date desc
|
order by m1.report_date desc
|
||||||
|
|
|
||||||
|
|
@ -113,10 +113,10 @@ public class InspectTask implements Serializable {
|
||||||
private Date finishTime;
|
private Date finishTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 状态(1未完成 2进行中 3已完成)
|
* 状态(0未完成 1进行中 2已完成)
|
||||||
*/
|
*/
|
||||||
@TableField(value="status")
|
@TableField(value="status")
|
||||||
@Schema(description="状态(1未完成 2进行中 3已完成)")
|
@Schema(description="状态(0未完成 1进行中 2已完成)")
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
package com.gunshi.project.xyt.model;
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
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 io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.Size;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 描述: 白蚁防治宣传图片墙
|
||||||
|
* author: xusan
|
||||||
|
* date: 2024-08-29 17:33:08
|
||||||
|
*/
|
||||||
|
@Schema(description="白蚁防治宣传图片墙")
|
||||||
|
@Data
|
||||||
|
@TableName("public.termite_adver_pic")
|
||||||
|
public class TermiteAdverPic implements Serializable {
|
||||||
|
|
||||||
|
public final static String thisTableName = "TermiteAdverPic";
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键
|
||||||
|
*/
|
||||||
|
@TableId(value="id", type= IdType.AUTO)
|
||||||
|
@Schema(description="主键")
|
||||||
|
@JsonSerialize(using = ToStringSerializer.class)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 图片标题
|
||||||
|
*/
|
||||||
|
@TableField(value="pic_title")
|
||||||
|
@Schema(description="图片标题")
|
||||||
|
@Size(max = 50,message = "图片标题最大长度要小于 50")
|
||||||
|
private String picTitle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
@TableField(value="create_time")
|
||||||
|
@Schema(description="创建时间")
|
||||||
|
@JsonFormat(pattern = DateFormatString.YYYY_MM_DD_HH_MM_SS, timezone = "GMT+8")
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
@Schema(description = "图片")
|
||||||
|
private FileAssociations pic;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -78,11 +78,11 @@ public class TermiteSurvey implements Serializable {
|
||||||
|
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
@Schema(description = "白蚁危害处数")
|
@Schema(description = "白蚁危害处数")
|
||||||
private Integer harmNum;
|
private Integer harmNum = 0;
|
||||||
|
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
@Schema(description = "已处置处数")
|
@Schema(description = "已处置处数")
|
||||||
private Integer handleNum;
|
private Integer handleNum = 0;
|
||||||
|
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
@Schema(description = "明细")
|
@Schema(description = "明细")
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ public class InspectTaskService extends ServiceImpl<InspectTaskMapper, InspectTa
|
||||||
|
|
||||||
public InspectTask saveData(InspectTask dto) {
|
public InspectTask saveData(InspectTask dto) {
|
||||||
dto.setId(IdWorker.getId());
|
dto.setId(IdWorker.getId());
|
||||||
dto.setStatus(1);
|
dto.setStatus(0);
|
||||||
dto.setCreateTime(new Date());
|
dto.setCreateTime(new Date());
|
||||||
this.save(dto);
|
this.save(dto);
|
||||||
inspectTaskDetailService.saveDetail(dto.getItems(),dto.getId());
|
inspectTaskDetailService.saveDetail(dto.getItems(),dto.getId());
|
||||||
|
|
@ -58,22 +58,33 @@ public class InspectTaskService extends ServiceImpl<InspectTaskMapper, InspectTa
|
||||||
}
|
}
|
||||||
|
|
||||||
public Page<InspectTask> pageQuery(InspectTaskPageSo page) {
|
public Page<InspectTask> pageQuery(InspectTaskPageSo page) {
|
||||||
LambdaQueryWrapper<InspectTask> query = Wrappers.lambdaQuery();
|
// LambdaQueryWrapper<InspectTask> query = Wrappers.lambdaQuery();
|
||||||
if (ObjectUtils.isNotNull(page.getStatus())) {
|
// if (ObjectUtils.isNotNull(page.getStatus())) {
|
||||||
query.eq(InspectTask::getStatus, 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);
|
||||||
}
|
}
|
||||||
if (ObjectUtils.isNotNull(page.getTaskType())) {
|
|
||||||
query.eq(InspectTask::getTaskType, page.getTaskType());
|
|
||||||
|
|
||||||
|
public Boolean startInspect(Long id) {
|
||||||
|
InspectTask task = this.getById(id);
|
||||||
|
if (Objects.isNull(task)) {
|
||||||
|
throw new IllegalArgumentException("当前数据不存在");
|
||||||
}
|
}
|
||||||
if(page.getDateTimeRangeSo() != null && page.getDateTimeRangeSo().getStart() != null){
|
task.setStatus(1);
|
||||||
query.ge(InspectTask::getCreateTime,page.getDateTimeRangeSo().getStart());
|
return this.updateById(task);
|
||||||
}
|
|
||||||
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 res;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,65 @@
|
||||||
|
package com.gunshi.project.xyt.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.gunshi.project.xyt.mapper.TermiteAdverPicMapper;
|
||||||
|
import com.gunshi.project.xyt.model.FileAssociations;
|
||||||
|
import com.gunshi.project.xyt.model.TermiteAdverPic;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 描述: 白蚁防治宣传图片墙
|
||||||
|
* author: xusan
|
||||||
|
* date: 2024-08-29 17:33:09
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public class TermiteAdverPicService extends ServiceImpl<TermiteAdverPicMapper, TermiteAdverPic>
|
||||||
|
{
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private FileAssociationsService fileService;
|
||||||
|
|
||||||
|
public TermiteAdverPic saveData(TermiteAdverPic dto) {
|
||||||
|
dto.setId(IdWorker.getId());
|
||||||
|
dto.setCreateTime(new Date());
|
||||||
|
boolean result = this.save(dto);
|
||||||
|
if (result) {
|
||||||
|
fileService.saveFile(Arrays.asList(dto.getPic()), getGroupId(), String.valueOf(dto.getId()));
|
||||||
|
}
|
||||||
|
return dto;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGroupId() {
|
||||||
|
return "termiteAdverPic";
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean delData(Serializable id) {
|
||||||
|
if (Objects.isNull(this.getById(id))) {
|
||||||
|
throw new IllegalArgumentException("当前数据不存在");
|
||||||
|
}
|
||||||
|
boolean data = this.removeById(id);
|
||||||
|
if (data) {
|
||||||
|
fileService.deleteFile(getGroupId(), id.toString());
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<TermiteAdverPic> queryList() {
|
||||||
|
List<TermiteAdverPic> list = new ArrayList<>();
|
||||||
|
for(TermiteAdverPic pic : list){
|
||||||
|
List<FileAssociations> files = fileService.getFiles(getGroupId(), pic.getId().toString());
|
||||||
|
pic.setPic(files.get(0));
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -66,6 +66,8 @@ public class TermiteSurveyService extends ServiceImpl<TermiteSurveyMapper, Termi
|
||||||
}
|
}
|
||||||
|
|
||||||
public Page<TermiteSurvey> pageQuery(TermiteSurveyPageSo page) {
|
public Page<TermiteSurvey> pageQuery(TermiteSurveyPageSo page) {
|
||||||
|
System.out.println(page.getIsHarm() == null);
|
||||||
|
System.out.println(page.getIsHarm() != null);
|
||||||
return this.baseMapper.pageQuery(page.getPageSo().toPage(),page);
|
return this.baseMapper.pageQuery(page.getPageSo().toPage(),page);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue