From dfb9b1cc0b412334d0ab7891caac061a8243a0cb Mon Sep 17 00:00:00 2001 From: yuxc <653031404@qq.com> Date: 星期二, 06 六月 2023 17:03:30 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeReferBtmTypeServiceImpl.java | 113 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 113 insertions(+), 0 deletions(-) diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeReferBtmTypeServiceImpl.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeReferBtmTypeServiceImpl.java new file mode 100644 index 0000000..62b83ca --- /dev/null +++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeReferBtmTypeServiceImpl.java @@ -0,0 +1,113 @@ +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; + +/** + * 瀵筼md涓彁渚涚殑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; + } + + +} -- Gitblit v1.9.3