画像库树图修改

This commit is contained in:
zhangheng 2024-06-27 14:47:11 +08:00
parent 6061b870b1
commit bc519951f0
7 changed files with 175 additions and 27 deletions

View File

@ -9,6 +9,8 @@ import com.xinelu.common.utils.poi.ExcelUtil;
import com.xinelu.manage.domain.labelfieldinfo.LabelFieldInfo;
import com.xinelu.manage.dto.labelfieldinfo.LabelFieldInfoAddDTO;
import com.xinelu.manage.service.labelfieldinfo.ILabelFieldInfoService;
import com.xinelu.manage.vo.labelfieldinfo.LabelFieldTreeVO;
import com.xinelu.manage.vo.labelfieldinfo.LabelFieldVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
@ -55,8 +57,8 @@ public class LabelFieldInfoController extends BaseController {
* 查询标签字段信息列表树图
*/
@GetMapping("/labelFieldList")
public AjaxResult labelFieldList(String fieldType) {
return AjaxResult.success(labelFieldInfoService.labelFieldList(fieldType));
public List<LabelFieldTreeVO> labelFieldList(String fieldType) {
return labelFieldInfoService.labelFieldList(fieldType);
}
/**

View File

@ -95,4 +95,12 @@ public interface LabelFieldInfoMapper {
* @return GroupingValue
*/
List<GroupingValue> selectLabelFieldInfoByTaskPartitionDictId(Long taskPartitionDictId);
/**
* 查询标签
*
* @param taskPartitionDictIds 标签
* @return GroupingValue
*/
List<LabelFieldVO> selectLabelFieldNameByTaskPartitionDictIds(@Param("taskPartitionDictIds") List<Long> taskPartitionDictIds);
}

View File

@ -3,6 +3,8 @@ package com.xinelu.manage.service.labelfieldinfo;
import com.xinelu.common.core.domain.AjaxResult;
import com.xinelu.manage.domain.labelfieldinfo.LabelFieldInfo;
import com.xinelu.manage.dto.labelfieldinfo.LabelFieldInfoAddDTO;
import com.xinelu.manage.vo.labelfieldinfo.LabelFieldTreeVO;
import com.xinelu.manage.vo.labelfieldinfo.LabelFieldVO;
import java.util.List;
@ -35,7 +37,7 @@ public interface ILabelFieldInfoService {
* @param fieldType 字段类型
* @return AjaxResult
*/
AjaxResult labelFieldList(String fieldType);
List<LabelFieldTreeVO> labelFieldList(String fieldType);
/**
* 新增标签字段信息

View File

@ -1,6 +1,5 @@
package com.xinelu.manage.service.labelfieldinfo.impl;
import com.xinelu.common.core.domain.AjaxResult;
import com.xinelu.common.exception.ServiceException;
import com.xinelu.common.utils.SecurityUtils;
import com.xinelu.manage.domain.labelfieldinfo.LabelFieldInfo;
@ -8,15 +7,17 @@ import com.xinelu.manage.dto.labelfieldinfo.LabelFieldInfoAddDTO;
import com.xinelu.manage.mapper.labelfieldcontent.LabelFieldContentMapper;
import com.xinelu.manage.mapper.labelfieldinfo.LabelFieldInfoMapper;
import com.xinelu.manage.service.labelfieldinfo.ILabelFieldInfoService;
import com.xinelu.manage.vo.labelfieldcontent.LabelFieldContentVO;
import com.xinelu.manage.vo.labelfieldinfo.LabelFieldTreeVO;
import com.xinelu.manage.vo.labelfieldinfo.LabelFieldVO;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
@ -64,18 +65,31 @@ public class LabelFieldInfoServiceImpl implements ILabelFieldInfoService {
* @return AjaxResult
*/
@Override
public AjaxResult labelFieldList(String fieldType) {
public List<LabelFieldTreeVO> labelFieldList(String fieldType) {
int i = 1;
List<LabelFieldVO> labelFieldList = labelFieldInfoMapper.selectLabelFieldList(fieldType);
List<Long> labelFieldIds = labelFieldList.stream().filter(Objects::nonNull).map(LabelFieldVO::getLabelFieldId).filter(Objects::nonNull).collect(Collectors.toList());
if (labelFieldIds.size() == 0) {
return AjaxResult.success(labelFieldList);
List<Long> taskPartitionDictIds = labelFieldList.stream().filter(Objects::nonNull).map(LabelFieldVO::getTaskPartitionDictId).filter(Objects::nonNull).distinct().collect(Collectors.toList());
if (taskPartitionDictIds.size() == 0) {
return new ArrayList<>();
}
List<LabelFieldContentVO> labelFieldContentList = labelFieldContentMapper.selectLabelFieldContent(labelFieldIds);
for (LabelFieldVO labelField : labelFieldList) {
List<LabelFieldContentVO> collect = labelFieldContentList.stream().filter(Objects::nonNull).filter(item -> Objects.nonNull(item.getFieldId()) && labelField.getLabelFieldId().equals(item.getFieldId())).collect(Collectors.toList());
labelField.setLabelFieldContentList(collect);
List<LabelFieldVO> collect = labelFieldList.stream().filter(Objects::nonNull).collect(Collectors.toList());
List<LabelFieldVO> labelFieldInfoList = labelFieldInfoMapper.selectLabelFieldNameByTaskPartitionDictIds(taskPartitionDictIds);
List<LabelFieldVO> labelFieldVOS = new ArrayList<>();
labelFieldVOS.addAll(collect);
labelFieldVOS.addAll(labelFieldInfoList);
for (LabelFieldVO labelFieldVO : labelFieldVOS) {
labelFieldVO.setCode(i);
i++;
}
return AjaxResult.success(labelFieldList);
for (LabelFieldVO labelField : collect) {
if (Objects.nonNull(labelField.getTaskPartitionDictId()) && StringUtils.isNotBlank(labelField.getTaskPartitionDictName()) && StringUtils.isNotBlank(labelField.getLabel())) {
List<LabelFieldVO> collectLabelFieldInfoList = labelFieldInfoList.stream().filter(Objects::nonNull).filter(item -> Objects.nonNull(item.getTaskPartitionDictId()) && labelField.getTaskPartitionDictId().equals(item.getTaskPartitionDictId())).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(collectLabelFieldInfoList)) {
labelField.setLabelFieldList(collectLabelFieldInfoList);
}
}
}
return collect.stream().map(LabelFieldTreeVO::new).collect(Collectors.toList());
}
/**

View File

@ -0,0 +1,88 @@
package com.xinelu.manage.vo.labelfieldinfo;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;
/**
* 画像树图信息对象vo
*
* @author xinelu
* @date 2024-06-27
*/
@Data
public class LabelFieldTreeVO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 节点ID
*/
private Long id;
/**
* 节点名称
*/
private String label;
/**
* 节点层级
*/
private Integer value;
private String termCode;
/**
* 子节点
*/
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private List<LabelFieldTreeVO> children;
public LabelFieldTreeVO() {
}
public LabelFieldTreeVO(LabelFieldVO labelField) {
this.id = labelField.getId();
this.label = labelField.getLabel();
this.termCode = labelField.getFieldCode();
this.value = labelField.getCode();
this.children = labelField.getLabelFieldList().stream().map(LabelFieldTreeVO::new).collect(Collectors.toList());
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getTermCode() {
return termCode;
}
public void setTermCode(String termCode) {
this.termCode = termCode;
}
public Integer getValue() {
return value;
}
public void setValue(Integer value) {
this.value = value;
}
public List<LabelFieldTreeVO> getChildren() {
return children;
}
public void setChildren(List<LabelFieldTreeVO> children) {
this.children = children;
}
}

View File

@ -1,10 +1,10 @@
package com.xinelu.manage.vo.labelfieldinfo;
import com.xinelu.manage.domain.labelfieldinfo.LabelFieldInfo;
import com.xinelu.manage.vo.labelfieldcontent.LabelFieldContentVO;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.ArrayList;
import java.util.List;
/**
@ -22,8 +22,17 @@ public class LabelFieldVO extends LabelFieldInfo {
*/
private Long LabelFieldId;
/**
* 标签内容
*/
private List<LabelFieldContentVO> labelFieldContentList;
private String label;
private Integer code;
private List<LabelFieldVO> labelFieldList = new ArrayList<LabelFieldVO>();
public List<LabelFieldVO> getChildren() {
return labelFieldList;
}
public void setChildren(List<LabelFieldVO> children) {
this.labelFieldList = children;
}
}

View File

@ -61,14 +61,20 @@
<select id="selectLabelFieldList" resultType="com.xinelu.manage.vo.labelfieldinfo.LabelFieldVO">
select id LabelFieldId,
field_name,
field_code,
field_type,
field_sort,
field_remark
from label_field_info
where field_type = #{fieldType}
select
lfi.task_partition_dict_id id,
lfi.task_partition_dict_id,
lfi.task_partition_dict_name,
lfi.task_partition_dict_name label
from label_field_info lfi
LEFT JOIN task_partition_dict tpd ON tpd.id = lfi.task_partition_dict_id
<where>
<if test="fieldType != null and fieldType != ''">
lfi.field_type = #{fieldType}
</if>
</where>
group by task_partition_dict_id
order by tpd.task_partition_sort
</select>
<select id="selectLabelFieldInfoById" parameterType="Long"
@ -248,4 +254,23 @@
</if>
</where>
</select>
<select id="selectLabelFieldNameByTaskPartitionDictIds"
resultType="com.xinelu.manage.vo.labelfieldinfo.LabelFieldVO">
select id,
field_name label,
field_code,
task_partition_dict_id,
task_partition_dict_name
from label_field_info
<where>
<if test="taskPartitionDictIds != null and taskPartitionDictIds.size() > 0">
task_partition_dict_id in
<foreach item="taskPartitionDictIds" collection="taskPartitionDictIds" open="(" separator="," close=")">
#{taskPartitionDictIds}
</foreach>
</if>
</where>
order by field_sort
</select>
</mapper>