| | |
| | | package com.vci.ubcs.code.applyjtcodeservice.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.vci.ubcs.code.applyjtcodeservice.vo.GroupAttrPoolMappingVO; |
| | | import com.vci.ubcs.code.entity.CodeClassify; |
| | | import com.vci.ubcs.code.feign.ICodeClassifyClient; |
| | | import com.vci.ubcs.code.applyjtcodeservice.entity.*; |
| | |
| | | import com.vci.ubcs.starter.web.util.VciBaseUtil; |
| | | import com.vci.ubcs.code.applyjtcodeservice.vo.DockingPreAttrMappingVO; |
| | | import com.vci.ubcs.code.applyjtcodeservice.vo.DockingPreAttrRangeVO; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /*** |
| | |
| | | * @date 2023-05-22 |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | | public class DockingPreAttrMappingServiceImpl extends ServiceImpl<DockingPreAttrMappingMapper, DockingPreAttrMapping> implements IDockingPreAttrMappingService { |
| | | |
| | | /*** |
| | |
| | | * 1.传递过来的有可能主数据模板新增属性,这样的需要添加,也有可能删除的属性,这样的映射需要删除 |
| | | * 也有更新的这样则更新 |
| | | */ |
| | | List<DockingPreAttrMapping> newDockingPreAttrMapping=new ArrayList<>(); |
| | | List<DockingPreAttrMapping> newDockingPreAttrMapping = new ArrayList<>(); |
| | | List<String>appingConfigOidList=new ArrayList<>(); |
| | | List<String>attrIdList=new ArrayList<>(); |
| | | List<String> attributeOidList=new ArrayList<>(); |
| | |
| | | return dockingPreAttrMappingVOList; |
| | | } |
| | | |
| | | /** |
| | | * 集团属性池映射数据同步导集团属性映射界面 |
| | | * @param groupAttrPoolMappings |
| | | * @return |
| | | */ |
| | | @Override |
| | | public R syncGroupAttrMapping(List<GroupAttrPoolMapping> groupAttrPoolMappings) { |
| | | log.info("开始集团属性池同步到集团属性映射配置表"); |
| | | List<String> groupAttrKeys = groupAttrPoolMappings.stream().map(GroupAttrPoolMapping::getGroupAttrKey).collect(Collectors.toList()); |
| | | List<DockingPreAttrMapping> dockingPreAttrMappings = dockingPreAttrMappingMapper.selectList( |
| | | Wrappers.<DockingPreAttrMapping>query() |
| | | .lambda().in(DockingPreAttrMapping::getSourceAttrKey,groupAttrKeys) |
| | | ); |
| | | // 属性映射配置表中不存在要同步的集团属性 |
| | | if(Func.isEmpty(dockingPreAttrMappings)){ |
| | | return R.fail(String.format("要同步的%s属性,在集团属性映射表中不存在!", JSON.toJSONString(groupAttrKeys))); |
| | | } |
| | | log.info(String.format("这些%s集团属性正在往集团属性映射表中同步。",JSON.toJSONString(groupAttrPoolMappings))); |
| | | Map<String, GroupAttrPoolMapping> syncTargetMap = new HashMap<>(); |
| | | // 准备要修改的比对参数 |
| | | groupAttrPoolMappings.stream().forEach(item->{ |
| | | syncTargetMap.put((item.getGroupAttrKey()+item.getGroupAttrName()).toLowerCase(Locale.ROOT),item); |
| | | }); |
| | | List<DockingPreAttrMapping> newGroupAttrPoolMappings = new ArrayList<>(); |
| | | //查找到更改就改变查询出来的数据进行修改。 |
| | | dockingPreAttrMappings.stream().forEach(item->{ |
| | | GroupAttrPoolMapping groupAttrPoolMapping = syncTargetMap.get((item.getSourceAttrKey()+item.getSourceAttrName()).toLowerCase(Locale.ROOT)); |
| | | if(Func.isNotEmpty(groupAttrPoolMapping)){ |
| | | DockingPreAttrMapping dockingPreAttrMapping = BeanUtil.copy(item, DockingPreAttrMapping.class); |
| | | dockingPreAttrMapping.setTargetAttrKey(groupAttrPoolMapping.getCodeMetaAttrKey()); |
| | | dockingPreAttrMapping.setTargetAttrName(groupAttrPoolMapping.getCodeMetaAttrName()); |
| | | newGroupAttrPoolMappings.add(dockingPreAttrMapping); |
| | | } |
| | | }); |
| | | boolean resBoolean = this.saveOrUpdateBatch(newGroupAttrPoolMappings); |
| | | log.info("集团属性池同步到集团属性映射配置表完成!"); |
| | | return resBoolean ? R.success("集团属性池同步到集团属性映射配置表成功!"):R.fail("同步过程中,修改集团属性映射表时失败!"); |
| | | } |
| | | |
| | | } |