| | |
| | | package com.vci.ubcs.code.applyjtcodeservice.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.vci.ubcs.code.applyjtcodeservice.entity.DockingPreAttrRange; |
| | | import com.vci.ubcs.code.applyjtcodeservice.entity.DockingPreMetaAttr; |
| | | import com.vci.ubcs.code.applyjtcodeservice.entity.GroupAttrPoolMapping; |
| | | import com.vci.ubcs.code.applyjtcodeservice.mapper.GroupAttrPoolMappingMapper; |
| | | import com.vci.ubcs.code.applyjtcodeservice.service.IDockingPreAttrMappingService; |
| | | import com.vci.ubcs.code.applyjtcodeservice.service.IGroupAttrPoolMappingService; |
| | | import com.vci.ubcs.code.applyjtcodeservice.service.IGroupMdmInterService; |
| | | import com.vci.ubcs.code.applyjtcodeservice.vo.GroupAttrPoolMappingVO; |
| | | 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.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.extern.slf4j.Slf4j; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | import javax.sql.rowset.serial.SerialException; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | |
| | | /** |
| | | * 查询全部集团属性池映射的属性 |
| | | * |
| | | * @param GroupAttrPoolMappingVO |
| | | * @param bladeQueryObject |
| | | * @return |
| | | * @throws SerialException |
| | | */ |
| | | @Override |
| | | public List<GroupAttrPoolMappingVO> getGroupAttrPoolALlList(GroupAttrPoolMappingVO GroupAttrPoolMappingVO) throws SerialException { |
| | | List<GroupAttrPoolMapping> groupAttrPoolMappings = groupAttrPoolMappingMapper.selectList(null); |
| | | return GroupAttrPoolMappingWrapper.build().entityVOs(groupAttrPoolMappings); |
| | | 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); |
| | | return GroupAttrPoolMappingWrapper.build().pageVO(groupAttrPoolMappingIPage); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @throws SerialException |
| | | */ |
| | | @Override |
| | | public boolean saveDistinctGroupAttr(List<DockingPreMetaAttr> dockingPreMetaAttrList) throws SerialException { |
| | | public boolean saveDistinctGroupAttr(List<DockingPreMetaAttr> dockingPreMetaAttrList) throws ServiceException { |
| | | // 为空直接返回 |
| | | if(Func.isEmpty(dockingPreMetaAttrList)){ |
| | | return true; |
| | |
| | | .lambda().in(GroupAttrPoolMapping::getGroupAttrKey, distinctListEnglishName) |
| | | .in(GroupAttrPoolMapping::getGroupAttrName, distinctListChineseName) |
| | | ); |
| | | List<GroupAttrPoolMapping> finalGroupAttrPoolMappings = null; |
| | | List<GroupAttrPoolMapping> newGroupAttrPoolMappings = null; |
| | | // 将已存在的集团属性从groupAttrPoolMappings中移除 |
| | | if(Func.isNotEmpty(dbGroupAttrPoolMappings)){ |
| | | finalGroupAttrPoolMappings = groupAttrPoolMappings.stream() |
| | | newGroupAttrPoolMappings = groupAttrPoolMappings.stream() |
| | | .filter(mapping -> !dbGroupAttrPoolMappings.stream() |
| | | .map(GroupAttrPoolMapping::getGroupAttrKey) |
| | | .collect(Collectors.toList()) |
| | | .contains(mapping.getGroupAttrKey())) |
| | | .collect(Collectors.toList()); |
| | | }else{ |
| | | newGroupAttrPoolMappings = groupAttrPoolMappings; |
| | | } |
| | | List<GroupAttrPoolMapping> finalGroupAttrPoolMappings = newGroupAttrPoolMappings.stream().map(item -> { |
| | | DefaultAttrAssimtUtil.addDefaultAttrAssimt(item, MdmBtmTypeConstant.GROUP_ATTR_POOL); |
| | | return item; |
| | | }).collect(Collectors.toList()); |
| | | log.info("本次同步的数据为:"+ JSON.toJSONString(finalGroupAttrPoolMappings)); |
| | | boolean resBoolean = this.saveBatch(finalGroupAttrPoolMappings); |
| | | log.info("集团属性同步到集团属性池,同步完毕"); |
| | | return resBoolean; |
| | |
| | | * @throws SerialException |
| | | */ |
| | | @Override |
| | | public boolean editGroupAttr(List<GroupAttrPoolMappingVO> groupAttrPoolMappingVO) throws SerialException { |
| | | public boolean editGroupAttr(List<GroupAttrPoolMappingVO> groupAttrPoolMappingVO) throws ServiceException { |
| | | if(Func.isEmpty(groupAttrPoolMappingVO)){ |
| | | return true; |
| | | } |
| | | List<GroupAttrPoolMapping> groupAttrPoolMappings = GroupAttrPoolMappingWrapper.build().VOsEntity(groupAttrPoolMappingVO); |
| | | return this.updateBatchById(groupAttrPoolMappings); |
| | | List<GroupAttrPoolMapping> finalGroupAttrPoolMappings = groupAttrPoolMappings.stream().map(item -> { |
| | | DefaultAttrAssimtUtil.updateDefaultAttrAssimt(item); |
| | | return item; |
| | | }).collect(Collectors.toList()); |
| | | return this.updateBatchById(finalGroupAttrPoolMappings); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @throws SerialException |
| | | */ |
| | | @Override |
| | | public boolean syncGroupAttrMapping(List<GroupAttrPoolMappingVO> groupAttrPoolMappingVOS) throws SerialException { |
| | | return dockingPreAttrMappingService.syncGroupAttrMapping(groupAttrPoolMappingVOS); |
| | | public R syncGroupAttrMapping(List<GroupAttrPoolMappingVO> groupAttrPoolMappingVOS) throws ServiceException { |
| | | List<String> groupKeyList = groupAttrPoolMappingVOS.stream().map(GroupAttrPoolMappingVO::getGroupAttrKey).collect(Collectors.toList()); |
| | | List<GroupAttrPoolMapping> groupAttrPoolMappings = this.groupAttrPoolMappingMapper.selectList( |
| | | Wrappers.<GroupAttrPoolMapping>query().lambda().in(GroupAttrPoolMapping::getGroupAttrKey, groupKeyList) |
| | | ); |
| | | if(Func.isEmpty(groupAttrPoolMappings) && groupKeyList.size() == groupAttrPoolMappings.size()){ |
| | | return R.fail("勾选的要同步的集团属性中有在库中不存在的数据,请刷新后重试!"); |
| | | } |
| | | return dockingPreAttrMappingService.syncGroupAttrMapping(groupAttrPoolMappings); |
| | | } |
| | | |
| | | } |