|
|
@ -14,6 +14,9 @@ import java.util.concurrent.TimeUnit;
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
|
|
|
import com.bocloud.ams.service.internal.CmpInternalService;
|
|
|
|
|
|
|
|
import com.megatron.common.utils.MapTools;
|
|
|
|
import org.apache.commons.beanutils.BeanUtilsBean;
|
|
|
|
import org.apache.commons.beanutils.BeanUtilsBean;
|
|
|
|
import org.apache.commons.beanutils.locale.LocaleBeanUtils;
|
|
|
|
import org.apache.commons.beanutils.locale.LocaleBeanUtils;
|
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
@ -107,6 +110,8 @@ public class ModuleServiceImpl implements ModuleService {
|
|
|
|
private CollectionComponentRepository collectionComponentRepository;
|
|
|
|
private CollectionComponentRepository collectionComponentRepository;
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private ModuleGroupRepository moduleGroupRepository;
|
|
|
|
private ModuleGroupRepository moduleGroupRepository;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private CmpInternalService cmpInternalService;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public GeneralResult<GridBean<CiModule>> getModelList(Pager pager) {
|
|
|
|
public GeneralResult<GridBean<CiModule>> getModelList(Pager pager) {
|
|
|
@ -118,23 +123,23 @@ public class ModuleServiceImpl implements ModuleService {
|
|
|
|
List<Param> params = pager.getParams();
|
|
|
|
List<Param> params = pager.getParams();
|
|
|
|
List<Map<String, Object>> collectMap = params.stream().map(Param::getParam).collect(Collectors.toList());
|
|
|
|
List<Map<String, Object>> collectMap = params.stream().map(Param::getParam).collect(Collectors.toList());
|
|
|
|
Map<String, Object> map =
|
|
|
|
Map<String, Object> map =
|
|
|
|
collectMap.stream().filter(item -> item.containsKey("flag")).findFirst().orElse(null);
|
|
|
|
collectMap.stream().filter(item -> item.containsKey("flag")).findFirst().orElse(null);
|
|
|
|
if (null != map) {
|
|
|
|
if (null != map) {
|
|
|
|
Param newParam = null;
|
|
|
|
Param newParam = null;
|
|
|
|
Iterator<Param> iterator = params.iterator();
|
|
|
|
Iterator<Param> iterator = params.iterator();
|
|
|
|
while (iterator.hasNext()) {
|
|
|
|
while (iterator.hasNext()) {
|
|
|
|
Map<String, Object> parMap = iterator.next().getParam();
|
|
|
|
Map<String, Object> parMap = iterator.next().getParam();
|
|
|
|
if (parMap.containsKey("moduleGroupId") && parMap.containsKey("flag")) {
|
|
|
|
if (parMap.containsKey("moduleGroupId") && parMap.containsKey("flag")) {
|
|
|
|
Long groupId = Long.valueOf((Integer)parMap.get("moduleGroupId"));
|
|
|
|
Long groupId = Long.valueOf((Integer) parMap.get("moduleGroupId"));
|
|
|
|
if (parMap.get("flag").equals(true)) {
|
|
|
|
if (parMap.get("flag").equals(true)) {
|
|
|
|
// 递归获取所有子groupId
|
|
|
|
// 递归获取所有子groupId
|
|
|
|
List<ModuleGroup> groups = moduleGroupRepository.all();
|
|
|
|
List<ModuleGroup> groups = moduleGroupRepository.all();
|
|
|
|
Map<Long, List<ModuleGroup>> groupMap =
|
|
|
|
Map<Long, List<ModuleGroup>> groupMap =
|
|
|
|
groups.stream().collect(Collectors.groupingBy(ModuleGroup::getParentId));
|
|
|
|
groups.stream().collect(Collectors.groupingBy(ModuleGroup::getParentId));
|
|
|
|
List<Long> groupIds = new ArrayList<>();
|
|
|
|
List<Long> groupIds = new ArrayList<>();
|
|
|
|
this.getGroups(groupIds, groupId, groupMap);
|
|
|
|
this.getGroups(groupIds, groupId, groupMap);
|
|
|
|
List<String> groupIdList =
|
|
|
|
List<String> groupIdList =
|
|
|
|
groupIds.stream().map(String::valueOf).collect(Collectors.toList());
|
|
|
|
groupIds.stream().map(String::valueOf).collect(Collectors.toList());
|
|
|
|
String ids = String.join(",", groupIdList);
|
|
|
|
String ids = String.join(",", groupIdList);
|
|
|
|
Map<String, Object> groupIdMap = new HashMap<>();
|
|
|
|
Map<String, Object> groupIdMap = new HashMap<>();
|
|
|
|
groupIdMap.put("moduleGroupId", ids);
|
|
|
|
groupIdMap.put("moduleGroupId", ids);
|
|
|
@ -160,7 +165,7 @@ public class ModuleServiceImpl implements ModuleService {
|
|
|
|
if (CollectionUtils.isNotEmpty(groups)) {
|
|
|
|
if (CollectionUtils.isNotEmpty(groups)) {
|
|
|
|
for (CiModule module : modules) {
|
|
|
|
for (CiModule module : modules) {
|
|
|
|
ModuleGroup group = groups.stream().filter(item -> item.getId().equals(module.getGroupId()))
|
|
|
|
ModuleGroup group = groups.stream().filter(item -> item.getId().equals(module.getGroupId()))
|
|
|
|
.findFirst().orElse(null);
|
|
|
|
.findFirst().orElse(null);
|
|
|
|
if (null != group) {
|
|
|
|
if (null != group) {
|
|
|
|
module.setParentGroupId(group.getParentId());
|
|
|
|
module.setParentGroupId(group.getParentId());
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -180,7 +185,7 @@ public class ModuleServiceImpl implements ModuleService {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
List<CiModule> modules = moduleRepository.all();
|
|
|
|
List<CiModule> modules = moduleRepository.all();
|
|
|
|
List<CiModule> list = modules.stream().filter(item -> ModuleConstant.STATUS_ENABLE.equals(item.getStatus()))
|
|
|
|
List<CiModule> list = modules.stream().filter(item -> ModuleConstant.STATUS_ENABLE.equals(item.getStatus()))
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
return new GeneralResult<>(true, list, "查询成功!");
|
|
|
|
return new GeneralResult<>(true, list, "查询成功!");
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
log.error("query module is error:", e);
|
|
|
|
log.error("query module is error:", e);
|
|
|
@ -252,12 +257,12 @@ public class ModuleServiceImpl implements ModuleService {
|
|
|
|
return new GeneralResult<>(false, "新增模型属性分组失败");
|
|
|
|
return new GeneralResult<>(false, "新增模型属性分组失败");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Property id = new Property("uuid", "唯一标识", PropertyType.TEXTFIELD.name(), group.getName(), 100, true, true,
|
|
|
|
Property id = new Property("uuid", "唯一标识", PropertyType.TEXTFIELD.name(), group.getName(), 100, true, true,
|
|
|
|
1, module.getId(), true, false, false, target, PropertyConstant.DefaultValueType.INNERFUN,
|
|
|
|
1, module.getId(), true, false, false, target, PropertyConstant.DefaultValueType.INNERFUN,
|
|
|
|
PropertyConstant.GLOBALLY_UNIQUE_IDENTIFIER, true, false);
|
|
|
|
PropertyConstant.GLOBALLY_UNIQUE_IDENTIFIER, true, false);
|
|
|
|
// name设置为标题列
|
|
|
|
// name设置为标题列
|
|
|
|
Property name = new Property("name", "名称", PropertyType.TEXTFIELD.name(), group.getName(), 100, true, true,
|
|
|
|
Property name = new Property("name", "名称", PropertyType.TEXTFIELD.name(), group.getName(), 100, true, true,
|
|
|
|
2, module.getId(), true, false, true, target, PropertyConstant.DefaultValueType.FIXED, null, false,
|
|
|
|
2, module.getId(), true, false, true, target, PropertyConstant.DefaultValueType.FIXED, null, false,
|
|
|
|
true);
|
|
|
|
true);
|
|
|
|
properties.add(id);
|
|
|
|
properties.add(id);
|
|
|
|
properties.add(name);
|
|
|
|
properties.add(name);
|
|
|
|
propertyRepository.batchSave(properties, 10);
|
|
|
|
propertyRepository.batchSave(properties, 10);
|
|
|
@ -323,11 +328,11 @@ public class ModuleServiceImpl implements ModuleService {
|
|
|
|
List<TopologyConfig> configs = topologyConfigRepository.listAll();
|
|
|
|
List<TopologyConfig> configs = topologyConfigRepository.listAll();
|
|
|
|
// 获取拓扑路径涉及到的模型数据
|
|
|
|
// 获取拓扑路径涉及到的模型数据
|
|
|
|
List<Long> modules = configs.stream().filter(item -> StringUtils.isNotEmpty(item.getTopologyPath()))
|
|
|
|
List<Long> modules = configs.stream().filter(item -> StringUtils.isNotEmpty(item.getTopologyPath()))
|
|
|
|
.flatMap(config -> Arrays.stream(config.getTopologyPath().split(","))).distinct()
|
|
|
|
.flatMap(config -> Arrays.stream(config.getTopologyPath().split(","))).distinct()
|
|
|
|
.map(item -> Long.valueOf(item)).collect(Collectors.toList());
|
|
|
|
.map(item -> Long.valueOf(item)).collect(Collectors.toList());
|
|
|
|
List<Long> ignores = configs.stream().filter(item -> StringUtils.isNotEmpty(item.getIgnoreModuleIds()))
|
|
|
|
List<Long> ignores = configs.stream().filter(item -> StringUtils.isNotEmpty(item.getIgnoreModuleIds()))
|
|
|
|
.flatMap(config -> Arrays.stream(config.getIgnoreModuleIds().split(","))).distinct()
|
|
|
|
.flatMap(config -> Arrays.stream(config.getIgnoreModuleIds().split(","))).distinct()
|
|
|
|
.map(item -> Long.valueOf(item)).collect(Collectors.toList());
|
|
|
|
.map(item -> Long.valueOf(item)).collect(Collectors.toList());
|
|
|
|
modules.addAll(ignores);
|
|
|
|
modules.addAll(ignores);
|
|
|
|
modules.removeAll(Collections.singleton(null)); // 移除所有的null元素
|
|
|
|
modules.removeAll(Collections.singleton(null)); // 移除所有的null元素
|
|
|
|
if (modules.contains(id)) {
|
|
|
|
if (modules.contains(id)) {
|
|
|
@ -419,8 +424,47 @@ public class ModuleServiceImpl implements ModuleService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public GeneralResult statistics(RequestContext context) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
List<String> nameList = Arrays.asList("网络设备", "物理服务器", "安全设备");
|
|
|
|
|
|
|
|
//查询根节点
|
|
|
|
|
|
|
|
List<ModuleGroup> rootGroups = moduleGroupRepository.queryRootInName(nameList);
|
|
|
|
|
|
|
|
log.info("moduleGroups:{}", JSON.toJSONString("moduleGroups"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//查询出所有根节点下的子节点
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<Long> rootGroupIds = rootGroups.stream().map(ModuleGroup::getId).collect(Collectors.toList());
|
|
|
|
|
|
|
|
// 获取模型分组所有数据
|
|
|
|
|
|
|
|
List<ModuleGroup> moduleGroups = moduleGroupRepository.all();
|
|
|
|
|
|
|
|
// 获取根节点的子节点集合
|
|
|
|
|
|
|
|
List<ModuleGroup> children = moduleGroups.stream().filter(item -> rootGroupIds.contains(item.getParentId()))
|
|
|
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
log.info("children:{}", JSON.toJSONString(children));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//查询云主机总数
|
|
|
|
|
|
|
|
Pager pager = new Pager();
|
|
|
|
|
|
|
|
pager.setPage(1);
|
|
|
|
|
|
|
|
pager.setRows(Integer.MAX_VALUE);
|
|
|
|
|
|
|
|
List<Param> paramList = new ArrayList<>();
|
|
|
|
|
|
|
|
Param param = new Param();
|
|
|
|
|
|
|
|
param.setParam(MapTools.simpleMap("isTemplate",false));
|
|
|
|
|
|
|
|
param.setSign(Sign.EQ);
|
|
|
|
|
|
|
|
paramList.add(param);
|
|
|
|
|
|
|
|
pager.setParams(paramList);
|
|
|
|
|
|
|
|
GeneralResult<JSONObject> list = cmpInternalService.list(pager.toMap());
|
|
|
|
|
|
|
|
log.info("list:{}", JSON.toJSONString(list));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return new GeneralResult<>(true, "查询成功");
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
log.info("查询失败", e);
|
|
|
|
|
|
|
|
return new GeneralResult<>(false, "查询失败");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private GeneralResult baseModifyProperty(Long moduleId, List<PropertyGroup> groups, List<Property> properties,
|
|
|
|
private GeneralResult baseModifyProperty(Long moduleId, List<PropertyGroup> groups, List<Property> properties,
|
|
|
|
Long userId) throws Exception {
|
|
|
|
Long userId) throws Exception {
|
|
|
|
CiModule module = moduleRepository.query(moduleId);
|
|
|
|
CiModule module = moduleRepository.query(moduleId);
|
|
|
|
if (module == null) {
|
|
|
|
if (module == null) {
|
|
|
|
return GeneralResult.FAILED("修改属性对应的配置模型不存在");
|
|
|
|
return GeneralResult.FAILED("修改属性对应的配置模型不存在");
|
|
|
@ -435,15 +479,15 @@ public class ModuleServiceImpl implements ModuleService {
|
|
|
|
List<PropertyGroup> oldGroups = propertyGroupRepository.listByModuleId(moduleId);
|
|
|
|
List<PropertyGroup> oldGroups = propertyGroupRepository.listByModuleId(moduleId);
|
|
|
|
// 1-add:新增property数据 以及对应的propertyItem数据
|
|
|
|
// 1-add:新增property数据 以及对应的propertyItem数据
|
|
|
|
List<Property> addProperties =
|
|
|
|
List<Property> addProperties =
|
|
|
|
properties.stream().filter(item -> null == item.getId()).collect(Collectors.toList());
|
|
|
|
properties.stream().filter(item -> null == item.getId()).collect(Collectors.toList());
|
|
|
|
// 3-update:更新property数据(不允许从池表中引入的数据被更新) 以及对应的propertyItem数据
|
|
|
|
// 3-update:更新property数据(不允许从池表中引入的数据被更新) 以及对应的propertyItem数据
|
|
|
|
List<Property> updateProperties = properties.stream()
|
|
|
|
List<Property> updateProperties = properties.stream()
|
|
|
|
.filter(item -> null != item.getId()).collect(Collectors.toList());
|
|
|
|
.filter(item -> null != item.getId()).collect(Collectors.toList());
|
|
|
|
// 2-delete:删除去掉的property数据 以及对应的propertyItem数据
|
|
|
|
// 2-delete:删除去掉的property数据 以及对应的propertyItem数据
|
|
|
|
List<Long> inputPropertyIds =
|
|
|
|
List<Long> inputPropertyIds =
|
|
|
|
properties.stream().filter(item -> null != item.getId()).map(Property::getId).collect(Collectors.toList());
|
|
|
|
properties.stream().filter(item -> null != item.getId()).map(Property::getId).collect(Collectors.toList());
|
|
|
|
List<Property> deleteProperties = oldProperties.stream()
|
|
|
|
List<Property> deleteProperties = oldProperties.stream()
|
|
|
|
.filter(item -> !inputPropertyIds.contains(item.getId())).collect(Collectors.toList());
|
|
|
|
.filter(item -> !inputPropertyIds.contains(item.getId())).collect(Collectors.toList());
|
|
|
|
// 1-delete:删除去掉的property数据 以及 对应的propertyItem数据
|
|
|
|
// 1-delete:删除去掉的property数据 以及 对应的propertyItem数据
|
|
|
|
if (CollectionUtils.isNotEmpty(deleteProperties)) {
|
|
|
|
if (CollectionUtils.isNotEmpty(deleteProperties)) {
|
|
|
|
// 先校验是否存在被其他模型引用的属性,如果存在就不允许删除
|
|
|
|
// 先校验是否存在被其他模型引用的属性,如果存在就不允许删除
|
|
|
@ -451,7 +495,7 @@ public class ModuleServiceImpl implements ModuleService {
|
|
|
|
List<Property> linkModuleIds = propertyRepository.queryByLinkModuleId(moduleId);
|
|
|
|
List<Property> linkModuleIds = propertyRepository.queryByLinkModuleId(moduleId);
|
|
|
|
if (CollectionUtils.isNotEmpty(linkModuleIds)) {
|
|
|
|
if (CollectionUtils.isNotEmpty(linkModuleIds)) {
|
|
|
|
long count = linkModuleIds.stream().map(Property::getPropertyIds).map(item -> item.split(","))
|
|
|
|
long count = linkModuleIds.stream().map(Property::getPropertyIds).map(item -> item.split(","))
|
|
|
|
.flatMap(item -> Arrays.stream(item)).filter(item -> deletePropertyIds.contains(item)).count();
|
|
|
|
.flatMap(item -> Arrays.stream(item)).filter(item -> deletePropertyIds.contains(item)).count();
|
|
|
|
if (count > 0) {
|
|
|
|
if (count > 0) {
|
|
|
|
return GeneralResult.FAILED("删除属性失败,存在其他模型引用此属性");
|
|
|
|
return GeneralResult.FAILED("删除属性失败,存在其他模型引用此属性");
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -460,7 +504,7 @@ public class ModuleServiceImpl implements ModuleService {
|
|
|
|
List<CollectionComponent> collectionComponents = collectionComponentRepository.queryByModuleId(moduleId);
|
|
|
|
List<CollectionComponent> collectionComponents = collectionComponentRepository.queryByModuleId(moduleId);
|
|
|
|
if (CollectionUtils.isNotEmpty(collectionComponents)) {
|
|
|
|
if (CollectionUtils.isNotEmpty(collectionComponents)) {
|
|
|
|
long count = collectionComponents.stream().map(CollectionComponent::getPropertyId)
|
|
|
|
long count = collectionComponents.stream().map(CollectionComponent::getPropertyId)
|
|
|
|
.filter(item -> deletePropertyIds.contains(item)).count();
|
|
|
|
.filter(item -> deletePropertyIds.contains(item)).count();
|
|
|
|
if (count > 0) {
|
|
|
|
if (count > 0) {
|
|
|
|
return GeneralResult.FAILED("删除属性失败,存在属性被采集插件使用");
|
|
|
|
return GeneralResult.FAILED("删除属性失败,存在属性被采集插件使用");
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -480,7 +524,7 @@ public class ModuleServiceImpl implements ModuleService {
|
|
|
|
// 根据需要删除的property数据删除对应的propertyItem数据
|
|
|
|
// 根据需要删除的property数据删除对应的propertyItem数据
|
|
|
|
List<Long> propertyIds = deleteProperties.stream().map(Property::getId).collect(Collectors.toList());
|
|
|
|
List<Long> propertyIds = deleteProperties.stream().map(Property::getId).collect(Collectors.toList());
|
|
|
|
List<PropertyItem> deleteItems = oldItems.stream()
|
|
|
|
List<PropertyItem> deleteItems = oldItems.stream()
|
|
|
|
.filter(item -> propertyIds.contains(item.getPropertyId())).collect(Collectors.toList());
|
|
|
|
.filter(item -> propertyIds.contains(item.getPropertyId())).collect(Collectors.toList());
|
|
|
|
if (CollectionUtils.isNotEmpty(deleteItems)) {
|
|
|
|
if (CollectionUtils.isNotEmpty(deleteItems)) {
|
|
|
|
deleteItems.stream().forEach(item -> {
|
|
|
|
deleteItems.stream().forEach(item -> {
|
|
|
|
item.setGmtModify(new Date());
|
|
|
|
item.setGmtModify(new Date());
|
|
|
@ -522,7 +566,7 @@ public class ModuleServiceImpl implements ModuleService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 3-update:更新数据
|
|
|
|
// 3-update:更新数据
|
|
|
|
for (Property property : updateProperties) {
|
|
|
|
for (Property property : updateProperties) {
|
|
|
|
if(null != property.getPropertyPoolId()){
|
|
|
|
if (null != property.getPropertyPoolId()) {
|
|
|
|
property.setGmtModify(new Date());
|
|
|
|
property.setGmtModify(new Date());
|
|
|
|
property.setMenderId(userId);
|
|
|
|
property.setMenderId(userId);
|
|
|
|
propertyRepository.update(property);
|
|
|
|
propertyRepository.update(property);
|
|
|
@ -530,7 +574,7 @@ public class ModuleServiceImpl implements ModuleService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 获取新增item数据
|
|
|
|
// 获取新增item数据
|
|
|
|
List<PropertyItem> addItems = new ArrayList<>();
|
|
|
|
List<PropertyItem> addItems = new ArrayList<>();
|
|
|
|
if (!Common.ONE.equals(property.getTableType())){
|
|
|
|
if (!Common.ONE.equals(property.getTableType())) {
|
|
|
|
addItems = property.getItemList().stream().filter(item -> null == item.getId()).collect(Collectors.toList());
|
|
|
|
addItems = property.getItemList().stream().filter(item -> null == item.getId()).collect(Collectors.toList());
|
|
|
|
addItems.stream().forEach(item -> {
|
|
|
|
addItems.stream().forEach(item -> {
|
|
|
|
item.setModuleId(property.getModuleId());
|
|
|
|
item.setModuleId(property.getModuleId());
|
|
|
@ -546,22 +590,23 @@ public class ModuleServiceImpl implements ModuleService {
|
|
|
|
// 获取更新的item数据
|
|
|
|
// 获取更新的item数据
|
|
|
|
List<PropertyItem> updateItems = new ArrayList<>();
|
|
|
|
List<PropertyItem> updateItems = new ArrayList<>();
|
|
|
|
List<Long> updateItemIds = new ArrayList<>();
|
|
|
|
List<Long> updateItemIds = new ArrayList<>();
|
|
|
|
if (!Common.ONE.equals(property.getTableType())){
|
|
|
|
if (!Common.ONE.equals(property.getTableType())) {
|
|
|
|
updateItems = property.getItemList().stream().filter(item -> null != item.getId()).collect(Collectors.toList());
|
|
|
|
updateItems = property.getItemList().stream().filter(item -> null != item.getId()).collect(Collectors.toList());
|
|
|
|
updateItems.stream().forEach(item -> {
|
|
|
|
updateItems.stream().forEach(item -> {
|
|
|
|
item.setMenderId(userId);
|
|
|
|
item.setMenderId(userId);
|
|
|
|
if (CollectionUtils.isNotEmpty(item.getItemList())) {
|
|
|
|
if (CollectionUtils.isNotEmpty(item.getItemList())) {
|
|
|
|
// 表格属性中结构项数据的下拉选项数据 转成 JSON 存储
|
|
|
|
// 表格属性中结构项数据的下拉选项数据 转成 JSON 存储
|
|
|
|
item.setItemValue(JSON.toJSONString(item.getItemList()));
|
|
|
|
item.setItemValue(JSON.toJSONString(item.getItemList()));
|
|
|
|
} updateItemIds.add(item.getId());
|
|
|
|
}
|
|
|
|
|
|
|
|
updateItemIds.add(item.getId());
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 根据当前属性id查询出之前的item
|
|
|
|
// 根据当前属性id查询出之前的item
|
|
|
|
List<PropertyItem> updateOldItems = oldItems.stream()
|
|
|
|
List<PropertyItem> updateOldItems = oldItems.stream()
|
|
|
|
.filter(item -> item.getPropertyId().equals(property.getId())).collect(Collectors.toList());
|
|
|
|
.filter(item -> item.getPropertyId().equals(property.getId())).collect(Collectors.toList());
|
|
|
|
// 获取需要删除的item数据(就是原始的减去现在的)
|
|
|
|
// 获取需要删除的item数据(就是原始的减去现在的)
|
|
|
|
List<PropertyItem> deleteItems = updateOldItems.stream()
|
|
|
|
List<PropertyItem> deleteItems = updateOldItems.stream()
|
|
|
|
.filter(item -> !updateItemIds.contains(item.getId())).collect(Collectors.toList());
|
|
|
|
.filter(item -> !updateItemIds.contains(item.getId())).collect(Collectors.toList());
|
|
|
|
deleteItems.stream().forEach(item -> {
|
|
|
|
deleteItems.stream().forEach(item -> {
|
|
|
|
item.setGmtModify(new Date());
|
|
|
|
item.setGmtModify(new Date());
|
|
|
|
item.setMenderId(userId);
|
|
|
|
item.setMenderId(userId);
|
|
|
@ -588,13 +633,13 @@ public class ModuleServiceImpl implements ModuleService {
|
|
|
|
// 获取需要新增的group数据
|
|
|
|
// 获取需要新增的group数据
|
|
|
|
if (CollectionUtils.isNotEmpty(groups)) {
|
|
|
|
if (CollectionUtils.isNotEmpty(groups)) {
|
|
|
|
List<PropertyGroup> addGroups =
|
|
|
|
List<PropertyGroup> addGroups =
|
|
|
|
groups.stream().filter(item -> null == item.getId()).collect(Collectors.toList());
|
|
|
|
groups.stream().filter(item -> null == item.getId()).collect(Collectors.toList());
|
|
|
|
if (CollectionUtils.isNotEmpty(addGroups)) {
|
|
|
|
if (CollectionUtils.isNotEmpty(addGroups)) {
|
|
|
|
propertyGroupRepository.batchSave(addGroups, addGroups.size());
|
|
|
|
propertyGroupRepository.batchSave(addGroups, addGroups.size());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 获取需要更新的group数据
|
|
|
|
// 获取需要更新的group数据
|
|
|
|
List<PropertyGroup> updateGroups =
|
|
|
|
List<PropertyGroup> updateGroups =
|
|
|
|
groups.stream().filter(item -> null != item.getId()).collect(Collectors.toList());
|
|
|
|
groups.stream().filter(item -> null != item.getId()).collect(Collectors.toList());
|
|
|
|
if (CollectionUtils.isNotEmpty(updateGroups)) {
|
|
|
|
if (CollectionUtils.isNotEmpty(updateGroups)) {
|
|
|
|
updateGroups.stream().forEach(item -> {
|
|
|
|
updateGroups.stream().forEach(item -> {
|
|
|
|
item.setMenderId(userId);
|
|
|
|
item.setMenderId(userId);
|
|
|
@ -604,7 +649,7 @@ public class ModuleServiceImpl implements ModuleService {
|
|
|
|
List<Long> groupIds = updateGroups.stream().map(PropertyGroup::getId).collect(Collectors.toList());
|
|
|
|
List<Long> groupIds = updateGroups.stream().map(PropertyGroup::getId).collect(Collectors.toList());
|
|
|
|
// 获取需要删除的数据
|
|
|
|
// 获取需要删除的数据
|
|
|
|
List<PropertyGroup> deleteGroups =
|
|
|
|
List<PropertyGroup> deleteGroups =
|
|
|
|
oldGroups.stream().filter(item -> !groupIds.contains(item.getId())).collect(Collectors.toList());
|
|
|
|
oldGroups.stream().filter(item -> !groupIds.contains(item.getId())).collect(Collectors.toList());
|
|
|
|
if (CollectionUtils.isNotEmpty(deleteGroups)) {
|
|
|
|
if (CollectionUtils.isNotEmpty(deleteGroups)) {
|
|
|
|
deleteGroups.stream().forEach(item -> {
|
|
|
|
deleteGroups.stream().forEach(item -> {
|
|
|
|
item.setModuleId(userId);
|
|
|
|
item.setModuleId(userId);
|
|
|
@ -636,7 +681,7 @@ public class ModuleServiceImpl implements ModuleService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
code = code.trim();
|
|
|
|
code = code.trim();
|
|
|
|
Pattern compile = Pattern.compile(
|
|
|
|
Pattern compile = Pattern.compile(
|
|
|
|
"^(create|alter|select|update|union|and|or|delete|insert|trancate|char|substr|commit|ascii|declare|exec|count|show|into|drop|execute)$");
|
|
|
|
"^(create|alter|select|update|union|and|or|delete|insert|trancate|char|substr|commit|ascii|declare|exec|count|show|into|drop|execute)$");
|
|
|
|
if (compile.matcher(code).find()) {
|
|
|
|
if (compile.matcher(code).find()) {
|
|
|
|
throw new Exception("属性编码不能是关键字:" + code);
|
|
|
|
throw new Exception("属性编码不能是关键字:" + code);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -658,7 +703,7 @@ public class ModuleServiceImpl implements ModuleService {
|
|
|
|
List<PropertyItem> items = property.getItemList();
|
|
|
|
List<PropertyItem> items = property.getItemList();
|
|
|
|
if (CollectionUtils.isNotEmpty(items)) {
|
|
|
|
if (CollectionUtils.isNotEmpty(items)) {
|
|
|
|
if (property.getType().equals(PropertyConstant.PropertyType.MULTILINETABLE)
|
|
|
|
if (property.getType().equals(PropertyConstant.PropertyType.MULTILINETABLE)
|
|
|
|
|| property.getType().equals(PropertyConstant.PropertyType.SINGLELINETABLE)) {
|
|
|
|
|| property.getType().equals(PropertyConstant.PropertyType.SINGLELINETABLE)) {
|
|
|
|
Map<String, String> itemNameMap = new HashMap<>();
|
|
|
|
Map<String, String> itemNameMap = new HashMap<>();
|
|
|
|
Map<String, String> itemCodeMap = new HashMap<>();
|
|
|
|
Map<String, String> itemCodeMap = new HashMap<>();
|
|
|
|
List<PropertyItem> tableItems = property.getItemList();
|
|
|
|
List<PropertyItem> tableItems = property.getItemList();
|
|
|
@ -681,9 +726,9 @@ public class ModuleServiceImpl implements ModuleService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
itemCodeMap.put(itemCode, itemCode);
|
|
|
|
itemCodeMap.put(itemCode, itemCode);
|
|
|
|
if (tableItem.getType().equals(PropertyConstant.PropertyType.SINGLESELECT)
|
|
|
|
if (tableItem.getType().equals(PropertyConstant.PropertyType.SINGLESELECT)
|
|
|
|
|| tableItem.getType().equals(PropertyConstant.PropertyType.MULTISELECT)
|
|
|
|
|| tableItem.getType().equals(PropertyConstant.PropertyType.MULTISELECT)
|
|
|
|
|| tableItem.getType().equals(PropertyConstant.PropertyType.RADIO)
|
|
|
|
|| tableItem.getType().equals(PropertyConstant.PropertyType.RADIO)
|
|
|
|
|| tableItem.getType().equals(PropertyConstant.PropertyType.CHECKBOX)) {
|
|
|
|
|| tableItem.getType().equals(PropertyConstant.PropertyType.CHECKBOX)) {
|
|
|
|
validateItemValues(tableItem);
|
|
|
|
validateItemValues(tableItem);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -754,7 +799,7 @@ public class ModuleServiceImpl implements ModuleService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void copyProperties(Property property, PropertyPool pool)
|
|
|
|
private void copyProperties(Property property, PropertyPool pool)
|
|
|
|
throws IllegalAccessException, InvocationTargetException {
|
|
|
|
throws IllegalAccessException, InvocationTargetException {
|
|
|
|
Long id = property.getId();
|
|
|
|
Long id = property.getId();
|
|
|
|
BeanUtilsBean.getInstance().copyProperties(property, pool);
|
|
|
|
BeanUtilsBean.getInstance().copyProperties(property, pool);
|
|
|
|
property.setId(id);
|
|
|
|
property.setId(id);
|
|
|
|