增加配置属性
This commit is contained in:
parent
fda3089c7e
commit
954da9f9b7
|
|
@ -1,4 +1,4 @@
|
||||||
package com.bonus.material.ma.vo;
|
package com.bonus.common.biz.domain;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
@ -14,4 +14,8 @@ public class MaTypeProperty {
|
||||||
@ApiModelProperty(value = "属性名称")
|
@ApiModelProperty(value = "属性名称")
|
||||||
private String propertyName;
|
private String propertyName;
|
||||||
|
|
||||||
|
/** 是否必填(0:否, 1:是) */
|
||||||
|
@ApiModelProperty(value = "是否必填(0:否, 1:是)")
|
||||||
|
private String mustHave;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -66,7 +66,7 @@ public class TreeBuild {
|
||||||
// 判断当前节点的父节点ID是否等于根节点的ID,即当前节点为其下的子节点
|
// 判断当前节点的父节点ID是否等于根节点的ID,即当前节点为其下的子节点
|
||||||
if (treeNode.getParentId() == pNode.getId()) {
|
if (treeNode.getParentId() == pNode.getId()) {
|
||||||
if (!"1".equals(pNode.getLevel())) {
|
if (!"1".equals(pNode.getLevel())) {
|
||||||
treeNode.setPropertyNames(pNode.getPropertyNames());
|
treeNode.setMaTypeProperties(pNode.getMaTypeProperties());
|
||||||
}
|
}
|
||||||
// 再递归进行判断当前节点的情况,调用自身方法
|
// 再递归进行判断当前节点的情况,调用自身方法
|
||||||
childTree.add(buildChildTree(treeNode));
|
childTree.add(buildChildTree(treeNode));
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ public class TreeNode {
|
||||||
|
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
private List<String> propertyNames;
|
private List<MaTypeProperty> maTypeProperties;
|
||||||
|
|
||||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||||
private List<TreeNode> children = new ArrayList<>();
|
private List<TreeNode> children = new ArrayList<>();
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,12 @@
|
||||||
package com.bonus.material.device.domain.vo;
|
package com.bonus.material.device.domain.vo;
|
||||||
|
|
||||||
import com.bonus.material.device.domain.DevInfo;
|
import com.bonus.material.device.domain.DevInfo;
|
||||||
import com.bonus.material.ma.vo.MaTypeProperty;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ import com.bonus.material.device.domain.dto.InfoMotionDto;
|
||||||
import com.bonus.material.device.domain.vo.DevInfoPropertyVo;
|
import com.bonus.material.device.domain.vo.DevInfoPropertyVo;
|
||||||
import com.bonus.material.device.domain.vo.DevInfoVo;
|
import com.bonus.material.device.domain.vo.DevInfoVo;
|
||||||
import com.bonus.material.device.domain.vo.LeaseVo;
|
import com.bonus.material.device.domain.vo.LeaseVo;
|
||||||
import com.bonus.material.ma.vo.MaTypeProperty;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,7 @@ import com.bonus.material.device.domain.vo.DevInfoVo;
|
||||||
import com.bonus.material.home.mapper.MaTypeInfoMapper;
|
import com.bonus.material.home.mapper.MaTypeInfoMapper;
|
||||||
import com.bonus.material.home.service.MaTypeInfoSevice;
|
import com.bonus.material.home.service.MaTypeInfoSevice;
|
||||||
import com.bonus.material.ma.mapper.MaTypeMapper;
|
import com.bonus.material.ma.mapper.MaTypeMapper;
|
||||||
import com.bonus.material.ma.vo.MaType;
|
import com.bonus.common.biz.domain.MaTypeProperty;
|
||||||
import com.bonus.material.ma.vo.MaTypeProperty;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
@ -63,10 +62,7 @@ public class MaTypeInfoServiceImpl implements MaTypeInfoSevice {
|
||||||
maTypePropertiesMap = maTypeProperties.stream().collect(Collectors.groupingBy(MaTypeProperty::getTypeId));
|
maTypePropertiesMap = maTypeProperties.stream().collect(Collectors.groupingBy(MaTypeProperty::getTypeId));
|
||||||
}
|
}
|
||||||
for (TreeNode treeNode : treeNodes) {
|
for (TreeNode treeNode : treeNodes) {
|
||||||
List<MaTypeProperty> tmpPropList = maTypePropertiesMap.get(treeNode.getId());
|
treeNode.setMaTypeProperties(maTypePropertiesMap.get(treeNode.getId()));
|
||||||
if (!org.springframework.util.CollectionUtils.isEmpty(tmpPropList)) {
|
|
||||||
treeNode.setPropertyNames(tmpPropList.stream().map(o -> o.getPropertyName()).collect(Collectors.toList()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.bonus.material.ma.mapper;
|
package com.bonus.material.ma.mapper;
|
||||||
|
|
||||||
|
import com.bonus.common.biz.domain.MaTypeProperty;
|
||||||
import com.bonus.material.ma.vo.*;
|
import com.bonus.material.ma.vo.*;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
@ -92,5 +93,5 @@ public interface MaTypeMapper {
|
||||||
|
|
||||||
int deleteMaTypePropertyNames(@Param("typeId")Long typeId);
|
int deleteMaTypePropertyNames(@Param("typeId")Long typeId);
|
||||||
|
|
||||||
int insertMaTypePropertyNames(@Param("typeId")Long typeId, @Param("list") List<String> propertyNames);
|
int insertMaTypePropertyNames(@Param("typeId")Long typeId, @Param("list") List<MaTypeProperty> properties);
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.bonus.material.ma.service.impl;
|
package com.bonus.material.ma.service.impl;
|
||||||
|
|
||||||
|
import com.bonus.common.biz.domain.MaTypeProperty;
|
||||||
import com.bonus.common.core.utils.DateUtils;
|
import com.bonus.common.core.utils.DateUtils;
|
||||||
import com.bonus.common.core.utils.StringUtils;
|
import com.bonus.common.core.utils.StringUtils;
|
||||||
import com.bonus.material.ma.mapper.MaTypeFileMapper;
|
import com.bonus.material.ma.mapper.MaTypeFileMapper;
|
||||||
|
|
@ -131,10 +132,10 @@ public class MaTypeServiceImpl implements ITypeService {
|
||||||
maType.setUpdateTime(DateUtils.getNowDate());
|
maType.setUpdateTime(DateUtils.getNowDate());
|
||||||
int i = maTypeMapper.updateType(maType);
|
int i = maTypeMapper.updateType(maType);
|
||||||
//保存配置属性
|
//保存配置属性
|
||||||
if (!CollectionUtils.isEmpty(maType.getPropertyNames())) {
|
if (!CollectionUtils.isEmpty(maType.getMaTypeProperties())) {
|
||||||
maTypeMapper.deleteMaTypePropertyNames(maType.getTypeId());
|
maTypeMapper.deleteMaTypePropertyNames(maType.getTypeId());
|
||||||
List<String> maTypeProperties = maType.getPropertyNames();
|
List<MaTypeProperty> maTypeProperties = maType.getMaTypeProperties();
|
||||||
maTypeProperties.removeIf(String::isEmpty);
|
//maTypeProperties.removeIf(MaTypeProperty::isNull);
|
||||||
maTypeMapper.insertMaTypePropertyNames(maType.getTypeId(), maTypeProperties);
|
maTypeMapper.insertMaTypePropertyNames(maType.getTypeId(), maTypeProperties);
|
||||||
}
|
}
|
||||||
// 图片路径保存
|
// 图片路径保存
|
||||||
|
|
@ -225,10 +226,7 @@ public class MaTypeServiceImpl implements ITypeService {
|
||||||
maTypePropertiesMap = maTypeProperties.stream().collect(Collectors.groupingBy(MaTypeProperty::getTypeId));
|
maTypePropertiesMap = maTypeProperties.stream().collect(Collectors.groupingBy(MaTypeProperty::getTypeId));
|
||||||
}
|
}
|
||||||
for (MaType maType : maTypes) {
|
for (MaType maType : maTypes) {
|
||||||
List<MaTypeProperty> tmpPropList = maTypePropertiesMap.get(maType.getTypeId());
|
maType.setMaTypeProperties(maTypePropertiesMap.get(maType.getTypeId()));
|
||||||
if (!CollectionUtils.isEmpty(tmpPropList)) {
|
|
||||||
maType.setPropertyNames(tmpPropList.stream().map(o -> o.getPropertyName()).collect(Collectors.toList()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.bonus.material.ma.vo;
|
package com.bonus.material.ma.vo;
|
||||||
|
|
||||||
|
import com.bonus.common.biz.domain.MaTypeProperty;
|
||||||
import com.bonus.common.core.annotation.Excel;
|
import com.bonus.common.core.annotation.Excel;
|
||||||
import com.bonus.common.core.web.domain.BaseEntity;
|
import com.bonus.common.core.web.domain.BaseEntity;
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
|
@ -217,5 +218,5 @@ public class MaType extends BaseEntity {
|
||||||
|
|
||||||
private List<Integer> typeIds;
|
private List<Integer> typeIds;
|
||||||
|
|
||||||
private List<String> propertyNames;
|
private List<MaTypeProperty> maTypeProperties;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.bonus.material.ma.vo;
|
package com.bonus.material.ma.vo;
|
||||||
|
|
||||||
|
import com.bonus.common.biz.domain.MaTypeProperty;
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
@ -27,7 +28,7 @@ public class TreeSelect implements Serializable
|
||||||
|
|
||||||
private String companyId;
|
private String companyId;
|
||||||
|
|
||||||
private List<String> propertyNames;
|
private List<MaTypeProperty> maTypeProperties;
|
||||||
|
|
||||||
/** 子节点 */
|
/** 子节点 */
|
||||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||||
|
|
@ -53,7 +54,7 @@ public class TreeSelect implements Serializable
|
||||||
this.id = maType.getTypeId();
|
this.id = maType.getTypeId();
|
||||||
this.label = maType.getTypeName();
|
this.label = maType.getTypeName();
|
||||||
this.companyId = maType.getCompanyId();
|
this.companyId = maType.getCompanyId();
|
||||||
this.propertyNames = maType.getPropertyNames();
|
this.maTypeProperties = maType.getMaTypeProperties();
|
||||||
this.children = maType.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
|
this.children = maType.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
// public TreeSelect(SysDept dept)
|
// public TreeSelect(SysDept dept)
|
||||||
|
|
@ -109,12 +110,12 @@ public class TreeSelect implements Serializable
|
||||||
this.companyId = companyId;
|
this.companyId = companyId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getPropertyNames() {
|
public List<MaTypeProperty> getMaTypeProperties() {
|
||||||
return propertyNames;
|
return maTypeProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPropertyNames(List<String> propertyNames) {
|
public void setMaTypeProperties(List<MaTypeProperty> maTypeProperties) {
|
||||||
this.propertyNames = propertyNames;
|
this.maTypeProperties = maTypeProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TreeSelect> getChildren()
|
public List<TreeSelect> getChildren()
|
||||||
|
|
|
||||||
|
|
@ -455,9 +455,10 @@
|
||||||
and del_flag = 0
|
and del_flag = 0
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<select id="selectMaTypePropertyNames" resultType="com.bonus.material.ma.vo.MaTypeProperty">
|
<select id="selectMaTypePropertyNames" resultType="com.bonus.common.biz.domain.MaTypeProperty">
|
||||||
select type_id as typeId,
|
select type_id as typeId,
|
||||||
property_name as propertyName
|
property_name as propertyName,
|
||||||
|
must_have as mustHave
|
||||||
from ma_type_properties
|
from ma_type_properties
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
@ -467,12 +468,13 @@
|
||||||
|
|
||||||
<insert id="insertMaTypePropertyNames">
|
<insert id="insertMaTypePropertyNames">
|
||||||
insert into
|
insert into
|
||||||
ma_type_properties(type_id, property_name, create_time)
|
ma_type_properties(type_id, property_name, must_have, create_time)
|
||||||
values
|
values
|
||||||
<foreach collection="list" item="item" index="index" separator=",">
|
<foreach collection="list" item="item" index="index" separator=",">
|
||||||
(
|
(
|
||||||
#{typeId},
|
#{typeId},
|
||||||
#{item},
|
#{item.propertyName},
|
||||||
|
#{item.mustHave},
|
||||||
now()
|
now()
|
||||||
)
|
)
|
||||||
</foreach>
|
</foreach>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue