From 0aa0bbdfde221a46019f90a245e40d6b57fd251b Mon Sep 17 00:00:00 2001 From: ludc Date: 星期二, 11 七月 2023 19:09:03 +0800 Subject: [PATCH] 编码规则bug修复 --- Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeRuleServiceImpl.java | 131 ++++++++++++++++++++++--------------------- 1 files changed, 66 insertions(+), 65 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 439fd53..83fafcf 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 @@ -17,15 +17,10 @@ package com.vci.ubcs.code.service.impl; import com.alibaba.cloud.commons.lang.StringUtils; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -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.github.yulichang.wrapper.MPJLambdaWrapper; import com.vci.ubcs.code.constant.MdmBtmTypeConstant; import com.vci.ubcs.code.dto.CodeBasicSecDTO; import com.vci.ubcs.code.dto.CodeRuleDTO; @@ -44,8 +39,6 @@ import com.vci.ubcs.code.vo.pagemodel.CodeRuleVO; 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.service.RevisionModelUtil; import com.vci.ubcs.starter.util.DefaultAttrAssimtUtil; @@ -54,12 +47,11 @@ 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 org.springblade.core.log.exception.ServiceException; 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.R; import org.springblade.core.tool.utils.BeanUtil; +import org.springblade.core.tool.utils.Func; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -130,14 +122,39 @@ * @throws VciBaseException 鍙傛暟涓虹┖锛屽敮涓�椤癸紝蹇呰緭椤逛笉閫氳繃鏃朵細鎶涘嚭寮傚父 */ @Override - public boolean addSave(CodeRuleDTO codeRuleDTO) throws VciBaseException { + public R addSave(CodeRuleDTO codeRuleDTO) throws VciBaseException { VciBaseUtil.alertNotNull(codeRuleDTO, "闇�瑕佹坊鍔犵殑鏁版嵁瀵硅薄"); - //灏咲TO杞崲涓篋O + 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); - return codeRuleMapper.insert(codeRule)>0; + return R.status(codeRuleMapper.insert(codeRule)>0); + } + + /** + * 妫�鏌d缂栧彿鏄惁閲嶅 + * @param codeRuleDTO 褰撳墠鍒ゆ柇鏄惁閲嶅鐨勫璞� + * @return 杩斿洖false琛ㄧず鏈噸澶� + */ + @Override + public boolean checkCodeRuleRepeat(CodeRuleDTO codeRuleDTO){ + List<CodeRule> codeRulesList = this.codeRuleMapper.selectList(Wrappers.<CodeRule>query().lambda().eq(CodeRule::getId, codeRuleDTO.getId())); + 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; } /** @@ -147,7 +164,7 @@ * @return true琛ㄧず鍙互缂栬緫鎴栧垹闄わ紝false琛ㄧず涓嶅彲浠� */ @Override - public boolean checkEditDelStatus(String lcStatus) { + public boolean checkEditDelStatus(String lcStatus) throws VciBaseException { if (CodeRuleLC.RELEASED.getValue().equals(lcStatus) || CodeRuleLC.DISABLED.getValue().equals(lcStatus)) { return false; } @@ -162,8 +179,11 @@ * @throws VciBaseException 鍙傛暟涓虹┖锛屽敮涓�椤癸紝蹇呰緭椤逛笉閫氳繃鏃朵細鎶涘嚭寮傚父 */ @Override - public boolean editSave(CodeRuleDTO codeRuleDTO) throws VciBaseException{ + 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("缂栫爜瑙勫垯宸插彂甯冿紝涓嶅厑璁哥紪杈戞垨鍒犻櫎"); } @@ -171,7 +191,7 @@ CodeRule codeRule = selectByOid(codeRuleDTO.getOid()); revisionModelUtil.copyFromDTOIgnore(codeRuleDTO, codeRule); DefaultAttrAssimtUtil.updateDefaultAttrAssimt(codeRule); - return codeRuleMapper.updateById(codeRule)>0; + return R.status(codeRuleMapper.updateById(codeRule)>0); } /** @@ -456,6 +476,34 @@ } /** + * 妫�鏌ョ浉浼肩紪鐮佽鍒欙紝骞惰繑鍥炲搴旂殑缁撴灉 + * @param oid 涓婚敭 + * @return 鎵ц缁撴灉 + */ + @Override + public R checkLikeCodeRule(String oid) throws VciBaseException { + CodeRuleVO codeRuleVO = getObjectByOid(oid); + // 1銆佸幓鎺夋祦姘寸爜娈碉紝璁$畻鍑哄叾浠栫爜娈靛�奸暱搴︼紝鍦ㄥ凡鍙戝竷鐨勮鍒欎腑姣斿鍑洪暱搴︿竴鑷寸殑缂栫爜瑙勫垯 + HashMap<String, Object> condtionMap = new HashMap<>(); + condtionMap.put("pkCodeRule_equal",codeRuleVO.getOid()); + condtionMap.put("secType_notequal", CodeSecTypeEnum.CODE_SERIAL_SEC); + codeRuleVO.setSecVOList(codeBasicSecService.listCodeBasicSecByRuleOid(condtionMap)); + // TODO 寰呭畬鍠� + + + // 2銆佸湪1銆佺殑鍩虹涓婂啀姣斿鐮佹绫诲瀷鐨勯『搴忎竴鑷寸殑缂栫爜璺潃 + + // 3銆佸湪2銆佺殑鍩虹涓婃瘮杈冪爜娈电爜鍊奸暱搴︼紝瀵规瘮鍑洪暱搴︾浉鍚岀殑缂栫爜瑙勫垯 + + // 4銆佸湪3銆佺殑鍩虹涓婃瘮杈冪爜鍊兼槸鍚︾浉鍚� + + + // 鏈�鍚庡皢缁撴灉杩涜杩斿洖 + + return null; + } + + /** * 鎵归噺鏁版嵁瀵硅薄杞崲涓烘樉绀哄璞� * * @param codeRules 鏁版嵁瀵硅薄鍒楄〃 @@ -491,61 +539,14 @@ //濡傛灉鏈塴cstatus鐨勭被鐨勮瘽 vo.setLcStatusText(CodeRuleLC.getTextByValue(vo.getLcStatus())); if (hasSec) { - List<CodeBasicSecVO> codeBasicSecVOS = codeBasicSecService.listCodeBasicSecByRuleOid(vo.getOid()); - // 鍒ゆ柇鏄惁涓哄紩鐢ㄧ爜娈碉紝濡傛灉鏄簲鐢ㄧ爜娈电殑璇濓紝涓轰簡閫傞厤鍓嶇缁勪欢锛岃繖閲岃瀵硅〃杩涜澶勭悊涓�涓嬶紝鎸夌収浠ュ墠鐨勫弬鐓ф牸寮忚繘琛岃浆鎹� - codeBasicSecVOS.stream().peek(item->{ - //寮曠敤鐮佹 - if(item.getSecType().equals(CodeSecTypeEnum.CODE_REFER_SEC) && StringUtils.isNotEmpty(item.getReferConfig())){ - item.setReferConfig(referConfigTOUIUiTable(item)); - } - }); + Map<String, Object> condtionMap = new HashMap<>(); + condtionMap.put("pkCodeRule_equal",vo.getOid()); + List<CodeBasicSecVO> codeBasicSecVOS = codeBasicSecService.listCodeBasicSecByRuleOid(condtionMap); //鏌ヨ鐮佹 vo.setSecVOList(codeBasicSecVOS); } } return vo; } - - /** - * 灏唕eferconfig杞崲涓篔SON鏍煎紡鐨刄IFormReferVO - * @param item - * @return - */ - private String referConfigTOUIUiTable(CodeBasicSecVO item){ - // JSON鏍煎紡鐨勫弬鐓ч厤缃浆鎹负瀵硅薄 - CodeReferConfig codeReferConfig = JSONObject.parseObject(item.getReferConfig(), CodeReferConfig.class); - // 鎷疯礉涓轰互鍓嶇殑鑰佸璞� - UIFormReferVO uiFormReferVO = new UIFormReferVO(); - BeanUtil.copy(codeReferConfig,uiFormReferVO); - - // 琛ㄦ牸鐨勮嚜瀹氫箟瀹氫箟 - UITableCustomDefineVO uiTableCustomDefineVO = new UITableCustomDefineVO(); - uiTableCustomDefineVO.setPage(new UITablePageVO(codeReferConfig.getLimit(),1)); - // 鍒楄〃鐨勫垪鐨勪俊鎭浆鎹� - List<UITableFieldVO> uiTableFieldVOs = new ArrayList<>(); - // 蹇�熸煡璇㈠垪 - List<UITableFieldVO> queryColumns = new ArrayList<>(); - codeReferConfig.getCodeShowFieldConfigs().stream().forEach(showField ->{ - UITableFieldVO uiTableFieldVO = new UITableFieldVO(); - BeanUtil.copy(showField,uiTableFieldVO); - uiTableFieldVOs.add(uiTableFieldVO); - if(showField.getIsQuery().equals("true")){ - queryColumns.add(uiTableFieldVO); - } - }); - // 鏄剧ず鐨勫垪 - uiTableCustomDefineVO.setCols(uiTableFieldVOs); - // 蹇�熸煡璇㈠垪 - uiTableCustomDefineVO.setQueryColumns(queryColumns); - // 绛涢�夋潯浠� - HashMap<String, String> whereMap = new HashMap<>(); - codeReferConfig.getCodeSrchCondConfigs().stream().forEach(srch->{ - whereMap.put(srch.getFilterValue()+"_"+srch.getFilterType(),srch.getFilterValue()); - }); - uiFormReferVO.setWhere(whereMap); - return JSONObject.toJSONString(uiFormReferVO); - } - - } -- Gitblit v1.9.3