* 'dev' of http://221.0.232.152:9393/ability-center/share-platform:
  数据异常导出失败
  npe
  导出表头宽度自适应
  调整导出文件名
  ...
  能力统计 导出
  CIM组件统计改为开发组件
  selectDeptDetailTypeCountList 增加导出接口
  npe
  会议室重复统计
  ...
  npe
  ...
  能力使用部门排序
  屮
  ...
  ...
  HIQDUCS-100 的处理
  设备申请新增设备详情字段
  统计报表状态修改
This commit is contained in:
huangweixiong 2022-10-18 16:41:18 +08:00
commit b326c8e24b
10 changed files with 903 additions and 165 deletions

View File

@ -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<String, Object> params, HttpServletResponse response) throws IOException {
ArrayList<Map> resultList = (ArrayList<Map>) resourceService.selectApplyDeptDetailTypeCountList(params);
List<SelectApplyDeptDetailTypeCountListExcel> 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<String, Object> params, HttpServletResponse response) throws IOException {
ArrayList<Map> resultList = (ArrayList<Map>) resourceService.selectDeptDetailTypeCountList(params);
List<SelectDeptDetailTypeCountListExcel> 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<String, Object> params, HttpServletResponse response) throws IOException {
ArrayList<Map> resultList = (ArrayList<Map>) resourceService.selectCensusResourceTable(params);
List<List<Object>> date = resultList.stream().map(index -> {
List<Object> 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<List<String>> exportSelectCensusResourceTableHead() {
List<List<String>> list = new ArrayList<>();
List<String> head0 = new ArrayList<>();
head0.add("上架部门");
List<String> head1 = new ArrayList<>();
head1.add("类型");
List<String> head2 = new ArrayList<>();
head2.add("资源名称");
List<String> head3 = new ArrayList<>();
head3.add("日期");
List<String> 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<String, Object> params, HttpServletResponse response) throws IOException {
ArrayList<Map> resultList = (ArrayList<Map>) resourceService.selectCensusApplyTable(params);
List<List<Object>> date = resultList.stream().map(index -> {
List<Object> 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<List<String>> exportSelectCensusApplyTableHead() {
List<List<String>> list = new ArrayList<>();
List<String> head0 = new ArrayList<>();
head0.add("提供部门");
List<String> head1 = new ArrayList<>();
head1.add("资源名称");
List<String> head2 = new ArrayList<>();
head2.add("类型");
List<String> head3 = new ArrayList<>();
head3.add("申请部门");
List<String> head4 = new ArrayList<>();
head4.add("日期");
List<String> 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;
}
}

View File

@ -91,6 +91,10 @@ public class TbDeviceApplyServiceImpl extends CrudServiceImpl<TbDeviceApplyDao,
params.put("states", stateList);
List<TbDeviceApplyDTO> dtoList = tbDeviceApplyDao.queryList(params);
List<TbDeviceApplyDTO> 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());
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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<Cell> 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));
}
}

View File

@ -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<Integer, Map<Integer, Integer>> 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<CellData> cellDataList, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) {
boolean needSetWidth = isHead || !CollectionUtils.isEmpty(cellDataList);
if (needSetWidth) {
Map<Integer, Integer> 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<CellData> 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;
}
}
}
}
}

View File

@ -478,8 +478,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
switch (orderType.toUpperCase()) {
case "DESC": // total 倒序
ids = customThreadPool.submit(() -> {
List<Long> temp = selectDTOPageSpecilTotal.parallelStream().map(Map.class::cast)
.sorted(Comparator.comparing(x -> {
List<Long> 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();
@ -488,15 +487,13 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
}
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());
}).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<Long> temp = selectDTOPageSpecilTotal.parallelStream().map(Map.class::cast)
.sorted(Comparator.comparing(x -> {
List<Long> 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();
@ -523,8 +520,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
index_ = (index.getTotal() == null ? -1L : (index.getTotal() == 0 ? -1 : index.getTotal()));
}
return index_ == 0 ? -1 : index_;
}).reversed()
).collect(Collectors.toList());
}).reversed()).collect(Collectors.toList());
} else {
resourceDTOS = resourceDTOS.stream().sorted(Comparator.comparing(x -> {
ResourceDTO index = x;
@ -537,8 +533,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
index_ = (index.getTotal() == null ? -1L : (index.getTotal() == 0 ? -1 : index.getTotal()));
}
return index_ == 0 ? -1 : index_;
})
).collect(Collectors.toList());
})).collect(Collectors.toList());
}
customThreadPool.shutdown();
} else { // 非总体评价排序时
@ -693,11 +688,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
public Object selectNewest(JSONObject jsonObject) {
IPage<ResourceEntity> page = new Page<>(jsonObject.getIntValue("pageNum"), jsonObject.getIntValue("pageSize"));
QueryWrapper<ResourceEntity> 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<ResourceEntity> resourceEntityIPage = resourceDao.selectPage(page, queryWrapper);
IPage<ResourceDTO> resourceDTOIPage = new Page<>();
resourceDTOIPage.setPages(resourceEntityIPage.getPages());
@ -819,8 +810,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
}
Map<String, List<Map<String, Object>>> listMap = typeMapList.stream().collect(Collectors.groupingBy(m -> m.get("type").toString()));
//区级要根据行政区划多加一层结构
List<CompletableFuture> tasks =
listMap.entrySet().stream().filter(index -> !"区级".equals(index.getKey())).map(item -> {
List<CompletableFuture> tasks = listMap.entrySet().stream().filter(index -> !"区级".equals(index.getKey())).map(item -> {
CompletableFuture task = CompletableFuture.runAsync(() -> {
HashMap<String, Object> map = new HashMap<>();
map.put("type", item.getKey());
@ -907,7 +897,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
List<Map> deptTotalCount = resourceDao.selectDeptTotalCount();
HashMap<String, Object> 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<ResourceDao, ResourceEn
@Override
public Object getApplyCameraList(Long instanceId) {
QueryWrapper<TAbilityApplicationEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("instance_id", instanceId)
.eq("approve_status", "通过");
queryWrapper.eq("instance_id", instanceId).eq("approve_status", "通过");
List<TAbilityApplicationEntity> applicationEntities = tAbilityApplicationDao.selectList(queryWrapper);
ArrayList cameraList = new ArrayList();
applicationEntities.forEach(index -> {
@ -1919,8 +1908,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
resourceIds.add(Long.parseLong(abilityApplicationDTO1.getResourceId()));
} else {
TResourceMountApplyDTO resourceMountApplyDTO = tResourceMountApplyService.get(Long.valueOf(his.getBusinessKey()));
if (resourceMountApplyDTO != null && resourceMountApplyDTO.getResourceDTO() != null
&& resourceMountApplyDTO.getResourceDTO().getId() != null) {
if (resourceMountApplyDTO != null && resourceMountApplyDTO.getResourceDTO() != null && resourceMountApplyDTO.getResourceDTO().getId() != null) {
resourceIds.add(resourceMountApplyDTO.getResourceDTO().getId());
if (resourceMountApplyDTO.getResourceId() != null) {
ResourceDTO resourceDTO = get(resourceMountApplyDTO.getResourceId());
@ -2036,6 +2024,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
@Override
public Object selectApplyDeptDetailTypeCountList(Map params) {
if (params.containsKey("deptId") && org.apache.commons.lang3.StringUtils.isNotEmpty(params.get("deptId").toString())) {
List<Map<String, Object>> typeCountListByApplyDept = resourceDao.selectApplyDeptDetailTypeCountList(params);
Map<String, List<Map<String, Object>>> typeCountListMap = typeCountListByApplyDept.stream().collect(Collectors.groupingBy(m -> m.get("deptName").toString()));
ArrayList<Map> resultList = new ArrayList<>();
@ -2064,10 +2053,105 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
count.putAll(countMap);
resultList.add(count);
return resultList;
} else {
List<Map<String, Object>> typeCountListByApplyDept = resourceDao.selectApplyDeptDetailTypeCountList(params);
List<HashMap<String, Object>> resultList = getDeptTemp1();
resultList.addAll(getDeptTemp2());
Map<String, Integer> countMap = new HashMap<>();
Map<String, List<Map<String, Object>>> 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<String, List<Map<String, Object>>> 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<String, List<Map<String, Object>>> 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<HashMap<String, Object>> temp = typeCountListMap2.keySet().stream().map(index_ -> {
HashMap<String, Object> 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<String, Object> count = new HashMap<>();
count.put("name", "总计");
count.putAll(countMap);
resultList.add(count);
return resultList;
}
}
@Override
public Object selectDeptDetailTypeCountList(Map params) {
if (params.containsKey("deptId") && org.apache.commons.lang3.StringUtils.isNotEmpty(params.get("deptId").toString())) {
List<Map<String, Object>> typeCountListByDept = resourceDao.selectDeptDetailTypeCountList(params);
Map<String, List<Map<String, Object>>> typeCountListMap = typeCountListByDept.stream().collect(Collectors.groupingBy(m -> m.get("deptName").toString()));
ArrayList<Map> resultList = new ArrayList<>();
@ -2096,6 +2180,105 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
count.putAll(countMap);
resultList.add(count);
return resultList;
} else { // 全部部门
List<Map<String, Object>> typeCountListByDept = resourceDao.selectDeptDetailTypeCountList(params);
Map<String, List<Map<String, Object>>> typeCountListMap = // 市级部门
typeCountListByDept.stream().filter(index -> index.get("deptType").toString().equals("2")).collect(Collectors.groupingBy(m -> m.get("dept_id").toString()));
List<HashMap<String, Object>> resultList = getDeptTemp1();
resultList.addAll(getDeptTemp2());
Map<String, Integer> 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<String, List<Map<String, Object>>> 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<String, Object> count = new HashMap<>();
count.put("name", "总计");
count.putAll(countMap);
resultList.add(count);
return resultList;
}
}
/**
* @return 返回市级部门的初级构造
*/
private List<HashMap<String, Object>> getDeptTemp1() {
List<HashMap<String, Object>> resultList;
List<Map<String, Object>> 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<String, Object> 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<HashMap<String, Object>> getDeptTemp2() {
List<HashMap<String, Object>> resultList;
List<Map<String, Object>> 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<String, Object> 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;
}
@Override

View File

@ -18,7 +18,7 @@
</resultMap>
<select id="getDeviceDTOList" resultMap="deviceDTO">
select td.*, IFNULL(tda.state,1) as state from tb_device td left join tb_device_apply tda on td.id=tda.device_id
select td.*, IFNULL(ANY_VALUE(tda.state),1) as state from tb_device td left join tb_device_apply tda on td.id=tda.device_id
<if test="userId != null and userId != ''">
and tda.creator = #{userId}
</if>

View File

@ -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
</select>
@ -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 @@
<select id="selectCensusResourceTable" resultType="java.util.Map">
SELECT sd.name AS deptName, tdr.name AS resourceName, tdr.type, tdr.create_date AS createDate,
if(tdr.del_flag=0, '审核通过', '审核中') AS approveStatus, trma.instance_id AS applyNumber
FROM (SELECT IF(d.type='组件服务', A.attr_value, d.type) AS type, d.id, d.del_flag, d.dept_id, d.create_date,
CASE WHEN (tdr.del_flag=0 OR tdr.del_flag=5) THEN '通过' WHEN tdr.del_flag=6 THEN '不通过' ELSE '审核中' END AS approveStatus, trma.instance_id AS applyNumber
FROM (SELECT IF(d.type='组件服务', a.attr_value, d.type) AS type, d.id, d.del_flag, d.dept_id, d.create_date,
d.name
FROM tb_data_resource d LEFT JOIN tb_data_attr a ON d.id=a.data_resource_id AND a.attr_type='组件类型' AND
a.del_flag=0
@ -1845,13 +1854,16 @@
WHERE 1=1 AND tdr.dept_id=sd.id
<choose>
<when test="approveStatus != null and approveStatus == '通过'">
AND tdr.del_flag = 0
AND tdr.del_flag in (0, 5)
</when>
<when test="approveStatus != null and approveStatus == '审核中'">
AND tdr.del_flag in (2, 3)
AND tdr.del_flag not in (0, 1, 5, 6)
</when>
<when test="approveStatus != null and approveStatus == '不通过'">
AND tdr.del_flag=6
</when>
<otherwise>
AND tdr.del_flag in (0, 2, 3)
AND tdr.del_flag != 1
</otherwise>
</choose>
<if test="deptId != null and deptId != ''">
@ -1904,14 +1916,6 @@
AND su.dept_id = sd.id
AND taa.resource_id = tdr.id
AND dept.id = tdr.dept_id
<!--<choose>
<when test="approveStatus != null and approveStatus != ''">
AND taa.approve_status = #{approveStatus}
</when>
<otherwise>
AND taa.approve_status != '不通过'
</otherwise>
</choose> -->
<if test="approveStatus != null and approveStatus != ''">
AND taa.approve_status = #{approveStatus}
</if>
@ -1925,7 +1929,7 @@
AND SUBSTR(taa.create_date, 1, 10) BETWEEN #{startDate} AND #{endDate}
</if>
<if test="type == null or type == '' or type == '会议室'">
UNION ALL
SELECT
@ -1934,13 +1938,25 @@
'青岛市大数据发展管理局' AS 'resourceDeptName',
'会议室' AS 'type',
tm.create_date AS 'createDate',
CASE tmb.state WHEN 1 THEN '申请中' WHEN 2 THEN '通过' WHEN 3 THEN '不通过' ELSE '申请中' END AS 'approveStatus',
CASE tmb.state WHEN 1 THEN '审核中' WHEN 2 THEN '通过' WHEN 3 THEN '不通过' ELSE '审核中' END AS 'approveStatus',
'' AS 'applyNumber'
FROM
t_meetingroom_book tmb,
t_meetingroom tm
WHERE
tmb.room_id = tm.id
<choose>
<when test="approveStatus != null and approveStatus == '通过'">
AND tmb.state=2
</when>
<when test="approveStatus != null and approveStatus == '不通过'">
AND tmb.state=3
</when>
<when test="approveStatus != null and approveStatus == '审核中'">
AND tmb.state not in (2, 3)
</when>
</choose>
</if>
ORDER BY createDate DESC
</select>

View File

@ -84,7 +84,7 @@
<select id="selectInfrastructureCarGroupByDept" resultType="java.util.Map">
SELECT
IFNULL(dept.id, -1) AS "deptId",
IFNULL(ANY_VALUE(dept.id), -1) AS "deptId",
car.dept_name AS "deptName",
COUNT(car.id) AS "count"
FROM
@ -94,6 +94,7 @@
left join sys_dept dept on car.dept_name=dept.name
WHERE car.user_id = #{userId}
AND car.del_flag = 0
AND car.dept_name IS NOT NULL
<if test="name != null and name != ''">
AND car.name LIKE CONCAT('%',#{name},'%')
</if>