From 7602a824e39e19260ae32bb45e799e6ce43300ac Mon Sep 17 00:00:00 2001 From: ludc Date: 星期五, 14 七月 2023 21:15:29 +0800 Subject: [PATCH] 参照配置组件修改 --- Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeRuleServiceImpl.java | 219 ++++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 178 insertions(+), 41 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 fd7c939..8bd5db7 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,13 +17,16 @@ package com.vci.ubcs.code.service.impl; import com.alibaba.cloud.commons.lang.StringUtils; +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.vci.ubcs.code.constant.MdmBtmTypeConstant; import com.vci.ubcs.code.dto.CodeBasicSecDTO; import com.vci.ubcs.code.dto.CodeRuleDTO; 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; @@ -32,19 +35,27 @@ import com.vci.ubcs.code.service.ICodeBasicSecService; import com.vci.ubcs.code.service.ICodeClassifyService; import com.vci.ubcs.code.service.ICodeRuleService; +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 com.vci.ubcs.code.wrapper.CodeClassifyWrapper; import com.vci.ubcs.code.wrapper.CodeRuleWrapper; -import com.vci.ubcs.com.vci.starter.exception.VciBaseException; -import com.vci.ubcs.com.vci.starter.revision.service.RevisionModelUtil; -import com.vci.ubcs.com.vci.starter.web.pagemodel.KeyValue; -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.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.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 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.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; @@ -94,15 +105,27 @@ @Resource private RevisionModelUtil revisionModelUtil; + @Value("${user-info.tenant-id}") + private String tenantId; + @Value("${user-info.id}") + private String userId; + + /** + * 鍒嗛〉鏌ヨ + * @param query + * @param conidtionMap + * @return + */ @Override - public IPage<CodeRuleVO> gridCodeRule(IPage<CodeRuleVO> page, CodeRuleVO codeRule) { - //瀵圭敓鍛藉懆鏈熺殑鏋氫妇杩涜杞崲 - if(!StringUtils.isEmpty(codeRule.getLcStatusText())){ - codeRule.setLcStatus(CodeRuleLC.getValueByText(codeRule.getLcStatusText())); + public IPage<CodeRuleVO> gridCodeRule(Query query, Map<String,Object> conidtionMap) { + //濡傛灉绛変簬鑷繁閰嶇疆鐨勭鐞嗙粍绉熸埛id鍜岀鐞嗙粍瓒呯璐﹀彿锛屽氨涓嶉渶瑕佹寜鐓ц鍒欐墍鏈夎�呮潵杩涜鏌ヨ + if(!(AuthUtil.getTenantId().equals(this.tenantId) && AuthUtil.getUserId().toString().equals(this.userId))){ + // 鎸夌収瑙勫垯鎵�鏈夎�呮潵鏌ヨ + conidtionMap.put("owner",AuthUtil.getUserId()); } - List<CodeRule> codeRulePage = codeRuleMapper.selectCodeRulePage(page, codeRule); + IPage<CodeRule> codeRuleIPage = this.codeRuleMapper.selectPage(Condition.getPage(query), UBCSCondition.getQueryWrapper(conidtionMap, CodeRule.class)); //do杞瑅o鍚屾椂setLcStatusText鐢熷懡鍛ㄦ湡鍊硷紝骞跺寘瑁呮垚鍒嗛〉瀵硅薄杩斿洖 - return page.setRecords(CodeRuleWrapper.build().listVO(codeRulePage)); + return CodeRuleWrapper.build().pageVO(codeRuleIPage); } /** @@ -113,31 +136,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)); - String userId = AuthUtil.getUserId().toString(); - codeRule.setOid(VciBaseUtil.getPk()); - codeRule.setRevisionOid(VciBaseUtil.getPk()); - codeRule.setNameOid(VciBaseUtil.getPk()); - codeRule.setBtmname("coderule"); - codeRule.setLastR("1"); - codeRule.setLastV("1"); - codeRule.setFirstR("1"); - codeRule.setFirstV("1"); - codeRule.setCreator(userId); - codeRule.setCreateTime(new Date()); - codeRule.setLastModifier("1"); - codeRule.setLastModifyTime(new Date()); - codeRule.setVersionRule("0"); - codeRule.setVersionSeq(1); + // 濉厖榛樿鍊� + DefaultAttrAssimtUtil.addDefaultAttrAssimt(codeRule, MdmBtmTypeConstant.CODE_RULE); codeRule.setLctid(CODE_RULE_LC); codeRule.setLcStatus(FRAMEWORK_RELEASE_EDITING); - codeRule.setOwner("1"); - codeRule.setCreator(userId); - codeRule.setLastModifier(userId); - 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 +178,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,15 +193,22 @@ * @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("缂栫爜瑙勫垯宸插彂甯冿紝涓嶅厑璁哥紪杈戞垨鍒犻櫎"); } //灏咲TO杞崲涓篋O CodeRule codeRule = selectByOid(codeRuleDTO.getOid()); revisionModelUtil.copyFromDTOIgnore(codeRuleDTO, codeRule); - return codeRuleMapper.updateById(codeRule)>0; + if(!codeRule.getOwner().equals(codeRuleDTO.getOwner())){ + codeRule.setOwner(codeRuleDTO.getOwner()); + } + DefaultAttrAssimtUtil.updateDefaultAttrAssimt(codeRule); + return R.status(codeRuleMapper.updateById(codeRule)>0); } /** @@ -291,7 +329,7 @@ */ @Override public Collection<CodeClassifyVO> listUseRangeInCodeClassify(String oid) { - List<CodeClassify> codeClassifies = codeClassifyServcie.selectByWrapper(Wrappers.<CodeClassify>query().eq("codeRuleOid", oid)); + List<CodeClassify> codeClassifies = codeClassifyServcie.selectByWrapper(Wrappers.<CodeClassify>query().lambda().eq(CodeClassify::getCodeRuleOid, oid)); return CodeClassifyWrapper.build().listVO(codeClassifies); } @@ -323,6 +361,21 @@ } /** + * 涓婚敭鎵归噺鑾峰彇涓绘暟鎹紪鐮佽鍒� + * + * @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 = listCodeRuleDOByOidCollections(oidCollections); + return codeRuleDO2VOs(codeRuleDOList, true); + } + + /** * 浣跨敤涓婚敭闆嗗悎鏌ヨ鏁版嵁瀵硅薄 * * @param oidCollections 涓婚敭鐨勯泦鍚� @@ -345,14 +398,13 @@ /** * 鍙傜収涓绘暟鎹紪鐮佽鍒欏垪琛� * - * @param codeRule 鏌ヨ鏉′欢 - * @param page 鍒嗛〉鍜屾帓搴� + * @param bladeQueryObject 鏌ヨ鏉′欢 * @return 涓绘暟鎹紪鐮佽鍒欐樉绀哄璞″垪琛紝鐢熸晥鐨勫唴瀹� * @throws VciBaseException 鏌ヨ鏉′欢鍜屽垎椤靛嚭閿欑殑鏃跺�欎細鎶涘嚭寮傚父 */ @Override - public IPage<CodeRuleVO> refDataGridCodeRule(IPage<CodeRuleVO> page, CodeRuleVO codeRule) throws VciBaseException { - return gridCodeRule(page, codeRule); + public IPage<CodeRuleVO> refDataGridCodeRule(BladeQueryObject bladeQueryObject) throws VciBaseException { + return gridCodeRule(bladeQueryObject.getQuery(), bladeQueryObject.getConditionMap()); } /** @@ -428,5 +480,90 @@ return R.data(exFlag&&exFlag1); } + /** + * 浣跨敤涓婚敭鑾峰彇缂栫爜瑙勫垯鐨勫唴瀹� + * + * @param oid 涓婚敭 + * @return 瑙勫垯鐨勬樉绀哄璞� + */ + @Override + public CodeRuleVO getObjectHasSecByOid(String oid) { + CodeRule ruleDO = selectByOid(oid); + return codeRuleDO2VO(ruleDO, true); + } + + /** + * 妫�鏌ョ浉浼肩紪鐮佽鍒欙紝骞惰繑鍥炲搴旂殑缁撴灉 + * @param oid 涓婚敭 + * @return 鎵ц缁撴灉 + */ + @Override + public R checkLikeCodeRule(String oid) throws VciBaseException { + // 1銆佹煡璇㈠嚭褰撳墠瑕佸彂甯冪殑瑙勫垯 + CodeRuleVO codeRuleVO = getObjectHasSecByOid(oid); + // 2銆佹壘鍑轰笌褰撳墠鍙戝竷鐨勮鍒欑爜娈甸『搴忎竴鑷寸殑瑙勫垯 + if(Func.isNotEmpty(codeRuleVO.getSecVOList())){ + String secType = codeRuleVO.getSecVOList().stream().map(CodeBasicSecVO::getSecType).collect(Collectors.joining(",")); + + } + + // TODO 寰呭畬鍠� + + + // 2銆佸湪1銆佺殑鍩虹涓婂啀姣斿鐮佹绫诲瀷鐨勯『搴忎竴鑷寸殑缂栫爜璺潃 + + // 3銆佸湪2銆佺殑鍩虹涓婃瘮杈冪爜娈电爜鍊奸暱搴︼紝瀵规瘮鍑洪暱搴︾浉鍚岀殑缂栫爜瑙勫垯 + + // 4銆佸湪3銆佺殑鍩虹涓婃瘮杈冪爜鍊兼槸鍚︾浉鍚� + + + // 鏈�鍚庡皢缁撴灉杩涜杩斿洖 + + return null; + } + + /** + * 鎵归噺鏁版嵁瀵硅薄杞崲涓烘樉绀哄璞� + * + * @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 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; + } } -- Gitblit v1.9.3