From c7bb59c8630c508e9b5d072f3e1526db83336a2c Mon Sep 17 00:00:00 2001
From: yuxc <653031404@qq.com>
Date: 星期一, 10 七月 2023 10:46:07 +0800
Subject: [PATCH] 1、查询按钮是修改判断为删除的逻辑
---
Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/service/impl/BtmTypeServiceImpl.java | 113 +++++++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 99 insertions(+), 14 deletions(-)
diff --git a/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/service/impl/BtmTypeServiceImpl.java b/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/service/impl/BtmTypeServiceImpl.java
index 3444498..a75265e 100644
--- a/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/service/impl/BtmTypeServiceImpl.java
+++ b/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/service/impl/BtmTypeServiceImpl.java
@@ -4,6 +4,7 @@
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.nacos.api.exception.NacosException;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.vci.ubcs.omd.constant.BtmTypeConstant;
@@ -110,7 +111,11 @@
@Override
public BtmTypeVO getBtmTypeByOid(String pkBtmType) throws ServiceException {
Func.requireNotNull(pkBtmType,"涓氬姟绫诲瀷涓婚敭涓嶈兘涓虹┖");
- BtmTypeVO btmTypeVO = BtmTypeWrapper.build().entityVO(baseMapper.selectOne(Wrappers.<BtmType>query().lambda().eq(BtmType::getOid, pkBtmType)));
+ BtmType queryBtmType = baseMapper.selectOne(Wrappers.<BtmType>query().lambda().eq(BtmType::getOid, pkBtmType));
+ if (queryBtmType == null){
+ return null;
+ }
+ BtmTypeVO btmTypeVO = BtmTypeWrapper.build().entityVO(queryBtmType);
btmTypeVO.setAttributes(btmTypeAttributeService.getAttributeByBtmTypeOid(pkBtmType));
return btmTypeVO;
}
@@ -383,7 +388,7 @@
ddlDTO.setBtmTypeList(btmTypeVOList);
try {
// 灏嗕互鍓嶇殑checkDifferent鍜宺eflexDifferent缁撳悎浜�
- R result = DomainRepeater.checkDifferent(ddlDTO,btmTypeVO.getDomain());
+ R result = DomainRepeater.checkDifferent(ddlDTO,btmTypeVO.getBizDomain());
if (result.isSuccess()){
List<ModifyAttributeInfo> infoList = new ArrayList<>();
Object data = result.getData();
@@ -490,12 +495,13 @@
}
checkBtmTypeBeforeSave(btmTypeDTO);
BtmType btmTypeDO = Optional.ofNullable(BeanUtil.copy(btmTypeDTO, BtmType.class)).orElseGet(BtmType::new);
+ btmTypeDO.setBizDomain(btmTypeDTO.getDomain());
List<BtmTypeLinkAttributesDTO> attributes = btmTypeDTO.getAttributes();
List<BtmTypeAttributeVO> afterAttributes;
if (StringUtils.isBlank(btmTypeDO.getOid())){
btmTypeDO = BtmTypeWrapper.build().entityBeforeInsert(btmTypeDO);
if (StringUtils.isBlank(btmTypeDO.getTableName())) {
- btmTypeDO.setTableName(getTableName(btmTypeDO.getId(),btmTypeDO.getDomain()));
+ btmTypeDO.setTableName(getTableName(btmTypeDO.getId(),btmTypeDO.getBizDomain()));
}
// 娣诲姞灞炴��
btmTypeDTO.setOid(btmTypeDO.getOid());
@@ -532,11 +538,13 @@
dataSourceTransactionManager.commit(transaction);
}else {
dataSourceTransactionManager.rollback(transaction);
+ return R.fail(result.getMsg());
}
}
} catch (Throwable e) {
if (autoCreateTable) {
dataSourceTransactionManager.rollback(transaction);
+ throw new VciBaseException(e.getMessage());
}
}
return R.data(btmTypeVO);
@@ -596,13 +604,12 @@
if (btmTypeDTO.isRevisionFlag()){
// 闇�瑕佹帶鍒剁増鏈�
// 妫�鏌ヤ娇鐢ㄧ殑鐗堟湰瑙勫垯鏄惁瀛樺湪
- if (StringUtils.isNotBlank(btmTypeDTO.getRevisionRuleId())) {
- if (revisionRuleService.checkRevisionRuleExist(btmTypeDTO.getRevisionRuleId())) {
- throw new VciBaseException("鐗堟湰瑙勫垯{0}[{1}]鍦ㄧ郴缁熶腑涓嶅瓨鍦紝璇峰厛鏌ヨ瘉",
- new Object[]{btmTypeDTO.getRevisionRuleId(), btmTypeDTO.getRevisionRuleName()});
- }
+ if (StringUtils.isNotBlank(btmTypeDTO.getRevisionRuleId())) {
+ if (!revisionRuleService.checkRevisionRuleExist(btmTypeDTO.getRevisionRuleId())) {
+ throw new VciBaseException("鐗堟湰瑙勫垯{0}[{1}]鍦ㄧ郴缁熶腑涓嶅瓨鍦紝璇峰厛鏌ヨ瘉",
+ new Object[]{btmTypeDTO.getRevisionRuleId(), btmTypeDTO.getRevisionRuleName()});
}
-// btmTypeDTO.setAttributes(addAttributeByFieldMap(btmTypeDTO.getAttributes(),BtmTypeFieldConstant.REVISION_MANAGE_FIELD_MAP));
+ }
}
if (btmTypeDTO.isLifeCycleFlag()){
// 闇�瑕佹帶鍒剁敓鍛藉懆鏈�
@@ -620,11 +627,9 @@
// new Object[]{btmTypeDTO.getSubLifeCycleId(), btmTypeDTO.getSubLifeCycleName()});
// }
// }
-// btmTypeDTO.setAttributes(addAttributeByFieldMap(btmTypeDTO.getAttributes(),BtmTypeFieldConstant.LIFECYCLE_MANAGE_FIELD_MAP));
}
if (btmTypeDTO.isSecretFlag()){
// 闇�瑕佹帶鍒跺瘑绾�
-// btmTypeDTO.setAttributes(addAttributeByFieldMap(btmTypeDTO.getAttributes(),BtmTypeFieldConstant.SECRET_MANAGE_FIELD_MAP));
}
}
@Override
@@ -645,9 +650,9 @@
@Override
public List<BtmTreeVO> treeDomain() {
try {
- Map<String, String> domain = Optional.ofNullable(DomainRepeater.getDomain()).orElseGet(ArrayList::new).stream().collect(Collectors.toMap(s -> s.getValue(), t -> t.getLabel()));
+ Map<String, String> domain = Optional.ofNullable(DomainRepeater.getDomain()).orElseGet(ArrayList::new).stream().collect(Collectors.toMap(DomainVO::getValue, DomainVO::getLabel));
List<BtmTypeVO> vos = BtmTypeWrapper.build().listEntityVO(baseMapper.selectAll());
- Map<String, List<BtmTypeVO>> domainMap = vos.stream().collect(Collectors.groupingBy(BtmTypeVO::getDomain));
+ Map<String, List<BtmTypeVO>> domainMap = vos.stream().sorted(Comparator.comparing(BtmTypeVO::getId)).collect(Collectors.groupingBy(BtmTypeVO::getBizDomain));
List<BtmTreeVO> treeList = new ArrayList<>();
domainMap.forEach((k,v)-> {
if (domain.containsKey(k)){
@@ -730,7 +735,7 @@
btmType.setCreator(user);
btmType.setBtmName(BtmTypeConstant.BTMTYPE);
btmType.setCreateTime(now);
- btmType.setDomain(domain);
+ btmType.setBizDomain(domain);
btmType.setLastModifyTime(now);
btmType.setLastModifier(user);
btmType.setName(dto.getDescription());
@@ -864,4 +869,84 @@
btmType.setAttributes(btmTypeAttributeService.getAllAttribute(btmType));
return btmType;
}
+
+ /**
+ * 鑾峰彇寮曠敤鏌愪釜鐢熷懡鍛ㄦ湡鐨勪笟鍔$被鍨�
+ *
+ * @param lifeId 鐢熷懡鍛ㄦ湡鐨勭紪鍙�
+ * @return 涓氬姟绫诲瀷鏄剧ず瀵硅薄
+ */
+ @Override
+ public List<BtmTypeVO> selectByLifeId(String lifeId) {
+ if(StringUtils.isBlank(lifeId)){
+ return new ArrayList<>();
+ }
+ LambdaQueryWrapper<BtmType> query = new LambdaQueryWrapper<BtmType>();
+ query.eq(BtmType::getLifeCycleId,lifeId);
+ return BtmTypeWrapper.build().listEntityVO(getBaseMapper().selectList(query));
+ }
+
+ /**
+ * 鑾峰彇寮曠敤鏌愪簺鐢熷懡鍛ㄦ湡鐨勪笟鍔$被鍨�
+ *
+ * @param lifeIds 鐢熷懡鍛ㄦ湡鐨勭紪鍙烽泦鍚�
+ * @return 涓氬姟绫诲瀷鏄剧ず瀵硅薄
+ */
+ @Override
+ public List<BtmTypeVO> selectByLifeIds(Collection<String> lifeIds) {
+ if(CollectionUtils.isEmpty(lifeIds)){
+ return new ArrayList<>();
+ }
+ List<BtmType> btmTypeList = new ArrayList<>();
+ VciBaseUtil.switchCollectionForOracleIn(lifeIds).stream().forEach(ids->{
+ LambdaQueryWrapper<BtmType> query = new LambdaQueryWrapper<BtmType>();
+ ids.stream().forEach(id->{
+ query.eq(BtmType::getLifeCycleId,id);
+ query.or();
+ });
+ query.eq(BtmType::getLifeCycleId,"-1");
+ btmTypeList.addAll(baseMapper.selectList(query));
+ });
+ return BtmTypeWrapper.build().listEntityVO(btmTypeList);
+ }
+
+ /**
+ * 缁熻寮曠敤鏌愪釜鐢熷懡鍛ㄦ湡鐨勪笟鍔$被鍨�
+ *
+ * @param lifeId 鐢熷懡鍛ㄦ湡鐨勭紪鍙�
+ * @return 涓暟
+ */
+ @Override
+ public Integer countByLifeId(String lifeId) {
+ if(StringUtils.isBlank(lifeId)){
+ return 0;
+ }
+ LambdaQueryWrapper<BtmType> query = new LambdaQueryWrapper<BtmType>();
+ query.eq(BtmType::getLifeCycleId,lifeId);
+ return baseMapper.selectCount(query).intValue();
+ }
+
+ /**
+ * 缁熻寮曠敤鏌愪簺鐢熷懡鍛ㄦ湡鐨勪笟鍔$被鍨�
+ *
+ * @param lifeIds 鐢熷懡鍛ㄦ湡鐨勭紪鍙烽泦鍚�
+ * @return 涓暟
+ */
+ @Override
+ public Integer countByLifeIds(Collection<String> lifeIds) {
+ if(CollectionUtils.isEmpty(lifeIds)){
+ return 0;
+ }
+ final Integer[] total = {0};
+ VciBaseUtil.switchCollectionForOracleIn(lifeIds).stream().forEach(ids->{
+ LambdaQueryWrapper<BtmType> query = new LambdaQueryWrapper<BtmType>();
+ ids.stream().forEach(id->{
+ query.eq(BtmType::getLifeCycleId,id);
+ query.or();
+ });
+ query.eq(BtmType::getLifeCycleId,"-1");
+ total[0] += baseMapper.selectCount(query).intValue();
+ });
+ return total[0];
+ }
}
--
Gitblit v1.9.3