¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.vci.ubcs.code.service.impl; |
| | | |
| | | import com.alibaba.nacos.common.utils.StringUtils; |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.baomidou.mybatisplus.extension.toolkit.SqlHelper; |
| | | import com.vci.ubcs.starter.revision.model.TreeQueryObject; |
| | | import com.vci.ubcs.starter.revision.model.TreeWrapperOptions; |
| | | import com.vci.ubcs.code.entity.CodeClassify; |
| | | import com.vci.ubcs.code.entity.CodeClstemplateEntity; |
| | | import com.vci.ubcs.code.entity.CodeOsbtmtypeEntity; |
| | | import com.vci.ubcs.code.entity.CodeOsbtmtypeattributeEntity; |
| | | import com.vci.ubcs.code.enumpack.FrameworkDataLCStatus; |
| | | import com.vci.ubcs.code.mapper.CodeClassifyMapper; |
| | | import com.vci.ubcs.code.mapper.CodeClstemplateMapper; |
| | | import com.vci.ubcs.code.mapper.CodeOsbtmtypeMapper; |
| | | import com.vci.ubcs.code.mapper.CodeOsbtmtypeattributeMapper; |
| | | import com.vci.ubcs.code.po.CodeClassifyPO; |
| | | import com.vci.ubcs.code.service.ICodeClassifyService; |
| | | import com.vci.ubcs.code.service.ICodeKeyattrrepeatService; |
| | | import com.vci.ubcs.code.service.ICodeRuleService; |
| | | import com.vci.ubcs.code.vo.CodeOsattributeVO; |
| | | import com.vci.ubcs.code.vo.CodeOsbtmtypeVO; |
| | | import com.vci.ubcs.code.vo.pagemodel.CodeClassifyVO; |
| | | import com.vci.ubcs.code.vo.pagemodel.CodeKeyAttrRepeatRuleVO; |
| | | import com.vci.ubcs.code.vo.pagemodel.CodeRuleVO; |
| | | import com.vci.ubcs.starter.revision.model.TreeQueryObject; |
| | | import com.vci.ubcs.starter.bo.WriteExcelData; |
| | | import com.vci.ubcs.starter.exception.VciBaseException; |
| | | import com.vci.ubcs.starter.poi.bo.ReadExcelOption; |
| | | import com.vci.ubcs.starter.poi.bo.WriteExcelOption; |
| | | import com.vci.ubcs.starter.poi.constant.ExcelLangCodeConstant; |
| | | import com.vci.ubcs.starter.poi.util.ExcelUtil; |
| | | import com.vci.ubcs.starter.revision.service.RevisionModelUtil; |
| | | import com.vci.ubcs.starter.util.LocalFileUtil; |
| | | import com.vci.ubcs.starter.web.pagemodel.BaseQueryObject; |
| | | import com.vci.ubcs.starter.web.pagemodel.DataGrid; |
| | | import com.vci.ubcs.starter.web.pagemodel.Tree; |
| | | import com.vci.ubcs.starter.web.util.BeanUtilForVCI; |
| | | import com.vci.ubcs.starter.web.util.LangBaseUtil; |
| | | import com.vci.ubcs.starter.web.util.VciBaseUtil; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import org.apache.poi.hssf.util.HSSFColor; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springblade.core.cache.utils.CacheUtil; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.File; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.vci.ubcs.code.constant.FrameWorkDefaultValueConstant.*; |
| | | |
| | | @Service |
| | | public class CodeClassifyServiceImpl extends ServiceImpl<CodeClassifyMapper, CodeClassify> implements ICodeClassifyService { |
| | | |
| | | @Resource |
| | | private CodeClassifyMapper codeClassifyMapper; |
| | | |
| | | @Resource |
| | | private CodeClstemplateMapper codeClstemplateMapper; |
| | | |
| | | @Resource |
| | | private ICodeRuleService codeRuleService; |
| | | |
| | | @Resource |
| | | private CodeOsbtmtypeMapper codeOsbtmtypeMapper; |
| | | @Resource |
| | | CodeOsbtmtypeattributeMapper codeOsbtmtypeattributeMapper; |
| | | |
| | | /** |
| | | * æ¥å¿ |
| | | */ |
| | | private Logger logger = LoggerFactory.getLogger(getClass()); |
| | | /** |
| | | * 对象çæä½ |
| | | */ |
| | | @Resource |
| | | private RevisionModelUtil revisionModelUtil; |
| | | |
| | | @Resource |
| | | private ICodeKeyattrrepeatService iCodeKeyattrrepeatService; |
| | | /** |
| | | * ä¸çº§èç¹ç屿§åç§° |
| | | */ |
| | | public static final String PARENT_FIELD_NAME = "parentCodeClassifyOid"; |
| | | /** |
| | | * ä½¿ç¨æ¥è¯¢å°è£
卿¥æ¥è¯¢ |
| | | * @param wrapper æ¥è¯¢å°è£
å¨ |
| | | * @return æ°æ®å¯¹è±¡ |
| | | */ |
| | | @Override |
| | | public List<CodeClassify> selectByWrapper(Wrapper wrapper) { |
| | | return codeClassifyMapper.selectList(wrapper); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<CodeClassifyVO> selectPlCodeClassifyPage(IPage<CodeClassifyVO> page, CodeClassifyVO plCodeClassify) { |
| | | return page.setRecords(codeClassifyMapper.selectPlCodeClassifyPage(page, plCodeClassify)); |
| | | } |
| | | |
| | | @Override |
| | | public R addSave(CodeClassify codeClassifyEntity) { |
| | | |
| | | if(StringUtils.isNotBlank(codeClassifyEntity.getParentCodeClassifyOid()) && StringUtils.isNotBlank(codeClassifyEntity.getBtmTypeId())){ |
| | | return R.fail("åªæå¨é¡¶å±ç主é¢åºåç±»æè½è®¾ç½®ä¸å¡ç±»å"); |
| | | } |
| | | codeClassifyEntity.setCreator(AuthUtil.getUser().getUserName()); |
| | | codeClassifyEntity.setCreateTime(new Date()); |
| | | codeClassifyEntity.setTs(new Date()); |
| | | codeClassifyEntity.setOwner(AuthUtil.getUser().getUserName()); |
| | | codeClassifyEntity.setLastModifier(AuthUtil.getUser().getUserName()); |
| | | codeClassifyEntity.setLastModifyTime(new Date()); |
| | | codeClassifyEntity.setRevisionSeq(1); |
| | | codeClassifyEntity.setVersionSeq(1); |
| | | int insertNumber = codeClassifyMapper.insert(codeClassifyEntity); |
| | | return R.status(SqlHelper.retBool(insertNumber)); |
| | | } |
| | | |
| | | /** |
| | | * ä¿®æ¹ä¸»é¢åºåç±» |
| | | * @param codeClassifyEntity 主é¢åºåç±»æ°æ®ä¼ è¾å¯¹è±¡ |
| | | * @return æ§è¡ç»æ |
| | | */ |
| | | @Override |
| | | public R editSave(CodeClassify codeClassifyEntity) { |
| | | if(codeClassifyEntity == null || codeClassifyEntity.getOid() == null){ |
| | | return R.fail("ä¼ å
¥æ°æ®ä¸è½ä¸ºç©ºï¼"); |
| | | } |
| | | //æ£æ¥ts |
| | | Map<String,Object> condition = new HashMap<>(2); |
| | | condition.put("oid",codeClassifyEntity.getOid()); |
| | | condition.put("ts",codeClassifyEntity.getTs()); |
| | | CodeClassify detail = codeClassifyMapper |
| | | .selectOne(Condition.getQueryWrapper(condition,CodeClassify.class)); |
| | | if(detail == null){//䏿¯ææ°çä¸è®©æ¹ |
| | | return R.fail("å½åæ°æ®ä¸æ¯ææ°ï¼è¯·å·æ°ååä¿®æ¹ï¼"); |
| | | } |
| | | |
| | | if(StringUtils.isNotBlank(codeClassifyEntity.getParentCodeClassifyOid()) && StringUtils.isNotBlank(codeClassifyEntity.getBtmTypeId())){ |
| | | return R.fail("åªæå¨é¡¶å±ç主é¢åºåç±»æè½è®¾ç½®ä¸å¡ç±»å"); |
| | | } |
| | | codeClassifyEntity.setLastModifier(AuthUtil.getUser().getUserName()); |
| | | codeClassifyEntity.setLastModifyTime(new Date()); |
| | | int insertNumber = codeClassifyMapper.updateById(codeClassifyEntity); |
| | | |
| | | // //å¤çæ°æ®éæé»è¾,æååæ§è¡éæç¬¬ä¸æ¥,åç±»æ°æ®ç¹æ®å¤çãåªæå¯ç¨ç¶æçåç±»ææ¨é |
| | | // if(FRAMEWORK_DATA_ENABLED.equals(codeClassifyDO.getLcStatus())); |
| | | // { |
| | | // codeDuckingServiceI.insertCache1(CACHE_TYPE_CLASSIFY_EDIT,FRAMEWORK_DATA_ENABLED,DOCKING_DEFAULT_CLASSIFY, DOCKING_DEFAULT_CLASSIFYOID, codeClassifyDO.getOid(), codeClassifyDTO.getTs()); |
| | | // } |
| | | return R.status(SqlHelper.retBool(insertNumber)); |
| | | // return BaseResult.success(codeClassifyDO2VO(codeClassifyDO)); |
| | | } |
| | | |
| | | /** |
| | | * æ£æ¥ 主é¢åºåç±»æ¯å¦å é¤ |
| | | * @param codeClassifyEntity 主é¢åºåç±»æ°æ®ä¼ è¾å¯¹è±¡ï¼å¿
é¡»è¦æoidåts屿§ |
| | | * @return æ§è¡ç»æ success为true为å¯ä»¥å é¤ï¼falseè¡¨ç¤ºææ°æ®å¼ç¨ï¼obj为true表示æä¸çº§ |
| | | */ |
| | | @Override |
| | | public R checkIsCanDelete(CodeClassify codeClassifyEntity) { |
| | | if(codeClassifyEntity == null || codeClassifyEntity.getOid() == null){ |
| | | return R.fail("ä¼ å
¥æ°æ®ä¸è½ä¸ºç©ºï¼"); |
| | | } |
| | | CodeClassify codeClassifyNew = selectByOid(codeClassifyEntity.getOid()); |
| | | if(codeClassifyNew == null){ |
| | | return R.fail("æªæ¥è¯¢å°ç¸å
³æ°æ®ï¼"); |
| | | } |
| | | codeClassifyNew.setTs(codeClassifyEntity.getTs()); |
| | | return checkIsCanDeleteForDO(codeClassifyEntity); |
| | | } |
| | | |
| | | /** |
| | | * 䏻鮿¥è¯¢æ°æ®å¯¹è±¡ |
| | | * @param oid ä¸»é® |
| | | * @return æ°æ®å¯¹è±¡ |
| | | */ |
| | | private CodeClassify selectByOid(String oid){ |
| | | |
| | | CodeClassify codeClassifyEntity = codeClassifyMapper.selectById(oid.trim()); |
| | | if(codeClassifyEntity == null || StringUtils.isBlank(codeClassifyEntity.getOid())){ |
| | | throw new ServiceException("dataOidNotExist");//æ ¹æ®ä¸»é®idæªæ¥å°ç¸å
³æ°æ® |
| | | } |
| | | return codeClassifyEntity; |
| | | } |
| | | |
| | | /** |
| | | * æ ¡éªæ¯å¦å¯ä»¥å é¤ï¼å¦æåå¨ä¸çº§ï¼å¹¶ä¸ä¸çº§ææ°æ®å¼ç¨åä¸è½å é¤ |
| | | * @param codeClassifyEntity æ°æ®åºä¸çæ°æ®å¯¹è±¡ |
| | | * @return success为true为å¯ä»¥å é¤ï¼falseè¡¨ç¤ºææ°æ®å¼ç¨ï¼obj为true表示æä¸çº§ |
| | | */ |
| | | private R checkIsCanDeleteForDO(CodeClassify codeClassifyEntity) { |
| | | |
| | | //æ£æ¥ts |
| | | // Map<String,Object> condition = new HashMap<>(2); |
| | | // condition.put("oid",codeClassifyEntity.getOid()); |
| | | // condition.put("ts",codeClassifyEntity.getTs()); |
| | | CodeClassify detail = codeClassifyMapper.selectOne(Condition.getQueryWrapper(codeClassifyEntity)); |
| | | // .selectOne(Condition.getQueryWrapper(condition,CodeClassify.class)); |
| | | if(detail == null){//䏿¯ææ°çä¸è®©æ¹ |
| | | throw new ServiceException("å½åæ°æ®ä¸æ¯ææ°ï¼è¯·å·æ°ååä¿®æ¹ï¼"); |
| | | // return R.fail("å½åæ°æ®ä¸æ¯ææ°ï¼è¯·å·æ°ååä¿®æ¹ï¼"); |
| | | } |
| | | //æ ¡éªä¸çº§æ¯å¦æå¼ç¨ |
| | | if(checkChildIsLinked(detail.getOid())){ |
| | | return R.fail("dataCascadeLinkedNotDelete"); |
| | | } |
| | | return R.data(checkHasChild(detail.getOid())); |
| | | } |
| | | |
| | | /** |
| | | * æ£æ¥æ¯å¦æä¸çº§æ¯å¦å
³èäºæ°æ® |
| | | * |
| | | * @param oid ä¸»é® |
| | | * @return true 表示æå¼ç¨ï¼false表示没æå¼ç¨ |
| | | */ |
| | | @Override |
| | | public boolean checkChildIsLinked(String oid) { |
| | | |
| | | Map<String,String> childOids = codeClassifyMapper.selectAllLevelChildOid(oid.trim()); |
| | | if(!CollectionUtils.isEmpty(childOids)){ |
| | | for(String childOid: childOids.keySet()){ |
| | | if(!checkIsLinked(childOid)){ |
| | | return false; |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * æ ¡éªæ¯å¦è¢«å¼ç¨ |
| | | * @param oid ä¸»é® |
| | | */ |
| | | private boolean checkIsLinked(String oid) { |
| | | //TODO æ·»å éè¦æ ¡éªå¼ç¨çå°æ¹ |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | | public boolean checkHasChild(String oid) { |
| | | if(StringUtils.isBlank(oid)){ |
| | | throw new ServiceException("oidä¸è½ä¸ºç©ºï¼"); |
| | | } |
| | | return codeClassifyMapper.checkHasChild(oid.trim()); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * å é¤ä¸»é¢åºåç±» |
| | | * @param codeClassify 主é¢åºåç±»æ°æ®ä¼ è¾å¯¹è±¡ï¼oidåtséè¦ä¼ è¾ |
| | | * @return å é¤ç»æåé¦ï¼ï¼successï¼æåï¼failï¼å¤±è´¥ |
| | | */ |
| | | @Override |
| | | public R deleteCodeClassify(CodeClassify codeClassify) { |
| | | |
| | | if(codeClassify == null || codeClassify.getOid() == null){ |
| | | throw new ServiceException("ä¼ å
¥åæ°ä¸è½ä¸ºç©ºï¼"); |
| | | } |
| | | codeClassify = codeClassifyMapper.selectById(codeClassify.getOid()); |
| | | |
| | | R result = checkIsCanDeleteForDO(codeClassify); |
| | | |
| | | //å
ç®ç§°æ¯å¦æå
³è模æ¿ï¼ææ¨¡æ¿è¦å
å é¤ |
| | | Map<String,Object> condition = new HashMap<>(2); |
| | | condition.put("codeClassifyOid",codeClassify.getOid()); |
| | | List<CodeClstemplateEntity> codeClstemplateEntities = codeClstemplateMapper.selectByMap(condition); |
| | | // VciQueryWrapperForDO queryWrapper = new VciQueryWrapperForDO(CodeClassifyTemplateDO.class); |
| | | // queryWrapper.addQueryMap("codeClassifyOid",codeClassifyDTO.getOid()); |
| | | // List<CodeClassifyTemplateDO> codeClassifyTemplateDOListHaveTemplate = codeClassifyTemplateMapper.selectByWrapper(queryWrapper); |
| | | if(codeClstemplateEntities.size()>0){ |
| | | return R.fail("åç±»å
³è模æ¿ï¼è¯·å
å é¤!"); |
| | | } |
| | | |
| | | //å¤çæ°æ®éæé»è¾,æååæ§è¡éæç¬¬ä¸æ¥,åç±»æ°æ®ç¹æ®å¤çã |
| | | //1ãæ¥è¯¢è¦å é¤çç¶ç±»æ°æ® |
| | | List<CodeClassify> deletes = new ArrayList<CodeClassify>(); |
| | | deletes.add(codeClassify); |
| | | |
| | | if(result.isSuccess()) { |
| | | //æ¾ä¸çº§çï¼è¿ä¸ªæ¯å¯ä»¥å é¤çæ¶å |
| | | Map<String,String> childrenOids = codeClassifyMapper.selectAllLevelChildOid(codeClassify.getOid().trim()); |
| | | if (!CollectionUtils.isEmpty(childrenOids)) { |
| | | Collection<Collection<String>> childrenCollections = VciBaseUtil.switchCollectionForOracleIn(childrenOids.keySet()); |
| | | for(Collection<String> s : childrenCollections){ |
| | | |
| | | //å¤çæ°æ®éæé»è¾,æååæ§è¡éæç¬¬ä¸æ¥,åç±»æ°æ®ç¹æ®å¤çã |
| | | //2ãæ¥è¯¢è¦å é¤çåç±»æ°æ® |
| | | List<CodeClassify> codeClassifyDOList = codeClassifyMapper.selectBatchIds(s); |
| | | deletes.addAll(codeClassifyDOList); |
| | | codeClassifyMapper.deleteBatchIds(s); |
| | | } |
| | | |
| | | } |
| | | }else{ |
| | | return result; |
| | | } |
| | | |
| | | //æ§è¡å é¤æä½ |
| | | int deleteCount = codeClassifyMapper.deleteById(codeClassify.getOid()); |
| | | |
| | | //å¤çæ°æ®éæé»è¾,æååæ§è¡éæç¬¬ä¸æ¥ |
| | | for (CodeClassify codeClassifyTemp:deletes){ |
| | | //codeDuckingServiceI.insertCache1(CACHE_TYPE_CLASSIFY_DELETE,FRAMEWORK_DATA_DISABLED,DOCKING_DEFAULT_CLASSIFY, DOCKING_DEFAULT_CLASSIFYOID, codeClassifyDO1.getOid(), DateUtils.addHours(new Date(),1));//è¿éæ¯å½åæ¶é´ |
| | | |
| | | //åå¨è¦å é¤çæ°æ® |
| | | // CacheUtil.put(); |
| | | CacheUtil.put("ubcs:code", "bean:id:", codeClassifyTemp.getOid(), codeClassifyTemp); |
| | | // codeDuckingServiceI.cacheDeleteData(codeClassifyTemp.getOid(), codeClassifyTemp); |
| | | } |
| | | return R.data(deleteCount>0); |
| | | // return null; |
| | | } |
| | | |
| | | /** |
| | | * å¯ç¨ãåç¨ |
| | | * @param oid ä¸»é® |
| | | * @param lcStatus ç¶æ |
| | | * @return æ§è¡ç»æ |
| | | */ |
| | | @Override |
| | | public R updateLcStatus(String oid, String lcStatus){ |
| | | |
| | | //æ¥è¯¢ä¿®æ¹åts |
| | | CodeClassify codeClassify = codeClassifyMapper.selectById(oid);//ä¸»è¦æ¯ä¸ºäºæ¥è¯¢ts |
| | | codeClassify.setLcStatus(lcStatus); |
| | | codeClassify.setTs(new Date()); |
| | | codeClassify.setLastModifyTime(new Date()); |
| | | codeClassify.setLastModifier(AuthUtil.getUser().getUserName()); |
| | | //å¯ç¨ãåç¨ |
| | | // int u = codeClassifyMapper.updateLcStatus(oid,lcStatus); |
| | | int count = codeClassifyMapper.updateById(codeClassify); |
| | | // //å¤çæ°æ®éæé»è¾,æååæ§è¡éæç¬¬ä¸æ¥,åç±»æ°æ®ç¹æ®å¤çã |
| | | // if(u!=0) { |
| | | // codeDuckingServiceI.insertCache1(lcStatus,lcStatus,DOCKING_DEFAULT_CLASSIFY, DOCKING_DEFAULT_CLASSIFYOID, oid, codeClassifyDO_old.getTs()); |
| | | // } |
| | | return R.data(SqlHelper.retBool(count)); |
| | | } |
| | | |
| | | /** |
| | | * 䏻鮿¹éè·å主é¢åºåç±» |
| | | * @param oidCollections 主é®éåï¼ä½æ¯åæ§è½å½±åï¼å»ºè®®ä¸æ¬¡æ¥è¯¢ä¸è¶
è¿10000个 |
| | | * @return 主é¢åºåç±»æ¾ç¤ºå¯¹è±¡ |
| | | */ |
| | | @Override |
| | | public Collection<CodeClassifyVO> listCodeClassifyByOids(Collection<String> oidCollections) { |
| | | VciBaseUtil.alertNotNull(oidCollections,"æ°æ®å¯¹è±¡ä¸»é®éå"); |
| | | List<CodeClassify> codeClassifyDOList = listCodeClassifyDOByOidCollections(oidCollections); |
| | | return codeClassifyDO2VOs(codeClassifyDOList); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 使ç¨ä¸»é®éåæ¥è¯¢æ°æ®å¯¹è±¡ |
| | | * @param oidCollections 主é®çéå |
| | | * @return æ°æ®å¯¹è±¡å表 |
| | | */ |
| | | private List<CodeClassify> listCodeClassifyDOByOidCollections(Collection<String> oidCollections){ |
| | | List<CodeClassify> codeClassifyList = new ArrayList<CodeClassify>(); |
| | | if(!CollectionUtils.isEmpty(oidCollections)){ |
| | | Collection<Collection<String>> oidCollectionsList = VciBaseUtil.switchCollectionForOracleIn(oidCollections); |
| | | for(Collection<String> oids: oidCollectionsList){ |
| | | List<CodeClassify> tempDOList = codeClassifyMapper.selectBatchIds(oids); |
| | | if(!CollectionUtils.isEmpty(tempDOList)){ |
| | | codeClassifyList.addAll(tempDOList); |
| | | } |
| | | } |
| | | } |
| | | return codeClassifyList; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * æ¹éæ°æ®å¯¹è±¡è½¬æ¢ä¸ºæ¾ç¤ºå¯¹è±¡ |
| | | * @param codeClassifys æ°æ®å¯¹è±¡å表 |
| | | * @return æ¾ç¤ºå¯¹è±¡ |
| | | */ |
| | | @Override |
| | | public List<CodeClassifyVO> codeClassifyDO2VOs(Collection<CodeClassify> codeClassifys) { |
| | | List<CodeClassifyVO> voList = new ArrayList<CodeClassifyVO>(); |
| | | if(!CollectionUtils.isEmpty(codeClassifys)){ |
| | | for(CodeClassify s: codeClassifys){ |
| | | CodeClassifyVO vo = codeClassifyDO2VO(s); |
| | | if(vo != null){ |
| | | voList.add(vo); |
| | | } |
| | | } |
| | | } |
| | | return voList; |
| | | } |
| | | |
| | | /** |
| | | * æ°æ®å¯¹è±¡è½¬æ¢ä¸ºæ¾ç¤ºå¯¹è±¡ |
| | | * @param codeClassify æ°æ®å¯¹è±¡ |
| | | * @return æ¾ç¤ºå¯¹è±¡ |
| | | */ |
| | | @Override |
| | | public CodeClassifyVO codeClassifyDO2VO(CodeClassify codeClassify) { |
| | | CodeClassifyVO vo = new CodeClassifyVO(); |
| | | if(codeClassify != null){ |
| | | BeanUtilForVCI.copyPropertiesIgnoreCase(codeClassify,vo); |
| | | //妿ælcstatusçç±»çè¯ |
| | | vo.setLcStatusText(FrameworkDataLCStatus.getTextByValue(vo.getLcStatus())); |
| | | } |
| | | return vo; |
| | | } |
| | | |
| | | /** |
| | | * åç
§æ 主é¢åºåç±» |
| | | * @param treeQueryObject æ å½¢æ¥è¯¢å¯¹è±¡ |
| | | * @return 主é¢åºåç±»æ¾ç¤ºæ |
| | | */ |
| | | @Override |
| | | public List<Tree> referTree(TreeQueryObject treeQueryObject) { |
| | | if(treeQueryObject == null){ |
| | | treeQueryObject = new TreeQueryObject(); |
| | | } |
| | | if(treeQueryObject.getConditionMap() == null){ |
| | | treeQueryObject.setConditionMap(new HashMap<>()); |
| | | } |
| | | if(treeQueryObject.getConditionMap().containsKey(LC_STATUS)) { |
| | | treeQueryObject.getConditionMap().remove(LC_STATUS); |
| | | } |
| | | if(treeQueryObject.getExtandParamsMap() ==null || !treeQueryObject.getExtandParamsMap().containsKey(REFER_SHOW_DISABLED_QUERY_KEY)) { |
| | | } |
| | | treeQueryObject.getConditionMap().put(LC_STATUS, FRAMEWORK_DATA_ENABLED); |
| | | return treeCodeClassify(treeQueryObject); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢ä¸»é¢åºåç±» æ |
| | | * @param treeQueryObject æ æ¥è¯¢å¯¹è±¡ |
| | | * @return 主é¢åºåç±» æ¾ç¤ºæ |
| | | */ |
| | | @Override |
| | | public List<Tree> treeCodeClassify(TreeQueryObject treeQueryObject) { |
| | | List<CodeClassify> doList =codeClassifyMapper.selectCodeClassifyVOByTree(treeQueryObject.getParentOid()); |
| | | List<CodeClassifyVO> voList = codeClassifyDO2VOs(doList); |
| | | TreeWrapperOptions treeWrapperOptions = new TreeWrapperOptions(PARENT_FIELD_NAME.toLowerCase(Locale.ROOT)); |
| | | treeWrapperOptions.copyFromTreeQuery(treeQueryObject); |
| | | List<Tree> tree= revisionModelUtil.doList2Trees(voList,treeWrapperOptions,(CodeClassifyVO s) ->{ |
| | | //å¯ä»¥å¨è¿éå¤çæ èç¹çæ¾ç¤º |
| | | return s.getId() + " " + s.getName() + (FrameworkDataLCStatus.DISABLED.getValue().equalsIgnoreCase(s |
| | | .getLcStatus()) ? (" ãåç¨ã ") : ""); |
| | | }); |
| | | Iterator var6 = tree.listIterator(); |
| | | while(var6.hasNext()){ |
| | | Tree trees = (Tree) var6.next(); |
| | | boolean checkHasChild=codeClassifyMapper.checkHasChild(trees.getOid()); |
| | | if(checkHasChild){ |
| | | trees.setLeaf(false); |
| | | }else{ |
| | | trees.setLeaf(true); |
| | | } |
| | | } |
| | | return tree; |
| | | } |
| | | |
| | | |
| | | // /** |
| | | // * æ ¹æ®æ å½¢æ¥è¯¢å¯¹è±¡æ¥æ¥è¯¢æ°æ®å¯¹è±¡ |
| | | // * |
| | | // * @param treeQueryObject æ å½¢æ¥è¯¢å¯¹è±¡ |
| | | // * @return æ¥è¯¢ç»æ,æ°æ®å¯¹è±¡ |
| | | // */ |
| | | // @Override |
| | | // public List<CodeClassifyVO> selectCodeClassifyDOByTree(TreeQueryObject treeQueryObject) { |
| | | // VciQueryWrapperForDO queryWrapperForDO = new VciQueryWrapperForDO(null,CodeClassifyDO.class); |
| | | // VciParentQueryOption parentQueryOption = new VciParentQueryOption(); |
| | | // parentQueryOption.setParentFieldName(PARENT_FIELD_NAME); |
| | | // queryWrapperForDO.parentQueryChild(treeQueryObject,parentQueryOption); |
| | | // if(StringUtils.isBlank(treeQueryObject.getSort())) { |
| | | // PageHelper pageHelper = new PageHelper(-1); |
| | | // pageHelper.addDefaultAsc("id"); |
| | | // queryWrapperForDO.setPageHelper(pageHelper); |
| | | // } |
| | | // return codeClassifyMapper.selectByWrapper(queryWrapperForDO); |
| | | // } |
| | | |
| | | /** |
| | | * 导åºåç±» |
| | | * |
| | | * @param oid åç±»ä¸»é® |
| | | * @return excelæä»¶è·¯å¾ |
| | | */ |
| | | @Override |
| | | public String exportClassify(String oid) { |
| | | VciBaseUtil.alertNotNull(oid,"åç±»ç主é®"); |
| | | CodeClassify codeClassify = codeClassifyMapper.selectById(oid); |
| | | codeClassify.setDataLevel(0); |
| | | codeClassify.setPath(codeClassify.getId()); |
| | | List<CodeClassifyVO> codeClassifyVOS = listChildrenClassify(oid, true, "id", false); |
| | | if(codeClassifyVOS ==null){ |
| | | codeClassifyVOS = new ArrayList<>(); |
| | | } |
| | | CodeClassifyVO codeClassifyVO = new CodeClassifyVO(); |
| | | BeanUtils.copyProperties(codeClassify,codeClassifyVO); |
| | | codeClassifyVOS.add(codeClassifyVO); |
| | | |
| | | //æ¥è¯¢ä¸ä¸è§åçç¼å·ï¼åå
³é®å±æ§éå¤è§å |
| | | List<String> codeRuleOids = codeClassifyVOS.stream().filter(s -> StringUtils.isNotBlank(s.getCoderuleoid())).map(CodeClassifyVO::getCoderuleoid).collect(Collectors.toList()); |
| | | Map<String, CodeRuleVO> ruleVOMap = new HashMap<>(); |
| | | if(!CollectionUtils.isEmpty(codeRuleOids)){ |
| | | VciBaseUtil.switchCollectionForOracleIn(codeRuleOids).stream().forEach(ruleOids->{ |
| | | // Collection<CodeRuleVO> ruleVOS = codeRuleService.listCodeRuleByOids(ruleOids); |
| | | Collection<CodeRuleVO> ruleVOS = null; |
| | | ruleVOMap.putAll( Optional.ofNullable(ruleVOS).orElseGet(()->new ArrayList<>()).stream().collect(Collectors.toMap(s->s.getOid(),t->t))); |
| | | }); |
| | | } |
| | | //æ¾å
³é®å±æ§è§å |
| | | List<String> keyRuleOids = codeClassifyVOS.stream().filter(s -> StringUtils.isNotBlank(s.getCodekeyattrrepeatoid())).map(CodeClassifyVO::getCodekeyattrrepeatoid).collect(Collectors.toList()); |
| | | Map<String, CodeKeyAttrRepeatRuleVO> keyRuleVOMap = new HashMap<>(); |
| | | if(!CollectionUtils.isEmpty(keyRuleOids)){ |
| | | VciBaseUtil.switchCollectionForOracleIn(keyRuleOids).stream().forEach(ruleOids->{ |
| | | Collection<CodeKeyAttrRepeatRuleVO> ruleVOS = iCodeKeyattrrepeatService.listCodeKeyAttrRepeatRuleByOids(ruleOids); |
| | | keyRuleVOMap.putAll( Optional.ofNullable(ruleVOS).orElseGet(()->new ArrayList<>()).stream().collect(Collectors.toMap(s->s.getOid(),t->t))); |
| | | }); |
| | | } |
| | | //ok,åexcel |
| | | String excelName = LocalFileUtil.getDefaultTempFolder() + File.separator + "导åºåç±».xls"; |
| | | try { |
| | | new File(excelName).createNewFile(); |
| | | } catch (Throwable e) { |
| | | throw new VciBaseException(LangBaseUtil.getErrorMsg(e), new String[]{excelName}, e); |
| | | } |
| | | List<WriteExcelData> excelDataList = new ArrayList<>(); |
| | | excelDataList.add(new WriteExcelData(0,0,"åç±»ç¼å·")); |
| | | excelDataList.add(new WriteExcelData(0,1,"åç±»åç§°")); |
| | | excelDataList.add(new WriteExcelData(0,2,"ä¸å¡ç±»åç¼å·")); |
| | | excelDataList.add(new WriteExcelData(0,3,"ä¸å¡ç±»ååç§°")); |
| | | excelDataList.add(new WriteExcelData(0,4,"ç¼ç è§åç¼å·")); |
| | | excelDataList.add(new WriteExcelData(0,5,"ç¼ç è§ååç§°")); |
| | | excelDataList.add(new WriteExcelData(0,6,"æ¥éè§åç¼å·")); |
| | | excelDataList.add(new WriteExcelData(0,7,"æ¥éè§ååç§°")); |
| | | excelDataList.add(new WriteExcelData(0,8,"å类路å¾")); |
| | | excelDataList.add(new WriteExcelData(0,9,"ç¶æ")); |
| | | excelDataList.add(new WriteExcelData(0,10,"åç±»å±çº§")); |
| | | excelDataList.add(new WriteExcelData(0,11,"æè¿°")); |
| | | for (int i = 0; i < codeClassifyVOS.size(); i++) { |
| | | CodeClassifyVO vo = codeClassifyVOS.get(i); |
| | | excelDataList.add(new WriteExcelData(i+1,0,vo.getId())); |
| | | excelDataList.add(new WriteExcelData(i+1,1,vo.getName())); |
| | | excelDataList.add(new WriteExcelData(i+1,2,vo.getBtmtypeid())); |
| | | excelDataList.add(new WriteExcelData(i+1,3,vo.getBtmtypename())); |
| | | excelDataList.add(new WriteExcelData(i+1,4, StringUtils.isNotBlank(vo.getCoderuleoid())?ruleVOMap.getOrDefault(vo.getCoderuleoid(),new CodeRuleVO()).getId():"")); |
| | | excelDataList.add(new WriteExcelData(i+1,5, StringUtils.isNotBlank(vo.getCoderuleoid())?ruleVOMap.getOrDefault(vo.getCoderuleoid(),new CodeRuleVO()).getName():"")); |
| | | excelDataList.add(new WriteExcelData(i+1,6, StringUtils.isNotBlank(vo.getCodekeyattrrepeatoid())?keyRuleVOMap.getOrDefault(vo.getCodekeyattrrepeatoid(),new CodeKeyAttrRepeatRuleVO()).getId():"")); |
| | | excelDataList.add(new WriteExcelData(i+1,7, StringUtils.isNotBlank(vo.getCodekeyattrrepeatoid())?keyRuleVOMap.getOrDefault(vo.getCodekeyattrrepeatoid(),new CodeKeyAttrRepeatRuleVO()).getName():"")); |
| | | excelDataList.add(new WriteExcelData(i+1,8,vo.getOid().equalsIgnoreCase(codeClassify.getOid())?vo.getPath():codeClassify.getPath() + vo.getPath())); |
| | | excelDataList.add(new WriteExcelData(i+1,9,FrameworkDataLCStatus.getTextByValue(vo.getLcStatus()))); |
| | | excelDataList.add(new WriteExcelData(i+1,10,vo.getDataLevel())); |
| | | excelDataList.add(new WriteExcelData(i+1,11,vo.getDescription())); |
| | | } |
| | | WriteExcelOption excelOption = new WriteExcelOption(excelDataList); |
| | | ExcelUtil.writeDataToFile(excelName, excelOption); |
| | | return excelName; |
| | | } |
| | | |
| | | /** |
| | | * è·åå级ç主é¢åºåç±» |
| | | * |
| | | * @param codeClassifyOid åç±»çä¸»é® |
| | | * @param allLevel æ¯å¦ææçå±çº§ |
| | | * @param fieldInPath å¨è·¯å¾ä¸çåæ®µ |
| | | * @param enable æ¯å¦åªæ¾ç¤ºå¯ç¨ |
| | | * @return åç±»çæ¾ç¤ºå¯¹è±¡ |
| | | */ |
| | | @Override |
| | | public List<CodeClassifyVO> listChildrenClassify(String codeClassifyOid, boolean allLevel, String fieldInPath, boolean enable) { |
| | | if(allLevel){ |
| | | List<CodeClassify> classifyDOS = codeClassifyMapper.selectAllLevelChildHasPath(codeClassifyOid); |
| | | if(!CollectionUtils.isEmpty(classifyDOS)){ |
| | | classifyDOS = classifyDOS.stream().filter(s->FRAMEWORK_DATA_ENABLED.equalsIgnoreCase(s.getLcStatus())).collect(Collectors.toList()); |
| | | } |
| | | return codeClassifyDO2VOs(classifyDOS); |
| | | }else{ |
| | | //åªæ¥è¯¢ä¸æ¡ï¼é£path就没å¿
è¦æ¥è¯¢äº |
| | | Map<String,Object> conditionMap = new HashMap<>(); |
| | | conditionMap.put("parentcodeclassifyoid",codeClassifyOid); |
| | | if (enable){ |
| | | conditionMap.put("lcstatus",FRAMEWORK_DATA_ENABLED); |
| | | } |
| | | return codeClassifyDO2VOs(codeClassifyMapper.selectByMap(conditionMap)); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * å建导å
¥æ¨¡æ¿ |
| | | * |
| | | * @return excelæä»¶è·¯å¾ |
| | | */ |
| | | @Override |
| | | public String createImportExcel() { |
| | | //ok,åexcel |
| | | String excelName = LocalFileUtil.getDefaultTempFolder() + File.separator + "å类导å
¥æ¨¡æ¿.xls"; |
| | | try { |
| | | new File(excelName).createNewFile(); |
| | | } catch (Throwable e) { |
| | | throw new VciBaseException(LangBaseUtil.getErrorMsg(e), new String[]{excelName}, e); |
| | | } |
| | | List<WriteExcelData> excelDataList = new ArrayList<>(); |
| | | WriteExcelData excelData = new WriteExcelData(0, 0, "åç±»ç¼å·"); |
| | | excelData.setFontColor(String.valueOf(HSSFColor.HSSFColorPredefined.RED.getIndex())); |
| | | excelDataList.add(excelData); |
| | | WriteExcelData excelData1 = new WriteExcelData(0, 1, "åç±»åç§°"); |
| | | excelData1.setFontColor(String.valueOf(HSSFColor.HSSFColorPredefined.RED.getIndex())); |
| | | excelDataList.add(excelData1); |
| | | excelDataList.add(new WriteExcelData(0,2,"ä¸å¡ç±»åç¼å·")); |
| | | excelDataList.add(new WriteExcelData(0,3,"ç¼ç è§åç¼å·")); |
| | | excelDataList.add(new WriteExcelData(0,4,"æ¥éè§åç¼å·")); |
| | | WriteExcelData excelData2 = new WriteExcelData(0, 5, "å类路å¾"); |
| | | excelData2.setFontColor(String.valueOf(HSSFColor.HSSFColorPredefined.RED.getIndex())); |
| | | excelDataList.add(excelData2); |
| | | excelDataList.add(new WriteExcelData(0,6,"ç¶æ")); |
| | | WriteExcelOption excelOption = new WriteExcelOption(excelDataList); |
| | | ExcelUtil.writeDataToFile(excelName, excelOption); |
| | | return excelName; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 导å
¥åç±» |
| | | * |
| | | * @param file1 æä»¶çä¿¡æ¯ |
| | | * @return é误æä»¶çå°å |
| | | */ |
| | | @Override |
| | | public void importClassify(File file1) { |
| | | VciBaseUtil.alertNotNull(file1,"excelæä»¶"); |
| | | if(!file1.exists()){ |
| | | throw new VciBaseException("导å
¥çexcelæä»¶ä¸åå¨,{0}",new String[]{file1.getPath()}); |
| | | } |
| | | ReadExcelOption excelOption = new ReadExcelOption(); |
| | | List<CodeClassifyPO> poList = null; |
| | | try{ |
| | | poList = ExcelUtil.readDataObjectFromExcel(file1,CodeClassifyPO.class,excelOption,(value,po,fieldName)->{ |
| | | po.setLcStatus(FrameworkDataLCStatus.getValueByText(po.getLcStatusText())); |
| | | if(StringUtils.isBlank(po.getLcStatusText())){ |
| | | po.setLcStatus(FrameworkDataLCStatus.ENABLED.getValue()); |
| | | } |
| | | }); |
| | | }catch (Exception e){ |
| | | if(logger.isErrorEnabled()){ |
| | | logger.error("读åexcelå
å®¹çæ¶ååºç°äºé误",e); |
| | | } |
| | | throw new VciBaseException(LangBaseUtil.getErrorMsg(e),new String[]{},e); |
| | | } |
| | | //å»é¤æ´è¡é½æ¯ç©ºçæ
åµ |
| | | |
| | | if(CollectionUtils.isEmpty(poList)){ |
| | | throw new VciBaseException(ExcelLangCodeConstant.IMPORT_CONTENT_NULL,new String[]{}); |
| | | } |
| | | |
| | | poList = poList.stream().filter(s->!(StringUtils.isBlank(s.getId()) && StringUtils.isBlank(s.getName()) && StringUtils.isBlank(s.getPath()))).collect(Collectors.toList()); |
| | | |
| | | List<CodeClassify> codeClassify = new ArrayList<>(); |
| | | //ççè·¯å¾æ¯å¦æéå¤ |
| | | Map<String/**è·¯å¾**/, Long/**个æ°**/> pathCountMap = poList.stream().filter(s->StringUtils.isNotBlank(s.getPath())).collect(Collectors.groupingBy(s -> s.getPath(), Collectors.counting())); |
| | | List<String> repeatPaths = Optional.ofNullable(pathCountMap).orElse(new HashMap<>()).entrySet().stream().filter(entry -> entry.getValue() > 1).map(entry -> entry.getKey()).collect(Collectors.toList()); |
| | | if(!CollectionUtils.isEmpty(repeatPaths)){ |
| | | //æéå¤çå
容 |
| | | List<String> rowIndexList = new ArrayList<>(); |
| | | poList.stream().forEach(po->{ |
| | | if(repeatPaths.contains(po.getPath())){ |
| | | rowIndexList.add(po.getRowIndex()); |
| | | } |
| | | }); |
| | | throw new VciBaseException("è·¯å¾æéå¤,{0}",new String[]{rowIndexList.stream().collect(Collectors.joining(","))}); |
| | | } |
| | | //ç¼å·è·åä¸å¡ç±»åæå¡ |
| | | List<String> ruleOids = poList.stream().filter( |
| | | s -> StringUtils.isNotBlank(s.getCodeRuleId())) |
| | | .map(CodeClassifyPO::getCodeRuleId) |
| | | .collect(Collectors.toList()); |
| | | Map<String, CodeRuleVO> ruleVOMap = Optional.ofNullable(ruleOids.size()==0 ? null:codeRuleService.listCodeRuleByOids(ruleOids) |
| | | ).orElse(new ArrayList<>()).stream().collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t,(o1,o2)->o2)); |
| | | |
| | | List<String> keyOids = poList.stream().filter(s -> StringUtils.isNotBlank(s.getKeyRepeatRuleId())) |
| | | .map(CodeClassifyPO::getKeyRepeatRuleId).collect(Collectors.toList()); |
| | | Map<String,CodeKeyAttrRepeatRuleVO> keyRuleVOMap =Optional.ofNullable(keyOids.size()==0 ? null: iCodeKeyattrrepeatService.listCodeKeyAttrRepeatRuleByOids(keyOids) |
| | | ).orElse(new ArrayList<>()).stream().collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t,(o1,o2)->o2)); |
| | | |
| | | List<String> btmOids = poList.stream().filter(s -> StringUtils.isNotBlank(s.getKeyRepeatRuleId())) |
| | | .map(CodeClassifyPO::getBtmTypeId).collect(Collectors.toList()); |
| | | Map<String, CodeOsbtmtypeEntity> btmVOMap = Optional.ofNullable(btmOids.size()==0 ? null: codeOsbtmtypeMapper.selectBatchIds(btmOids) |
| | | ).orElse(new ArrayList<>()).stream().collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t,(o1,o2)->o2)); |
| | | // Map<String, CodeOsbtmtypeVO> btmVOMap = null; |
| | | Map<String/**è·¯å¾**/,String/**主é®**/> oidPathMap = new HashMap<>(); |
| | | |
| | | //æä»¬éè¦æ¥è¯¢ææå·²ç»åå¨çåç±»ï¼ä¸»è¦æ¯è·¯å¾ï¼ç¨æ¥å¤æåç±»çæ°æ® |
| | | List<CodeClassify> existClassifyDOs = codeClassifyMapper.selectAllLevelChildHasPath(""); |
| | | Map<String/**è·¯å¾**/, CodeClassify/**å·²ç»åå¨çæ°æ®**/> pathDOMap = Optional.ofNullable(existClassifyDOs).orElse(new ArrayList<>()).stream().collect(Collectors.toMap(s -> { |
| | | String path = s.getPath(); |
| | | if(StringUtils.isNotBlank(path) && path.startsWith("#")){ |
| | | return path.substring(1); |
| | | } |
| | | return path; |
| | | }, t -> t)); |
| | | poList.stream().forEach(po->{ |
| | | CodeClassify classify = new CodeClassify(); |
| | | VciBaseUtil.alertNotNull(po.getId(),"åç±»ç¼å·",po.getName(),"åç±»åç§°",po.getPath(),"å类路å¾"); |
| | | if(StringUtils.isNotBlank(po.getBtmTypeId()) && !btmVOMap.containsKey(po.getBtmTypeId().toLowerCase(Locale.ROOT))){ |
| | | throw new VciBaseException("第{0}è¡çä¸å¡ç±»å{1}å¨ç³»ç»ä¸ä¸åå¨",new String[]{String.valueOf(VciBaseUtil.getInt(po.getRowIndex())+1),po.getBtmTypeId()}); |
| | | } |
| | | if(StringUtils.isNotBlank(po.getCodeRuleId()) && !ruleVOMap.containsKey(po.getCodeRuleId().toLowerCase(Locale.ROOT))){ |
| | | throw new VciBaseException("第{0}è¡çç¼ç è§å{1}å¨ç³»ç»ä¸ä¸åå¨",new String[]{String.valueOf(po.getRowIndex()+1),po.getCodeRuleId()}); |
| | | } |
| | | if(StringUtils.isNotBlank(po.getKeyRepeatRuleId()) && !keyRuleVOMap.containsKey(po.getKeyRepeatRuleId().toLowerCase(Locale.ROOT))){ |
| | | throw new VciBaseException("第{0}è¡çå
³é®å±æ§æ¥éè§å{1}å¨ç³»ç»ä¸ä¸åå¨",new String[]{String.valueOf(po.getRowIndex()+1),po.getKeyRepeatRuleId()}); |
| | | } |
| | | classify.setOid(VciBaseUtil.getPk()); |
| | | classify.setId(po.getId()); |
| | | classify.setName(po.getName()); |
| | | classify.setDescription(po.getDescription()); |
| | | oidPathMap.put(po.getPath(),classify.getOid()); |
| | | if(StringUtils.isNotBlank(po.getBtmTypeId())){ |
| | | CodeOsbtmtypeVO typeVO = (CodeOsbtmtypeVO)btmVOMap.get(po.getBtmTypeId().toLowerCase(Locale.ROOT)); |
| | | classify.setBtmTypeId(typeVO.getId()); |
| | | classify.setBtmTypeName(typeVO.getName()); |
| | | } |
| | | if(StringUtils.isNotBlank(po.getCodeRuleId())){ |
| | | CodeRuleVO codeRuleVO = ruleVOMap.get(po.getCodeRuleId().toLowerCase(Locale.ROOT)); |
| | | classify.setCodeRuleOid(codeRuleVO.getOid()); |
| | | } |
| | | if(StringUtils.isNotBlank(po.getKeyRepeatRuleId())){ |
| | | CodeKeyAttrRepeatRuleVO repeatRuleVO = keyRuleVOMap.get(po.getKeyRepeatRuleId()); |
| | | classify.setCodeKeyAttrRepeatOid(repeatRuleVO.getOid()); |
| | | } |
| | | classify.setLcStatus(po.getLcStatus()); |
| | | classify.setPath(po.getPath()); |
| | | codeClassify.add(classify); |
| | | }); |
| | | //è¦çåå¨çï¼ä¿®æ¹è·¯å¾å¯¹åºçä¸»é® |
| | | Map<String/**è·¯å¾**/,String/**主é®**/> catchedOidPathMap = new HashMap<>(); |
| | | if(!CollectionUtils.isEmpty(oidPathMap)){ |
| | | oidPathMap.forEach((path,oid)->{ |
| | | if(pathDOMap.containsKey(path)){ |
| | | //说æåå¨ |
| | | catchedOidPathMap.put(path,pathDOMap.get(path).getOid()); |
| | | }else{ |
| | | catchedOidPathMap.put(path,oid); |
| | | } |
| | | }); |
| | | } |
| | | List<CodeClassify> addClassifyDOList = new ArrayList<>(); |
| | | List<CodeClassify> editClassifyDOList = new ArrayList<>(); |
| | | codeClassify.stream().forEach(classifyDO->{ |
| | | |
| | | //è¦çä¸çº§æ¯ä¸æ¯åå¨å¦ |
| | | String parentPath = classifyDO.getPath(); |
| | | if(parentPath.contains("#")) { |
| | | parentPath = parentPath.substring(0, parentPath.lastIndexOf("#")); |
| | | } |
| | | if((!catchedOidPathMap.containsKey(parentPath) && !pathDOMap.containsKey(parentPath) )&& !classifyDO.getPath().equalsIgnoreCase(classifyDO.getId())){ |
| | | throw new VciBaseException("åç±»ç¼å·[{0}],åç±»åç§°[{1}]ï¼è·¯å¾ä¸º[{2}]çä¸çº§åç±»å¨ç³»ç»ä¸ï¼å¨æ¬æ¬¡å¯¼å
¥çæ°æ®åç³»ç»ä¸åæ²¡ææ¾å°",new String[]{classifyDO.getId(),classifyDO.getName(),classifyDO.getPath()}); |
| | | } |
| | | if (!classifyDO.getPath().equalsIgnoreCase(classifyDO.getId())){ |
| | | //䏿¯é¡¶çº§çæ¶åï¼è¦è®¾ç½®ä¸çº§çä¸»é® |
| | | |
| | | classifyDO.setParentCodeClassifyOid(catchedOidPathMap.containsKey(parentPath)?catchedOidPathMap.get(parentPath):pathDOMap.get(parentPath).getOid()); |
| | | } |
| | | if(classifyDO.getPath().equalsIgnoreCase(classifyDO.getId()) && StringUtils.isBlank(classifyDO.getBtmTypeId())){ |
| | | throw new VciBaseException("åç±»ç¼å·[{0}],åç±»åç§°[{1}]ï¼æ¯é¡¶å±åç±»ï¼éè¦è®¾ç½®ä¸å¡ç±»åç¼å·",new String[]{classifyDO.getId(),classifyDO.getName()}); |
| | | } |
| | | if(pathDOMap.containsKey(classifyDO.getPath())){ |
| | | //åå¨ï¼éè¦ä¿®æ¹å¯¹è±¡ |
| | | classifyDO.setOid(catchedOidPathMap.get(classifyDO.getPath())); |
| | | CodeClassify classifyDOInDB = pathDOMap.get(classifyDO.getPath()); |
| | | classifyDOInDB.setOid(classifyDO.getOid()); |
| | | classifyDOInDB.setId(classifyDO.getId()); |
| | | classifyDOInDB.setName(classifyDO.getName()); |
| | | classifyDOInDB.setDescription(classifyDO.getDescription()); |
| | | classifyDOInDB.setBtmTypeId(classifyDO.getBtmTypeId()); |
| | | classifyDOInDB.setBtmTypeName(classifyDO.getBtmTypeName()); |
| | | classifyDOInDB.setCodeRuleOid(classifyDO.getCodeRuleOid()); |
| | | classifyDOInDB.setCodeRuleOidName(classifyDO.getCodeRuleOidName()); |
| | | classifyDOInDB.setParentCodeClassifyOid(classifyDO.getParentCodeClassifyOid()); |
| | | classifyDOInDB.setCodeKeyAttrRepeatOid(classifyDO.getCodeKeyAttrRepeatOid()); |
| | | classifyDOInDB.setCodeKeyAttrRepeatOidName(classifyDO.getCodeKeyAttrRepeatOidName()); |
| | | if(classifyDOInDB.getOrderNum() == null){ |
| | | classifyDOInDB.setOrderNum(0); |
| | | } |
| | | editClassifyDOList.add(classifyDOInDB); |
| | | }else{ |
| | | //æ¯æ°çï¼ç´æ¥æ·»å å°±è¡äº |
| | | //夿巿ä¹å¤ç? |
| | | classifyDO.setOrderNum(0); |
| | | addClassifyDOList.add(classifyDO); |
| | | } |
| | | }); |
| | | if(!CollectionUtils.isEmpty(editClassifyDOList)){ |
| | | VciBaseUtil.switchCollectionForOracleIn(editClassifyDOList).stream().forEach( |
| | | // classifyDOs->{codeClassifyMapper..updateById(classifyDOs.stream().collect(Collectors.toList())); |
| | | classifyDos->{ |
| | | for (CodeClassify classifyDo : classifyDos) { |
| | | codeClassifyMapper.updateById(classifyDo); |
| | | } |
| | | // } |
| | | }); |
| | | } |
| | | if(!CollectionUtils.isEmpty(addClassifyDOList)){ |
| | | // revisionModelUtil.wrapperForBatchAdd(addClassifyDOList); |
| | | VciBaseUtil.switchCollectionForOracleIn(addClassifyDOList).stream().forEach(classifyDOs->{ |
| | | for (CodeClassify classifyDO : classifyDOs) { |
| | | classifyDO.setCreateTime(new Date()); |
| | | classifyDO.setTs(new Date()); |
| | | classifyDO.setBtmname("codeclassify"); |
| | | classifyDO.setLcStatus("Enabled"); |
| | | classifyDO.setOwner(AuthUtil.getUser().getUserName()); |
| | | classifyDO.setCreator(AuthUtil.getUser().getUserName()); |
| | | classifyDO.setLastModifier(AuthUtil.getUser().getUserName()); |
| | | classifyDO.setLastModifyTime(new Date()); |
| | | codeClassifyMapper.insert(classifyDO); |
| | | } |
| | | // codeClassifyMapper.batchInsert(classifyDOs.stream().collect(Collectors.toList())); |
| | | }); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * è·ååç±»å
³èç屿§ |
| | | * |
| | | * @param baseQueryObject æ¥è¯¢å¯¹è±¡ï¼å¿
é¡»æcodeClassifyOidï¼æ¯æidånameä¸¤ç§æ¥è¯¢æ¡ä»¶ |
| | | * @return 屿§çä¿¡æ¯ï¼å
å«é»è®¤ç屿§ |
| | | */ |
| | | @Override |
| | | public DataGrid<CodeOsattributeVO> listClassifyLinkAttr(BaseQueryObject baseQueryObject) { |
| | | if(baseQueryObject == null){ |
| | | baseQueryObject = new BaseQueryObject(); |
| | | } |
| | | if(baseQueryObject.getConditionMap() == null){ |
| | | baseQueryObject.setConditionMap(new HashMap<>()); |
| | | } |
| | | String classifyOid = baseQueryObject.getConditionMap().getOrDefault("codeClassifyOid",""); |
| | | String id = baseQueryObject.getConditionMap().getOrDefault("id",""); |
| | | String name = baseQueryObject.getConditionMap().getOrDefault("name",""); |
| | | if(StringUtils.isBlank(classifyOid)){ |
| | | return new DataGrid<>(); |
| | | } |
| | | CodeClassifyVO topClassifyVO = getTopClassifyVO(classifyOid); |
| | | if(topClassifyVO == null || StringUtils.isBlank(topClassifyVO.getBtmtypeid())){ |
| | | return new DataGrid<>(); |
| | | } |
| | | |
| | | Map<String,Object> condition = new HashMap<>(1); |
| | | condition.put("pkbtmtype",topClassifyVO.getBtmtypeid()); |
| | | |
| | | List<CodeOsbtmtypeattributeEntity> unDefaultAttributes = codeOsbtmtypeattributeMapper.selectByMap(condition); |
| | | // List<OsBtmTypeAttributeVO> unDefaultAttributes = btmService. (topClassifyVO.getBtmtypeid()); |
| | | List<CodeOsattributeVO> attributeVOS = new ArrayList<>(); |
| | | if(!CollectionUtils.isEmpty(unDefaultAttributes)){ |
| | | unDefaultAttributes.stream().forEach(attr->{ |
| | | CodeOsattributeVO attributeVO = new CodeOsattributeVO(); |
| | | BeanUtils.copyProperties(attr,attributeVO); |
| | | attributeVO.setAttributedatatype(attr.getAttrdatatype()); |
| | | attributeVO.setAttrlength(Short.valueOf(attr.getAttributelength())); |
| | | attributeVO.setBtmtypeid(attr.getReferbtmtypeid()); |
| | | attributeVO.setBtmtypename(attr.getReferbtmtypename()); |
| | | boolean add = true; |
| | | if(StringUtils.isNotBlank(id) && !attributeVO.getId().contains(id.replace("*",""))){ |
| | | add = false; |
| | | } |
| | | if(StringUtils.isNotBlank(name) && !attributeVO.getId().contains(name.replace("*",""))){ |
| | | add = false; |
| | | } |
| | | if(add){ |
| | | attributeVOS.add(attributeVO); |
| | | } |
| | | }); |
| | | } |
| | | // if(!CollectionUtils.isEmpty(attributeService.getDefaultAttributeVOs())){ |
| | | // attributeService.getDefaultAttributeVOs().stream().forEach(attr->{ |
| | | // boolean add = true; |
| | | // if(StringUtils.isNotBlank(id) && !attr.getId().contains(id.replace("*",""))){ |
| | | // add = false; |
| | | // } |
| | | // if(StringUtils.isNotBlank(name) && !attr.getId().contains(name.replace("*",""))){ |
| | | // add = false; |
| | | // } |
| | | // if(add){ |
| | | // attributeVOS.add(attr); |
| | | // } |
| | | // }); |
| | | // } |
| | | DataGrid<CodeOsattributeVO> dataGrid = new DataGrid<>(); |
| | | dataGrid.setData(attributeVOS); |
| | | dataGrid.setTotal(attributeVOS.size()); |
| | | return dataGrid; |
| | | } |
| | | |
| | | /** |
| | | * è·åå½ååç±»çé¡¶å±åç±» |
| | | * |
| | | * @param codeClassifyOid åç±»çä¸»é® |
| | | * @return é¡¶å±åç±»çä¿¡æ¯ |
| | | */ |
| | | @Override |
| | | public CodeClassifyVO getTopClassifyVO(String codeClassifyOid) { |
| | | VciBaseUtil.alertNotNull(codeClassifyOid,"åç±»ç主é®"); |
| | | |
| | | // List<Map<String,Object>> classifyDOS = codeClassifyMapper.selectAllLevelParentByOid(codeClassifyOid); |
| | | List<CodeClassify> classifyDOS = selectAllLevelParentByOid(codeClassifyOid); |
| | | |
| | | if(!CollectionUtils.isEmpty(classifyDOS)){ |
| | | CodeClassify classifyDO = classifyDOS.stream().filter(s -> StringUtils.isBlank(s.getParentCodeClassifyOid())).findFirst().orElseGet(() -> null); |
| | | if(classifyDO!=null){ |
| | | return codeClassifyDO2VO(classifyDO); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * è·åå½ååç±»çææä¸çº§åç±»ï¼å«æ¬æ¬¡æ¥è¯¢å±çº§å·ï¼ |
| | | * @param oid ä¸»é® |
| | | * @return ææçä¸çº§ |
| | | */ |
| | | @Override |
| | | public List<CodeClassify> selectAllLevelParentByOid(String oid){ |
| | | // String sql = "select oid,level from " + VciBaseUtil.getTableName(MdmBtmTypeConstant.CODE_CLASSIFY) + " start with oid= :oid connect by prior PARENTCODECLASSIFYOID = oid "; |
| | | // Map< String,String> conditionMap = new HashMap< String,String>(); |
| | | // conditionMap.put("oid",oid); |
| | | |
| | | List<Map<String,Object>> cbos = codeClassifyMapper.selectAllLevelParentByOid(oid); |
| | | Map<String,String> oidLevelMap = new HashMap<>(); |
| | | Optional.ofNullable(cbos).orElseGet(()->new ArrayList<>()).stream().forEach(cbo->{ |
| | | oidLevelMap.put(cbo.get("OID").toString(),cbo.get("LEVEL").toString()); |
| | | }); |
| | | if(CollectionUtils.isEmpty(oidLevelMap)){ |
| | | return new ArrayList<>(); |
| | | } |
| | | |
| | | //使ç¨ä¸»é®æ¥è¯¢ä¸ä¸ |
| | | List<CodeClassify> classifyDOS = codeClassifyMapper.selectBatchIds(oidLevelMap.keySet()); |
| | | if(!CollectionUtils.isEmpty(classifyDOS)){ |
| | | classifyDOS.stream().forEach(classifyDO->{ |
| | | classifyDO.setDataLevel(VciBaseUtil.getInt(oidLevelMap.getOrDefault(classifyDO.getOid(),"0"))); |
| | | }); |
| | | } |
| | | return classifyDOS; |
| | | } |
| | | |
| | | /** |
| | | * 使ç¨ç¼å·çè·¯å¾è·å对象 |
| | | * |
| | | * @param idPath ç¼å·çè·¯å¾ï¼ä¸å®è¦ä»æé¡¶å±èç¹å¼å§ï¼æ ¼å¼ä¸ºxxx/yyy/zz è¿æ · |
| | | * @return åç±»çæ¾ç¤ºå¯¹è±¡ |
| | | */ |
| | | @Override |
| | | public CodeClassifyVO getObjectByIdPath(String idPath) { |
| | | List<Map<String, Object>> idPathValues = codeClassifyMapper.selectByFieldPath("/" + idPath); |
| | | CodeClassify classifyDO = null; |
| | | if (idPathValues != null){ |
| | | classifyDO = codeClassifyMapper.selectById(idPathValues.get(0).get("oid").toString()); |
| | | } |
| | | return codeClassifyDO2VO(classifyDO); |
| | | } |
| | | |
| | | /** |
| | | * 主é¢åºçæ |
| | | * |
| | | * @param treeQueryObject æ å½¢æ¥è¯¢å¯¹è±¡ |
| | | * @return 主é¢åºæ¾ç¤ºæ |
| | | */ |
| | | @Override |
| | | public List<Tree> treeTopCodeClassify(TreeQueryObject treeQueryObject) { |
| | | if(treeQueryObject == null){ |
| | | treeQueryObject = new TreeQueryObject(); |
| | | } |
| | | if(treeQueryObject.getConditionMap() == null){ |
| | | treeQueryObject.setConditionMap(new HashMap<>()); |
| | | } |
| | | treeQueryObject.getConditionMap().put(PARENT_FIELD_NAME, "=null"); |
| | | return treeCodeClassify(treeQueryObject); |
| | | } |
| | | |
| | | } |