| | |
| | | */ |
| | | package com.vci.ubcs.code.service.impl; |
| | | |
| | | import com.alibaba.nacos.common.utils.StringUtils; |
| | | import com.vci.ubcs.code.bo.CodeClassifyFullInfoBO; |
| | | import com.vci.ubcs.code.entity.CodeKeyattrrepeatEntity; |
| | | import com.vci.ubcs.code.enumpack.FrameworkDataLCStatus; |
| | | import com.vci.ubcs.code.vo.CodeKeyattrrepeatVO; |
| | | import com.vci.ubcs.code.mapper.CodeKeyattrrepeatMapper; |
| | | import com.vci.ubcs.code.service.ICodeKeyattrrepeatService; |
| | | import com.vci.ubcs.code.vo.pagemodel.CodeClassifyVO; |
| | | import com.vci.ubcs.code.vo.pagemodel.CodeKeyAttrRepeatRuleVO; |
| | | import com.vci.ubcs.com.vci.starter.web.util.BeanUtilForVCI; |
| | | import com.vci.ubcs.com.vci.starter.web.util.VciBaseUtil; |
| | | import com.vci.ubcs.starter.exception.VciBaseException; |
| | | import com.vci.ubcs.starter.web.util.BeanUtilForVCI; |
| | | import com.vci.ubcs.starter.web.util.VciBaseUtil; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.vci.ubcs.code.constant.FrameWorkLangCodeConstant.DATA_OID_NOT_EXIST; |
| | | |
| | | /** |
| | | * 关键属性查重规则 服务实现类 |
| | |
| | | } |
| | | return vo; |
| | | } |
| | | |
| | | /** |
| | | * 使用分类的全部信息来获取关键属性判断规则的内容 |
| | | * |
| | | * @param classifyFullInfo 主题库分类的全部信息 |
| | | * @return 规则的显示对象 |
| | | */ |
| | | @Override |
| | | public CodeKeyattrrepeatVO getRuleByClassifyFullInfo(CodeClassifyFullInfoBO classifyFullInfo) { |
| | | VciBaseUtil.alertNotNull(classifyFullInfo,"主题库分类的信息"); |
| | | String keyAttrRuleOid = classifyFullInfo.getCurrentClassifyVO().getCodekeyattrrepeatoid(); |
| | | if(StringUtils.isBlank(keyAttrRuleOid)){ |
| | | //我们根据上级的分类,按照层级倒序排列 |
| | | if(!CollectionUtils.isEmpty(classifyFullInfo.getParentClassifyVOs())){ |
| | | //有上级分类的情况下才去查询 |
| | | List<CodeClassifyVO> sortedClassifyVO = classifyFullInfo.getParentClassifyVOs().stream().sorted(((o1, o2) -> o1.getDataLevel().compareTo(o2.getDataLevel()))).collect(Collectors.toList()); |
| | | for(int i = sortedClassifyVO.size() -1;i>=0;i--){ |
| | | CodeClassifyVO record = sortedClassifyVO.get(i); |
| | | |
| | | if(StringUtils.isNotBlank(record.getCodekeyattrrepeatoid())){ |
| | | keyAttrRuleOid = record.getCodekeyattrrepeatoid(); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if(StringUtils.isNotBlank(keyAttrRuleOid)){ |
| | | CodeKeyAttrRepeatRuleVO objectByOid = getObjectByOid(keyAttrRuleOid); |
| | | CodeKeyattrrepeatVO codeKeyattrrepeatVO = new CodeKeyattrrepeatVO(); |
| | | BeanUtils.copyProperties(objectByOid,codeKeyattrrepeatVO); |
| | | return codeKeyattrrepeatVO; |
| | | } |
| | | //关键属性的规则可以为空,为空的时候就代表不控制, |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 主键获取关键数据查重规则 |
| | | * @param oid 主键 |
| | | * @return 关键数据查重规则显示对象 |
| | | */ |
| | | @Override |
| | | public CodeKeyAttrRepeatRuleVO getObjectByOid(String oid){ |
| | | CodeKeyAttrRepeatRuleVO codeKeyAttrRepeatRuleVO = codeKeyAttrRepeatRuleDO2VO(selectByOid(oid)); |
| | | CodeKeyattrrepeatVO codeKeyattrrepeatVO = new CodeKeyattrrepeatVO(); |
| | | BeanUtils.copyProperties(codeKeyAttrRepeatRuleVO,codeKeyattrrepeatVO); |
| | | return codeKeyAttrRepeatRuleVO; |
| | | } |
| | | /** |
| | | * 主键查询数据对象 |
| | | * @param oid 主键 |
| | | * @return 数据对象 |
| | | * @throws VciBaseException 参数为空,并且数据不存在的时候会抛出异常 |
| | | */ |
| | | private CodeKeyattrrepeatEntity selectByOid(String oid) { |
| | | VciBaseUtil.alertNotNull(oid,"主键"); |
| | | |
| | | CodeKeyattrrepeatEntity codeKeyAttrRepeatRuleDO = codeKeyattrrepeatMapper.selectById(oid.trim()); |
| | | // .selectByPrimaryKey(oid.trim()); |
| | | if(codeKeyAttrRepeatRuleDO == null || StringUtils.isBlank(codeKeyAttrRepeatRuleDO.getOid())){ |
| | | throw new VciBaseException(DATA_OID_NOT_EXIST); |
| | | } |
| | | return codeKeyAttrRepeatRuleDO; |
| | | } |
| | | } |