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..d8ddc33b 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,10 @@ 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.SelectApplyDeptDetailTypeCountListExcel; +import io.renren.modules.resource.excel.census.SelectDeptDetailTypeCountListExcel; +import io.renren.modules.resource.excel.census.config.CustomCellWriteHeightConfig; +import io.renren.modules.resource.excel.census.config.CustomCellWriteWeightConfig; import io.renren.modules.resource.service.ResourceService; import io.renren.modules.resourceBrowse.service.ResourceBrowseService; import io.renren.modules.sys.dto.SysDeptDTO; @@ -25,6 +30,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 +379,39 @@ 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, HttpServletResponse response) throws IOException { + ArrayList resultList = (ArrayList) resourceService.selectApplyDeptDetailTypeCountList(params); + List date = resultList.stream().map(index -> { + SelectApplyDeptDetailTypeCountListExcel temp = new SelectApplyDeptDetailTypeCountListExcel( + index.getOrDefault("name", "").toString(), + Integer.valueOf(index.getOrDefault("znsf", "0").toString()), + Integer.valueOf(index.getOrDefault("tcfw", "0").toString()), + Integer.valueOf(index.getOrDefault("kfzj", "0").toString()), + Integer.valueOf(index.getOrDefault("ywzy", "0").toString()), + Integer.valueOf(index.getOrDefault("yyzy", "0").toString()), + Integer.valueOf(index.getOrDefault("hys", "0").toString()), + Integer.valueOf(index.getOrDefault("count", "0").toString())); + return temp; + }).collect(Collectors.toList()); + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setCharacterEncoding("utf-8"); + String fileName = URLEncoder.encode("按照部门_能力类型_组件类型统计能力使用情况_" + System.currentTimeMillis(), "UTF-8").replaceAll("\\+", "%20"); + response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); + EasyExcel.write(response.getOutputStream(), SelectApplyDeptDetailTypeCountListExcel.class) + .registerWriteHandler(new CustomCellWriteWeightConfig()) + .registerWriteHandler(new CustomCellWriteHeightConfig()) + .sheet("使用情况").doWrite(date); + } + @GetMapping("/selectDeptDetailTypeCountList") @ApiOperation("按照部门、能力类型、组件类型统计能力上架情况") @LogOperation("按照部门、能力类型、组件类型统计能力上架情况") @@ -384,6 +425,38 @@ 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()); + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setCharacterEncoding("utf-8"); + String fileName = URLEncoder.encode("按照部门_能力类型_组件类型统计能力上架情况_" + System.currentTimeMillis(), "UTF-8").replaceAll("\\+", "%20"); + response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); + EasyExcel.write(response.getOutputStream(), SelectDeptDetailTypeCountListExcel.class) + .registerWriteHandler(new CustomCellWriteWeightConfig()) + .registerWriteHandler(new CustomCellWriteHeightConfig()) + .sheet("上架情况").doWrite(date); + } + @GetMapping("/selectCensusResourceTable") @ApiOperation("查询部门上架资源及审批结果详细信息") @LogOperation("查询部门上架资源及审批结果详细信息") @@ -398,6 +471,57 @@ public class CensusController { return new Result().ok(resourceService.selectCensusResourceTable(params)); } + @GetMapping("/exportSelectCensusResourceTable") + @ApiOperation("查询部门上架资源及审批结果详细信息") + @LogOperation("查询部门上架资源及审批结果详细信息") + @ApiImplicitParams({ + @ApiImplicitParam(name = "startDate", value = "开始时间", paramType = "query", dataType = "String"), + @ApiImplicitParam(name = "endDate", value = "结束时间", paramType = "query", dataType = "String"), + @ApiImplicitParam(name = "type", value = "资源类型", paramType = "query", dataType = "String"), + @ApiImplicitParam(name = "deptId", value = "所属部门", paramType = "query", dataType = "long"), + @ApiImplicitParam(name = "approveStatus", value = "审核状态,可选值(通过、审核中)", paramType = "query", dataType = "String"), + }) + public void exportSelectCensusResourceTable(@RequestParam Map params, HttpServletResponse response) throws IOException { + ArrayList resultList = (ArrayList) resourceService.selectCensusResourceTable(params); + List> date = resultList.stream().map(index -> { + List data = new ArrayList<>(); + data.add(index.getOrDefault("deptName", "") == null ? "" : index.getOrDefault("deptName", "").toString()); + data.add(index.getOrDefault("type", "") == null ? "" : index.getOrDefault("type", "").toString()); + data.add(index.getOrDefault("resourceName", "") == null ? "" : index.getOrDefault("resourceName", "").toString()); + data.add(index.getOrDefault("createDate", "") == null ? "" : index.getOrDefault("createDate", "").toString()); + data.add(index.getOrDefault("approveStatus", "") == null ? "" : index.getOrDefault("approveStatus", "").toString()); + return data; + }).collect(Collectors.toList()); + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setCharacterEncoding("utf-8"); + String fileName = URLEncoder.encode("部门上架资源及审批结果详细信息_" + System.currentTimeMillis(), "UTF-8").replaceAll("\\+", "%20"); + response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); + EasyExcel.write(response.getOutputStream()).head(exportSelectCensusResourceTableHead()) + .registerWriteHandler(new CustomCellWriteWeightConfig()) + .registerWriteHandler(new CustomCellWriteHeightConfig()) + .sheet("上架情况").doWrite(date); + } + + private List> exportSelectCensusResourceTableHead() { + List> list = new ArrayList<>(); + List head0 = new ArrayList<>(); + head0.add("上架部门"); + List head1 = new ArrayList<>(); + head1.add("类型"); + List head2 = new ArrayList<>(); + head2.add("资源名称"); + List head3 = new ArrayList<>(); + head3.add("日期"); + List head4 = new ArrayList<>(); + head4.add("状态"); + list.add(head0); + list.add(head1); + list.add(head2); + list.add(head3); + list.add(head4); + return list; + } + @GetMapping("/selectCensusApplyTable") @ApiOperation("查询部门申请资源及审批结果详细信息") @LogOperation("查询部门申请资源及审批结果详细信息") @@ -412,4 +536,59 @@ public class CensusController { return new Result().ok(resourceService.selectCensusApplyTable(params)); } + @GetMapping("/exportSelectCensusApplyTable") + @ApiOperation("导出查询部门申请资源及审批结果详细信息") + @LogOperation("导出查询部门申请资源及审批结果详细信息") + @ApiImplicitParams({ + @ApiImplicitParam(name = "startDate", value = "开始时间", paramType = "query", dataType = "String"), + @ApiImplicitParam(name = "endDate", value = "结束时间", paramType = "query", dataType = "String"), + @ApiImplicitParam(name = "type", value = "资源类型", paramType = "query", dataType = "String"), + @ApiImplicitParam(name = "deptId", value = "所属部门", paramType = "query", dataType = "long"), + @ApiImplicitParam(name = "approveStatus", value = "审核状态,可选值(通过、审核中)", paramType = "query", dataType = "String"), + }) + public void exportSelectCensusApplyTable(@RequestParam Map params, HttpServletResponse response) throws IOException { + ArrayList resultList = (ArrayList) resourceService.selectCensusApplyTable(params); + List> date = resultList.stream().map(index -> { + List data = new ArrayList<>(); + data.add(index.getOrDefault("resourceDeptName", "") == null ? "" : index.getOrDefault("resourceDeptName", "").toString()); + data.add(index.getOrDefault("resourceName", "") == null ? "" : index.getOrDefault("resourceName", "").toString()); + data.add(index.getOrDefault("type", "") == null ? "" : index.getOrDefault("type", "").toString()); + data.add(index.getOrDefault("deptName", "") == null ? "" : index.getOrDefault("deptName", "").toString()); + data.add(index.getOrDefault("createDate", "") == null ? "" : index.getOrDefault("createDate", "").toString()); + data.add(index.getOrDefault("approveStatus", "") == null ? "" : index.getOrDefault("approveStatus", "").toString()); + return data; + }).collect(Collectors.toList()); + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setCharacterEncoding("utf-8"); + String fileName = URLEncoder.encode("部门申请资源及审批结果详细信息_" + System.currentTimeMillis(), "UTF-8").replaceAll("\\+", "%20"); + response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); + EasyExcel.write(response.getOutputStream()).head(exportSelectCensusApplyTableHead()) + .registerWriteHandler(new CustomCellWriteWeightConfig()) + .registerWriteHandler(new CustomCellWriteHeightConfig()) + .sheet("申请情况").doWrite(date); + } + + private List> exportSelectCensusApplyTableHead() { + List> list = new ArrayList<>(); + List head0 = new ArrayList<>(); + head0.add("提供部门"); + List head1 = new ArrayList<>(); + head1.add("资源名称"); + List head2 = new ArrayList<>(); + head2.add("类型"); + List head3 = new ArrayList<>(); + head3.add("申请部门"); + List head4 = new ArrayList<>(); + head4.add("日期"); + List head5 = new ArrayList<>(); + head5.add("状态"); + list.add(head0); + list.add(head1); + list.add(head2); + list.add(head3); + list.add(head4); + list.add(head5); + return list; + } + } diff --git a/renren-admin/src/main/java/io/renren/modules/device/service/Impl/TbDeviceApplyServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/device/service/Impl/TbDeviceApplyServiceImpl.java index 05ee2fe3..4fc7d50e 100644 --- a/renren-admin/src/main/java/io/renren/modules/device/service/Impl/TbDeviceApplyServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/device/service/Impl/TbDeviceApplyServiceImpl.java @@ -91,6 +91,10 @@ public class TbDeviceApplyServiceImpl extends CrudServiceImpl dtoList = tbDeviceApplyDao.queryList(params); List result = dtoList.stream().skip((curPage - 1) * limit).limit(limit).collect(Collectors.toList()); + result.stream().forEach(it -> { + it.setTbDeviceDTO(tbDeviceService.get(it.getDeviceId())); + it.setAuditorName(sysUserService.get(it.getAuditor()).getRealName()); + }); return new PageData(result, dtoList.size()); } } diff --git a/renren-admin/src/main/java/io/renren/modules/resource/excel/census/SelectApplyDeptDetailTypeCountListExcel.java b/renren-admin/src/main/java/io/renren/modules/resource/excel/census/SelectApplyDeptDetailTypeCountListExcel.java new file mode 100644 index 00000000..5c6e1208 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/resource/excel/census/SelectApplyDeptDetailTypeCountListExcel.java @@ -0,0 +1,112 @@ +package io.renren.modules.resource.excel.census; + +import com.alibaba.excel.annotation.ExcelProperty; + +import java.util.Objects; + +public class SelectApplyDeptDetailTypeCountListExcel { + @ExcelProperty({"申请部门"}) + private String name; + @ExcelProperty({"组件", "智能算法"}) + private Integer znsf; + @ExcelProperty({"组件", "图层服务"}) + private Integer tcfw; + @ExcelProperty({"组件", "通用开发组件"}) + private Integer kfzj; + @ExcelProperty({"组件", "业务能力组件"}) + private Integer ywzj; + @ExcelProperty({"应用资源"}) + private Integer yyzy; + @ExcelProperty({"会议室"}) + private Integer hys; + @ExcelProperty({"总计"}) + private Integer count; + + public SelectApplyDeptDetailTypeCountListExcel(String name, Integer znsf, Integer tcfw, Integer kfzj, Integer ywzj, Integer yyzy, Integer hys, Integer count) { + this.name = name; + this.znsf = znsf; + this.tcfw = tcfw; + this.kfzj = kfzj; + this.ywzj = ywzj; + this.yyzy = yyzy; + this.hys = hys; + this.count = count; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + 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 getHys() { + return hys; + } + + public void setHys(Integer hys) { + this.hys = hys; + } + + 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; + SelectApplyDeptDetailTypeCountListExcel that = (SelectApplyDeptDetailTypeCountListExcel) o; + return name.equals(that.name) && znsf.equals(that.znsf) && tcfw.equals(that.tcfw) && kfzj.equals(that.kfzj) && ywzj.equals(that.ywzj) && yyzy.equals(that.yyzy) && hys.equals(that.hys) && count.equals(that.count); + } + + @Override + public int hashCode() { + return Objects.hash(name, znsf, tcfw, kfzj, ywzj, yyzy, hys, count); + } +} 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/excel/census/config/CustomCellWriteHeightConfig.java b/renren-admin/src/main/java/io/renren/modules/resource/excel/census/config/CustomCellWriteHeightConfig.java new file mode 100644 index 00000000..e4a15c9c --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/resource/excel/census/config/CustomCellWriteHeightConfig.java @@ -0,0 +1,58 @@ +package io.renren.modules.resource.excel.census.config; + + +import com.alibaba.excel.write.style.row.AbstractRowHeightStyleStrategy; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.Row; + +import java.util.Iterator; + + +public class CustomCellWriteHeightConfig extends AbstractRowHeightStyleStrategy { + /** + * 默认高度 + */ + private static final Integer DEFAULT_HEIGHT = 300; + + /** + * Sets the height of header + * + * @param row + * @param relativeRowIndex + */ + @Override + protected void setHeadColumnHeight(Row row, int relativeRowIndex) { + + } + + /** + * Sets the height of content + * + * @param row + * @param relativeRowIndex + */ + @Override + protected void setContentColumnHeight(Row row, int relativeRowIndex) { + Iterator cellIterator = row.cellIterator(); + if (!cellIterator.hasNext()) { + return; + } + + // 默认为 1行高度 + Integer maxHeight = 1; + while (cellIterator.hasNext()) { + Cell cell = cellIterator.next(); + switch (cell.getCellTypeEnum()) { + case STRING: + if (cell.getStringCellValue().indexOf("\n") != -1) { + int length = cell.getStringCellValue().split("\n").length; + maxHeight = Math.max(maxHeight, length); + } + break; + default: + break; + } + } + row.setHeight((short) (maxHeight * DEFAULT_HEIGHT)); + } +} diff --git a/renren-admin/src/main/java/io/renren/modules/resource/excel/census/config/CustomCellWriteWeightConfig.java b/renren-admin/src/main/java/io/renren/modules/resource/excel/census/config/CustomCellWriteWeightConfig.java new file mode 100644 index 00000000..a233c31f --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/resource/excel/census/config/CustomCellWriteWeightConfig.java @@ -0,0 +1,93 @@ +package io.renren.modules.resource.excel.census.config; + +import com.alibaba.excel.enums.CellDataTypeEnum; +import com.alibaba.excel.metadata.CellData; +import com.alibaba.excel.metadata.Head; +import com.alibaba.excel.util.CollectionUtils; +import com.alibaba.excel.write.metadata.holder.WriteSheetHolder; +import com.alibaba.excel.write.style.column.AbstractColumnWidthStyleStrategy; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.Sheet; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +/** + * 自适应行宽 + */ +public class CustomCellWriteWeightConfig extends AbstractColumnWidthStyleStrategy { + private Map> CACHE = new HashMap<>(); + + /** + * Sets the column width when head create + * + * @param writeSheetHolder + * @param cellDataList + * @param cell + * @param head + * @param relativeRowIndex + * @param isHead + */ + @Override + protected void setColumnWidth(WriteSheetHolder writeSheetHolder, List cellDataList, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) { + boolean needSetWidth = isHead || !CollectionUtils.isEmpty(cellDataList); + if (needSetWidth) { + Map maxColumnWidthMap = CACHE.get(writeSheetHolder.getSheetNo()); + if (maxColumnWidthMap == null) { + maxColumnWidthMap = new HashMap<>(); + CACHE.put(writeSheetHolder.getSheetNo(), maxColumnWidthMap); + } + + Integer columnWidth = this.dataLength(cellDataList, cell, isHead); + if (columnWidth >= 0) { + if (columnWidth > 254) { + columnWidth = 254; + } + + Integer maxColumnWidth = maxColumnWidthMap.get(cell.getColumnIndex()); + if (maxColumnWidth == null || columnWidth > maxColumnWidth) { + maxColumnWidthMap.put(cell.getColumnIndex(), columnWidth); + Sheet sheet = writeSheetHolder.getSheet(); + sheet.setColumnWidth(cell.getColumnIndex(), columnWidth * 256); + } + + } + } + } + + /** + * 计算长度 + * + * @param cellDataList + * @param cell + * @param isHead + * @return + */ + private Integer dataLength(List cellDataList, Cell cell, Boolean isHead) { + if (isHead) { + return cell.getStringCellValue().getBytes().length; + } else { + CellData cellData = cellDataList.get(0); + CellDataTypeEnum type = cellData.getType(); + if (type == null) { + return -1; + } else { + switch (type) { + case STRING: + // 换行符(数据需要提前解析好) + int index = cellData.getStringValue().indexOf("\n"); + return index != -1 ? + cellData.getStringValue().substring(0, index).getBytes().length + 1 : cellData.getStringValue().getBytes().length + 1; + case BOOLEAN: + return cellData.getBooleanValue().toString().getBytes().length; + case NUMBER: + return cellData.getNumberValue().toString().getBytes().length; + default: + return -1; + } + } + } + } +} 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 35b3c2ca..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 @@ -478,34 +478,31 @@ public class ResourceServiceImpl extends CrudServiceImpl { - List temp = selectDTOPageSpecilTotal.parallelStream().map(Map.class::cast) - .sorted(Comparator.comparing(x -> { - Map index = (Map) x; - int pingTOp_ = (index.get("pin_top") == null) ? 0 : Integer.parseInt(index.get("pin_top").toString()); - String total = (index.get("total") == null) ? "0" : index.get("total").toString(); - if (pingTOp_ <= 0) { - return 0l + Long.valueOf(total) == 0 ? -1 : Long.valueOf(total); - } - long pingTOp = (index.get("pin_top_time") == null) ? 0 + (Long.valueOf(total) == 0 ? -1 : Long.valueOf(total)) : Long.parseLong(index.get("pin_top_time").toString()) + Long.valueOf(total); - return (pingTOp % 1000) == 0 ? -1 : pingTOp % 1000; - }).reversed() - ).skip((long) (pageNum - 1) * pageSize).limit(pageSize).map(x -> Long.valueOf(x.get("id").toString())).limit(pageSize).collect(Collectors.toList()); + List temp = selectDTOPageSpecilTotal.parallelStream().map(Map.class::cast).sorted(Comparator.comparing(x -> { + Map index = (Map) x; + int pingTOp_ = (index.get("pin_top") == null) ? 0 : Integer.parseInt(index.get("pin_top").toString()); + String total = (index.get("total") == null) ? "0" : index.get("total").toString(); + if (pingTOp_ <= 0) { + return 0l + Long.valueOf(total) == 0 ? -1 : Long.valueOf(total); + } + long pingTOp = (index.get("pin_top_time") == null) ? 0 + (Long.valueOf(total) == 0 ? -1 : Long.valueOf(total)) : Long.parseLong(index.get("pin_top_time").toString()) + Long.valueOf(total); + return (pingTOp % 1000) == 0 ? -1 : pingTOp % 1000; + }).reversed()).skip((long) (pageNum - 1) * pageSize).limit(pageSize).map(x -> Long.valueOf(x.get("id").toString())).limit(pageSize).collect(Collectors.toList()); return temp; }).get(); break; case "ASC": // total 升序 ids = customThreadPool.submit(() -> { - List temp = selectDTOPageSpecilTotal.parallelStream().map(Map.class::cast) - .sorted(Comparator.comparing(x -> { - Map index = (Map) x; - int pingTOp_ = (index.get("pin_top") == null) ? 0 : Integer.parseInt(index.get("pin_top").toString()); - String total = (index.get("total") == null) ? "0" : index.get("total").toString(); - if (pingTOp_ <= 0) { - return 0l + Long.valueOf(total) == 0 ? -1 : Long.valueOf(total); - } - long pingTOp = (index.get("pin_top_time") == null) ? 0 + (Long.valueOf(total) == 0 ? -1 : Long.valueOf(total)) : Long.parseLong(index.get("pin_top_time").toString()) + Long.valueOf(total); - return (pingTOp % 1000) == 0 ? -1 : pingTOp % 1000; - })).skip((pageNum - 1) * pageSize).limit(pageSize).map(x -> Long.valueOf(x.get("id").toString())).limit(pageSize).collect(Collectors.toList()); + List temp = selectDTOPageSpecilTotal.parallelStream().map(Map.class::cast).sorted(Comparator.comparing(x -> { + Map index = (Map) x; + int pingTOp_ = (index.get("pin_top") == null) ? 0 : Integer.parseInt(index.get("pin_top").toString()); + String total = (index.get("total") == null) ? "0" : index.get("total").toString(); + if (pingTOp_ <= 0) { + return 0l + Long.valueOf(total) == 0 ? -1 : Long.valueOf(total); + } + long pingTOp = (index.get("pin_top_time") == null) ? 0 + (Long.valueOf(total) == 0 ? -1 : Long.valueOf(total)) : Long.parseLong(index.get("pin_top_time").toString()) + Long.valueOf(total); + return (pingTOp % 1000) == 0 ? -1 : pingTOp % 1000; + })).skip((pageNum - 1) * pageSize).limit(pageSize).map(x -> Long.valueOf(x.get("id").toString())).limit(pageSize).collect(Collectors.toList()); return temp; }).get(); break; @@ -513,32 +510,30 @@ public class ResourceServiceImpl extends CrudServiceImpl { - ResourceDTO index = (ResourceDTO) x; - int pinTop = index.getPinTop() == null ? 0 : index.getPinTop(); - long index_; - if (pinTop > 0) { - index_ = index.getPinTopTime() == null ? new Date(0).getTime() + (index.getTotal() == null ? -1L : index.getTotal()) : index.getPinTopTime().getTime() + (index.getTotal() == null ? -1L : index.getTotal()); - index_ = index_ % 1000; - } else { - index_ = (index.getTotal() == null ? -1L : (index.getTotal() == 0 ? -1 : index.getTotal())); - } - return index_ == 0 ? -1 : index_; - }).reversed() - ).collect(Collectors.toList()); + ResourceDTO index = (ResourceDTO) x; + int pinTop = index.getPinTop() == null ? 0 : index.getPinTop(); + long index_; + if (pinTop > 0) { + index_ = index.getPinTopTime() == null ? new Date(0).getTime() + (index.getTotal() == null ? -1L : index.getTotal()) : index.getPinTopTime().getTime() + (index.getTotal() == null ? -1L : index.getTotal()); + index_ = index_ % 1000; + } else { + index_ = (index.getTotal() == null ? -1L : (index.getTotal() == 0 ? -1 : index.getTotal())); + } + return index_ == 0 ? -1 : index_; + }).reversed()).collect(Collectors.toList()); } else { resourceDTOS = resourceDTOS.stream().sorted(Comparator.comparing(x -> { - ResourceDTO index = x; - int pinTop = index.getPinTop() == null ? 0 : index.getPinTop(); - long index_; - if (pinTop > 0) { - index_ = index.getPinTopTime() == null ? new Date(0).getTime() + (index.getTotal() == null ? -1L : index.getTotal()) : index.getPinTopTime().getTime() + (index.getTotal() == null ? -1L : index.getTotal()); - index_ = index_ % 1000; - } else { - index_ = (index.getTotal() == null ? -1L : (index.getTotal() == 0 ? -1 : index.getTotal())); - } - return index_ == 0 ? -1 : index_; - }) - ).collect(Collectors.toList()); + ResourceDTO index = x; + int pinTop = index.getPinTop() == null ? 0 : index.getPinTop(); + long index_; + if (pinTop > 0) { + index_ = index.getPinTopTime() == null ? new Date(0).getTime() + (index.getTotal() == null ? -1L : index.getTotal()) : index.getPinTopTime().getTime() + (index.getTotal() == null ? -1L : index.getTotal()); + index_ = index_ % 1000; + } else { + index_ = (index.getTotal() == null ? -1L : (index.getTotal() == 0 ? -1 : index.getTotal())); + } + return index_ == 0 ? -1 : index_; + })).collect(Collectors.toList()); } customThreadPool.shutdown(); } else { // 非总体评价排序时 @@ -693,11 +688,7 @@ public class ResourceServiceImpl extends CrudServiceImpl page = new Page<>(jsonObject.getIntValue("pageNum"), jsonObject.getIntValue("pageSize")); QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq(StringUtils.isNotBlank(jsonObject.getString("type")), "type", jsonObject.getString("type")) - .eq("del_flag", ResourceEntityDelFlag.NORMAL.getFlag()) - .ne("type", "知识库") - .ne("type", "赋能案例") - .orderByDesc("create_date"); + queryWrapper.eq(StringUtils.isNotBlank(jsonObject.getString("type")), "type", jsonObject.getString("type")).eq("del_flag", ResourceEntityDelFlag.NORMAL.getFlag()).ne("type", "知识库").ne("type", "赋能案例").orderByDesc("create_date"); IPage resourceEntityIPage = resourceDao.selectPage(page, queryWrapper); IPage resourceDTOIPage = new Page<>(); resourceDTOIPage.setPages(resourceEntityIPage.getPages()); @@ -819,24 +810,23 @@ public class ResourceServiceImpl extends CrudServiceImpl>> listMap = typeMapList.stream().collect(Collectors.groupingBy(m -> m.get("type").toString())); //区级要根据行政区划多加一层结构 - List tasks = - listMap.entrySet().stream().filter(index -> !"区级".equals(index.getKey())).map(item -> { - CompletableFuture task = CompletableFuture.runAsync(() -> { - HashMap map = new HashMap<>(); - map.put("type", item.getKey()); - Integer integer = resourceDao.selectTypeCountByDept(item.getKey(), jsonObject.getString("type")); - map.put("total", integer); - item.getValue().forEach(item1 -> { - item1.remove("type"); - item1.remove("regionSort"); - }); - map.put("dataList", item.getValue()); - if (integer != 0) { - resultList.add(map); - } - }, executor); - return task; - }).collect(Collectors.toList()); + List tasks = listMap.entrySet().stream().filter(index -> !"区级".equals(index.getKey())).map(item -> { + CompletableFuture task = CompletableFuture.runAsync(() -> { + HashMap map = new HashMap<>(); + map.put("type", item.getKey()); + Integer integer = resourceDao.selectTypeCountByDept(item.getKey(), jsonObject.getString("type")); + map.put("total", integer); + item.getValue().forEach(item1 -> { + item1.remove("type"); + item1.remove("regionSort"); + }); + map.put("dataList", item.getValue()); + if (integer != 0) { + resultList.add(map); + } + }, executor); + return task; + }).collect(Collectors.toList()); CompletableFuture.allOf(tasks.toArray(new CompletableFuture[tasks.size()])).join(); Optional>> areaList = Optional.ofNullable(listMap.get("区级")); @@ -907,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); @@ -1115,8 +1105,7 @@ public class ResourceServiceImpl extends CrudServiceImpl queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("instance_id", instanceId) - .eq("approve_status", "通过"); + queryWrapper.eq("instance_id", instanceId).eq("approve_status", "通过"); List applicationEntities = tAbilityApplicationDao.selectList(queryWrapper); ArrayList cameraList = new ArrayList(); applicationEntities.forEach(index -> { @@ -1919,8 +1908,7 @@ public class ResourceServiceImpl extends CrudServiceImpl> typeCountListByApplyDept = resourceDao.selectApplyDeptDetailTypeCountList(params); - Map>> typeCountListMap = typeCountListByApplyDept.stream().collect(Collectors.groupingBy(m -> m.get("deptName").toString())); - ArrayList resultList = new ArrayList<>(); - Map countMap = new HashMap<>(); - typeCountListMap.forEach((k, v) -> { - HashMap map = new HashMap<>(); - map.put("count", v.stream().mapToInt(it -> Integer.parseInt(it.get("count").toString())).sum()); - map.put("name", k); - v.forEach(item -> { - map.put(item.get("type").toString(), item.get("count")); - if (countMap.containsKey(item.get("type"))) { - countMap.replace(item.get("type").toString(), Integer.parseInt(item.get("count").toString()) + countMap.get(item.get("type"))); - } else { - countMap.put(item.get("type").toString(), Integer.parseInt(item.get("count").toString())); - } + if (params.containsKey("deptId") && org.apache.commons.lang3.StringUtils.isNotEmpty(params.get("deptId").toString())) { + List> typeCountListByApplyDept = resourceDao.selectApplyDeptDetailTypeCountList(params); + Map>> typeCountListMap = typeCountListByApplyDept.stream().collect(Collectors.groupingBy(m -> m.get("deptName").toString())); + ArrayList resultList = new ArrayList<>(); + Map countMap = new HashMap<>(); + typeCountListMap.forEach((k, v) -> { + HashMap map = new HashMap<>(); + map.put("count", v.stream().mapToInt(it -> Integer.parseInt(it.get("count").toString())).sum()); + map.put("name", k); + v.forEach(item -> { + map.put(item.get("type").toString(), item.get("count")); + if (countMap.containsKey(item.get("type"))) { + countMap.replace(item.get("type").toString(), Integer.parseInt(item.get("count").toString()) + countMap.get(item.get("type"))); + } else { + countMap.put(item.get("type").toString(), Integer.parseInt(item.get("count").toString())); + } + }); + resultList.add(map); }); - resultList.add(map); - }); - Integer total = 0; - for (Integer count : countMap.values()) { - total += count; + Integer total = 0; + for (Integer count : countMap.values()) { + total += count; + } + countMap.put("count", total); + HashMap count = new HashMap<>(); + count.put("name", "总计"); + count.putAll(countMap); + resultList.add(count); + return resultList; + } else { + List> typeCountListByApplyDept = resourceDao.selectApplyDeptDetailTypeCountList(params); + List> resultList = getDeptTemp1(); + resultList.addAll(getDeptTemp2()); + Map countMap = new HashMap<>(); + + Map>> typeCountListMap = // 市级部门 + typeCountListByApplyDept.stream().filter(index -> index.get("deptType").toString().equals("2")).collect(Collectors.groupingBy(m -> m.get("dept_id").toString())); + resultList = resultList.stream().map(index -> { + if (typeCountListMap.keySet().contains(index.get("dept_id").toString())) { // 该部门存在上架信息 + index.put("count", typeCountListMap.get(index.get("dept_id").toString()).stream().mapToInt(it -> Integer.parseInt(it.get("count").toString())).sum()); + typeCountListMap.get(index.get("dept_id").toString()).stream().forEach(count -> { + index.put(count.get("type").toString(), count.get("count")); + if (countMap.containsKey(count.get("type"))) { + countMap.replace(count.get("type").toString(), Integer.parseInt(count.get("count").toString()) + countMap.get(count.get("type"))); + } else { + countMap.put(count.get("type").toString(), Integer.parseInt(count.get("count").toString())); + } + }); + } + return index; + }).collect(Collectors.toList()); + Map>> typeCountListMap1 = // 区级部门 + typeCountListByApplyDept.stream().filter(index -> index.get("deptType").toString().equals("3")).collect(Collectors.groupingBy(m -> m.get("district").toString())); + resultList = resultList.stream().map(index -> { + if (typeCountListMap1.keySet().contains(index.get("dept_id").toString())) { // 该部门存在上架信息 + index.put("count", typeCountListMap1.get(index.get("dept_id").toString()).stream().mapToInt(it -> Integer.parseInt(it.get("count").toString())).sum()); + typeCountListMap1.get(index.get("dept_id").toString()).stream().forEach(count -> { + index.put(count.get("type").toString(), Integer.parseInt(count.get("count").toString()) + Integer.parseInt(index.getOrDefault(count.get("type").toString(), "0").toString())); + if (countMap.containsKey(count.get("type"))) { + countMap.replace(count.get("type").toString(), Integer.parseInt(count.get("count").toString()) + countMap.get(count.get("type"))); + } else { + countMap.put(count.get("type").toString(), Integer.parseInt(count.get("count").toString())); + } + }); + } + return index; + }).collect(Collectors.toList()); + + Map>> typeCountListMap2 = // 会议室 + typeCountListByApplyDept.stream().filter(index -> index.get("deptType").toString().equals("99")).collect(Collectors.groupingBy(m -> m.get("deptName").toString())); + resultList = resultList.stream().map(index -> { + if (typeCountListMap2.keySet().contains(index.get("name").toString())) { // 该部门存在上架信息 + index.put("count", Integer.parseInt(index.get("count").toString()) + typeCountListMap2.get(index.get("name").toString()).stream().mapToInt(it -> Integer.parseInt(it.get("count").toString())).sum()); + typeCountListMap2.get(index.get("name").toString()).stream().forEach(count -> { + index.put(count.get("type").toString(), Integer.parseInt(count.get("count").toString()) + Integer.parseInt(index.getOrDefault(count.get("type").toString(), "0").toString())); + if (countMap.containsKey(count.get("type"))) { + countMap.replace(count.get("type").toString(), Integer.parseInt(count.get("count").toString()) + countMap.get(count.get("type"))); + } else { + countMap.put(count.get("type").toString(), Integer.parseInt(count.get("count").toString())); + } + }); + typeCountListMap2.remove(index.get("name").toString());// 去除 + } + return index; + }).collect(Collectors.toList()); + + if (!typeCountListMap2.isEmpty()) { // 仍然有会议室信息 + List> temp = typeCountListMap2.keySet().stream().map(index_ -> { + HashMap map = new HashMap<>(); + typeCountListMap2.get(index_).stream().forEach(count -> { + map.put(count.get("type").toString(), Integer.parseInt(count.get("count").toString())); + if (countMap.containsKey(count.get("type"))) { + countMap.replace(count.get("type").toString(), Integer.parseInt(count.get("count").toString()) + countMap.get(count.get("type"))); + } else { + countMap.put(count.get("type").toString(), Integer.parseInt(count.get("count").toString())); + } + }); + map.put("name", index_); + map.put("dept_id", null); + map.put("yyzy", "0"); + map.put("znsf", "0"); + map.put("tcfw", "0"); + map.put("kfzj", "0"); + map.put("ywzj", "0"); + map.put("jcss", "0"); + map.put("zsk", "0"); + map.put("sjzy", "0"); + return map; + }).collect(Collectors.toList()); // 会议室的 + resultList.addAll(temp); + } + + Integer total = 0; + for (Integer count : countMap.values()) { + total += count; + } + countMap.put("count", total); + HashMap count = new HashMap<>(); + count.put("name", "总计"); + count.putAll(countMap); + resultList.add(count); + return resultList; } - countMap.put("count", total); - HashMap count = new HashMap<>(); - count.put("name", "总计"); - count.putAll(countMap); - resultList.add(count); - return resultList; } @Override public Object selectDeptDetailTypeCountList(Map params) { - List> typeCountListByDept = resourceDao.selectDeptDetailTypeCountList(params); - Map>> typeCountListMap = typeCountListByDept.stream().collect(Collectors.groupingBy(m -> m.get("deptName").toString())); - ArrayList resultList = new ArrayList<>(); - Map countMap = new HashMap<>(); - typeCountListMap.forEach((k, v) -> { - HashMap map = new HashMap<>(); - map.put("count", v.stream().mapToInt(it -> Integer.parseInt(it.get("count").toString())).sum()); - map.put("name", k); - v.forEach(item -> { - map.put(item.get("type").toString(), item.get("count")); - if (countMap.containsKey(item.get("type"))) { - countMap.replace(item.get("type").toString(), Integer.parseInt(item.get("count").toString()) + countMap.get(item.get("type"))); - } else { - countMap.put(item.get("type").toString(), Integer.parseInt(item.get("count").toString())); - } + if (params.containsKey("deptId") && org.apache.commons.lang3.StringUtils.isNotEmpty(params.get("deptId").toString())) { + List> typeCountListByDept = resourceDao.selectDeptDetailTypeCountList(params); + Map>> typeCountListMap = typeCountListByDept.stream().collect(Collectors.groupingBy(m -> m.get("deptName").toString())); + ArrayList resultList = new ArrayList<>(); + Map countMap = new HashMap<>(); + typeCountListMap.forEach((k, v) -> { + HashMap map = new HashMap<>(); + map.put("count", v.stream().mapToInt(it -> Integer.parseInt(it.get("count").toString())).sum()); + map.put("name", k); + v.forEach(item -> { + map.put(item.get("type").toString(), item.get("count")); + if (countMap.containsKey(item.get("type"))) { + countMap.replace(item.get("type").toString(), Integer.parseInt(item.get("count").toString()) + countMap.get(item.get("type"))); + } else { + countMap.put(item.get("type").toString(), Integer.parseInt(item.get("count").toString())); + } + }); + resultList.add(map); }); - resultList.add(map); - }); - Integer total = 0; - for (Integer count : countMap.values()) { - total += count; + Integer total = 0; + for (Integer count : countMap.values()) { + total += count; + } + countMap.put("count", total); + HashMap count = new HashMap<>(); + count.put("name", "总计"); + count.putAll(countMap); + resultList.add(count); + return resultList; + } else { // 全部部门 + List> typeCountListByDept = resourceDao.selectDeptDetailTypeCountList(params); + Map>> typeCountListMap = // 市级部门 + typeCountListByDept.stream().filter(index -> index.get("deptType").toString().equals("2")).collect(Collectors.groupingBy(m -> m.get("dept_id").toString())); + List> resultList = getDeptTemp1(); + resultList.addAll(getDeptTemp2()); + Map countMap = new HashMap<>(); + resultList = resultList.stream().map(index -> { + if (typeCountListMap.keySet().contains(index.get("dept_id").toString())) { // 该部门存在上架信息 + index.put("count", typeCountListMap.get(index.get("dept_id").toString()).stream().mapToInt(it -> Integer.parseInt(it.get("count").toString())).sum()); + typeCountListMap.get(index.get("dept_id").toString()).stream().forEach(count -> { + index.put(count.get("type").toString(), count.get("count")); + if (countMap.containsKey(count.get("type"))) { + countMap.replace(count.get("type").toString(), Integer.parseInt(count.get("count").toString()) + countMap.get(count.get("type"))); + } else { + countMap.put(count.get("type").toString(), Integer.parseInt(count.get("count").toString())); + } + }); + } + return index; + }).collect(Collectors.toList()); + Map>> typeCountListMap1 = // 区级部门 + typeCountListByDept.stream().filter(index -> index.get("deptType").toString().equals("3")).collect(Collectors.groupingBy(m -> m.get("district").toString())); + resultList = resultList.stream().map(index -> { + if (typeCountListMap1.keySet().contains(index.get("dept_id").toString())) { // 该部门存在上架信息 + index.put("count", typeCountListMap1.get(index.get("dept_id").toString()).stream().mapToInt(it -> Integer.parseInt(it.get("count").toString())).sum()); + typeCountListMap1.get(index.get("dept_id").toString()).stream().forEach(count -> { + index.put(count.get("type").toString(), Integer.parseInt(count.get("count").toString()) + Integer.parseInt(index.getOrDefault(count.get("type").toString(), "0").toString())); + if (countMap.containsKey(count.get("type"))) { + countMap.replace(count.get("type").toString(), Integer.parseInt(count.get("count").toString()) + countMap.get(count.get("type"))); + } else { + countMap.put(count.get("type").toString(), Integer.parseInt(count.get("count").toString())); + } + }); + } + return index; + }).collect(Collectors.toList()); + Integer total = 0; + for (Integer count : countMap.values()) { + total += count; + } + countMap.put("count", total); + HashMap count = new HashMap<>(); + count.put("name", "总计"); + count.putAll(countMap); + resultList.add(count); + return resultList; } - countMap.put("count", total); - HashMap count = new HashMap<>(); - count.put("name", "总计"); - count.putAll(countMap); - resultList.add(count); + + } + + /** + * @return 返回市级部门的初级构造 + */ + private List> getDeptTemp1() { + List> resultList; + List> maps = jdbcTemplate.queryForList("SELECT id,`name`,type,pid,district FROM sys_dept WHERE type = 2 ORDER BY sys_dept.sort;"); + resultList = maps.stream().map(index -> { + HashMap map = new HashMap<>(); + map.put("count", 0); // + map.put("name", index.get("name").toString()); + map.put("dept_id", index.get("id").toString()); + map.put("yyzy", "0"); + map.put("znsf", "0"); + map.put("tcfw", "0"); + map.put("kfzj", "0"); + map.put("ywzj", "0"); + map.put("jcss", "0"); + map.put("zsk", "0"); + map.put("sjzy", "0"); + return map; + }).collect(Collectors.toList()); + return resultList; + } + + /** + * 获取区的初级构造 + * + * @return + */ + private List> getDeptTemp2() { + List> resultList; + List> maps = jdbcTemplate.queryForList("SELECT id,`name` FROM sys_region WHERE tree_level = 3 AND leaf = 0 ORDER BY sort;"); + resultList = maps.stream().map(index -> { + HashMap map = new HashMap<>(); + map.put("count", 0); // + map.put("name", index.get("name").toString()); + map.put("dept_id", index.get("id").toString()); + map.put("yyzy", "0"); + map.put("znsf", "0"); + map.put("tcfw", "0"); + map.put("kfzj", "0"); + map.put("ywzj", "0"); + map.put("jcss", "0"); + map.put("zsk", "0"); + map.put("sjzy", "0"); + return map; + }).collect(Collectors.toList()); return resultList; } diff --git a/renren-admin/src/main/resources/mapper/device/TbDeviceDao.xml b/renren-admin/src/main/resources/mapper/device/TbDeviceDao.xml index a82cda63..0815b9dd 100644 --- a/renren-admin/src/main/resources/mapper/device/TbDeviceDao.xml +++ b/renren-admin/src/main/resources/mapper/device/TbDeviceDao.xml @@ -18,7 +18,7 @@ @@ -759,7 +759,8 @@ ( SELECT DISTINCT sd.id AS "deptId", - ( CASE sd.type WHEN 1 THEN '省级' WHEN 2 THEN '市级' WHEN 3 THEN '区级' WHEN 4 THEN '企业' ELSE '其他' END ) AS "type" + ( CASE sd.type WHEN 1 THEN '省级' WHEN 2 THEN '市级' WHEN 3 THEN '区级' WHEN 4 THEN '企业' ELSE '其他' END ) AS + "type" FROM sys_dept sd WHERE @@ -1646,7 +1647,7 @@ MATCH (type) AGAINST ( '应用资源' IN BOOLEAN MODE) UNION SELECT - ( CASE tda.attr_value WHEN '智能算法' THEN '组件' WHEN '图层服务' THEN '图层' ELSE '其他' END ) AS "type", + ( CASE tda.attr_value WHEN '开发组件' THEN '组件' WHEN '图层服务' THEN '图层' ELSE '其他' END ) AS "type", COUNT( tdr.id ) AS "count" FROM tb_data_resource tdr, @@ -1658,7 +1659,7 @@ AND tdr.dept_id = #{deptId} AND MATCH (tdr.type) AGAINST ( '组件服务' IN BOOLEAN MODE) AND tda.attr_type = '组件类型' - AND tda.attr_value IN ( '智能算法', '图层服务' ) + AND tda.attr_value IN ( '开发组件', '图层服务' ) GROUP BY tda.attr_value @@ -1718,6 +1719,9 @@ SELECT COUNT( taa.resource_id ) AS "count", sd.NAME AS "deptName", + sd.id AS "dept_id", + sd.type AS "deptType", + sd.district AS "district", ( CASE tdr.type @@ -1776,9 +1780,11 @@ UNION SELECT - - COUNT( id ) AS 'count' , + COUNT( id ) AS 'count', dept AS 'deptName', + NULL AS "dept_id", + 99 AS "deptType", + NULL AS "district", 'hys' AS 'type' FROM t_meetingroom_book tmb @@ -1790,6 +1796,9 @@ SELECT COUNT( tdr.id ) AS "count", sd.NAME AS "deptName", + sd.id AS "dept_id", + sd.type AS "deptType", + sd.district AS "district", (CASE tdr.type WHEN '应用资源' THEN 'yyzy' WHEN '智能算法' THEN 'znsf' @@ -1834,8 +1843,8 @@ diff --git a/renren-admin/src/main/resources/mapper/resourceCar/ResourceCarDao.xml b/renren-admin/src/main/resources/mapper/resourceCar/ResourceCarDao.xml index 55fe4beb..e87e1c28 100644 --- a/renren-admin/src/main/resources/mapper/resourceCar/ResourceCarDao.xml +++ b/renren-admin/src/main/resources/mapper/resourceCar/ResourceCarDao.xml @@ -84,7 +84,7 @@