From a1a8c8e0637b77669cfa04154c7282850b50856d Mon Sep 17 00:00:00 2001
From: ludc
Date: 星期一, 26 六月 2023 19:33:34 +0800
Subject: [PATCH] secDoList值为空修改

---
 Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeBasicSecServiceImpl.java |  102 +++++++++++++++++++++++++++++++++------------------
 1 files changed, 66 insertions(+), 36 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 4c46eb9..7120791 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
@@ -6,9 +6,11 @@
 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.*;
@@ -24,10 +26,15 @@
 import com.vci.ubcs.code.wrapper.CodeBasicSecWrapper;
 import com.vci.ubcs.omd.cache.EnumCache;
 import com.vci.ubcs.omd.enums.EnumEnum;
+import com.vci.ubcs.starter.enumpack.CodeTableNameEnum;
 import com.vci.ubcs.starter.exception.VciBaseException;
 import com.vci.ubcs.starter.revision.service.RevisionModelUtil;
 import com.vci.ubcs.starter.util.DefaultAttrAssimtUtil;
+import com.vci.ubcs.starter.util.UBCSCondition;
+import com.vci.ubcs.starter.util.UBCSSqlKeyword;
+import com.vci.ubcs.starter.web.enumpck.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;
@@ -35,6 +42,8 @@
 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;
@@ -108,19 +117,27 @@
 
 	/**
 	 * 鏌ヨ鎵�鏈夌殑鐮佹鍩虹淇℃伅
-	 *
-	 * @param page 鏌ヨ鏉′欢
-	 * @param codeBasicSecVO   鍒嗛〉鍜屾帓搴�
+	 * @param conditionMap 鏌ヨ鏉′欢
+	 * @param query 鍒嗛〉瀵硅薄
 	 * @return 鎵ц缁撴灉
 	 * @throws VciBaseException 鏌ヨ鏉′欢鍜屽垎椤靛嚭閿欑殑鏃跺�欎細鎶涘嚭寮傚父
 	 */
 	@Override
-	public IPage<CodeBasicSecVO> gridCodeBasicSec(IPage<CodeBasicSecVO> page, CodeBasicSecVO codeBasicSecVO) throws VciBaseException {
-		if(Func.isEmpty(codeBasicSecVO.getPkCodeRule()) || Func.isBlank(codeBasicSecVO.getPkCodeRule())){
+	public IPage<CodeBasicSecVO> gridCodeBasicSec(Query query, Map<String,Object> conditionMap) throws ServiceException {
+		if(Func.isEmpty(Func.isEmpty(conditionMap.get(CodeTableNameEnum.PL_CODE_BASICSEC.getText()+".pkCodeRule")))){
 			return null;
 		}
-		List<CodeBasicSec> codeBasicSecs = codeBasicSecMapper.selectCodeBasicSecPage(page, codeBasicSecVO);
-		return page.setRecords(CodeBasicSecWrapper.build().listVO(codeBasicSecs));
+		// 鑱旇〃鏌ヨ ,璁剧疆琛ㄥ埆鍚嶏紝琛ㄥ埆鍚嶉粯璁ゅ氨閲囩敤琛ㄥ悕灏忓啓锛岄厤缃珮绾ф煡璇㈢殑鏃跺�欏氨闇�瑕佹牴鎹繖涓潵瀵箇here鏉′欢杩涜閰嶇疆
+		MPJLambdaWrapper<CodeBasicSec> mpjLambdaWrapper = new MPJLambdaWrapper<>(CodeBasicSec.class, CodeTableNameEnum.PL_CODE_BASICSEC.getText())
+			.selectAll(CodeBasicSec.class)
+			.selectAs(CodeClassify::getName, CodeBasicSec::getReferCodeClassifyOidName)
+			.leftJoin(CodeClassify.class, CodeTableNameEnum.PL_CODE_CLASSIFY.getText(), CodeClassify::getOid, CodeBasicSec::getReferCodeClassifyOid)
+			.leftJoin(CodeBasicSec.class,CodeTableNameEnum.PL_CODE_BASICSEC.getText()+1,CodeBasicSec::getOid,CodeBasicSec::getParentClassifySecOid
+				,ext->ext.selectAs(CodeBasicSec::getName,CodeBasicSec::getParentClassifySecText));
+		// 娣诲姞where鏉′欢
+		UBCSSqlKeyword.buildConditionByAs(conditionMap,mpjLambdaWrapper,CodeTableNameEnum.PL_CODE_BASICSEC.getText());
+		IPage<CodeBasicSec> codeBasicSecIPage = codeBasicSecMapper.selectPage(UBCSCondition.getPage(query), mpjLambdaWrapper);
+		return CodeBasicSecWrapper.build().pageVO(codeBasicSecIPage);
 	}
 
 	/**
@@ -130,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));
@@ -173,7 +190,7 @@
 	 * @return 鏈夌┖鐨勫垯浼爇ey-灞炴�у悕 value-瀛楁鍚箟锛屾病鏈夌┖鐨勫垯浼� key-success value-true
 	 */
 	@Override
-	public KeyValue checkAttrNullableBySecType(CodeBasicSecDTO codeBasicSecDTO) {
+	public KeyValue checkAttrNullableBySecType(CodeBasicSecDTO codeBasicSecDTO) throws ServiceException {
 		VciBaseUtil.alertNotNull(codeBasicSecDTO.getSecType(), "鐮佹鍒嗙被");
 		String secType = codeBasicSecDTO.getSecType();
 		HashMap<String, String> attrMap = JSONObject.parseObject(JSONObject.toJSONString(codeBasicSecDTO), HashMap.class);
@@ -336,7 +353,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", "灞炴�х爜娈靛悕绉�");
@@ -452,29 +469,29 @@
 	/**
 	 * 鍙傜収鐮佹鍩虹淇℃伅鍒楄〃
 	 *
-	 * @param codeBasicSecVO 鏌ヨ鏉′欢
-	 * @param page   鍒嗛〉鍜屾帓搴�
+	 * @param conditionMap 鏌ヨ鏉′欢
+	 * @param query 鍒嗛〉鍜屾帓搴�
 	 * @return 鐮佹鍩虹淇℃伅鏄剧ず瀵硅薄鍒楄〃锛岀敓鏁堢殑鍐呭
 	 * @throws VciBaseException 鏌ヨ鏉′欢鍜屽垎椤靛嚭閿欑殑鏃跺�欎細鎶涘嚭寮傚父
 	 */
 	@Override
-	public IPage<CodeBasicSecVO> refDataGridCodeBasicSec(IPage<CodeBasicSecVO> page, CodeBasicSecVO codeBasicSecVO) throws VciBaseException {
-		return gridCodeBasicSec(page,codeBasicSecVO);
+	public IPage<CodeBasicSecVO> refDataGridCodeBasicSec(Query query ,Map<String,Object> conditionMap) throws VciBaseException {
+		return gridCodeBasicSec(query,conditionMap);
 	}
 
 	/**
 	 * 鍙傜収鍒嗙被鐨勭爜娈�
-	 * @param codeBasicSecVO 鏌ヨ鏉′欢
-	 * @param page 鍒嗛〉鐨勫璞�
+	 * @param conditionMap 鏌ヨ鏉′欢
+	 * @param query 鍒嗛〉鍜屾帓搴�
 	 * @return 鐮佹鐨勫唴瀹�
 	 */
 	@Override
-	public IPage<CodeBasicSecVO> refDataGridClassifySec(IPage<CodeBasicSecVO> page, CodeBasicSecVO codeBasicSecVO) throws VciBaseException {
-		if(Func.isEmpty(codeBasicSecVO.getPkCodeRule()) || Func.isBlank(codeBasicSecVO.getPkCodeRule())){
+	public IPage<CodeBasicSecVO> refDataGridClassifySec(Query query ,Map<String,Object> conditionMap) throws VciBaseException {
+		if(Func.isEmpty(conditionMap.get("pkCodeRule"))){
 			return null;
 		}
-		codeBasicSecVO.setSecType(CodeSecTypeEnum.CODE_CLASSIFY_SEC.getValue());
-		return refDataGridCodeBasicSec(page,codeBasicSecVO);
+		conditionMap.put("secType",(CodeSecTypeEnum.CODE_CLASSIFY_SEC.getValue()));
+		return refDataGridCodeBasicSec(query.setAscs("ordernum"),conditionMap);
 	}
 
 	/**
@@ -486,27 +503,30 @@
 	 */
 	@Override
 	@Transactional(rollbackFor = Exception.class)
-	public R cloneCodeBasicSec(List<String> oidList, String pkCodeRule) {
+	public R cloneCodeBasicSec(List<String> oidList, String pkCodeRule) throws ServiceException {
 		boolean isLinked = checkIsLinked(pkCodeRule,null);
 		if (isLinked) {
 			return R.fail("缂栫爜瑙勫垯宸茶寮曠敤锛屼笉鍏佽缂栬緫鎴栧垹闄�");
 		}
 		List<CodeBasicSec> createList = new ArrayList<>();
 		List<CodeBasicSec> basicSecDOS = codeBasicSecMapper.selectBatchIds(oidList);
+		if(basicSecDOS.isEmpty()){
+			return R.fail("鍏嬮殕鐨勭爜娈典俊鎭笉瀛樺湪锛�");
+		}
 		basicSecDOS.forEach(sec -> {
 			CodeBasicSec newSecDO = new CodeBasicSec();
 			BeanUtilForVCI.copyPropertiesIgnoreCase(sec,newSecDO);
-			newSecDO.setOid("");
-			newSecDO.setNameOid("");
-			newSecDO.setRevisionOid("");
+			newSecDO.setOid(VciBaseUtil.getPk());
+			newSecDO.setNameOid(VciBaseUtil.getPk());
+			newSecDO.setRevisionOid(VciBaseUtil.getPk());
 			newSecDO.setId(newSecDO.getId() + "_copy");
 			newSecDO.setName(newSecDO.getName() + "_copy");
 			newSecDO.setPkCodeRule(pkCodeRule);
 			createList.add(newSecDO);
 		});
-		boolean b = saveBatch(createList);
+		boolean resBoolean = saveBatch(createList);
 		//codeBasicSecMapper.insertBatch(createList);
-		return R.data(b,"鍏嬮殕鐮佹淇℃伅鎴愬姛");
+		return resBoolean ? R.data(resBoolean,"鍏嬮殕鐮佹淇℃伅鎴愬姛"):R.fail("鍏嬮殕鐮佹淇℃伅澶辫触锛�");
 	}
 
 	/**
@@ -550,7 +570,7 @@
 	 */
 	@Override
 	@Transactional(rollbackFor = Exception.class)
-	public boolean upOrderNum(String oid) {
+	public boolean upOrderNum(String oid) throws ServiceException{
 		CodeBasicSec secDO = selectByOid(oid);
 		if(secDO.getOrderNum() > 1){
 			//绛変簬1鐨勬椂鍊欎笉鑳戒笂绉讳簡
@@ -581,7 +601,7 @@
 	 */
 	@Override
 	@Transactional(rollbackFor = Exception.class)
-	public boolean downOrderNum(String oid) {
+	public boolean downOrderNum(String oid) throws ServiceException {
 		CodeBasicSec secDO = selectByOid(oid);
 		Long total = codeBasicSecMapper.selectCount(Wrappers.<CodeBasicSec>query()
 			.lambda().eq(CodeBasicSec::getPkCodeRule,secDO.getPkCodeRule())
@@ -613,7 +633,7 @@
 	 * @return
 	 */
 	@Override
-	public List<String> getOidByCodeclassifysecOid(String codeClassifySecOid) {
+	public List<String> getOidByCodeclassifysecOid(String codeClassifySecOid)throws ServiceException {
 		return codeBasicSecMapper.getOidByCodeclassifysecOid(codeClassifySecOid.trim());
 	}
 
@@ -693,7 +713,7 @@
 	 * @return 鐮佹鐨勫唴瀹�
 	 */
 	@Override
-	public List<CodeBasicSecVO> listCodeBasicSecByRuleOid(String ruleOid) {
+	public List<CodeBasicSecVO> listCodeBasicSecByRuleOid(String ruleOid)throws ServiceException {
 		if(StringUtils.isBlank(ruleOid)){
 			return new ArrayList<>();
 		}
@@ -772,12 +792,22 @@
 	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()));
+			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()

--
Gitblit v1.9.3