| | |
| | | package com.vci.ubcs.omd.service.impl; |
| | | |
| | | import com.alibaba.cloud.commons.lang.StringUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.vci.ubcs.omd.constant.BtmTypeConstant; |
| | | import com.vci.ubcs.omd.constant.BtmTypeFieldConstant; |
| | | import com.vci.ubcs.omd.dto.BtmTypeLinkAttributesDTO; |
| | | import com.vci.ubcs.omd.entity.BtmTypeAttribute; |
| | | import com.vci.ubcs.omd.mapper.BtmTypeAttributeMapper; |
| | | import com.vci.ubcs.omd.service.IAttributeService; |
| | | import com.vci.ubcs.omd.service.IBtmTypeAttributeService; |
| | | import com.vci.ubcs.omd.vo.BtmTypeAttributeVO; |
| | | import com.vci.ubcs.omd.vo.BtmTypeVO; |
| | | import com.vci.ubcs.omd.wrapper.BtmTypeAttributeWrapper; |
| | | import com.vci.ubcs.starter.exception.VciBaseException; |
| | | import com.vci.ubcs.starter.web.enumpck.VciFieldTypeEnum; |
| | | import com.vci.ubcs.starter.web.util.VciBaseUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | attributesDTOList.stream().forEachOrdered(s -> { |
| | | attributeService.checkAttribute(s); |
| | | btmTypeAttributeDOList.add(BtmTypeAttributeWrapper.build().copyBtmTypeAttributeDTO2Entity(s,btmTypeOid, creator, now)); |
| | | attributeIdList.add(s.getId().toLowerCase().trim()); |
| | | attributeIdList.add(s.getId().trim()); |
| | | }); |
| | | //检查属性是否都存在 |
| | | boolean exists = attributeService.checkAttributeExists(attributeIdList); |
| | |
| | | attributesDTOList.stream().forEachOrdered(s -> { |
| | | attributeService.checkAttribute(s); |
| | | btmTypeAttributeDOList.add(BtmTypeAttributeWrapper.build().copyBtmTypeAttributeDTO2Entity(s,btmTypeOid, creator, now)); |
| | | attributeIdList.add(s.getId().toLowerCase().trim()); |
| | | attributeIdList.add(s.getId().trim()); |
| | | }); |
| | | //检查属性是否都存在 |
| | | boolean exists = attributeService.checkAttributeExists(attributeIdList); |
| | |
| | | public List<BtmTypeAttribute> selectByBtmTypeIds(List<String> idList) { |
| | | return baseMapper.selectByBtmTypeIds(idList); |
| | | } |
| | | |
| | | /** |
| | | * 获取默认字段 |
| | | * 默认字段均不可为空 |
| | | * @param btmType 业务类型 |
| | | * @return 执行结果 |
| | | */ |
| | | @Override |
| | | public List<BtmTypeAttributeVO> getDefaultAttribute(BtmTypeVO btmType) { |
| | | List<BtmTypeAttributeVO> list = new ArrayList<>(); |
| | | // 业务类型的基本字段 |
| | | BtmTypeFieldConstant.BASIC_FIELD_MAP.forEach((id,name) -> { |
| | | id = id.toLowerCase(Locale.ROOT); |
| | | BtmTypeAttributeVO vo = new BtmTypeAttributeVO(); |
| | | vo.setId(id); |
| | | vo.setName(name); |
| | | vo.setPkBtmType(btmType.getOid()); |
| | | if ("oid".equals(id)){ |
| | | vo.setNullableFlag(false); |
| | | } |
| | | if (Arrays.asList("createtime","lastmodifytime","ts").contains(id)){ |
| | | vo.setAttrDataType(VciFieldTypeEnum.VTDateTime.name()); |
| | | vo.setAttributeLength(6); |
| | | }else { |
| | | vo.setAttrDataType(VciFieldTypeEnum.VTString.name()); |
| | | vo.setAttributeLength(150); |
| | | } |
| | | list.add(vo); |
| | | }); |
| | | |
| | | // 版本规则字段 |
| | | if (StringUtils.isNotBlank(btmType.getRevisionRuleId())){ |
| | | BtmTypeFieldConstant.REVISION_MANAGE_FIELD_MAP.forEach((id,name) -> { |
| | | BtmTypeAttributeVO vo = new BtmTypeAttributeVO(); |
| | | vo.setId(id); |
| | | vo.setName(name); |
| | | vo.setPkBtmType(btmType.getOid()); |
| | | vo.setAttrDataType(VciFieldTypeEnum.VTString.name()); |
| | | // 版本规则字段不能为空 |
| | | // vo.setNullableFlag(false); |
| | | vo.setAttributeLength(150); |
| | | if (Arrays.asList("lastr","firstr","lastv","firstv","revisionseq","versionseq").contains(id)){ |
| | | vo.setAttributeLength(5); |
| | | vo.setAttrDataType(VciFieldTypeEnum.VTInteger.name()); |
| | | } |
| | | if (Arrays.asList("checkintime","checkouttime").contains(id)){ |
| | | vo.setAttrDataType(VciFieldTypeEnum.VTDateTime.name()); |
| | | vo.setAttributeLength(6); |
| | | } |
| | | list.add(vo); |
| | | }); |
| | | } |
| | | |
| | | // 生命周期字段 |
| | | if (StringUtils.isNotBlank(btmType.getLifeCycleId())){ |
| | | BtmTypeFieldConstant.LIFECYCLE_MANAGE_FIELD_MAP.forEach((id,name) -> { |
| | | BtmTypeAttributeVO vo = new BtmTypeAttributeVO(); |
| | | vo.setId(id); |
| | | vo.setName(name); |
| | | vo.setPkBtmType(btmType.getOid()); |
| | | // vo.setNullableFlag(false); |
| | | vo.setAttributeLength(50); |
| | | vo.setAttrDataType(VciFieldTypeEnum.VTString.name()); |
| | | list.add(vo); |
| | | }); |
| | | } |
| | | |
| | | // 密级字段 |
| | | if (btmType.isSecretFlag()){ |
| | | BtmTypeFieldConstant.SECRET_MANAGE_FIELD_MAP.forEach((id,name) -> { |
| | | BtmTypeAttributeVO vo = new BtmTypeAttributeVO(); |
| | | vo.setId(id); |
| | | vo.setName(name); |
| | | vo.setPkBtmType(btmType.getOid()); |
| | | // vo.setNullableFlag(false); |
| | | vo.setAttributeLength(5); |
| | | vo.setAttrDataType(VciFieldTypeEnum.VTInteger.name()); |
| | | list.add(vo); |
| | | }); |
| | | } |
| | | |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 获取所有字段 |
| | | * |
| | | * @param btmType 业务类型 |
| | | * @return 执行结果 |
| | | */ |
| | | @Override |
| | | public List<BtmTypeAttributeVO> getAllAttribute(BtmTypeVO btmType) { |
| | | List<BtmTypeAttributeVO> list = getAttributeByBtmTypeOid(btmType.getOid()); |
| | | list.addAll(getDefaultAttribute(btmType)); |
| | | return list; |
| | | } |
| | | } |