¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.vci.ubcs.code.service.impl; |
| | | |
| | | import com.alibaba.cloud.commons.lang.StringUtils; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.vci.ubcs.code.service.ICodeReferBtmTypeService; |
| | | import com.vci.ubcs.omd.feign.IAttributeClient; |
| | | import com.vci.ubcs.omd.feign.IBtmAttributeClient; |
| | | import com.vci.ubcs.omd.feign.IBtmTypeClient; |
| | | import com.vci.ubcs.omd.vo.AttributeVO; |
| | | import com.vci.ubcs.omd.vo.BtmTypeAttributeVO; |
| | | import com.vci.ubcs.omd.vo.BtmTypeVO; |
| | | import com.vci.ubcs.starter.web.enumpck.BooleanEnum; |
| | | import com.vci.ubcs.starter.web.pagemodel.BaseQueryObject; |
| | | import com.vci.ubcs.starter.web.pagemodel.DataGrid; |
| | | import com.vci.ubcs.starter.web.util.BeanUtil; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.rmi.ServerException; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 对omd䏿ä¾çfeignæ¥å£è¿è¡è°ç¨ï¼ä»¥åå¤çç¸å
³é»è¾ |
| | | * @author ludc |
| | | * @date 2023/6/1 18:39 |
| | | */ |
| | | @Service |
| | | public class CodeReferBtmTypeServiceImpl implements ICodeReferBtmTypeService { |
| | | |
| | | /** |
| | | * ä¸å¡ç±»åæå¡ |
| | | */ |
| | | @Resource |
| | | private IBtmTypeClient btmTypeClient; |
| | | |
| | | /** |
| | | * è·åä¸å¡ç±»åå表 |
| | | * @param baseQueryObject æ¥è¯¢æ¡ä»¶ |
| | | * @return å表çå
容 |
| | | */ |
| | | @Override |
| | | public Page<BtmTypeVO> referDataGrid(BaseQueryObject baseQueryObject) throws ServiceException { |
| | | Map<String, String> conditionMap = baseQueryObject.getConditionMap(); |
| | | conditionMap.put("domain", AppConstant.APPLICATION_NAME_CODE); |
| | | baseQueryObject.setConditionMap(conditionMap); |
| | | R<Page<BtmTypeVO>> btmTypeClientRefPage = btmTypeClient.getRefPage(baseQueryObject); |
| | | if(btmTypeClientRefPage.getCode() != 200){ |
| | | throw new ServiceException("ä¸å¡ç±»åfeignæ¥å£è°ç¨é误"); |
| | | } |
| | | return btmTypeClientRefPage.getData(); |
| | | } |
| | | |
| | | /** |
| | | * è·åä¸å¡ç±»åå
å«ç屿§ï¼ä¸å页 |
| | | * @param baseQueryObject æ¥è¯¢å¯¹è±¡ |
| | | * @return 屿§çä¿¡æ¯ |
| | | */ |
| | | @Override |
| | | public Page<BtmTypeAttributeVO> gridAttributesByBtmId(BaseQueryObject baseQueryObject) throws ServiceException { |
| | | String btmTypeId = baseQueryObject.getConditionMap().containsKey("btmTypeId")?baseQueryObject.getConditionMap().get("btmTypeId"):""; |
| | | if(StringUtils.isBlank(btmTypeId)){ |
| | | return new Page<>(); |
| | | } |
| | | String hasDefaultAttr = baseQueryObject.getConditionMap().getOrDefault("hasDefaultAttr","false"); |
| | | String attrId = baseQueryObject.getConditionMap().containsKey("name")?baseQueryObject.getConditionMap().get("name").replace("*",""):""; |
| | | String attrName = baseQueryObject.getConditionMap().containsKey("label") ? baseQueryObject.getConditionMap().get("label").replace("*","") : ""; |
| | | List<BtmTypeAttributeVO> boAttrs = null; |
| | | try { |
| | | boAttrs = btmTypeClient.getAllAttributeByBtmId(btmTypeId).getData().getAttributes(); |
| | | }catch (Exception e){ |
| | | throw new ServiceException("ä¸å¡ç±»åfeignæ¥å£è°ç¨é误"); |
| | | } |
| | | if(boAttrs == null){ |
| | | boAttrs = new ArrayList<>(); |
| | | } |
| | | if(BooleanEnum.TRUE.getValue().equalsIgnoreCase(hasDefaultAttr)){ |
| | | // TODO è·åé»è®¤ç屿§ |
| | | List<BtmTypeAttributeVO> finalBoAttrs = boAttrs; |
| | | BtmTypeVO btmTypeVO = btmTypeClient.getDefaultAttrByBtmId(btmTypeId).getData(); |
| | | btmTypeVO.getAttributes().stream().forEach(attr->{ |
| | | BtmTypeAttributeVO attributeVO = new BtmTypeAttributeVO(); |
| | | BeanUtil.convert(attr,attributeVO); |
| | | attributeVO.setAttributeLength(attr.getAttributeLength()); |
| | | attributeVO.setAttrDataType(attr.getAttrDataType()); |
| | | attributeVO.setReferBtmTypeId(attr.getBtmTypeId()); |
| | | attributeVO.setReferBtmTypeName(attr.getReferBtmTypeName()); |
| | | finalBoAttrs.add(attributeVO); |
| | | }); |
| | | boAttrs = finalBoAttrs; |
| | | } |
| | | List<BtmTypeAttributeVO> attrList = boAttrs.stream().filter(s->{ |
| | | boolean usedFlag = true; |
| | | if(StringUtils.isNotBlank(attrId) && !s.getId().contains(attrId.replace("*",""))){ |
| | | usedFlag = false; |
| | | } |
| | | if(StringUtils.isNotBlank(attrName) && !s.getName().contains(attrName.replace("*",""))){ |
| | | usedFlag = false; |
| | | } |
| | | return usedFlag; |
| | | }).collect(Collectors.toList()); |
| | | Page<BtmTypeAttributeVO> btmTypeAttributeVOPage = new Page<>(); |
| | | btmTypeAttributeVOPage.setRecords(attrList); |
| | | return btmTypeAttributeVOPage; |
| | | } |
| | | |
| | | |
| | | } |