From 06eeaf07b62ba255f029a665396e45a3e48a5efd Mon Sep 17 00:00:00 2001 From: cwchen <1048842385@qq.com> Date: Thu, 3 Apr 2025 16:25:28 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=88=86=E7=B1=BB=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/SynthesisQueryController.java | 33 ++++--- .../backstage/dao/SynthesisQueryDao.java | 10 +++ .../entity/ProClassifyStatisticsVo.java | 32 +++++++ .../backstage/entity/SynthesisNumVo.java | 9 ++ .../service/SynthesisQueryService.java | 13 +++ .../impl/SynthesisQueryServiceImpl.java | 54 ++++++++++-- .../backstage/SynthesisQueryMapper.xml | 29 ++++++ .../synthesisQuery/proClassifyStatistics.js | 88 +++++++++++++------ .../synthesisQuery/proClassifyStatistics.html | 11 +-- 9 files changed, 230 insertions(+), 49 deletions(-) create mode 100644 src/main/java/com/bonus/imgTool/backstage/entity/ProClassifyStatisticsVo.java diff --git a/src/main/java/com/bonus/imgTool/backstage/controller/SynthesisQueryController.java b/src/main/java/com/bonus/imgTool/backstage/controller/SynthesisQueryController.java index 6fbccb5..c623047 100644 --- a/src/main/java/com/bonus/imgTool/backstage/controller/SynthesisQueryController.java +++ b/src/main/java/com/bonus/imgTool/backstage/controller/SynthesisQueryController.java @@ -1,7 +1,11 @@ package com.bonus.imgTool.backstage.controller; +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.annotation.DecryptAndVerify; import com.bonus.imgTool.annotation.LogAnnotation; +import com.bonus.imgTool.backstage.entity.ProClassifyStatisticsVo; import com.bonus.imgTool.backstage.entity.QueryParamDto; import com.bonus.imgTool.backstage.entity.SynthesisQueryVo; import com.bonus.imgTool.backstage.service.SynthesisQueryService; @@ -13,12 +17,18 @@ import com.bonus.imgTool.utils.ServerResponse; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.apache.poi.ss.usermodel.Workbook; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletResponse; +import java.net.URLEncoder; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -32,6 +42,7 @@ import java.util.Map; */ @RestController @RequestMapping("/backstage/synthesisQuery/") +@Slf4j public class SynthesisQueryController { @Resource(name = "SynthesisQueryService") @@ -65,19 +76,19 @@ public class SynthesisQueryController { return synthesisQueryService.generateWatermark(data.getData()); } - /*@PostMapping(value = "getProClassifyStatisticsList") + @PostMapping(value = "getProClassifyStatisticsList") @DecryptAndVerify(decryptedClass = QueryParamDto.class)//加解密统一管理 - @LogAnnotation(operModul = "综合查询-照片综合查询", operation = "查询照片", operDesc = "系统级事件",operType="查询") + @LogAnnotation(operModul = "综合查询-项目分类统计", operation = "查询列表", operDesc = "系统级事件",operType="查询") public ServerResponse getProClassifyStatisticsList(EncryptedReq dto) { PageHelper.startPage(dto.getData().getPageNum(), dto.getData().getPageSize()); - Map map = new HashMap(); - try { - PageInfo pageInfo = synthesisQueryService.getProClassifyStatisticsList(dto.getData()); - return ServerResponse.createSuccessPage(pageInfo, dto.getData().getPage(), dto.getData().getLimit()); - } catch (Exception e) { - log.error(e.toString(), e); - } - return ServerResponse.createErrorPage(dto.getData().getPage(), dto.getData().getLimit()); - }*/ + return synthesisQueryService.getProClassifyStatisticsList(dto.getData()); + } + + @PostMapping("downloadExcel") + @DecryptAndVerify(decryptedClass = QueryParamDto.class)//加解密统一管理 + @LogAnnotation(operModul = "综合查询-项目分类统计", operation = "导出列表", operDesc = "系统级事件",operType="导出") + public void downloadExcel(HttpServletResponse response, EncryptedReq dto) { + synthesisQueryService.downloadExcel(dto.getData(),response); + } } diff --git a/src/main/java/com/bonus/imgTool/backstage/dao/SynthesisQueryDao.java b/src/main/java/com/bonus/imgTool/backstage/dao/SynthesisQueryDao.java index 9cac711..5c32732 100644 --- a/src/main/java/com/bonus/imgTool/backstage/dao/SynthesisQueryDao.java +++ b/src/main/java/com/bonus/imgTool/backstage/dao/SynthesisQueryDao.java @@ -4,6 +4,7 @@ import com.bonus.imgTool.backstage.entity.ComprehensiveQueryVo; import com.bonus.imgTool.backstage.entity.QueryParamDto; import com.bonus.imgTool.backstage.entity.SynthesisNumVo; import com.bonus.imgTool.backstage.entity.SynthesisQueryVo; +import com.bonus.imgTool.backstage.entity.ProClassifyStatisticsVo; import org.springframework.stereotype.Repository; import java.util.List; @@ -67,5 +68,14 @@ public interface SynthesisQueryDao { */ String getSyData(SynthesisQueryVo vo); + /** + * 项目分类统计 + * @param dto + * @return List + * @author cwchen + * @date 2025/4/3 15:37 + */ + List getProClassifyStatisticsList(QueryParamDto dto); + void deleteComprehensiveQuery(Long id); } diff --git a/src/main/java/com/bonus/imgTool/backstage/entity/ProClassifyStatisticsVo.java b/src/main/java/com/bonus/imgTool/backstage/entity/ProClassifyStatisticsVo.java new file mode 100644 index 0000000..a30b970 --- /dev/null +++ b/src/main/java/com/bonus/imgTool/backstage/entity/ProClassifyStatisticsVo.java @@ -0,0 +1,32 @@ +package com.bonus.imgTool.backstage.entity; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.Date; + +/** + * @className:ProClassifyStatisticsVo + * @author:cwchen + * @date:2025-04-03-15:31 + * @version:1.0 + * @description:项目分类统计-vo + */ +@Data +public class ProClassifyStatisticsVo extends SynthesisNumVo{ + + @Excel(name = "序号", width = 10.0, orderNum = "0") + private Long id; + /**工程ID*/ + private Long proId; + /**工程名称*/ + @Excel(name = "工程名称", width = 30.0, orderNum = "1") + private String proName; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "最后更新时间", width = 20.0, orderNum = "8",format = "yyyy-MM-dd HH:mm:ss") + private Date lastUpdateTime; + +} diff --git a/src/main/java/com/bonus/imgTool/backstage/entity/SynthesisNumVo.java b/src/main/java/com/bonus/imgTool/backstage/entity/SynthesisNumVo.java index 0c8eac2..7d68d74 100644 --- a/src/main/java/com/bonus/imgTool/backstage/entity/SynthesisNumVo.java +++ b/src/main/java/com/bonus/imgTool/backstage/entity/SynthesisNumVo.java @@ -1,5 +1,7 @@ package com.bonus.imgTool.backstage.entity; +import cn.afterturn.easypoi.excel.annotation.Excel; +import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; /** @@ -13,15 +15,22 @@ import lombok.Data; public class SynthesisNumVo { /**总照片数量*/ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "总照片数量", width = 20.0, orderNum = "2") private int totalNum; /**安全违章*/ + @Excel(name = "安全违章", width = 20.0, orderNum = "3") private int safetyVioNum; /**质量检查*/ + @Excel(name = "质量检查", width = 20.0, orderNum = "4") private int qualityInsNum; /**安全措施落实*/ + @Excel(name = "安全措施落实", width = 20.0, orderNum = "5") private int safetyMeasNum; /**协调照片*/ + @Excel(name = "协调照片", width = 20.0, orderNum = "6") private int coordinatedPhotoNum; /**重要事项及宣传类*/ + @Excel(name = "重要事项及宣传类", width = 20.0, orderNum = "7") private int importIssuesAndPublicityNum; } diff --git a/src/main/java/com/bonus/imgTool/backstage/service/SynthesisQueryService.java b/src/main/java/com/bonus/imgTool/backstage/service/SynthesisQueryService.java index 54cdad7..3a59990 100644 --- a/src/main/java/com/bonus/imgTool/backstage/service/SynthesisQueryService.java +++ b/src/main/java/com/bonus/imgTool/backstage/service/SynthesisQueryService.java @@ -5,6 +5,8 @@ import com.bonus.imgTool.backstage.entity.QueryParamDto; import com.bonus.imgTool.backstage.entity.SynthesisQueryVo; import com.bonus.imgTool.utils.ServerResponse; +import javax.servlet.http.HttpServletResponse; + /** * @className:SynthesisQueryService * @author:cwchen @@ -64,6 +66,17 @@ public interface SynthesisQueryService { */ ServerResponse generateWatermark(SynthesisQueryVo data); + /** + * 项目分类统计查询 + * @param data + * @return ServerResponse + * @author cwchen + * @date 2025/4/3 15:31 + */ + ServerResponse getProClassifyStatisticsList(QueryParamDto data); + + void downloadExcel(QueryParamDto data, HttpServletResponse response); + /** * 综合查询删除 * @param id diff --git a/src/main/java/com/bonus/imgTool/backstage/service/impl/SynthesisQueryServiceImpl.java b/src/main/java/com/bonus/imgTool/backstage/service/impl/SynthesisQueryServiceImpl.java index a045c83..fa07ff6 100644 --- a/src/main/java/com/bonus/imgTool/backstage/service/impl/SynthesisQueryServiceImpl.java +++ b/src/main/java/com/bonus/imgTool/backstage/service/impl/SynthesisQueryServiceImpl.java @@ -1,10 +1,10 @@ package com.bonus.imgTool.backstage.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.dao.SynthesisQueryDao; -import com.bonus.imgTool.backstage.entity.ComprehensiveQueryVo; -import com.bonus.imgTool.backstage.entity.QueryParamDto; -import com.bonus.imgTool.backstage.entity.SynthesisNumVo; -import com.bonus.imgTool.backstage.entity.SynthesisQueryVo; +import com.bonus.imgTool.backstage.entity.*; import com.bonus.imgTool.backstage.service.SynthesisQueryService; import com.bonus.imgTool.system.vo.LoginUser; import com.bonus.imgTool.utils.HighQualityWatermark; @@ -15,14 +15,17 @@ import com.bonus.imgTool.webResult.Constants; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import lombok.extern.slf4j.Slf4j; -import org.apache.catalina.security.SecurityUtil; import org.apache.commons.lang3.StringUtils; +import org.apache.poi.ss.usermodel.Workbook; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.interceptor.TransactionAspectSupport; import javax.annotation.Resource; +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletResponse; import java.io.File; +import java.net.URLEncoder; import java.text.SimpleDateFormat; import java.util.*; import java.util.stream.Collectors; @@ -152,4 +155,45 @@ public class SynthesisQueryServiceImpl implements SynthesisQueryService { String localPath = SystemUtils.getUploadPath() +File.separator+ vo.getOriginalFilePath(); return HighQualityWatermark.generateWatermark(watermarkLines,localPath); } + + @Override + public ServerResponse getProClassifyStatisticsList(QueryParamDto dto) { + List list = null; + try { + String roleLevel = Optional.ofNullable(UserUtil.getLoginUser()).map(LoginUser::getRoleLevel).orElse("0"); + String proIds = Optional.ofNullable(UserUtil.getLoginUser()).map(LoginUser::getProIds).orElse("-1"); + if(Objects.equals(roleLevel, Constants.ROLE_LEVEL)){ // 项目部级 + List proList = Arrays.stream(proIds.split(",")).map(String::trim).filter(s -> !s.isEmpty()).map(Long::valueOf).collect(Collectors.toList()); + dto.setProIds(proList); + } + dto.setRoleLevel(roleLevel); + list = Optional.ofNullable(synthesisQueryDao.getProClassifyStatisticsList(dto)).orElseGet(ArrayList::new); + } catch (Exception e) { + log.error(e.toString(),e); + } + PageInfo pageInfo = new PageInfo<>(list); + return ServerResponse.createSuccessPage(pageInfo, dto.getPageNum(), dto.getPageSize()); + } + + @Override + public void downloadExcel(QueryParamDto dto, HttpServletResponse response) { + try { + List list = list = Optional.ofNullable(synthesisQueryDao.getProClassifyStatisticsList(dto)).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, ProClassifyStatisticsVo.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); + } + } } diff --git a/src/main/resources/mappers/backstage/SynthesisQueryMapper.xml b/src/main/resources/mappers/backstage/SynthesisQueryMapper.xml index c570371..77b6b5f 100644 --- a/src/main/resources/mappers/backstage/SynthesisQueryMapper.xml +++ b/src/main/resources/mappers/backstage/SynthesisQueryMapper.xml @@ -214,6 +214,35 @@ + + diff --git a/src/main/resources/static/js/synthesisQuery/proClassifyStatistics.js b/src/main/resources/static/js/synthesisQuery/proClassifyStatistics.js index 38c8bfb..5e16192 100644 --- a/src/main/resources/static/js/synthesisQuery/proClassifyStatistics.js +++ b/src/main/resources/static/js/synthesisQuery/proClassifyStatistics.js @@ -5,12 +5,14 @@ layui.use(['form', 'layer', 'table'], function () { layer = layui.layer; table = layui.table; layui.form.render(); + let pros = getProsSelect(); + setSelectValueName(pros,'proId','请选择工程'); pages(1, 10, 1); }) function pages(pageNum, pageSize, typeNum) { let params = getReqParams(pageNum, pageSize, typeNum); - let url = dataUrl + "/users/getList" + let url = dataUrl + "/backstage/synthesisQuery/getProClassifyStatisticsList" ajaxRequest(url, "POST", params, true, function () { }, function (result) { console.log(result); @@ -65,48 +67,48 @@ function initTable(dataList, limit, page) { return (page - 1) * limit + d.LAY_NUM; } }, - {field: "loginName", title: "项目名称", width: "23%", unresize: true, align: "center"}, + {field: "proName", title: "项目名称", width: "21%", unresize: true, align: "center"}, { - field: "username", title: "总照片数量", width: "8%", unresize: true, align: "center", + field: "totalNum", title: "总照片数量", width: "8%", unresize: true, align: "center", templet: function (d) { - return "
0
"; + return "
"+d.totalNum+"
"; } }, { - field: "username", title: "安全违章", width: "8%", unresize: true, align: "center", + field: "safetyVioNum", title: "安全违章", width: "8%", unresize: true, align: "center", templet: function (d) { - return "
0
"; + return "
"+d.safetyVioNum+"
"; } }, { - field: "username", title: "质量检查", width: "8%", unresize: true, align: "center", + field: "qualityInsNum", title: "质量检查", width: "8%", unresize: true, align: "center", templet: function (d) { - return "
0
"; + return "
"+d.qualityInsNum+"
"; } }, { - field: "username", title: "安全措施落实", width: "10%", unresize: true, align: "center", + field: "safetyMeasNum", title: "安全措施落实", width: "10%", unresize: true, align: "center", templet: function (d) { - return "
0
"; + return "
"+d.safetyMeasNum+"
"; } }, { - field: "username", title: "协调照片 ", width: "8%", unresize: true, align: "center", + field: "coordinatedPhotoNum", title: "协调照片 ", width: "8%", unresize: true, align: "center", templet: function (d) { - return "
0
"; + return "
"+d.coordinatedPhotoNum+"
"; } }, { - field: "username", title: "重要事项及宣传 ", width: "10%", unresize: true, align: "center", + field: "importIssuesAndPublicityNum", title: "重要事项及宣传 ", width: "10%", unresize: true, align: "center", templet: function (d) { - return "
0
"; + return "
"+d.importIssuesAndPublicityNum+"
"; } }, { - field: "createTime", title: "最后更新时间", width: "10%", align: "center", templet: 'center', + field: "lastUpdateTime", title: "最后更新时间", width: "14%", align: "center", templet: 'center', }, { - title: "操作", unresize: true, width: "10%", align: "center", + title: "操作", unresize: true, width: "8%", align: "center", templet: function (d) { let html = ''; let view = "" @@ -133,16 +135,16 @@ function getReqParams(page, limit, type) { let obj = {}; if (!type) { obj = { - page: page + "", - limit: limit + "", - keyWord: $('#keyWord').val(), + pageNum: page + "", + pageSize: limit + "", + id: $('#proId').val(), }; } else { obj = { - page: '1', - limit: '10', - keyWord: '', + pageNum: '1', + pageSize: '10', + id: '', }; } obj = { @@ -154,14 +156,12 @@ function getReqParams(page, limit, type) { // 查询/重置 function query(type) { pageNum = 1; + if(type === 2){ + $('#proId').val(''); + layui.form.render(); + } pages(1, limitSize); } - - -//重置 -function reset() { - pages(1, limitSize, 1) -} /**详情*/ function viewData(obj){ openIframeByParamObj("viewData", "详情", "./proClassifyStatisticsDetail.html", "92%", "95%", obj); @@ -172,3 +172,35 @@ function viewImg(obj,type){ obj.type = type; openIframeByParamObj("viewImg", "图片详情", "./photoView.html", "92%", "85%", obj); } + +/*下载*/ +function downloadExcel(){ + let obj = { + id: $('#proId').val() + } + let params = { + encryptedData: encryptCBC(JSON.stringify(obj)) + } + let loadingMsg = layer.msg("数据导出中,请稍候...", {icon: 16, scrollbar: false, time: 0,}); + let url = dataUrl + "/backstage/synthesisQuery/downloadExcel?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(params); + xhr.send(); +} \ No newline at end of file diff --git a/src/main/resources/static/pages/synthesisQuery/proClassifyStatistics.html b/src/main/resources/static/pages/synthesisQuery/proClassifyStatistics.html index 22df3ff..1f43d28 100644 --- a/src/main/resources/static/pages/synthesisQuery/proClassifyStatistics.html +++ b/src/main/resources/static/pages/synthesisQuery/proClassifyStatistics.html @@ -9,6 +9,7 @@ + @@ -19,22 +20,22 @@