工程导出
This commit is contained in:
parent
5485b7bf5e
commit
acec3e5119
|
|
@ -178,7 +178,7 @@ public class SynthesisQueryServiceImpl implements SynthesisQueryService {
|
|||
@Override
|
||||
public void downloadExcel(QueryParamDto dto, HttpServletResponse response) {
|
||||
try {
|
||||
List<ProClassifyStatisticsVo> list = list = Optional.ofNullable(synthesisQueryDao.getProClassifyStatisticsList(dto)).orElseGet(ArrayList::new);
|
||||
List<ProClassifyStatisticsVo> list = Optional.ofNullable(synthesisQueryDao.getProClassifyStatisticsList(dto)).orElseGet(ArrayList::new);
|
||||
final Long[] num = {1L};
|
||||
list.forEach(vo -> {
|
||||
vo.setId(num[0]);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.bonus.imgTool.basic.controller;
|
|||
|
||||
import com.bonus.imgTool.annotation.DecryptAndVerify;
|
||||
import com.bonus.imgTool.annotation.LogAnnotation;
|
||||
import com.bonus.imgTool.backstage.entity.QueryParamDto;
|
||||
import com.bonus.imgTool.basic.service.ProService;
|
||||
import com.bonus.imgTool.basic.service.ProcessService;
|
||||
import com.bonus.imgTool.basic.vo.ProcessVo;
|
||||
|
|
@ -15,6 +16,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
@ -57,5 +59,12 @@ public class ProController {
|
|||
return ServerResponse.createErroe("更新数据失败");
|
||||
}
|
||||
|
||||
@PostMapping("downloadProExcel")
|
||||
@DecryptAndVerify(decryptedClass = ProDto.class)//加解密统一管理
|
||||
@LogAnnotation(operModul = "工程管理", operation = "导出列表", operDesc = "系统级事件",operType="导出")
|
||||
public void downloadProExcel(HttpServletResponse response, EncryptedReq<ProDto> dto) {
|
||||
service.downloadProExcel(dto.getData(),response);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
package com.bonus.imgTool.basic.service;
|
||||
|
||||
|
||||
import com.bonus.imgTool.backstage.entity.QueryParamDto;
|
||||
import com.bonus.imgTool.basic.vo.ProcessVo;
|
||||
import com.bonus.imgTool.basic.vo.dto.ProDto;
|
||||
import com.bonus.imgTool.basic.vo.dto.ProcessDto;
|
||||
import com.bonus.imgTool.utils.ServerResponse;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
public interface ProService {
|
||||
|
|
@ -13,4 +15,6 @@ public interface ProService {
|
|||
List<ProDto> getProList(ProDto data);
|
||||
|
||||
void updateProList();
|
||||
|
||||
void downloadProExcel(ProDto data, HttpServletResponse response);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,10 @@
|
|||
package com.bonus.imgTool.basic.service.impl;
|
||||
|
||||
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
||||
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
|
||||
import com.bonus.imgTool.backstage.entity.ProClassifyStatisticsVo;
|
||||
import com.bonus.imgTool.backstage.entity.QueryParamDto;
|
||||
import com.bonus.imgTool.basic.dao.ProDao;
|
||||
import com.bonus.imgTool.basic.dao.ProcessDao;
|
||||
import com.bonus.imgTool.basic.service.ProService;
|
||||
|
|
@ -11,12 +16,18 @@ import com.bonus.imgTool.system.vo.LoginUser;
|
|||
import com.bonus.imgTool.task.job.ProPullTask;
|
||||
import com.bonus.imgTool.utils.ServerResponse;
|
||||
import com.bonus.imgTool.utils.UserUtil;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
@Service
|
||||
|
|
@ -41,4 +52,25 @@ public class ProServiceImpl implements ProService {
|
|||
proPullTask.getAttTempDataTask();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadProExcel(ProDto data, HttpServletResponse response) {
|
||||
try {
|
||||
List<ProDto> list = Optional.ofNullable(dao.getProList(data)).orElseGet(ArrayList::new);
|
||||
final Long[] num = {1L};
|
||||
list.forEach(vo -> {
|
||||
vo.setId(num[0]);
|
||||
num[0]++;
|
||||
});
|
||||
ExportParams exportParams = new ExportParams("项目清单", "项目清单", ExcelType.XSSF);
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, ProDto.class, list);
|
||||
response.setContentType("application/vnd.ms-excel");
|
||||
response.setHeader("content-disposition", "attachment;fileName=" + URLEncoder.encode("项目清单" + ".xlsx", "UTF-8"));
|
||||
ServletOutputStream outputStream = response.getOutputStream();
|
||||
workbook.write(outputStream);
|
||||
outputStream.close();
|
||||
workbook.close();
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.bonus.imgTool.basic.vo.dto;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import com.bonus.imgTool.base.entity.PageEntity;
|
||||
import lombok.Data;
|
||||
|
||||
|
|
@ -14,6 +15,12 @@ import lombok.Data;
|
|||
public class ProDto extends PageEntity {
|
||||
|
||||
|
||||
/**
|
||||
* 工程id
|
||||
*/
|
||||
@Excel(name = "序号", width = 20.0, orderNum = "0")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 工程id
|
||||
*/
|
||||
|
|
@ -22,6 +29,7 @@ public class ProDto extends PageEntity {
|
|||
/**
|
||||
* 工程名称
|
||||
*/
|
||||
@Excel(name = "工程名称", width = 20.0, orderNum = "2")
|
||||
private String proName;
|
||||
|
||||
/**
|
||||
|
|
@ -33,22 +41,26 @@ public class ProDto extends PageEntity {
|
|||
/**
|
||||
* 工程类型
|
||||
*/
|
||||
@Excel(name = "工程类型", width = 20.0, orderNum = "3")
|
||||
private String proType;
|
||||
|
||||
|
||||
/**
|
||||
* 电压等级
|
||||
*/
|
||||
@Excel(name = "电压等级", width = 20.0, orderNum = "4")
|
||||
private String voltageLevel;
|
||||
|
||||
/**
|
||||
* 公司名称
|
||||
*/
|
||||
@Excel(name = "公司名称", width = 20.0, orderNum = "1")
|
||||
private String companyName;
|
||||
|
||||
/**
|
||||
* 工程地址
|
||||
*/
|
||||
@Excel(name = "工程地址", width = 20.0, orderNum = "5")
|
||||
private String origin;
|
||||
|
||||
/**
|
||||
|
|
@ -64,6 +76,7 @@ public class ProDto extends PageEntity {
|
|||
/**
|
||||
* 工程状态
|
||||
*/
|
||||
@Excel(name = "工程状态", width = 20.0, orderNum = "6")
|
||||
private String status;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -126,4 +126,6 @@ public class SafetyViolationDto extends PageEntity {
|
|||
|
||||
private String uploadType;
|
||||
|
||||
private String keyWord;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -158,6 +158,9 @@
|
|||
<if test="proStatus != null and proStatus != ''">
|
||||
and tp.status = #{proStatus}
|
||||
</if>
|
||||
<if test="keyWord != null and keyWord != ''">
|
||||
and locate(#{keyWord},tsv.check_place)
|
||||
</if>
|
||||
</where>
|
||||
GROUP BY tsv.id
|
||||
</select>
|
||||
|
|
|
|||
|
|
@ -208,6 +208,9 @@
|
|||
<if test="proStatus != null and proStatus != ''">
|
||||
and tp.status = #{proStatus}
|
||||
</if>
|
||||
<if test="keyWord != null and keyWord != ''">
|
||||
and locate(#{keyWord},tsv.vio_place)
|
||||
</if>
|
||||
</where>
|
||||
GROUP BY tsv.id
|
||||
</select>
|
||||
|
|
|
|||
|
|
@ -135,3 +135,37 @@ function updatePro() {
|
|||
}
|
||||
|
||||
|
||||
|
||||
function exportExcel() {
|
||||
let obj = {
|
||||
companyName: $('#companyName').val(),
|
||||
proName: $('#proName').val(),
|
||||
status: $('#status').val(),
|
||||
};
|
||||
let params = {
|
||||
encryptedData: encryptCBC(JSON.stringify(obj))
|
||||
}
|
||||
let loadingMsg = layer.msg("数据导出中,请稍候...", {icon: 16, scrollbar: false, time: 0,});
|
||||
let url = dataUrl + "/basic/pro/downloadProExcel?token=" + tokens + "&encryptedData=" + encodeURIComponent(encryptCBC(JSON.stringify(obj)));
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.open("post", url, true);
|
||||
xhr.responseType = "blob"; // 转换流
|
||||
xhr.setRequestHeader('Content-Type','application/json;charset=UTF-8')
|
||||
xhr.onload = function () {
|
||||
layer.close(loadingMsg);
|
||||
if (this.status === 200) {
|
||||
let blob = this.response;
|
||||
var a = document.createElement("a");
|
||||
var url = window.URL.createObjectURL(blob);
|
||||
a.href = url;
|
||||
a.download = "项目清单" + ".xlsx"; // 文件名
|
||||
} else {
|
||||
layer.msg("数据导出发生异常,请稍后重试", {icon: 16, scrollbar: false, time: 2000});
|
||||
}
|
||||
a.click();
|
||||
window.URL.revokeObjectURL(url);
|
||||
};
|
||||
xhr.send();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@
|
|||
</button>
|
||||
<button type="button" class="layui-btn layui-btn-normal layui-btn-sm btn-1" onclick="query(2)">重置
|
||||
</button>
|
||||
<button type="button" class="layui-btn layui-btn-normal layui-btn-sm btn-1" onclick="exprot()">导出
|
||||
<button type="button" class="layui-btn layui-btn-normal layui-btn-sm btn-1" onclick="exportExcel()">导出
|
||||
</button>
|
||||
<button type="button" class="layui-btn layui-btn-normal layui-btn-sm btn-1" style="width: 100px" onclick="updatePro()">更新数据
|
||||
</button>
|
||||
|
|
|
|||
Loading…
Reference in New Issue