From c02702e70e7e3d4d131612bad4df9ebb4c21ab67 Mon Sep 17 00:00:00 2001 From: wangliwen Date: Tue, 18 Oct 2022 09:58:06 +0800 Subject: [PATCH] =?UTF-8?q?selectDeptDetailTypeCountList=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=AF=BC=E5=87=BA=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/controller/CensusController.java | 48 ++++++++++ .../SelectDeptDetailTypeCountListExcel.java | 92 +++++++++++++++++++ .../service/impl/ResourceServiceImpl.java | 2 +- 3 files changed, 141 insertions(+), 1 deletion(-) create mode 100644 renren-admin/src/main/java/io/renren/modules/resource/excel/census/SelectDeptDetailTypeCountListExcel.java diff --git a/renren-admin/src/main/java/io/renren/common/controller/CensusController.java b/renren-admin/src/main/java/io/renren/common/controller/CensusController.java index fbbd954e..c65e18f7 100644 --- a/renren-admin/src/main/java/io/renren/common/controller/CensusController.java +++ b/renren-admin/src/main/java/io/renren/common/controller/CensusController.java @@ -1,6 +1,7 @@ package io.renren.common.controller; import cn.hutool.core.util.ObjectUtil; +import com.alibaba.excel.EasyExcel; import com.alibaba.fastjson.JSONObject; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; @@ -8,6 +9,7 @@ import io.renren.common.annotation.LogOperation; import io.renren.common.utils.Result; import io.renren.modules.processForm.service.TAbilityApplicationService; import io.renren.modules.resource.dao.ResourceDao; +import io.renren.modules.resource.excel.census.SelectDeptDetailTypeCountListExcel; import io.renren.modules.resource.service.ResourceService; import io.renren.modules.resourceBrowse.service.ResourceBrowseService; import io.renren.modules.sys.dto.SysDeptDTO; @@ -25,6 +27,9 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.web.bind.annotation.*; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.net.URLEncoder; import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutorService; @@ -371,6 +376,19 @@ public class CensusController { return new Result().ok(resourceService.selectApplyDeptDetailTypeCountList(params)); } + @GetMapping("/exportSelectApplyDeptDetailTypeCountList") + @ApiOperation("导出按照部门、能力类型、组件类型统计能力使用情况") + @LogOperation("导出按照部门、能力类型、组件类型统计能力使用情况") + @ApiImplicitParams({ + @ApiImplicitParam(name = "startDate", value = "开始时间", paramType = "query", dataType = "String"), + @ApiImplicitParam(name = "endDate", value = "结束时间", paramType = "query", dataType = "String"), + @ApiImplicitParam(name = "deptId", value = "所属部门", paramType = "query", dataType = "long"), + @ApiImplicitParam(name = "approveStatus", value = "审核状态,可选值(通过、审核中)", paramType = "query", dataType = "String"), + }) + public void exportSelectApplyDeptDetailTypeCountList(@RequestParam Map params) { + // TODO 导出按照部门、能力类型、组件类型统计能力使用情况 + } + @GetMapping("/selectDeptDetailTypeCountList") @ApiOperation("按照部门、能力类型、组件类型统计能力上架情况") @LogOperation("按照部门、能力类型、组件类型统计能力上架情况") @@ -384,6 +402,36 @@ public class CensusController { return new Result().ok(resourceService.selectDeptDetailTypeCountList(params)); } + @GetMapping("/exportSelectDeptDetailTypeCountList") + @ApiOperation("导出按照部门、能力类型、组件类型统计能力上架情况") + @LogOperation("导出按照部门、能力类型、组件类型统计能力上架情况") + @ApiImplicitParams({ + @ApiImplicitParam(name = "startDate", value = "开始时间", paramType = "query", dataType = "String"), + @ApiImplicitParam(name = "endDate", value = "结束时间", paramType = "query", dataType = "String"), + @ApiImplicitParam(name = "deptId", value = "所属部门", paramType = "query", dataType = "long"), + @ApiImplicitParam(name = "approveStatus", value = "审核状态,可选值(通过、审核中)", paramType = "query", dataType = "String"), + }) + public void exportSelectDeptDetailTypeCountList(@RequestParam Map params, HttpServletResponse response) throws IOException { + ArrayList resultList = (ArrayList) resourceService.selectDeptDetailTypeCountList(params); + List date = resultList.stream().map(index -> { + SelectDeptDetailTypeCountListExcel temp = new SelectDeptDetailTypeCountListExcel(); + temp.setDeptName(index.getOrDefault("name", "").toString()); + temp.setCount(Integer.valueOf(index.getOrDefault("count", "0").toString())); + temp.setKfzj(Integer.valueOf(index.getOrDefault("kfzj", "0").toString())); + temp.setTcfw(Integer.valueOf(index.getOrDefault("tcfw", "0").toString())); + temp.setYwzj(Integer.valueOf(index.getOrDefault("ywzj", "0").toString())); + temp.setZnsf(Integer.valueOf(index.getOrDefault("znsf", "0").toString())); + temp.setYyzy(Integer.valueOf(index.getOrDefault("yyzy", "0").toString())); + return temp; + }).collect(Collectors.toList()); + // TODO 导出按照部门、能力类型、组件类型统计能力上架情况 + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setCharacterEncoding("utf-8"); + String fileName = URLEncoder.encode("导出按照部门_能力类型_组件类型统计能力上架情况", "UTF-8").replaceAll("\\+", "%20"); + response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); + EasyExcel.write(response.getOutputStream(), SelectDeptDetailTypeCountListExcel.class).sheet("数据").doWrite(date); + } + @GetMapping("/selectCensusResourceTable") @ApiOperation("查询部门上架资源及审批结果详细信息") @LogOperation("查询部门上架资源及审批结果详细信息") diff --git a/renren-admin/src/main/java/io/renren/modules/resource/excel/census/SelectDeptDetailTypeCountListExcel.java b/renren-admin/src/main/java/io/renren/modules/resource/excel/census/SelectDeptDetailTypeCountListExcel.java new file mode 100644 index 00000000..d79af22c --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/resource/excel/census/SelectDeptDetailTypeCountListExcel.java @@ -0,0 +1,92 @@ +package io.renren.modules.resource.excel.census; + +import com.alibaba.excel.annotation.ExcelProperty; + +import java.util.Objects; + + +public class SelectDeptDetailTypeCountListExcel { + @ExcelProperty({"上架部门"}) + private String deptName; + @ExcelProperty({"组件", "智能算法"}) + private Integer znsf; + @ExcelProperty({"组件", "图层服务"}) + private Integer tcfw; + @ExcelProperty({"组件", "通用开发组件"}) + private Integer kfzj; + @ExcelProperty({"组件", "业务能力组件"}) + private Integer ywzj; + @ExcelProperty({"应用资源"}) + private Integer yyzy; + @ExcelProperty({"总计"}) + private Integer count; + + public String getDeptName() { + return deptName; + } + + public void setDeptName(String deptName) { + this.deptName = deptName; + } + + public Integer getZnsf() { + return znsf; + } + + public void setZnsf(Integer znsf) { + this.znsf = znsf; + } + + public Integer getTcfw() { + return tcfw; + } + + public void setTcfw(Integer tcfw) { + this.tcfw = tcfw; + } + + public Integer getKfzj() { + return kfzj; + } + + public void setKfzj(Integer kfzj) { + this.kfzj = kfzj; + } + + public Integer getYwzj() { + return ywzj; + } + + public void setYwzj(Integer ywzj) { + this.ywzj = ywzj; + } + + public Integer getYyzy() { + return yyzy; + } + + public void setYyzy(Integer yyzy) { + this.yyzy = yyzy; + } + + public Integer getCount() { + return count; + } + + public void setCount(Integer count) { + this.count = count; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + SelectDeptDetailTypeCountListExcel that = (SelectDeptDetailTypeCountListExcel) o; + return deptName.equals(that.deptName) && znsf.equals(that.znsf) && tcfw.equals(that.tcfw) && kfzj.equals(that.kfzj) && ywzj.equals(that.ywzj) && yyzy.equals(that.yyzy) && count.equals(that.count); + } + + @Override + public int hashCode() { + return Objects.hash(deptName, znsf, tcfw, kfzj, ywzj, yyzy, count); + } +} diff --git a/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java index f6668621..a226a89c 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java @@ -897,7 +897,7 @@ public class ResourceServiceImpl extends CrudServiceImpl deptTotalCount = resourceDao.selectDeptTotalCount(); HashMap map1 = new HashMap() { { - put("0", 0); + put("1", 0); put("5", 0); put("10", 0); put("15", 0);