From 647adaf46129a7ef13411140e01735d18ca241b7 Mon Sep 17 00:00:00 2001 From: lizhicheng Date: Thu, 14 Jul 2022 15:33:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E6=AD=A5=E5=AE=8C=E6=88=90=E8=B5=8B?= =?UTF-8?q?=E8=83=BD=E5=9C=BA=E6=99=AF=E3=80=81=E5=BC=80=E5=8F=91=E6=96=87?= =?UTF-8?q?=E6=A1=A3=EF=BC=8C=E8=9E=8D=E5=90=88=E6=9C=8D=E5=8A=A1=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/db/V3.8__fuse_add_col.sql | 5 +++ .../fuse/controller/FuseController.java | 1 + .../io/renren/modules/fuse/dto/TbFuseDTO.java | 2 + .../modules/fuse/entity/TbFuseEntity.java | 4 ++ .../fuse/service/impl/TbFuseServiceImpl.java | 3 ++ .../controller/ResourceController.java | 7 ++++ .../modules/resource/dao/ResourceDao.java | 2 + .../resource/service/ResourceService.java | 2 + .../service/impl/ResourceServiceImpl.java | 41 +++++++++++++++++++ .../impl/ResourceCollectionServiceImpl.java | 11 +++-- .../main/resources/db/V3.8__fuse_add_col.sql | 5 +++ .../resources/mapper/resource/ResourceDao.xml | 5 +++ 12 files changed, 82 insertions(+), 6 deletions(-) create mode 100644 config/db/V3.8__fuse_add_col.sql create mode 100644 renren-admin/src/main/resources/db/V3.8__fuse_add_col.sql diff --git a/config/db/V3.8__fuse_add_col.sql b/config/db/V3.8__fuse_add_col.sql new file mode 100644 index 00000000..3a09209e --- /dev/null +++ b/config/db/V3.8__fuse_add_col.sql @@ -0,0 +1,5 @@ +ALTER TABLE `tb_fuse` +ADD COLUMN `type` varchar(128) NULL COMMENT '服务类型'; + +ALTER TABLE `tb_fuse_attr` +MODIFY COLUMN `attr_value` varchar(4096) NULL COMMENT '属性值'; \ No newline at end of file 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 ec9ce0bb..da0a3fa6 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,6 +47,7 @@ public class FuseController { @ApiImplicitParam(name = Constant.ORDER, required = true, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType = "String"), @ApiImplicitParam(name = "name", value = "融合服务名称", paramType = "query", dataType = "String"), @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 = "deptUser", value = "部门联系人", paramType = "query", dataType = "String"), 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 c4957117..d1d84a05 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 @@ -23,6 +23,8 @@ public class TbFuseDTO { private String name; @ApiModelProperty(value = "融合服务描述") private String description; + @ApiModelProperty(value = "融合服务类型,可选值(融合服务,赋能场景)") + private String type; @ApiModelProperty(value = "应用领域") private String applicationArea; @ApiModelProperty(value = "所属部门") 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 8a077ecb..102799eb 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 @@ -30,6 +30,10 @@ public class TbFuseEntity extends BaseEntity { * 融合服务描述 */ private String description; + /** + * 融合服务类型 + */ + private String type; /** * 应用领域 */ diff --git a/renren-admin/src/main/java/io/renren/modules/fuse/service/impl/TbFuseServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/fuse/service/impl/TbFuseServiceImpl.java index 6b895db0..79204729 100644 --- a/renren-admin/src/main/java/io/renren/modules/fuse/service/impl/TbFuseServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/fuse/service/impl/TbFuseServiceImpl.java @@ -62,6 +62,9 @@ public class TbFuseServiceImpl extends CrudServiceImpl params){ return new Result<>().ok(resourceService.list(params)); } + + @GetMapping("/selectDevelopDoc") + @ApiOperation("查询能力开发文档目录") + @LogOperation("查询能力开发文档目录") + public Result> selectDevelopDoc() { + return new Result>().ok(resourceService.selectDevelopDoc()); + } } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resource/dao/ResourceDao.java b/renren-admin/src/main/java/io/renren/modules/resource/dao/ResourceDao.java index 73242c7a..17565996 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/dao/ResourceDao.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/dao/ResourceDao.java @@ -166,4 +166,6 @@ public interface ResourceDao extends BaseDao { Integer selectDayMax(); List selectUsersApplyAndCount(@Param("userIds") List userIds); + + List> selectDevelopDocResource(); } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resource/service/ResourceService.java b/renren-admin/src/main/java/io/renren/modules/resource/service/ResourceService.java index 0175ab01..d615af06 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/service/ResourceService.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/service/ResourceService.java @@ -130,4 +130,6 @@ public interface ResourceService extends CrudService selectDevelopDoc(); + } \ No newline at end of file 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 c6def0d6..c37bb248 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 @@ -1790,4 +1790,45 @@ public class ResourceServiceImpl extends CrudServiceImpl selectDevelopDoc() { + List result = new ArrayList<>(); + List> dtoMaps = baseDao.selectDevelopDocResource(); + Map>> resourceTypeMap = dtoMaps.stream().collect(Collectors.groupingBy(m -> m.get("type").toString())); + resourceTypeMap.entrySet().stream().forEach(temp -> { + if (!"组件服务".equals(temp.getKey())) { + Map map = new HashMap(); + map.put("title", temp.getKey()); + map.put("children", temp.getValue()); + result.add(map); + } + }); + if (resourceTypeMap.get("组件服务") != null) { + Map componentMap = new HashMap(); + componentMap.put("title", "组件服务"); + Map map = new ConcurrentHashMap<>(); + List tasks = resourceTypeMap.get("组件服务").stream().map(it -> { + CompletableFuture task = CompletableFuture.runAsync(() -> { + selectAttrsByResourceId(Long.parseLong(it.get("id").toString())).stream().filter(temp -> "组件类型".equals(temp.getAttrType())).forEach(attr -> { + if (map.get(attr.getAttrValue()) != null) { + map.get(attr.getAttrValue()).add(it); + } else { + map.put(attr.getAttrValue(), (List) Collections.synchronizedList(new ArrayList() {{ + add(it); + }})); + } + }); + }, executor); + return task; + }).collect(Collectors.toList()); + CompletableFuture.allOf(tasks.toArray(new CompletableFuture[tasks.size()])).join(); + componentMap.put("children", map.entrySet().stream().map(it -> new HashMap() {{ + put("title", it.getKey()); + put("children", it.getValue()); + }}).collect(Collectors.toList())); + result.add(componentMap); + } + return result; + } + } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resourceCollection/service/impl/ResourceCollectionServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/resourceCollection/service/impl/ResourceCollectionServiceImpl.java index d5151dc1..13ca5bba 100644 --- a/renren-admin/src/main/java/io/renren/modules/resourceCollection/service/impl/ResourceCollectionServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/resourceCollection/service/impl/ResourceCollectionServiceImpl.java @@ -93,12 +93,11 @@ public class ResourceCollectionServiceImpl extends CrudServiceImpl collectionEntities = resourceCollectionDao.selectByMap(selectMap); if (collectionEntities.isEmpty()) { resourceCollectionDao.insert(item); - - Integer num = jdbcTemplate.queryForObject("SELECT round(tb_data_resource_assignmark.total) FROM tb_data_resource_assignmark WHERE id =" + item.getResourceId(), Integer.class); - - String sql = String.format("update tb_data_resource SET total = %d WHERE id = %s", num.intValue(), item.getResourceId().toString()); - jdbcTemplate.update(sql); - + if (resourceService.get(item.getResourceId()) != null) { + Integer num = jdbcTemplate.queryForObject("SELECT round(tb_data_resource_assignmark.total) FROM tb_data_resource_assignmark WHERE id =" + item.getResourceId(), Integer.class); + String sql = String.format("update tb_data_resource SET total = %d WHERE id = %s", num.intValue(), item.getResourceId().toString()); + jdbcTemplate.update(sql); + } } else { collectionEntities.forEach(index -> { index.setUpdateDate(new Date()); diff --git a/renren-admin/src/main/resources/db/V3.8__fuse_add_col.sql b/renren-admin/src/main/resources/db/V3.8__fuse_add_col.sql new file mode 100644 index 00000000..3a09209e --- /dev/null +++ b/renren-admin/src/main/resources/db/V3.8__fuse_add_col.sql @@ -0,0 +1,5 @@ +ALTER TABLE `tb_fuse` +ADD COLUMN `type` varchar(128) NULL COMMENT '服务类型'; + +ALTER TABLE `tb_fuse_attr` +MODIFY COLUMN `attr_value` varchar(4096) NULL COMMENT '属性值'; \ No newline at end of file diff --git a/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml b/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml index 43aa418e..8aa14429 100644 --- a/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml +++ b/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml @@ -1412,4 +1412,9 @@ tdr.del_flag = 0 AND tdr.id = #{id} + + \ No newline at end of file