From dedbadd96ab7e1533572b25511fd201678c64dad Mon Sep 17 00:00:00 2001
From: ludc
Date: 星期四, 17 十月 2024 09:56:18 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
Source/UBCS/ubcs-service/ubcs-applyjtcodeservice/src/main/java/com/vci/ubcs/code/applyjtcodeservice/service/impl/GroupAttrPoolMappingServiceImpl.java | 118 +++++++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 91 insertions(+), 27 deletions(-)
diff --git a/Source/UBCS/ubcs-service/ubcs-applyjtcodeservice/src/main/java/com/vci/ubcs/code/applyjtcodeservice/service/impl/GroupAttrPoolMappingServiceImpl.java b/Source/UBCS/ubcs-service/ubcs-applyjtcodeservice/src/main/java/com/vci/ubcs/code/applyjtcodeservice/service/impl/GroupAttrPoolMappingServiceImpl.java
index 6593e75..b14bbb1 100644
--- a/Source/UBCS/ubcs-service/ubcs-applyjtcodeservice/src/main/java/com/vci/ubcs/code/applyjtcodeservice/service/impl/GroupAttrPoolMappingServiceImpl.java
+++ b/Source/UBCS/ubcs-service/ubcs-applyjtcodeservice/src/main/java/com/vci/ubcs/code/applyjtcodeservice/service/impl/GroupAttrPoolMappingServiceImpl.java
@@ -1,27 +1,38 @@
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.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.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 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.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@@ -43,16 +54,19 @@
private final IDockingPreAttrMappingService dockingPreAttrMappingService;
+ private final IEnumClient enumClient;
+
/**
* 鏌ヨ鍏ㄩ儴闆嗗洟灞炴�ф睜鏄犲皠鐨勫睘鎬�
- *
- * @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().setDescs("groupAttrKey")), queryWrapper);
+ return GroupAttrPoolMappingWrapper.build().pageVO(groupAttrPoolMappingIPage);
}
/**
@@ -98,14 +112,13 @@
* @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;
}
List<GroupAttrPoolMapping> groupAttrPoolMappings = new ArrayList<>();
- List<String> distinctListEnglishName = new ArrayList<>();
- List<String> distinctListChineseName = new ArrayList<>();
+ Map<String,String> distinctMap = new HashMap<>();
log.info("寮�濮嬪皢闆嗗洟灞炴�у悓姝ュ埌闆嗗洟灞炴�ф睜涓�");
// 灏哾ockingPreMetaAttrList闆嗗悎杞崲涓洪泦鍥㈠睘鎬ф睜灞炴�у璞�
dockingPreMetaAttrList.stream().forEach(item->{
@@ -114,29 +127,40 @@
groupAttrPoolMapping.setGroupAttrName(item.getChineseName());
groupAttrPoolMappings.add(groupAttrPoolMapping);
// 鍘婚噸鏌ヨ鏉′欢闆嗗洟灞炴�ц嫳鏂囧悕绉�
- distinctListEnglishName.add(item.getEnglishName());
- // 鍘婚噸鏌ヨ鏉′欢闆嗗洟灞炴�т腑鏂囧悕绉�
- distinctListChineseName.add(item.getName());
+ distinctMap.put(item.getEnglishName(),item.getChineseName());
+ });
+ // 鏋勯�犳煡閲峴ql锛堟牴鎹泦鍥㈠睘鎬т腑鏂囧拰鑻辨枃浣滀负涓�缁勬煡璇㈡潯浠讹級
+ 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> finalGroupAttrPoolMappings = null;
+ List<GroupAttrPoolMapping> dbGroupAttrPoolMappings = groupAttrPoolMappingMapper.selectList(lambdaQueryWrapper);
+ 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;
}
- boolean resBoolean = this.saveBatch(finalGroupAttrPoolMappings);
- log.info("闆嗗洟灞炴�у悓姝ュ埌闆嗗洟灞炴�ф睜,鍚屾瀹屾瘯");
- return resBoolean;
+ List<GroupAttrPoolMapping> finalGroupAttrPoolMappings = newGroupAttrPoolMappings.stream().map(item -> {
+ DefaultAttrAssimtUtil.addDefaultAttrAssimt(item, MdmBtmTypeConstant.GROUP_ATTR_POOL);
+ return item;
+ }).collect(Collectors.toList());
+ log.info("鏈鍚屾鐨勬暟鎹负锛�"+ JSON.toJSONString(finalGroupAttrPoolMappings));
+ try {
+ this.saveBatch(finalGroupAttrPoolMappings);
+ log.info("闆嗗洟灞炴�у悓姝ュ埌闆嗗洟灞炴�ф睜,鍚屾瀹屾瘯");
+ return true;
+ }catch (Exception e){
+ log.info("闆嗗洟灞炴�у悓姝ュ埌闆嗗洟灞炴�ф睜,鍚屾澶辫触锛侊紝鍘熷洜锛�"+e.getMessage());
+ throw new ServiceException("闆嗗洟灞炴�у悓姝ュ埌闆嗗洟灞炴�ф睜,鍚屾澶辫触锛侊紝鍘熷洜锛�"+e.getMessage());
+ }
}
/**
@@ -146,12 +170,16 @@
* @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);
}
/**
@@ -161,8 +189,44 @@
* @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);
+ }
+
+ /**
+ * 鏍规嵁鍒嗙被OID鑾峰彇鍒版ā鏉垮啀鏍规嵁灞炴�d鑾峰彇鍒版ā鏉夸笅鐨勫睘鎬d鐨別num鍊硷紝鐒跺悗鏌ヨ鍑烘灇涓�
+ * @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("蹇呬紶鍙傛暟锛屾ā鏉垮睘鎬d涓嶈兘涓虹┖");
+ }
+ // 鏍规嵁鍒嗙被oid鏌ヨ鎵�浣跨敤鐨勬ā鏉垮拰妯℃澘灞炴��
+ List<CodeClassifyTemplateAttrVO> attrVOS = codeClassifyClient.listCodeAttributeByClassId(groupAttrPoolMappingVOS.getClassifyId());
+ // 绛涢�夊嚭妯℃澘灞炴�т腑id绛変簬codeMetaAttrKey鐨勶紝骞跺彇鍑篹numId
+ 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());
}
}
--
Gitblit v1.9.3