From 744171debef6aee198be296520f0b86dc1586723 Mon Sep 17 00:00:00 2001
From: ludc
Date: 星期三, 02 八月 2023 20:02:08 +0800
Subject: [PATCH] 提交代码

---
 Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeBasicSecServiceImpl.java |  268 ++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 194 insertions(+), 74 deletions(-)

diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeBasicSecServiceImpl.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeBasicSecServiceImpl.java
index ed02a92..c19a4ca 100644
--- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeBasicSecServiceImpl.java
+++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeBasicSecServiceImpl.java
@@ -2,43 +2,43 @@
 
 import com.alibaba.cloud.commons.lang.StringUtils;
 import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 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.MdmBtmTypeConstant;
 import com.vci.ubcs.code.dto.CodeBasicSecDTO;
-import com.vci.ubcs.code.entity.CodeBasicSec;
-import com.vci.ubcs.code.entity.CodeClassifyValue;
-import com.vci.ubcs.code.entity.CodeFixedValue;
+import com.vci.ubcs.code.entity.*;
 import com.vci.ubcs.code.enumpack.*;
 import com.vci.ubcs.code.lifecycle.CodeRuleLC;
 import com.vci.ubcs.code.mapper.CodeBasicSecMapper;
 import com.vci.ubcs.code.mapper.CodeClassifyValueMapper;
 import com.vci.ubcs.code.mapper.CodeFixedValueMapper;
-import com.vci.ubcs.code.service.ICodeBasicSecService;
-import com.vci.ubcs.code.service.ICodeClassifyValueService;
-import com.vci.ubcs.code.service.ICodeFixedValueService;
-import com.vci.ubcs.code.service.ICodeRuleService;
-import com.vci.ubcs.code.vo.pagemodel.CodeBasicSecVO;
-import com.vci.ubcs.code.vo.pagemodel.CodeFixedValueVO;
-import com.vci.ubcs.code.vo.pagemodel.CodeRuleVO;
+import com.vci.ubcs.code.service.*;
+import com.vci.ubcs.code.vo.CodeReferConfigVO;
+import com.vci.ubcs.code.vo.pagemodel.*;
 import com.vci.ubcs.code.wrapper.CodeBasicSecWrapper;
+import com.vci.ubcs.omd.cache.EnumCache;
+import com.vci.ubcs.omd.enums.EnumEnum;
+import com.vci.ubcs.starter.enumpack.CodeTableNameEnum;
 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.util.UBCSSqlKeyword;
 import com.vci.ubcs.starter.web.enumpck.OsCodeFillTypeEnum;
-import com.vci.ubcs.starter.web.pagemodel.KeyValue;
-import com.vci.ubcs.starter.web.pagemodel.UIFormReferVO;
+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 com.vci.ubcs.system.entity.DictBiz;
 import com.vci.ubcs.system.feign.IDictBizClient;
-import org.springblade.core.secure.utils.AuthUtil;
+import org.springblade.core.log.exception.ServiceException;
+import org.springblade.core.mp.support.Query;
 import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.BeanUtil;
 import org.springblade.core.tool.utils.Func;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -85,6 +85,9 @@
 	private ICodeClassifyValueService codeClassifyValueService;
 
 	@Resource
+	private ICodeReferConfigService codeReferConfigService;
+
+	@Resource
 	private IDictBizClient iDictBizClient;
 
 	/**
@@ -105,19 +108,27 @@
 
 	/**
 	 * 鏌ヨ鎵�鏈夌殑鐮佹鍩虹淇℃伅
-	 *
-	 * @param page 鏌ヨ鏉′欢
-	 * @param codeBasicSecVO   鍒嗛〉鍜屾帓搴�
+	 * @param conditionMap 鏌ヨ鏉′欢
+	 * @param query 鍒嗛〉瀵硅薄
 	 * @return 鎵ц缁撴灉
 	 * @throws VciBaseException 鏌ヨ鏉′欢鍜屽垎椤靛嚭閿欑殑鏃跺�欎細鎶涘嚭寮傚父
 	 */
 	@Override
-	public IPage<CodeBasicSecVO> gridCodeBasicSec(IPage<CodeBasicSecVO> page, CodeBasicSecVO codeBasicSecVO) throws VciBaseException {
-		if(Func.isEmpty(codeBasicSecVO.getPkCodeRule()) || Func.isBlank(codeBasicSecVO.getPkCodeRule())){
+	public IPage<CodeBasicSecVO> gridCodeBasicSec(Query query, Map<String,Object> conditionMap) throws ServiceException {
+		if(Func.isEmpty(Func.isEmpty(conditionMap.get(CodeTableNameEnum.PL_CODE_BASICSEC.getText()+".pkCodeRule")))){
 			return null;
 		}
-		List<CodeBasicSec> codeBasicSecs = codeBasicSecMapper.selectCodeBasicSecPage(page, codeBasicSecVO);
-		return page.setRecords(CodeBasicSecWrapper.build().listVO(codeBasicSecs));
+		// 鑱旇〃鏌ヨ ,璁剧疆琛ㄥ埆鍚嶏紝琛ㄥ埆鍚嶉粯璁ゅ氨閲囩敤琛ㄥ悕灏忓啓锛岄厤缃珮绾ф煡璇㈢殑鏃跺�欏氨闇�瑕佹牴鎹繖涓潵瀵箇here鏉′欢杩涜閰嶇疆
+		MPJLambdaWrapper<CodeBasicSec> mpjLambdaWrapper = new MPJLambdaWrapper<>(CodeBasicSec.class, CodeTableNameEnum.PL_CODE_BASICSEC.getText())
+			.selectAll(CodeBasicSec.class)
+			.selectAs(CodeClassify::getName, CodeBasicSec::getReferCodeClassifyOidName)
+			.leftJoin(CodeClassify.class, CodeTableNameEnum.PL_CODE_CLASSIFY.getText(), CodeClassify::getOid, CodeBasicSec::getReferCodeClassifyOid)
+			.leftJoin(CodeBasicSec.class,CodeTableNameEnum.PL_CODE_BASICSEC.getText()+1,CodeBasicSec::getOid,CodeBasicSec::getParentClassifySecOid
+				,ext->ext.selectAs(CodeBasicSec::getName,CodeBasicSec::getParentClassifySecText));
+		// 娣诲姞where鏉′欢
+		UBCSSqlKeyword.buildConditionByAs(conditionMap,mpjLambdaWrapper,CodeTableNameEnum.PL_CODE_BASICSEC.getText());
+		IPage<CodeBasicSec> codeBasicSecIPage = codeBasicSecMapper.selectPage(UBCSCondition.getPage(query), mpjLambdaWrapper);
+		return CodeBasicSecWrapper.build().pageVO(codeBasicSecIPage);
 	}
 
 	/**
@@ -127,7 +138,7 @@
 	 */
 	@Override
 	@Transactional(rollbackFor = Exception.class)
-	public boolean batchDeleteSecByCodeRuleOid(String codeRuleOid) {
+	public boolean batchDeleteSecByCodeRuleOid(String codeRuleOid) throws ServiceException {
 		VciBaseUtil.alertNotNull(codeRuleOid,"缂栫爜瑙勫垯涓婚敭");
 		// 1銆侀�氳繃pkcoderule浣滀负鏉′欢锛屽厛鏌ヨ瑕佸垹闄ゅ熀纭�鐮佹
 		List<CodeBasicSec> deleteList = this.codeBasicSecMapper.selectList(Wrappers.<CodeBasicSec>query().eq("pkcoderule", codeRuleOid));
@@ -145,8 +156,10 @@
 			Set<String> fixedSecOidSet = fixedSecList.stream().map(CodeBasicSec::getOid).collect(Collectors.toSet());
 			// 閫氳繃澶栭敭杩涜鏌ヨ
 			List<CodeFixedValue> fixedValueS = fixedValueMapper.selectList(Wrappers.<CodeFixedValue>query().lambda().in(CodeFixedValue::getCodeFixedSecOid,fixedSecOidSet));
-			// 鏍规嵁鏌ヨ鍑烘潵鐨刬d鎵ц鍥哄畾鐮佹鎵ц鍒犻櫎
-			deletFlag = fixedValueMapper.deleteBatchIds(fixedValueS.stream().map(CodeFixedValue::getOid).collect(Collectors.toSet()))>0;
+			if(!fixedValueS.isEmpty()){
+				// 鏍规嵁鏌ヨ鍑烘潵鐨刬d鎵ц鍥哄畾鐮佹鎵ц鍒犻櫎
+				deletFlag = fixedValueMapper.deleteBatchIds(fixedValueS.stream().map(CodeFixedValue::getOid).collect(Collectors.toSet()))>0;
+			}
 		}
 		// 4銆佸啀鍒犻櫎鍒嗙被鐮佹
 		List<CodeBasicSec> classifySecList = deleteList.stream().filter(sec -> {
@@ -157,8 +170,10 @@
 			Set<String> classifySecOidSet = classifySecList.stream().map(CodeBasicSec::getOid).collect(Collectors.toSet());
 			// 閫氳繃澶栭敭杩涜鏌ヨ
 			List<CodeClassifyValue> fixedValueS = codeClassifyValueMapper.selectList(Wrappers.<CodeClassifyValue>query().lambda().in(CodeClassifyValue::getCodeClassifySecOid,classifySecOidSet));
-			// 鏍规嵁鏌ヨ鍑烘潵鐨勪富閿甶d鎵ц鍥哄畾鐮佹鎵ц鍒犻櫎
-			deletFlag = fixedValueMapper.deleteBatchIds(fixedValueS.stream().map(CodeClassifyValue::getOid).collect(Collectors.toSet()))>0;
+			if(!fixedValueS.isEmpty()){
+				// 鏍规嵁鏌ヨ鍑烘潵鐨勪富閿甶d鎵ц鍥哄畾鐮佹鎵ц鍒犻櫎
+				deletFlag = fixedValueMapper.deleteBatchIds(fixedValueS.stream().map(CodeClassifyValue::getOid).collect(Collectors.toSet()))>0;
+			}
 		}
 		return deletFlag;
 	}
@@ -170,7 +185,7 @@
 	 * @return 鏈夌┖鐨勫垯浼爇ey-灞炴�у悕 value-瀛楁鍚箟锛屾病鏈夌┖鐨勫垯浼� key-success value-true
 	 */
 	@Override
-	public KeyValue checkAttrNullableBySecType(CodeBasicSecDTO codeBasicSecDTO) {
+	public KeyValue checkAttrNullableBySecType(CodeBasicSecDTO codeBasicSecDTO) throws ServiceException {
 		VciBaseUtil.alertNotNull(codeBasicSecDTO.getSecType(), "鐮佹鍒嗙被");
 		String secType = codeBasicSecDTO.getSecType();
 		HashMap<String, String> attrMap = JSONObject.parseObject(JSONObject.toJSONString(codeBasicSecDTO), HashMap.class);
@@ -215,11 +230,11 @@
 		CodeBasicSec codeBasicSecDO = new CodeBasicSec();
 		BeanUtilForVCI.copyPropertiesIgnoreCase(codeBasicSecDTO, codeBasicSecDO);
 		//text杞崲
-		codeBasicSecDO.setSecTypeText(CodeSecTypeEnum.getTextByValue(codeBasicSecDTO.getSecType()));
-		codeBasicSecDO.setCodeLevelTypeText(CodeLevelTypeEnum.getTextByValue(codeBasicSecDTO.getCodeLevelType()));
-		codeBasicSecDO.setCodeSecLengthTypeText(CodeSecLengthTypeEnum.getTextByValue(codeBasicSecDTO.getCodeSecLengthType()));
-		codeBasicSecDO.setValueCutTypeText(CodeCutTypeEnum.getValueByText(codeBasicSecDTO.getValueCutType()));
-		codeBasicSecDO.setCodeGetValueTypeText(CodeGetValueTypeEnum.getValueByText(codeBasicSecDTO.getCodeGetValueType()));
+		codeBasicSecDO.setSecTypeText(EnumCache.getValue(EnumEnum.CODE_SEC_TYPE,codeBasicSecDTO.getSecType()));
+		codeBasicSecDO.setCodeLevelTypeText(EnumCache.getValue(EnumEnum.CODE_LEVEL_TYPE,codeBasicSecDTO.getCodeLevelType()));
+		codeBasicSecDO.setCodeSecLengthTypeText(EnumCache.getValue(EnumEnum.CODE_SEC_LENGTH,codeBasicSecDTO.getCodeSecLengthType()));
+		codeBasicSecDO.setValueCutTypeText(EnumCache.getValue(EnumEnum.CODE_CUT_TYPE,codeBasicSecDTO.getValueCutType()));
+		codeBasicSecDO.setCodeGetValueTypeText(EnumCache.getValue(EnumEnum.CODE_GET_VALUE_TYPE,codeBasicSecDTO.getCodeGetValueType()));
 		//濉厖涓�浜涢粯璁ゅ��
 		DefaultAttrAssimtUtil.addDefaultAttrAssimt(codeBasicSecDO,MdmBtmTypeConstant.CODE_BASIC_SEC);
 		//鎺掑簭鍙凤紝榛樿绛変簬褰撳墠宸叉湁鐨勬暟閲忓姞1
@@ -237,29 +252,82 @@
 			&& StringUtils.isBlank(codeBasicSecDO.getCodeFillSeparator())){
 			throw new VciBaseException("褰撹ˉ浣嶆柟寮忎负宸﹁ˉ浣嶆垨鑰呭彸琛ヤ綅鐨勬椂鍊欙紝琛ヤ綅瀛楃涓嶈兘涓虹┖");
 		}
+		CodeReferConfigVO codeReferConfigVO = null;
 		//寮曠敤鐮佹鐨勬椂鍊欙紝闇�瑕佸垽鏂弬鐓х殑淇℃伅鏄惁姝g‘
 		if(CodeSecTypeEnum.CODE_REFER_SEC.getValue().equalsIgnoreCase(codeBasicSecDO.getSecType())){
 			if(StringUtils.isBlank(codeBasicSecDO.getReferConfig())){
-				throw new VciBaseException("寮曠敤鐮佹鐨勬椂鍊欙紝闇�瑕佸~鍐� 鍙傜収閰嶇疆 鐨勫唴瀹�");
+				throw new VciBaseException("寮曠敤鐮佹鐨勬椂鍊欙紝闇�瑕佸~鍐� 鍙傜収閰嶇疆鐨勫唴瀹�");
 			}
 			try{
-				JSONObject.parseObject(codeBasicSecDO.getReferConfig(), UIFormReferVO.class);
+				//JSONObject.parseObject(codeBasicSecDO.getReferConfig(), UIFormReferVO.class);
+				codeReferConfigVO = JSONObject.parseObject(codeBasicSecDO.getReferConfig(), CodeReferConfigVO.class);
+				// 灏嗗弬鐓ч厤缃繘琛屾寔涔呭寲锛岀粰鐢ㄦ埛鎻愪緵鍙彲閫夋嫨鍙傜収閰嶇疆鐨勬柟寮�
 			}catch (Throwable e){
 				throw new VciBaseException("寮曠敤鐮佹鐨勬椂鍊欙紝鍙傜収閰嶇疆鐨勫唴瀹圭殑鏍煎紡涓嶆纭�,",new String[0],e);
+			}
+			// 鍒ゆ柇鏄惁涓哄紩鐢ㄧ爜娈碉紝濡傛灉鏄簲鐢ㄧ爜娈电殑璇濓紝涓轰簡閫傞厤鍓嶇缁勪欢锛岃繖閲岃瀵硅〃杩涜澶勭悊涓�涓嬶紝鎸夌収浠ュ墠鐨勫弬鐓ф牸寮忚繘琛岃浆鎹�
+			codeBasicSecDO.setReferValueInfo(referConfigToUIUiTable(codeReferConfigVO));
+			if(codeReferConfigVO.getIsPersistence()=="true"){
+				codeReferConfigService.insert(codeReferConfigVO);
 			}
 		}
 		boolean resBoolean = codeBasicSecMapper.insert(codeBasicSecDO) > 0;
 		//SessionInfo sessionInfo = VciBaseUtil.getCurrentUserSessionInfo();
 		if(StringUtils.isNotBlank(codeBasicSecDO.getCodeFillSeparator())){
 			DictBiz dictBiz = new DictBiz();
-			dictBiz.setCode(MdmBtmTypeConstant.CODE_BASIC_SEC);
-			dictBiz.setDictKey("codefileseparator");
+			dictBiz.setCode("codeFillSeparator");
+			dictBiz.setDictKey(codeBasicSecDO.getCodeFillSeparator());
 			dictBiz.setDictValue(codeBasicSecDO.getCodeFillSeparator());
 			//浠庡師鏉ョ殑charService锛堝彲杈撳彲閫夛級鏇存敼涓鸿皟鐢╫md涓殑鎺ュ彛鏉ュ疄鐜�
 			iDictBizClient.getCheck(dictBiz);
 			//charService.save(MdmBtmTypeConstant.CODE_BASIC_SEC,"codefileseparator",codeBasicSecDO.getCodeFillSeparator(),sessionInfo);
 		}
 		return resBoolean;
+	}
+
+	/**
+	 * 灏唕eferconfig杞崲涓篔SON鏍煎紡鐨刄IFormReferVO
+	 * @param codeReferConfig
+	 * @return
+	 */
+	private String referConfigToUIUiTable(CodeReferConfigVO codeReferConfig){
+		// 鎷疯礉涓轰互鍓嶇殑鑰佸璞�
+		UIReferConfigFormVO uiFormReferVO = new UIReferConfigFormVO();
+		BeanUtil.copy(codeReferConfig,uiFormReferVO);
+
+		// 琛ㄦ牸鐨勮嚜瀹氫箟瀹氫箟
+		UITableConfigVO uiTableConfigVO = new UITableConfigVO();
+		uiTableConfigVO.setPage(new UITablePageVO(codeReferConfig.getLimit(),1));
+		// 鍒楄〃鐨勫垪鐨勪俊鎭浆鎹�
+		List<TableColVO> uiTableFieldVOs = new ArrayList<>();
+		// 蹇�熸煡璇㈠垪
+		List<TableColVO> queryColumns = new ArrayList<>();
+		if(!CollectionUtils.isEmpty(codeReferConfig.getCodeShowFieldConfigVOS())){
+			codeReferConfig.getCodeShowFieldConfigVOS().stream().forEach(showField ->{
+				TableColVO tableColVO = new TableColVO();
+				BeanUtil.copy(showField,tableColVO);
+				tableColVO.setSortField(showField.getAttrSortField());
+				uiTableFieldVOs.add(tableColVO);
+				if(showField.getIsQuery().equals("true")){
+					queryColumns.add(tableColVO);
+				}
+			});
+		}
+		// 鏄剧ず鐨勫垪
+		uiTableConfigVO.setCols(uiTableFieldVOs);
+		// 蹇�熸煡璇㈠垪
+		uiTableConfigVO.setQueryColumns(queryColumns);
+		//set缁欒〃鏍奸厤缃睘鎬�
+		uiFormReferVO.setTableConfig(uiTableConfigVO);
+		// 绛涢�夋潯浠�
+		HashMap<String, String> whereMap = new HashMap<>();
+		if(!codeReferConfig.getCodeSrchCondConfigVOS().isEmpty()){
+			codeReferConfig.getCodeSrchCondConfigVOS().stream().forEach(srch->{
+				whereMap.put(srch.getFilterField()+srch.getFilterType(),srch.getFilterValue());
+			});
+		}
+		uiFormReferVO.setWhere(whereMap);
+		return JSONObject.toJSONString(uiFormReferVO);
 	}
 
 	/**
@@ -292,25 +360,31 @@
 				&& StringUtils.isBlank(codeBasicSecDO.getCodeFillSeparator())){
 				throw new VciBaseException("褰撹ˉ浣嶆柟寮忎负宸﹁ˉ浣嶆垨鑰呭彸琛ヤ綅鐨勬椂鍊欙紝琛ヤ綅瀛楃涓嶈兘涓虹┖");
 			}
+			CodeReferConfigVO codeReferConfigVO = null;
 			//寮曠敤鐮佹鐨勬椂鍊欙紝闇�瑕佸垽鏂弬鐓х殑淇℃伅鏄惁姝g‘
 			if(CodeSecTypeEnum.CODE_REFER_SEC.getValue().equalsIgnoreCase(codeBasicSecDO.getSecType())){
 				if(StringUtils.isBlank(codeBasicSecDO.getReferConfig())){
-					throw new VciBaseException("寮曠敤鐮佹鐨勬椂鍊欙紝闇�瑕佸~鍐� 鍙傜収閰嶇疆 鐨勫唴瀹�");
+					throw new VciBaseException("寮曠敤鐮佹鐨勬椂鍊欙紝闇�瑕佸~鍐欏弬鐓ч厤缃殑鍐呭");
 				}
 				try{
-					JSONObject.parseObject(codeBasicSecDO.getReferConfig(), UIFormReferVO.class);
+					// JSONObject.parseObject(codeBasicSecDO.getReferConfig(), UIFormReferVO.class);
+					codeReferConfigVO = JSONObject.parseObject(codeBasicSecDO.getReferConfig(), CodeReferConfigVO.class);
 				}catch (Throwable e){
 					throw new VciBaseException("寮曠敤鐮佹鐨勬椂鍊欙紝鍙傜収閰嶇疆鐨勫唴瀹圭殑鏍煎紡涓嶆纭�,",new String[0],e);
+				}
+				// 鍒ゆ柇鏄惁涓哄紩鐢ㄧ爜娈碉紝濡傛灉鏄簲鐢ㄧ爜娈电殑璇濓紝涓轰簡閫傞厤鍓嶇缁勪欢锛岃繖閲岃瀵硅〃杩涜澶勭悊涓�涓嬶紝鎸夌収浠ュ墠鐨勫弬鐓ф牸寮忚繘琛岃浆鎹�
+				codeBasicSecDO.setReferValueInfo(referConfigToUIUiTable(codeReferConfigVO));
+				if(codeReferConfigVO.getIsPersistence()=="true"){
+					codeReferConfigService.insert(codeReferConfigVO);
 				}
 			}
 			revisionModelUtil.copyFromDTOIgnore(codeBasicSecDTO, codeBasicSecDO);
 			resBoolean = codeBasicSecMapper.updateById(codeBasicSecDO)>0;
 			//SessionInfo sessionInfo = VciBaseUtil.getCurrentUserSessionInfo();
 			if(StringUtils.isNotBlank(codeBasicSecDO.getCodeFillSeparator())){
-				//杩欏効鐩墠闇�瑕佹敼 2023/4/24
 				DictBiz dictBiz = new DictBiz();
-				dictBiz.setCode(MdmBtmTypeConstant.CODE_BASIC_SEC);
-				dictBiz.setDictKey("codefileseparator");
+				dictBiz.setCode("codeFillSeparator");
+				dictBiz.setDictKey(codeBasicSecDO.getCodeFillSeparator());
 				dictBiz.setDictValue(codeBasicSecDO.getCodeFillSeparator());
 				//浠庡師鏉ョ殑charService锛堝彲杈撳彲閫夛級鏇存敼涓鸿皟鐢╫md涓殑鎺ュ彛鏉ュ疄鐜�
 				iDictBizClient.getCheck(dictBiz);
@@ -326,7 +400,7 @@
 	 * @param secType 鐮佹绫诲瀷
 	 * @return 涓嶅彲涓虹┖鐨勫瓧娈甸泦鍚�
 	 */
-	private Map<String, String> getNotNullableAttr(String secType) {
+	private Map<String, String> getNotNullableAttr(String secType) throws ServiceException {
 		Map<String, String> attrMap = new HashMap<>();
 		if (CodeSecTypeEnum.CODE_ATTR_SEC.getValue().equalsIgnoreCase(secType)) {
 			attrMap.put("name", "灞炴�х爜娈靛悕绉�");
@@ -442,29 +516,29 @@
 	/**
 	 * 鍙傜収鐮佹鍩虹淇℃伅鍒楄〃
 	 *
-	 * @param codeBasicSecVO 鏌ヨ鏉′欢
-	 * @param page   鍒嗛〉鍜屾帓搴�
+	 * @param conditionMap 鏌ヨ鏉′欢
+	 * @param query 鍒嗛〉鍜屾帓搴�
 	 * @return 鐮佹鍩虹淇℃伅鏄剧ず瀵硅薄鍒楄〃锛岀敓鏁堢殑鍐呭
 	 * @throws VciBaseException 鏌ヨ鏉′欢鍜屽垎椤靛嚭閿欑殑鏃跺�欎細鎶涘嚭寮傚父
 	 */
 	@Override
-	public IPage<CodeBasicSecVO> refDataGridCodeBasicSec(IPage<CodeBasicSecVO> page, CodeBasicSecVO codeBasicSecVO) throws VciBaseException {
-		return gridCodeBasicSec(page,codeBasicSecVO);
+	public IPage<CodeBasicSecVO> refDataGridCodeBasicSec(Query query ,Map<String,Object> conditionMap) throws VciBaseException {
+		return gridCodeBasicSec(query,conditionMap);
 	}
 
 	/**
 	 * 鍙傜収鍒嗙被鐨勭爜娈�
-	 * @param codeBasicSecVO 鏌ヨ鏉′欢
-	 * @param page 鍒嗛〉鐨勫璞�
+	 * @param conditionMap 鏌ヨ鏉′欢
+	 * @param query 鍒嗛〉鍜屾帓搴�
 	 * @return 鐮佹鐨勫唴瀹�
 	 */
 	@Override
-	public IPage<CodeBasicSecVO> refDataGridClassifySec(IPage<CodeBasicSecVO> page, CodeBasicSecVO codeBasicSecVO) throws VciBaseException {
-		if(Func.isEmpty(codeBasicSecVO.getPkCodeRule()) || Func.isBlank(codeBasicSecVO.getPkCodeRule())){
+	public IPage<CodeBasicSecVO> refDataGridClassifySec(Query query ,Map<String,Object> conditionMap) throws VciBaseException {
+		if(Func.isEmpty(conditionMap.get("pkCodeRule"))){
 			return null;
 		}
-		codeBasicSecVO.setSecType(CodeSecTypeEnum.CODE_CLASSIFY_SEC.getValue());
-		return refDataGridCodeBasicSec(page,codeBasicSecVO);
+		conditionMap.put("secType",(CodeSecTypeEnum.CODE_CLASSIFY_SEC.getValue()));
+		return refDataGridCodeBasicSec(query.setAscs("orderNum"),conditionMap);
 	}
 
 	/**
@@ -476,27 +550,30 @@
 	 */
 	@Override
 	@Transactional(rollbackFor = Exception.class)
-	public R cloneCodeBasicSec(List<String> oidList, String pkCodeRule) {
+	public R cloneCodeBasicSec(List<String> oidList, String pkCodeRule) throws ServiceException {
 		boolean isLinked = checkIsLinked(pkCodeRule,null);
 		if (isLinked) {
 			return R.fail("缂栫爜瑙勫垯宸茶寮曠敤锛屼笉鍏佽缂栬緫鎴栧垹闄�");
 		}
 		List<CodeBasicSec> createList = new ArrayList<>();
 		List<CodeBasicSec> basicSecDOS = codeBasicSecMapper.selectBatchIds(oidList);
+		if(basicSecDOS.isEmpty()){
+			return R.fail("鍏嬮殕鐨勭爜娈典俊鎭笉瀛樺湪锛�");
+		}
 		basicSecDOS.forEach(sec -> {
 			CodeBasicSec newSecDO = new CodeBasicSec();
 			BeanUtilForVCI.copyPropertiesIgnoreCase(sec,newSecDO);
-			newSecDO.setOid("");
-			newSecDO.setNameOid("");
-			newSecDO.setRevisionOid("");
+			newSecDO.setOid(VciBaseUtil.getPk());
+			newSecDO.setNameOid(VciBaseUtil.getPk());
+			newSecDO.setRevisionOid(VciBaseUtil.getPk());
 			newSecDO.setId(newSecDO.getId() + "_copy");
 			newSecDO.setName(newSecDO.getName() + "_copy");
 			newSecDO.setPkCodeRule(pkCodeRule);
 			createList.add(newSecDO);
 		});
-		boolean b = saveBatch(createList);
+		boolean resBoolean = saveBatch(createList);
 		//codeBasicSecMapper.insertBatch(createList);
-		return R.data(b,"鍏嬮殕鐮佹淇℃伅鎴愬姛");
+		return resBoolean ? R.data(resBoolean,"鍏嬮殕鐮佹淇℃伅鎴愬姛"):R.fail("鍏嬮殕鐮佹淇℃伅澶辫触锛�");
 	}
 
 	/**
@@ -540,7 +617,7 @@
 	 */
 	@Override
 	@Transactional(rollbackFor = Exception.class)
-	public boolean upOrderNum(String oid) {
+	public boolean upOrderNum(String oid) throws ServiceException{
 		CodeBasicSec secDO = selectByOid(oid);
 		if(secDO.getOrderNum() > 1){
 			//绛変簬1鐨勬椂鍊欎笉鑳戒笂绉讳簡
@@ -571,7 +648,7 @@
 	 */
 	@Override
 	@Transactional(rollbackFor = Exception.class)
-	public boolean downOrderNum(String oid) {
+	public boolean downOrderNum(String oid) throws ServiceException {
 		CodeBasicSec secDO = selectByOid(oid);
 		Long total = codeBasicSecMapper.selectCount(Wrappers.<CodeBasicSec>query()
 			.lambda().eq(CodeBasicSec::getPkCodeRule,secDO.getPkCodeRule())
@@ -603,7 +680,7 @@
 	 * @return
 	 */
 	@Override
-	public List<String> getOidByCodeclassifysecOid(String codeClassifySecOid) {
+	public List<String> getOidByCodeclassifysecOid(String codeClassifySecOid)throws ServiceException {
 		return codeBasicSecMapper.getOidByCodeclassifysecOid(codeClassifySecOid.trim());
 	}
 
@@ -675,7 +752,6 @@
 		return codeBasicSecDO;
 	}
 
-
 	/**
 	 * 浣跨敤瑙勫垯鐨勪富閿幏鍙栧搴旂殑鐮佹鍐呭
 	 *
@@ -683,17 +759,14 @@
 	 * @return 鐮佹鐨勫唴瀹�
 	 */
 	@Override
-	public List<CodeBasicSecVO> listCodeBasicSecByRuleOid(String ruleOid) {
+	public List<CodeBasicSecVO> listCodeBasicSecByRuleOid(String ruleOid)throws ServiceException {
 		if(StringUtils.isBlank(ruleOid)){
 			return new ArrayList<>();
 		}
-		Map<String,String> conditionMap = new HashMap<>();
-		conditionMap.put("pkCodeRule",ruleOid);
-//		PageHelper pageHelper = new PageHelper(-1);
-//		pageHelper.addDefaultAsc("ordernum");
-		QueryWrapper<CodeBasicSec> wrapper = new QueryWrapper<>();
-		wrapper.orderByAsc("ordernum");
-		List<CodeBasicSec> secDOList = codeBasicSecMapper.selectList(wrapper);//.selectByCondition(conditionMap, pageHelper);
+		LambdaQueryWrapper<CodeBasicSec> wrapper = Wrappers.<CodeBasicSec>query().lambda()
+			.eq(CodeBasicSec::getPkCodeRule, ruleOid)
+			.orderByAsc(CodeBasicSec::getOrderNum);
+		List<CodeBasicSec> secDOList = baseMapper.selectList(wrapper);//
 		return codeBasicSecDO2VOs(secDOList,true);
 	}
 
@@ -730,6 +803,27 @@
 	}
 
 	/**
+	 * 鎵归噺鏁版嵁瀵硅薄杞崲涓烘樉绀哄璞�
+	 *
+	 * @param codeBasicSecDOs 鏁版嵁瀵硅薄鍒楄〃
+	 * @return 鏄剧ず瀵硅薄
+	 * @throws VciBaseException 鍙傛暟涓虹┖鎴栬�呬笉瀛樺湪鐨勬椂鍊欎細鎶涘嚭寮傚父
+	 */
+	@Override
+	public List<CodeBasicSecVO> codeBasicSecDO2VOs(Collection<CodeBasicSec> codeBasicSecDOs) throws VciBaseException {
+		List<CodeBasicSecVO> voList = new ArrayList<CodeBasicSecVO>();
+		if (!CollectionUtils.isEmpty(codeBasicSecDOs)) {
+			for (CodeBasicSec s : codeBasicSecDOs) {
+				CodeBasicSecVO vo = codeBasicSecDO2VO(s);
+				if (vo != null) {
+					voList.add(vo);
+				}
+			}
+		}
+		return voList;
+	}
+
+	/**
 	 * 鏁版嵁瀵硅薄杞崲涓烘樉绀哄璞�
 	 *
 	 * @param codeBasicSecDO 鏁版嵁瀵硅薄
@@ -738,14 +832,40 @@
 	 */
 	@Override
 	public CodeBasicSecVO codeBasicSecDO2VO(CodeBasicSec codeBasicSecDO) throws VciBaseException {
-		CodeBasicSecVO vo = new CodeBasicSecVO();
+		CodeBasicSecVO codeBasicSecVO = new CodeBasicSecVO();
 		if (codeBasicSecDO != null) {
-			BeanUtilForVCI.copyPropertiesIgnoreCase(codeBasicSecDO, vo);
+			BeanUtilForVCI.copyPropertiesIgnoreCase(codeBasicSecDO, codeBasicSecVO);
+			if(StringUtils.isNotBlank(codeBasicSecDO.getSecType())){
+				codeBasicSecVO.setSecTypeText(EnumCache.getValue(EnumEnum.CODE_SEC_TYPE,codeBasicSecDO.getSecType()));
+			}
+			if(StringUtils.isNotBlank(codeBasicSecDO.getCodeLevelType())){
+				codeBasicSecVO.setCodeLevelTypeText(EnumCache.getValue(EnumEnum.CODE_LEVEL_TYPE,codeBasicSecDO.getCodeLevelType()));
+			}
+			if(StringUtils.isNotBlank(codeBasicSecDO.getCodeSecLengthType())){
+				codeBasicSecVO.setCodeSecLengthTypeText(EnumCache.getValue(EnumEnum.CODE_SEC_LENGTH,codeBasicSecDO.getCodeSecLengthType()));
+			}
+			if(StringUtils.isNotBlank(codeBasicSecDO.getValueCutType())){
+				codeBasicSecVO.setValueCutTypeText(EnumCache.getValue(EnumEnum.CODE_CUT_TYPE,codeBasicSecDO.getValueCutType()));
+			}
+			if(StringUtils.isNotBlank(codeBasicSecDO.getCodeGetValueType())){
+				codeBasicSecVO.setCodeGetValueTypeText(EnumCache.getValue(EnumEnum.CODE_GET_VALUE_TYPE,codeBasicSecDO.getCodeGetValueType()));
+			}
+			// 濡傛灉鏄垎绫荤爜娈甸渶瑕佹煡璇㈡墍灞炲垎绫荤殑涓枃鍚嶇О
+			if(codeBasicSecDO.getSecType().equals("codeclassifysec") && Func.isNotEmpty(codeBasicSecDO.getParentClassifySecOid())){
+				CodeBasicSec codeBasicSec = codeBasicSecMapper.selectOne(Wrappers.<CodeBasicSec>query().lambda()
+					.eq(CodeBasicSec::getOid, codeBasicSecDO.getParentClassifySecOid())
+					.eq(CodeBasicSec::getSecType, codeBasicSecDO.getSecType()));
+				if(Func.isNotEmpty(codeBasicSec)){
+					codeBasicSecVO.setParentClassifySecOid(codeBasicSec.getOid());
+					codeBasicSecVO.setParentClassifySecText(codeBasicSec.getName());
+				}
+			}
 			//濡傛灉鏈塴cstatus鐨勭被鐨勮瘽
 			if (true) {
 				//vo.setLcStatusText({lcStatusFullClassName}.getTextByValue(vo.getLcStatus()));
 			}
 		}
-		return vo;
+		return codeBasicSecVO;
 	}
+
 }

--
Gitblit v1.9.3