Commit 302eb5da by zhangkb

修改标签查询元数据接口

parent c0347c54
...@@ -32,8 +32,10 @@ public class TagFileCtrl { ...@@ -32,8 +32,10 @@ public class TagFileCtrl {
private TagFileService tagExportService; private TagFileService tagExportService;
@GetMapping("/exportTagMeta") @GetMapping("/exportTagMeta")
public int exportTagMeta(@RequestParam("idPath") String idPath,HttpServletResponse response) { public int exportTagMeta(@RequestParam("idPath") String idPath,
return tagExportService.exportTagMetadataExcel(idPath, response); @RequestParam("dimensionType") String dimensionType,
@RequestParam("tagType") String tagType,HttpServletResponse response) {
return tagExportService.exportTagMetadataExcel(idPath, dimensionType, tagType, response);
} }
@GetMapping("/exportTag") @GetMapping("/exportTag")
......
package com.keymobile.tagmanager.persistence; package com.keymobile.tagmanager.persistence;
import java.util.Optional;
import org.springframework.data.mongodb.repository.MongoRepository; import org.springframework.data.mongodb.repository.MongoRepository;
import com.keymobile.tagmanager.model.Tag; import com.keymobile.tagmanager.model.Tag;
public interface TagRepository extends MongoRepository<Tag, String> { public interface TagRepository extends MongoRepository<Tag, String> {
public Optional<Tag> findByIdPath(String idPath);
} }
...@@ -9,8 +9,10 @@ import org.springframework.web.bind.annotation.RequestParam; ...@@ -9,8 +9,10 @@ import org.springframework.web.bind.annotation.RequestParam;
@FeignClient(name = "MetadataRepo") @FeignClient(name = "MetadataRepo")
public interface RepoServiceClient { public interface RepoServiceClient {
@PostMapping(value = "/rest/tag/getByTag") @PostMapping(value = "/rest/tag/getByTag")
public Map<String,Object> getTagMetadata(@RequestParam String idPath, public Map<String,Object> getTagMetadata(@RequestParam String dimensionType,
@RequestParam String idPath,
@RequestParam(required = false) String keyword, @RequestParam(required = false) String keyword,
@RequestParam(required = false) int pageNum, @RequestParam(required = false) int pageNum,
@RequestParam(required = false) int pageSize); @RequestParam(required = false) int pageSize,
@RequestParam String tagType);
} }
...@@ -5,10 +5,13 @@ import java.util.Date; ...@@ -5,10 +5,13 @@ import java.util.Date;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import java.util.UUID; import java.util.UUID;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction; import org.springframework.data.domain.Sort.Direction;
...@@ -55,9 +58,10 @@ public class TagFileService { ...@@ -55,9 +58,10 @@ public class TagFileService {
* author:zhangkb time:2020-1-14 desc:元数据管理导出 * author:zhangkb time:2020-1-14 desc:元数据管理导出
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public int exportTagMetadataExcel(String idPath,HttpServletResponse response) { public int exportTagMetadataExcel(String idPath,String dimensionType,
String tagType,HttpServletResponse response) {
//获取标签元数据信息 //获取标签元数据信息
Map<String,Object> data = repoService.getTagMetadata(idPath, "", 1, 10000); Map<String,Object> data = repoService.getTagMetadata(dimensionType,idPath, "", 1, 10000,tagType);
List<Map<String,Object>> content = (List<Map<String,Object>>)data.get("content"); List<Map<String,Object>> content = (List<Map<String,Object>>)data.get("content");
List<TagMetadata> toExportTagMeta = new ArrayList<>(); List<TagMetadata> toExportTagMeta = new ArrayList<>();
for(Map<String,Object> map : content) { for(Map<String,Object> map : content) {
...@@ -65,7 +69,26 @@ public class TagFileService { ...@@ -65,7 +69,26 @@ public class TagFileService {
tagMeta.setMetaModel(map.get("type").toString()); tagMeta.setMetaModel(map.get("type").toString());
tagMeta.setName(map.get("name").toString()); tagMeta.setName(map.get("name").toString());
tagMeta.setMetaName(map.get("namePath").toString()); tagMeta.setMetaName(map.get("namePath").toString());
tagMeta.setTagName(map.get("tagStr").toString());
String tagStr = map.get("tagStr").toString();
//根据标签idPath获取对应的标签名
if(StringUtils.isNotBlank(map.get("tagStr").toString())) {
String tagStrName = "";
tagStr = tagStr.substring(0, tagStr.length()-1);
String[] tags = tagStr.split(";");
for(String tag:tags) {
//根据namePath获取标签
Optional<Tag> tagOp = tagRepository.findByIdPath(tag);
if(tagOp.isPresent()) {
tagStrName+=tagOp.get().getName()+",";
}
}
if(StringUtils.isNotEmpty(tagStrName)) {
tagMeta.setTagName(tagStrName.substring(0, tagStrName.length()-1));
}else {
tagMeta.setTagName(tagStrName);
}
}
toExportTagMeta.add(tagMeta); toExportTagMeta.add(tagMeta);
} }
// 导出操作 // 导出操作
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment