From e9b405657b6117a8dcfcf8505cfd5d6eccd39cc8 Mon Sep 17 00:00:00 2001
From: ludc
Date: 星期二, 30 五月 2023 18:32:57 +0800
Subject: [PATCH] code服务中部分do转vo时显示值转换改为缓存中拿值

---
 Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeBasicSecServiceImpl.java |  146 ++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 132 insertions(+), 14 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 d6584b6..fd0dfdc 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,6 +2,7 @@
 
 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;
@@ -15,14 +16,15 @@
 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.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.starter.exception.VciBaseException;
 import com.vci.ubcs.starter.revision.service.RevisionModelUtil;
+import com.vci.ubcs.starter.util.DefaultAttrAssimtUtil;
 import com.vci.ubcs.starter.web.enumpck.OsCodeFillTypeEnum;
 import com.vci.ubcs.starter.web.pagemodel.KeyValue;
 import com.vci.ubcs.starter.web.pagemodel.UIFormReferVO;
@@ -34,6 +36,7 @@
 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;
@@ -80,7 +83,16 @@
 	private ICodeClassifyValueService codeClassifyValueService;
 
 	@Resource
+	private ICodeReferConfigService codeReferConfigService;
+
+	@Resource
 	private IDictBizClient iDictBizClient;
+
+	/**
+	 * 鍥哄畾鐮佹鐨勭爜鍊肩殑鏈嶅姟
+	 */
+	@Resource
+	private ICodeFixedValueService fixedValueService;
 
 	/**
 	 * 涓婂眰鍒嗙被鐮佹鐨勫睘鎬у悕绉�
@@ -200,7 +212,6 @@
 		if (! "success".equals(attrKv.getKey())){
 			throw new VciBaseException(attrKv.getValue() + "涓嶈兘涓虹┖");
 		}
-
 		//灏咲TO杞崲涓篋O
 		CodeBasicSec codeBasicSecDO = new CodeBasicSec();
 		BeanUtilForVCI.copyPropertiesIgnoreCase(codeBasicSecDTO, codeBasicSecDO);
@@ -211,15 +222,7 @@
 		codeBasicSecDO.setValueCutTypeText(CodeCutTypeEnum.getValueByText(codeBasicSecDTO.getValueCutType()));
 		codeBasicSecDO.setCodeGetValueTypeText(CodeGetValueTypeEnum.getValueByText(codeBasicSecDTO.getCodeGetValueType()));
 		//濉厖涓�浜涢粯璁ゅ��
-		codeBasicSecDO.setOid(VciBaseUtil.getPk());
-		codeBasicSecDO.setRevisionOid(VciBaseUtil.getPk());
-		codeBasicSecDO.setNameOid(VciBaseUtil.getPk());
-		codeBasicSecDO.setBtmname(MdmBtmTypeConstant.CODE_BASIC_SEC);
-		codeBasicSecDO.setTs(new Date());
-		codeBasicSecDO.setCreateTime(new Date());
-		codeBasicSecDO.setCreator(AuthUtil.getUserId().toString());
-		codeBasicSecDO.setLastModifier(AuthUtil.getUserId().toString());
-		codeBasicSecDO.setLastModifyTime(new Date());
+		DefaultAttrAssimtUtil.addDefaultAttrAssimt(codeBasicSecDO,MdmBtmTypeConstant.CODE_BASIC_SEC);
 		//鎺掑簭鍙凤紝榛樿绛変簬褰撳墠宸叉湁鐨勬暟閲忓姞1
 		Long total = codeBasicSecMapper.selectCount(Wrappers.<CodeBasicSec>query()
 			.lambda()
@@ -235,15 +238,22 @@
 			&& 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;
@@ -277,6 +287,7 @@
 		}
 		//灏咲TO杞崲涓篋O
 		CodeBasicSec codeBasicSecDO = selectByOid(codeBasicSecDTO.getOid());
+		DefaultAttrAssimtUtil.updateDefaultAttrAssimt(codeBasicSecDO);
 		boolean status = codeRuleService.checkEditDelStatus(codeRuleService.getObjectByOid(codeBasicSecDO.getPkCodeRule()).getLcStatus());
 		boolean resBoolean;
 		if (!status){
@@ -672,4 +683,111 @@
 		return codeBasicSecDO;
 	}
 
+
+	/**
+	 * 浣跨敤瑙勫垯鐨勪富閿幏鍙栧搴旂殑鐮佹鍐呭
+	 *
+	 * @param ruleOid 瑙勫垯鐨勫唴瀹�
+	 * @return 鐮佹鐨勫唴瀹�
+	 */
+	@Override
+	public List<CodeBasicSecVO> listCodeBasicSecByRuleOid(String ruleOid) {
+		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(codeBasicSecVO, codeBasicSecVO);
+			codeBasicSecVO.setSecTypeText(CodeSecTypeEnum.getTextByValue(codeBasicSecVO.getSecType()));
+			codeBasicSecVO.setCodeLevelTypeText(CodeLevelTypeEnum.getTextByValue(codeBasicSecVO.getCodeLevelType()));
+			codeBasicSecVO.setCodeSecLengthTypeText(CodeSecLengthTypeEnum.getTextByValue(codeBasicSecVO.getCodeSecLengthType()));
+			codeBasicSecVO.setValueCutTypeText(CodeCutTypeEnum.getValueByText(codeBasicSecVO.getValueCutType()));
+			codeBasicSecVO.setCodeGetValueTypeText(CodeGetValueTypeEnum.getValueByText(codeBasicSecVO.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