From 29ab7773efe351a879ce9b3c29ab3ca50f4e62cb Mon Sep 17 00:00:00 2001
From: xiejun <xiejun@vci-tech.com>
Date: 星期三, 15 一月 2025 21:36:08 +0800
Subject: [PATCH] 产品型号集成,类型转换,人员组织加日志,申请接口引用码段值校验

---
 Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeRuleServiceImpl.java | 1352 +++++++++++++++++++++++++++++++---------------------------
 1 files changed, 713 insertions(+), 639 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 0a10361..6381134 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
@@ -1,686 +1,760 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 搴勯獮 (smallchill@163.com)
+ */
 package com.vci.ubcs.code.service.impl;
 
-import com.vci.ubcs.code.constant.MdmBtmTypeConstant;
-import com.vci.ubcs.code.mapper.CodeBasicSecMapper;
-import com.vci.ubcs.code.mapper.CodeRuleMapper;
-import com.vci.ubcs.code.lifecycle.CodeRuleLC;
-import com.vci.ubcs.code.entity.CodeAllCodeDO;
-import com.vci.ubcs.code.entity.CodeBasicSecDO;
-import com.vci.ubcs.code.entity.CodeClassifyDO;
-import com.vci.ubcs.code.entity.CodeRuleDO;
-import com.vci.ubcs.code.service.CodeBasicSecServiceI;
-import com.vci.ubcs.code.service.CodeClassifyServiceI;
-import com.vci.ubcs.code.service.CodeRuleServiceI;
-import com.vci.corba.common.VCIError;
-import com.vci.starter.revision.service.RevisionModelUtil;
-import com.vci.starter.web.exception.VciBaseException;
-import com.vci.starter.web.pagemodel.BaseResult;
-import com.vci.starter.web.pagemodel.DataGrid;
-import com.vci.starter.web.pagemodel.KeyValue;
-import com.vci.starter.web.pagemodel.PageHelper;
-import com.vci.starter.web.util.BeanUtilForVCI;
-import com.vci.starter.web.util.VciBaseUtil;
-import com.vci.starter.web.wrapper.VciQueryWrapperForDO;
-import com.vci.web.pageModel.BatchCBO;
-import com.vci.web.service.WebBoServiceI;
-import com.vci.web.util.WebUtil;
-import org.apache.commons.lang.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+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.baomidou.mybatisplus.extension.toolkit.SqlHelper;
+import com.vci.ubcs.code.constant.FrameWorkDefaultValueConstant;
+
 import com.vci.ubcs.code.dto.CodeBasicSecDTO;
 import com.vci.ubcs.code.dto.CodeRuleDTO;
-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 org.springframework.beans.factory.annotation.Autowired;
+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;
+import com.vci.ubcs.code.mapper.CommonsMapper;
+import com.vci.ubcs.code.service.*;
+import com.vci.ubcs.code.vo.pagemodel.*;
+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.model.TreeQueryObject;
+import com.vci.ubcs.starter.revision.service.RevisionModelUtil;
+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.*;
+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.cache.NacosConfigCache;
+import com.vci.ubcs.system.entity.Strategy;
+import com.vci.ubcs.system.feign.ISysClient;
+import com.vci.ubcs.system.user.entity.User;
+import com.vci.ubcs.system.user.feign.IUserClient;
+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.IResultCode;
+import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.api.ResultCode;
+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;
 import org.springframework.util.CollectionUtils;
-import plm.bs.bom.clientobject.ClientBusinessObject;
-import plm.bs.bom.clientobject.ClientBusinessObjectOperation;
 
 import javax.annotation.Resource;
+import java.rmi.ServerException;
 import java.util.*;
 import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
-import static com.vci.frameworkcore.constant.FrameWorkBusLangCodeConstant.*;
+import static com.vci.ubcs.code.constant.FrameWorkDefaultValueConstant.FRAMEWORK_RELEASE_EDITING;
+import static com.vci.ubcs.code.constant.FrameWorkLangCodeConstant.DATA_OID_NOT_EXIST;
+import static com.vci.ubcs.code.constant.MdmLifeCycleConstant.CODE_RULE_LC;
 
 /**
- * 涓绘暟鎹紪鐮佽鍒欐湇鍔�
+ * 缂栫爜瑙勫垯 鏈嶅姟瀹炵幇绫�
  *
- * @author weidy
- * @date 2022-01-24
+ * @author ludc
+ * @since 2023-04-03
  */
 @Service
-public class CodeRuleServiceImpl implements CodeRuleServiceI {
+public class CodeRuleServiceImpl extends ServiceImpl<CodeRuleMapper, CodeRule> implements ICodeRuleService {
 
-    /**
-     * 鏃ュ織
-     */
-    private Logger logger = LoggerFactory.getLogger(getClass());
+	/**
+	 * 鏁版嵁鎿嶄綔灞�
+	 */
+	@Resource
+	private CodeRuleMapper codeRuleMapper;
+	@Resource
+	private CommonsMapper commonsMapper;
+	@Resource
+	private CodeSerialValueMapper codeSerialValueMapper;
 
-    /**
-     * 鏁版嵁鎿嶄綔灞�
-     */
-    @Resource
-    private CodeRuleMapper codeRuleMapper;
+	/**
+	 * 鍏朵粬鏈嶅姟灞�
+	 */
+	@Resource
+	@Lazy
+	private ICodeClassifyService codeClassifyServcie;
+	@Resource
+	private ICodeAllCodeService codeAllcodeService;
+	@Resource
+	private ICodeBasicSecService codeBasicSecService;
+	@Resource
+	private ICodeClassifyValueService iCodeClassifyValueService;
 
-    /**
-     * 涓氬姟绫诲瀷鎿嶄綔鐨勬湇鍔�
-     */
-    @Autowired
-    @Lazy
-	private WebBoServiceI boService;
+	/**
+	 * 瀵硅薄鐨勬搷浣�
+	 */
+	@Resource
+	private RevisionModelUtil revisionModelUtil;
 
-    /**
-     * 瀵硅薄鐨勬搷浣�
-     */
-    @Autowired
-    private RevisionModelUtil revisionModelUtil;
+	@Resource
+	private ICodeFixedValueService codeFixedValueService;
 
-    /**
-     * 涓婚搴撳垎绫绘暟鎹搷浣滃眰
-     */
-    @Autowired
-    private CodeClassifyServiceI codeClassifyService;
+	/**
+	 * 绯荤粺鏈嶅姟
+	 */
+	@Resource
+	private IUserClient userClient;
 
-    /**
-     * 鐮佹鍩虹淇℃伅鏈嶅姟
-     */
-    @Autowired
-    private CodeBasicSecServiceI codeBasicSecService;
+	/**
+	 * 鍒嗛〉鏌ヨ
+	 * @param query
+	 * @param conidtionMap
+	 * @return
+	 */
+	@Override
+	public IPage<CodeRuleVO> gridCodeRule(Query query, Map<String,Object> conidtionMap) throws VciBaseException {
+		//int i = 1 / 0;
+		//濡傛灉绛変簬鑷繁閰嶇疆鐨勭鐞嗙粍绉熸埛id鍜岀鐞嗙粍瓒呯璐﹀彿锛屽氨涓嶉渶瑕佹寜鐓ц鍒欐墍鏈夎�呮潵杩涜鏌ヨ
+		/*if(!(AuthUtil.getTenantId().equals(NacosConfigCache.getAdminUserInfo().getTenantId())
+			&& AuthUtil.getUserId().toString().equals(NacosConfigCache.getAdminUserInfo().getUserId().toString()))
+		){
+			// 鎸夌収瑙勫垯鎵�鏈夎�呮潵鏌ヨ
+			conidtionMap.put("owner",AuthUtil.getUserId().toString());
+		}*/
+		IPage<CodeRule> codeRuleIPage = this.codeRuleMapper.selectPage(Condition.getPage(query), UBCSCondition.getQueryWrapper(conidtionMap, CodeRule.class));
+		//do杞瑅o鍚屾椂setLcStatusText鐢熷懡鍛ㄦ湡鍊硷紝骞跺寘瑁呮垚鍒嗛〉瀵硅薄杩斿洖
+		return CodeRuleWrapper.build().pageVO(codeRuleIPage);
+	}
 
-    /**
-     * 鐮佹鍩虹淇℃伅鏁版嵁鎿嶄綔灞�
-     */
-    @Resource
-    private CodeBasicSecMapper codeBasicSecMapper;
+	/**
+	 * 澧炲姞涓绘暟鎹紪鐮佽鍒�
+	 *
+	 * @param codeRuleDTO 涓绘暟鎹紪鐮佽鍒欐暟鎹紶杈撳璞�
+	 * @return 鎵ц缁撴灉
+	 * @throws VciBaseException 鍙傛暟涓虹┖锛屽敮涓�椤癸紝蹇呰緭椤逛笉閫氳繃鏃朵細鎶涘嚭寮傚父
+	 */
+	@Override
+	public R addSave(CodeRuleDTO codeRuleDTO) throws VciBaseException {
+		VciBaseUtil.alertNotNull(codeRuleDTO, "闇�瑕佹坊鍔犵殑鏁版嵁瀵硅薄");
+		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);
+		codeRule.setOwnerText(AuthUtil.getUserAccount()+"("+AuthUtil.getNickName()+")");
+		return R.status(codeRuleMapper.insert(codeRule)>0);
+	}
 
+	/**
+	 * 妫�鏌d缂栧彿鏄惁閲嶅
+	 * @param codeRuleDTO 褰撳墠鍒ゆ柇鏄惁閲嶅鐨勫璞�
+	 * @return 杩斿洖false琛ㄧず鏈噸澶�
+	 */
+	@Override
+	public boolean checkCodeRuleRepeat(CodeRuleDTO codeRuleDTO)throws VciBaseException {
+		LambdaQueryWrapper<CodeRule> wrapper = Wrappers.<CodeRule>query()
+			.lambda().eq(CodeRule::getId, codeRuleDTO.getId());
+		if(AuthUtil.getTenantId().equals(NacosConfigCache.getAdminUserInfo().getTenantId())){
+			wrapper.eq(CodeRule::getTenantId,AuthUtil.getTenantId());
+		}
+		// 鏍规嵁瑙勫垯id鏌ヨ缂栧彿
+		List<CodeRule> codeRulesList = this.codeRuleMapper.selectList(wrapper);
+		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;
+	}
 
-    /**
-     * 鏌ヨ鎵�鏈夌殑涓绘暟鎹紪鐮佽鍒�
-     *
-     * @param conditionMap 鏌ヨ鏉′欢
-     * @param pageHelper   鍒嗛〉鍜屾帓搴�
-     * @return 鎵ц缁撴灉
-     * @throws VciBaseException 鏌ヨ鏉′欢鍜屽垎椤靛嚭閿欑殑鏃跺�欎細鎶涘嚭寮傚父
-     */
-    @Override
-    public DataGrid<CodeRuleVO> gridCodeRule(Map<String, String> conditionMap, PageHelper pageHelper) throws VciBaseException {
-        if (pageHelper == null) {
-            pageHelper = new PageHelper(-1);
-        }
-        pageHelper.addDefaultDesc("createTime");
-        List<CodeRuleDO> doList = codeRuleMapper.selectByCondition(conditionMap, pageHelper);
-        DataGrid<CodeRuleVO> dataGrid = new DataGrid<CodeRuleVO>();
-        if (!CollectionUtils.isEmpty(doList)) {
-            dataGrid.setData(codeRuleDO2VOs(doList));
-            dataGrid.setTotal(VciBaseUtil.getInt(String.valueOf(codeRuleMapper.countByCondition(conditionMap))));
-        }
-        return dataGrid;
-    }
+	/**
+	 * 鏍¢獙缂栫爜瑙勫垯鐨勭姸鎬佹槸鍚﹀彲浠ョ紪杈戞垨鍒犻櫎
+	 *
+	 * @param lcStatus 缂栫爜瑙勫垯
+	 * @return true琛ㄧず鍙互缂栬緫鎴栧垹闄わ紝false琛ㄧず涓嶅彲浠�
+	 */
+	@Override
+	public boolean checkEditDelStatus(String lcStatus) throws VciBaseException {
+		if (CodeRuleLC.RELEASED.getValue().equals(lcStatus) || CodeRuleLC.DISABLED.getValue().equals(lcStatus)) {
+			return false;
+		}
+		return true;
+	}
 
-    /**
-     * 鎵归噺鏁版嵁瀵硅薄杞崲涓烘樉绀哄璞�
-     *
-     * @param codeRuleDOs 鏁版嵁瀵硅薄鍒楄〃
-     * @return 鏄剧ず瀵硅薄
-     * @throws VciBaseException 鍙傛暟涓虹┖鎴栬�呬笉瀛樺湪鐨勬椂鍊欎細鎶涘嚭寮傚父
-     */
-    @Override
-    public List<CodeRuleVO> codeRuleDO2VOs(Collection<CodeRuleDO> codeRuleDOs) throws VciBaseException {
-        return codeRuleDO2VOs(codeRuleDOs, false);
-    }
+	/**
+	 * 淇敼涓绘暟鎹紪鐮佽鍒�
+	 *
+	 * @param codeRuleDTO 涓绘暟鎹紪鐮佽鍒欐暟鎹紶杈撳璞�
+	 * @return 鎵ц缁撴灉
+	 * @throws VciBaseException 鍙傛暟涓虹┖锛屽敮涓�椤癸紝蹇呰緭椤逛笉閫氳繃鏃朵細鎶涘嚭寮傚父
+	 */
+	@Override
+	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());
+			R<User> userR = userClient.userInfoById(Func.toLong(codeRuleDTO.getOwner()));
+			if(!userR.isSuccess() || Func.isEmpty(userR.getData())){
+				codeRule.setOwnerText(codeRuleDTO.getOwner());
+			}else{
+				codeRule.setOwnerText(userR.getData().getAccount()+"("+userR.getData().getRealName()+")");
+			}
+		}
+		DefaultAttrAssimtUtil.updateDefaultAttrAssimt(codeRule);
+		return R.status(codeRuleMapper.updateById(codeRule)>0);
+	}
 
-    /**
-     * 鎵归噺鏁版嵁瀵硅薄杞崲涓烘樉绀哄璞�
-     *
-     * @param codeRuleDOs 鏁版嵁瀵硅薄鍒楄〃
-     * @param hasSec      鏄惁鍖呭惈鐮佹
-     * @return 鏄剧ず瀵硅薄
-     * @throws VciBaseException 鍙傛暟涓虹┖鎴栬�呬笉瀛樺湪鐨勬椂鍊欎細鎶涘嚭寮傚父
-     */
-    @Override
-    public List<CodeRuleVO> codeRuleDO2VOs(Collection<CodeRuleDO> codeRuleDOs, boolean hasSec) throws VciBaseException {
-        List<CodeRuleVO> voList = new ArrayList<CodeRuleVO>();
-        if (!CollectionUtils.isEmpty(codeRuleDOs)) {
-            for (CodeRuleDO s : codeRuleDOs) {
-                CodeRuleVO vo = codeRuleDO2VO(s);
-                if (vo != null) {
-                    voList.add(vo);
-                }
-            }
-            if (hasSec) {
-                List<CodeBasicSecVO> secVOList = codeBasicSecService.listCodeBasicSecByRuleOids(voList.stream().map(CodeRuleVO::getOid).collect(Collectors.toList()));
-                if (!CollectionUtils.isEmpty(secVOList)) {
-                    Map<String, List<CodeBasicSecVO>> secVOMap = secVOList.stream().collect(Collectors.groupingBy(CodeBasicSecVO::getPkCodeRule));
-                    voList.stream().forEach(vo -> {
-                        vo.setSecVOList(secVOMap.getOrDefault(vo.getOid(), new ArrayList<>()));
-                    });
-                }
-            }
-        }
-        return voList;
-    }
+	/**
+	 * 鍒犻櫎涓绘暟鎹紪鐮佽鍒�
+	 *
+	 * @param codeRuleDTO 涓绘暟鎹紪鐮佽鍒欐暟鎹紶杈撳璞★紝oid鍜宼s闇�瑕佷紶杈�
+	 * @return 鍒犻櫎缁撴灉鍙嶉锛氾細success锛氭垚鍔燂紝fail锛氬け璐�
+	 * @throws VciBaseException 鍙傛暟涓虹┖锛岃寮曠敤鏃舵姏鍑哄紓甯�
+	 */
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public R deleteCodeRule(CodeRuleDTO codeRuleDTO) throws VciBaseException {
+		VciBaseUtil.alertNotNull(codeRuleDTO, "涓绘暟鎹紪鐮佽鍒欐暟鎹璞�", codeRuleDTO.getOid(), "涓绘暟鎹紪鐮佽鍒欑殑涓婚敭");
+		CodeRule codeRule = selectByOid(codeRuleDTO.getOid());
+		if (!checkEditDelStatus(codeRule.getLcStatus())) {
+			return R.fail("缂栫爜瑙勫垯宸插彂甯冿紝涓嶅厑璁哥紪杈戞垨鍒犻櫎");
+		} else {
+			if (isAlreadyInUse(codeRule.getOid())) {
+				return R.fail("缂栫爜瑙勫垯宸茶寮曠敤锛屼笉鍏佽缂栬緫鎴栧垹闄わ紒");
+			}
+		}
+		List<CodeAllCode> codeDOList = codeAllcodeService.selectByWrapper(Wrappers.<CodeAllCode>query().lambda().eq(CodeAllCode::getCodeRuleOid, codeRuleDTO.getOid()));
+		if (!CollectionUtils.isEmpty(codeDOList)) {
+			return R.fail("缂栫爜瑙勫垯宸茬敓鎴愮紪鐮侊紝涓嶅厑璁稿垹闄�");
+		}
+		//鎵ц鍒犻櫎鎿嶄綔
+		//WebUtil.setPersistence(false);
+		boolean resBoolean = codeBasicSecService.batchDeleteSecByCodeRuleOid(codeRule.getOid());
+		boolean resBoolean1 = codeRuleMapper.deleteById(codeRule.getOid()) > 0;
+		//WebUtil.setPersistence(true);
+		return R.status(resBoolean&&resBoolean1);
+	}
 
-    /**
-     * 鏁版嵁瀵硅薄杞崲涓烘樉绀哄璞�
-     *
-     * @param codeRuleDO 鏁版嵁瀵硅薄
-     * @return 鏄剧ず瀵硅薄
-     * @throws VciBaseException 鎷疯礉灞炴�у嚭閿欑殑鏃跺�欎細鎶涘嚭寮傚父
-     */
-    @Override
-    public CodeRuleVO codeRuleDO2VO(CodeRuleDO codeRuleDO) throws VciBaseException {
-        CodeRuleVO vo = new CodeRuleVO();
-        if (codeRuleDO != null) {
-            BeanUtilForVCI.copyPropertiesIgnoreCase(codeRuleDO, vo);
-            //濡傛灉鏈塴cstatus鐨勭被鐨勮瘽
-            vo.setLcStatusText(CodeRuleLC.getTextByValue(vo.getLcStatus()));
+	/**
+	 * 缂栫爜瑙勫垯娓呯┖鎵�鏈夊凡鐢熸垚鐨勭紪鐮�
+	 *
+	 * @param oid 缂栫爜瑙勫垯涓婚敭
+	 * @return 鎵ц缁撴灉
+	 */
+	@Override
+	public R clearAllCode(String oid) {
+		WebUtil.alertNotNull(oid, "缂栫爜瑙勫垯涓婚敭");
+		List<CodeAllCode> codeDOList = codeAllcodeService.selectByWrapper(Wrappers.<CodeAllCode>query().lambda().eq(CodeAllCode::getCodeRuleOid, oid));
+		if (CollectionUtils.isEmpty(codeDOList)) {
+			return R.fail("褰撳墠缂栫爜瑙勫垯娌℃湁鐢熸垚缂栫爜,鏃犻渶娓呯┖");
+		}
+		//鏄惁闇�瑕佽繘琛宐tm涓嶇粺涓�鐨勫垽鏂�?
+		String btmType = codeDOList.get(0).getCreateCodeBtm();
+		//澶氱绫诲瀷涓嬬殑鏌ヨ
+		Set<String> btmTypeSet = codeDOList.stream().filter(s -> {
+			return !btmType.equalsIgnoreCase(s.getCreateCodeBtm());
+		}).map(s -> s.getCreateCodeBtm()).collect(Collectors.toSet());
+		List<Map<String,String>> businessDataList = new ArrayList<>();
+		if (btmTypeSet.size() > 1) {
+			for (String btm : btmTypeSet) {
+				Map<String,String> businessData = commonsMapper.selectByCount("PL_CODE_"+btm,oid,btm);
+				businessDataList.add(businessData);
+			}
+		}else {
+			Map<String,String> businessData = commonsMapper.selectByCount("PL_CODE_"+btmType,oid,btmType);
+			businessDataList.add(businessData);
+		}
+		if (CollectionUtils.isEmpty(businessDataList) || StringUtils.isBlank(businessDataList.get(0).get("count"))) {
+			//鏃犳晥鏌ヨ
+			return R.fail("鏌ヨ澶辫触");
+		} else if (!"0".equalsIgnoreCase(businessDataList.get(0).get("count"))) {
+			return R.fail("缂栫爜瑙勫垯鐢熸垚鐨勭紪鐮佸凡鍦ㄤ笟鍔℃暟鎹腑搴旂敤锛屼笉鍏佽娓呯┖");
+		}
+		//娌℃湁鏁版嵁锛屽彲浠ュ畨鍏ㄥ垹闄�
+		WebUtil.setPersistence(false);
+		//鍒犻櫎鐮佸�艰〃涓殑鏁版嵁锛屼絾涓嶅锛屽鏋滄湁娴佹按鐨勭爜娈碉紝闇�瑕侀噸鏂拌绠楁祦姘�
+		List<CodeSerialValue> serialValueList = codeSerialValueMapper.selectByCodeRoleId(oid);
+		/*BatchCBO batchCBO = boService.batchDelete(codeDOList);
+		batchCBO.getDeleteCbos().addAll(serialValueList);
+		WebUtil.setPersistence(true);
+		boService.persistenceBatch(batchCBO);*/
+		return R.success("娓呯┖鐮佸�兼垚鍔燂紒");
+	}
 
-        }
-        return vo;
-    }
+	/**
+	 * 涓婚敭鏌ヨ鏁版嵁瀵硅薄
+	 *
+	 * @param oid 涓婚敭
+	 * @return 鏁版嵁瀵硅薄
+	 * @throws VciBaseException 鍙傛暟涓虹┖锛屽苟涓旀暟鎹笉瀛樺湪鐨勬椂鍊欎細鎶涘嚭寮傚父
+	 */
+	private CodeRule selectByOid(String oid) throws VciBaseException {
+		VciBaseUtil.alertNotNull(oid, "涓婚敭");
+		CodeRule codeRuleDO = codeRuleMapper.selectById(oid.trim());
+		if (codeRuleDO == null || StringUtils.isBlank(codeRuleDO.getOid())) {
+			throw new VciBaseException(DATA_OID_NOT_EXIST);
+		}
+		return codeRuleDO;
+	}
 
-    /**
-     * 鏁版嵁瀵硅薄杞崲涓烘樉绀哄璞�
-     *
-     * @param codeRuleDO 瑙勫垯鐨勬暟鎹璞�
-     * @param hasSec     鏄惁鏌ヨ鐮佹
-     * @return 鏄剧ず瀵硅薄
-     * @throws VciBaseException 鎷疯礉灞炴�у嚭閿欑殑鏃跺�欎細鎶涘嚭寮傚父
-     */
-    public CodeRuleVO codeRuleDO2VO(CodeRuleDO codeRuleDO, boolean hasSec) throws VciBaseException {
-        CodeRuleVO vo = new CodeRuleVO();
-        if (codeRuleDO != null) {
-            BeanUtilForVCI.copyPropertiesIgnoreCase(codeRuleDO, vo);
-            //濡傛灉鏈塴cstatus鐨勭被鐨勮瘽
-            vo.setLcStatusText(CodeRuleLC.getTextByValue(vo.getLcStatus()));
-            if (hasSec) {
-                //鏌ヨ鐮佹
-                vo.setSecVOList(codeBasicSecService.listCodeBasicSecByRuleOid(vo.getOid()));
-            }
-        }
-        return vo;
-    }
+	/**
+	 * 妫�楠岀紪鐮佽鍒欐槸鍚﹀凡缁忚浣跨敤
+	 *
+	 * @param oid 缂栫爜瑙勫垯涓婚敭
+	 * @return true琛ㄧず宸茬粡浣跨敤锛宖alse琛ㄧず鏈浣跨敤
+	 */
+	@Override
+	public boolean isAlreadyInUse(String oid) throws VciBaseException {
+		Collection<CodeClassifyVO> codeClassifyVOS = listUseRangeInCodeClassify(oid);
+		if (codeClassifyVOS.size() > 0) {
+			return true;
+		} else {
+			return false;
+		}
+	}
 
-    /**
-     * 澧炲姞涓绘暟鎹紪鐮佽鍒�
-     *
-     * @param codeRuleDTO 涓绘暟鎹紪鐮佽鍒欐暟鎹紶杈撳璞�
-     * @return 鎵ц缁撴灉
-     * @throws VciBaseException 鍙傛暟涓虹┖锛屽敮涓�椤癸紝蹇呰緭椤逛笉閫氳繃鏃朵細鎶涘嚭寮傚父
-     */
-    @Override
-    public CodeRuleVO addSave(CodeRuleDTO codeRuleDTO) throws VciBaseException {
-        VciBaseUtil.alertNotNull(codeRuleDTO, "闇�瑕佹坊鍔犵殑鏁版嵁瀵硅薄");
-        //灏咲TO杞崲涓篋O
-        CodeRuleDO codeRuleDO = new CodeRuleDO();
-        BeanUtilForVCI.copyPropertiesIgnoreCase(codeRuleDTO, codeRuleDO);
-        codeRuleMapper.insert(codeRuleDO);
-        return codeRuleDO2VO(codeRuleDO);
-    }
+	/**
+	 * 鏌ョ湅涓绘暟鎹紪鐮佽鍒欑殑浣跨敤鑼冨洿
+	 *
+	 * @param oid 缂栫爜瑙勫垯涓婚敭
+	 * @return 涓婚搴撳垎绫讳娇鐢ㄥ埌璇ョ紪鐮佽鍒欑殑鎵�鏈夐泦鍚�
+	 */
+	@Override
+	public Collection<CodeClassifyVO> listUseRangeInCodeClassify(String oid) throws VciBaseException {
+		List<CodeClassify> codeClassifies = codeClassifyServcie.selectByWrapper(Wrappers.<CodeClassify>query().lambda().eq(CodeClassify::getCodeRuleOid, oid));
+		return CodeClassifyWrapper.build().listVO(codeClassifies);
+	}
 
-    /**
-     * 淇敼涓绘暟鎹紪鐮佽鍒�
-     *
-     * @param codeRuleDTO 涓绘暟鎹紪鐮佽鍒欐暟鎹紶杈撳璞�
-     * @return 鎵ц缁撴灉
-     * @throws VciBaseException 鍙傛暟涓虹┖锛屽敮涓�椤癸紝蹇呰緭椤逛笉閫氳繃鏃朵細鎶涘嚭寮傚父
-     */
-    @Override
-    public CodeRuleVO editSave(CodeRuleDTO codeRuleDTO) throws VciBaseException {
-        VciBaseUtil.alertNotNull(codeRuleDTO, "鏁版嵁瀵硅薄", codeRuleDTO.getOid(), "涓绘暟鎹紪鐮佽鍒欎富閿�");
-        if (!checkEditDelStatus(codeRuleDTO.getLcStatus())) {
-            throw new VciBaseException("缂栫爜瑙勫垯宸插彂甯冿紝涓嶅厑璁哥紪杈戞垨鍒犻櫎");
-        }
-        //灏咲TO杞崲涓篋O
-        CodeRuleDO codeRuleDO = selectByOid(codeRuleDTO.getOid());
-        revisionModelUtil.copyFromDTOIgnore(codeRuleDTO, codeRuleDO);
-        codeRuleMapper.updateByPrimaryKey(codeRuleDO);
-        return codeRuleDO2VO(codeRuleDO);
-    }
+	/**
+	 * 涓婚敭鑾峰彇涓绘暟鎹紪鐮佽鍒�
+	 *
+	 * @param oid 涓婚敭
+	 * @return 涓绘暟鎹紪鐮佽鍒欐樉绀哄璞�
+	 * @throws VciBaseException 鍙傛暟涓虹┖锛屾暟鎹笉瀛樺湪鏃朵細鎶涘嚭寮傚父
+	 */
+	@Override
+	public CodeRuleVO getObjectByOid(String oid) throws VciBaseException {
+		CodeRule codeRule = selectByOid(oid);
+		return CodeRuleWrapper.build().entityVO(codeRule);
+	}
 
+	/**
+	 * 涓婚敭鎵归噺鑾峰彇涓绘暟鎹紪鐮佽鍒�
+	 *
+	 * @param oidCollections 涓婚敭闆嗗悎锛屼絾鏄彈鎬ц兘褰卞搷锛屽缓璁竴娆℃煡璇笉瓒呰繃10000涓�
+	 * @return 涓绘暟鎹紪鐮佽鍒欐樉绀哄璞�
+	 * @throws VciBaseException 鏌ヨ鍑虹幇寮傚父鏃朵細鎶涘嚭
+	 */
+	@Override
+	public Collection<CodeRuleVO> listCodeRuleByOids(Collection<String> oidCollections) throws VciBaseException {
+		VciBaseUtil.alertNotNull(oidCollections, "鏁版嵁瀵硅薄涓婚敭闆嗗悎");
+		List<CodeRule> codeRuleDOList = listCodeRuleDOByOidCollections(oidCollections);
+		return codeRuleDO2VOs(codeRuleDOList,true);
+	}
 
-    /**
-     * 鏍¢獙鏄惁鍙互鍒犻櫎锛屽鏋滃瓨鍦ㄤ笅绾э紝骞朵笖涓嬬骇鏈夋暟鎹紩鐢ㄥ垯涓嶈兘鍒犻櫎
-     *
-     * @param codeRuleDTO 鏁版嵁浼犺緭瀵硅薄
-     * @param codeRuleDO  鏁版嵁搴撲腑鐨勬暟鎹璞�
-     * @return success涓簍rue涓哄彲浠ュ垹闄わ紝false琛ㄧず鏈夋暟鎹紩鐢紝obj涓簍rue琛ㄧず鏈変笅绾�
-     */
-    private BaseResult checkIsCanDeleteForDO(CodeRuleDTO codeRuleDTO, CodeRuleDO codeRuleDO) {
-        boService.checkTs(codeRuleDTO);
-        if (!checkIsLinked(codeRuleDO.getOid())) {
-            return BaseResult.success();
-        } else {
-            return BaseResult.fail(DATA_LINKED_NOT_DELETE, new String[]{""});
-        }
-    }
+	/**
+	 * 涓婚敭鎵归噺鑾峰彇涓绘暟鎹紪鐮佽鍒�
+	 *
+	 * @param oidCollections 涓婚敭闆嗗悎锛屼絾鏄彈鎬ц兘褰卞搷锛屽缓璁竴娆℃煡璇笉瓒呰繃10000涓�
+	 * @param hasSec         鏄惁鍖呭惈鐮佹
+	 * @return 涓绘暟鎹紪鐮佽鍒欐樉绀哄璞�
+	 * @throws VciBaseException 鏌ヨ鍑虹幇寮傚父鏃朵細鎶涘嚭
+	 */
+	@Override
+	public Collection<CodeRuleVO> listCodeRuleByIds(Collection<String> oidCollections, boolean hasSec) throws VciBaseException {
+		VciBaseUtil.alertNotNull(oidCollections, "鏁版嵁瀵硅薄涓婚敭闆嗗悎");
+		List<CodeRule> codeRuleDOList = listCodeRuleDOByIdCollections(oidCollections);
+		return codeRuleDO2VOs(codeRuleDOList, hasSec);
+	}
 
-    /**
-     * 鏍¢獙鏄惁琚紩鐢�
-     *
-     * @param oid 涓婚敭
-     * @throws VciBaseException 琚紩鐢ㄧ殑鏃跺�欎細鎶涘嚭寮傚父
-     */
-    private boolean checkIsLinked(String oid) throws VciBaseException {
-        //TODO 娣诲姞闇�瑕佹牎楠屽紩鐢ㄧ殑鍦版柟
-        return false;
-    }
+	/**
+	 * 浣跨敤涓婚敭闆嗗悎鏌ヨ鏁版嵁瀵硅薄
+	 *
+	 * @param oidCollections 涓婚敭鐨勯泦鍚�
+	 * @return 鏁版嵁瀵硅薄鍒楄〃
+	 */
+	private List<CodeRule> listCodeRuleDOByOidCollections(Collection<String> oidCollections) throws VciBaseException {
+		List<CodeRule> codeRuleDOList = new ArrayList<CodeRule>();
+		if (!CollectionUtils.isEmpty(oidCollections)) {
+			Collection<Collection<String>> oidCollectionsList = VciBaseUtil.switchCollectionForOracleIn(oidCollections);
+			for (Collection<String> oids : oidCollectionsList) {
+				List<CodeRule> tempDOList = codeRuleMapper.selectBatchIds(oids);
+				if (!CollectionUtils.isEmpty(tempDOList)) {
+					codeRuleDOList.addAll(tempDOList);
+				}
+			}
+		}
+		return codeRuleDOList;
+	}
 
-    /**
-     * 鍒犻櫎涓绘暟鎹紪鐮佽鍒�
-     *
-     * @param codeRuleDTO 涓绘暟鎹紪鐮佽鍒欐暟鎹紶杈撳璞★紝oid鍜宼s闇�瑕佷紶杈�
-     * @return 鍒犻櫎缁撴灉鍙嶉锛氾細success锛氭垚鍔燂紝fail锛氬け璐�
-     * @throws VciBaseException 鍙傛暟涓虹┖锛岃寮曠敤鏃舵姏鍑哄紓甯�
-     */
-    @Override
-    public BaseResult deleteCodeRule(CodeRuleDTO codeRuleDTO) throws VciBaseException {
-        VciBaseUtil.alertNotNull(codeRuleDTO, "涓绘暟鎹紪鐮佽鍒欐暟鎹璞�", codeRuleDTO.getOid(), "涓绘暟鎹紪鐮佽鍒欑殑涓婚敭");
-        CodeRuleDO codeRuleDO = selectByOid(codeRuleDTO.getOid());
-        //BaseResult baseResult = checkIsCanDeleteForDO(codeRuleDTO,codeRuleDO);
-        // if(baseResult.isSuccess()) {
-        //             }else{
-        //     return baseResult;
-        // }
-        if (!checkEditDelStatus(codeRuleDO.getLcStatus())) {
-            return BaseResult.fail("缂栫爜瑙勫垯宸插彂甯冿紝涓嶅厑璁哥紪杈戞垨鍒犻櫎");
-        } else {
-            if (isAlreadyInUse(codeRuleDO.getOid())) {
-                return BaseResult.fail("缂栫爜瑙勫垯宸茶寮曠敤锛屼笉鍏佽缂栬緫鎴栧垹闄わ紒");
-            }
-        }
-        Map<String, String> conditionMap = new HashMap<>();
-        conditionMap.put("codeRuleOid", codeRuleDTO.getOid());
-        List<CodeAllCodeDO> codeDOList = boService.queryObject(CodeAllCodeDO.class, conditionMap);
-        if (!CollectionUtils.isEmpty(codeDOList)) {
-            return BaseResult.fail("缂栫爜瑙勫垯宸茬敓鎴愮紪鐮侊紝涓嶅厑璁稿垹闄�");
-        }
-        //鎵ц鍒犻櫎鎿嶄綔
-        WebUtil.setPersistence(false);
-        BatchCBO batchCBO = codeBasicSecService.batchDeleteSecByCodeRuleOid(codeRuleDO.getOid());
-        BatchCBO mainCBO = codeRuleMapper.deleteByPrimaryKey(codeRuleDO.getOid());
-        WebUtil.setPersistence(true);
-        Set<ClientBusinessObject> deleteSet = new HashSet<>();
-        deleteSet.addAll(batchCBO.getDeleteCbos());
-        deleteSet.addAll(mainCBO.getDeleteCbos());
-        batchCBO.setDeleteCbos(deleteSet);
-        boService.persistenceBatch(batchCBO);
-        return (batchCBO != null && batchCBO.getDeleteCbos() != null && batchCBO.getDeleteCbos().size() > 0) ? BaseResult.successMsg(DELETE_SUCCESS) : BaseResult.fail(DELETE_FAIL);
-    }
+	/**
+	 * 浣跨敤瑙勫垯id闆嗗悎鏌ヨ鏁版嵁瀵硅薄
+	 *
+	 * @param idCollections id鐨勯泦鍚�
+	 * @return 鏁版嵁瀵硅薄鍒楄〃
+	 */
+	private List<CodeRule> listCodeRuleDOByIdCollections(Collection<String> idCollections) throws VciBaseException {
+		List<CodeRule> codeRuleDOList = new ArrayList<CodeRule>();
+		if (!CollectionUtils.isEmpty(idCollections)) {
+			Collection<Collection<String>> idCollectionsList = VciBaseUtil.switchCollectionForOracleIn(idCollections);
+			for (Collection<String> ids : idCollectionsList) {
+				List<CodeRule> tempDOList = codeRuleMapper.selectList(
+					Wrappers.<CodeRule>query()
+						.lambda().in(CodeRule::getId,ids)
+				);
+				if (!CollectionUtils.isEmpty(tempDOList)) {
+					codeRuleDOList.addAll(tempDOList);
+				}
+			}
+		}
+		return codeRuleDOList;
+	}
 
-    /**
-     * 鏍¢獙缂栫爜瑙勫垯鐨勭姸鎬佹槸鍚﹀彲浠ョ紪杈戞垨鍒犻櫎
-     *
-     * @param lcStatus 缂栫爜瑙勫垯
-     * @return true琛ㄧず鍙互缂栬緫鎴栧垹闄わ紝false琛ㄧず涓嶅彲浠�
-     */
-    @Override
-    public boolean checkEditDelStatus(String lcStatus) {
-        if (CodeRuleLC.RELEASED.getValue().equals(lcStatus) || CodeRuleLC.DISABLED.getValue().equals(lcStatus)) {
-            return false;
-        }
-        return true;
-    }
+	/**
+	 * 鍙傜収涓绘暟鎹紪鐮佽鍒欏垪琛�
+	 *
+	 * @param bladeQueryObject 鏌ヨ鏉′欢
+	 * @return 涓绘暟鎹紪鐮佽鍒欐樉绀哄璞″垪琛紝鐢熸晥鐨勫唴瀹�
+	 * @throws VciBaseException 鏌ヨ鏉′欢鍜屽垎椤靛嚭閿欑殑鏃跺�欎細鎶涘嚭寮傚父
+	 */
+	@Override
+	public IPage<CodeRuleVO> refDataGridCodeRule(BladeQueryObject bladeQueryObject) throws VciBaseException {
+		return gridCodeRule(bladeQueryObject.getQuery(), bladeQueryObject.getConditionMap());
+	}
 
+	/**
+	 * 鍋滅敤涓庡惎鐢ㄧ紪鐮佽鍒�
+	 *
+	 * @param oid    缂栫爜瑙勫垯涓婚敭
+	 * @param update enable:鍚敤 disable:鍋滅敤 release:鍙戝竷
+	 * @return 鎵ц缁撴灉
+	 */
+	@Override
+	public R updateStatus(String oid, String update) throws VciBaseException {
+		int count = 0;
+		//鍏堟煡璇㈠璞�
+		CodeRule codeRuleDO = selectByOid(oid);
+		//鍒涘缓淇敼瀵硅薄鐨勭殑wrapper鏉′欢
+		LambdaUpdateWrapper<CodeRule> wrapper = Wrappers.<CodeRule>update()
+			.lambda()
+			.eq(CodeRule::getOid, oid);
+		if ("enable".equalsIgnoreCase(update)) {
+			if (!CodeRuleLC.DISABLED.getValue().equals(codeRuleDO.getLcStatus())) {
+				return R.fail("闈炲仠鐢ㄧ姸鎬佺殑缂栫爜瑙勫垯鏃犻渶鐐瑰嚮鍚敤");
+			}
+			count = codeRuleMapper.update(null,wrapper.set(CodeRule::getLcStatus, CodeRuleLC.RELEASED.getValue()));
+		} else if ("disable".equalsIgnoreCase(update)) {
+			if (!CodeRuleLC.RELEASED.getValue().equals(codeRuleDO.getLcStatus())) {
+				return R.fail("闈炲彂甯冪姸鎬佺殑缂栫爜瑙勫垯鏃犳硶鍋滅敤");
+			}
+			count = codeRuleMapper.update(null,wrapper.set(CodeRule::getLcStatus, CodeRuleLC.DISABLED.getValue()));
+		} else if ("release".equalsIgnoreCase(update)) {
+			if (!CodeRuleLC.EDITING.getValue().equals(codeRuleDO.getLcStatus())) {
+				return R.fail("闈炵紪杈戠姸鎬佺殑缂栫爜瑙勫垯鏃犳硶鍙戝竷");
+			}
+			// 鍙戝竷鏃跺皢鐮佹绫诲瀷鎸夌収瀛楃涓插垎闅旂殑褰㈠紡鎷兼帴骞跺瓨鍌�
+			String secTypeStr = codeBasicSecService.listCodeBasicSecByRuleOid(codeRuleDO.getOid()).stream().map(CodeBasicSecVO::getSecType).collect(Collectors.joining(","));
+			count = codeRuleMapper.update(null,wrapper.set(CodeRule::getLcStatus, CodeRuleLC.RELEASED.getValue()).set(CodeRule::getBasicSecTypes,secTypeStr));
+		} else {
+			return R.fail("鏆備笉鏀寔鐨勬搷浣滅被鍨�");
+		}
+		if (count > 0) {
+			return R.success("鏇存柊鐘舵�佹垚鍔�");
+		} else {
+			return R.fail("鏇存柊鐘舵�佸け璐�");
+		}
+	}
 
-    /**
-     * 涓婚敭鑾峰彇涓绘暟鎹紪鐮佽鍒�
-     *
-     * @param oid 涓婚敭
-     * @return 涓绘暟鎹紪鐮佽鍒欐樉绀哄璞�
-     * @throws VciBaseException 鍙傛暟涓虹┖锛屾暟鎹笉瀛樺湪鏃朵細鎶涘嚭寮傚父
-     */
-    @Override
-    public CodeRuleVO getObjectByOid(String oid) throws VciBaseException {
-        return codeRuleDO2VO(selectByOid(oid));
-    }
+	/**
+	 * 鍏嬮殕缂栫爜瑙勫垯
+	 *
+	 * @param codeRuleDTO 涓绘暟鎹紪鐮佽鍒欐暟鎹紶杈撳璞★紝oid鍜宼s闇�瑕佷紶杈�
+	 * @return 涓绘暟鎹紪鐮佽鍒欐樉绀哄璞�
+	 */
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public R cloneCodeRule(CodeRuleDTO codeRuleDTO) throws ServerException {
+		if(checkCodeRuleRepeat(codeRuleDTO)){
+			return R.fail("瑙勫垯缂栧彿宸插瓨鍦紒");
+		}
+		VciBaseUtil.alertNotNull(codeRuleDTO, "闇�瑕佹坊鍔犵殑鏁版嵁瀵硅薄");
+		CodeRule codeRuleDO = new CodeRule();
+		BeanUtilForVCI.copyPropertiesIgnoreCase(codeRuleDTO, codeRuleDO);
+		DefaultAttrAssimtUtil.addDefaultAttrAssimt(codeRuleDO,MdmBtmTypeConstant.CODE_RULE);
+		boolean exFlag = SqlHelper.retBool(codeRuleMapper.insert(codeRuleDO));
 
-    /**
-     * 涓婚敭鏌ヨ鏁版嵁瀵硅薄
-     *
-     * @param oid 涓婚敭
-     * @return 鏁版嵁瀵硅薄
-     * @throws VciBaseException 鍙傛暟涓虹┖锛屽苟涓旀暟鎹笉瀛樺湪鐨勬椂鍊欎細鎶涘嚭寮傚父
-     */
-    private CodeRuleDO selectByOid(String oid) throws VciBaseException {
-        VciBaseUtil.alertNotNull(oid, "涓婚敭");
-        CodeRuleDO codeRuleDO = codeRuleMapper.selectByPrimaryKey(oid.trim());
-        if (codeRuleDO == null || StringUtils.isBlank(codeRuleDO.getOid())) {
-            throw new VciBaseException(DATA_OID_NOT_EXIST);
-        }
-        return codeRuleDO;
-    }
+		List<CodeBasicSecDTO> secList = codeRuleDTO.getElements();
+		List<CodeBasicSec> codeBasicSecs = new ArrayList<>();
+		List<CodeBasicSec> codeClassifySec = new ArrayList<>();
+		// 鍥哄畾鐮佸�兼槧灏勫叧绯�
+		Map<String,List<CodeFixedValue>> codeFixedValueMaps = new HashMap<>();
+		for (CodeBasicSecDTO codeBasicSecDTO : secList) {
+			codeBasicSecDTO.setPkCodeRule(codeRuleDO.getOid());
+			KeyValue attrKv = codeBasicSecService.checkAttrNullableBySecType(codeBasicSecDTO);
+			if (!"success".equals(attrKv.getKey())) {
+				throw new VciBaseException(attrKv.getValue() + "涓嶈兘涓虹┖");
+			}
+			CodeBasicSec codeBasicSecDO = new CodeBasicSec();
+			BeanUtilForVCI.copyPropertiesIgnoreCase(codeBasicSecDTO, codeBasicSecDO);
+			String oldBasicOid = codeBasicSecDO.getOid(); //琚厠闅嗙殑鐮佹鐨刼id
+			// 鍒ゆ柇鏄惁鏄垎绫荤爜娈�
+			if(codeBasicSecDO.getSecType().equals(CodeSecTypeEnum.CODE_CLASSIFY_SEC.getValue())){
+				// 瀛樺偍鏃х殑鐮佹oid鍜屾柊鐨勭爜娈电殑oid鐨勫叧鑱斿叧绯�
+				codeClassifySec.add(codeBasicSecDO);
+				continue;
+			}
+			// 鏇存敼鍒涘缓鏃堕棿锛屼慨鏀规椂闂寸瓑榛樿鍊�
+			DefaultAttrAssimtUtil.addDefaultAttrAssimt(codeBasicSecDO,MdmBtmTypeConstant.CODE_BASIC_SEC);
+			// 鍥哄畾鐮佹
+			if(codeBasicSecDO.getSecType().equals(CodeSecTypeEnum.CODE_FIXED_SEC.getValue())){
+				// 鍥哄畾鐮佹瀛樺偍濂給id鍜岀爜鍊肩殑鍏宠仈鍏崇郴
+				codeFixedValueMaps.put(codeBasicSecDO.getOid(),codeFixedValueService.list(Wrappers.<CodeFixedValue>query()
+					.lambda().eq(CodeFixedValue::getCodeFixedSecOid, oldBasicOid)
+				));
+			}
+			codeBasicSecs.add(codeBasicSecDO);
+		}
+		// 澶勭悊鍒嗙被鐮佹鐨刼id锛屽洜涓簅id鍏宠仈parentClassifyOid锛屼笌鐮佸�糲odeClassifyOid锛岀爜鍊煎張闇�瑕侀�氳繃鏃х殑鐮佹oid鏉ユ煡璇紝鎵�浠ヤ笉鑳界洿鎺ユ敼鍙榦id
+		boolean resChangeAssn = codeBasicSecService.changeParentOidAssnOid(codeClassifySec);
+		// 灏嗗鐞嗚繃鐨勫垎绫荤爜娈典篃娣诲姞杩涜鍋氭柊澧炲鐞嗙殑鐮佹闆嗗悎涓�
+		codeBasicSecs.addAll(codeClassifySec);
+		// 鏂板鐮佹
+		boolean exFlag1 = this.codeBasicSecService.saveBatch(codeBasicSecs);
+		// 鏈�缁堣瀛樺叆鐮佸�艰〃涓殑锛岀爜鍊煎璞�
+		List<CodeFixedValue> codeFixedDOValues = new ArrayList<>();
+		// 鏋勯�犵爜鍊煎璞★紝涓庣爜娈典富閿叧鑱斿叧绯伙紝浠ュ強鏀瑰彉鐮佸�肩殑oid
+		codeFixedValueMaps.forEach((key, value) -> {
+			value.stream().forEach(item -> {
+				item.setOid("");
+				item.setCodeFixedSecOid(key);
+				DefaultAttrAssimtUtil.updateDefaultAttrAssimt(item);
+				codeFixedDOValues.add(item);
+			});
+		});
+		boolean exFlag2 = codeFixedValueService.saveBatch(codeFixedDOValues) && resChangeAssn;
+		return R.data(exFlag&&exFlag1&&exFlag2);
+	}
 
-    /**
-     * 涓婚敭鎵归噺鑾峰彇涓绘暟鎹紪鐮佽鍒�
-     *
-     * @param oidCollections 涓婚敭闆嗗悎锛屼絾鏄彈鎬ц兘褰卞搷锛屽缓璁竴娆℃煡璇笉瓒呰繃10000涓�
-     * @return 涓绘暟鎹紪鐮佽鍒欐樉绀哄璞�
-     * @throws VciBaseException 鏌ヨ鍑虹幇寮傚父鏃朵細鎶涘嚭
-     */
-    @Override
-    public Collection<CodeRuleVO> listCodeRuleByOids(Collection<String> oidCollections) throws VciBaseException {
-        VciBaseUtil.alertNotNull(oidCollections, "鏁版嵁瀵硅薄涓婚敭闆嗗悎");
-        List<CodeRuleDO> codeRuleDOList = listCodeRuleDOByOidCollections(oidCollections);
-        return codeRuleDO2VOs(codeRuleDOList);
-    }
+	/**
+	 * 浣跨敤涓婚敭鑾峰彇缂栫爜瑙勫垯鐨勫唴瀹�
+	 *
+	 * @param oid 涓婚敭
+	 * @return 瑙勫垯鐨勬樉绀哄璞�
+	 */
+	@Override
+	public CodeRuleVO getObjectHasSecByOid(String oid) throws VciBaseException {
+		CodeRule ruleDO = selectByOid(oid);
+		return codeRuleDO2VO(ruleDO, true);
+	}
 
-    /**
-     * 涓婚敭鎵归噺鑾峰彇涓绘暟鎹紪鐮佽鍒�
-     *
-     * @param oidCollections 涓婚敭闆嗗悎锛屼絾鏄彈鎬ц兘褰卞搷锛屽缓璁竴娆℃煡璇笉瓒呰繃10000涓�
-     * @param hasSec         鏄惁鍖呭惈鐮佹
-     * @return 涓绘暟鎹紪鐮佽鍒欐樉绀哄璞�
-     * @throws VciBaseException 鏌ヨ鍑虹幇寮傚父鏃朵細鎶涘嚭
-     */
-    @Override
-    public Collection<CodeRuleVO> listCodeRuleByOids(Collection<String> oidCollections, boolean hasSec) throws VciBaseException {
-        VciBaseUtil.alertNotNull(oidCollections, "鏁版嵁瀵硅薄涓婚敭闆嗗悎");
-        List<CodeRuleDO> codeRuleDOList = listCodeRuleDOByOidCollections(oidCollections);
-        return codeRuleDO2VOs(codeRuleDOList, true);
-    }
+	/**
+	 * 妫�鏌ョ浉浼肩紪鐮佽鍒欙紝骞惰繑鍥炲搴旂殑缁撴灉
+	 * @param oid 涓婚敭
+	 * @return 鎵ц缁撴灉
+	 */
+	@Override
+	public R checkLikeCodeRule(String oid) throws VciBaseException {
+		// 1銆佹煡璇㈠嚭褰撳墠瑕佸彂甯冪殑瑙勫垯
+		CodeRuleVO releaseCodeRule = getObjectHasSecByOid(oid);
+		// 褰撳墠鍙戝竷鐨勮鍒欎笉瀛樺湪鐮佹淇℃伅锛岀洿鎺ョ┖淇℃伅杩斿洖
+		if(Func.isEmpty(releaseCodeRule.getSecVOList())){
+			return R.fail("瑙勫垯淇℃伅涓嶅瓨鍦紝璇峰埛鏂板悗閲嶈瘯锛�");
+		}
+		// 2銆佹壘鍑轰笌褰撳墠鍙戝竷鐨勮鍒欑爜娈甸『搴忎竴鑷寸殑瑙勫垯
+		String secTypes = releaseCodeRule.getSecVOList().stream().map(CodeBasicSecVO::getSecType).collect(Collectors.joining(","));
+		// 鏌ヨ鍑烘墍鏈夊凡鍙戝竷鐨勭紪鐮佽鍒欎腑鐮佹绫诲瀷椤哄簭涓庡綋鍓嶈鍙戝竷鐨勮鍒欓『搴忎竴鑷寸殑缂栫爜瑙勫垯锛屾鏃跺凡杩戣繃婊ゆ帀澶ч儴鍒嗚鍒欙紝杩愮畻閲忓噺灏�
+		List<CodeRule> codeRuleList = codeRuleMapper.selectList(Wrappers.<CodeRule>query().lambda()
+			.eq(CodeRule::getLcStatus, CodeRuleLC.RELEASED.getValue())
+			.eq(CodeRule::getBasicSecTypes,secTypes)
+		);
+		// 涓虹┖锛岃瘉鏄庝笉瀛樺湪绫诲悓鐨勭紪鐮佽鍒欑洿鎺ヨ繑鍥�
+		if(Func.isEmpty(codeRuleList)){
+			return R.data(new ResultDataVO(true));
+		}
+		// 鏌ヨ鍑哄熀纭�鐮佹鍒楄〃锛堟寜鐓rderNum鍗囧簭鎺掑簭锛�
+		List<CodeRuleVO> codeRuleVOS = codeRuleDO2VOs(codeRuleList, true);
+		// 3銆佸悇绫荤爜娈靛垎鍒繘琛屾瘮瀵�
+		List<CodeRuleVO> lastCodeRule = new ArrayList<>();
+		codeRuleVOS.stream().forEach(item->{
+			List<CodeBasicSecVO> secVOList = item.getSecVOList();
+			boolean flag = true;
+			for (int index = 0; index < secVOList.size(); index++) {
+				// 褰撳墠瑕佸彂甯冪殑瑙勫垯鍖呭惈鐨勭爜娈典俊鎭�
+				CodeBasicSecVO releaseBasicSec = releaseCodeRule.getSecVOList().get(index);
+				// 宸插彂甯冪殑瑙勫垯鍖呭惈鐨勭爜娈典俊鎭�
+				CodeBasicSecVO releasedBasicSec = secVOList.get(index);
+				// 鍥犱负鐮佹椤哄簭閮芥槸鎸夌収OrderNum鎺掑簭鐨勶紝鎵�浠ョ洿鎺ユ寜鐓т笅鏍囦袱涓ゆ瘮杈冨氨鍙互浜�
+				switch (releasedBasicSec.getSecType()){
+					// 灞炴�х爜娈碉紝姣斿灞炴�у拰灞炴�ф墍鍦ㄥ垎绫�(referCodeClassifyOid)
+					case "codeattrsec":
+						if(!releasedBasicSec.getReferCodeClassifyOid().equals(releaseBasicSec.getReferCodeClassifyOid())){
+							flag = false;
+						}
+						break;
+					// 鍙彉鐮佹锛屾瘮瀵圭爜娈甸暱搴︼紝缂栫爜琛ヤ綅鏂瑰紡鍜岃ˉ浣嶆椂鐨勫瓧绗�
+					case "codevariablesec":
+						if(!(releasedBasicSec.getCodeSecLength().equals(releaseBasicSec.getCodeSecLength())
+							&& releasedBasicSec.getCodeFillType().equals(releaseBasicSec.getCodeFillType())
+							&& releasedBasicSec.getCodeFillSeparator().equals(releaseBasicSec.getCodeFillSeparator()))){
+							flag = false;
+						}
+						break;
+					// 鍥哄畾鐮佹姣斿鎸夊崌搴忔帓搴忕殑鐮佸�硷紝
+					case "codefixedsec":
+						if(Func.isNotEmpty(releasedBasicSec.getFixedValueVOList()) && Func.isNotEmpty(releaseBasicSec.getFixedValueVOList())){
+							// 灏唂ixedValue鎸夌収閫楀彿鍒嗛殧鎷兼帴璧锋潵锛屼互渚挎瘮杈冿紝鐢变簬鏌ヨ鏃跺凡鎸夌収orderNum鎺掕繃搴忎簡锛屾墍浠ヤ笉闇�瑕佸啀娆℃帓搴�
+							String reledFixedValues = releasedBasicSec.getFixedValueVOList().stream().map(CodeFixedValueVO::getId).collect(Collectors.joining(","));
+							String releFixedValues = releaseBasicSec.getFixedValueVOList().stream().map(CodeFixedValueVO::getId).collect(Collectors.joining(","));
+							if(reledFixedValues.equals(releFixedValues)){
+								flag = false;
+							}
+						}
+						break;
+					// 鍒嗙被鐮佹姣斿鎸夊崌搴忔帓搴忕爜鍊�
+					case "codeclassifysec":
+						String classifyValueStr = this.iCodeClassifyValueService.getClassifyValueStr(releasedBasicSec.getOid());
+						String classifyValueStr1 = this.iCodeClassifyValueService.getClassifyValueStr(releaseBasicSec.getOid());
+						if(classifyValueStr.equals(classifyValueStr1)){
+							flag = false;
+						}
+						break;
+					// 鏃ユ湡鐮佹姣斿鏃ユ湡鏍煎紡
+					case "codedatesec":
+						if(!releasedBasicSec.getCodeDateFormatStr().equals(releaseBasicSec.getCodeDateFormatStr())){
+							flag = false;
+						}
+						break;
+					// 寮曠敤鐮佹锛屾瘮瀵瑰弬鐓у紩鐢ㄧ殑涓氬姟绫诲瀷
+					case "coderefersec":
+						if(!releasedBasicSec.getReferBtmId().equals(releaseBasicSec.getReferBtmId())){
+							flag = false;
+						}
+						break;
+					// 灞傜骇鐮佹锛屾瘮瀵瑰眰绾х被鍨嬨�佸眰绾х殑鍊笺�佸瓧绗︽埅鍙栫被鍨嬨�佸彇鍊肩被鍨�
+					case "codelevelsec":
+						if(!(releasedBasicSec.getCodeLevelType().equals(releaseBasicSec.getCodeLevelType())
+							/*鍏堝仛闈炵┖鍒ゆ柇锛屽洜涓烘敼灞炴�т笉鏄繀濉睘鎬�*/
+							&& (Func.isNotEmpty(releasedBasicSec.getCodeLevelValue()) && Func.isNotEmpty(releaseBasicSec.getCodeLevelValue()))
+							&& releasedBasicSec.getCodeLevelValue().equals(releaseBasicSec.getCodeLevelValue())
+							&& releasedBasicSec.getValueCutType().equals(releaseBasicSec.getValueCutType())
+							&& releasedBasicSec.getCodeGetValueType().equals(releaseBasicSec.getCodeGetValueType()))){
+							flag = false;
+						}
+						break;
+					// 娴佹按鐮佹姣斿鐮佹鐨勯暱搴�
+					case "codeserialsec":
+						if(!releasedBasicSec.getCodeFillLength().equals(releaseBasicSec.getCodeFillLength())){
+							flag = false;
+						}
+						break;
+				}
+				if (!flag) {
+					break;
+				}
+			}
+			// 婊¤冻鎵�鏈夌爜娈电被鍨嬫瘮瀵规潯浠剁殑瑙勫垯
+			if (flag) {
+				lastCodeRule.add(item);
+			}
+		});
+		// 涓虹┖鏃惰鏄庢楠�3娌℃瘮瀵瑰嚭绫讳技鐨勭紪鐮佽鍒�
+		if(lastCodeRule.isEmpty()){
+			return R.data(new ResultDataVO(true));
+		}
+		StringBuffer resMsg = new StringBuffer();
+		resMsg.append("瀛樺湪濡備笅鐩镐技瑙勫垯锛屾槸鍚︾户缁彂甯冿紵\n");
+		// 鏈�鍚庡皢缁撴灉杩涜澶勭悊骞惰繑鍥�
+		lastCodeRule.stream().forEach(item->{
+			resMsg.append(item.getName());
+			resMsg.append(item.getId());
+			resMsg.append("缂栫爜瑙勫垯;\n");
+		});
+		ResultDataVO resultDataVO = new ResultDataVO(false,resMsg.toString());
+		return R.data(resultDataVO);
+	}
 
-    /**
-     * 浣跨敤缂栧彿鐨勯泦鍚堣幏鍙栬鍒欑殑鍐呭
-     *
-     * @param idCollection 缂栧彿鐨勯泦鍚�
-     * @return 瑙勫垯鐨勫唴瀹�
-     */
-    @Override
-    public List<CodeRuleVO> listCodeRuleByIds(Collection<String> idCollection) {
-        return codeRuleDO2VOs(listCodeRuleDOByIdCollections(idCollection));
-    }
+	/**
+	 * 鎵归噺鏁版嵁瀵硅薄杞崲涓烘樉绀哄璞�
+	 *
+	 * @param codeRules 鏁版嵁瀵硅薄鍒楄〃
+	 * @param hasSec      鏄惁鍖呭惈鐮佹
+	 * @return 鏄剧ず瀵硅薄
+	 * @throws VciBaseException 鍙傛暟涓虹┖鎴栬�呬笉瀛樺湪鐨勬椂鍊欎細鎶涘嚭寮傚父
+	 */
+	public List<CodeRuleVO> codeRuleDO2VOs(Collection<CodeRule> codeRules, boolean hasSec) throws VciBaseException {
+		List<CodeRuleVO> voList = new ArrayList<CodeRuleVO>();
+		if (!CollectionUtils.isEmpty(codeRules)) {
+			for (CodeRule s : codeRules) {
+				CodeRuleVO vo = codeRuleDO2VO(s,true);
+				if (vo != null) {
+					voList.add(vo);
+				}
+			}
+		}
+		return voList;
+	}
 
-    /**
-     * 浣跨敤涓婚敭闆嗗悎鏌ヨ鏁版嵁瀵硅薄
-     *
-     * @param oidCollections 涓婚敭鐨勯泦鍚�
-     * @return 鏁版嵁瀵硅薄鍒楄〃
-     */
-    private List<CodeRuleDO> listCodeRuleDOByOidCollections(Collection<String> oidCollections) {
-        List<CodeRuleDO> codeRuleDOList = new ArrayList<CodeRuleDO>();
-        if (!CollectionUtils.isEmpty(oidCollections)) {
-            Collection<Collection<String>> oidCollectionsList = VciBaseUtil.switchCollectionForOracleIn(oidCollections);
-            for (Collection<String> oids : oidCollectionsList) {
-                List<CodeRuleDO> tempDOList = codeRuleMapper.selectByPrimaryKeyCollection(oids);
-                if (!CollectionUtils.isEmpty(tempDOList)) {
-                    codeRuleDOList.addAll(tempDOList);
-                }
-            }
-        }
-        return codeRuleDOList;
-    }
+	/**
+	 * 鏁版嵁瀵硅薄杞崲涓烘樉绀哄璞�
+	 *
+	 * @param codeRuleDO 瑙勫垯鐨勬暟鎹璞�
+	 * @param hasSec     鏄惁鏌ヨ鐮佹
+	 * @return 鏄剧ず瀵硅薄
+	 * @throws VciBaseException 鎷疯礉灞炴�у嚭閿欑殑鏃跺�欎細鎶涘嚭寮傚父
+	 */
+	public CodeRuleVO codeRuleDO2VO(CodeRule codeRuleDO, boolean hasSec) throws VciBaseException {
+		CodeRuleVO vo = new CodeRuleVO();
+		if (codeRuleDO != null) {
+			BeanUtilForVCI.copyPropertiesIgnoreCase(codeRuleDO, vo);
+			//濡傛灉鏈塴cstatus鐨勭被鐨勮瘽
+			vo.setLcStatusText(CodeRuleLC.getTextByValue(vo.getLcStatus()));
+			if (hasSec) {
+				List<CodeBasicSecVO> codeBasicSecVOS = codeBasicSecService.listCodeBasicSecByRuleOid(vo.getOid());
+				//鏌ヨ鐮佹
+				vo.setSecVOList(codeBasicSecVOS);
+			}
+		}
+		return vo;
+	}
 
-    /**
-     * 浣跨敤缂栧彿闆嗗悎鏌ヨ鏁版嵁瀵硅薄
-     *
-     * @param idCollections 缂栧彿鐨勯泦鍚�
-     * @return 鏁版嵁瀵硅薄鍒楄〃
-     */
-    private List<CodeRuleDO> listCodeRuleDOByIdCollections(Collection<String> idCollections) {
-        List<CodeRuleDO> codeRuleDOList = new ArrayList<CodeRuleDO>();
-        if (!CollectionUtils.isEmpty(idCollections)) {
-            Collection<Collection<String>> idCollectionsList = VciBaseUtil.switchCollectionForOracleIn(idCollections);
-            for (Collection<String> ids : idCollectionsList) {
-                List<CodeRuleDO> tempDOList = codeRuleMapper.selectByIdCollection(ids);
-                if (!CollectionUtils.isEmpty(tempDOList)) {
-                    codeRuleDOList.addAll(tempDOList);
-                }
-            }
-        }
-        return codeRuleDOList;
-    }
-
-
-    /**
-     * 鍙傜収涓绘暟鎹紪鐮佽鍒欏垪琛�
-     *
-     * @param conditionMap 鏌ヨ鏉′欢
-     * @param pageHelper   鍒嗛〉鍜屾帓搴�
-     * @return 涓绘暟鎹紪鐮佽鍒欐樉绀哄璞″垪琛紝鐢熸晥鐨勫唴瀹�
-     * @throws VciBaseException 鏌ヨ鏉′欢鍜屽垎椤靛嚭閿欑殑鏃跺�欎細鎶涘嚭寮傚父
-     */
-    @Override
-    public DataGrid<CodeRuleVO> refDataGridCodeRule(Map<String, String> conditionMap, PageHelper pageHelper) throws VciBaseException {
-        if (conditionMap == null) {
-            conditionMap = new HashMap<String, String>();
-        }
-        return gridCodeRule(conditionMap, pageHelper);
-    }
-
-    /**
-     * 鏌ョ湅涓绘暟鎹紪鐮佽鍒欑殑浣跨敤鑼冨洿
-     *
-     * @param oid 缂栫爜瑙勫垯涓婚敭
-     * @return 涓婚搴撳垎绫讳娇鐢ㄥ埌璇ョ紪鐮佽鍒欑殑鎵�鏈夐泦鍚�
-     */
-    @Override
-    public Collection<CodeClassifyVO> listUseRangeInCodeClassify(String oid) {
-        Map<String, String> conditionMap = new HashMap<>();
-        conditionMap.put("codeRuleOid", oid);
-        VciQueryWrapperForDO queryWrapper = new VciQueryWrapperForDO(conditionMap, CodeClassifyDO.class);
-        List<CodeClassifyDO> dos = codeClassifyService.selectByWrapper(queryWrapper);
-        return codeClassifyService.codeClassifyDO2VOs(dos);
-    }
-
-    /**
-     * 妫�楠岀紪鐮佽鍒欐槸鍚﹀凡缁忚浣跨敤
-     *
-     * @param oid 缂栫爜瑙勫垯涓婚敭
-     * @return true琛ㄧず宸茬粡浣跨敤锛宖alse琛ㄧず鏈浣跨敤
-     */
-    @Override
-    public boolean isAlreadyInUse(String oid) {
-        Collection<CodeClassifyVO> codeClassifyVOS = listUseRangeInCodeClassify(oid);
-        if (codeClassifyVOS.size() > 0) {
-            return true;
-        } else {
-            return false;
-        }
-    }
-
-    /**
-     * 鍋滅敤涓庡惎鐢ㄧ紪鐮佽鍒�
-     *
-     * @param oid    缂栫爜瑙勫垯涓婚敭
-     * @param update enable:鍚敤 disable:鍋滅敤 release:鍙戝竷
-     * @return 鎵ц缁撴灉
-     */
-    @Override
-    public BaseResult updateStatus(String oid, String update) {
-        int count = 0;
-        CodeRuleDO codeRuleDO = selectByOid(oid);
-        if ("enable".equalsIgnoreCase(update)) {
-            if (!CodeRuleLC.DISABLED.getValue().equals(codeRuleDO.getLcStatus())) {
-                return BaseResult.fail("闈炲仠鐢ㄧ姸鎬佺殑缂栫爜瑙勫垯鏃犻渶鐐瑰嚮鍚敤");
-            }
-            count = codeRuleMapper.updateLcStatus(oid, CodeRuleLC.RELEASED.getValue());
-        } else if ("disable".equalsIgnoreCase(update)) {
-            if (!CodeRuleLC.RELEASED.getValue().equals(codeRuleDO.getLcStatus())) {
-                return BaseResult.fail("闈炲彂甯冪姸鎬佺殑缂栫爜瑙勫垯鏃犳硶鍋滅敤");
-            }
-            count = codeRuleMapper.updateLcStatus(oid, CodeRuleLC.DISABLED.getValue());
-        } else if ("release".equalsIgnoreCase(update)) {
-            if (!CodeRuleLC.EDITING.getValue().equals(codeRuleDO.getLcStatus())) {
-                return BaseResult.fail("闈炵紪杈戠姸鎬佺殑缂栫爜瑙勫垯鏃犳硶鍙戝竷");
-            }
-            count = codeRuleMapper.updateLcStatus(oid, CodeRuleLC.RELEASED.getValue());
-        } else {
-            return BaseResult.fail("鏆備笉鏀寔鐨勬搷浣滅被鍨�");
-        }
-        if (count > 0) {
-            return BaseResult.success();
-        } else {
-            return BaseResult.fail("鏇存柊鐘舵�佸け璐�");
-        }
-    }
-
-    /**
-     * 鍏嬮殕缂栫爜瑙勫垯
-     *
-     * @param codeRuleDTO 涓绘暟鎹紪鐮佽鍒欐暟鎹紶杈撳璞★紝oid鍜宼s闇�瑕佷紶杈�
-     * @return 涓绘暟鎹紪鐮佽鍒欐樉绀哄璞�
-     */
-    public BaseResult cloneCodeRule_v1(CodeRuleDTO codeRuleDTO) {
-        VciBaseUtil.alertNotNull(codeRuleDTO.getOid(), "缂栫爜瑙勫垯涓婚敭");
-        ClientBusinessObjectOperation operation = new ClientBusinessObjectOperation();
-        Map<String, String> conditionMap = new HashMap<>();
-        conditionMap.put("pkCodeRule", codeRuleDTO.getOid());
-        List<CodeBasicSecDO> basicSecDOS = boService.queryObject(CodeBasicSecDO.class, conditionMap);
-        List<String> secOidList = new ArrayList<>();
-        for (CodeBasicSecDO secDO : basicSecDOS) {
-            secOidList.add(secDO.getOid());
-        }
-        List<ClientBusinessObject> cboList = new ArrayList<>();
-        try {
-            ClientBusinessObject templateCbo = operation.readBusinessObjectById(codeRuleDTO.getOid(), MdmBtmTypeConstant.CODE_RULE);
-            ClientBusinessObject codeRuleCbo = operation.initBusinessObject(templateCbo.getBtmName());
-            String curOid = codeRuleCbo.getOid();
-            String curRevisionId = codeRuleCbo.getRevisionid();
-            String curNameOid = codeRuleCbo.getNameoid();
-            BeanUtilForVCI.copyPropertiesIgnoreCase(templateCbo, codeRuleCbo);
-            codeRuleCbo.setOid(curOid);
-            codeRuleCbo.setRevisionid(curRevisionId);
-            codeRuleCbo.setNameoid(curNameOid);
-            codeRuleCbo.setId(templateCbo.getId() + "_copy");
-            codeRuleCbo.setName(templateCbo.getName() + "_copy");
-            if (!CollectionUtils.isEmpty(secOidList)) {
-                ClientBusinessObject[] secCboArr = operation.readBusinessObjectById(secOidList.toArray(new String[0]), MdmBtmTypeConstant.CODE_BASIC_SEC);
-                for (ClientBusinessObject cbo : secCboArr) {
-                    ClientBusinessObject newSecCbo = operation.initBusinessObject(cbo.getBtmName());
-                    String newSecCboOid = newSecCbo.getOid();
-                    String newSecCboRevisionId = newSecCbo.getRevisionid();
-                    String newSecCboNameOid = newSecCbo.getNameoid();
-                    BeanUtilForVCI.copyPropertiesIgnoreCase(cbo, newSecCbo);
-                    newSecCbo.setOid(newSecCboOid);
-                    newSecCbo.setRevisionid(newSecCboRevisionId);
-                    newSecCbo.setNameoid(newSecCboNameOid);
-                    newSecCbo.setId(newSecCbo.getId() + "_copy");
-                    newSecCbo.setName(newSecCbo.getName() + "_copy");
-                    newSecCbo.setAttributeValue("pkCodeRule", codeRuleCbo.getOid());
-                    cboList.add(newSecCbo);
-                }
-            }
-            cboList.add(codeRuleCbo);
-            ClientBusinessObject[] saveList = operation.batchSaveCreateBuinessObject(cboList.toArray(new ClientBusinessObject[0]));
-            if (saveList.length == 0) {
-                return BaseResult.fail("鍏嬮殕鍑洪敊浜嗏�︹��");
-            }
-        } catch (VCIError vciError) {
-            vciError.printStackTrace();
-        }
-        return BaseResult.success();
-    }
-
-    /**
-     * 鍏嬮殕缂栫爜瑙勫垯
-     *
-     * @param codeRuleDTO 涓绘暟鎹紪鐮佽鍒欐暟鎹紶杈撳璞★紝oid鍜宼s闇�瑕佷紶杈�
-     * @return 涓绘暟鎹紪鐮佽鍒欐樉绀哄璞�
-     */
-    @Override
-    public BaseResult cloneCodeRule(CodeRuleDTO codeRuleDTO) {
-        VciBaseUtil.alertNotNull(codeRuleDTO, "闇�瑕佹坊鍔犵殑鏁版嵁瀵硅薄");
-        CodeRuleDO codeRuleDO = new CodeRuleDO();
-        BeanUtilForVCI.copyPropertiesIgnoreCase(codeRuleDTO, codeRuleDO);
-        WebUtil.setPersistence(false);
-        BatchCBO batchInsertCBO = codeRuleMapper.insert(codeRuleDO);
-        List<CodeBasicSecDTO> secList = codeRuleDTO.getElements();
-        secList.forEach(codeBasicSecDTO -> {
-            codeBasicSecDTO.setPkCodeRule(codeRuleDO.getOid());
-            KeyValue attrKv = codeBasicSecService.checkAttrNullableBySecType(codeBasicSecDTO);
-            if (!"success".equals(attrKv.getKey())) {
-                throw new VciBaseException(attrKv.getValue() + "涓嶈兘涓虹┖");
-            }
-            CodeBasicSecDO codeBasicSecDO = new CodeBasicSecDO();
-            BeanUtilForVCI.copyPropertiesIgnoreCase(codeBasicSecDTO, codeBasicSecDO);
-            codeBasicSecDO.setOid("");
-            codeBasicSecDO.setRevisionOid("");
-            codeBasicSecDO.setNameOid("");
-			//codeBasicSecMapper涓殑璇彞鍏ㄩ儴杩佺Щ鍒拌繖閲�
-			VciBaseUtil.alertNotNull(codeBasicSecDO,"瑕佹坊鍔犵殑鏁版嵁");
-			BatchCBO cbo = boService.addSave(codeBasicSecDO);
-			batchInsertCBO.addCreateCbo(cbo.getCreateCboArray()[0]);
-        });
-        boService.persistenceBatch(batchInsertCBO);
-        return BaseResult.success();
-    }
-
-    /**
-     * 浣跨敤涓婚敭鑾峰彇缂栫爜瑙勫垯鐨勫唴瀹�
-     *
-     * @param oid 涓婚敭
-     * @return 瑙勫垯鐨勬樉绀哄璞�
-     */
-    @Override
-    public CodeRuleVO getObjectHasSecByOid(String oid) {
-        CodeRuleDO ruleDO = selectByOid(oid);
-        return codeRuleDO2VO(ruleDO, true);
-    }
-
-    /**
-     * 缂栫爜瑙勫垯娓呯┖鎵�鏈夊凡鐢熸垚鐨勭紪鐮�
-     *
-     * @param oid 缂栫爜瑙勫垯涓婚敭
-     * @return 鎵ц缁撴灉
-     */
-    @Override
-    public BaseResult clearAllCode(String oid) {
-        WebUtil.alertNotNull(oid, "缂栫爜瑙勫垯涓婚敭");
-        Map<String, String> conditionMap = new HashMap<>();
-        conditionMap.put("codeRuleOid", oid);
-        List<CodeAllCodeDO> codeDOList = boService.queryObject(CodeAllCodeDO.class, conditionMap);
-        if (CollectionUtils.isEmpty(codeDOList)) {
-            return BaseResult.fail("褰撳墠缂栫爜瑙勫垯娌℃湁鐢熸垚缂栫爜,鏃犻渶娓呯┖");
-        }
-        //鏄惁闇�瑕佽繘琛宐tm涓嶇粺涓�鐨勫垽鏂�?
-        String btmType = codeDOList.get(0).getCreateCodeBtm();
-        /*boolean flag = codeDOList.stream().anyMatch(s -> !StringUtils.equalsIgnoreCase(btmType, s.getCreateCodeBtm()));
-        if (flag) {
-            return BaseResult.fail("褰撳墠缂栫爜瑙勫垯鐢熸垚缂栫爜鍦ㄤ笉鍚岀被鍨嬩笅浣跨敤杩�");
-        }*/
-        //澶氱绫诲瀷涓嬬殑鏌ヨ
-        Set<String> btmTypeSet = codeDOList.stream().filter(s -> {
-            return !StringUtils.equalsIgnoreCase(btmType, s.getCreateCodeBtm());
-        }).map(s -> s.getCreateCodeBtm()).collect(Collectors.toSet());
-        List<ClientBusinessObject> businessDataList = new ArrayList<>();
-        if (btmTypeSet.size() > 1) {
-            for (String btm : btmTypeSet) {
-                String sql = "select COUNT(w.OID) from PLATFORMBTM_" + btm + "  w\n" +
-                        "join PLATFORMBTM_" + MdmBtmTypeConstant.CODE_ALL_CODE + " c on w.OID = c.CREATECODEOID\n" +
-                        "where c.CREATECODEBTM = '" + btm + "' and c.CODERULEOID = '" + oid + "'" +
-                        "and w.ISLASTR = '1' and w.ISLASTV = '1'";
-                List<ClientBusinessObject> businessData = boService.queryByOnlySql(sql);
-                businessDataList.addAll(businessData);
-            }
-        }else {
-            String sql = "select COUNT(w.OID) from PLATFORMBTM_" + btmType + "  w\n" +
-                    "join PLATFORMBTM_" + MdmBtmTypeConstant.CODE_ALL_CODE + " c on w.OID = c.CREATECODEOID\n" +
-                    "where c.CREATECODEBTM = '" + btmType + "' and c.CODERULEOID = '" + oid + "'" +
-                    "and w.ISLASTR = '1' and w.ISLASTV = '1'";
-            List<ClientBusinessObject> businessData = boService.queryByOnlySql(sql);
-            businessDataList.addAll(businessData);
-        }
-        if (CollectionUtils.isEmpty(businessDataList) || StringUtils.isBlank(businessDataList.get(0).getAttributeValue("COUNT(w.OID)"))) {
-            //鏃犳晥鏌ヨ
-            return BaseResult.fail("鏌ヨ澶辫触");
-        } else if (!StringUtils.equalsIgnoreCase("0", businessDataList.get(0).getAttributeValue("COUNT(w.OID)"))) {
-            return BaseResult.fail("缂栫爜瑙勫垯鐢熸垚鐨勭紪鐮佸凡鍦ㄤ笟鍔℃暟鎹腑搴旂敤锛屼笉鍏佽娓呯┖");
-        }
-        //娌℃湁鏁版嵁锛屽彲浠ュ畨鍏ㄥ垹闄�
-        WebUtil.setPersistence(false);
-        //鍒犻櫎鐮佸�艰〃涓殑鏁版嵁锛屼絾涓嶅锛屽鏋滄湁娴佹按鐨勭爜娈碉紝闇�瑕侀噸鏂拌绠楁祦姘�
-        conditionMap.clear();
-        conditionMap.put("codeRuleOid", oid);
-        List<ClientBusinessObject> serialValueList = boService.queryCBO("codeserialvalue", conditionMap);
-        BatchCBO batchCBO = boService.batchDelete(codeDOList);
-        batchCBO.getDeleteCbos().addAll(serialValueList);
-        WebUtil.setPersistence(true);
-        boService.persistenceBatch(batchCBO);
-        return BaseResult.success();
-    }
 }
-

--
Gitblit v1.9.3