| | |
| | | package com.vci.ubcs.code.service.impl; |
| | | |
| | | import com.vci.ubcs.code.mapper.CodeResembleRuleMapper; |
| | | import com.vci.ubcs.code.entity.CodeResembleRuleDO; |
| | | import com.vci.ubcs.code.service.CodeResembleRuleServiceI; |
| | | import com.vci.frameworkcore.lcstatuspck.FrameworkDataLCStatus; |
| | | import com.vci.starter.revision.service.RevisionModelUtil; |
| | | import com.vci.starter.web.exception.VciBaseException; |
| | | import com.vci.starter.web.pagemodel.BaseResult; |
| | | import com.vci.starter.web.pagemodel.DataGrid; |
| | | import com.vci.starter.web.pagemodel.PageHelper; |
| | | import com.vci.starter.web.util.BeanUtilForVCI; |
| | | import com.vci.starter.web.util.VciBaseUtil; |
| | | import com.vci.web.pageModel.BatchCBO; |
| | | import com.vci.web.service.WebBoServiceI; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.github.yulichang.base.MPJBaseServiceImpl; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import com.vci.ubcs.code.dto.CodeResembleRuleDTO; |
| | | import com.vci.ubcs.code.entity.CodeBasicSec; |
| | | import com.vci.ubcs.code.entity.CodeReferConfig; |
| | | import com.vci.ubcs.code.entity.CodeResembleRule; |
| | | import com.vci.ubcs.code.enumpack.FrameworkDataLCStatus; |
| | | import com.vci.ubcs.code.mapper.CodeReferConfigMapper; |
| | | import com.vci.ubcs.code.mapper.CodeResembleRuleMapper; |
| | | import com.vci.ubcs.code.service.ICodeResembleRuleService; |
| | | import com.vci.ubcs.code.vo.pagemodel.CodeResembleRuleVO; |
| | | import com.vci.ubcs.omd.entity.BtmType; |
| | | 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.MdmBtmTypeConstant; |
| | | import com.vci.ubcs.starter.util.UBCSCondition; |
| | | import com.vci.ubcs.starter.util.UBCSSqlKeyword; |
| | | import com.vci.ubcs.starter.web.pagemodel.DataGrid; |
| | | import com.vci.ubcs.starter.web.pagemodel.PageHelper; |
| | | import com.vci.ubcs.starter.web.util.BeanUtilForVCI; |
| | | import com.vci.ubcs.starter.web.util.VciBaseUtil; |
| | | import net.logstash.logback.encoder.org.apache.commons.lang3.StringUtils; |
| | | 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.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | |
| | | import static com.vci.frameworkcore.constant.FrameWorkLangCodeConstant.*; |
| | | import static com.vci.ubcs.code.constant.FrameWorkLangCodeConstant.*; |
| | | |
| | | /** |
| | | * 相似查询规则服务 |
| | |
| | | * @date 2022-04-10 |
| | | */ |
| | | @Service |
| | | public class CodeResembleRuleServiceImpl implements CodeResembleRuleServiceI { |
| | | public class CodeResembleRuleServiceImpl extends MPJBaseServiceImpl<CodeResembleRuleMapper, CodeResembleRule> implements ICodeResembleRuleService { |
| | | |
| | | /** |
| | | * 日志 |
| | | */ |
| | | private Logger logger = LoggerFactory.getLogger(getClass()); |
| | | |
| | | /** |
| | | * 数据操作层 |
| | | */ |
| | | @Resource |
| | | private CodeResembleRuleMapper codeResembleRuleMapper; |
| | | |
| | | /** |
| | | * 业务类型操作的服务 |
| | | */ |
| | | @Autowired |
| | | @Lazy |
| | | private WebBoServiceI boService; |
| | | |
| | | /** |
| | | * 对象的操作 |
| | | */ |
| | | @Autowired |
| | | private RevisionModelUtil revisionModelUtil; |
| | | /** |
| | | * 对象的操作 |
| | | */ |
| | | @Autowired |
| | | private RevisionModelUtil revisionModelUtil; |
| | | |
| | | |
| | | /** |
| | | * 查询所有的相似查询规则 |
| | | * @param conditionMap 查询条件 |
| | | * @param pageHelper 分页和排序 |
| | | * @return 执行结果 |
| | | * @throws VciBaseException 查询条件和分页出错的时候会抛出异常 |
| | | */ |
| | | @Override |
| | | public DataGrid<CodeResembleRuleVO> gridCodeResembleRule(Map<String, String> conditionMap, PageHelper pageHelper) throws VciBaseException{ |
| | | if (pageHelper == null) { |
| | | pageHelper = new PageHelper(-1); |
| | | } |
| | | pageHelper.addDefaultDesc("createTime"); |
| | | List<CodeResembleRuleDO> doList = codeResembleRuleMapper.selectByCondition(conditionMap,pageHelper); |
| | | DataGrid<CodeResembleRuleVO> dataGrid=new DataGrid<CodeResembleRuleVO>(); |
| | | if (!CollectionUtils.isEmpty(doList)) { |
| | | dataGrid.setData(codeResembleRuleDO2VOs(doList)); |
| | | dataGrid.setTotal(VciBaseUtil.getInt(String.valueOf(codeResembleRuleMapper.countByCondition(conditionMap)))); |
| | | } |
| | | return dataGrid; |
| | | } |
| | | @Override |
| | | public CodeResembleRuleVO getObjectByOid(String oid) { |
| | | return codeResembleRuleDO2VO(selectByOid(oid)); |
| | | } |
| | | |
| | | /** |
| | | * 批量数据对象转换为显示对象 |
| | | * @param codeResembleRuleDOs 数据对象列表 |
| | | * @return 显示对象 |
| | | * @throws VciBaseException 参数为空或者不存在的时候会抛出异常 |
| | | */ |
| | | @Override |
| | | public List<CodeResembleRuleVO> codeResembleRuleDO2VOs(Collection<CodeResembleRuleDO> codeResembleRuleDOs) throws VciBaseException{ |
| | | List<CodeResembleRuleVO> voList = new ArrayList<CodeResembleRuleVO>(); |
| | | if(!CollectionUtils.isEmpty(codeResembleRuleDOs)){ |
| | | for(CodeResembleRuleDO s: codeResembleRuleDOs){ |
| | | CodeResembleRuleVO vo = codeResembleRuleDO2VO(s); |
| | | if(vo != null){ |
| | | voList.add(vo); |
| | | } |
| | | } |
| | | } |
| | | return voList; |
| | | } |
| | | |
| | | /** |
| | | * 数据对象转换为显示对象 |
| | | * @param codeResembleRuleDO 数据对象 |
| | | * @return 显示对象 |
| | | * @throws VciBaseException 拷贝属性出错的时候会抛出异常 |
| | | */ |
| | | @Override |
| | | public CodeResembleRuleVO codeResembleRuleDO2VO(CodeResembleRuleDO codeResembleRuleDO) throws VciBaseException{ |
| | | CodeResembleRuleVO vo = new CodeResembleRuleVO(); |
| | | if(codeResembleRuleDO != null){ |
| | | BeanUtilForVCI.copyPropertiesIgnoreCase(codeResembleRuleDO,vo); |
| | | //如果有lcstatus的类的话 |
| | | vo.setLcStatusText(FrameworkDataLCStatus.getTextByValue(vo.getLcStatus())); |
| | | |
| | | } |
| | | return vo; |
| | | } |
| | | |
| | | /** |
| | | * 增加相似查询规则 |
| | | * @param codeResembleRuleDTO 相似查询规则数据传输对象 |
| | | * @return 执行结果 |
| | | * @throws VciBaseException 参数为空,唯一项,必输项不通过时会抛出异常 |
| | | */ |
| | | @Override |
| | | public CodeResembleRuleVO addSave(CodeResembleRuleDTO codeResembleRuleDTO) throws VciBaseException{ |
| | | VciBaseUtil.alertNotNull(codeResembleRuleDTO,"需要添加的数据对象"); |
| | | //将DTO转换为DO |
| | | CodeResembleRuleDO codeResembleRuleDO = new CodeResembleRuleDO(); |
| | | BeanUtilForVCI.copyPropertiesIgnoreCase(codeResembleRuleDTO,codeResembleRuleDO); |
| | | codeResembleRuleMapper.insert(codeResembleRuleDO); |
| | | return codeResembleRuleDO2VO(codeResembleRuleDO); |
| | | } |
| | | |
| | | /** |
| | | * 修改相似查询规则 |
| | | * @param codeResembleRuleDTO 相似查询规则数据传输对象 |
| | | * @return 执行结果 |
| | | * @throws VciBaseException 参数为空,唯一项,必输项不通过时会抛出异常 |
| | | */ |
| | | @Override |
| | | public CodeResembleRuleVO editSave(CodeResembleRuleDTO codeResembleRuleDTO) throws VciBaseException{ |
| | | VciBaseUtil.alertNotNull(codeResembleRuleDTO,"数据对象",codeResembleRuleDTO.getOid(),"相似查询规则主键"); |
| | | //将DTO转换为DO |
| | | CodeResembleRuleDO codeResembleRuleDO = selectByOid(codeResembleRuleDTO.getOid()); |
| | | revisionModelUtil.copyFromDTOIgnore(codeResembleRuleDTO,codeResembleRuleDO); |
| | | codeResembleRuleMapper.updateByPrimaryKey(codeResembleRuleDO); |
| | | return codeResembleRuleDO2VO(codeResembleRuleDO); |
| | | } |
| | | /** |
| | | * 主键查询数据对象 |
| | | * @param oid 主键 |
| | | * @return 数据对象 |
| | | * @throws VciBaseException 参数为空,并且数据不存在的时候会抛出异常 |
| | | */ |
| | | private CodeResembleRule selectByOid(String oid) throws VciBaseException { |
| | | VciBaseUtil.alertNotNull(oid,"主键"); |
| | | CodeResembleRule codeResembleRuleDO = baseMapper.selectById(oid.trim()); |
| | | // CodeResembleRule codeResembleRuleDO = codeResembleRuleMapper.selectByPrimaryKey(oid.trim()); |
| | | if(codeResembleRuleDO == null || StringUtils.isBlank(codeResembleRuleDO.getOid())){ |
| | | throw new VciBaseException(DATA_OID_NOT_EXIST); |
| | | } |
| | | return codeResembleRuleDO; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 校验是否可以删除,如果存在下级,并且下级有数据引用则不能删除 |
| | | * @param codeResembleRuleDTO 数据传输对象 |
| | | * @param codeResembleRuleDO 数据库中的数据对象 |
| | | * @return success为true为可以删除,false表示有数据引用,obj为true表示有下级 |
| | | */ |
| | | private BaseResult checkIsCanDeleteForDO(CodeResembleRuleDTO codeResembleRuleDTO, CodeResembleRuleDO codeResembleRuleDO) { |
| | | CodeResembleRuleDO tsDO = new CodeResembleRuleDO(); |
| | | BeanUtilForVCI.copyPropertiesIgnoreCase(codeResembleRuleDTO,tsDO); |
| | | boService.checkTs(tsDO); |
| | | if(!checkIsLinked(codeResembleRuleDO.getOid())) { |
| | | return BaseResult.success(); |
| | | }else{ |
| | | return BaseResult.fail(DATA_LINKED_NOT_DELETE,new String[]{""}); |
| | | } |
| | | } |
| | | /** |
| | | * 数据对象转换为显示对象 |
| | | * @param codeResembleRuleDO 数据对象 |
| | | * @return 显示对象 |
| | | * @throws VciBaseException 拷贝属性出错的时候会抛出异常 |
| | | */ |
| | | @Override |
| | | public CodeResembleRuleVO codeResembleRuleDO2VO(CodeResembleRule codeResembleRuleDO) throws VciBaseException{ |
| | | CodeResembleRuleVO vo = new CodeResembleRuleVO(); |
| | | if(codeResembleRuleDO != null){ |
| | | BeanUtilForVCI.copyPropertiesIgnoreCase(codeResembleRuleDO,vo); |
| | | //如果有lcstatus的类的话 |
| | | vo.setLcStatusText(FrameworkDataLCStatus.getTextByValue(vo.getLcStatus())); |
| | | |
| | | /** |
| | | * 校验是否被引用 |
| | | * @param oid 主键 |
| | | * @throws VciBaseException 被引用的时候会抛出异常 |
| | | */ |
| | | private boolean checkIsLinked(String oid) throws VciBaseException{ |
| | | //TODO 添加需要校验引用的地方 |
| | | return false; |
| | | } |
| | | } |
| | | return vo; |
| | | } |
| | | |
| | | /** |
| | | * 删除相似查询规则 |
| | | * @param codeResembleRuleDTO 相似查询规则数据传输对象,oid和ts需要传输 |
| | | * @return 删除结果反馈::success:成功,fail:失败 |
| | | * @throws VciBaseException 参数为空,被引用时抛出异常 |
| | | */ |
| | | @Override |
| | | public BaseResult deleteCodeResembleRule(CodeResembleRuleDTO codeResembleRuleDTO) throws VciBaseException{ |
| | | VciBaseUtil.alertNotNull(codeResembleRuleDTO,"相似查询规则数据对象",codeResembleRuleDTO.getOid(),"相似查询规则的主键"); |
| | | CodeResembleRuleDO codeResembleRuleDO = selectByOid(codeResembleRuleDTO.getOid()); |
| | | BaseResult baseResult = checkIsCanDeleteForDO(codeResembleRuleDTO,codeResembleRuleDO); |
| | | if(baseResult.isSuccess()) { |
| | | }else{ |
| | | return baseResult; |
| | | } |
| | | //执行删除操作 |
| | | BatchCBO batchCBO = codeResembleRuleMapper.deleteByPrimaryKey(codeResembleRuleDO.getOid()); |
| | | return (batchCBO!=null && batchCBO.getDeleteCbos() !=null &&batchCBO.getDeleteCbos().size() > 0)?BaseResult.successMsg(DELETE_SUCCESS):BaseResult.fail(DELETE_FAIL); |
| | | } |
| | | /** |
| | | * 查询所有的相似查询规则 |
| | | * @param conditionMap 查询条件 |
| | | * @param pageHelper 分页和排序 |
| | | * @return 执行结果 |
| | | * @throws VciBaseException 查询条件和分页出错的时候会抛出异常 |
| | | */ |
| | | @Override |
| | | public DataGrid<CodeResembleRuleVO> gridCodeResembleRule(Map<String, String> conditionMap, PageHelper pageHelper) throws VciBaseException{ |
| | | if (pageHelper == null) { |
| | | pageHelper = new PageHelper(-1); |
| | | } |
| | | Query query = new Query(); |
| | | query.setSize(pageHelper.getLimit()); |
| | | query.setCurrent(pageHelper.getPage()); |
| | | query.setDescs("createTime"); |
| | | MPJLambdaWrapper<CodeResembleRule> mpjLambdaWrapper = new MPJLambdaWrapper<>(CodeResembleRule.class,CodeTableNameEnum.PL_CODE_RULE.getText()); |
| | | Map<String, Object> condition = new HashMap<>(conditionMap); |
| | | // 添加where条件 |
| | | UBCSSqlKeyword.buildConditionByAs(condition,mpjLambdaWrapper,CodeTableNameEnum.PL_CODE_RULE.getText()); |
| | | IPage<CodeResembleRule> codeResembleRuleIPage = baseMapper.selectPage(UBCSCondition.getPage(query), mpjLambdaWrapper); |
| | | DataGrid<CodeResembleRuleVO> dataGrid=new DataGrid<CodeResembleRuleVO>(); |
| | | if (!CollectionUtils.isEmpty(codeResembleRuleIPage.getRecords())) { |
| | | dataGrid.setData(codeResembleRuleDO2VOs(codeResembleRuleIPage.getRecords())); |
| | | dataGrid.setTotal(codeResembleRuleIPage.getTotal()); |
| | | } |
| | | return dataGrid; |
| | | } |
| | | |
| | | /** |
| | | * 主键获取相似查询规则 |
| | | * @param oid 主键 |
| | | * @return 相似查询规则显示对象 |
| | | * @throws VciBaseException 参数为空,数据不存在时会抛出异常 |
| | | */ |
| | | @Override |
| | | public CodeResembleRuleVO getObjectByOid(String oid) throws VciBaseException{ |
| | | return codeResembleRuleDO2VO(selectByOid(oid)); |
| | | } |
| | | /** |
| | | * 批量数据对象转换为显示对象 |
| | | * @param codeResembleRuleDOs 数据对象列表 |
| | | * @return 显示对象 |
| | | * @throws VciBaseException 参数为空或者不存在的时候会抛出异常 |
| | | */ |
| | | @Override |
| | | public List<CodeResembleRuleVO> codeResembleRuleDO2VOs(Collection<CodeResembleRule> codeResembleRuleDOs) throws VciBaseException{ |
| | | List<CodeResembleRuleVO> voList = new ArrayList<CodeResembleRuleVO>(); |
| | | if(!CollectionUtils.isEmpty(codeResembleRuleDOs)){ |
| | | for(CodeResembleRule s: codeResembleRuleDOs){ |
| | | CodeResembleRuleVO vo = codeResembleRuleDO2VO(s); |
| | | if(vo != null){ |
| | | voList.add(vo); |
| | | } |
| | | } |
| | | } |
| | | return voList; |
| | | } |
| | | |
| | | /** |
| | | * 主键查询数据对象 |
| | | * @param oid 主键 |
| | | * @return 数据对象 |
| | | * @throws VciBaseException 参数为空,并且数据不存在的时候会抛出异常 |
| | | */ |
| | | private CodeResembleRuleDO selectByOid(String oid) throws VciBaseException{ |
| | | VciBaseUtil.alertNotNull(oid,"主键"); |
| | | CodeResembleRuleDO codeResembleRuleDO = codeResembleRuleMapper.selectByPrimaryKey(oid.trim()); |
| | | if(codeResembleRuleDO == null || StringUtils.isBlank(codeResembleRuleDO.getOid())){ |
| | | throw new VciBaseException(DATA_OID_NOT_EXIST); |
| | | } |
| | | return codeResembleRuleDO; |
| | | } |
| | | // /** |
| | | // * 数据对象转换为显示对象 |
| | | // * @param codeResembleRuleDO 数据对象 |
| | | // * @return 显示对象 |
| | | // * @throws VciBaseException 拷贝属性出错的时候会抛出异常 |
| | | // */ |
| | | // @Override |
| | | // public CodeResembleRuleVO codeResembleRuleDO2VO(CodeResembleRule codeResembleRuleDO) throws VciBaseException{ |
| | | // CodeResembleRuleVO vo = new CodeResembleRuleVO(); |
| | | // if(codeResembleRuleDO != null){ |
| | | // BeanUtilForVCI.copyPropertiesIgnoreCase(codeResembleRuleDO,vo); |
| | | // //如果有lcstatus的类的话 |
| | | // vo.setLcStatusText(FrameworkDataLCStatus.getTextByValue(vo.getLcStatus())); |
| | | // |
| | | // } |
| | | // return vo; |
| | | // } |
| | | |
| | | /** |
| | | * 主键批量获取相似查询规则 |
| | | * @param oidCollections 主键集合,但是受性能影响,建议一次查询不超过10000个 |
| | | * @return 相似查询规则显示对象 |
| | | * @throws VciBaseException 查询出现异常时会抛出 |
| | | */ |
| | | @Override |
| | | public Collection<CodeResembleRuleVO> listCodeResembleRuleByOids(Collection<String> oidCollections) throws VciBaseException{ |
| | | VciBaseUtil.alertNotNull(oidCollections,"数据对象主键集合"); |
| | | List<CodeResembleRuleDO> codeResembleRuleDOList = listCodeResembleRuleDOByOidCollections(oidCollections); |
| | | return codeResembleRuleDO2VOs(codeResembleRuleDOList); |
| | | } |
| | | /** |
| | | * 增加相似查询规则 |
| | | * @param codeResembleRuleDTO 相似查询规则数据传输对象 |
| | | * @return 执行结果 |
| | | * @throws VciBaseException 参数为空,唯一项,必输项不通过时会抛出异常 |
| | | */ |
| | | @Override |
| | | public CodeResembleRuleVO addSave(CodeResembleRuleDTO codeResembleRuleDTO) throws VciBaseException{ |
| | | VciBaseUtil.alertNotNull(codeResembleRuleDTO,"需要添加的数据对象"); |
| | | //将DTO转换为DO |
| | | CodeResembleRule codeResembleRuleDO = new CodeResembleRule(); |
| | | BeanUtilForVCI.copyPropertiesIgnoreCase(codeResembleRuleDTO,codeResembleRuleDO); |
| | | DefaultAttrAssimtUtil.addDefaultAttrAssimt(codeResembleRuleDO, MdmBtmTypeConstant.CODE_RESEMBLE_RULE); |
| | | codeResembleRuleDO.setTenantId(AuthUtil.getTenantId()); |
| | | codeResembleRuleDO.setLctid("frameworkDataLc"); |
| | | codeResembleRuleDO.setLcStatus("Enabled"); |
| | | codeResembleRuleDO.setOwner(AuthUtil.getUser().getUserName()); |
| | | codeResembleRuleDO.setLastModifier(AuthUtil.getUser().getUserName()); |
| | | baseMapper.insert(codeResembleRuleDO); |
| | | return codeResembleRuleDO2VO(codeResembleRuleDO); |
| | | } |
| | | |
| | | /** |
| | | * 使用主键集合查询数据对象 |
| | | * @param oidCollections 主键的集合 |
| | | * @return 数据对象列表 |
| | | */ |
| | | private List<CodeResembleRuleDO> listCodeResembleRuleDOByOidCollections(Collection<String> oidCollections){ |
| | | List<CodeResembleRuleDO> codeResembleRuleDOList = new ArrayList<CodeResembleRuleDO>(); |
| | | if(!CollectionUtils.isEmpty(oidCollections)){ |
| | | Collection<Collection<String>> oidCollectionsList = VciBaseUtil.switchCollectionForOracleIn(oidCollections); |
| | | for(Collection<String> oids: oidCollectionsList){ |
| | | List<CodeResembleRuleDO> tempDOList = codeResembleRuleMapper.selectByPrimaryKeyCollection(oids); |
| | | if(!CollectionUtils.isEmpty(tempDOList)){ |
| | | codeResembleRuleDOList.addAll(tempDOList); |
| | | } |
| | | } |
| | | } |
| | | return codeResembleRuleDOList; |
| | | } |
| | | /** |
| | | * 修改相似查询规则 |
| | | * @param codeResembleRuleDTO 相似查询规则数据传输对象 |
| | | * @return 执行结果 |
| | | * @throws VciBaseException 参数为空,唯一项,必输项不通过时会抛出异常 |
| | | */ |
| | | @Override |
| | | public CodeResembleRuleVO editSave(CodeResembleRuleDTO codeResembleRuleDTO) throws VciBaseException{ |
| | | VciBaseUtil.alertNotNull(codeResembleRuleDTO,"数据对象",codeResembleRuleDTO.getOid(),"相似查询规则主键"); |
| | | //将DTO转换为DO |
| | | CodeResembleRule codeResembleRuleDO = selectByOid(codeResembleRuleDTO.getOid()); |
| | | revisionModelUtil.copyFromDTOIgnore(codeResembleRuleDTO,codeResembleRuleDO); |
| | | codeResembleRuleDO.setLastModifier(AuthUtil.getUser().getUserName()); |
| | | codeResembleRuleDO.setLastModifyTime(new Date()); |
| | | codeResembleRuleDO.setTs(new Date()); |
| | | baseMapper.updateById(codeResembleRuleDO); |
| | | return codeResembleRuleDO2VO(codeResembleRuleDO); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 校验是否可以删除,如果存在下级,并且下级有数据引用则不能删除 |
| | | * @param codeResembleRuleDTO 数据传输对象 |
| | | * @param codeResembleRuleDO 数据库中的数据对象 |
| | | * @return success为true为可以删除,false表示有数据引用,obj为true表示有下级 |
| | | */ |
| | | private R checkIsCanDeleteForDO(CodeResembleRuleDTO codeResembleRuleDTO, CodeResembleRule codeResembleRuleDO) { |
| | | CodeResembleRule tsDO = new CodeResembleRule(); |
| | | BeanUtilForVCI.copyPropertiesIgnoreCase(codeResembleRuleDTO,tsDO); |
| | | // boService.checkTs(tsDO); |
| | | // QueryWrapper<CodeResembleRule> wrapper = new QueryWrapper<>(); |
| | | // wrapper.eq("oid",tsDO.getOid()); |
| | | // wrapper.eq("ts",tsDO.getTs()); |
| | | if(!checkIsLinked(codeResembleRuleDO.getOid())) { |
| | | return R.success("可以删除!"); |
| | | }else{ |
| | | return R.fail(DATA_LINKED_NOT_DELETE); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 校验是否被引用 |
| | | * @param oid 主键 |
| | | * @throws VciBaseException 被引用的时候会抛出异常 |
| | | */ |
| | | private boolean checkIsLinked(String oid) throws VciBaseException{ |
| | | //TODO 添加需要校验引用的地方 |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * 删除相似查询规则 |
| | | * @param codeResembleRuleDTO 相似查询规则数据传输对象,oid和ts需要传输 |
| | | * @return 删除结果反馈::success:成功,fail:失败 |
| | | * @throws VciBaseException 参数为空,被引用时抛出异常 |
| | | */ |
| | | @Override |
| | | public R deleteCodeResembleRule(CodeResembleRuleDTO codeResembleRuleDTO) throws VciBaseException{ |
| | | VciBaseUtil.alertNotNull(codeResembleRuleDTO,"相似查询规则数据对象",codeResembleRuleDTO.getOid(),"相似查询规则的主键"); |
| | | CodeResembleRule codeResembleRuleDO = selectByOid(codeResembleRuleDTO.getOid()); |
| | | R baseResult = checkIsCanDeleteForDO(codeResembleRuleDTO,codeResembleRuleDO); |
| | | if(baseResult.isSuccess()) { |
| | | }else{ |
| | | return baseResult; |
| | | } |
| | | //执行删除操作 |
| | | // BatchCBO batchCBO = codeResembleRuleMapper.deleteByPrimaryKey(codeResembleRuleDO.getOid()); |
| | | int i = baseMapper.deleteById(codeResembleRuleDO.getOid()); |
| | | return (i > 0)?R.success(DELETE_SUCCESS):R.fail(DELETE_FAIL); |
| | | } |
| | | |
| | | // /** |
| | | // * 主键查询数据对象 |
| | | // * @param oid 主键 |
| | | // * @return 数据对象 |
| | | // * @throws VciBaseException 参数为空,并且数据不存在的时候会抛出异常 |
| | | // */ |
| | | // private CodeResembleRule selectByOid(String oid) throws VciBaseException{ |
| | | // VciBaseUtil.alertNotNull(oid,"主键"); |
| | | // CodeResembleRule codeResembleRuleDO = codeResembleRuleMapper.selectByPrimaryKey(oid.trim()); |
| | | // if(codeResembleRuleDO == null || StringUtils.isBlank(codeResembleRuleDO.getOid())){ |
| | | // throw new VciBaseException(DATA_OID_NOT_EXIST); |
| | | // } |
| | | // return codeResembleRuleDO; |
| | | // } |
| | | |
| | | /** |
| | | * 主键批量获取相似查询规则 |
| | | * @param oidCollections 主键集合,但是受性能影响,建议一次查询不超过10000个 |
| | | * @return 相似查询规则显示对象 |
| | | * @throws VciBaseException 查询出现异常时会抛出 |
| | | */ |
| | | @Override |
| | | public Collection<CodeResembleRuleVO> listCodeResembleRuleByOids(Collection<String> oidCollections) throws VciBaseException{ |
| | | VciBaseUtil.alertNotNull(oidCollections,"数据对象主键集合"); |
| | | List<CodeResembleRule> codeResembleRuleDOList = listCodeResembleRuleDOByOidCollections(oidCollections); |
| | | return codeResembleRuleDO2VOs(codeResembleRuleDOList); |
| | | } |
| | | |
| | | /** |
| | | * 使用主键集合查询数据对象 |
| | | * @param oidCollections 主键的集合 |
| | | * @return 数据对象列表 |
| | | */ |
| | | private List<CodeResembleRule> listCodeResembleRuleDOByOidCollections(Collection<String> oidCollections){ |
| | | List<CodeResembleRule> codeResembleRuleDOList = new ArrayList<CodeResembleRule>(); |
| | | if(!CollectionUtils.isEmpty(oidCollections)){ |
| | | Collection<Collection<String>> oidCollectionsList = VciBaseUtil.switchCollectionForOracleIn(oidCollections); |
| | | for(Collection<String> oids: oidCollectionsList){ |
| | | List<CodeResembleRule> tempDOList = baseMapper.selectBatchIds(oids); |
| | | if(!CollectionUtils.isEmpty(tempDOList)){ |
| | | codeResembleRuleDOList.addAll(tempDOList); |
| | | } |
| | | } |
| | | } |
| | | return codeResembleRuleDOList; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 参照相似查询规则列表 |
| | | * @param conditionMap 查询条件 |
| | | * @param pageHelper 分页和排序 |
| | | * @return 相似查询规则显示对象列表,生效的内容 |
| | | * @throws VciBaseException 查询条件和分页出错的时候会抛出异常 |
| | | */ |
| | | @Override |
| | | public DataGrid<CodeResembleRuleVO> refDataGridCodeResembleRule(Map<String, String> conditionMap, PageHelper pageHelper) throws VciBaseException{ |
| | | if(conditionMap == null){ |
| | | conditionMap = new HashMap<String, String>(); |
| | | } |
| | | return gridCodeResembleRule(conditionMap,pageHelper); |
| | | } |
| | | /** |
| | | * 参照相似查询规则列表 |
| | | * @param conditionMap 查询条件 |
| | | * @param pageHelper 分页和排序 |
| | | * @return 相似查询规则显示对象列表,生效的内容 |
| | | * @throws VciBaseException 查询条件和分页出错的时候会抛出异常 |
| | | */ |
| | | @Override |
| | | public DataGrid<CodeResembleRuleVO> refDataGridCodeResembleRule(Map<String, String> conditionMap, PageHelper pageHelper) throws VciBaseException{ |
| | | if(conditionMap == null){ |
| | | conditionMap = new HashMap<String, String>(); |
| | | } |
| | | return gridCodeResembleRule(conditionMap,pageHelper); |
| | | } |
| | | } |
| | | |