lihang
2023-07-10 0a6ab7fccd8db586125dbe3a9b80841f1c0d3d5f
Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/service/impl/AttributeServiceImpl.java
@@ -27,10 +27,7 @@
import org.springframework.util.CollectionUtils;
import javax.validation.constraints.NotEmpty;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import java.util.*;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@@ -77,13 +74,9 @@
   @Override
   public boolean submit(AttributeDTO dto) {
      VciBaseUtil.alertNotNull(dto.getId(),"属性编号",dto.getName(),"属性名称",dto.getTypeKey(),"属性类型",dto.getMaxLength(),"属性长度");
      if (!Pattern.compile(REGEXP).matcher(dto.getId()).matches()){
         throw new VciBaseException("属性编号{0}只能是英文",new Object[]{dto.getId()});
      }
      LambdaQueryWrapper<Attribute> wrapper = Wrappers.<Attribute>query().lambda().eq(Attribute::getId, dto.getId());
      Long count = baseMapper.selectCount((Func.isEmpty(dto.getOid())) ? wrapper : wrapper.notIn(Attribute::getOid, dto.getOid()));
      if (count > 0L) {
         throw new ServiceException("属性编号已存在!");
      String msg = checkAttributeId(dto.getId(),dto.getOid());
      if (StringUtils.isNotBlank(msg)){
         throw new VciBaseException(msg);
      }
      Attribute attribute = AttributeWrapper.build().copyBeforeSave(dto);
      CacheUtil.clear(OmdCacheConstant.ATTR_CACHE);
@@ -91,6 +84,23 @@
   }
   /**
    * 元数据的ID校验
    * @param id 编号值
    * @param oid 数据主键
    * @return 校验结果
    */
   private String checkAttributeId(String id, String oid) {
      if (!Pattern.compile(REGEXP).matcher(id).matches()){
         return "属性编号"+id+"只能是英文";
      }
      Long count = baseMapper.checkIdExist(id.toLowerCase(Locale.ROOT),oid);
      if (count > 0L) {
         return "属性编号"+id+"(不区分大小写)已存在!";
      }
      return null;
   }
   /**
    * 删除
    *
    * @param oids 主键集合