From d02571d59633367ac76b7f58ab38584698b1aa1b Mon Sep 17 00:00:00 2001
From: ludc
Date: 星期四, 17 十月 2024 09:55:37 +0800
Subject: [PATCH] 高级查询中增加范围查询功能
---
Source/UBCS/ubcs-service/ubcs-applyjtcodeservice/src/main/java/com/vci/ubcs/code/applyjtcodeservice/service/impl/GroupAttrPoolMappingServiceImpl.java | 70 +++++++++++++++++++++++++++-------
1 files changed, 55 insertions(+), 15 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 db69aa6..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,6 +1,7 @@
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;
@@ -14,11 +15,14 @@
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;
@@ -28,7 +32,9 @@
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;
/**
@@ -48,6 +54,8 @@
private final IDockingPreAttrMappingService dockingPreAttrMappingService;
+ private final IEnumClient enumClient;
+
/**
* 鏌ヨ鍏ㄩ儴闆嗗洟灞炴�ф睜鏄犲皠鐨勫睘鎬�
* @param bladeQueryObject
@@ -57,7 +65,7 @@
@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);
}
@@ -110,8 +118,7 @@
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->{
@@ -120,16 +127,15 @@
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> dbGroupAttrPoolMappings = groupAttrPoolMappingMapper.selectList(lambdaQueryWrapper);
List<GroupAttrPoolMapping> newGroupAttrPoolMappings = null;
// 灏嗗凡瀛樺湪鐨勯泦鍥㈠睘鎬т粠groupAttrPoolMappings涓Щ闄�
if(Func.isNotEmpty(dbGroupAttrPoolMappings)){
@@ -147,9 +153,14 @@
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());
+ }
}
/**
@@ -183,10 +194,39 @@
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鑾峰彇鍒版ā鏉垮啀鏍规嵁灞炴�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