From 3ea117935f971b75b141fc92591c10ade8aa3c81 Mon Sep 17 00:00:00 2001
From: wangting <675591594@qq.com>
Date: 星期二, 18 七月 2023 16:39:56 +0800
Subject: [PATCH] 流程业务数据保存
---
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeRuleServiceImpl.java | 154 +++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 142 insertions(+), 12 deletions(-)
diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeRuleServiceImpl.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeRuleServiceImpl.java
index 64161fa..b0bb55c 100644
--- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeRuleServiceImpl.java
+++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeRuleServiceImpl.java
@@ -17,17 +17,17 @@
package com.vci.ubcs.code.service.impl;
import com.alibaba.cloud.commons.lang.StringUtils;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.github.yulichang.wrapper.MPJLambdaWrapper;
+import com.vci.ubcs.code.constant.FrameWorkDefaultValueConstant;
import com.vci.ubcs.code.constant.MdmBtmTypeConstant;
import com.vci.ubcs.code.dto.CodeBasicSecDTO;
import com.vci.ubcs.code.dto.CodeRuleDTO;
import com.vci.ubcs.code.entity.*;
+import com.vci.ubcs.code.enumpack.CodeSecTypeEnum;
import com.vci.ubcs.code.lifecycle.CodeRuleLC;
import com.vci.ubcs.code.mapper.CodeRuleMapper;
import com.vci.ubcs.code.mapper.CodeSerialValueMapper;
@@ -36,25 +36,29 @@
import com.vci.ubcs.code.service.ICodeBasicSecService;
import com.vci.ubcs.code.service.ICodeClassifyService;
import com.vci.ubcs.code.service.ICodeRuleService;
+import com.vci.ubcs.code.vo.pagemodel.CodeBasicSecVO;
import com.vci.ubcs.code.vo.pagemodel.CodeClassifyVO;
import com.vci.ubcs.code.vo.pagemodel.CodeRuleVO;
import com.vci.ubcs.code.wrapper.CodeClassifyWrapper;
import com.vci.ubcs.code.wrapper.CodeRuleWrapper;
+import com.vci.ubcs.omd.cache.EnumCache;
+import com.vci.ubcs.omd.enums.EnumEnum;
import com.vci.ubcs.starter.exception.VciBaseException;
import com.vci.ubcs.starter.revision.service.RevisionModelUtil;
import com.vci.ubcs.starter.util.DefaultAttrAssimtUtil;
import com.vci.ubcs.starter.util.UBCSCondition;
-import com.vci.ubcs.starter.web.pagemodel.BladeQueryObject;
-import com.vci.ubcs.starter.web.pagemodel.KeyValue;
+import com.vci.ubcs.starter.web.pagemodel.*;
import com.vci.ubcs.starter.web.util.BeanUtilForVCI;
import com.vci.ubcs.starter.web.util.VciBaseUtil;
import com.vci.ubcs.starter.web.util.WebUtil;
-import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.constant.BladeConstant;
import org.springblade.core.tool.utils.BeanUtil;
+import org.springblade.core.tool.utils.Func;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -63,6 +67,7 @@
import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;
+import java.util.stream.Stream;
import static com.vci.ubcs.code.constant.FrameWorkDefaultValueConstant.FRAMEWORK_RELEASE_EDITING;
import static com.vci.ubcs.code.constant.FrameWorkLangCodeConstant.DATA_OID_NOT_EXIST;
@@ -104,6 +109,11 @@
@Resource
private RevisionModelUtil revisionModelUtil;
+ @Value("${user-info.tenant-id}")
+ private String tenantId;
+ @Value("${user-info.id}")
+ private String userId;
+
/**
* 鍒嗛〉鏌ヨ
* @param query
@@ -112,6 +122,11 @@
*/
@Override
public IPage<CodeRuleVO> gridCodeRule(Query query, Map<String,Object> conidtionMap) {
+ //濡傛灉绛変簬鑷繁閰嶇疆鐨勭鐞嗙粍绉熸埛id鍜岀鐞嗙粍瓒呯璐﹀彿锛屽氨涓嶉渶瑕佹寜鐓ц鍒欐墍鏈夎�呮潵杩涜鏌ヨ
+ if(!(AuthUtil.getTenantId().equals(this.tenantId) && AuthUtil.getUserId().toString().equals(this.userId))){
+ // 鎸夌収瑙勫垯鎵�鏈夎�呮潵鏌ヨ
+ conidtionMap.put("owner",AuthUtil.getUserId());
+ }
IPage<CodeRule> codeRuleIPage = this.codeRuleMapper.selectPage(Condition.getPage(query), UBCSCondition.getQueryWrapper(conidtionMap, CodeRule.class));
//do杞瑅o鍚屾椂setLcStatusText鐢熷懡鍛ㄦ湡鍊硷紝骞跺寘瑁呮垚鍒嗛〉瀵硅薄杩斿洖
return CodeRuleWrapper.build().pageVO(codeRuleIPage);
@@ -125,14 +140,39 @@
* @throws VciBaseException 鍙傛暟涓虹┖锛屽敮涓�椤癸紝蹇呰緭椤逛笉閫氳繃鏃朵細鎶涘嚭寮傚父
*/
@Override
- public boolean addSave(CodeRuleDTO codeRuleDTO) throws VciBaseException {
+ public R addSave(CodeRuleDTO codeRuleDTO) throws VciBaseException {
VciBaseUtil.alertNotNull(codeRuleDTO, "闇�瑕佹坊鍔犵殑鏁版嵁瀵硅薄");
- //灏咲TO杞崲涓篋O
+ if(checkCodeRuleRepeat(codeRuleDTO)){
+ return R.fail("瑙勫垯缂栧彿宸插瓨鍦紒");
+ }
+ // 灏咲TO杞崲涓篋O
CodeRule codeRule = Objects.requireNonNull(BeanUtil.copy(codeRuleDTO, CodeRule.class));
+ // 濉厖榛樿鍊�
DefaultAttrAssimtUtil.addDefaultAttrAssimt(codeRule, MdmBtmTypeConstant.CODE_RULE);
codeRule.setLctid(CODE_RULE_LC);
codeRule.setLcStatus(FRAMEWORK_RELEASE_EDITING);
- return codeRuleMapper.insert(codeRule)>0;
+ return R.status(codeRuleMapper.insert(codeRule)>0);
+ }
+
+ /**
+ * 妫�鏌d缂栧彿鏄惁閲嶅
+ * @param codeRuleDTO 褰撳墠鍒ゆ柇鏄惁閲嶅鐨勫璞�
+ * @return 杩斿洖false琛ㄧず鏈噸澶�
+ */
+ @Override
+ public boolean checkCodeRuleRepeat(CodeRuleDTO codeRuleDTO){
+ List<CodeRule> codeRulesList = this.codeRuleMapper.selectList(Wrappers.<CodeRule>query().lambda().eq(CodeRule::getId, codeRuleDTO.getId()));
+ if(!codeRulesList.isEmpty()){
+ return codeRulesList.parallelStream().anyMatch(codeRule -> {
+ if(StringUtils.isNotBlank(codeRuleDTO.getOid())){
+ // 浠h〃鏄慨鏀�
+ return !codeRule.getOid().equals(codeRuleDTO.getOid());
+ }else {
+ return true;
+ }
+ });
+ }
+ return false;
}
/**
@@ -142,7 +182,7 @@
* @return true琛ㄧず鍙互缂栬緫鎴栧垹闄わ紝false琛ㄧず涓嶅彲浠�
*/
@Override
- public boolean checkEditDelStatus(String lcStatus) {
+ public boolean checkEditDelStatus(String lcStatus) throws VciBaseException {
if (CodeRuleLC.RELEASED.getValue().equals(lcStatus) || CodeRuleLC.DISABLED.getValue().equals(lcStatus)) {
return false;
}
@@ -157,16 +197,22 @@
* @throws VciBaseException 鍙傛暟涓虹┖锛屽敮涓�椤癸紝蹇呰緭椤逛笉閫氳繃鏃朵細鎶涘嚭寮傚父
*/
@Override
- public boolean editSave(CodeRuleDTO codeRuleDTO) throws VciBaseException{
+ public R editSave(CodeRuleDTO codeRuleDTO) throws VciBaseException{
VciBaseUtil.alertNotNull(codeRuleDTO, "鏁版嵁瀵硅薄", codeRuleDTO.getOid(), "涓绘暟鎹紪鐮佽鍒欎富閿�");
+ if(checkCodeRuleRepeat(codeRuleDTO)){
+ return R.fail("瑙勫垯缂栧彿宸插瓨鍦紒");
+ }
if (!checkEditDelStatus(codeRuleDTO.getLcStatus())) {
throw new VciBaseException("缂栫爜瑙勫垯宸插彂甯冿紝涓嶅厑璁哥紪杈戞垨鍒犻櫎");
}
//灏咲TO杞崲涓篋O
CodeRule codeRule = selectByOid(codeRuleDTO.getOid());
revisionModelUtil.copyFromDTOIgnore(codeRuleDTO, codeRule);
+ if(!codeRule.getOwner().equals(codeRuleDTO.getOwner())){
+ codeRule.setOwner(codeRuleDTO.getOwner());
+ }
DefaultAttrAssimtUtil.updateDefaultAttrAssimt(codeRule);
- return codeRuleMapper.updateById(codeRule)>0;
+ return R.status(codeRuleMapper.updateById(codeRule)>0);
}
/**
@@ -395,6 +441,9 @@
if (!CodeRuleLC.EDITING.getValue().equals(codeRuleDO.getLcStatus())) {
return R.fail("闈炵紪杈戠姸鎬佺殑缂栫爜瑙勫垯鏃犳硶鍙戝竷");
}
+ // 鍙戝竷鏃跺皢鐮佹绫诲瀷鎸夌収瀛楃涓插垎闅旂殑褰㈠紡鎷兼帴骞跺瓨鍌�
+ String secTypeStr = codeBasicSecService.listCodeBasicSecByRuleOid(codeRuleDO.getOid()).stream().map(CodeBasicSecVO::getSecType).collect(Collectors.joining(","));
+ codeRuleDO.setBasicSecTypes(secTypeStr);
count = codeRuleMapper.update(null,wrapper.set(CodeRule::getLcStatus, CodeRuleLC.RELEASED.getValue()));
} else {
return R.fail("鏆備笉鏀寔鐨勬搷浣滅被鍨�");
@@ -451,6 +500,86 @@
}
/**
+ * 妫�鏌ョ浉浼肩紪鐮佽鍒欙紝骞惰繑鍥炲搴旂殑缁撴灉
+ * @param oid 涓婚敭
+ * @return 鎵ц缁撴灉
+ */
+ @Override
+ public R checkLikeCodeRule(String oid) throws VciBaseException {
+ // 1銆佹煡璇㈠嚭褰撳墠瑕佸彂甯冪殑瑙勫垯
+ CodeRuleVO codeRuleVO = getObjectHasSecByOid(oid);
+ // 褰撳墠鍙戝竷鐨勮鍒欎笉瀛樺湪鐮佹淇℃伅
+ if(Func.isEmpty(codeRuleVO.getSecVOList())){
+ return R.data(null);
+ }
+ // 2銆佹壘鍑轰笌褰撳墠鍙戝竷鐨勮鍒欑爜娈甸『搴忎竴鑷寸殑瑙勫垯
+ String secTypes = codeRuleVO.getSecVOList().stream().map(CodeBasicSecVO::getSecType).collect(Collectors.joining(","));
+ //鍏堟煡璇㈠嚭鎵�鏈夊凡鍙戝竷鐨勭紪鐮佽鍒�
+ List<CodeRule> codeRuleList = codeRuleMapper.selectList(Wrappers.<CodeRule>query().lambda().eq(CodeRule::getLcStatus, FrameWorkDefaultValueConstant.FRAMEWORK_RELEASE_RELEASED));
+ List<CodeRuleVO> codeRuleVOS = codeRuleDO2VOs(codeRuleList, true);
+ // 婊¤冻鐮佹绫诲瀷椤哄簭涓�鑷寸殑瑕佹眰鐨勭紪鐮佽鍒欙紝鍙互杩涘叆涓嬩竴姝ユ瘮杈冭鍒�
+ List<CodeRuleVO> codeRuleVOStream = codeRuleVOS.parallelStream().filter(item -> {
+ // 瀵笲asicSec浣跨敤orderNum鎺掑簭(鏌ヨ鐨勬椂鍊欏叾瀹炲凡缁忔帓杩囦竴娆″簭浜�)锛屽苟灏唖ecType鐢ㄩ�楀彿鍒嗛殧鎷兼帴鎴愪竴涓瓧绗︿覆
+ String itemSecTypes = item.getSecVOList().parallelStream().sorted(Comparator.comparing(CodeBasicSecVO::getOrderNum)).map(CodeBasicSecVO::getSecType).collect(Collectors.joining(","));
+ if (secTypes.equals(itemSecTypes)) {
+ return true;
+ }
+ return false;
+ }).collect(Collectors.toList());
+ // 3銆佸悇绫荤爜娈靛垎鍒繘琛屾瘮瀵�
+ codeRuleVOStream.parallelStream().filter(item->{
+ item.getSecVOList().stream().filter(basicSec->{
+ switch (basicSec.getSecType()){
+ // 灞炴�х爜娈碉紝姣斿灞炴�у拰灞炴�ф墍鍦ㄥ垎绫�(referCodeClassifyOid)
+ case "codeattrsec":
+ List<CodeBasicSecVO> codeattrsec = this.getBasicSecBySecType("codeattrsec", codeRuleVO);
+
+ break;
+ // 鍙彉鐮佹锛屾瘮瀵圭爜娈甸暱搴︼紝缂栫爜琛ヤ綅鏂瑰紡鍜岃ˉ浣嶆椂鐨勫瓧绗�
+ case "codevariablesec":
+ break;
+ // 鍥哄畾鐮佹姣斿鎸夊崌搴忔帓搴忕殑鐮佸�硷紝
+ case "codefixedsec":
+ break;
+ // 鍒嗙被鐮佹姣斿鎸夊崌搴忔帓搴忕爜鍊�
+ case "codeclassifysec":
+ break;
+ // 鏃ユ湡鐮佹姣斿鏃ユ湡鏍煎紡
+ case "codedatesec":
+ break;
+ // 寮曠敤鐮佹锛屾瘮瀵瑰弬鐓у簲鐢ㄧ殑涓氬姟绫诲瀷
+ case "coderefersec":
+ break;
+ // 灞傜骇鐮佹锛屾瘮瀵瑰眰绾х被鍨嬨�佸眰绾х殑鍊笺�佸瓧绗︽埅鍙栫被鍨嬨�佸彇鍊肩被鍨�
+ case "codelevelsec":
+ break;
+ case "codeserialsec":
+ // 娴佹按鐮佹姣斿鐮佹鐨勯暱搴�
+
+ break;
+ default:
+ return false;
+ }
+ return false;
+ });
+ return false;
+ });
+ // 鏈�鍚庡皢缁撴灉杩涜杩斿洖
+
+ return null;
+ }
+
+ private List<CodeBasicSecVO> getBasicSecBySecType(String secType,CodeRuleVO codeRuleVO){
+ List<CodeBasicSecVO> codeBasicSecVOList = codeRuleVO.getSecVOList().parallelStream().filter(item -> {
+ if (item.getSecType().equals(secType)) {
+ return true;
+ }
+ return false;
+ }).collect(Collectors.toList());
+ return codeBasicSecVOList;
+ }
+
+ /**
* 鎵归噺鏁版嵁瀵硅薄杞崲涓烘樉绀哄璞�
*
* @param codeRules 鏁版嵁瀵硅薄鍒楄〃
@@ -486,8 +615,9 @@
//濡傛灉鏈塴cstatus鐨勭被鐨勮瘽
vo.setLcStatusText(CodeRuleLC.getTextByValue(vo.getLcStatus()));
if (hasSec) {
+ List<CodeBasicSecVO> codeBasicSecVOS = codeBasicSecService.listCodeBasicSecByRuleOid(vo.getOid());
//鏌ヨ鐮佹
- vo.setSecVOList(codeBasicSecService.listCodeBasicSecByRuleOid(vo.getOid()));
+ vo.setSecVOList(codeBasicSecVOS);
}
}
return vo;
--
Gitblit v1.9.3