| | |
| | | import com.vci.ubcs.code.vo.webserviceModel.attrmap.*; |
| | | import com.vci.ubcs.code.vo.webserviceModel.attrmap.DataObjectVO; |
| | | import com.vci.ubcs.code.vo.webserviceModel.classify.*; |
| | | import com.vci.ubcs.code.vo.webserviceModel.classify.QueryClassifyVO; |
| | | import com.vci.ubcs.code.vo.webserviceModel.classify.QueryData; |
| | | import com.vci.ubcs.code.vo.webserviceModel.classify.QueryLibraryVO; |
| | | import com.vci.ubcs.code.vo.webserviceModel.classify.ResultClassifyVO; |
| | | import com.vci.ubcs.code.vo.webserviceModel.coderule.*; |
| | | import com.vci.ubcs.code.vo.webserviceModel.data.*; |
| | | import com.vci.ubcs.code.vo.webserviceModel.result.json.*; |
| | | import com.vci.ubcs.code.vo.webserviceModel.result.xml.XMLResultClassfyVO; |
| | |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.vci.ubcs.code.constant.MdmEngineConstant.DEFAULT_SYNC_ATTR_LIST; |
| | | import static com.vci.ubcs.code.constant.MdmEngineConstant.IMPORT_ROW_INDEX; |
| | | import static com.vci.ubcs.code.enumpack.CodeSecTypeEnum.CODE_CLASSIFY_SEC; |
| | | |
| | | /*** |
| | |
| | | errorid = "101"; |
| | | throw new Throwable("接口参数:账号信息获取失败"); |
| | | } |
| | | if(!CollectionUtils.isEmpty(classifyIdList)){ |
| | | //先简称是否有关联模板,有模板要先删除 |
| | | List<CodeClassify> libIdDos = classifyService.selectByWrapper(Wrappers.<CodeClassify>query().lambda().in(CodeClassify::getId, classifyIdList)); |
| | | codeClassifyVOS=classifyService.codeClassifyDO2VOs(libIdDos); |
| | | }else { |
| | | List<CodeClassify> libIdDos = classifyService.selectByWrapper(Wrappers.<CodeClassify>query().lambda().eq(CodeClassify::getId, libId)); |
| | | String oid= libIdDos.get(0).getOid(); |
| | | TreeQueryObject treeQueryObject=new TreeQueryObject(); |
| | | treeQueryObject.setParentOid(oid); |
| | | treeQueryObject.setQueryAllLevel(true); |
| | | codeClassifyVOS=classifyService.selectCodeClassifyDOByTree(treeQueryObject); |
| | | List<CodeClassify> libIdDos =classifyService.selectByWrapper(Wrappers.<CodeClassify>query().lambda().in(CodeClassify::getId, libId)); |
| | | if(CollectionUtils.isEmpty(libIdDos)) { |
| | | CodeClassify libCodeClassify =libIdDos.get(0); |
| | | String oid=libCodeClassify.getOid(); |
| | | if (!CollectionUtils.isEmpty(classifyIdList)) { |
| | | //先简称是否有关联模板,有模板要先删除 |
| | | List<CodeClassify> childCodeClassifyList = classifyService.selectByWrapper(Wrappers.<CodeClassify>query().lambda().in(CodeClassify::getId, classifyIdList)); |
| | | List<CodeClassify>newchildCodeClassifyList=new ArrayList<>(); |
| | | if(!CollectionUtils.isEmpty(childCodeClassifyList)) { |
| | | Map<String,String> errorMap=new HashMap<>(); |
| | | childCodeClassifyList.stream().forEach(codeClassify -> { |
| | | CodeClassifyVO toClassifyVO= classifyService.getTopClassifyVO(codeClassify.getOid()); |
| | | if(toClassifyVO.getOid().equals(libCodeClassify.getOid())){ |
| | | newchildCodeClassifyList.add(codeClassify); |
| | | } |
| | | }); |
| | | Map<String/**分类编号**/, CodeClassify/**分类对象**/> classifyfCodeMap = newchildCodeClassifyList.stream().collect(Collectors.toMap(s -> s.getId(), t -> t)); |
| | | classifyIdList.stream().forEach(classifyfCode -> { |
| | | if(!classifyfCodeMap.containsKey(classifyfCode)) { |
| | | errorMap.put("error", errorMap.getOrDefault("error", "") + ";根据classCode:【" + classifyfCode + "】在library:【" + libCodeClassify.getId() + "】下未查询到"); |
| | | } |
| | | }); |
| | | if(errorMap.size()>0){ |
| | | errorid = "101"; |
| | | msg = errorMap.getOrDefault("error",""); |
| | | throw new Throwable(msg); |
| | | } |
| | | codeClassifyVOS = classifyService.codeClassifyDO2VOs(newchildCodeClassifyList); |
| | | }else{ |
| | | errorid = "101"; |
| | | msg = "接口参数:classCode 未查询到对应的分类信息"; |
| | | throw new Throwable(msg); |
| | | } |
| | | } else { |
| | | TreeQueryObject treeQueryObject = new TreeQueryObject(); |
| | | treeQueryObject.setParentOid(oid); |
| | | treeQueryObject.setQueryAllLevel(true); |
| | | codeClassifyVOS = classifyService.selectCodeClassifyDOByTree(treeQueryObject); |
| | | } |
| | | }else{ |
| | | errorid = "101"; |
| | | throw new Throwable("接口参数:账号信息获取失败"); |
| | | } |
| | | LibraryVO libraryVo=new LibraryVO(); |
| | | libraryVo.setId(libId); |
| | |
| | | String systemId=""; |
| | | log.info("查询分类的数据参数:->"+data); |
| | | log.info("查询分类的数据类型:->"+dataType); |
| | | ResultClassifyVO resultClassifyVO =new ResultClassifyVO(); |
| | | List<ClassifyVO> classifyVOList=new ArrayList<>(); |
| | | ResultData resultData=new ResultData(); |
| | | ResultClassifyRuleVO resultClassifyRuleVO =new ResultClassifyRuleVO(); |
| | | List<com.vci.ubcs.code.vo.webserviceModel.coderule.ResultClassifyVO> classifyVOList=new ArrayList<>(); |
| | | ResultClassifyRuleData resultClassifyRuleData=new ResultClassifyRuleData(); |
| | | try { |
| | | if (StringUtils.isBlank(data)) { |
| | | errorid = "101"; |
| | |
| | | treeQueryObject.setQueryAllLevel(true); |
| | | codeClassifyVOS=classifyService.selectCodeClassifyDOByTree(treeQueryObject); |
| | | } |
| | | LibraryVO libraryVo=new LibraryVO(); |
| | | libraryVo.setId(libId); |
| | | libraryVo.setName(""); |
| | | ResultLibraryVO resultLibraryVO=new ResultLibraryVO(); |
| | | resultLibraryVO.setId(libId); |
| | | resultLibraryVO.setName(""); |
| | | if(!CollectionUtils.isEmpty(codeClassifyVOS)){ |
| | | errorid = "0"; |
| | | msg="成功!"; |
| | | codeClassifyVOS.stream().forEach(codeClassifyDO -> { |
| | | ClassifyVO classifyVO=new ClassifyVO(); |
| | | //后去包含码段的编码规则 |
| | | CodeRuleVO codeRuleVO= this.engineService.getCodeRuleByClassifyOid(codeClassifyDO.getOid()); |
| | | ResultCodeRuleVO resultCodeRuleVO=new ResultCodeRuleVO(); |
| | | if(codeRuleVO!=null){ |
| | | CodeRuleVO resultClassifyRuleVO1=new CodeRuleVO(); |
| | | List<CodeBasicSecVO> codeBasicSecVOS= codeRuleVO.getSecVOList(); |
| | | List<CodeSectionVO> codeSectionVOList=new CopyOnWriteArrayList<>(); |
| | | if(!CollectionUtils.isEmpty(codeBasicSecVOS)){ |
| | | codeBasicSecVOS.stream().forEach(codeBasicSecVO -> { |
| | | List<CodeSectionValueVO> codeSectionValueVOList=new ArrayList<>(); |
| | | String secType= codeBasicSecVO.getSecType(); |
| | | if(secType.equals("codevariablesec")){//可变码段 |
| | | CodeSectionValueVO sectionValueVO=new CodeSectionValueVO("","","","",""); |
| | | codeSectionValueVOList.add(sectionValueVO); |
| | | }else if(secType.equals("codefixedsec")){//固定码段 |
| | | List<CodeFixedValueVO> fixedValueVOList=codeBasicSecVO.getFixedValueVOList(); |
| | | fixedValueVOList.stream().forEach(codeFixedValueVO -> { |
| | | CodeSectionValueVO sectionValueVO=new CodeSectionValueVO(codeFixedValueVO.getOid(),codeFixedValueVO.getOrderNum()+"",codeFixedValueVO.getId(),codeFixedValueVO.getName(),codeFixedValueVO.getDescription()); |
| | | codeSectionValueVOList.add(sectionValueVO); |
| | | }); |
| | | }else if(secType.equals("codeclassifysec")){//分类码段 |
| | | String secOid=codeBasicSecVO.getOid(); |
| | | String parentClassifySecOid= codeBasicSecVO.getParentClassifySecOid(); |
| | | List<CodeClassifyValueVO> codeClassifyValueVOS= this.codeClassifyValueService.listCodeClassifyValueBySecOid(secOid,parentClassifySecOid); |
| | | if(CollectionUtils.isEmpty(codeClassifyValueVOS)){ |
| | | codeClassifyValueVOS.stream().forEach(codeClassifyValueVO -> { |
| | | CodeSectionValueVO sectionValueVO=new CodeSectionValueVO(codeClassifyValueVO.getOid(),codeClassifyValueVO.getOrderNum()+"",codeClassifyValueVO.getId(),codeClassifyValueVO.getName(),codeClassifyValueVO.getDescription()); |
| | | }); |
| | | } |
| | | }else if(secType.equals("codedatesec")){//日期码段 |
| | | |
| | | }else if(secType.equals("coderefersec")){//引用码段 |
| | | |
| | | }else if(secType.equals("codelevelsec")) {//层级码段 |
| | | int level = codeBasicSecVO.getCodeLevelValue(); |
| | | CodeClassifyVO levelCodeClassifyVO = new CodeClassifyVO(); |
| | | CodeClassifyFullInfoBO classifyFullInfoBO = this.classifyService.getClassifyFullInfo(codeClassifyDO.getOid()); |
| | | if(codeBasicSecVO.getCodeLevelType().equals("code_level_special")){//指定层级 |
| | | List<CodeClassifyVO> classifyVOS = classifyFullInfoBO.getParentClassifyVOs().stream().sorted(((o1, o2) -> o2.getDataLevel().compareTo(o1.getDataLevel()))).collect(Collectors.toList()); |
| | | if (classifyVOS.size() >= level && level > 0) { |
| | | levelCodeClassifyVO = classifyVOS.get(level - 1); |
| | | } |
| | | }else{//最小层 |
| | | levelCodeClassifyVO=codeClassifyDO; |
| | | } |
| | | CodeSectionValueVO sectionValueVO=new CodeSectionValueVO(levelCodeClassifyVO.getOid(),"0",levelCodeClassifyVO.getId(),codeBasicSecVO.getName(),codeBasicSecVO.getDescription()); |
| | | codeSectionValueVOList.add(sectionValueVO); |
| | | }else if(secType.equals("codeattrsec")){//属性码段 |
| | | |
| | | }else if(secType.equals("codeserialsec")){//流水码段 |
| | | |
| | | } |
| | | //构建规则码段 |
| | | CodeSectionVO codeSectionVO=new CodeSectionVO(); |
| | | codeSectionVO.setId(codeBasicSecVO.getOid());//主键 |
| | | codeSectionVO.setName(codeBasicSecVO.getName());//码段名称 |
| | | codeSectionVO.setCodeSecLength(codeBasicSecVO.getCodeSecLength());//码段长度 |
| | | codeSectionVO.setNum(codeBasicSecVO.getId());//码段编号 |
| | | codeSectionVO.setCodeDateFormatStr(codeBasicSecVO.getCodeDateFormatStr());//日期类型 |
| | | codeSectionVO.setCodeSecLengthType(codeBasicSecVO.getCodeSecLengthType());//码段长度类型 |
| | | codeSectionVO.setPkCodeRule(codeRuleVO.getOid()); |
| | | codeSectionVO.setSecType(codeBasicSecVO.getSecType());//码段类型 |
| | | codeSectionVO.setDescription(codeBasicSecVO.getDescription()); |
| | | codeSectionVO.setParentClassifySecOid(codeBasicSecVO.getParentClassifySecOid()); |
| | | codeSectionVO.setSectionValue(codeSectionValueVOList); |
| | | codeSectionVOList.add(codeSectionVO); |
| | | }); |
| | | } |
| | | //构建规则信息 |
| | | resultCodeRuleVO.setId(codeRuleVO.getOid()); |
| | | resultCodeRuleVO.setNum(codeRuleVO.getId()); |
| | | resultCodeRuleVO.setDescription(codeRuleVO.getDescription()); |
| | | resultCodeRuleVO.setCodeSection(codeSectionVOList); |
| | | } |
| | | //构建分类信息 |
| | | com.vci.ubcs.code.vo.webserviceModel.coderule.ResultClassifyVO classifyVO=new com.vci.ubcs.code.vo.webserviceModel.coderule.ResultClassifyVO(); |
| | | classifyVO.setId(codeClassifyDO.getOid()); |
| | | classifyVO.setLcStatus(codeClassifyDO.getLcStatus()); |
| | | classifyVO.setClassCode(codeClassifyDO.getId()); |
| | |
| | | classifyVO.setName(codeClassifyDO.getName()); |
| | | classifyVO.setPid(codeClassifyDO.getParentcodeclassifyoid()); |
| | | classifyVO.setFullPathName(codeClassifyDO.getPath()); |
| | | classifyVO.setCodeRule(resultCodeRuleVO); |
| | | classifyVOList.add(classifyVO); |
| | | }); |
| | | libraryVo.setClassify(classifyVOList); |
| | | resultLibraryVO.setClassify(classifyVOList); |
| | | }else{ |
| | | errorid = "100"; |
| | | msg="未查询到相关的分类信息"; |
| | | } |
| | | issucess=true; |
| | | resultData.setLibrary(libraryVo); |
| | | resultClassifyRuleData.setLibrary(resultLibraryVO); |
| | | }catch (Throwable e){ |
| | | e.printStackTrace();; |
| | | msg="查询分类失败:"+e.getMessage(); |
| | | }finally { |
| | | resultData.setErrorid(errorid); |
| | | resultData.setMsg(msg); |
| | | resultClassifyVO.setResultData(resultData); |
| | | resultClassifyRuleData.setErrorid(errorid); |
| | | resultClassifyRuleData.setMsg(msg); |
| | | resultClassifyRuleVO.setData(resultClassifyRuleData); |
| | | } |
| | | if(dataType.equals("xml")){ |
| | | //组织返回接口信息 |
| | | XStream xStream = new XStream(new DomDriver()); |
| | | xStream.processAnnotations(XMLResultSystemVO.class); |
| | | xStream.autodetectAnnotations(true); |
| | | resultStr = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" + xStream.toXML(resultData); |
| | | resultStr = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" + xStream.toXML(resultClassifyRuleData); |
| | | |
| | | }else{ |
| | | Object object = JSONObject.toJSON(resultClassifyVO); |
| | | Object object = JSONObject.toJSON(resultClassifyRuleVO); |
| | | resultStr = object.toString(); |
| | | } |
| | | try { |