diff --git a/config/db/V8.3__tb_fuse_add_col.sql b/config/db/V8.3__tb_fuse_add_col.sql new file mode 100644 index 00000000..c752b342 --- /dev/null +++ b/config/db/V8.3__tb_fuse_add_col.sql @@ -0,0 +1 @@ +ALTER TABLE tb_fuse ADD COLUMN `district` int(2) DEFAULT 0 COMMENT '赋能场景类型:0市级、1基层场景'; \ No newline at end of file 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 f11f0943..0713ace5 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 @@ -380,7 +380,7 @@ public class CensusController { @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 = "deptId", value = "申请部门", paramType = "query", dataType = "long"), @ApiImplicitParam(name = "approveStatus", value = "审核状态,可选值(通过、审核中)", paramType = "query", dataType = "String"), @ApiImplicitParam(name = "region", value = "所属区域id", paramType = "query", dataType = "String"), }) diff --git a/renren-admin/src/main/java/io/renren/modules/activiti/controller/ActTaskController.java b/renren-admin/src/main/java/io/renren/modules/activiti/controller/ActTaskController.java index af2e5078..c7de54f6 100644 --- a/renren-admin/src/main/java/io/renren/modules/activiti/controller/ActTaskController.java +++ b/renren-admin/src/main/java/io/renren/modules/activiti/controller/ActTaskController.java @@ -1,6 +1,5 @@ package io.renren.modules.activiti.controller; -import com.alibaba.druid.pool.DruidDataSource; import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.renren.common.annotation.LogOperation; @@ -12,7 +11,6 @@ import io.renren.common.utils.Result; import io.renren.modules.activiti.dto.BatchCompleteDTO; import io.renren.modules.activiti.dto.TaskDTO; import io.renren.modules.activiti.service.ActTaskService; -import io.renren.modules.resource.service.impl.ResourceServiceImpl; import io.renren.modules.security.user.SecurityUser; import io.renren.modules.security.user.UserDetail; import io.renren.modules.sys.dto.SysUserDTO; @@ -29,6 +27,7 @@ import org.activiti.engine.task.TaskQuery; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.dao.DataAccessException; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.*; @@ -66,6 +65,7 @@ public class ActTaskController { @Autowired protected TaskService taskService; + private JdbcTemplate lcJdbcTemplate = JdbcTemplateFactory.getJdbcTemplate(); /** * 获取用户任务列表 @@ -449,13 +449,13 @@ public class ActTaskController { @ApiImplicitParam(name = "status", value = "状态", paramType = "query", dataType = "String"), @ApiImplicitParam(name = "pageNum", value = "页码", paramType = "query", required = true, dataType = "Integer"), @ApiImplicitParam(name = "pageSize", value = "分页大小", paramType = "query", required = true, dataType = "Integer") - }) public Result getZwyBusinessList(String name, String status, int pageNum, int pageSize) { UserDetail user = SecurityUser.getUser(); - JdbcTemplate lcJdbcTemplate = JdbcTemplateFactory.getJdbcTemplate(); - StringBuilder sql = new StringBuilder("SELECT BSNUM, BUSINESS_NAME, APPLYTYPE, to_char(CREATE_TIME,'yyyy-mm-dd hh24:mi:ss') AS \"CREATE_TIME\", STATUS " + - "FROM VIEW_CLOUD_BUSINESS_INDEX WHERE 1 = 1 AND APPLYTYPE = '01' AND STATUS != '00' AND ACCOUNT = '" + user.getUsername() + "'"); + + StringBuilder sql = new StringBuilder("SELECT BSNUM, BUSINESS_NAME, to_char(CREATE_TIME,'yyyy-mm-dd hh24:mi:ss') AS \"CREATE_TIME\", " + + "(CASE WHEN STATUS = '04' THEN '不通过' WHEN STATUS IN ('01', '03') THEN '审核中' ELSE '通过' END) AS \"STATUS\"" + + "FROM VIEW_CLOUD_BUSINESS_INDEX WHERE 1 = 1 AND APPLYTYPE = '01' AND STATUS NOT IN ('00', '07', '99') AND ACCOUNT = '" + user.getUsername() + "'"); if (!StringUtils.isEmpty(name)) { sql.append(" AND BUSINESS_NAME LIKE ('%' || '").append(name).append("' || '%') "); } @@ -463,7 +463,6 @@ public class ActTaskController { sql.append(" AND STATUS = '").append(status).append("'"); } sql.append(" ORDER BY CREATE_TIME DESC"); - logger.error("--->查询语句{}", sql); try { Map resultMap = new HashMap<>(); List> list = lcJdbcTemplate.queryForList(sql.toString()); @@ -472,8 +471,8 @@ public class ActTaskController { resultMap.put("list", list); return new Result().ok(resultMap); } catch (Exception e) { + logger.error("查询浪潮数据库申SQL语句--->{}", sql); logger.error("浪潮数据查询异常", e); - return new Result().error("数据查询异常,请联系云资源数据库管理人员!"); } @@ -490,9 +489,9 @@ public class ActTaskController { }) public Result getZwyVideoList(String name, String status, int pageNum, int pageSize) { - JdbcTemplate lcJdbcTemplate = JdbcTemplateFactory.getJdbcTemplate(); UserDetail user = SecurityUser.getUser(); - StringBuilder sql = new StringBuilder("SELECT BSNUM, BUSINESS_NAME, to_char(CREATE_TIME,'yyyy-mm-dd hh24:mi:ss') AS \"CREATE_TIME\", STATUS " + + StringBuilder sql = new StringBuilder("SELECT BSNUM, BUSINESS_NAME, to_char(CREATE_TIME,'yyyy-mm-dd hh24:mi:ss') AS \"CREATE_TIME\", " + + "(CASE WHEN STATUS = '04' THEN '不通过' WHEN STATUS IN ('05', '06') THEN '通过' ELSE '审核中' END) AS \"STATUS\"" + "FROM VIEW_VIDEO_BUSINESS_INDEX WHERE 1 = 1 AND STATUS != '00' AND ACCOUNT = '" + user.getUsername() + "'"); if (!StringUtils.isEmpty(name)) { sql.append(" AND BUSINESS_NAME LIKE CONCAT('%', ").append(name).append(", '%') "); @@ -501,7 +500,6 @@ public class ActTaskController { sql.append(" AND STATUS = '").append(status).append("'"); } sql.append(" ORDER BY CREATE_TIME DESC"); - logger.error("--->查询语句{}", sql); try { Map resultMap = new HashMap<>(); List> list = lcJdbcTemplate.queryForList(sql.toString()); @@ -510,6 +508,7 @@ public class ActTaskController { resultMap.put("list", list); return new Result().ok(resultMap); } catch (Exception e) { + logger.error("查询浪潮数据库申SQL语句--->{}", sql); logger.error("浪潮数据查询异常", e); return new Result().error("数据查询异常,请联系云资源数据库管理人员!"); } @@ -524,65 +523,73 @@ public class ActTaskController { @ApiImplicitParam(name = "id", value = "业务ID", paramType = "query", required = true, dataType = "String") }) public Result getZwyBusinessInfoById(String id) { - JdbcTemplate lcJdbcTemplate = JdbcTemplateFactory.getJdbcTemplate(); - try { - ArrayList arrayList = new ArrayList<>(); - //云主机 - CompletableFuture yzj = CompletableFuture.runAsync(() -> { - StringBuilder sql = new StringBuilder("SELECT BSNUM, '云主机' AS \"SOURCE_TYPE\", NAME, DISPOSE AS \"INFO\" " + - " FROM VIEW_CLOUD_HOST_INFO WHERE 1 = 1 AND BSNUM = '"); - sql.append(id).append("'"); - logger.error("--->查询语句{}", sql); - List> list = lcJdbcTemplate.queryForList(sql.toString()); - arrayList.addAll(list); + ArrayList arrayList = new ArrayList<>(); - }, executor); + //云主机 + CompletableFuture yzj = CompletableFuture.runAsync(() -> { - //云数据库 - CompletableFuture ysjk = CompletableFuture.runAsync(() -> { + StringBuilder sql = new StringBuilder("SELECT BSNUM, '云主机' AS \"SOURCE_TYPE\", NAME, DISPOSE AS \"INFO\" " + + " FROM VIEW_CLOUD_HOST_INFO WHERE 1 = 1 AND BSNUM = '"); + sql.append(id).append("'"); - StringBuilder sql = new StringBuilder("SELECT BSNUM, '云数据库' AS \"SOURCE_TYPE\", NAME, (TYPE || '/' || STORAGE_SPACE || 'GB') AS \"INFO\" " + - " FROM VIEW_CLOUD_DATABASE_INFO WHERE 1 = 1 AND BSNUM = '"); - sql.append(id).append("'"); - logger.error("--->查询语句{}", sql); - List> list = lcJdbcTemplate.queryForList(sql.toString()); - arrayList.addAll(list); + List> list = null; + try { + list = lcJdbcTemplate.queryForList(sql.toString()); + } catch (DataAccessException e) { + logger.error("查询浪潮数据库云主机数据异常,SQL语句--->{}", sql); + } + arrayList.addAll(list); + }, executor); - }, executor); + //云数据库 + CompletableFuture ysjk = CompletableFuture.runAsync(() -> { - //对象存储 - CompletableFuture dxcc = CompletableFuture.runAsync(() -> { + StringBuilder sql = new StringBuilder("SELECT BSNUM, '云数据库' AS \"SOURCE_TYPE\", NAME, (TYPE || '/' || STORAGE_SPACE || 'GB') AS \"INFO\" " + + " FROM VIEW_CLOUD_DATABASE_INFO WHERE 1 = 1 AND BSNUM = '"); + sql.append(id).append("'"); + List> list = null; + try { + list = lcJdbcTemplate.queryForList(sql.toString()); + } catch (DataAccessException e) { + logger.error("查询浪潮数据库云数据库数据异常,SQL语句--->{}", sql); + } + arrayList.addAll(list); + }, executor); - StringBuilder sql = new StringBuilder("SELECT BSNUM, '对象存储' AS \"SOURCE_TYPE\", NAME, (DATA_DISK || 'GB') AS \"INFO\" " + - " FROM VIEW_CLOUD_OBJECTSTORAGE_INFO WHERE 1 = 1 AND BSNUM = '"); - sql.append(id).append("'"); - logger.error("--->查询语句{}", sql); - List> list = lcJdbcTemplate.queryForList(sql.toString()); - arrayList.addAll(list); + //对象存储 + CompletableFuture dxcc = CompletableFuture.runAsync(() -> { - }, executor); + StringBuilder sql = new StringBuilder("SELECT BSNUM, '对象存储' AS \"SOURCE_TYPE\", NAME, (DATA_DISK || 'GB') AS \"INFO\" " + + " FROM VIEW_CLOUD_OBJECTSTORAGE_INFO WHERE 1 = 1 AND BSNUM = '"); + sql.append(id).append("'"); + List> list = null; + try { + list = lcJdbcTemplate.queryForList(sql.toString()); + } catch (DataAccessException e) { + logger.error("查询浪潮数据库对象存储数据异常,SQL语句--->{}", sql); + } + arrayList.addAll(list); + }, executor); - //托管服务 - CompletableFuture tgfw = CompletableFuture.runAsync(() -> { - StringBuilder sql = new StringBuilder("SELECT BSNUM, '托管服务' AS \"SOURCE_TYPE\", NAME, (U_NUM || 'U') AS \"INFO\" " + - " FROM VIEW_TRUSTEESHIPSERVICE_INFO WHERE 1 = 1 AND BSNUM = '"); - sql.append(id).append("'"); - logger.error("--->查询语句{}", sql); - List> list = lcJdbcTemplate.queryForList(sql.toString()); - arrayList.addAll(list); + //托管服务 + CompletableFuture tgfw = CompletableFuture.runAsync(() -> { + StringBuilder sql = new StringBuilder("SELECT BSNUM, '托管服务' AS \"SOURCE_TYPE\", NAME, (U_NUM || 'U') AS \"INFO\" " + + " FROM VIEW_TRUSTEESHIPSERVICE_INFO WHERE 1 = 1 AND BSNUM = '"); + sql.append(id).append("'"); + List> list = null; + try { + list = lcJdbcTemplate.queryForList(sql.toString()); + } catch (DataAccessException e) { + logger.error("查询浪潮数据库托管服务数据异常,SQL语句--->{}", sql); + } + arrayList.addAll(list); + }, executor); - }, executor); - - CompletableFuture all = CompletableFuture.allOf(yzj, ysjk, dxcc, tgfw); - all.join(); - return new Result().ok(arrayList); - } catch (Exception e) { - logger.error("浪潮数据查询异常", e); - - return new Result().error("数据查询异常,请联系云资源数据库管理人员!"); - } + CompletableFuture all = CompletableFuture.allOf(yzj, ysjk, dxcc, tgfw); + all.join(); + return new Result().ok(arrayList); } @@ -593,17 +600,15 @@ public class ActTaskController { @ApiImplicitParam(name = "id", value = "业务ID", paramType = "query", required = true, dataType = "String") }) public Result getZwyVideoInfoById(String id) { - JdbcTemplate lcJdbcTemplate = JdbcTemplateFactory.getJdbcTemplate(); StringBuilder sql = new StringBuilder("SELECT BSNUM, CAMERATYPE, NAME, ORG_NAME " + "FROM VIEW_VIDEO_BUSINESS_RELATION WHERE 1 = 1 AND BSNUM = '"); sql.append(id).append("'"); - logger.error("--->查询语句{}", sql); try { List> list = lcJdbcTemplate.queryForList(sql.toString()); return new Result().ok(list); } catch (Exception e) { logger.error("浪潮数据查询异常", e); - + logger.error("查询浪潮数据库申SQL语句--->{}", sql); return new Result().error("数据查询异常,请联系云资源数据库管理人员!"); } diff --git a/renren-admin/src/main/java/io/renren/modules/fuse/controller/FuseController.java b/renren-admin/src/main/java/io/renren/modules/fuse/controller/FuseController.java index 164510f4..650fc0bc 100644 --- a/renren-admin/src/main/java/io/renren/modules/fuse/controller/FuseController.java +++ b/renren-admin/src/main/java/io/renren/modules/fuse/controller/FuseController.java @@ -47,7 +47,8 @@ public class FuseController { @ApiImplicitParam(name = "description", value = "融合服务描述", paramType = "query", dataType = "String"), @ApiImplicitParam(name = "type", value = "融合服务类型", paramType = "query", dataType = "String"), @ApiImplicitParam(name = "applicationArea", value = "应用领域", paramType = "query", dataType = "String"), - @ApiImplicitParam(name = "deptId", value = "所属部门", paramType = "query", dataType = "int") + @ApiImplicitParam(name = "deptId", value = "所属部门", paramType = "query", dataType = "int"), + @ApiImplicitParam(name = "district", value = "赋能场景类型", paramType = "query", dataType = "int") }) public Result> page(@ApiIgnore @RequestParam Map params) { PageData page = tbFuseService.page(params); diff --git a/renren-admin/src/main/java/io/renren/modules/fuse/dto/TbFuseDTO.java b/renren-admin/src/main/java/io/renren/modules/fuse/dto/TbFuseDTO.java index 7ff0b2ec..9eb0728b 100644 --- a/renren-admin/src/main/java/io/renren/modules/fuse/dto/TbFuseDTO.java +++ b/renren-admin/src/main/java/io/renren/modules/fuse/dto/TbFuseDTO.java @@ -58,6 +58,8 @@ public class TbFuseDTO { private Integer dataSourceCount; @ApiModelProperty(value = "组件服务数量") private Integer componentCount; + @ApiModelProperty(value = "组件服务数量") + private Integer district; } diff --git a/renren-admin/src/main/java/io/renren/modules/fuse/entity/TbFuseEntity.java b/renren-admin/src/main/java/io/renren/modules/fuse/entity/TbFuseEntity.java index 26609e37..58e4d62a 100644 --- a/renren-admin/src/main/java/io/renren/modules/fuse/entity/TbFuseEntity.java +++ b/renren-admin/src/main/java/io/renren/modules/fuse/entity/TbFuseEntity.java @@ -79,4 +79,6 @@ public class TbFuseEntity extends BaseEntity { private Integer infrastructureCount; private Integer dataSourceCount; private Integer componentCount; + private Integer district; + } 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 26673d1c..4a0f0217 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 @@ -77,11 +77,13 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.Cacheable; import org.springframework.context.annotation.Lazy; +import org.springframework.dao.DataAccessException; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import org.springframework.web.client.RestClientException; @@ -251,29 +253,31 @@ public class ResourceServiceImpl extends CrudServiceImpl getWrapper(Map params) { @@ -2163,20 +2167,6 @@ public class ResourceServiceImpl extends CrudServiceImpl infrastructureCount = CompletableFuture.runAsync(() -> { //基础设施 - // HashMap queryMap = new HashMap<>(); - // queryMap.put("cameraName", keyWorld); - // Integer countNew = cameraChannelMapper.selectByParentIdCountNew(queryMap, null, ""); - // resultList.add(new HashMap() { - // { - // put("count", countNew + ""); - // put("type", "基础设施"); - // } - // }); - // - //}, executor); - //统计增加会客厅搜索结果 CompletableFuture meetingRoomCount = CompletableFuture.runAsync(() -> meetCountNew[0] = tMeetingroomMapper.selectByName(keyWorld).size(), executor); @@ -2217,7 +2207,6 @@ public class ResourceServiceImpl extends CrudServiceImpl> zwyCountListByapplyDept = new ArrayList<>(); - Map lcDept = sysDeptDao.selectLCDeptByUcsDeptName(params.get("deptId").toString()); - if (lcDept.isEmpty() || org.apache.commons.lang3.StringUtils.isBlank(lcDept.get("lc_name").toString())) { - logger.error("未查询到{}对应的浪潮系统部门", params.get("provideDept").toString()); + List> lcDept = sysDeptDao.selectLCDeptByUcsDeptName(params.get("deptId").toString()); + if (lcDept.isEmpty()) { + logger.error("未查询到{}对应的浪潮系统部门", params.get("deptId").toString()); return new ArrayList<>(); } else { StringBuilder sb = new StringBuilder("SELECT " + " COUNT( BSNUM ) AS \"count\", " + - " 'yzy' AS \"type\" " + + " 'yzy' AS \"type\" " + "FROM " + " VIEW_CLOUD_BUSINESS_INDEX " + "WHERE " + " 1 = 1 " + - " AND ORG_NAME = '"); - sb.append(lcDept.get("lc_name").toString()) - .append("' UNION ALL " + + " AND ORG_NAME IN ("); + lcDept.forEach(x -> sb.append("'").append(x.get("lc_name").toString()).append("', ")); + sb.deleteCharAt(sb.length() - 2); + sb.append(") UNION ALL " + "SELECT " + " COUNT( BSNUM ) AS \"count\", " + " 'ysp' AS \"type\" " + @@ -2252,20 +2242,30 @@ public class ResourceServiceImpl extends CrudServiceImpl sb.append("'").append(x.get("lc_name").toString()).append("', ")); + sb.deleteCharAt(sb.length() - 2); + sb.append(")"); try { zwyCountListByapplyDept.addAll(lcJdbcTemplate.queryForList(sb.toString())); } catch (Exception e) { - logger.error(sb.toString(), e); + logger.error("查询浪潮数据库申SQL语句--->{}", sb); + logger.error("查询浪潮数据库异常", e); } } + Map>> zwyCountListMap = zwyCountListByapplyDept.stream().collect(Collectors.groupingBy(m -> m.get("type").toString())); List> typeCountListByApplyDept = resourceDao.selectApplyDeptDetailTypeCountList(params); - if (!typeCountListByApplyDept.isEmpty() && !zwyCountListByapplyDept.isEmpty()) { - typeCountListByApplyDept.get(0).putAll(zwyCountListByapplyDept.get(0)); - } + zwyCountListMap.forEach((k, v) -> { + Map zwyCountMap = new HashMap<>(); + zwyCountMap.put("count", v.stream().mapToInt(it -> Integer.parseInt(it.get("count").toString())).sum()); + zwyCountMap.put("type", k); + zwyCountMap.put("deptName", params.get("deptId").toString()); + zwyCountMap.put("district", 250000); + zwyCountMap.put("deptType", 2); + typeCountListByApplyDept.add(zwyCountMap); + } + ); Map>> typeCountListMap = typeCountListByApplyDept.stream().collect(Collectors.groupingBy(m -> m.get("deptName").toString())); ArrayList resultList = new ArrayList<>(); @@ -2307,17 +2307,23 @@ public class ResourceServiceImpl extends CrudServiceImpl { Map ucsDept = sysDeptDao.selectUCSDeptByLCDeptName(x.get("deptName").toString()); - if (!ucsDept.isEmpty()) { - x.put("dept_id", ucsDept.get("ucs_id").toString()); - x.put("deptType", ucsDept.get("type").toString()); - x.put("district", ucsDept.get("district").toString()); - x.replace("deptName", ucsDept.get("ucs_name").toString()); + if (ucsDept != null && !ucsDept.isEmpty()) { + logger.error("浪潮{}单位对应ucs单位为{}", x.get("deptName").toString(), ucsDept.get("ucs_name")); + x.put("dept_id", ucsDept.get("ucs_id")); + x.put("deptType", ucsDept.get("type")); + x.put("district", ucsDept.get("district")); + x.replace("deptName", ucsDept.get("ucs_name")); + } { + logger.error("未在ucs系统中找到浪潮{}单位对应部门", x.get("deptName").toString()); + x.put("dept_id", ""); + x.put("deptType", 2); + x.put("district", 250000); + x.replace("deptName", "其他单位"); } }); typeCountListByApplyDept.addAll(zwyCountListByApplyDept); } - Map>> typeCountListMap = typeCountListByApplyDept.stream().collect(Collectors.groupingBy(m -> m.get("deptName").toString())); ArrayList resultList = new ArrayList<>(); Map countMap = new HashMap<>(); @@ -2326,7 +2332,12 @@ public class ResourceServiceImpl extends CrudServiceImpl Integer.parseInt(it.get("count").toString())).sum()); map.put("name", k); v.forEach(item -> { - map.put(item.get("type").toString(), item.get("count")); + if (map.containsKey(item.get("type").toString())) { + map.replace(item.get("type").toString(), Integer.parseInt(item.get("count").toString()) + (Integer) map.get(item.get("type"))); + } else { + 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 { @@ -2355,10 +2366,18 @@ public class ResourceServiceImpl extends CrudServiceImpl { Map ucsDept = sysDeptDao.selectUCSDeptByLCDeptName(x.get("deptName").toString()); - if (!ucsDept.isEmpty()) { - x.put("dept_id", ucsDept.get("ucs_id").toString()); - x.put("deptType", ucsDept.get("type").toString()); - x.put("district", ucsDept.get("district").toString()); + + if (null != ucsDept && !ucsDept.isEmpty()) { + x.put("dept_id", ucsDept.get("ucs_id")); + x.put("deptName", ucsDept.get("ucs_name")); + x.put("deptType", ucsDept.get("type")); + x.put("district", ucsDept.get("district")); + } else { + x.put("dept_id", ""); + x.put("deptType", 2); + x.put("district", 250000); + logger.error("未在ucs系统中找到浪潮{}单位对应部门", x.get("deptName").toString()); + x.put("deptName", "其他单位"); } }); List> typeCountListByApplyDept = resourceDao.selectApplyDeptDetailTypeCountList(params); @@ -2372,11 +2391,15 @@ public class ResourceServiceImpl extends CrudServiceImpl>> 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")); + + index.replace(count.get("type").toString(), Integer.parseInt(count.get("count").toString()) + Integer.parseInt(index.get(count.get("type").toString()).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 { @@ -2394,7 +2417,9 @@ public class ResourceServiceImpl extends CrudServiceImpl 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 { @@ -2441,6 +2466,7 @@ public class ResourceServiceImpl extends CrudServiceImpl> temp = typeCountListMap3.keySet().stream().map(index_ -> { HashMap map = new HashMap<>(); @@ -2492,7 +2518,9 @@ public class ResourceServiceImpl extends CrudServiceImpl> typeCountListByDept = resourceDao.selectDeptDetailTypeCountList(params); Map>> typeCountListMap = typeCountListByDept.stream().collect(Collectors.groupingBy(m -> m.get("deptName").toString())); ArrayList resultList = new ArrayList<>(); @@ -2521,36 +2549,40 @@ public class ResourceServiceImpl extends CrudServiceImpl> 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); - }); - 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 { // 全部部门 + } + + //else if (params.containsKey("region") && org.apache.commons.lang3.StringUtils.isNotEmpty(params.get("region").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); + // }); + // 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())); @@ -2729,31 +2761,26 @@ public class ResourceServiceImpl extends CrudServiceImpl ucs = CompletableFuture.runAsync(() -> { - List ucsApplyDtoList = resourceDao.selectCensusApplyTable(params); - result.addAll(ucsApplyDtoList); - total.addAndGet(ucsApplyDtoList.size()); - }, executor); + if (params.containsKey("type") && (null == params.get("type") || org.apache.commons.lang3.StringUtils.isBlank(params.get("type").toString()))) { //查所有 + + int total = 0; + List ucsApplyDtoList = resourceDao.selectCensusApplyTable(params); + result.addAll(ucsApplyDtoList); + total += ucsApplyDtoList.size(); + + List lcApplyDtoList = lcSelectCensusApplyTable(params); + result.addAll(lcApplyDtoList); + total += lcApplyDtoList.size(); - //浪潮政务云和云视频申请记录 - CompletableFuture lc = CompletableFuture.runAsync(() -> { - List lcApplyDtoList = lcSelectCensusApplyTable(params); - result.add(lcApplyDtoList); - total.addAndGet(lcApplyDtoList.size()); - }, executor); - CompletableFuture.allOf(ucs, lc).join(); //根据时间重新排序再分页 - result.stream() + List newResult = (List) result.stream() .sorted(Comparator.comparing(x -> { Map map = (Map) x; return DateUtils.parse(map.get("createDate").toString(), DateUtils.DATE_TIME_PATTERN); }).reversed()) .skip((curPage - 1) * limit).limit(limit).collect(Collectors.toList()); - return new PageData(result, total.intValue()); - } else if ("云资源".equals(params.get("resourceType").toString()) || "云视频".equals(params.get("resourceType").toString())) { + return new PageData(newResult, total); + } else if ("云资源".equals(params.get("type").toString()) || "云视频".equals(params.get("type").toString())) { List lcApplyDtoList = lcSelectCensusApplyTable(params); result.addAll(lcApplyDtoList.stream().skip((curPage - 1) * limit).limit(limit).collect(Collectors.toList())); return new PageData(result, lcApplyDtoList.size()); @@ -2767,6 +2794,11 @@ public class ResourceServiceImpl extends CrudServiceImpl lcSelectCensusApplyTable(Map params) { + + if (params.get("region") != null && !"250000".equals(params.get("region").toString())) { + logger.error("非市级单位无法查浪潮数据"); + return new ArrayList<>(); + } StringBuilder sb = new StringBuilder("SELECT * FROM ( " + "SELECT " + " vcbi.ORG_NAME AS \"deptName\", bsrel.name AS \"resourceName\", '青岛市大数据发展管理局' AS \"resourceDeptName\", " + @@ -2785,7 +2817,7 @@ public class ResourceServiceImpl extends CrudServiceImpl lcDept = sysDeptDao.selectLCDeptByUcsDeptName(params.get("provideDept").toString()); + if (params.get("provideDept") != null && org.apache.commons.lang3.StringUtils.isNotBlank(params.get("provideDept").toString())) { + List> lcDept = sysDeptDao.selectLCDeptByUcsDeptName(params.get("provideDept").toString()); - try { - if (lcDept.isEmpty() - || lcDept.get("lc_name") == null - || (lcDept.get("lc_name") != null && org.apache.commons.lang3.StringUtils.isBlank(lcDept.get("lc_name").toString())) - ) { - logger.error("未查询到{}对应的浪潮系统部门", params.get("provideDept").toString()); - return new ArrayList<>(); - } - sb.append(" AND apply.\"resourceDeptName\" = ").append(lcDept.get("lc_name").toString()); - } catch (Exception e) { - logger.error("", e); + if (CollectionUtils.isEmpty(lcDept)) { + logger.error("未查询到{}对应的浪潮系统部门", params.get("provideDept").toString()); return new ArrayList<>(); } + sb.append(" AND apply.\"resourceDeptName\" IN ("); + lcDept.forEach(x -> sb.append("'").append(x.get("lc_name").toString()).append("', ")); + sb.deleteCharAt(sb.length() - 2); + sb.append(")"); } - if (params.get("region") != null) { - List deptNames = sysDeptDao.selectLCDeptByRegion((Long) params.get("region")); - logger.error("只查询本区域部门申请,部门列表{}", deptNames); - sb.append(" AND apply.\"deptName\" IN ( "); - deptNames.forEach(name -> sb.append("'").append(name).append("', ")); - sb.deleteCharAt(sb.length() - 1); - sb.append(" ) "); - } - if (params.get("type") != null) { + + if (params.get("type") != null && org.apache.commons.lang3.StringUtils.isNotBlank(params.get("type").toString())) { if ("云视频".equals(params.get("type").toString())) { - sb.append(" AND apply.type = '云视频' "); + sb.append(" AND apply.\"type\" = '云视频' "); } else { - sb.append(" AND apply.type != '云视频' "); + sb.append(" AND apply.\"type\" != '云视频' "); } } - if (params.get("startDate") != null && params.get("endDate") != null) { + if (params.get("startDate") != null && params.get("endDate") != null && org.apache.commons.lang3.StringUtils.isNotBlank(params.get("startDate").toString())) { sb.append(" AND apply.\"createDate\" BETWEEN '").append(params.get("startDate").toString()) .append("' AND '").append(params.get("endDate").toString()).append("'"); } - if (params.get("approveStatus") != null) { + if (params.get("approveStatus") != null && org.apache.commons.lang3.StringUtils.isNotBlank(params.get("approveStatus").toString())) { sb.append(" AND apply.\"approveStatus\" = '").append(params.get("approveStatus").toString()).append("'"); } - if (params.get("deptId") != null) { - sb.append(" AND apply.\"deptName\" = '").append(params.get("deptId").toString()).append("'"); + if (params.get("deptId") != null && org.apache.commons.lang3.StringUtils.isNotBlank(params.get("deptId").toString())) { + List> deptIds = sysDeptDao.selectLCDeptByUcsDeptName(params.get("deptId").toString()); + sb.append(" AND apply.\"deptName\" IN ("); + deptIds.forEach(x -> sb.append("'").append(x.get("lc_name").toString()).append("', ")); + sb.deleteCharAt(sb.length() - 2); + sb.append(")"); } - if (params.get("resourceName") != null) { + if (params.get("resourceName") != null && org.apache.commons.lang3.StringUtils.isNotBlank(params.get("resourceName").toString())) { sb.append(" AND apply.\"resourceName\" LIKE '%" + params.get("resourceName").toString() + "%'"); } sb.append(" ORDER BY apply.\"createDate\" DESC"); - logger.error("查询浪潮数据库--按资源查询申请记录SQL:{}", sb); - List> list = jdbcTemplate.queryForList(sb.toString()); + List> list = null; + try { + list = lcJdbcTemplate.queryForList(sb.toString()); + } catch (DataAccessException e) { + logger.error("查询浪潮数据库--按资源查询申请记录SQL:{}", sb); + } return new ArrayList<>(list); } diff --git a/renren-admin/src/main/java/io/renren/modules/resourceBrowse/controller/ResourceBrowseController.java b/renren-admin/src/main/java/io/renren/modules/resourceBrowse/controller/ResourceBrowseController.java index b2d67292..b874e0be 100644 --- a/renren-admin/src/main/java/io/renren/modules/resourceBrowse/controller/ResourceBrowseController.java +++ b/renren-admin/src/main/java/io/renren/modules/resourceBrowse/controller/ResourceBrowseController.java @@ -61,7 +61,6 @@ public class ResourceBrowseController { @ApiImplicitParam(name = "name", value = "关键字", paramType = "query", dataType = "String"), @ApiImplicitParam(name = "type", value = "查询类型(组件服务 应用资源 知识库)", paramType = "query", dataType = "String"), }) - //@RequiresPermissions("resourceBrowse:resourcebrowse:page") public Result> page(@ApiIgnore @RequestParam Map params) { UserDetail user = SecurityUser.getUser(); if (user == null) { @@ -70,9 +69,9 @@ public class ResourceBrowseController { Long id = user.getId(); params.put("userId", id); } - Integer page = Integer.parseInt(params.get("page").toString()) - 1; - Integer pageSize = Integer.parseInt(params.get("limit").toString()); - params.put("pageNum", page); + Integer page = params.get("page") != null ? Integer.parseInt(params.get("page").toString()) - 1 : 0; + Integer pageSize = params.get("limit")!= null ? Integer.parseInt(params.get("limit").toString()) : 5; + params.put("pageNum", page * pageSize); params.put("pageSize", pageSize); //PageData page = resourceBrowseService.page(params); diff --git a/renren-admin/src/main/java/io/renren/modules/resourceBrowse/dao/ResourceBrowseDao.java b/renren-admin/src/main/java/io/renren/modules/resourceBrowse/dao/ResourceBrowseDao.java index 98b1c0c5..6937e13c 100644 --- a/renren-admin/src/main/java/io/renren/modules/resourceBrowse/dao/ResourceBrowseDao.java +++ b/renren-admin/src/main/java/io/renren/modules/resourceBrowse/dao/ResourceBrowseDao.java @@ -25,6 +25,4 @@ public interface ResourceBrowseDao extends BaseDao { List selectDayList(@Param("startDate") String startDate, @Param("endDate") String endDate); List selectResourceBrowseByTypeAndUser(@Param("params") Map params); - - Integer resourceBrowseDTOCount(@Param("params") Map params); } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resourceBrowse/service/impl/ResourceBrowseServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/resourceBrowse/service/impl/ResourceBrowseServiceImpl.java index 9358efeb..66f72034 100644 --- a/renren-admin/src/main/java/io/renren/modules/resourceBrowse/service/impl/ResourceBrowseServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/resourceBrowse/service/impl/ResourceBrowseServiceImpl.java @@ -14,6 +14,7 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import java.util.*; +import java.util.stream.Collectors; /** * 浏览记录 @@ -79,9 +80,12 @@ public class ResourceBrowseServiceImpl extends CrudServiceImpl selectResourceBrowseByTypeAndUser(Map map) { - Integer total = resourceBrowseDao.resourceBrowseDTOCount(map); List list = resourceBrowseDao.selectResourceBrowseByTypeAndUser(map); - PageData pageData = new PageData(list, total); + list = list.stream() + .skip(Long.valueOf(map.get("pageNum").toString())) + .limit(Long.valueOf(map.get("pageSize").toString())) + .collect(Collectors.toList()); + PageData pageData = new PageData(list, list.size()); return pageData; } } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/sys/dao/SysDeptDao.java b/renren-admin/src/main/java/io/renren/modules/sys/dao/SysDeptDao.java index a358f456..424e5bb7 100644 --- a/renren-admin/src/main/java/io/renren/modules/sys/dao/SysDeptDao.java +++ b/renren-admin/src/main/java/io/renren/modules/sys/dao/SysDeptDao.java @@ -38,7 +38,7 @@ public interface SysDeptDao extends BaseDao { */ SysDeptEntity getByName(String name); - Map selectLCDeptByUcsDeptName(@Param("provideDept") String provideDept); + List> selectLCDeptByUcsDeptName(@Param("provideDept") String provideDept); List selectLCDeptByRegion(@Param("region") Long region); diff --git a/renren-admin/src/main/resources/db/V8.3__tb_fuse_add_col.sql b/renren-admin/src/main/resources/db/V8.3__tb_fuse_add_col.sql new file mode 100644 index 00000000..c752b342 --- /dev/null +++ b/renren-admin/src/main/resources/db/V8.3__tb_fuse_add_col.sql @@ -0,0 +1 @@ +ALTER TABLE tb_fuse ADD COLUMN `district` int(2) DEFAULT 0 COMMENT '赋能场景类型:0市级、1基层场景'; \ No newline at end of file diff --git a/renren-admin/src/main/resources/mapper/fuse/TbFuseDao.xml b/renren-admin/src/main/resources/mapper/fuse/TbFuseDao.xml index a3fba930..6ac06ab3 100644 --- a/renren-admin/src/main/resources/mapper/fuse/TbFuseDao.xml +++ b/renren-admin/src/main/resources/mapper/fuse/TbFuseDao.xml @@ -19,6 +19,7 @@ + - - \ No newline at end of file