From a19d26e88360c9760b2286bac4dfb1710fd2fa21 Mon Sep 17 00:00:00 2001 From: xiejun <xj@2023> Date: 星期六, 12 八月 2023 13:33:58 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/service/impl/BtmAttributeServiceImpl.java | 198 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 185 insertions(+), 13 deletions(-) diff --git a/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/service/impl/BtmAttributeServiceImpl.java b/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/service/impl/BtmAttributeServiceImpl.java index 94cbe3d..bf62946 100644 --- a/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/service/impl/BtmAttributeServiceImpl.java +++ b/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/service/impl/BtmAttributeServiceImpl.java @@ -1,24 +1,28 @@ 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; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import javax.validation.constraints.NotEmpty; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Optional; +import java.util.*; /** * Description: 涓氬姟绫诲瀷鍏宠仈灞炴�х殑鏈嶅姟瀹炵幇绫� @@ -49,36 +53,71 @@ * @return 鍙楀奖鍝嶇殑琛屾暟 */ @Override - public int checkAndInsert(String btmTypeOid, List<BtmTypeLinkAttributesDTO> attributesDTOList, String creator, Date now) { + public List<BtmTypeAttributeVO> checkAndInsert(String btmTypeOid, List<BtmTypeLinkAttributesDTO> attributesDTOList, String creator, Date now) { List<String> attributeIdList = new ArrayList<>(); List<BtmTypeAttribute> btmTypeAttributeDOList = new ArrayList<>(); if (!CollectionUtils.isEmpty(attributesDTOList)) { 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); if (!exists){ - return -1; + return null; } - return batchInsert(btmTypeAttributeDOList); + saveBatch(btmTypeAttributeDOList); + return BtmTypeAttributeWrapper.build().listEntityVO(btmTypeAttributeDOList); // btmTypeAttributeDOList.stream().forEachOrdered(s -> { // btmTypeAttributeDOMapper.insert(s); // }); } - return 0; + return null; } /** - * 鎵归噺鎻掑叆 + * 妫�鏌ュ睘鎬у瓨鍦ㄥ苟鍒犻櫎 * - * @param records 鏁版嵁瀵硅薄闆嗗悎 + * @param records 涓婚敭闆嗗悎 + * @return 鍙楀奖鍝嶇殑琛屾暟 */ @Override - public int batchInsert(List<BtmTypeAttribute> records) { - return baseMapper.insertBatchSomeColumn(records); + public int checkAndRemove(List<String> records) { + if (CollectionUtils.isEmpty(records)){ + return 0; + } + return baseMapper.batchDelete(records); + } + + /** + * 妫�鏌ュ睘鎬у瓨鍦ㄥ苟娣诲姞 + * + * @param btmTypeOid 涓氬姟绫诲瀷涓婚敭 + * @param attributesDTOList 椤甸潰浼犺緭瀵硅薄闆嗗悎 + * @param creator 鍒涘缓浜� + * @param now ts鏃堕棿鎴� + * @return 鍙楀奖鍝嶇殑琛屾暟 + */ + @Override + public List<BtmTypeAttributeVO> checkAndUpdate(String btmTypeOid, List<BtmTypeLinkAttributesDTO> attributesDTOList, String creator, Date now) { + List<String> attributeIdList = new ArrayList<>(); + List<BtmTypeAttribute> btmTypeAttributeDOList = new ArrayList<>(); + if (!CollectionUtils.isEmpty(attributesDTOList)) { + attributesDTOList.stream().forEachOrdered(s -> { + attributeService.checkAttribute(s); + btmTypeAttributeDOList.add(BtmTypeAttributeWrapper.build().copyBtmTypeAttributeDTO2Entity(s,btmTypeOid, creator, now)); + attributeIdList.add(s.getId().trim()); + }); + //妫�鏌ュ睘鎬ф槸鍚﹂兘瀛樺湪 + boolean exists = attributeService.checkAttributeExists(attributeIdList); + if (!exists){ + return null; + } + baseMapper.batchUpdate(btmTypeAttributeDOList); + return BtmTypeAttributeWrapper.build().listEntityVO(btmTypeAttributeDOList); + } + return null; } /** @@ -95,4 +134,137 @@ ).orElseGet(ArrayList::new) ); } + + /** + * 鏍规嵁涓氬姟绫诲瀷涓婚敭鑾峰彇鍏宠仈鐨勬墍鏈夊睘鎬у璞� + * + * @param oidCollection 涓氬姟绫诲瀷涓婚敭闆嗗悎 + * @return 鎵�鏈夌殑灞炴�у璞★紝鍖呮嫭绯荤粺鍐呯疆灞炴�э紝key鏄笟鍔$被鍨嬩富閿紝value鏄寘鍚殑灞炴�� + * @throws VciBaseException 涓氬姟绫诲瀷涓嶅瓨鍦紝鍙傛暟涓虹┖鎴栬�呮煡璇㈠嚭閿欐椂浼氭姏鍑哄紓甯� + */ + @Override + public List<BtmTypeAttributeVO> batchListHasAttributesByBtmTypeOidCollection(Collection<String> oidCollection) throws VciBaseException { + VciBaseUtil.alertNotNull(oidCollection,"涓氬姟绫诲瀷涓婚敭"); + List<BtmTypeAttribute> doList = baseMapper.selectList(Wrappers.<BtmTypeAttribute>query().lambda().in(BtmTypeAttribute::getPkBtmType, oidCollection)); + return BtmTypeAttributeWrapper.build().listEntityVO(doList); + } + + /** + * 鑾峰彇涓氬姟绫诲瀷涓殑鎸囧畾灞炴�� + * + * @param id 涓氬姟绫诲瀷鐨勪富閿� + * @param attributeIdCollection 灞炴�х殑id,鑻ヤ负绌哄垯鑾峰彇鍏ㄩ儴 + * @return 灞炴�х殑鏁版嵁瀵硅薄 + */ + @Override + public List<BtmTypeAttribute> selectByBtmTypeIdAndAttributeIds(String id, Collection<String> attributeIdCollection) { + return baseMapper.selectByBtmTypeIdAndAttributeIds(id,attributeIdCollection); + } + + /** + * 閫氳繃涓氬姟绫诲瀷鐨勮嫳鏂囧悕绉拌幏鍙栧叧鑱旂殑灞炴�� + * + * @param idList 涓氬姟绫诲瀷鐨勮嫳鏂囧悕绉伴泦鍚� + * @return 鍖呭惈鐨勫睘鎬� + */ + @Override + 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("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; + } } -- Gitblit v1.9.3