| | |
| | | package com.vci.ubcs.omd.wrapper; |
| | | |
| | | import com.vci.ubcs.omd.cache.BtmTypeCache; |
| | | import com.vci.ubcs.omd.constant.BtmTypeConstant; |
| | | import com.vci.ubcs.omd.entity.LinkType; |
| | | import com.vci.ubcs.omd.vo.BtmTypeVO; |
| | | import com.vci.ubcs.omd.vo.LinkTypeAttributeVO; |
| | | import com.vci.ubcs.omd.vo.LinkTypeVO; |
| | | import com.vci.ubcs.starter.web.enumpck.NewAppConstantEnum; |
| | | import com.vci.ubcs.starter.web.util.VciBaseUtil; |
| | | import org.springblade.core.mp.support.BaseEntityWrapper; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Optional; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | |
| | | @Override |
| | | public LinkTypeVO entityVO(LinkType entity) { |
| | | LinkTypeVO vo = BeanUtil.copy(entity, LinkTypeVO.class); |
| | | LinkTypeVO vo = Optional.ofNullable(BeanUtil.copy(entity, LinkTypeVO.class)).orElseGet(LinkTypeVO::new); |
| | | List<String> fromIdList = Func.toStrList(",", vo.getFromBtmType()); |
| | | List<String> toIdList = Func.toStrList(",", vo.getToBtmType()); |
| | | Set<String> btmIdSet = new HashSet<>(); |
| | | btmIdSet.addAll(fromIdList); |
| | | btmIdSet.addAll(toIdList); |
| | | List<BtmTypeVO> btmTypeVOList = BtmTypeCache.selectByIdCollection(new ArrayList<>(btmIdSet)); |
| | | List<BtmTypeVO> fromBtm = new ArrayList<>(); |
| | | List<BtmTypeVO> toBtm = new ArrayList<>(); |
| | | Optional.ofNullable(btmTypeVOList).orElseGet(ArrayList::new).forEach(btm -> { |
| | | if (vo.getFromBtmType().contains(btm.getId())){ |
| | | fromBtm.add(btm); |
| | | } |
| | | if (vo.getToBtmType().contains(btm.getId())){ |
| | | toBtm.add(btm); |
| | | } |
| | | }); |
| | | vo.setFromBtmTypes(fromBtm); |
| | | vo.setToBtmTypes(toBtm); |
| | | // 枚举处理 |
| | | vo.setDomainText(NewAppConstantEnum.getTextByName(vo.getDomain())); |
| | | return vo; |
| | | } |
| | | |
| | | public List<LinkTypeVO> listEntityVO(List<LinkType> entityList){ |
| | | return Optional.ofNullable(entityList).orElseGet(ArrayList::new).stream().map(this::entityVO).collect(Collectors.toList()); |
| | | public List<LinkTypeVO> listEntityVO(List<LinkType> entityList, Map<String, List<LinkTypeAttributeVO>> pkLinkTypeAndAttributeMap){ |
| | | List<LinkTypeVO> voList = Optional.ofNullable(entityList).orElseGet(ArrayList::new).stream().map(this::entityVO).collect(Collectors.toList()); |
| | | if (!CollectionUtils.isEmpty(voList) && pkLinkTypeAndAttributeMap != null){ |
| | | voList.forEach(vo -> { |
| | | List<LinkTypeAttributeVO> attributes = pkLinkTypeAndAttributeMap.getOrDefault(vo.getOid(), new ArrayList<>()); |
| | | vo.setAttributes(attributes); |
| | | }); |
| | | } |
| | | return voList; |
| | | } |
| | | |
| | | public void copyLinkTypeVO2DO(LinkTypeVO linkTypeVO, LinkType linkTypeDO, String creator, Date now) { |
| | |
| | | linkTypeDO.setLastModifyTime(now); |
| | | linkTypeDO.setBtmName(BtmTypeConstant.LINK_TYPE); |
| | | } |
| | | |
| | | /** |
| | | * 编辑保存前设置默认字段值 |
| | | * |
| | | * @param linkTypeDO 链接类型 |
| | | * @param modifier 修改人 |
| | | * @param modifyTime 修改时间 |
| | | * @return |
| | | */ |
| | | public LinkType setBeforeUpdate(LinkType linkTypeDO, String modifier, Date modifyTime) { |
| | | linkTypeDO.setLastModifier(modifier); |
| | | linkTypeDO.setTs(modifyTime); |
| | | linkTypeDO.setLastModifyTime(modifyTime); |
| | | return linkTypeDO; |
| | | } |
| | | |
| | | /** |
| | | * 插入前设置默认字段 |
| | | * @param linkTypeDO 链接类型 |
| | | * @param creator 创建人 |
| | | * @param createTime 创建时间 |
| | | */ |
| | | public void setBeforeInsert(LinkType linkTypeDO, String creator, Date createTime) { |
| | | linkTypeDO.setOid(VciBaseUtil.getPk()); |
| | | linkTypeDO.setCreator(creator); |
| | | linkTypeDO.setCreateTime(createTime); |
| | | linkTypeDO.setOwner(creator); |
| | | linkTypeDO.setBtmName(BtmTypeConstant.LINK_TYPE); |
| | | linkTypeDO.setTs(createTime); |
| | | linkTypeDO.setLastModifyTime(createTime); |
| | | linkTypeDO.setLastModifier(creator); |
| | | } |
| | | } |