|
|
@@ -19,8 +19,8 @@ import cn.com.yusys.yusp.domain.entity.AitagTagInfoEntity;
|
|
|
import cn.com.yusys.yusp.domain.vo.AitagTagInfoQueryVo;
|
|
|
import cn.com.yusys.yusp.service.AitagTagInfoService;
|
|
|
import cn.com.yusys.yusp.service.TagImportListener;
|
|
|
+import cn.com.yusys.yusp.util.SessionCommonUtil;
|
|
|
import com.alibaba.excel.EasyExcel;
|
|
|
-import com.alibaba.excel.event.AnalysisEventListener;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
@@ -92,14 +92,14 @@ public class AitagTagInfoServiceImpl extends ServiceImpl<AitagTagInfoDao, AitagT
|
|
|
if (aitagTagInfoQueryVo.getTagRemark() != null) {
|
|
|
queryWrapper.eq(AitagTagInfoEntity::getTagRemark, aitagTagInfoQueryVo.getTagRemark());
|
|
|
}
|
|
|
- if (aitagTagInfoQueryVo.getparentId() != null) {
|
|
|
- queryWrapper.eq(AitagTagInfoEntity::getParentId, aitagTagInfoQueryVo.getparentId());
|
|
|
+ if (aitagTagInfoQueryVo.getParentId() != null) {
|
|
|
+ queryWrapper.eq(AitagTagInfoEntity::getParentId, aitagTagInfoQueryVo.getParentId());
|
|
|
}
|
|
|
if (aitagTagInfoQueryVo.getReg() != null) {
|
|
|
queryWrapper.eq(AitagTagInfoEntity::getReg, aitagTagInfoQueryVo.getReg());
|
|
|
}
|
|
|
- if (aitagTagInfoQueryVo.getLevel() != null) {
|
|
|
- queryWrapper.eq(AitagTagInfoEntity::getLevel, aitagTagInfoQueryVo.getLevel());
|
|
|
+ if (aitagTagInfoQueryVo.getTagLevel() != null) {
|
|
|
+ queryWrapper.eq(AitagTagInfoEntity::getTagLevel, aitagTagInfoQueryVo.getTagLevel());
|
|
|
}
|
|
|
if (aitagTagInfoQueryVo.getTagPath() != null) {
|
|
|
queryWrapper.eq(AitagTagInfoEntity::getTagPath, aitagTagInfoQueryVo.getTagPath());
|
|
|
@@ -120,7 +120,7 @@ public class AitagTagInfoServiceImpl extends ServiceImpl<AitagTagInfoDao, AitagT
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public void saveTag(AitagTagInfoEntity aitagTagInfo){
|
|
|
+ public String saveTag(AitagTagInfoEntity aitagTagInfo){
|
|
|
aitagTagInfo.setId(StringUtils.getUUID());
|
|
|
String parentId = aitagTagInfo.getParentId();
|
|
|
if(!StringUtils.isBlank(parentId)){
|
|
|
@@ -131,24 +131,22 @@ public class AitagTagInfoServiceImpl extends ServiceImpl<AitagTagInfoDao, AitagT
|
|
|
if(!aitagTagInfoEntities.isEmpty()){
|
|
|
AitagTagInfoEntity aitagTagInfoEntity = aitagTagInfoEntities.get(0);
|
|
|
aitagTagInfo.setTagPath(aitagTagInfoEntity.getTagPath()+"/"+aitagTagInfo.getTagNm());
|
|
|
- aitagTagInfo.setLevel(aitagTagInfoEntity.getLevel()+1);
|
|
|
+ aitagTagInfo.setTagLevel(aitagTagInfoEntity.getTagLevel()+1);
|
|
|
}else{
|
|
|
aitagTagInfo.setTagPath(aitagTagInfo.getTagNm());
|
|
|
- aitagTagInfo.setLevel(1);
|
|
|
+ aitagTagInfo.setTagLevel(1);
|
|
|
}
|
|
|
}else{
|
|
|
aitagTagInfo.setTagPath(aitagTagInfo.getTagNm());
|
|
|
- aitagTagInfo.setLevel(1);
|
|
|
+ aitagTagInfo.setTagLevel(1);
|
|
|
}
|
|
|
aitagTagInfo.setRevisionTime(DateUtils.getCurrDateTimeStr());
|
|
|
aitagTagInfo.setTagVersion("1");
|
|
|
aitagTagInfo.setIsDelete(TAG_UNDELETED);
|
|
|
aitagTagInfo.setState(TAG_ENABLED);
|
|
|
+ aitagTagInfo.setReviser(SessionCommonUtil.getUserInfo());
|
|
|
this.save(aitagTagInfo);
|
|
|
- HashMap<String, Object> body = new HashMap<>();
|
|
|
- String[] ids = {aitagTagInfo.getId()};
|
|
|
- body.put("tag_ids",ids);
|
|
|
- callAiTag(body,"/api/aitag/admin/v1/synchronize_tag");
|
|
|
+ return aitagTagInfo.getId();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -186,12 +184,11 @@ public class AitagTagInfoServiceImpl extends ServiceImpl<AitagTagInfoDao, AitagT
|
|
|
this.aitagTagInfoVersionDao.insert(aitagTagInfoVersionEntity);
|
|
|
aitagTagInfoEntity.setRevisionTime(DateUtils.getCurrDateTimeStr());
|
|
|
aitagTagInfoEntity.setTagVersion(Integer.parseInt(tagInfo.getTagVersion())+1+"");
|
|
|
+ AitagTagInfoEntity parentTagInfo = this.baseMapper.selectById(aitagTagInfoEntity.getParentId());
|
|
|
+ aitagTagInfoEntity.setTagPath(parentTagInfo.getTagPath()+"/"+aitagTagInfoEntity.getTagNm());
|
|
|
+ aitagTagInfoEntity.setTagLevel(parentTagInfo.getTagLevel()+1);
|
|
|
+ aitagTagInfoEntity.setReviser(SessionCommonUtil.getUserInfo());
|
|
|
this.baseMapper.updateById(aitagTagInfoEntity);
|
|
|
-
|
|
|
- HashMap<String, Object> body = new HashMap<>();
|
|
|
- String[] ids = {aitagTagInfoEntity.getId()};
|
|
|
- body.put("tag_ids",ids);
|
|
|
- callAiTag(body,"/api/aitag/admin/v1/synchronize_tag");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -201,16 +198,14 @@ public class AitagTagInfoServiceImpl extends ServiceImpl<AitagTagInfoDao, AitagT
|
|
|
for (String id:list){
|
|
|
aitagTagInfoEntity.setId(id);
|
|
|
aitagTagInfoEntity.setIsDelete(TAG_DELETED);
|
|
|
+ aitagTagInfoEntity.setReviser(SessionCommonUtil.getUserInfo());
|
|
|
this.baseMapper.updateById(aitagTagInfoEntity);
|
|
|
}
|
|
|
- HashMap<String, Object> body = new HashMap<>();
|
|
|
- body.put("tag_ids",list);
|
|
|
- callAiTag(body,"/api/aitag/admin/v1/delete_tag");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public void versionRollback(VersionRollbackVo versionRollback) {
|
|
|
+ public String versionRollback(VersionRollbackVo versionRollback) {
|
|
|
LambdaQueryWrapper<AitagTagInfoVersionEntity> queryTagVersionWrapper = new LambdaQueryWrapper<>();
|
|
|
queryTagVersionWrapper.eq(AitagTagInfoVersionEntity::getTagCode,versionRollback.getTagCode());
|
|
|
queryTagVersionWrapper.eq(AitagTagInfoVersionEntity::getTagVersion,versionRollback.getVersion());
|
|
|
@@ -221,19 +216,18 @@ public class AitagTagInfoServiceImpl extends ServiceImpl<AitagTagInfoDao, AitagT
|
|
|
aitagTagInfoEntity.setId(versionRollback.getId());
|
|
|
aitagTagInfoEntity.setRevisionTime(DateUtils.getCurrDateTimeStr());
|
|
|
aitagTagInfoEntity.setReviser(versionRollback.getReviser());
|
|
|
+ aitagTagInfoEntity.setReviser(SessionCommonUtil.getUserInfo());
|
|
|
this.baseMapper.updateById(aitagTagInfoEntity);
|
|
|
LambdaUpdateWrapper<AitagTagInfoVersionEntity> updateTagVersion = new LambdaUpdateWrapper<>();
|
|
|
updateTagVersion.eq(AitagTagInfoVersionEntity::getTagCode,versionRollback.getTagCode());
|
|
|
updateTagVersion.ge(AitagTagInfoVersionEntity::getTagVersion,versionRollback.getVersion());
|
|
|
AitagTagInfoVersionEntity aitagTagInfoVersionEntity = new AitagTagInfoVersionEntity();
|
|
|
+ aitagTagInfoVersionEntity.setReviser(SessionCommonUtil.getUserInfo());
|
|
|
aitagTagInfoVersionEntity.setIsDelete(TAG_DELETED);
|
|
|
this.aitagTagInfoVersionDao.update(aitagTagInfoVersionEntity,updateTagVersion);
|
|
|
-
|
|
|
- HashMap<String, Object> body = new HashMap<>();
|
|
|
- String[] ids = {aitagTagInfoEntity.getId()};
|
|
|
- body.put("tag_ids",ids);
|
|
|
- callAiTag(body,"/api/aitag/admin/v1/synchronize_tag");
|
|
|
+ return aitagTagInfoEntity.getId();
|
|
|
}
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -254,14 +248,14 @@ public class AitagTagInfoServiceImpl extends ServiceImpl<AitagTagInfoDao, AitagT
|
|
|
if (aitagTagInfoQueryVo.getTagRemark() != null) {
|
|
|
queryWrapper.eq(AitagTagInfoEntity::getTagRemark, aitagTagInfoQueryVo.getTagRemark());
|
|
|
}
|
|
|
- if (aitagTagInfoQueryVo.getparentId() != null) {
|
|
|
- queryWrapper.eq(AitagTagInfoEntity::getParentId, aitagTagInfoQueryVo.getparentId());
|
|
|
+ if (aitagTagInfoQueryVo.getParentId() != null) {
|
|
|
+ queryWrapper.eq(AitagTagInfoEntity::getParentId, aitagTagInfoQueryVo.getParentId());
|
|
|
}
|
|
|
if (aitagTagInfoQueryVo.getReg() != null) {
|
|
|
queryWrapper.eq(AitagTagInfoEntity::getReg, aitagTagInfoQueryVo.getReg());
|
|
|
}
|
|
|
- if (aitagTagInfoQueryVo.getLevel() != null) {
|
|
|
- queryWrapper.eq(AitagTagInfoEntity::getLevel, aitagTagInfoQueryVo.getLevel());
|
|
|
+ if (aitagTagInfoQueryVo.getTagLevel() != null) {
|
|
|
+ queryWrapper.eq(AitagTagInfoEntity::getTagLevel, aitagTagInfoQueryVo.getTagLevel());
|
|
|
}
|
|
|
if (aitagTagInfoQueryVo.getTagPath() != null) {
|
|
|
queryWrapper.eq(AitagTagInfoEntity::getTagPath, aitagTagInfoQueryVo.getTagPath());
|
|
|
@@ -280,7 +274,8 @@ public class AitagTagInfoServiceImpl extends ServiceImpl<AitagTagInfoDao, AitagT
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void batchImport(MultipartFile file, String reviser,String categoryId) throws IOException {
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public List<String> batchImport(MultipartFile file, String reviser, String categoryId) throws IOException {
|
|
|
log.info("开始处理上传文件:{}", file.getOriginalFilename());
|
|
|
|
|
|
TagImportListener listener = new TagImportListener();
|
|
|
@@ -304,23 +299,9 @@ public class AitagTagInfoServiceImpl extends ServiceImpl<AitagTagInfoDao, AitagT
|
|
|
validateParentTags(nameToDtoMap);
|
|
|
resolveHierarchy(nameToDtoMap);
|
|
|
saveToDatabase(tagImportDtos,reviser,categoryId);
|
|
|
-
|
|
|
- HashMap<String, Object> body = new HashMap<>();
|
|
|
- List<String> tagIds = tagImportDtos.stream().map(TagImportDto::getId).collect(Collectors.toList());
|
|
|
- body.put("tag_ids",tagIds);
|
|
|
- callAiTag(body,"/api/aitag/admin/v1/synchronize_tag");
|
|
|
+ return tagImportDtos.stream().map(TagImportDto::getId).collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public String generateRegex(GenerateRegexVo regexVo) {
|
|
|
- Map body = JSONObject.parseObject(JSONObject.toJSONString(regexVo), Map.class);
|
|
|
- AiTaggingResponseVo taggingResponse = callAiTag(body, "/api/aitag/admin/v1/generate_reg");
|
|
|
- if(StringUtils.equals(taggingResponse.getCode(),"200")){
|
|
|
- return taggingResponse.getBody();
|
|
|
- }
|
|
|
- log.error("生成正则表达式异常:返回参数为:{}",JSON.toJSONString(taggingResponse));
|
|
|
- throw BizException.of("E008");
|
|
|
- }
|
|
|
|
|
|
private void saveToDatabase(List<TagImportDto> tagImportDtos,String reviser,String categoryId) {
|
|
|
AitagTagCategory aitagTagCategory = aiTagCategoryMapper.selectById(categoryId);
|
|
|
@@ -330,12 +311,14 @@ public class AitagTagInfoServiceImpl extends ServiceImpl<AitagTagInfoDao, AitagT
|
|
|
AitagTagInfoEntity.class);
|
|
|
String tagPath = tagImportDto.getTagPath();
|
|
|
aitagTagInfo.setTagPath(categoryNm+"/"+tagPath);
|
|
|
- aitagTagInfo.setLevel(aitagTagInfo.getTagPath().split("/").length);
|
|
|
+ aitagTagInfo.setTagLevel(aitagTagInfo.getTagPath().split("/").length);
|
|
|
aitagTagInfo.setRevisionTime(DateUtils.getCurrDateTimeStr());
|
|
|
aitagTagInfo.setReviser(reviser);
|
|
|
aitagTagInfo.setTagVersion("1");
|
|
|
aitagTagInfo.setIsDelete(TAG_UNDELETED);
|
|
|
+ aitagTagInfo.setCategoryId(categoryId);
|
|
|
aitagTagInfo.setState(TAG_ENABLED);
|
|
|
+ aitagTagInfo.setReviser(SessionCommonUtil.getUserInfo());
|
|
|
this.save(aitagTagInfo);
|
|
|
}
|
|
|
|
|
|
@@ -428,7 +411,9 @@ public class AitagTagInfoServiceImpl extends ServiceImpl<AitagTagInfoDao, AitagT
|
|
|
return rootNodes;
|
|
|
}
|
|
|
|
|
|
- private AiTaggingResponseVo callAiTag(Map<String,Object> body, String path) {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public AiTaggingResponseVo callAiTag(Map<String, Object> body, String path) {
|
|
|
String url = fastApiConfig.getUrl() + path;
|
|
|
log.info("调用AI打标接口: {}", url);
|
|
|
|