|
@@ -123,6 +123,7 @@ public class AitagTagInfoServiceImpl extends ServiceImpl<AitagTagInfoDao, AitagT
|
|
|
public String saveTag(AitagTagInfoEntity aitagTagInfo){
|
|
public String saveTag(AitagTagInfoEntity aitagTagInfo){
|
|
|
aitagTagInfo.setId(StringUtils.getUUID());
|
|
aitagTagInfo.setId(StringUtils.getUUID());
|
|
|
String parentId = aitagTagInfo.getParentId();
|
|
String parentId = aitagTagInfo.getParentId();
|
|
|
|
|
+ checkTagCodeDuplicate(aitagTagInfo.getTagCode());
|
|
|
if(!StringUtils.isBlank(parentId)){
|
|
if(!StringUtils.isBlank(parentId)){
|
|
|
LambdaQueryWrapper<AitagTagInfoEntity> queryWrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<AitagTagInfoEntity> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
queryWrapper.eq(AitagTagInfoEntity::getParentId,parentId);
|
|
queryWrapper.eq(AitagTagInfoEntity::getParentId,parentId);
|
|
@@ -132,6 +133,9 @@ public class AitagTagInfoServiceImpl extends ServiceImpl<AitagTagInfoDao, AitagT
|
|
|
AitagTagInfoEntity aitagTagInfoEntity = aitagTagInfoEntities.get(0);
|
|
AitagTagInfoEntity aitagTagInfoEntity = aitagTagInfoEntities.get(0);
|
|
|
aitagTagInfo.setTagPath(aitagTagInfoEntity.getTagPath()+"/"+aitagTagInfo.getTagNm());
|
|
aitagTagInfo.setTagPath(aitagTagInfoEntity.getTagPath()+"/"+aitagTagInfo.getTagNm());
|
|
|
aitagTagInfo.setTagLevel(aitagTagInfoEntity.getTagLevel()+1);
|
|
aitagTagInfo.setTagLevel(aitagTagInfoEntity.getTagLevel()+1);
|
|
|
|
|
+ if(aitagTagInfoEntity.getTagLevel() > 4){
|
|
|
|
|
+ throw BizException.of("E017");
|
|
|
|
|
+ }
|
|
|
}else{
|
|
}else{
|
|
|
aitagTagInfo.setTagPath(aitagTagInfo.getTagNm());
|
|
aitagTagInfo.setTagPath(aitagTagInfo.getTagNm());
|
|
|
aitagTagInfo.setTagLevel(1);
|
|
aitagTagInfo.setTagLevel(1);
|
|
@@ -166,6 +170,7 @@ public class AitagTagInfoServiceImpl extends ServiceImpl<AitagTagInfoDao, AitagT
|
|
|
queryWrapper.like(AitagTagInfoEntity::getTagNm, aitagTagInfoQueryVo.getTagNm());
|
|
queryWrapper.like(AitagTagInfoEntity::getTagNm, aitagTagInfoQueryVo.getTagNm());
|
|
|
}
|
|
}
|
|
|
queryWrapper.eq(AitagTagInfoEntity::getIsDelete, TAG_UNDELETED);
|
|
queryWrapper.eq(AitagTagInfoEntity::getIsDelete, TAG_UNDELETED);
|
|
|
|
|
+ queryWrapper.orderByAsc(AitagTagInfoEntity::getRevisionTime);
|
|
|
List<AitagTagInfoEntity> aitagTagInfoEntities = this.baseMapper.selectList(queryWrapper);
|
|
List<AitagTagInfoEntity> aitagTagInfoEntities = this.baseMapper.selectList(queryWrapper);
|
|
|
return this.buildTree(aitagTagInfoEntities);
|
|
return this.buildTree(aitagTagInfoEntities);
|
|
|
}
|
|
}
|
|
@@ -178,15 +183,38 @@ public class AitagTagInfoServiceImpl extends ServiceImpl<AitagTagInfoDao, AitagT
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void updateTag(AitagTagInfoEntity aitagTagInfoEntity) {
|
|
public void updateTag(AitagTagInfoEntity aitagTagInfoEntity) {
|
|
|
- AitagTagInfoEntity tagInfo = this.baseMapper.selectById(aitagTagInfoEntity.getId());
|
|
|
|
|
- AitagTagInfoVersionEntity aitagTagInfoVersionEntity = JSON.parseObject(JSON.toJSONString(tagInfo), AitagTagInfoVersionEntity.class);
|
|
|
|
|
|
|
+ AitagTagInfoEntity oldTagInfo = this.baseMapper.selectById(aitagTagInfoEntity.getId());
|
|
|
|
|
+ if(oldTagInfo.valueEqualsValue(aitagTagInfoEntity)){
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ String newTagCode = aitagTagInfoEntity.getTagCode();
|
|
|
|
|
+ String oldTagCode = oldTagInfo.getTagCode();
|
|
|
|
|
+ if(!StringUtils.isEmpty(newTagCode) && !StringUtils.equals(oldTagCode,newTagCode)){
|
|
|
|
|
+ checkTagCodeDuplicate(newTagCode);
|
|
|
|
|
+ }
|
|
|
|
|
+ AitagTagInfoVersionEntity aitagTagInfoVersionEntity = JSON.parseObject(JSON.toJSONString(oldTagInfo), AitagTagInfoVersionEntity.class);
|
|
|
|
|
+ aitagTagInfoVersionEntity.setPrimaryVersionId(aitagTagInfoEntity.getId());
|
|
|
aitagTagInfoVersionEntity.setId(StringUtils.getUUID());
|
|
aitagTagInfoVersionEntity.setId(StringUtils.getUUID());
|
|
|
this.aitagTagInfoVersionDao.insert(aitagTagInfoVersionEntity);
|
|
this.aitagTagInfoVersionDao.insert(aitagTagInfoVersionEntity);
|
|
|
aitagTagInfoEntity.setRevisionTime(DateUtils.getCurrDateTimeStr());
|
|
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.setTagVersion(Integer.parseInt(oldTagInfo.getTagVersion())+1+"");
|
|
|
|
|
+ if(!StringUtils.isBlank(aitagTagInfoEntity.getParentId())){
|
|
|
|
|
+ AitagTagInfoEntity parentTagInfo = this.baseMapper.selectById(aitagTagInfoEntity.getParentId());
|
|
|
|
|
+ if(parentTagInfo !=null){
|
|
|
|
|
+ aitagTagInfoEntity.setTagPath(parentTagInfo.getTagPath()+"/"+aitagTagInfoEntity.getTagNm());
|
|
|
|
|
+ aitagTagInfoEntity.setTagLevel(parentTagInfo.getTagLevel()+1);
|
|
|
|
|
+ if(aitagTagInfoEntity.getTagLevel() > 4){
|
|
|
|
|
+ throw BizException.of("E017");
|
|
|
|
|
+ }
|
|
|
|
|
+ }else{
|
|
|
|
|
+ aitagTagInfoEntity.setTagPath(aitagTagInfoEntity.getTagNm());
|
|
|
|
|
+ aitagTagInfoEntity.setTagLevel(1);
|
|
|
|
|
+ }
|
|
|
|
|
+ }else{
|
|
|
|
|
+ aitagTagInfoEntity.setTagPath(aitagTagInfoEntity.getTagNm());
|
|
|
|
|
+ aitagTagInfoEntity.setTagLevel(1);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
aitagTagInfoEntity.setReviser(SessionCommonUtil.getUserInfo());
|
|
aitagTagInfoEntity.setReviser(SessionCommonUtil.getUserInfo());
|
|
|
this.baseMapper.updateById(aitagTagInfoEntity);
|
|
this.baseMapper.updateById(aitagTagInfoEntity);
|
|
|
}
|
|
}
|
|
@@ -196,6 +224,12 @@ public class AitagTagInfoServiceImpl extends ServiceImpl<AitagTagInfoDao, AitagT
|
|
|
public void removeTags(List<String> list) {
|
|
public void removeTags(List<String> list) {
|
|
|
AitagTagInfoEntity aitagTagInfoEntity = new AitagTagInfoEntity();
|
|
AitagTagInfoEntity aitagTagInfoEntity = new AitagTagInfoEntity();
|
|
|
for (String id:list){
|
|
for (String id:list){
|
|
|
|
|
+ LambdaQueryWrapper<AitagTagInfoEntity> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ queryWrapper.eq(AitagTagInfoEntity::getParentId,id);
|
|
|
|
|
+ queryWrapper.eq(AitagTagInfoEntity::getIsDelete,NON_DELETE);
|
|
|
|
|
+ if(this.baseMapper.selectCount(queryWrapper)>0){
|
|
|
|
|
+ throw BizException.of("E011");
|
|
|
|
|
+ }
|
|
|
aitagTagInfoEntity.setId(id);
|
|
aitagTagInfoEntity.setId(id);
|
|
|
aitagTagInfoEntity.setIsDelete(TAG_DELETED);
|
|
aitagTagInfoEntity.setIsDelete(TAG_DELETED);
|
|
|
aitagTagInfoEntity.setReviser(SessionCommonUtil.getUserInfo());
|
|
aitagTagInfoEntity.setReviser(SessionCommonUtil.getUserInfo());
|
|
@@ -207,7 +241,7 @@ public class AitagTagInfoServiceImpl extends ServiceImpl<AitagTagInfoDao, AitagT
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public String versionRollback(VersionRollbackVo versionRollback) {
|
|
public String versionRollback(VersionRollbackVo versionRollback) {
|
|
|
LambdaQueryWrapper<AitagTagInfoVersionEntity> queryTagVersionWrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<AitagTagInfoVersionEntity> queryTagVersionWrapper = new LambdaQueryWrapper<>();
|
|
|
- queryTagVersionWrapper.eq(AitagTagInfoVersionEntity::getTagCode,versionRollback.getTagCode());
|
|
|
|
|
|
|
+ queryTagVersionWrapper.eq(AitagTagInfoVersionEntity::getPrimaryVersionId,versionRollback.getId());
|
|
|
queryTagVersionWrapper.eq(AitagTagInfoVersionEntity::getTagVersion,versionRollback.getVersion());
|
|
queryTagVersionWrapper.eq(AitagTagInfoVersionEntity::getTagVersion,versionRollback.getVersion());
|
|
|
List<AitagTagInfoVersionEntity> versionEntities = this.aitagTagInfoVersionDao.selectList(queryTagVersionWrapper);
|
|
List<AitagTagInfoVersionEntity> versionEntities = this.aitagTagInfoVersionDao.selectList(queryTagVersionWrapper);
|
|
|
if(versionEntities !=null && !versionEntities.isEmpty()){
|
|
if(versionEntities !=null && !versionEntities.isEmpty()){
|
|
@@ -219,7 +253,7 @@ public class AitagTagInfoServiceImpl extends ServiceImpl<AitagTagInfoDao, AitagT
|
|
|
aitagTagInfoEntity.setReviser(SessionCommonUtil.getUserInfo());
|
|
aitagTagInfoEntity.setReviser(SessionCommonUtil.getUserInfo());
|
|
|
this.baseMapper.updateById(aitagTagInfoEntity);
|
|
this.baseMapper.updateById(aitagTagInfoEntity);
|
|
|
LambdaUpdateWrapper<AitagTagInfoVersionEntity> updateTagVersion = new LambdaUpdateWrapper<>();
|
|
LambdaUpdateWrapper<AitagTagInfoVersionEntity> updateTagVersion = new LambdaUpdateWrapper<>();
|
|
|
- updateTagVersion.eq(AitagTagInfoVersionEntity::getTagCode,versionRollback.getTagCode());
|
|
|
|
|
|
|
+ updateTagVersion.eq(AitagTagInfoVersionEntity::getPrimaryVersionId,versionRollback.getId());
|
|
|
updateTagVersion.ge(AitagTagInfoVersionEntity::getTagVersion,versionRollback.getVersion());
|
|
updateTagVersion.ge(AitagTagInfoVersionEntity::getTagVersion,versionRollback.getVersion());
|
|
|
AitagTagInfoVersionEntity aitagTagInfoVersionEntity = new AitagTagInfoVersionEntity();
|
|
AitagTagInfoVersionEntity aitagTagInfoVersionEntity = new AitagTagInfoVersionEntity();
|
|
|
aitagTagInfoVersionEntity.setReviser(SessionCommonUtil.getUserInfo());
|
|
aitagTagInfoVersionEntity.setReviser(SessionCommonUtil.getUserInfo());
|
|
@@ -269,19 +303,20 @@ public class AitagTagInfoServiceImpl extends ServiceImpl<AitagTagInfoDao, AitagT
|
|
|
if (aitagTagInfoQueryVo.getTagPrompt() != null) {
|
|
if (aitagTagInfoQueryVo.getTagPrompt() != null) {
|
|
|
queryWrapper.eq(AitagTagInfoEntity::getTagPrompt, aitagTagInfoQueryVo.getTagPrompt());
|
|
queryWrapper.eq(AitagTagInfoEntity::getTagPrompt, aitagTagInfoQueryVo.getTagPrompt());
|
|
|
}
|
|
}
|
|
|
|
|
+ queryWrapper.eq(AitagTagInfoEntity::getIsDelete,NON_DELETE);
|
|
|
queryWrapper.select(AitagTagInfoEntity::getId,AitagTagInfoEntity::getTagNm,AitagTagInfoEntity::getParentId);
|
|
queryWrapper.select(AitagTagInfoEntity::getId,AitagTagInfoEntity::getTagNm,AitagTagInfoEntity::getParentId);
|
|
|
return this.baseMapper.selectList(queryWrapper);
|
|
return this.baseMapper.selectList(queryWrapper);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public List<String> batchImport(MultipartFile file, String reviser, String categoryId) throws IOException {
|
|
|
|
|
|
|
+ public List<String> batchImport(MultipartFile file, String categoryId) throws IOException {
|
|
|
log.info("开始处理上传文件:{}", file.getOriginalFilename());
|
|
log.info("开始处理上传文件:{}", file.getOriginalFilename());
|
|
|
|
|
|
|
|
TagImportListener listener = new TagImportListener();
|
|
TagImportListener listener = new TagImportListener();
|
|
|
EasyExcel.read(file.getInputStream(), TagImportDto.class, listener)
|
|
EasyExcel.read(file.getInputStream(), TagImportDto.class, listener)
|
|
|
.headRowNumber(1)
|
|
.headRowNumber(1)
|
|
|
- .sheet(1)
|
|
|
|
|
|
|
+ .sheet(0)
|
|
|
.doRead();
|
|
.doRead();
|
|
|
List<TagImportDto> tagImportDtos = listener.getDataList();
|
|
List<TagImportDto> tagImportDtos = listener.getDataList();
|
|
|
if (tagImportDtos.isEmpty()) {
|
|
if (tagImportDtos.isEmpty()) {
|
|
@@ -298,22 +333,29 @@ public class AitagTagInfoServiceImpl extends ServiceImpl<AitagTagInfoDao, AitagT
|
|
|
|
|
|
|
|
validateParentTags(nameToDtoMap);
|
|
validateParentTags(nameToDtoMap);
|
|
|
resolveHierarchy(nameToDtoMap);
|
|
resolveHierarchy(nameToDtoMap);
|
|
|
- saveToDatabase(tagImportDtos,reviser,categoryId);
|
|
|
|
|
|
|
+ saveToDatabase(tagImportDtos,categoryId);
|
|
|
return tagImportDtos.stream().map(TagImportDto::getId).collect(Collectors.toList());
|
|
return tagImportDtos.stream().map(TagImportDto::getId).collect(Collectors.toList());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
- private void saveToDatabase(List<TagImportDto> tagImportDtos,String reviser,String categoryId) {
|
|
|
|
|
|
|
+ private void saveToDatabase(List<TagImportDto> tagImportDtos,String categoryId) {
|
|
|
AitagTagCategory aitagTagCategory = aiTagCategoryMapper.selectById(categoryId);
|
|
AitagTagCategory aitagTagCategory = aiTagCategoryMapper.selectById(categoryId);
|
|
|
- String categoryNm = aitagTagCategory.getCategoryNm();
|
|
|
|
|
|
|
+ if(aitagTagCategory == null && aitagTagCategory.getIsDelete().intValue() != NON_DELETE){
|
|
|
|
|
+ throw BizException.of("E018");
|
|
|
|
|
+ }
|
|
|
for (TagImportDto tagImportDto: tagImportDtos){
|
|
for (TagImportDto tagImportDto: tagImportDtos){
|
|
|
|
|
+
|
|
|
|
|
+ checkTagCodeDuplicate(tagImportDto.getTagCode());
|
|
|
AitagTagInfoEntity aitagTagInfo = JSONObject.parseObject(JSONObject.toJSONString(tagImportDto),
|
|
AitagTagInfoEntity aitagTagInfo = JSONObject.parseObject(JSONObject.toJSONString(tagImportDto),
|
|
|
AitagTagInfoEntity.class);
|
|
AitagTagInfoEntity.class);
|
|
|
String tagPath = tagImportDto.getTagPath();
|
|
String tagPath = tagImportDto.getTagPath();
|
|
|
- aitagTagInfo.setTagPath(categoryNm+"/"+tagPath);
|
|
|
|
|
|
|
+ aitagTagInfo.setTagPath(tagPath);
|
|
|
aitagTagInfo.setTagLevel(aitagTagInfo.getTagPath().split("/").length);
|
|
aitagTagInfo.setTagLevel(aitagTagInfo.getTagPath().split("/").length);
|
|
|
|
|
+ if(aitagTagInfo.getTagLevel() > 4){
|
|
|
|
|
+ throw BizException.of("E017");
|
|
|
|
|
+ }
|
|
|
aitagTagInfo.setRevisionTime(DateUtils.getCurrDateTimeStr());
|
|
aitagTagInfo.setRevisionTime(DateUtils.getCurrDateTimeStr());
|
|
|
- aitagTagInfo.setReviser(reviser);
|
|
|
|
|
|
|
+ aitagTagInfo.setReviser(SessionCommonUtil.getUserInfo());
|
|
|
aitagTagInfo.setTagVersion("1");
|
|
aitagTagInfo.setTagVersion("1");
|
|
|
aitagTagInfo.setIsDelete(TAG_UNDELETED);
|
|
aitagTagInfo.setIsDelete(TAG_UNDELETED);
|
|
|
aitagTagInfo.setCategoryId(categoryId);
|
|
aitagTagInfo.setCategoryId(categoryId);
|
|
@@ -324,6 +366,15 @@ public class AitagTagInfoServiceImpl extends ServiceImpl<AitagTagInfoDao, AitagT
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private void checkTagCodeDuplicate(String tagCode) {
|
|
|
|
|
+ LambdaQueryWrapper<AitagTagInfoEntity> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ queryWrapper.eq(AitagTagInfoEntity::getTagCode, tagCode);
|
|
|
|
|
+ queryWrapper.eq(AitagTagInfoEntity::getIsDelete,TAG_UNDELETED);
|
|
|
|
|
+ if (this.baseMapper.selectCount(queryWrapper) > 0) {
|
|
|
|
|
+ throw BizException.of("E010");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 校验父标签存在性并将赋值parentId
|
|
* 校验父标签存在性并将赋值parentId
|
|
|
* @param nameToDtoMap
|
|
* @param nameToDtoMap
|