| | |
| | | package com.vci.ubcs.code.applyjtcodeservice.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | |
| | | import com.vci.ubcs.code.applyjtcodeservice.wrapper.GroupAttrPoolMappingWrapper; |
| | | import com.vci.ubcs.code.feign.ICodeClassifyClient; |
| | | import com.vci.ubcs.code.vo.pagemodel.CodeClassifyTemplateAttrVO; |
| | | import com.vci.ubcs.omd.feign.IEnumClient; |
| | | import com.vci.ubcs.omd.vo.EnumVO; |
| | | import com.vci.ubcs.starter.util.DefaultAttrAssimtUtil; |
| | | import com.vci.ubcs.starter.util.MdmBtmTypeConstant; |
| | | import com.vci.ubcs.starter.util.UBCSCondition; |
| | | import com.vci.ubcs.starter.web.pagemodel.BladeQueryObject; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.Value; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.mp.support.Condition; |
| | |
| | | |
| | | import javax.sql.rowset.serial.SerialException; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | |
| | | private final IDockingPreAttrMappingService dockingPreAttrMappingService; |
| | | |
| | | private final IEnumClient enumClient; |
| | | |
| | | /** |
| | | * 查询全部集团属性池映射的属性 |
| | | * @param bladeQueryObject |
| | |
| | | @Override |
| | | public IPage<GroupAttrPoolMappingVO> getGroupAttrPoolALlList(BladeQueryObject bladeQueryObject) throws ServiceException { |
| | | QueryWrapper<GroupAttrPoolMapping> queryWrapper = UBCSCondition.getQueryWrapper(bladeQueryObject.getConditionMap(), GroupAttrPoolMapping.class); |
| | | IPage<GroupAttrPoolMapping> groupAttrPoolMappingIPage = this.groupAttrPoolMappingMapper.selectPage(Condition.getPage(bladeQueryObject.getQuery()), queryWrapper); |
| | | IPage<GroupAttrPoolMapping> groupAttrPoolMappingIPage = this.groupAttrPoolMappingMapper.selectPage(Condition.getPage(bladeQueryObject.getQuery().setDescs("groupAttrKey")), queryWrapper); |
| | | return GroupAttrPoolMappingWrapper.build().pageVO(groupAttrPoolMappingIPage); |
| | | } |
| | | |
| | |
| | | return true; |
| | | } |
| | | List<GroupAttrPoolMapping> groupAttrPoolMappings = new ArrayList<>(); |
| | | List<String> distinctListEnglishName = new ArrayList<>(); |
| | | List<String> distinctListChineseName = new ArrayList<>(); |
| | | Map<String,String> distinctMap = new HashMap<>(); |
| | | log.info("开始将集团属性同步到集团属性池中"); |
| | | // 将dockingPreMetaAttrList集合转换为集团属性池属性对象 |
| | | dockingPreMetaAttrList.stream().forEach(item->{ |
| | |
| | | groupAttrPoolMapping.setGroupAttrName(item.getChineseName()); |
| | | groupAttrPoolMappings.add(groupAttrPoolMapping); |
| | | // 去重查询条件集团属性英文名称 |
| | | distinctListEnglishName.add(item.getEnglishName()); |
| | | // 去重查询条件集团属性中文名称 |
| | | distinctListChineseName.add(item.getName()); |
| | | distinctMap.put(item.getEnglishName(),item.getChineseName()); |
| | | }); |
| | | // 构造查重sql(根据集团属性中文和英文作为一组查询条件) |
| | | LambdaQueryWrapper<GroupAttrPoolMapping> lambdaQueryWrapper = Wrappers.<GroupAttrPoolMapping>query().lambda(); |
| | | distinctMap.forEach((key, value)->{ |
| | | lambdaQueryWrapper.eq(GroupAttrPoolMapping::getGroupAttrKey,key).and(wrapper->wrapper.eq(GroupAttrPoolMapping::getGroupAttrName,value)).or(true); |
| | | }); |
| | | // 去重查询结果 |
| | | List<GroupAttrPoolMapping> dbGroupAttrPoolMappings = groupAttrPoolMappingMapper.selectList( |
| | | Wrappers.<GroupAttrPoolMapping>query() |
| | | .lambda().in(GroupAttrPoolMapping::getGroupAttrKey, distinctListEnglishName) |
| | | .in(GroupAttrPoolMapping::getGroupAttrName, distinctListChineseName) |
| | | ); |
| | | List<GroupAttrPoolMapping> dbGroupAttrPoolMappings = groupAttrPoolMappingMapper.selectList(lambdaQueryWrapper); |
| | | List<GroupAttrPoolMapping> newGroupAttrPoolMappings = null; |
| | | // 将已存在的集团属性从groupAttrPoolMappings中移除 |
| | | if(Func.isNotEmpty(dbGroupAttrPoolMappings)){ |
| | |
| | | return item; |
| | | }).collect(Collectors.toList()); |
| | | log.info("本次同步的数据为:"+ JSON.toJSONString(finalGroupAttrPoolMappings)); |
| | | boolean resBoolean = this.saveBatch(finalGroupAttrPoolMappings); |
| | | log.info("集团属性同步到集团属性池,同步完毕"); |
| | | return resBoolean; |
| | | try { |
| | | this.saveBatch(finalGroupAttrPoolMappings); |
| | | log.info("集团属性同步到集团属性池,同步完毕"); |
| | | return true; |
| | | }catch (Exception e){ |
| | | log.info("集团属性同步到集团属性池,同步失败!,原因:"+e.getMessage()); |
| | | throw new ServiceException("集团属性同步到集团属性池,同步失败!,原因:"+e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | List<GroupAttrPoolMapping> groupAttrPoolMappings = this.groupAttrPoolMappingMapper.selectList( |
| | | Wrappers.<GroupAttrPoolMapping>query().lambda().in(GroupAttrPoolMapping::getGroupAttrKey, groupKeyList) |
| | | ); |
| | | if(Func.isEmpty(groupAttrPoolMappings) && groupKeyList.size() == groupAttrPoolMappings.size()){ |
| | | if(Func.isEmpty(groupAttrPoolMappings) || groupKeyList.size() != groupAttrPoolMappings.size()){ |
| | | return R.fail("勾选的要同步的集团属性中有在库中不存在的数据,请刷新后重试!"); |
| | | } |
| | | return dockingPreAttrMappingService.syncGroupAttrMapping(groupAttrPoolMappings); |
| | | } |
| | | |
| | | /** |
| | | * 根据分类OID获取到模板再根据属性id获取到模板下的属性id的enum值,然后查询出枚举 |
| | | * @param groupAttrPoolMappingVOS |
| | | * @return |
| | | */ |
| | | @Override |
| | | public R getEnumAttrByClsOIdAndAttrId(GroupAttrPoolMappingVO groupAttrPoolMappingVOS) { |
| | | if(Func.isEmpty(groupAttrPoolMappingVOS.getClassifyId())){ |
| | | throw new ServiceException("必传参数分类oid不能为空!"); |
| | | } |
| | | if(Func.isEmpty(groupAttrPoolMappingVOS.getCodeMetaAttrKey())){ |
| | | throw new ServiceException("必传参数,模板属性id不能为空"); |
| | | } |
| | | // 根据分类oid查询所使用的模板和模板属性 |
| | | List<CodeClassifyTemplateAttrVO> attrVOS = codeClassifyClient.listCodeAttributeByClassId(groupAttrPoolMappingVOS.getClassifyId()); |
| | | // 筛选出模板属性中id等于codeMetaAttrKey的,并取出enumId |
| | | if(attrVOS.isEmpty()){ |
| | | return R.fail("当前分类所使用模板的模板属性中未查询到相关的属性配置,请排查模板配置是否正确。"); |
| | | } |
| | | List<CodeClassifyTemplateAttrVO> codeClassifyTemplateAttrVOS = attrVOS.stream().filter(item -> item.getId().equalsIgnoreCase(groupAttrPoolMappingVOS.getCodeMetaAttrKey())).collect(Collectors.toList()); |
| | | // 根据上一步取出的enumId调用枚举服务查询出枚举并返回 |
| | | String enumId = codeClassifyTemplateAttrVOS.get(0).getEnumId(); |
| | | if(Func.isBlank(enumId)){ |
| | | return R.fail("在系统中根据当前配置的模板属性未查询到关于枚举的配置,请排查元数据上是否存在枚举属性!"); |
| | | } |
| | | R<List<EnumVO>> list = enumClient.getList(enumId); |
| | | return R.data(list.getData()); |
| | | } |
| | | |
| | | } |