From 439ed6aa61cbfcb2ce815a64b9b09f56167b8018 Mon Sep 17 00:00:00 2001 From: wangliwen Date: Sat, 10 Dec 2022 19:59:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=BF=E5=8A=A1=E4=BA=91=E8=AE=BF=E9=97=AE?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E6=97=B6=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/ResourceServiceImpl.java | 197 ++++++++++-------- 1 file changed, 105 insertions(+), 92 deletions(-) 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 3d9fc8e0..c8cf9cab 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 @@ -257,29 +257,29 @@ public class ResourceServiceImpl extends CrudServiceImpl getWrapper(Map params) { @@ -761,8 +761,8 @@ public class ResourceServiceImpl extends CrudServiceImpl { HashMap map = (HashMap) this.selectInfrastructureList(); final Long[] total = {0L}; - map.forEach((k,v) -> { - total[0] = total[0] + (Integer) v; + map.forEach((k, v) -> { + total[0] = total[0] + (Integer) v; }); re.add(new HashMap() { { @@ -1444,9 +1444,9 @@ public class ResourceServiceImpl extends CrudServiceImpl> result2; if (Long.parseLong(params.get("id").toString()) == 0) { - result2 = jdbcTemplate.queryForList("SELECT COUNT(a.id) AS resourceNum,a.dept_id AS deptId,b.name AS deptName,\n" + "SUM(a.visits) AS resourceVisits \n" + "FROM tb_data_resource a INNER JOIN sys_dept b ON a.dept_id = b.id\n" + "WHERE a.type = '组件服务' AND a.del_flag = 0\n" + "GROUP BY a.dept_id,b.name\n" + "ORDER BY a.dept_id,b.name\n"); + result2 = jdbcTemplate.queryForList("SELECT COUNT(a.id) AS resourceNum,a.dept_id AS deptId,b.name AS deptName, " + "SUM(a.visits) AS resourceVisits " + "FROM tb_data_resource a INNER JOIN sys_dept b ON a.dept_id = b.id " + "WHERE a.type = '组件服务' AND a.del_flag = 0 " + "GROUP BY a.dept_id,b.name " + "ORDER BY a.dept_id,b.name "); } else { - result2 = jdbcTemplate.queryForList("SELECT COUNT(a.id) AS resourceNum,a.dept_id AS deptId,b.name AS deptName,\n" + "SUM(a.visits) AS resourceVisits \n" + "FROM tb_data_resource a INNER JOIN sys_dept b ON a.dept_id = b.id\n" + "WHERE a.type = '组件服务' AND a.del_flag = 0\n" + "AND (b.ID = ? OR INSTR(b.pids,?))\n" + "GROUP BY a.dept_id,b.name\n" + "ORDER BY a.dept_id,b.name\n", pas); + result2 = jdbcTemplate.queryForList("SELECT COUNT(a.id) AS resourceNum,a.dept_id AS deptId,b.name AS deptName, " + "SUM(a.visits) AS resourceVisits " + "FROM tb_data_resource a INNER JOIN sys_dept b ON a.dept_id = b.id " + "WHERE a.type = '组件服务' AND a.del_flag = 0 " + "AND (b.ID = ? OR INSTR(b.pids,?)) " + "GROUP BY a.dept_id,b.name " + "ORDER BY a.dept_id,b.name ", pas); } if (!result2.isEmpty()) { @@ -1524,9 +1524,9 @@ public class ResourceServiceImpl extends CrudServiceImpl> result2; if (Long.parseLong(params.get("id").toString()) == 0) { - result2 = jdbcTemplate.queryForList("SELECT COUNT(a.id) AS resourceNum,a.dept_id AS deptId,b.name AS deptName\n" + "FROM tb_data_resource a INNER JOIN sys_dept b ON a.dept_id = b.id\n" + "WHERE a.type = '应用资源' AND a.del_flag = 0\n" + "GROUP BY a.dept_id,b.name\n" + "ORDER BY a.dept_id,b.name\n"); + result2 = jdbcTemplate.queryForList("SELECT COUNT(a.id) AS resourceNum,a.dept_id AS deptId,b.name AS deptName " + "FROM tb_data_resource a INNER JOIN sys_dept b ON a.dept_id = b.id " + "WHERE a.type = '应用资源' AND a.del_flag = 0 " + "GROUP BY a.dept_id,b.name " + "ORDER BY a.dept_id,b.name "); } else { - result2 = jdbcTemplate.queryForList("SELECT COUNT(a.id) AS resourceNum,a.dept_id AS deptId,b.name AS deptName\n" + "FROM tb_data_resource a INNER JOIN sys_dept b ON a.dept_id = b.id\n" + "WHERE a.type = '应用资源' AND a.del_flag = 0\n" + "AND (b.ID = ? OR b.pids LIKE CONCAT(CONCAT('%',?),'%'))\n" + "GROUP BY a.dept_id,b.name\n" + "ORDER BY a.dept_id,b.name\n", pas); + result2 = jdbcTemplate.queryForList("SELECT COUNT(a.id) AS resourceNum,a.dept_id AS deptId,b.name AS deptName " + "FROM tb_data_resource a INNER JOIN sys_dept b ON a.dept_id = b.id " + "WHERE a.type = '应用资源' AND a.del_flag = 0 " + "AND (b.ID = ? OR b.pids LIKE CONCAT(CONCAT('%',?),'%')) " + "GROUP BY a.dept_id,b.name " + "ORDER BY a.dept_id,b.name ", pas); } if (!result2.isEmpty()) { @@ -1621,9 +1621,9 @@ public class ResourceServiceImpl extends CrudServiceImpl> result2; if (Long.parseLong(params.get("id").toString()) == 0) { - result2 = jdbcTemplate.queryForList("SELECT COUNT(a.id) AS resourceNum,a.dept_id AS deptId,b.name AS deptName\n" + "FROM tb_data_resource a INNER JOIN sys_dept b ON a.dept_id = b.id\n" + "WHERE a.type = '基础设施' AND a.del_flag = 0\n" + "GROUP BY a.dept_id,b.name\n" + "ORDER BY a.dept_id,b.name\n"); + result2 = jdbcTemplate.queryForList("SELECT COUNT(a.id) AS resourceNum,a.dept_id AS deptId,b.name AS deptName " + "FROM tb_data_resource a INNER JOIN sys_dept b ON a.dept_id = b.id " + "WHERE a.type = '基础设施' AND a.del_flag = 0 " + "GROUP BY a.dept_id,b.name " + "ORDER BY a.dept_id,b.name "); } else { - result2 = jdbcTemplate.queryForList("SELECT COUNT(a.id) AS resourceNum,a.dept_id AS deptId,b.name AS deptName\n" + "FROM tb_data_resource a INNER JOIN sys_dept b ON a.dept_id = b.id\n" + "WHERE a.type = '基础设施' AND a.del_flag = 0\n" + "AND (b.ID = ? OR INSTR(b.pids,?))\n" + "GROUP BY a.dept_id,b.name\n" + "ORDER BY a.dept_id,b.name\n", pas); + result2 = jdbcTemplate.queryForList("SELECT COUNT(a.id) AS resourceNum,a.dept_id AS deptId,b.name AS deptName " + "FROM tb_data_resource a INNER JOIN sys_dept b ON a.dept_id = b.id " + "WHERE a.type = '基础设施' AND a.del_flag = 0 " + "AND (b.ID = ? OR INSTR(b.pids,?)) " + "GROUP BY a.dept_id,b.name " + "ORDER BY a.dept_id,b.name ", pas); } if (!result2.isEmpty()) { @@ -1669,9 +1669,9 @@ public class ResourceServiceImpl extends CrudServiceImpl> result2; if (Long.parseLong(params.get("id").toString()) == 0) { - result2 = jdbcTemplate.queryForList("SELECT COUNT(a.id) AS resourceNum,a.dept_id AS deptId,b.name AS deptName\n" + "FROM tb_data_resource a INNER JOIN sys_dept b ON a.dept_id = b.id\n" + "WHERE a.type = '数据资源' AND a.del_flag = 0\n" + "GROUP BY a.dept_id,b.name\n" + "ORDER BY a.dept_id,b.name\n"); + result2 = jdbcTemplate.queryForList("SELECT COUNT(a.id) AS resourceNum,a.dept_id AS deptId,b.name AS deptName " + "FROM tb_data_resource a INNER JOIN sys_dept b ON a.dept_id = b.id " + "WHERE a.type = '数据资源' AND a.del_flag = 0 " + "GROUP BY a.dept_id,b.name " + "ORDER BY a.dept_id,b.name "); } else { - result2 = jdbcTemplate.queryForList("SELECT COUNT(a.id) AS resourceNum,a.dept_id AS deptId,b.name AS deptName\n" + "FROM tb_data_resource a INNER JOIN sys_dept b ON a.dept_id = b.id\n" + "WHERE a.type = '数据资源' AND a.del_flag = 0\n" + "AND (b.ID = ? OR INSTR(b.pids,?))\n" + "GROUP BY a.dept_id,b.name\n" + "ORDER BY a.dept_id,b.name\n", pas); + result2 = jdbcTemplate.queryForList("SELECT COUNT(a.id) AS resourceNum,a.dept_id AS deptId,b.name AS deptName " + "FROM tb_data_resource a INNER JOIN sys_dept b ON a.dept_id = b.id " + "WHERE a.type = '数据资源' AND a.del_flag = 0 " + "AND (b.ID = ? OR INSTR(b.pids,?)) " + "GROUP BY a.dept_id,b.name " + "ORDER BY a.dept_id,b.name ", pas); } @@ -1717,9 +1717,9 @@ public class ResourceServiceImpl extends CrudServiceImpl>> partition = Lists.partition(result, pageSize); @@ -2240,27 +2240,31 @@ public class ResourceServiceImpl extends CrudServiceImpl(); } else { - StringBuilder sb = new StringBuilder("SELECT\n" + - "\tCOUNT( BSNUM ) AS \"count\",\n" + - "\t'yzy' AS \"type\" \n" + - "FROM\n" + - "\tVIEW_CLOUD_BUSINESS_INDEX \n" + - "WHERE\n" + - "\t1 = 1 \n" + - "\tAND ORG_NAME = '"); + StringBuilder sb = new StringBuilder("SELECT " + + " COUNT( BSNUM ) AS \"count\", " + + " 'yzy' AS \"type\" " + + "FROM " + + " VIEW_CLOUD_BUSINESS_INDEX " + + "WHERE " + + " 1 = 1 " + + " AND ORG_NAME = '"); sb.append(lcDept.get("lc_name").toString()) - .append("' UNION ALL\n" + - "SELECT\n" + - "\tCOUNT( BSNUM ) AS \"count\",\n" + - "\t'ysp' AS \"type\" \n" + - "FROM\n" + - "\tVIEW_VIDEO_BUSINESS_INDEX \n" + - "WHERE\n" + - "\t1 = 1 \n" + - "\tAND ORG_NAME = '") + .append("' UNION ALL " + + "SELECT " + + " COUNT( BSNUM ) AS \"count\", " + + " 'ysp' AS \"type\" " + + "FROM " + + " VIEW_VIDEO_BUSINESS_INDEX " + + "WHERE " + + " 1 = 1 " + + " AND ORG_NAME = '") .append(lcDept.get("lc_name").toString()) .append("'"); - zwyCountListByapplyDept.addAll(lcJdbcTemplate.queryForList(sb.toString())); + try { + zwyCountListByapplyDept.addAll(lcJdbcTemplate.queryForList(sb.toString())); + } catch (Exception e) { + logger.error(sb.toString(), e); + } } List> typeCountListByApplyDept = resourceDao.selectApplyDeptDetailTypeCountList(params); @@ -2299,7 +2303,12 @@ public class ResourceServiceImpl extends CrudServiceImpl> typeCountListByApplyDept = resourceDao.selectApplyDeptDetailTypeCountList(params); if ("250000".equals(params.get("region").toString())) { - List> zwyCountListByApplyDept = lcJdbcTemplate.queryForList(getAllsql); + List> zwyCountListByApplyDept = new ArrayList<>(); + try { + zwyCountListByApplyDept = lcJdbcTemplate.queryForList(getAllsql); + } catch (Exception e) { + logger.error(getAllsql, e); + } zwyCountListByApplyDept.forEach(x -> { Map ucsDept = sysDeptDao.selectUCSDeptByLCDeptName(x.get("deptName").toString()); @@ -2342,8 +2351,12 @@ public class ResourceServiceImpl extends CrudServiceImpl> zwyCountListByApplyDept = lcJdbcTemplate.queryForList(getAllsql); + List> zwyCountListByApplyDept = new ArrayList<>(); + try { + zwyCountListByApplyDept = lcJdbcTemplate.queryForList(getAllsql); + } catch (Exception e) { + logger.info(getAllsql, e); + } zwyCountListByApplyDept.forEach(x -> { Map ucsDept = sysDeptDao.selectUCSDeptByLCDeptName(x.get("deptName").toString()); @@ -2740,12 +2753,12 @@ public class ResourceServiceImpl extends CrudServiceImpl { - Map map = (Map) x; + Map map = (Map) x; return DateUtils.parse(map.get("createDate").toString(), DateUtils.DATE_TIME_PATTERN); - }).reversed()) + }).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())){ + } else if ("云资源".equals(params.get("resourceType").toString()) || "云视频".equals(params.get("resourceType").toString())) { List lcApplyDtoList = lcSelectCensusApplyTable(params); result.addAll(lcApplyDtoList.stream().skip((curPage - 1) * limit).limit(limit).collect(Collectors.toList())); return new PageData(result, lcApplyDtoList.size()); @@ -2759,38 +2772,38 @@ public class ResourceServiceImpl extends CrudServiceImpl lcSelectCensusApplyTable(Map params) { - StringBuilder sb = new StringBuilder("SELECT * FROM (\n" + - "SELECT\n" + - "\tvcbi.ORG_NAME AS \"deptName\", bsrel.name AS \"resourceName\", '青岛市大数据发展管理局' AS \"resourceDeptName\",\n" + - "\tbsrel.SOURCE_TYPE AS \"type\", to_char( vcbi.CREATE_TIME, 'yyyy-mm-dd HH24:MI:SS' ) AS \"createDate\",\n" + - "\tvcbi.status AS \"approveStatus\", bsrel.BSNUM AS \"applyNumber\" \n" + - "FROM\n" + - "\t(\n" + - "\t\tSELECT BSNUM, '云主机' AS \"SOURCE_TYPE\", NAME, DISPOSE AS \"INFO\" FROM VIEW_CLOUD_HOST_INFO \n" + - "\t\tUNION ALL\n" + - "\t\tSELECT BSNUM, '云数据库' AS \"SOURCE_TYPE\", NAME, (TYPE || '/' || STORAGE_SPACE || 'GB') AS \"INFO\" FROM VIEW_CLOUD_DATABASE_INFO \n" + - "\t\tUNION ALL\n" + - "\t\tSELECT BSNUM, '对象存储' AS \"SOURCE_TYPE\", NAME, ( DATA_DISK || 'GB' ) AS \"INFO\" FROM VIEW_CLOUD_OBJECTSTORAGE_INFO \n" + - "\t\tUNION ALL\n" + - "\t\tSELECT BSNUM, '托管服务' AS \"SOURCE_TYPE\", NAME, U_NUM AS \"INFO\" FROM VIEW_TRUSTEESHIPSERVICE_INFO\n" + - "\t) bsrel\n" + - "\tLEFT JOIN VIEW_CLOUD_BUSINESS_INDEX vcbi ON bsrel.BSNUM = vcbi.BSNUM \n" + - "WHERE\n" + - "\tvcbi.APPLYTYPE = '01' \n" + - "\tAND vcbi.status IN ( '01', '03', '04', '05', '06', '99' )\n" + - "\tUNION ALL\n" + - "\tSELECT vvbi.ORG_NAME AS \"deptName\", vvbr.name AS \"resourceName\", vvbr.ORG_NAME AS \"resourceDeptName\",\n" + - "\t'云视频' AS \"type\", to_char( vvbi.CREATE_TIME, 'yyyy-mm-dd HH24:MI:SS' ) AS \"createDate\", vvbi.status AS \"approveStatus\", \n" + - "\tvvbr.BSNUM AS \"applyNumber\" \n" + - "FROM\n" + - "\tVIEW_VIDEO_BUSINESS_RELATION vvbr\n" + - "\tLEFT JOIN VIEW_VIDEO_BUSINESS_INDEX vvbi ON vvbr.BSNUM = vvbi.BSNUM \n" + - "WHERE\n" + - "\tvvbi.STATUS != '00'\n" + - "\tAND vvbr.ORG_NAME IS NOT NULL \n" + - "\t) apply \n" + - "\tWHERE 1 = 1\n" + - "\t\n"); + StringBuilder sb = new StringBuilder("SELECT * FROM ( " + + "SELECT " + + " vcbi.ORG_NAME AS \"deptName\", bsrel.name AS \"resourceName\", '青岛市大数据发展管理局' AS \"resourceDeptName\", " + + " bsrel.SOURCE_TYPE AS \"type\", to_char( vcbi.CREATE_TIME, 'yyyy-mm-dd HH24:MI:SS' ) AS \"createDate\", " + + " vcbi.status AS \"approveStatus\", bsrel.BSNUM AS \"applyNumber\" " + + "FROM " + + " ( " + + " SELECT BSNUM, '云主机' AS \"SOURCE_TYPE\", NAME, DISPOSE AS \"INFO\" FROM VIEW_CLOUD_HOST_INFO " + + " UNION ALL " + + " SELECT BSNUM, '云数据库' AS \"SOURCE_TYPE\", NAME, (TYPE || '/' || STORAGE_SPACE || 'GB') AS \"INFO\" FROM VIEW_CLOUD_DATABASE_INFO " + + " UNION ALL " + + " SELECT BSNUM, '对象存储' AS \"SOURCE_TYPE\", NAME, ( DATA_DISK || 'GB' ) AS \"INFO\" FROM VIEW_CLOUD_OBJECTSTORAGE_INFO " + + " UNION ALL " + + " SELECT BSNUM, '托管服务' AS \"SOURCE_TYPE\", NAME, U_NUM AS \"INFO\" FROM VIEW_TRUSTEESHIPSERVICE_INFO " + + " ) bsrel " + + " LEFT JOIN VIEW_CLOUD_BUSINESS_INDEX vcbi ON bsrel.BSNUM = vcbi.BSNUM " + + "WHERE " + + " vcbi.APPLYTYPE = '01' " + + " AND vcbi.status IN ( '01', '03', '04', '05', '06', '99' ) " + + " UNION ALL " + + " SELECT vvbi.ORG_NAME AS \"deptName\", vvbr.name AS \"resourceName\", vvbr.ORG_NAME AS \"resourceDeptName\", " + + " '云视频' AS \"type\", to_char( vvbi.CREATE_TIME, 'yyyy-mm-dd HH24:MI:SS' ) AS \"createDate\", vvbi.status AS \"approveStatus\", " + + " vvbr.BSNUM AS \"applyNumber\" " + + "FROM " + + " VIEW_VIDEO_BUSINESS_RELATION vvbr " + + " LEFT JOIN VIEW_VIDEO_BUSINESS_INDEX vvbi ON vvbr.BSNUM = vvbi.BSNUM " + + "WHERE " + + " vvbi.STATUS != '00' " + + " AND vvbr.ORG_NAME IS NOT NULL " + + " ) apply " + + " WHERE 1 = 1 " + + " "); if (params.get("provideDept") != null) { Map lcDept = sysDeptDao.selectLCDeptByUcsDeptName(params.get("provideDept").toString()); @@ -2802,7 +2815,7 @@ public class ResourceServiceImpl extends CrudServiceImpl deptNames = sysDeptDao.selectLCDeptByRegion((Long)params.get("region")); + 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("', "));