From a52ecdaeca157f97c57a6234188d55a86db25ee8 Mon Sep 17 00:00:00 2001 From: dinggang <2498628697@qq.com> Date: Sat, 10 Dec 2022 16:10:20 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BA=91=E8=B5=84=E6=BA=90=E5=92=8C=E4=BA=91?= =?UTF-8?q?=E8=A7=86=E9=A2=91=E7=94=B3=E8=AF=B7=E6=9F=A5=E8=AF=A2=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=202.ucs=E4=B8=8E=E6=B5=AA=E6=BD=AE=E9=83=A8=E9=97=A8?= =?UTF-8?q?=E5=AF=B9=E5=BA=94=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/db/V8.2__add_table.sql | 18 ++ .../common/config/JdbcTemplateFactory.java | 37 +++ .../controller/ActTaskController.java | 80 +++---- .../activiti/service/ActTaskService.java | 4 +- .../service/impl/ResourceServiceImpl.java | 226 +++++++++++++++++- .../io/renren/modules/sys/dao/SysDeptDao.java | 7 + .../src/main/resources/db/V8.2__add_table.sql | 18 ++ .../resources/mapper/resource/ResourceDao.xml | 28 ++- .../main/resources/mapper/sys/SysDeptDao.xml | 11 + 9 files changed, 363 insertions(+), 66 deletions(-) create mode 100644 config/db/V8.2__add_table.sql create mode 100644 renren-admin/src/main/java/io/renren/common/config/JdbcTemplateFactory.java create mode 100644 renren-admin/src/main/resources/db/V8.2__add_table.sql diff --git a/config/db/V8.2__add_table.sql b/config/db/V8.2__add_table.sql new file mode 100644 index 00000000..171d9fa0 --- /dev/null +++ b/config/db/V8.2__add_table.sql @@ -0,0 +1,18 @@ +SET NAMES utf8mb4; +SET FOREIGN_KEY_CHECKS = 0; +-- ---------------------------- +-- Table structure for t_ucs_lc_dept_rel +-- ---------------------------- +DROP TABLE IF EXISTS `t_ucs_lc_dept_rel`; +CREATE TABLE `t_ucs_lc_dept_rel` ( + `ucs_id` bigint(0) NOT NULL COMMENT 'ucs部门ID,sys_dept主键', + `ucs_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'ucs部门名称', + `district` bigint(0) NULL DEFAULT NULL COMMENT '部门所属地区', + `district_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '地区名称', + `type` int(0) NULL DEFAULT NULL COMMENT '部门类型', + `lc_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '浪潮部门名称', + `lc_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '浪潮部门ID', + PRIMARY KEY (`ucs_id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'ucs与浪潮部门名称对应表' ROW_FORMAT = Dynamic; + +SET FOREIGN_KEY_CHECKS = 1; diff --git a/renren-admin/src/main/java/io/renren/common/config/JdbcTemplateFactory.java b/renren-admin/src/main/java/io/renren/common/config/JdbcTemplateFactory.java new file mode 100644 index 00000000..06ce8421 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/common/config/JdbcTemplateFactory.java @@ -0,0 +1,37 @@ +package io.renren.common.config; + +import com.alibaba.druid.pool.DruidDataSource; +import io.renren.commons.dynamic.datasource.properties.DataSourceProperties; +import org.springframework.jdbc.core.JdbcTemplate; + +public class JdbcTemplateFactory { + + public static JdbcTemplate getJdbcTemplate() { + DataSourceProperties properties = new DataSourceProperties(); + JdbcTemplate jdbcTemplate = new JdbcTemplate(); + DruidDataSource druidDataSource = new DruidDataSource(); + + druidDataSource.setUrl("jdbc:oracle:thin:@15.72.183.89:1521:orcl"); + druidDataSource.setDriverClassName("oracle.jdbc.OracleDriver"); + druidDataSource.setUsername("csynuser"); + druidDataSource.setPassword("csynuser123"); + + druidDataSource.setInitialSize(properties.getInitialSize()); + druidDataSource.setMaxActive(properties.getMaxActive()); + druidDataSource.setMinIdle(properties.getMinIdle()); + druidDataSource.setMaxWait(properties.getMaxWait()); + druidDataSource.setTimeBetweenEvictionRunsMillis(properties.getTimeBetweenEvictionRunsMillis()); + druidDataSource.setMinEvictableIdleTimeMillis(properties.getMinEvictableIdleTimeMillis()); + druidDataSource.setMaxEvictableIdleTimeMillis(properties.getMaxEvictableIdleTimeMillis()); + druidDataSource.setValidationQuery(properties.getValidationQuery()); + druidDataSource.setValidationQueryTimeout(properties.getValidationQueryTimeout()); + druidDataSource.setTestOnBorrow(properties.isTestOnBorrow()); + druidDataSource.setTestOnReturn(properties.isTestOnReturn()); + druidDataSource.setPoolPreparedStatements(properties.isPoolPreparedStatements()); + druidDataSource.setMaxOpenPreparedStatements(properties.getMaxOpenPreparedStatements()); + druidDataSource.setSharePreparedStatements(properties.isSharePreparedStatements()); + jdbcTemplate.setDataSource(druidDataSource); + return jdbcTemplate; + } + +} 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 ab02b0f7..78da8f1a 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 @@ -4,6 +4,7 @@ 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; +import io.renren.common.config.JdbcTemplateFactory; import io.renren.common.constant.Constant; import io.renren.common.exception.ErrorCode; import io.renren.common.page.PageData; @@ -11,7 +12,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.device.dto.TbDeviceApplyDTO; import io.renren.modules.security.user.SecurityUser; import io.renren.modules.security.user.UserDetail; import io.renren.modules.sys.dto.SysUserDTO; @@ -26,7 +26,6 @@ import org.activiti.engine.repository.ProcessDefinition; import org.activiti.engine.repository.ProcessDefinitionQuery; import org.activiti.engine.task.TaskQuery; 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.*; @@ -36,7 +35,6 @@ import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import java.util.logging.Logger; import java.util.stream.Collectors; /** @@ -58,12 +56,17 @@ public class ActTaskController { private SysUserService sysUserService; @Autowired private JdbcTemplate jdbcTemplate; - @Autowired protected RepositoryService repositoryService; @Autowired protected TaskService taskService; + private JdbcTemplate lcJdbcTemplate; + + public void setLcJdbcTemplate(JdbcTemplate lcJdbcTemplate) { + this.lcJdbcTemplate = JdbcTemplateFactory.getJdbcTemplate(); + } + /** * 获取用户任务列表 * 根据用户ID或角色组获取任务信息 @@ -441,22 +444,21 @@ public class ActTaskController { }) public Result getZwyBusinessList(String name, String applyType, String status, int pageNum, int pageSize) { UserDetail user = SecurityUser.getUser(); - JdbcTemplate jdbcTemplate = 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 STATUS != '00' AND ACCOUNT = " + user.getUsername()); + "FROM VIEW_CLOUD_BUSINESS_INDEX WHERE 1 = 1 AND APPLYTYPE = '01' AND STATUS != '00' AND ACCOUNT = '" + user.getUsername() + "'"); if (!StringUtils.isEmpty(name)) { sql.append(" AND BUSINESS_NAME LIKE CONCAT('%', ").append(name).append(", '%') "); } if (!StringUtils.isEmpty(applyType)) { - sql.append(" AND APPLYTYPE = ").append(applyType); + sql.append(" AND APPLYTYPE = '").append(applyType).append("'"); } if (!StringUtils.isEmpty(status)) { - sql.append(" AND STATUS = ").append(status); + sql.append(" AND STATUS = '").append(status).append("'"); } sql.append("ORDER BY CREATE_TIME DESC"); try { Map resultMap = new HashMap<>(); - List> list = jdbcTemplate.queryForList(sql.toString()); + List> list = lcJdbcTemplate.queryForList(sql.toString()); resultMap.put("total", list.size()); List> result = list.stream().skip((pageNum - 1) * pageSize).limit(pageSize).collect(Collectors.toList()); resultMap.put("list", result); @@ -479,19 +481,18 @@ public class ActTaskController { }) public Result getZwyVideoList(String name, String status, int pageNum, int pageSize) { UserDetail user = SecurityUser.getUser(); - JdbcTemplate jdbcTemplate = getJDBCTemplate(); StringBuilder sql = new StringBuilder("SELECT BSNUM, BUSINESS_NAME, to_char(CREATE_TIME,'yyyy-mm-dd hh24:mi:ss') AS \"CREATE_TIME\", STATUS " + - "FROM VIEW_VIDEO_BUSINESS_INDEX WHERE 1 = 1 AND STATUS != '00' AND ACCOUNT = " + user.getUsername()); + "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(", '%') "); } if (!StringUtils.isEmpty(status)) { - sql.append(" AND STATUS = ").append(status); + sql.append(" AND STATUS = '").append(status).append("'"); } sql.append("ORDER BY CREATE_TIME DESC"); try { Map resultMap = new HashMap<>(); - List> list = jdbcTemplate.queryForList(sql.toString()); + List> list = lcJdbcTemplate.queryForList(sql.toString()); resultMap.put("total", list.size()); List> result = list.stream().skip((pageNum - 1) * pageSize).limit(pageSize).collect(Collectors.toList()); resultMap.put("list", result); @@ -510,8 +511,6 @@ public class ActTaskController { @ApiImplicitParam(name = "id", value = "业务ID", paramType = "query",required = true, dataType = "String") }) public Result getZwyBusinessInfoById(String id) { - JdbcTemplate jdbcTemplate = getJDBCTemplate(); - try { ArrayList arrayList = new ArrayList<>(); @@ -519,10 +518,9 @@ public class ActTaskController { 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); - - List> list = jdbcTemplate.queryForList(sql.toString()); + " FROM VIEW_CLOUD_HOST_INFO WHERE 1 = 1 AND BSNUM = '"); + sql.append(id).append("'"); + List> list = lcJdbcTemplate.queryForList(sql.toString()); arrayList.addAll(list); }, executor); @@ -531,10 +529,9 @@ public class ActTaskController { CompletableFuture ysjk = CompletableFuture.runAsync(() -> { StringBuilder sql = new StringBuilder("SELECT BSNUM, '云数据库' AS \"SOURCE_TYPE\", NAME, (TYPE || '/' || STORAGE_SPACE || 'GB') AS \"INFO\" " + - " FROM VIEW_CLOUD_HOST_INFO WHERE 1 = 1 AND BSNUM = "); - sql.append(id); - - List> list = jdbcTemplate.queryForList(sql.toString()); + " FROM VIEW_CLOUD_DATABASE_INFO WHERE 1 = 1 AND BSNUM = '"); + sql.append(id).append("'"); + List> list = lcJdbcTemplate.queryForList(sql.toString()); arrayList.addAll(list); }, executor); @@ -543,28 +540,23 @@ public class ActTaskController { CompletableFuture dxcc = CompletableFuture.runAsync(() -> { StringBuilder sql = new StringBuilder("SELECT BSNUM, '对象存储' AS \"SOURCE_TYPE\", NAME, (DATA_DISK || 'GB') AS \"INFO\" " + - " FROM VIEW_CLOUD_HOST_INFO WHERE 1 = 1 AND BSNUM = "); - sql.append(id); - - List> list = jdbcTemplate.queryForList(sql.toString()); + " FROM VIEW_CLOUD_OBJECTSTORAGE_INFO WHERE 1 = 1 AND BSNUM = '"); + sql.append(id).append("'"); + List> list = lcJdbcTemplate.queryForList(sql.toString()); arrayList.addAll(list); }, executor); - //托管服务 CompletableFuture tgfw = CompletableFuture.runAsync(() -> { - - StringBuilder sql = new StringBuilder("SELECT BSNUM, '托管服务' AS \"SOURCE_TYPE\", NAME, U_NUM AS \"INFO\" " + - " FROM VIEW_CLOUD_HOST_INFO WHERE 1 = 1 AND BSNUM = "); - sql.append(id); - - List> list = jdbcTemplate.queryForList(sql.toString()); + 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 = lcJdbcTemplate.queryForList(sql.toString()); arrayList.addAll(list); }, executor); - CompletableFuture all = CompletableFuture.allOf(yzj, ysjk, dxcc, tgfw); all.join(); return new Result().ok(arrayList); @@ -581,12 +573,12 @@ public class ActTaskController { @ApiImplicitParam(name = "id", value = "业务ID", paramType = "query",required = true, dataType = "String") }) public Result getZwyVideoInfoById(String id) { - JdbcTemplate jdbcTemplate = getJDBCTemplate(); + StringBuilder sql = new StringBuilder("SELECT BSNUM, CAMERATYPE, NAME, ORG_NAME " + - "FROM VIEW_VIDEO_BUSINESS_RELATION WHERE 1 = 1 AND BSNUM = "); - sql.append(id); + "FROM VIEW_VIDEO_BUSINESS_RELATION WHERE 1 = 1 AND BSNUM = '"); + sql.append(id).append("'"); try { - List> list = jdbcTemplate.queryForList(sql.toString()); + List> list = lcJdbcTemplate.queryForList(sql.toString()); return new Result().ok(list); } catch (Exception e) { return new Result().error("数据查询异常,请联系云资源数据库管理人员!"); @@ -594,16 +586,6 @@ public class ActTaskController { } - private JdbcTemplate getJDBCTemplate() { - DruidDataSource druidDataSource = new DruidDataSource(); - druidDataSource.setUrl("jdbc:oracle:thin:@15.72.183.89:1521:orcl"); - druidDataSource.setDriverClassName("oracle.jdbc.OracleDriver"); - druidDataSource.setUsername("csynuser"); - druidDataSource.setPassword("csynuser123"); - jdbcTemplate.setDataSource(druidDataSource); - return jdbcTemplate; - } - @PostMapping("batchBackToFirst") @ApiOperation("驳回,回退至第一个用户任务(重新录入表单)") @LogOperation("驳回,回退至第一个用户任务(重新录入表单)") diff --git a/renren-admin/src/main/java/io/renren/modules/activiti/service/ActTaskService.java b/renren-admin/src/main/java/io/renren/modules/activiti/service/ActTaskService.java index b468dd47..1553213a 100644 --- a/renren-admin/src/main/java/io/renren/modules/activiti/service/ActTaskService.java +++ b/renren-admin/src/main/java/io/renren/modules/activiti/service/ActTaskService.java @@ -247,7 +247,7 @@ public class ActTaskService extends BaseServiceImpl { StringBuilder stringBuilder = new StringBuilder(); List resourcesName = resourceDao.selectResourcesTypeByIds(resourceIds); resourcesName.forEach(x -> stringBuilder.append(x).append(",")); - String string = stringBuilder.substring(0, stringBuilder.length() - 2); + String string = stringBuilder.substring(0, stringBuilder.length() - 1); dto.setResourceType(string); }, executor); @@ -256,7 +256,7 @@ public class ActTaskService extends BaseServiceImpl { StringBuilder stringBuilder = new StringBuilder(); List proviDeptsName = resourceDao.selectProvideDeptNameByIds(resourceIds); proviDeptsName.forEach(x -> stringBuilder.append(x).append(",")); - String string = stringBuilder.substring(0, stringBuilder.length() - 2); + String string = stringBuilder.substring(0, stringBuilder.length() - 1); dto.setProvideDept(string); }, executor); 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 9beb9934..3d9fc8e0 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 @@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.google.common.collect.Lists; +import io.renren.common.config.JdbcTemplateFactory; import io.renren.common.constant.Constant; import io.renren.common.domain.Tsingtao_xhaProperties; import io.renren.common.page.PageData; @@ -250,6 +251,35 @@ public class ResourceServiceImpl extends CrudServiceImpl getWrapper(Map params) { @@ -2201,8 +2231,43 @@ 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()); + return new ArrayList<>(); + } 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 = '"); + 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(lcDept.get("lc_name").toString()) + .append("'"); + zwyCountListByapplyDept.addAll(lcJdbcTemplate.queryForList(sb.toString())); + } + List> typeCountListByApplyDept = resourceDao.selectApplyDeptDetailTypeCountList(params); + if (!typeCountListByApplyDept.isEmpty() && !zwyCountListByapplyDept.isEmpty()) { + typeCountListByApplyDept.get(0).putAll(zwyCountListByapplyDept.get(0)); + } + Map>> typeCountListMap = typeCountListByApplyDept.stream().collect(Collectors.groupingBy(m -> m.get("deptName").toString())); ArrayList resultList = new ArrayList<>(); Map countMap = new HashMap<>(); @@ -2231,7 +2296,24 @@ public class ResourceServiceImpl extends CrudServiceImpl> typeCountListByApplyDept = resourceDao.selectApplyDeptDetailTypeCountList(params); + if ("250000".equals(params.get("region").toString())) { + List> zwyCountListByApplyDept = lcJdbcTemplate.queryForList(getAllsql); + + zwyCountListByApplyDept.forEach(x -> { + 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()); + } + }); + typeCountListByApplyDept.addAll(zwyCountListByApplyDept); + } + + Map>> typeCountListMap = typeCountListByApplyDept.stream().collect(Collectors.groupingBy(m -> m.get("deptName").toString())); ArrayList resultList = new ArrayList<>(); Map countMap = new HashMap<>(); @@ -2260,7 +2342,20 @@ public class ResourceServiceImpl extends CrudServiceImpl> zwyCountListByApplyDept = lcJdbcTemplate.queryForList(getAllsql); + + zwyCountListByApplyDept.forEach(x -> { + 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()); + } + }); List> typeCountListByApplyDept = resourceDao.selectApplyDeptDetailTypeCountList(params); + typeCountListByApplyDept.addAll(zwyCountListByApplyDept); + List> resultList = new ArrayList<>(); resultList.addAll(getDeptTemp2()); resultList.addAll(getDeptTemp1()); @@ -2283,6 +2378,7 @@ public class ResourceServiceImpl extends CrudServiceImpl>> typeCountListMap1 = // 区级部门 typeCountListByApplyDept.stream().filter(index -> index.get("deptType").toString().equals("3")) .collect(Collectors.groupingBy(m -> m.get("district").toString())); @@ -2358,6 +2454,8 @@ public class ResourceServiceImpl extends CrudServiceImpl dtoList = resourceDao.selectCensusApplyTable(params); - List result = dtoList.stream().skip((curPage - 1) * limit).limit(limit).collect(Collectors.toList()); - return new PageData(result, dtoList.size()); + + List result = new ArrayList(); + + if (null == params.get("resourceType")) { + AtomicInteger total = new AtomicInteger(); + //本地ucs系统申请记录 + CompletableFuture ucs = CompletableFuture.runAsync(() -> { + List ucsApplyDtoList = resourceDao.selectCensusApplyTable(params); + result.addAll(ucsApplyDtoList); + total.addAndGet(ucsApplyDtoList.size()); + }, executor); + + //浪潮政务云和云视频申请记录 + CompletableFuture lc = CompletableFuture.runAsync(() -> { + List lcApplyDtoList = lcSelectCensusApplyTable(params); + result.add(lcApplyDtoList); + total.addAndGet(lcApplyDtoList.size()); + }, executor); + CompletableFuture.allOf(ucs, lc).join(); + //根据时间重新排序再分页 + 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())){ + List lcApplyDtoList = lcSelectCensusApplyTable(params); + result.addAll(lcApplyDtoList.stream().skip((curPage - 1) * limit).limit(limit).collect(Collectors.toList())); + return new PageData(result, lcApplyDtoList.size()); + } else { + List ucsApplyDtoList = resourceDao.selectCensusApplyTable(params); + result.addAll(ucsApplyDtoList.stream().skip((curPage - 1) * limit).limit(limit).collect(Collectors.toList())); + return new PageData(result, ucsApplyDtoList.size()); + } + } + + private List 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"); + + if (params.get("provideDept") != null) { + Map lcDept = sysDeptDao.selectLCDeptByUcsDeptName(params.get("provideDept").toString()); + + if (lcDept.isEmpty() || 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()); + } + 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 ("云视频".equals(params.get("type").toString())) { + sb.append(" AND apply.type = '云视频' "); + } else { + sb.append(" AND apply.type != '云视频' "); + } + } + if (params.get("startDate") != null && params.get("endDate") != null) { + sb.append(" AND apply.\"createDate\" BETWEEN '").append(params.get("startDate").toString()) + .append("' AND '").append(params.get("endDate").toString()).append("'"); + } + if (params.get("approveStatus") != null) { + 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("resourceName") != null) { + 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()); + return new ArrayList<>(list); + } + + @Override public Object getPraiseList() { return resourceDao.getPraiseList(); @@ -2842,4 +3059,5 @@ public class ResourceServiceImpl extends CrudServiceImpl { */ SysDeptEntity getByName(String name); + Map selectLCDeptByUcsDeptName(@Param("provideDept") String provideDept); + + List selectLCDeptByRegion(@Param("region") Long region); + + Map selectUCSDeptByLCDeptName(@Param("deptName") String deptName); + } \ No newline at end of file diff --git a/renren-admin/src/main/resources/db/V8.2__add_table.sql b/renren-admin/src/main/resources/db/V8.2__add_table.sql new file mode 100644 index 00000000..171d9fa0 --- /dev/null +++ b/renren-admin/src/main/resources/db/V8.2__add_table.sql @@ -0,0 +1,18 @@ +SET NAMES utf8mb4; +SET FOREIGN_KEY_CHECKS = 0; +-- ---------------------------- +-- Table structure for t_ucs_lc_dept_rel +-- ---------------------------- +DROP TABLE IF EXISTS `t_ucs_lc_dept_rel`; +CREATE TABLE `t_ucs_lc_dept_rel` ( + `ucs_id` bigint(0) NOT NULL COMMENT 'ucs部门ID,sys_dept主键', + `ucs_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'ucs部门名称', + `district` bigint(0) NULL DEFAULT NULL COMMENT '部门所属地区', + `district_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '地区名称', + `type` int(0) NULL DEFAULT NULL COMMENT '部门类型', + `lc_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '浪潮部门名称', + `lc_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '浪潮部门ID', + PRIMARY KEY (`ucs_id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'ucs与浪潮部门名称对应表' ROW_FORMAT = Dynamic; + +SET FOREIGN_KEY_CHECKS = 1; diff --git a/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml b/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml index 0746ade5..ac4f65f7 100644 --- a/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml +++ b/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml @@ -1882,13 +1882,11 @@ FROM (SELECT IF(d.type='组件服务', A.attr_value, d.type) AS type, d.id, d.del_flag, d.dept_id, d.create_date 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) tdr, + a.del_flag=0 WHERE d.type IN ('应用资源', '组件服务') AND d.del_flag = 0) tdr, sys_dept sd WHERE 1 = 1 AND tdr.dept_id = sd.id - AND (tdr.type = '应用资源' OR tdr.type = '智能算法' OR tdr.type = '图层服务' OR tdr.type = '开发组件' OR - tdr.type = '业务组件') AND tdr.del_flag=0 @@ -2001,7 +1999,8 @@ AND a.attr_type = '组件类型' AND a.del_flag = 0 WHERE - d.type NOT IN ( '知识库', '基础设施', '数据资源' ) + d.type IN ( '应用资源', '组件服务' ) + AND d.del_flag = 0 ) tdr, sys_dept sd, sys_user su, @@ -2018,7 +2017,7 @@ AND taa.approve_status = #{approveStatus} - AND sd.id = #{deptId} + AND sd.name LIKE CONCAT('%', #{deptId} , '%') AND tdr.type = #{type} @@ -2030,15 +2029,15 @@ AND tdr.name LIKE CONCAT( '%', #{resourceName}, '%' ) - AND dept.`name` LIKE CONCAT( '%', #{provideDept}, '%' ) + AND dept.id = #{provideDept} AND SUBSTR(taa.create_date, 1, 10) BETWEEN #{startDate} AND #{endDate} - UNION ALL + UNION ALL SELECT tmb.dept AS 'deptName', tm.`name` AS 'resourceName', @@ -2050,9 +2049,13 @@ '' AS 'applyNumber' FROM t_meetingroom_book tmb, - t_meetingroom tm + t_meetingroom tm, + sys_dept sd, + sys_region sr WHERE - tmb.room_id = tm.id + tmb.room_id = tm.id + AND tmb.dept = sd.name + AND sd.district = sr.id AND tmb.state=2 @@ -2065,10 +2068,13 @@ - AND tmb.dept = #{deptId} + AND tmb.dept LIKE CONCAT( '%', #{deptId}, '%' ) - AND '青岛市大数据发展管理局' LIKE CONCAT( '%', #{provideDept}, '%' ) + AND #{provideDept} = 1067246875800000066 + + + AND sr.id = #{region} AND tm.name LIKE CONCAT( '%', #{resourceName}, '%' ) diff --git a/renren-admin/src/main/resources/mapper/sys/SysDeptDao.xml b/renren-admin/src/main/resources/mapper/sys/SysDeptDao.xml index 0d4aec95..e470d778 100644 --- a/renren-admin/src/main/resources/mapper/sys/SysDeptDao.xml +++ b/renren-admin/src/main/resources/mapper/sys/SysDeptDao.xml @@ -36,4 +36,15 @@ where t1.name = #{name} LIMIT 1 + + + + + \ No newline at end of file