From 336265194a47bcbdbd5f8d2274d10a6284ee1246 Mon Sep 17 00:00:00 2001
From: mamc <1428594221@qq.com>
Date: 星期三, 28 六月 2023 14:43:26 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeBasicSecServiceImpl.java | 628 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 595 insertions(+), 33 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 932cf97..b20064a 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,62 @@
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.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.CodeClassify;
import com.vci.ubcs.code.entity.CodeClassifyValue;
import com.vci.ubcs.code.entity.CodeFixedValue;
-import com.vci.ubcs.code.enumpack.CodeSecTypeEnum;
+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.ICodeRuleService;
+import com.vci.ubcs.code.service.*;
+import com.vci.ubcs.code.vo.CodeReferConfigVO;
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.wrapper.CodeBasicSecWrapper;
-import com.vci.ubcs.com.vci.starter.exception.VciBaseException;
-import com.vci.ubcs.com.vci.starter.web.enumpck.OsCodeFillTypeEnum;
-import com.vci.ubcs.com.vci.starter.web.pagemodel.KeyValue;
-import com.vci.ubcs.com.vci.starter.web.pagemodel.SessionInfo;
-import com.vci.ubcs.com.vci.starter.web.pagemodel.UIFormReferVO;
-import com.vci.ubcs.com.vci.starter.web.util.BeanUtilForVCI;
-import com.vci.ubcs.com.vci.starter.web.util.VciBaseUtil;
-import com.vci.ubcs.com.vci.starter.web.util.WebUtil;
+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.NewAppConstantEnum;
+import com.vci.ubcs.starter.web.enumpck.OsCodeFillTypeEnum;
+import com.vci.ubcs.starter.web.pagemodel.BladeQueryObject;
+import com.vci.ubcs.starter.web.pagemodel.KeyValue;
+import com.vci.ubcs.starter.web.pagemodel.UIFormReferVO;
+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.log.exception.ServiceException;
+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.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;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
import java.util.stream.Collectors;
+
+import static com.vci.ubcs.code.constant.FrameWorkLangCodeConstant.*;
/**
* 鐮佹鍩虹淇℃伅鏈嶅姟鎺ュ彛
@@ -65,24 +84,60 @@
private CodeClassifyValueMapper codeClassifyValueMapper;
@Resource
+ private RevisionModelUtil revisionModelUtil;
+
+ @Resource
@Lazy
private ICodeRuleService codeRuleService;
+ @Resource
+ private ICodeClassifyValueService codeClassifyValueService;
+
+ @Resource
+ private ICodeReferConfigService codeReferConfigService;
+
+ @Resource
+ private IDictBizClient iDictBizClient;
+
+ /**
+ * 鍥哄畾鐮佹鐨勭爜鍊肩殑鏈嶅姟
+ */
+ @Resource
+ private ICodeFixedValueService fixedValueService;
+
+ /**
+ * 涓婂眰鍒嗙被鐮佹鐨勫睘鎬у悕绉�
+ */
+ private static final String PARENT_FIELD_NAME = "parentclassifysecoid";
+
+ /**
+ * 涓婄骇鍒嗙被鐮佸�肩殑灞炴�у悕绉�
+ */
+ private static final String PARENT_CLASSIFY_VALUE_FIELD_NAME = "parentClassifyValueOid";
+
/**
* 鏌ヨ鎵�鏈夌殑鐮佹鍩虹淇℃伅
- *
- * @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);
}
/**
@@ -92,7 +147,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));
@@ -135,9 +190,9 @@
* @return 鏈夌┖鐨勫垯浼爇ey-灞炴�у悕 value-瀛楁鍚箟锛屾病鏈夌┖鐨勫垯浼� key-success value-true
*/
@Override
- public KeyValue checkAttrNullableBySecType(CodeBasicSecDTO codeBasicSecDTO) {
- VciBaseUtil.alertNotNull(codeBasicSecDTO.getSectype(), "鐮佹鍒嗙被");
- String secType = codeBasicSecDTO.getSectype();
+ 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);
Map<String, String> notNullableAttr = getNotNullableAttr(secType);
if (notNullableAttr == null) {
@@ -165,6 +220,7 @@
* @throws VciBaseException 鍙傛暟涓虹┖锛屽敮涓�椤癸紝蹇呰緭椤逛笉閫氳繃鏃朵細鎶涘嚭寮傚父
*/
@Override
+ @Transactional(rollbackFor = Exception.class)
public boolean addSave(CodeBasicSecDTO codeBasicSecDTO) throws VciBaseException {
VciBaseUtil.alertNotNull(codeBasicSecDTO, "闇�瑕佹坊鍔犵殑鏁版嵁瀵硅薄",codeBasicSecDTO.getPkCodeRule(),"缂栫爜瑙勫垯鐨勪富閿�");
CodeRuleVO ruleVO = codeRuleService.getObjectByOid(codeBasicSecDTO.getPkCodeRule());
@@ -175,10 +231,17 @@
if (! "success".equals(attrKv.getKey())){
throw new VciBaseException(attrKv.getValue() + "涓嶈兘涓虹┖");
}
-
//灏咲TO杞崲涓篋O
CodeBasicSec codeBasicSecDO = new CodeBasicSec();
BeanUtilForVCI.copyPropertiesIgnoreCase(codeBasicSecDTO, codeBasicSecDO);
+ //text杞崲
+ 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
Long total = codeBasicSecMapper.selectCount(Wrappers.<CodeBasicSec>query()
.lambda()
@@ -194,22 +257,92 @@
&& 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("寮曠敤鐮佹鐨勬椂鍊欙紝闇�瑕佸~鍐� 鍙傜収閰嶇疆 鐨勫唴瀹�");
}
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);
}
+ if(codeReferConfigVO.getIsPersistence()=="true"){
+ codeReferConfigService.insert(codeReferConfigVO);
+ }
}
boolean resBoolean = codeBasicSecMapper.insert(codeBasicSecDO) > 0;
- SessionInfo sessionInfo = VciBaseUtil.getCurrentUserSessionInfo();
- /*if(StringUtils.isNotBlank(codeBasicSecDO.getCodeFillSeparator())){
- charService.save(MdmBtmTypeConstant.CODE_BASIC_SEC,"codefileseparator",codeBasicSecDO.getCodeFillSeparator(),sessionInfo);
- }*/
+ //SessionInfo sessionInfo = VciBaseUtil.getCurrentUserSessionInfo();
+ if(StringUtils.isNotBlank(codeBasicSecDO.getCodeFillSeparator())){
+ DictBiz dictBiz = new DictBiz();
+ dictBiz.setCode(MdmBtmTypeConstant.CODE_BASIC_SEC);
+ dictBiz.setDictKey("codefileseparator");
+ dictBiz.setDictValue(codeBasicSecDO.getCodeFillSeparator());
+ //浠庡師鏉ョ殑charService锛堝彲杈撳彲閫夛級鏇存敼涓鸿皟鐢╫md涓殑鎺ュ彛鏉ュ疄鐜�
+ iDictBizClient.getCheck(dictBiz);
+ //charService.save(MdmBtmTypeConstant.CODE_BASIC_SEC,"codefileseparator",codeBasicSecDO.getCodeFillSeparator(),sessionInfo);
+ }
+ return resBoolean;
+ }
+
+ /**
+ * 淇敼鐮佹鍩虹淇℃伅
+ *
+ * @param codeBasicSecDTO 鐮佹鍩虹淇℃伅鏁版嵁浼犺緭瀵硅薄
+ * @return 鎵ц缁撴灉
+ * @throws VciBaseException 鍙傛暟涓虹┖锛屽敮涓�椤癸紝蹇呰緭椤逛笉閫氳繃鏃朵細鎶涘嚭寮傚父
+ */
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public boolean editSave(CodeBasicSecDTO codeBasicSecDTO) throws VciBaseException {
+ VciBaseUtil.alertNotNull(codeBasicSecDTO, "闇�瑕佹坊鍔犵殑鏁版嵁瀵硅薄");
+ KeyValue attrKv = checkAttrNullableBySecType(codeBasicSecDTO);
+ if (! "success".equals(attrKv.getKey())){
+ throw new VciBaseException(attrKv.getValue() + "涓嶈兘涓虹┖");
+ }
+ //灏咲TO杞崲涓篋O
+ CodeBasicSec codeBasicSecDO = selectByOid(codeBasicSecDTO.getOid());
+ DefaultAttrAssimtUtil.updateDefaultAttrAssimt(codeBasicSecDO);
+ boolean status = codeRuleService.checkEditDelStatus(codeRuleService.getObjectByOid(codeBasicSecDO.getPkCodeRule()).getLcStatus());
+ boolean resBoolean;
+ if (!status){
+ //杩斿洖閿欒淇℃伅
+ throw new VciBaseException("缂栫爜瑙勫垯涓嶅厑璁哥紪杈戞垨鍒犻櫎锛�");
+ } else {
+ //琛ヤ綅鐨勬椂鍊欙紝瑕佹帶鍒惰ˉ浣嶅瓧绗�
+ if((OsCodeFillTypeEnum.LEFT.getValue().equalsIgnoreCase(codeBasicSecDO.getCodeFillType())
+ || OsCodeFillTypeEnum.RIGHT.getValue().equalsIgnoreCase(codeBasicSecDO.getCodeFillType()))
+ && StringUtils.isBlank(codeBasicSecDO.getCodeFillSeparator())){
+ throw new VciBaseException("褰撹ˉ浣嶆柟寮忎负宸﹁ˉ浣嶆垨鑰呭彸琛ヤ綅鐨勬椂鍊欙紝琛ヤ綅瀛楃涓嶈兘涓虹┖");
+ }
+ //寮曠敤鐮佹鐨勬椂鍊欙紝闇�瑕佸垽鏂弬鐓х殑淇℃伅鏄惁姝g‘
+ if(CodeSecTypeEnum.CODE_REFER_SEC.getValue().equalsIgnoreCase(codeBasicSecDO.getSecType())){
+ if(StringUtils.isBlank(codeBasicSecDO.getReferConfig())){
+ throw new VciBaseException("寮曠敤鐮佹鐨勬椂鍊欙紝闇�瑕佸~鍐� 鍙傜収閰嶇疆 鐨勫唴瀹�");
+ }
+ try{
+ JSONObject.parseObject(codeBasicSecDO.getReferConfig(), UIFormReferVO.class);
+ }catch (Throwable e){
+ throw new VciBaseException("寮曠敤鐮佹鐨勬椂鍊欙紝鍙傜収閰嶇疆鐨勫唴瀹圭殑鏍煎紡涓嶆纭�,",new String[0],e);
+ }
+ }
+ 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.setDictValue(codeBasicSecDO.getCodeFillSeparator());
+ //浠庡師鏉ョ殑charService锛堝彲杈撳彲閫夛級鏇存敼涓鸿皟鐢╫md涓殑鎺ュ彛鏉ュ疄鐜�
+ iDictBizClient.getCheck(dictBiz);
+ //charService.save(MdmBtmTypeConstant.CODE_BASIC_SEC,"codefileseparator",codeBasicSecDO.getCodeFillSeparator(),sessionInfo);
+ }
+ }
return resBoolean;
}
@@ -219,7 +352,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", "灞炴�х爜娈靛悕绉�");
@@ -257,6 +390,435 @@
return attrMap;
}
+ /**
+ * 鍒犻櫎鐮佹鍩虹淇℃伅
+ * @param codeBasicSecDTO 鐮佹鍩虹淇℃伅鏁版嵁浼犺緭瀵硅薄锛宱id鍜宼s闇�瑕佷紶杈�
+ * @return 鍒犻櫎缁撴灉鍙嶉锛氾細success锛氭垚鍔燂紝fail锛氬け璐�
+ * @throws VciBaseException 鍙傛暟涓虹┖锛岃寮曠敤鏃舵姏鍑哄紓甯�
+ */
+ @Override
+ public R deleteCodeBasicSec(CodeBasicSecDTO codeBasicSecDTO) throws VciBaseException {
+ VciBaseUtil.alertNotNull(codeBasicSecDTO, "鐮佹鍩虹淇℃伅鏁版嵁瀵硅薄", codeBasicSecDTO.getOid(), "鐮佹鍩虹淇℃伅鐨勪富閿�");
+ return this.deleteCodeBasicSecByPrimaryKey(codeBasicSecDTO.getOid());
+ }
+
+ /**
+ * 涓婚敭鍒犻櫎鐮佹鍩虹淇℃伅
+ *
+ * @param oid 鐮佹鍩虹淇℃伅涓婚敭
+ * @return 鍒犻櫎缁撴灉鍙嶉锛氾細success锛氭垚鍔燂紝fail锛氬け璐�
+ * @throws VciBaseException 鍙傛暟涓虹┖锛岃寮曠敤鏃舵姏鍑哄紓甯�
+ */
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public R deleteCodeBasicSecByPrimaryKey(String oid) throws VciBaseException {
+ CodeBasicSec codeBasicSecDO = selectByOid(oid);
+ boolean isLinked = checkIsLinked(codeBasicSecDO.getPkCodeRule(), oid);
+ if (isLinked) {
+ return R.fail("缂栫爜瑙勫垯宸茶寮曠敤锛屼笉鍏佽缂栬緫鎴栧垹闄�");
+ }
+ //鎵ц鍒犻櫎鎿嶄綔
+ boolean eftDeleteBasic = codeBasicSecMapper.deleteById(oid) > 0;
+ if (CodeSecTypeEnum.CODE_FIXED_SEC.getValue().equals(codeBasicSecDO.getSecType())){
+ List<CodeFixedValue> fixedValueDOS = fixedValueMapper.selectList(Wrappers.<CodeFixedValue>query()
+ .lambda().eq(CodeFixedValue::getCodeFixedSecOid,codeBasicSecDO.getOid())
+ );
+ if(!CollectionUtils.isEmpty(fixedValueDOS)){
+ fixedValueMapper.deleteBatchIds(fixedValueDOS.stream().map(CodeFixedValue::getOid).collect(Collectors.toSet()));
+ }
+ }
+ if (CodeSecTypeEnum.CODE_CLASSIFY_SEC.getValue().equals(codeBasicSecDO.getSecType())){
+ List<CodeClassifyValue> classifyValueDOS = codeClassifyValueMapper.selectList(Wrappers.<CodeClassifyValue>query()
+ .lambda().eq(CodeClassifyValue::getCodeClassifySecOid,codeBasicSecDO.getOid())
+ );
+ if(!CollectionUtils.isEmpty(classifyValueDOS)) {
+ codeClassifyValueMapper.deleteBatchIds(classifyValueDOS.stream().map(CodeClassifyValue::getOid).collect(Collectors.toSet()));
+ }
+ }
+
+ return eftDeleteBasic ? R.success(DELETE_SUCCESS) : R.fail(DELETE_FAIL);
+ }
+
+ /**
+ * 涓婚敭鑾峰彇鐮佹鍩虹淇℃伅
+ *
+ * @param oid 涓婚敭
+ * @return 鐮佹鍩虹淇℃伅鏄剧ず瀵硅薄
+ * @throws VciBaseException 鍙傛暟涓虹┖锛屾暟鎹笉瀛樺湪鏃朵細鎶涘嚭寮傚父
+ */
+ @Override
+ public CodeBasicSecVO getObjectByOid(String oid) throws VciBaseException {
+ return CodeBasicSecWrapper.build().entityVO(selectByOid(oid));
+ }
+
+ /**
+ * 涓婚敭鎵归噺鑾峰彇鐮佹鍩虹淇℃伅
+ *
+ * @param oidCollections 涓婚敭闆嗗悎锛屼絾鏄彈鎬ц兘褰卞搷锛屽缓璁竴娆℃煡璇笉瓒呰繃10000涓�
+ * @return 鐮佹鍩虹淇℃伅鏄剧ず瀵硅薄
+ * @throws VciBaseException 鏌ヨ鍑虹幇寮傚父鏃朵細鎶涘嚭
+ */
+ @Override
+ public Collection<CodeBasicSecVO> listCodeBasicSecByOids(Collection<String> oidCollections) throws VciBaseException {
+ VciBaseUtil.alertNotNull(oidCollections, "鏁版嵁瀵硅薄涓婚敭闆嗗悎");
+ List<CodeBasicSec> codeBasicSecDOList = listCodeBasicSecDOByOidCollections(oidCollections);
+ return CodeBasicSecWrapper.build().listVO(codeBasicSecDOList);
+ }
+
+ /**
+ * 鍙傜収鐮佹鍩虹淇℃伅鍒楄〃
+ *
+ * @param conditionMap 鏌ヨ鏉′欢
+ * @param query 鍒嗛〉鍜屾帓搴�
+ * @return 鐮佹鍩虹淇℃伅鏄剧ず瀵硅薄鍒楄〃锛岀敓鏁堢殑鍐呭
+ * @throws VciBaseException 鏌ヨ鏉′欢鍜屽垎椤靛嚭閿欑殑鏃跺�欎細鎶涘嚭寮傚父
+ */
+ @Override
+ public IPage<CodeBasicSecVO> refDataGridCodeBasicSec(Query query ,Map<String,Object> conditionMap) throws VciBaseException {
+ return gridCodeBasicSec(query,conditionMap);
+ }
+
+ /**
+ * 鍙傜収鍒嗙被鐨勭爜娈�
+ * @param conditionMap 鏌ヨ鏉′欢
+ * @param query 鍒嗛〉鍜屾帓搴�
+ * @return 鐮佹鐨勫唴瀹�
+ */
+ @Override
+ public IPage<CodeBasicSecVO> refDataGridClassifySec(Query query ,Map<String,Object> conditionMap) throws VciBaseException {
+ if(Func.isEmpty(conditionMap.get("pkCodeRule"))){
+ return null;
+ }
+ conditionMap.put("secType",(CodeSecTypeEnum.CODE_CLASSIFY_SEC.getValue()));
+ return refDataGridCodeBasicSec(query.setAscs("ordernum"),conditionMap);
+ }
+
+ /**
+ * 鍏嬮殕鐮佹淇℃伅
+ *
+ * @param oidList 婧愮爜娈典俊鎭富閿泦鍚�
+ * @param pkCodeRule 鐩爣缂栫爜瑙勫垯
+ * @return 鍏嬮殕缁撴灉鍙嶉锛氾細success锛氭垚鍔燂紝fail锛氬け璐�
+ */
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ 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(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 resBoolean = saveBatch(createList);
+ //codeBasicSecMapper.insertBatch(createList);
+ return resBoolean ? R.data(resBoolean,"鍏嬮殕鐮佹淇℃伅鎴愬姛"):R.fail("鍏嬮殕鐮佹淇℃伅澶辫触锛�");
+ }
+
+ /**
+ * 鏌ヨ鐩爣鍒嗙被鐮佹鎵�鍦ㄧ殑鏍戠粨鏋�
+ *
+ * @param oid 鐩爣鍒嗙被鐮佹涓婚敭
+ * @return 鍒嗙被鐮佹鏍戠粨鏋�
+ */
+ /*@Override
+ public List<Tree> gridCodeClassifySecTree(String oid) {
+ VciParentQueryOption queryOption = new VciParentQueryOption(PARENT_FIELD_NAME);
+ queryOption.setfOid(oid);
+ queryOption.setLinkTypeFlag(false);
+ queryOption.setHasSelf(true);
+ VciQueryWrapperForDO wrapper = new VciQueryWrapperForDO(CodeBasicSec.class);
+ wrapper.childQueryParent(queryOption);
+ List<CodeBasicSec> doList = codeBasicSecMapper.selectByWrapper(wrapper);
+ List<String> secOid = new ArrayList<>();
+ doList.forEach(o -> secOid.add(o.getOid()));
+ List<CodeClassifyValueVO> valueVOs = (List<CodeClassifyValueVO>) codeClassifyValueService.listCodeClassifyValueByOids(secOid);
+ TreeQueryObject treeQueryObject = new TreeQueryObject();
+ treeQueryObject.setMultipleSelect(false);
+ treeQueryObject.setShowCheckBox(false);
+ treeQueryObject.setQueryAllLevel(false);
+ treeQueryObject.setValueField("oid");
+ treeQueryObject.setTextField("name");
+ treeQueryObject.setQueryAllRev(false);
+ TreeWrapperOptions treeWrapperOptions = new TreeWrapperOptions(PARENT_CLASSIFY_VALUE_FIELD_NAME);
+ treeWrapperOptions.copyFromTreeQuery(treeQueryObject);
+ return revisionModelUtil.doList2Trees(valueVOs,treeWrapperOptions,(CodeClassifyValueVO s) ->{
+ //鍙互鍦ㄨ繖閲屽鐞嗘爲鑺傜偣鐨勬樉绀�
+ return s.getId() + " " + s.getName() + (FrameworkDataLCStatus.DISABLED.getValue().equalsIgnoreCase(s
+ .getLcStatus()) ? (" 銆愬仠鐢ㄣ�� ") : "");
+ });
+ }*/
+
+ /**
+ * 涓婄Щ
+ *
+ * @param oid 涓婚敭
+ */
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public boolean upOrderNum(String oid) throws ServiceException{
+ CodeBasicSec secDO = selectByOid(oid);
+ if(secDO.getOrderNum() > 1){
+ //绛変簬1鐨勬椂鍊欎笉鑳戒笂绉讳簡
+ //鎵炬瘮鑷繁灏忕殑
+ List<CodeBasicSec> lastSecDOs = codeBasicSecMapper.selectList(Wrappers.<CodeBasicSec>query()
+ .lambda().eq(CodeBasicSec::getPkCodeRule,secDO.getPkCodeRule())
+ .eq(CodeBasicSec::getOrderNum,String.valueOf(secDO.getOrderNum()-1))
+ );
+ if(!CollectionUtils.isEmpty(lastSecDOs)){
+ CodeBasicSec lastSec = lastSecDOs.get(0);
+ codeBasicSecMapper.update(null, Wrappers.<CodeBasicSec>update()
+ .lambda().set(CodeBasicSec::getOrderNum, lastSec.getOrderNum() + 1)
+ .eq(CodeBasicSec::getOid, lastSec.getOid())
+ );
+ }
+ codeBasicSecMapper.update(null, Wrappers.<CodeBasicSec>update()
+ .lambda().set(CodeBasicSec::getOrderNum, secDO.getOrderNum() - 1)
+ .eq(CodeBasicSec::getOid, secDO.getOid())
+ );
+ }
+ return true;
+ }
+
+ /**
+ * 涓嬬Щ
+ *
+ * @param oid 涓婚敭
+ */
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public boolean downOrderNum(String oid) throws ServiceException {
+ CodeBasicSec secDO = selectByOid(oid);
+ Long total = codeBasicSecMapper.selectCount(Wrappers.<CodeBasicSec>query()
+ .lambda().eq(CodeBasicSec::getPkCodeRule,secDO.getPkCodeRule())
+ );
+ if(secDO.getOrderNum() < total){
+ //灏忎簬鎬绘暟鐨勬椂鍊欐墠涓嬬Щ
+ List<CodeBasicSec> lastSecDOs = codeBasicSecMapper.selectList(Wrappers.<CodeBasicSec>query()
+ .lambda().eq(CodeBasicSec::getOrderNum,secDO.getOrderNum()+1)
+ .eq(CodeBasicSec::getPkCodeRule,secDO.getPkCodeRule())
+ );
+ if(!CollectionUtils.isEmpty(lastSecDOs)){
+ CodeBasicSec lastSec = lastSecDOs.get(0);
+ codeBasicSecMapper.update(null, Wrappers.<CodeBasicSec>update()
+ .lambda().set(CodeBasicSec::getOrderNum, lastSec.getOrderNum() - 1)
+ .eq(CodeBasicSec::getOid, lastSec.getOid())
+ );
+ }
+ codeBasicSecMapper.update(null, Wrappers.<CodeBasicSec>update()
+ .lambda().set(CodeBasicSec::getOrderNum, secDO.getOrderNum() + 1)
+ .eq(CodeBasicSec::getOid, secDO.getOid())
+ );
+ }
+ return true;
+ }
+
+ /**
+ * 鏍戝舰缁撴瀯鏌ヨoid
+ * @param codeClassifySecOid
+ * @return
+ */
+ @Override
+ public List<String> getOidByCodeclassifysecOid(String codeClassifySecOid)throws ServiceException {
+ return codeBasicSecMapper.getOidByCodeclassifysecOid(codeClassifySecOid.trim());
+ }
+
+ /**
+ * 鏍¢獙鏄惁琚紩鐢�
+ *
+ * @param codeRuleOid 缂栫爜瑙勫垯涓婚敭
+ * @param codeBasicSecOid 缂栫爜鍩虹淇℃伅涓婚敭
+ * @return true琛ㄧず宸茶寮曠敤锛宖alse琛ㄧず鏈寮曠敤
+ * @throws VciBaseException 琚紩鐢ㄧ殑鏃跺�欎細鎶涘嚭寮傚父
+ */
+ private boolean checkIsLinked(String codeRuleOid, String codeBasicSecOid) throws VciBaseException {
+ boolean flag = true;
+ if (StringUtils.isNotBlank(codeRuleOid)) {
+ boolean status = codeRuleService.checkEditDelStatus(codeRuleService.getObjectByOid(codeRuleOid).getLcStatus());
+ if (!status){
+ return true;
+ }
+ boolean alreadyInUse = codeRuleService.isAlreadyInUse(codeRuleOid);
+ if (!alreadyInUse){
+ flag = false;
+ }
+ } else {
+ boolean status = codeRuleService.checkEditDelStatus(codeRuleService.getObjectByOid(codeBasicSecMapper.selectById(codeBasicSecOid).getPkCodeRule()).getLcStatus());
+ if (!status){
+ return true;
+ }
+ boolean alreadyInUse = codeRuleService.isAlreadyInUse(codeBasicSecMapper.selectById(codeBasicSecOid).getPkCodeRule());
+ if (!alreadyInUse){
+ flag = false;
+ }
+ }
+ return flag;
+ }
+
+ /**
+ * 浣跨敤涓婚敭闆嗗悎鏌ヨ鏁版嵁瀵硅薄
+ *
+ * @param oidCollections 涓婚敭鐨勯泦鍚�
+ * @return 鏁版嵁瀵硅薄鍒楄〃
+ */
+ private List<CodeBasicSec> listCodeBasicSecDOByOidCollections(Collection<String> oidCollections) {
+ List<CodeBasicSec> codeBasicSecDOList = new ArrayList<>();
+ if (!CollectionUtils.isEmpty(oidCollections)) {
+ Collection<Collection<String>> oidCollectionsList = VciBaseUtil.switchCollectionForOracleIn(oidCollections);
+ for (Collection<String> oids : oidCollectionsList) {
+ List<CodeBasicSec> tempDOList = codeBasicSecMapper.selectBatchIds(oids);
+ if (!CollectionUtils.isEmpty(tempDOList)) {
+ codeBasicSecDOList.addAll(tempDOList);
+ }
+ }
+ }
+ return codeBasicSecDOList;
+ }
+
+ /**
+ * 涓婚敭鏌ヨ鏁版嵁瀵硅薄
+ *
+ * @param oid 涓婚敭
+ * @return 鏁版嵁瀵硅薄
+ * @throws VciBaseException 鍙傛暟涓虹┖锛屽苟涓旀暟鎹笉瀛樺湪鐨勬椂鍊欎細鎶涘嚭寮傚父
+ */
+ private CodeBasicSec selectByOid(String oid) throws VciBaseException {
+ VciBaseUtil.alertNotNull(oid, "涓婚敭");
+ CodeBasicSec codeBasicSecDO = codeBasicSecMapper.selectById(oid.trim());
+ if (codeBasicSecDO == null || StringUtils.isBlank(codeBasicSecDO.getOid())) {
+ throw new VciBaseException(DATA_OID_NOT_EXIST);
+ }
+ return codeBasicSecDO;
+ }
+ /**
+ * 浣跨敤瑙勫垯鐨勪富閿幏鍙栧搴旂殑鐮佹鍐呭
+ *
+ * @param ruleOid 瑙勫垯鐨勫唴瀹�
+ * @return 鐮佹鐨勫唴瀹�
+ */
+ @Override
+ 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.eq("pkCodeRule",ruleOid);
+ wrapper.orderByAsc("ordernum");
+ List<CodeBasicSec> secDOList = baseMapper.selectList(wrapper);//.selectByCondition(conditionMap, pageHelper);
+ return codeBasicSecDO2VOs(secDOList,true);
+ }
+
+ /**
+ * 鎵归噺鏁版嵁瀵硅薄杞崲涓烘樉绀哄璞�
+ *
+ * @param codeBasicSecDOs 鏁版嵁瀵硅薄鍒楄〃
+ * @param hasFixedValue 鏄惁鏈夊浐瀹氬��
+ * @return 鏄剧ず瀵硅薄
+ * @throws VciBaseException 鍙傛暟涓虹┖鎴栬�呬笉瀛樺湪鐨勬椂鍊欎細鎶涘嚭寮傚父
+ */
+ @Override
+ public List<CodeBasicSecVO> codeBasicSecDO2VOs(Collection<CodeBasicSec> codeBasicSecDOs, boolean hasFixedValue) 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);
+ }
+ }
+ }
+ if(hasFixedValue && !CollectionUtils.isEmpty(voList)){
+ List<CodeBasicSecVO> fixedSecVOList = voList.stream().filter(s -> CodeSecTypeEnum.CODE_FIXED_SEC.getValue().equalsIgnoreCase(s.getSecType())).collect(Collectors.toList());
+ if(!CollectionUtils.isEmpty(fixedSecVOList)){
+ //鏌ヨ鍥哄畾鐮佺殑鐮佸��
+ Map<String, List<CodeFixedValueVO>> secValueMap = fixedValueService.listCodeFixedValueBySecOids(fixedSecVOList.stream().map(CodeBasicSecVO::getOid).collect(Collectors.toList()));
+ voList.stream().forEach(vo->{
+ vo.setFixedValueVOList(secValueMap.getOrDefault(vo.getOid(),null));
+ });
+ }
+ }
+ return voList;
+ }
+
+ /**
+ * 鎵归噺鏁版嵁瀵硅薄杞崲涓烘樉绀哄璞�
+ *
+ * @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 鏁版嵁瀵硅薄
+ * @return 鏄剧ず瀵硅薄
+ * @throws VciBaseException 鎷疯礉灞炴�у嚭閿欑殑鏃跺�欎細鎶涘嚭寮傚父
+ */
+ @Override
+ public CodeBasicSecVO codeBasicSecDO2VO(CodeBasicSec codeBasicSecDO) throws VciBaseException {
+ CodeBasicSecVO codeBasicSecVO = new CodeBasicSecVO();
+ if (codeBasicSecDO != null) {
+ 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()));
+ codeBasicSecVO.setParentClassifySecText(codeBasicSec.getName());
+ }
+ //濡傛灉鏈塴cstatus鐨勭被鐨勮瘽
+ if (true) {
+ //vo.setLcStatusText({lcStatusFullClassName}.getTextByValue(vo.getLcStatus()));
+ }
+ }
+ return codeBasicSecVO;
+ }
}
--
Gitblit v1.9.3