全周期档案导出
parent
0eb4f97f13
commit
f38fb5d9ae
|
|
@ -11,6 +11,7 @@ import com.gunshi.project.xyt.validate.markers.Update;
|
|||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
|
@ -68,6 +69,12 @@ public class ProjectEventsController extends AbstractCommonFileController{
|
|||
return R.ok(service.filePage(page));
|
||||
}
|
||||
|
||||
@Operation(summary = "导出")
|
||||
@PostMapping("/export")
|
||||
public void export(@RequestBody @Validated CommonDataPageSo page, HttpServletResponse response) {
|
||||
service.export(page,response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupId() {
|
||||
return "ProjectEvents";
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
package com.gunshi.project.xyt.entity.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnore;
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
|
|
@ -13,25 +17,54 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class ProjectEventsVo {
|
||||
|
||||
@Schema(description="主键")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
@ExcelIgnore
|
||||
private Long id;
|
||||
|
||||
@Schema(description="发生日期")
|
||||
@JsonFormat(pattern = DateFormatString.YYYY_MM_DD, timezone = "GMT+8")
|
||||
@ExcelProperty({"发生日期"})
|
||||
@ColumnWidth(20)
|
||||
private Date eventsDate;
|
||||
|
||||
@Schema(description="类型(1大事记 2调度指令 3维修养护 4安全鉴定 5除险加固 6白蚁普查)")
|
||||
@ExcelIgnore
|
||||
private Integer type;
|
||||
|
||||
@Schema(description="类型")
|
||||
@ExcelProperty({"类型"})
|
||||
private String typeName;
|
||||
|
||||
@Schema(description="事件内容描述")
|
||||
@ExcelProperty({"事件内容描述"})
|
||||
@ColumnWidth(100)
|
||||
private String eventsDesc;
|
||||
|
||||
@TableField(exist = false)
|
||||
@Schema(description = "文件集合")
|
||||
@ExcelIgnore
|
||||
private List<FileAssociations> files;
|
||||
|
||||
|
||||
public void setType(Integer type){
|
||||
this.type = type;
|
||||
if (this.type == 1) {
|
||||
this.typeName = "大事记";
|
||||
} else if (this.type == 2) {
|
||||
this.typeName = "调度指令";
|
||||
} else if (this.type == 3) {
|
||||
this.typeName = "维修养护";
|
||||
}else if (this.type == 4) {
|
||||
this.typeName = "安全鉴定";
|
||||
}else if (this.type == 5) {
|
||||
this.typeName = "除险加固";
|
||||
}else if (this.type == 6) {
|
||||
this.typeName = "白蚁普查";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -14,6 +14,8 @@ import com.gunshi.project.xyt.model.FileAssociations;
|
|||
import com.gunshi.project.xyt.model.ProjectEvents;
|
||||
import com.gunshi.project.xyt.model.TermiteSurvey;
|
||||
import com.gunshi.project.xyt.util.DataHandleUtil;
|
||||
import com.gunshi.project.xyt.util.ExcelUtil;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
|
@ -116,6 +118,19 @@ public class ProjectEventsService extends ServiceImpl<ProjectEventsMapper, Proje
|
|||
public Page<ProjectEventsVo> filePage(CommonDataPageSo page) {
|
||||
Page<ProjectEventsVo> res = new Page<>();
|
||||
List<ProjectEventsVo> list = new ArrayList<>();
|
||||
list = queryData(page,list);
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
fillFile(list);
|
||||
list = list.stream().sorted(Comparator.comparing(ProjectEventsVo::getEventsDate).reversed()).collect(Collectors.toList());
|
||||
List<ProjectEventsVo> paginate = DataHandleUtil.paginate(list, page.getPageSo().getPageNumber(), page.getPageSo().getPageSize());
|
||||
res.setRecords(paginate);
|
||||
}
|
||||
res.setCurrent(page.getPageSo().getPageNumber());
|
||||
res.setTotal(list.size());
|
||||
return res;
|
||||
}
|
||||
|
||||
private List<ProjectEventsVo> queryData(CommonDataPageSo page,List<ProjectEventsVo> list) {
|
||||
List<Integer> types = page.getTypes();
|
||||
if(CollectionUtils.isEmpty(types) || (CollectionUtils.isNotEmpty(types)) && types.contains(1)){
|
||||
List<ProjectEventsVo> projectEventsVos = this.baseMapper.eventList(page);
|
||||
|
|
@ -138,15 +153,7 @@ public class ProjectEventsService extends ServiceImpl<ProjectEventsMapper, Proje
|
|||
List<ProjectEventsVo> projectEventsVos = this.handelTermite(termiteVos);
|
||||
list.addAll(projectEventsVos);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
fillFile(list);
|
||||
list = list.stream().sorted(Comparator.comparing(ProjectEventsVo::getEventsDate).reversed()).collect(Collectors.toList());
|
||||
List<ProjectEventsVo> paginate = DataHandleUtil.paginate(list, page.getPageSo().getPageNumber(), page.getPageSo().getPageSize());
|
||||
res.setRecords(paginate);
|
||||
}
|
||||
res.setCurrent(page.getPageSo().getPageNumber());
|
||||
res.setTotal(list.size());
|
||||
return res;
|
||||
return list;
|
||||
}
|
||||
|
||||
private List<ProjectEventsVo> handelTermite(List<TermiteSurvey> termiteVos) {
|
||||
|
|
@ -208,6 +215,15 @@ public class ProjectEventsService extends ServiceImpl<ProjectEventsMapper, Proje
|
|||
vo.setFiles(map.get(vo.getId().toString()));
|
||||
}
|
||||
}
|
||||
|
||||
public void export(CommonDataPageSo page, HttpServletResponse response) {
|
||||
List<ProjectEventsVo> list = new ArrayList<>();
|
||||
list = queryData(page,list);
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
list = list.stream().sorted(Comparator.comparing(ProjectEventsVo::getEventsDate).reversed()).collect(Collectors.toList());
|
||||
}
|
||||
ExcelUtil.exportExcel(list,"全周期档案", ProjectEventsVo.class,response,"全周期档案");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue