| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.baomidou.mybatisplus.extension.toolkit.SqlHelper; |
| | | import com.vci.ubcs.code.constant.FrameWorkDefaultValueConstant; |
| | | |
| | | import com.vci.ubcs.code.dto.CodeBasicSecDTO; |
| | |
| | | import com.vci.ubcs.starter.web.util.VciBaseUtil; |
| | | import com.vci.ubcs.starter.web.util.WebUtil; |
| | | import com.vci.ubcs.system.cache.NacosConfigCache; |
| | | import com.vci.ubcs.system.entity.Strategy; |
| | | import com.vci.ubcs.system.feign.ISysClient; |
| | | import com.vci.ubcs.system.user.entity.User; |
| | | import com.vci.ubcs.system.user.feign.IUserClient; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.mp.support.Query; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | |
| | | private RevisionModelUtil revisionModelUtil; |
| | | |
| | | @Resource |
| | | private NacosConfigCache nacosConfigCache; |
| | | |
| | | @Resource |
| | | private ICodeFixedValueService codeFixedValueService; |
| | | |
| | | /** |
| | | * 系统服务 |
| | | */ |
| | | @Resource |
| | | private ICodeClassifyValueService codeClassifyValueService; |
| | | private IUserClient userClient; |
| | | |
| | | /** |
| | | * 分页查询 |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | public IPage<CodeRuleVO> gridCodeRule(Query query, Map<String,Object> conidtionMap) { |
| | | public IPage<CodeRuleVO> gridCodeRule(Query query, Map<String,Object> conidtionMap) throws VciBaseException { |
| | | //int i = 1 / 0; |
| | | //如果等于自己配置的管理组租户id和管理组超管账号,就不需要按照规则所有者来进行查询 |
| | | if(!(AuthUtil.getTenantId().equals(nacosConfigCache.getAdminUserInfo().getTenantId()) |
| | | && AuthUtil.getUserId().toString().equals(nacosConfigCache.getAdminUserInfo().getUserId().toString())) |
| | | /*if(!(AuthUtil.getTenantId().equals(NacosConfigCache.getAdminUserInfo().getTenantId()) |
| | | && AuthUtil.getUserId().toString().equals(NacosConfigCache.getAdminUserInfo().getUserId().toString())) |
| | | ){ |
| | | // 按照规则所有者来查询 |
| | | conidtionMap.put("owner",AuthUtil.getUserId()); |
| | | } |
| | | conidtionMap.put("owner",AuthUtil.getUserId().toString()); |
| | | }*/ |
| | | IPage<CodeRule> codeRuleIPage = this.codeRuleMapper.selectPage(Condition.getPage(query), UBCSCondition.getQueryWrapper(conidtionMap, CodeRule.class)); |
| | | //do转vo同时setLcStatusText生命周期值,并包装成分页对象返回 |
| | | return CodeRuleWrapper.build().pageVO(codeRuleIPage); |
| | |
| | | DefaultAttrAssimtUtil.addDefaultAttrAssimt(codeRule, MdmBtmTypeConstant.CODE_RULE); |
| | | codeRule.setLctid(CODE_RULE_LC); |
| | | codeRule.setLcStatus(FRAMEWORK_RELEASE_EDITING); |
| | | codeRule.setOwnerText(AuthUtil.getUserAccount()+"("+AuthUtil.getNickName()+")"); |
| | | return R.status(codeRuleMapper.insert(codeRule)>0); |
| | | } |
| | | |
| | |
| | | * @return 返回false表示未重复 |
| | | */ |
| | | @Override |
| | | public boolean checkCodeRuleRepeat(CodeRuleDTO codeRuleDTO){ |
| | | public boolean checkCodeRuleRepeat(CodeRuleDTO codeRuleDTO)throws VciBaseException { |
| | | LambdaQueryWrapper<CodeRule> wrapper = Wrappers.<CodeRule>query() |
| | | .lambda().eq(CodeRule::getId, codeRuleDTO.getId()); |
| | | if(AuthUtil.getTenantId().equals(nacosConfigCache.getAdminUserInfo().getTenantId())){ |
| | | wrapper.eq(CodeRule::getTenantId,codeRuleDTO.getTenantId()); |
| | | if(AuthUtil.getTenantId().equals(NacosConfigCache.getAdminUserInfo().getTenantId())){ |
| | | wrapper.eq(CodeRule::getTenantId,AuthUtil.getTenantId()); |
| | | } |
| | | // 根据规则id查询编号 |
| | | List<CodeRule> codeRulesList = this.codeRuleMapper.selectList(wrapper); |
| | |
| | | revisionModelUtil.copyFromDTOIgnore(codeRuleDTO, codeRule); |
| | | if(!codeRule.getOwner().equals(codeRuleDTO.getOwner())){ |
| | | codeRule.setOwner(codeRuleDTO.getOwner()); |
| | | R<User> userR = userClient.userInfoById(Func.toLong(codeRuleDTO.getOwner())); |
| | | if(!userR.isSuccess() || Func.isEmpty(userR.getData())){ |
| | | codeRule.setOwnerText(codeRuleDTO.getOwner()); |
| | | }else{ |
| | | codeRule.setOwnerText(userR.getData().getAccount()+"("+userR.getData().getRealName()+")"); |
| | | } |
| | | } |
| | | DefaultAttrAssimtUtil.updateDefaultAttrAssimt(codeRule); |
| | | return R.status(codeRuleMapper.updateById(codeRule)>0); |
| | |
| | | * @return true表示已经使用,false表示未被使用 |
| | | */ |
| | | @Override |
| | | public boolean isAlreadyInUse(String oid) { |
| | | public boolean isAlreadyInUse(String oid) throws VciBaseException { |
| | | Collection<CodeClassifyVO> codeClassifyVOS = listUseRangeInCodeClassify(oid); |
| | | if (codeClassifyVOS.size() > 0) { |
| | | return true; |
| | |
| | | * @return 主题库分类使用到该编码规则的所有集合 |
| | | */ |
| | | @Override |
| | | public Collection<CodeClassifyVO> listUseRangeInCodeClassify(String oid) { |
| | | public Collection<CodeClassifyVO> listUseRangeInCodeClassify(String oid) throws VciBaseException { |
| | | List<CodeClassify> codeClassifies = codeClassifyServcie.selectByWrapper(Wrappers.<CodeClassify>query().lambda().eq(CodeClassify::getCodeRuleOid, oid)); |
| | | return CodeClassifyWrapper.build().listVO(codeClassifies); |
| | | } |
| | |
| | | public Collection<CodeRuleVO> listCodeRuleByOids(Collection<String> oidCollections) throws VciBaseException { |
| | | VciBaseUtil.alertNotNull(oidCollections, "数据对象主键集合"); |
| | | List<CodeRule> codeRuleDOList = listCodeRuleDOByOidCollections(oidCollections); |
| | | return CodeRuleWrapper.build().listVO(codeRuleDOList); |
| | | return codeRuleDO2VOs(codeRuleDOList,true); |
| | | } |
| | | |
| | | /** |
| | |
| | | @Override |
| | | public Collection<CodeRuleVO> listCodeRuleByIds(Collection<String> oidCollections, boolean hasSec) throws VciBaseException { |
| | | VciBaseUtil.alertNotNull(oidCollections, "数据对象主键集合"); |
| | | List<CodeRule> codeRuleDOList = listCodeRuleDOByOidCollections(oidCollections); |
| | | return codeRuleDO2VOs(codeRuleDOList, true); |
| | | List<CodeRule> codeRuleDOList = listCodeRuleDOByIdCollections(oidCollections); |
| | | return codeRuleDO2VOs(codeRuleDOList, hasSec); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param oidCollections 主键的集合 |
| | | * @return 数据对象列表 |
| | | */ |
| | | private List<CodeRule> listCodeRuleDOByOidCollections(Collection<String> oidCollections) { |
| | | private List<CodeRule> listCodeRuleDOByOidCollections(Collection<String> oidCollections) throws VciBaseException { |
| | | List<CodeRule> codeRuleDOList = new ArrayList<CodeRule>(); |
| | | if (!CollectionUtils.isEmpty(oidCollections)) { |
| | | Collection<Collection<String>> oidCollectionsList = VciBaseUtil.switchCollectionForOracleIn(oidCollections); |
| | | for (Collection<String> oids : oidCollectionsList) { |
| | | List<CodeRule> tempDOList = codeRuleMapper.selectBatchIds(oids); |
| | | if (!CollectionUtils.isEmpty(tempDOList)) { |
| | | codeRuleDOList.addAll(tempDOList); |
| | | } |
| | | } |
| | | } |
| | | return codeRuleDOList; |
| | | } |
| | | |
| | | /** |
| | | * 使用规则id集合查询数据对象 |
| | | * |
| | | * @param idCollections id的集合 |
| | | * @return 数据对象列表 |
| | | */ |
| | | private List<CodeRule> listCodeRuleDOByIdCollections(Collection<String> idCollections) throws VciBaseException { |
| | | List<CodeRule> codeRuleDOList = new ArrayList<CodeRule>(); |
| | | if (!CollectionUtils.isEmpty(idCollections)) { |
| | | Collection<Collection<String>> idCollectionsList = VciBaseUtil.switchCollectionForOracleIn(idCollections); |
| | | for (Collection<String> ids : idCollectionsList) { |
| | | List<CodeRule> tempDOList = codeRuleMapper.selectList( |
| | | Wrappers.<CodeRule>query() |
| | | .lambda().in(CodeRule::getId,ids) |
| | | ); |
| | | if (!CollectionUtils.isEmpty(tempDOList)) { |
| | | codeRuleDOList.addAll(tempDOList); |
| | | } |
| | |
| | | * @return 执行结果 |
| | | */ |
| | | @Override |
| | | public R updateStatus(String oid, String update) { |
| | | public R updateStatus(String oid, String update) throws VciBaseException { |
| | | int count = 0; |
| | | //先查询对象 |
| | | CodeRule codeRuleDO = selectByOid(oid); |
| | |
| | | } |
| | | VciBaseUtil.alertNotNull(codeRuleDTO, "需要添加的数据对象"); |
| | | CodeRule codeRuleDO = new CodeRule(); |
| | | DefaultAttrAssimtUtil.addDefaultAttrAssimt(codeRuleDO,MdmBtmTypeConstant.CODE_RULE); |
| | | BeanUtilForVCI.copyPropertiesIgnoreCase(codeRuleDTO, codeRuleDO); |
| | | boolean exFlag = codeRuleMapper.insert(codeRuleDO)>0; |
| | | DefaultAttrAssimtUtil.addDefaultAttrAssimt(codeRuleDO,MdmBtmTypeConstant.CODE_RULE); |
| | | boolean exFlag = SqlHelper.retBool(codeRuleMapper.insert(codeRuleDO)); |
| | | |
| | | List<CodeBasicSecDTO> secList = codeRuleDTO.getElements(); |
| | | List<CodeBasicSec> codeBasicSecs = new ArrayList<>(); |
| | | List<CodeBasicSec> codeClassifySec = new ArrayList<>(); |
| | |
| | | * @return 规则的显示对象 |
| | | */ |
| | | @Override |
| | | public CodeRuleVO getObjectHasSecByOid(String oid) { |
| | | public CodeRuleVO getObjectHasSecByOid(String oid) throws VciBaseException { |
| | | CodeRule ruleDO = selectByOid(oid); |
| | | return codeRuleDO2VO(ruleDO, true); |
| | | } |