¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.vci.ubcs.code.service.impl; |
| | | |
| | | import com.alibaba.cloud.commons.lang.StringUtils; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.thoughtworks.xstream.XStream; |
| | | import com.thoughtworks.xstream.io.xml.DomDriver; |
| | | import com.vci.ubcs.code.bo.CodeClassifyFullInfoBO; |
| | | import com.vci.ubcs.code.dto.CodeOrderDTO; |
| | | import com.vci.ubcs.code.dto.CodeOrderSecDTO; |
| | | import com.vci.ubcs.code.entity.*; |
| | | import com.vci.ubcs.code.enumpack.CodeSecTypeEnum; |
| | | import com.vci.ubcs.code.service.*; |
| | | import com.vci.ubcs.code.util.gennerAttrMapUtil; |
| | | import com.vci.ubcs.code.vo.pagemodel.*; |
| | | import com.vci.ubcs.code.vo.webserviceModel.apply.*; |
| | | import com.vci.ubcs.code.vo.webserviceModel.attrmap.*; |
| | | import com.vci.ubcs.code.vo.webserviceModel.classify.*; |
| | | import com.vci.ubcs.code.vo.webserviceModel.result.json.*; |
| | | import com.vci.ubcs.code.vo.webserviceModel.result.xml.XMLResultClassfyVO; |
| | | import com.vci.ubcs.code.vo.webserviceModel.result.xml.XMLResultDataObjectDetailDO; |
| | | import com.vci.ubcs.code.vo.webserviceModel.result.xml.XMLResultSystemVO; |
| | | import com.vci.ubcs.starter.revision.model.TreeQueryObject; |
| | | import com.vci.ubcs.starter.web.pagemodel.SessionInfo; |
| | | import com.vci.ubcs.starter.web.util.BeanUtilForVCI; |
| | | import com.vci.ubcs.starter.web.util.VciBaseUtil; |
| | | import com.vci.ubcs.webservice.annotation.VciWebservice; |
| | | import com.vci.ubcs.webservice.config.AttributeMapConfig; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.vci.ubcs.code.constant.MdmEngineConstant.DEFAULT_SYNC_ATTR_LIST; |
| | | |
| | | /*** |
| | | * ç»ä¸æ¥å£ |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | | @VciWebservice(path = "/universalInterface") |
| | | public class UniversalInterfaceImpl<IDockingLogeServiceing> implements UniversalInterfaceI { |
| | | |
| | | @Autowired(required = false) |
| | | private AttributeMapConfig attributeMapConfig; |
| | | /** |
| | | * ç¼åæå¡ |
| | | */ |
| | | //@Autowired |
| | | //private RedisService redisService; |
| | | /** |
| | | * 主é¢åºåç±»çæå¡ |
| | | */ |
| | | @Autowired(required = false) |
| | | private ICodeClassifyService classifyService; |
| | | /** |
| | | * ä¸»æ°æ®å¼æçæå¡ |
| | | */ |
| | | @Resource |
| | | private MdmEngineService engineService; |
| | | |
| | | /** |
| | | * å¯çº§çæå¡ |
| | | */ |
| | | |
| | | @Resource |
| | | private MdmIOService mdmIOService; |
| | | /*** |
| | | * éææ¥å£æ¥å¿æå¡çé
ç½® |
| | | */ |
| | | @Resource |
| | | private IDockingLogeService dockingLogeService; |
| | | |
| | | private static String separator="##VCI##"; |
| | | private String errorid="0"; |
| | | private String msg="æå"; |
| | | private String objerrorCode="0"; |
| | | private String objerrorMsg="æå"; |
| | | /*** |
| | | * ç³è¯·ç¼ç æ¥å£ |
| | | * @param data ä¼ éçæ°æ®åæ° |
| | | * @param dataType æ è¯dataæ¯xmlæ ¼å¼è¿æ¯jsonæ ¼å¼ï¼æ¥å£è¿åæ°æ®ä¹æ¯æç
§è¿ä¸ªæ ¼å¼ï¼ä»¥ä¸æ¥å£ç±»å |
| | | * @return |
| | | * @throws Throwable |
| | | */ |
| | | @Override |
| | | public String applyCode(String data, String dataType) throws Throwable { |
| | | { |
| | | String resultStr = ""; |
| | | String errorid="0"; |
| | | msg="æå"; |
| | | objerrorCode="0"; |
| | | objerrorMsg="æå"; |
| | | log.info("ç³è¯·ç¼ç çæ°æ®åæ°:->"+data); |
| | | log.info("ç³è¯·ç¼ç çæ°æ®ç±»å:->"+dataType); |
| | | String systemId=""; |
| | | List<XMLResultClassfyVO> resultClassfyVOList = new ArrayList<>(); |
| | | try { |
| | | if(StringUtils.isBlank(data)) { |
| | | errorid="101"; |
| | | throw new Throwable("æ¥å£åæ°ï¼ä¼ é为空"); |
| | | } |
| | | InterParameterVO interParameterVO =new InterParameterVO(); |
| | | //妿dataTypeæ¯xmlåï¼éè¿xmlåºååæå¯¹è±¡å½¢å¼ï¼å¦ææ¯jsonåéè¿jsonè½¬æ¢æå¯¹è±¡æ ¼å¼ |
| | | try { |
| | | if ("xml".equals(dataType)) { |
| | | XStream xStream = new XStream(new DomDriver()); |
| | | xStream.processAnnotations(RootDataVO.class); |
| | | xStream.autodetectAnnotations(true); |
| | | RootDataVO rootDataVO = (RootDataVO) xStream.fromXML(data); |
| | | interParameterVO.setData(rootDataVO); |
| | | } else { |
| | | interParameterVO = JSONObject.toJavaObject(JSONObject.parseObject(data), InterParameterVO.class); |
| | | } |
| | | }catch (Throwable e){ |
| | | errorid="101"; |
| | | throw new Throwable("æ¥å£åæ°ï¼ä¼ å
¥æ°æ®åæ°è§£æå¤±è´¥"); |
| | | } |
| | | ClassfysVO classfysVO = interParameterVO.getData().getClassifys(); |
| | | systemId = interParameterVO.getData().getSystemId(); |
| | | UserVO userVo = interParameterVO.getData().getUser(); |
| | | List<ClassfyVO> classVOList = classfysVO.getClassify(); |
| | | InterParameterVO finalInterParameterVO = interParameterVO; |
| | | |
| | | //è¿æ¯è´¦å·ä¿¡æ¯ |
| | | SessionInfo sessionInfo = new SessionInfo(); |
| | | sessionInfo.setUserId(userVo.getUserName()); |
| | | sessionInfo.setUserName(userVo.getTrueName()); |
| | | sessionInfo.setIp(userVo.getIp()); |
| | | VciBaseUtil.setCurrentUserSessionInfo(sessionInfo); |
| | | |
| | | String finalSystemId = systemId; |
| | | classVOList.stream().forEach(classVO -> { |
| | | log.info("åæ°ï¼åç±»COde:" + classVO.getClassCode()); |
| | | LinkedList<XMLResultDataObjectDetailDO> resultDataObjectDetailDOs = new LinkedList<>(); |
| | | //è·ååç±»ä¿¡æ¯ |
| | | try { |
| | | String libray = classVO.getLibrary(); |
| | | CodeClassifyVO codeClassifyVO = getClassfy(classVO); |
| | | log.info("endï¼åç±»æ¥è¯¢å®æ¯"); |
| | | //è·åå类模æ¿ä¿¡æ¯ |
| | | if(codeClassifyVO==null || StringUtils.isBlank(codeClassifyVO.getOid())){ |
| | | objerrorCode="100"; |
| | | throw new Throwable ("æ ¹æ®ä¼ è¾çåç±»ï¼æªè·åå°å类信æ¯"); |
| | | } |
| | | CodeClassifyTemplateVO templateVO = engineService.getUsedTemplateByClassifyOid(codeClassifyVO.getOid()); |
| | | if(templateVO==null||StringUtils.isBlank(templateVO.getOid())){ |
| | | objerrorCode="1"; |
| | | throw new Throwable ("æ ¹æ®ä¼ è¾çåç±»ï¼æªè·åMDMç³»ç»ä¸å¯¹åºæ¨¡æ¿"); |
| | | } |
| | | log.info("endï¼æ¨¡æ¿æ¥è¯¢å®æ¯"); |
| | | ApplyDatasVO applyDatasVO = classVO.getObjects(); |
| | | DataObjectVO dataObjectVO = new DataObjectVO(); |
| | | List<CodeClassifyTemplateAttrVO> attrVOS = templateVO.getAttributes().stream().filter(s -> !DEFAULT_SYNC_ATTR_LIST.contains(s.getId()) && VciBaseUtil.getBoolean(s.getFormDisplayFlag()) |
| | | ).collect(Collectors.toList()); |
| | | this.getConfigDatas(finalSystemId, libray, applyDatasVO, attrVOS, dataObjectVO); |
| | | log.info("endï¼æ°æ®ç»ç»å®æ¯"); |
| | | //è§åç主é®éè¦å»è·å |
| | | CodeClassifyFullInfoBO classifyFullInfo = classifyService.getClassifyFullInfo(codeClassifyVO.getOid()); |
| | | if(classifyFullInfo==null ||classifyFullInfo.getCurrentClassifyVO()==null || StringUtils.isBlank(classifyFullInfo.getCurrentClassifyVO().getOid())){ |
| | | objerrorCode="1"; |
| | | log.info("classifyFullInfo:"+"æ ¹æ®ä¼ è¾çåç±»ï¼æªè·ååç±»ç¸å
³ä¿¡æ¯"); |
| | | throw new Throwable ("æ ¹æ®ä¼ è¾çåç±»ï¼æªè·ååç±»ç¸å
³ä¿¡æ¯"); |
| | | } |
| | | CodeRuleVO ruleVO = engineService.getCodeRuleByClassifyFullInfo(classifyFullInfo); |
| | | if(ruleVO==null|| StringUtils.isBlank(ruleVO.getOid())){ |
| | | objerrorCode="102"; |
| | | throw new Throwable ("æ ¹æ®ä¼ è¾çåç±»ï¼æªè·åMDMç³»ç»ä¸å¯¹åºè§å"); |
| | | } |
| | | log.info("endï¼è§åè·å宿¯"); |
| | | List<CodeOrderSecDTO> codeOrderSecDTOList = getRuleCodeOrderSecDTOs(classVO.getSections().getSection(), ruleVO); |
| | | log.info("endï¼ç 段è·å宿¯"); |
| | | CodeOrderDTO orderDTO = new CodeOrderDTO(); |
| | | orderDTO.setCodeClassifyOid(codeClassifyVO.getOid());//åç±»ä¸»é® |
| | | orderDTO.setSecDTOList(codeOrderSecDTOList);//åç±»ç æ®µ |
| | | mdmIOService.batchSyncApplyCode(orderDTO, dataObjectVO, resultDataObjectDetailDOs); |
| | | log.info("endï¼ç³è¯·è·å宿¯"); |
| | | } catch (Throwable e) { |
| | | XMLResultDataObjectDetailDO xmlResultDataObjectDetailDO=new XMLResultDataObjectDetailDO(); |
| | | xmlResultDataObjectDetailDO.setCode(""); |
| | | xmlResultDataObjectDetailDO.setId(""); |
| | | xmlResultDataObjectDetailDO.setErrorid(objerrorCode); |
| | | xmlResultDataObjectDetailDO.setMsg("ç¼ç ç³è¯·å¤±è´¥:"+e.getMessage()); |
| | | resultDataObjectDetailDOs.add(xmlResultDataObjectDetailDO); |
| | | e.printStackTrace(); |
| | | }finally { |
| | | XMLResultClassfyVO resultClassfyVO = new XMLResultClassfyVO(); |
| | | resultClassfyVO.setClassCode(classVO.getClassCode()); |
| | | resultClassfyVO.setLibrary(classVO.getLibrary()); |
| | | resultClassfyVO.setFullclsfNamePath(classVO.getFullclsfNamePath()); |
| | | resultClassfyVO.setObjects(resultDataObjectDetailDOs); |
| | | resultClassfyVOList.add(resultClassfyVO); |
| | | } |
| | | }); |
| | | XMLResultSystemVO xmlResultSystemVO=new XMLResultSystemVO(); |
| | | xmlResultSystemVO.setClassifys(resultClassfyVOList); |
| | | xmlResultSystemVO.setMsg(msg); |
| | | xmlResultSystemVO.setErrorid(errorid); |
| | | resultStr= transferResultXMl(xmlResultSystemVO,dataType); |
| | | }catch (Throwable e){ |
| | | e.printStackTrace();; |
| | | msg="ç³è¯·ç¼ç 失败:"+e.getMessage(); |
| | | }finally { |
| | | XMLResultSystemVO xmlResultSystemVO=new XMLResultSystemVO(); |
| | | xmlResultSystemVO.setClassifys(resultClassfyVOList); |
| | | xmlResultSystemVO.setMsg(msg); |
| | | xmlResultSystemVO.setErrorid(errorid); |
| | | resultStr= transferResultXMl(xmlResultSystemVO,dataType); |
| | | final boolean[] issucess = {true}; |
| | | if(!errorid.equals("0")) { |
| | | issucess[0] = false; |
| | | }else { |
| | | if(!CollectionUtils.isEmpty(resultClassfyVOList)) { |
| | | resultClassfyVOList.stream().forEach(xMLResultClassfyVO -> { |
| | | xMLResultClassfyVO.getObjects().stream().forEach(objec -> { |
| | | if (!(objec.getErrorid().equals("0") || objec.getErrorid().equals("204"))) { |
| | | issucess[0] = false; |
| | | msg=objec.getMsg(); |
| | | } |
| | | }); |
| | | }); |
| | | } |
| | | |
| | | } |
| | | try { |
| | | //è®°å½æ¥å¿ |
| | | this.saveLogs(systemId, systemId, data, resultStr, issucess[0], msg, "applyCode"); |
| | | }catch (Throwable e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | log.info("è¿ååæ°:"+resultStr); |
| | | |
| | | return resultStr; |
| | | } |
| | | } |
| | | |
| | | /*** |
| | | * ç»ä¸æ´æ°æ¥å£ï¼æ´æ¹ç¶æï¼æ´æ¹å±æ§ä¿¡æ¯ï¼æ¥å£ |
| | | * @param data |
| | | * @param dataType |
| | | * @return |
| | | * @throws Throwable |
| | | */ |
| | | @Override |
| | | public String syncEditData(String data, String dataType) throws Throwable { |
| | | |
| | | return null; |
| | | } |
| | | |
| | | /*** |
| | | * åç±»æ¥è¯¢ |
| | | * @param data |
| | | * @param dataType |
| | | * @return |
| | | * @throws Throwable |
| | | */ |
| | | @Override |
| | | public String queryClassify(String data, String dataType) throws Throwable { |
| | | boolean issucess=false; |
| | | String resultStr = ""; |
| | | String errorid="0"; |
| | | msg="æå"; |
| | | String systemId=""; |
| | | log.info("æ¥è¯¢åç±»çæ°æ®åæ°:->"+data); |
| | | log.info("æ¥è¯¢åç±»çæ°æ®ç±»å:->"+dataType); |
| | | ResultClassifyVO resultClassifyVO =new ResultClassifyVO(); |
| | | List<ClassifyVO> classifyVOList=new ArrayList<>(); |
| | | ResultData resultData=new ResultData(); |
| | | try { |
| | | if (StringUtils.isBlank(data)) { |
| | | errorid = "101"; |
| | | throw new Throwable("æ¥å£åæ°ï¼ä¼ é为空"); |
| | | } |
| | | QueryClassifyVO queryClassifyVO = new QueryClassifyVO(); |
| | | //妿dataTypeæ¯xmlåï¼éè¿xmlåºååæå¯¹è±¡å½¢å¼ï¼å¦ææ¯jsonåéè¿jsonè½¬æ¢æå¯¹è±¡æ ¼å¼ |
| | | try { |
| | | if ("xml".equals(dataType)) { |
| | | XStream xStream = new XStream(new DomDriver()); |
| | | xStream.processAnnotations(QueryData.class); |
| | | xStream.autodetectAnnotations(true); |
| | | QueryData queryData = (QueryData) xStream.fromXML(data); |
| | | queryClassifyVO.setData(queryData); |
| | | } else { |
| | | queryClassifyVO = JSONObject.toJavaObject(JSONObject.parseObject(data), QueryClassifyVO.class); |
| | | } |
| | | } catch (Throwable e) { |
| | | errorid = "101"; |
| | | msg="æ¥å£åæ°ï¼ä¼ å
¥æ°æ®åæ°è§£æå¤±è´¥"; |
| | | e.printStackTrace(); |
| | | throw new Throwable("æ¥å£åæ°ï¼ä¼ å
¥æ°æ®åæ°è§£æå¤±è´¥"); |
| | | } |
| | | QueryData queryData=queryClassifyVO.getData(); |
| | | UserVO userVo=queryData.getUser(); |
| | | systemId=queryData.getSystemId(); |
| | | QueryLibraryVO libraryVO= queryData.getLibrary(); |
| | | String libId= libraryVO.getId(); |
| | | List<String> classifyIdList= libraryVO.getClassifyid(); |
| | | List<CodeClassifyVO> codeClassifyVOS =new ArrayList<>(); |
| | | //è¿æ¯è´¦å·ä¿¡æ¯ |
| | | //è¿æ¯è´¦å·ä¿¡æ¯ |
| | | if(userVo!=null) { |
| | | SessionInfo sessionInfo = new SessionInfo(); |
| | | sessionInfo.setUserId(userVo.getUserName()); |
| | | sessionInfo.setUserName(userVo.getTrueName()); |
| | | sessionInfo.setIp(userVo.getIp()); |
| | | VciBaseUtil.setCurrentUserSessionInfo(sessionInfo); |
| | | }else{ |
| | | 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); |
| | | } |
| | | LibraryVO libraryVo=new LibraryVO(); |
| | | libraryVo.setId(libId); |
| | | libraryVo.setName(""); |
| | | if(!CollectionUtils.isEmpty(codeClassifyVOS)){ |
| | | errorid = "0"; |
| | | msg="æå!"; |
| | | codeClassifyVOS.stream().forEach(codeClassifyDO -> { |
| | | ClassifyVO classifyVO=new ClassifyVO(); |
| | | classifyVO.setId(codeClassifyDO.getOid()); |
| | | classifyVO.setLcStatus(codeClassifyDO.getLcStatus()); |
| | | classifyVO.setClassCode(codeClassifyDO.getId()); |
| | | classifyVO.setDescription(codeClassifyDO.getDescription()); |
| | | classifyVO.setName(codeClassifyDO.getName()); |
| | | classifyVO.setPid(codeClassifyDO.getParentcodeclassifyoid()); |
| | | classifyVO.setFullPathName(codeClassifyDO.getPath()); |
| | | classifyVOList.add(classifyVO); |
| | | }); |
| | | libraryVo.setClassify(classifyVOList); |
| | | }else{ |
| | | errorid = "100"; |
| | | msg="æªæ¥è¯¢å°ç¸å
³çå类信æ¯"; |
| | | } |
| | | issucess=true; |
| | | resultData.setLibrary(libraryVo); |
| | | }catch (Throwable e){ |
| | | e.printStackTrace();; |
| | | msg="æ¥è¯¢å类失败:"+e.getMessage(); |
| | | }finally { |
| | | resultData.setErrorid(errorid); |
| | | resultData.setMsg(msg); |
| | | resultClassifyVO.setResultData(resultData); |
| | | } |
| | | 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); |
| | | |
| | | }else{ |
| | | Object object = JSONObject.toJSON(resultClassifyVO); |
| | | resultStr = object.toString(); |
| | | } |
| | | try { |
| | | //è®°å½æ¥å¿ |
| | | this.saveLogs(systemId, systemId, data, resultStr, issucess, msg, "queryClassify"); |
| | | }catch (Throwable e){ |
| | | e.printStackTrace(); |
| | | } |
| | | log.info("è¿ååæ°:"+resultStr); |
| | | return resultStr; |
| | | } |
| | | |
| | | /*** |
| | | * æ°æ®æ¥è¯¢ |
| | | * @param data |
| | | * @param dataType |
| | | * @return |
| | | * @throws Throwable |
| | | */ |
| | | @Override |
| | | public String queryData(String data, String dataType) throws Throwable { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public String queryClassifyRule(String data, String dataType) throws Throwable { |
| | | |
| | | boolean issucess=false; |
| | | String resultStr = ""; |
| | | String errorid="0"; |
| | | msg="æå"; |
| | | String systemId=""; |
| | | log.info("æ¥è¯¢åç±»çæ°æ®åæ°:->"+data); |
| | | log.info("æ¥è¯¢åç±»çæ°æ®ç±»å:->"+dataType); |
| | | ResultClassifyVO resultClassifyVO =new ResultClassifyVO(); |
| | | List<ClassifyVO> classifyVOList=new ArrayList<>(); |
| | | try { |
| | | if (StringUtils.isBlank(data)) { |
| | | errorid = "101"; |
| | | throw new Throwable("æ¥å£åæ°ï¼ä¼ é为空"); |
| | | } |
| | | QueryClassifyVO queryClassifyVO = new QueryClassifyVO(); |
| | | //妿dataTypeæ¯xmlåï¼éè¿xmlåºååæå¯¹è±¡å½¢å¼ï¼å¦ææ¯jsonåéè¿jsonè½¬æ¢æå¯¹è±¡æ ¼å¼ |
| | | try { |
| | | if ("xml".equals(dataType)) { |
| | | XStream xStream = new XStream(new DomDriver()); |
| | | xStream.processAnnotations(QueryData.class); |
| | | xStream.autodetectAnnotations(true); |
| | | QueryData queryData = (QueryData) xStream.fromXML(data); |
| | | queryClassifyVO.setData(queryData); |
| | | } else { |
| | | queryClassifyVO = JSONObject.toJavaObject(JSONObject.parseObject(data), QueryClassifyVO.class); |
| | | } |
| | | } catch (Throwable e) { |
| | | errorid = "101"; |
| | | msg = "æ¥å£åæ°ï¼ä¼ å
¥æ°æ®åæ°è§£æå¤±è´¥"; |
| | | e.printStackTrace(); |
| | | throw new Throwable("æ¥å£åæ°ï¼ä¼ å
¥æ°æ®åæ°è§£æå¤±è´¥"); |
| | | } |
| | | QueryData queryData=queryClassifyVO.getData(); |
| | | UserVO userVo=queryData.getUser(); |
| | | systemId=queryData.getSystemId(); |
| | | QueryLibraryVO libraryVO= queryData.getLibrary(); |
| | | String libId= libraryVO.getId(); |
| | | List<String> classifyIdList= libraryVO.getClassifyid(); |
| | | List<CodeClassifyVO> codeClassifyVOS =new ArrayList<>(); |
| | | //è¿æ¯è´¦å·ä¿¡æ¯ |
| | | //è¿æ¯è´¦å·ä¿¡æ¯ |
| | | if(userVo!=null) { |
| | | SessionInfo sessionInfo = new SessionInfo(); |
| | | sessionInfo.setUserId(userVo.getUserName()); |
| | | sessionInfo.setUserName(userVo.getTrueName()); |
| | | sessionInfo.setIp(userVo.getIp()); |
| | | VciBaseUtil.setCurrentUserSessionInfo(sessionInfo); |
| | | }else{ |
| | | 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); |
| | | } |
| | | |
| | | }catch (Throwable e){ |
| | | e.printStackTrace();; |
| | | msg="æ¥è¯¢å类失败:"+e.getMessage(); |
| | | }finally { |
| | | // resultData.setErrorid(errorid); |
| | | // resultData.setMsg(msg); |
| | | // resultClassifyVO.setResultData(resultData); |
| | | } |
| | | 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); |
| | | |
| | | }else{ |
| | | Object object = JSONObject.toJSON(resultClassifyVO); |
| | | resultStr = object.toString(); |
| | | } |
| | | try { |
| | | //è®°å½æ¥å¿ |
| | | this.saveLogs(systemId, systemId, data, resultStr, issucess, msg, "queryClassify"); |
| | | }catch (Throwable e){ |
| | | e.printStackTrace(); |
| | | } |
| | | log.info("è¿ååæ°:"+resultStr); |
| | | return resultStr; |
| | | } |
| | | |
| | | /*** |
| | | * æ¥è¯¢æ ¡éªåç±»ä¿¡æ¯ |
| | | * @param classfyVO |
| | | */ |
| | | private CodeClassifyVO getClassfy(ClassfyVO classfyVO) throws Throwable{ |
| | | CodeClassifyVO classifyVO = new CodeClassifyVO(); |
| | | try { |
| | | String classCode = classfyVO.getClassCode(); |
| | | String className = classfyVO.getFullclsfNamePath(); |
| | | //æ ¹æ®åç±»ä»£å·æ¥è¯¢åç±»ä¿¡æ¯ |
| | | if (StringUtils.isNotBlank(classfyVO.getClassCode())) { |
| | | Map<String, String> conditionMap = new HashMap<>(); |
| | | List<CodeClassify> codeClassifyList = classifyService.selectByWrapper(Wrappers.<CodeClassify>query().lambda().eq(CodeClassify::getId, classCode)); |
| | | if (!CollectionUtils.isEmpty(codeClassifyList)) { |
| | | CodeClassify classifyDO = codeClassifyList.get(0); |
| | | //å°DTO转æ¢ä¸ºDO |
| | | classifyVO = new CodeClassifyVO(); |
| | | BeanUtilForVCI.copyPropertiesIgnoreCase(classifyDO, classifyVO); |
| | | if(StringUtils.isBlank(classifyVO.getOid())){ |
| | | throw new Throwable("æ ¹æ®åç±»ä»£å·æªæ¥è¯¢å°ç¸åºçå类信æ¯"); |
| | | } |
| | | }else{ |
| | | throw new Throwable("æ ¹æ®åç±»ä»£å·æªæ¥è¯¢å°ç¸åºçå类信æ¯"); |
| | | } |
| | | } else { |
| | | classifyVO = classifyService.getObjectByClsfNamePath(className.replace(separator, "/")); |
| | | if(StringUtils.isBlank(classifyVO.getOid())){ |
| | | throw new Throwable("æ ¹æ®åç±»åç§°è·¯å¾æªæ¥è¯¢å°ç¸åºçå类信æ¯"); |
| | | } |
| | | } |
| | | }catch (Throwable e){ |
| | | objerrorCode="100"; |
| | | new Throwable("è·åå类信æ¯å¤±è´¥:"+e.getMessage()); |
| | | } |
| | | return classifyVO; |
| | | } |
| | | /*** |
| | | * æ ¹æ®ç©¿å
¥çåæ°ä¿¡æ¯æ ¡éªç 段è§å |
| | | */ |
| | | private List<CodeOrderSecDTO> getRuleCodeOrderSecDTOs(List<SectionVO> SectionVOList,CodeRuleVO ruleVO) throws Throwable{ |
| | | List<CodeBasicSecVO> codeBasicSecVOS= ruleVO.getSecVOList(); |
| | | Map<String,String> sectionVOMap=new HashMap<>(); |
| | | SectionVOList.stream().forEach(SectionVO->{ |
| | | sectionVOMap.put(SectionVO.getName(),SectionVO.getValue()); |
| | | }); |
| | | List<CodeOrderSecDTO> codeOrderSecDTOList=new ArrayList<>(); |
| | | for(CodeBasicSecVO codeBasicSecVO: codeBasicSecVOS) { |
| | | String sectype = codeBasicSecVO.getSecType(); |
| | | if (!sectype.equals(CodeSecTypeEnum.CODE_SERIAL_SEC.getValue())) { |
| | | String name = codeBasicSecVO.getName(); |
| | | String sectypeText = codeBasicSecVO.getSecTypeText(); |
| | | log.info("ç æ®µåç§°:"+name); |
| | | log.info("æè¿°:"+sectypeText); |
| | | CodeOrderSecDTO CodeOrderSecDTO = new CodeOrderSecDTO(); |
| | | if (sectionVOMap.containsKey(name)) { |
| | | CodeOrderSecDTO.setSecOid(codeBasicSecVO.getOid()); |
| | | String sectypeValue = sectionVOMap.get(name); |
| | | log.info("ç æ®µå¼:"+sectypeValue); |
| | | CodeOrderSecDTO.setSecValue(sectypeValue); |
| | | codeOrderSecDTOList.add(CodeOrderSecDTO); |
| | | } else { |
| | | objerrorCode="101"; |
| | | throw new Throwable("ä¼ å
¥çç æ®µè§å缺å°" + name + "ç æ®µ"); |
| | | } |
| | | } |
| | | } |
| | | return codeOrderSecDTOList; |
| | | } |
| | | /*** |
| | | * æ ¹æ®å±æ§æ å°è½¬æ¢ç¼ç æéåæ®µ |
| | | */ |
| | | public void getConfigDatas(String systemId,String libray, ApplyDatasVO applyDatasVO,List<CodeClassifyTemplateAttrVO> codeClassifyTemplateAttrVOList,DataObjectVO dataObjectVO) throws Throwable { |
| | | List<ApplyDataVO> applyDataVOList=applyDatasVO.getObject(); |
| | | LinkedHashMap<String,LinkedHashMap<String,String>> dataKeyValueMap=new LinkedHashMap<>(); |
| | | //妿尿°æ®è½¬æ¢ææéè¦çæ°æ®å¯¹è±¡ |
| | | Map<String, String> attrMapConfigMap=new HashMap<>(); |
| | | Map<String, String> propMaps=new HashMap<>(); |
| | | try { |
| | | Map<String, String> stringStringMap=attributeMapConfig.getSystem_attrmap(); |
| | | //stringStringMap.put("RLM","D:\\RLM.xml"); |
| | | LibraryDO libraryDO= gennerAttrMapUtil.getNewInstance().gennerAttrMapBySystem(systemId,stringStringMap); |
| | | List<LibraryClsfDO> libraryClsfDOList=libraryDO.getClsf(); |
| | | Map<String, List<ClsfAttrMappingDO>> libPropMaps = libraryClsfDOList.stream().collect(Collectors.toMap(LibraryClsfDO::getLibrary, LibraryClsfDO::getProp, (key1, key2) -> key2)); |
| | | if(libPropMaps.containsKey(libray)){ |
| | | List<ClsfAttrMappingDO> clsfAttrMappingDOList=libPropMaps.get(libray); |
| | | propMaps = clsfAttrMappingDOList.stream().collect(Collectors.toMap(ClsfAttrMappingDO::getSourceKey, ClsfAttrMappingDO::getTargetKey, (key1, key2) -> key2)); |
| | | } |
| | | }catch (Throwable e){ |
| | | objerrorCode="1"; |
| | | throw new Throwable("MDMéæå±æ§é
ç½®æä»¶è¯»å失败"); |
| | | } |
| | | LinkedList<String> rowNameList=new LinkedList<>(); |
| | | LinkedHashMap<String,Integer> filedIndexMap=new LinkedHashMap<>(); |
| | | //æ ¹æ®å类模æ¿ç»ç»æ°æ® |
| | | final int[] index = {0}; |
| | | try { |
| | | codeClassifyTemplateAttrVOList.stream().forEach(codeClassifyTemplateAttrVO -> { |
| | | String attrName = codeClassifyTemplateAttrVO.getName(); |
| | | String field = codeClassifyTemplateAttrVO.getId(); |
| | | rowNameList.add(attrName); |
| | | filedIndexMap.put(field, index[0]++); |
| | | }); |
| | | dataObjectVO.setColName(rowNameList);//æ¾å
¥å±æ§ |
| | | attrMapConfigMap.putAll(propMaps); |
| | | LinkedList<RowDatas> rowDataList = new LinkedList<>(); |
| | | //Map<String, List<ProppertyVO>> dataPropMap = applyDataVOList.stream().collect(Collectors.toMap(ApplyDataVO::getId, ApplyDataVO::getProp, (key1, key2) -> key2)); |
| | | final int[] rowIndex = {0}; |
| | | applyDataVOList.stream().forEach(applyDataVO -> { |
| | | rowIndex[0]++; |
| | | RowDatas rowDatas = new RowDatas(); |
| | | rowDatas.setOid(applyDataVO.getId()); |
| | | rowDatas.setCreator(applyDataVO.getCreator()); |
| | | rowDatas.setEditor(applyDataVO.getEditor()); |
| | | rowDatas.setCode(applyDataVO.getCode()); |
| | | rowDatas.setOperation(applyDataVO.getOperate()); |
| | | rowDatas.setStatus(applyDataVO.getStatus()); |
| | | rowDatas.setRowIndex(rowIndex[0] + ""); |
| | | List<ProppertyVO> proppertyVOList = applyDataVO.getProp(); |
| | | |
| | | LinkedHashMap<Integer, String> integerValueMap = new LinkedHashMap<>(); |
| | | Map<String, String> filedValueMap = new HashMap<>(); |
| | | if (!CollectionUtils.isEmpty(proppertyVOList)) { |
| | | Map<String, String> sourceKeyValueMap = proppertyVOList.stream().collect(Collectors.toMap(ProppertyVO::getKey, ProppertyVO::getValue, (key1, key2) -> key2)); |
| | | Map<String, String> keyValueMap = new HashMap<>(); |
| | | //夿attrMapConfigMapæ¯å¦æå¼ï¼å¦ææ²¡æå说æåºç¡é»è®¤çæ¯ç¼ç ç³»ç»å段 |
| | | if (!CollectionUtils.isEmpty(attrMapConfigMap)) { |
| | | sourceKeyValueMap.keySet().forEach(sourceKey -> { |
| | | String dataValue = sourceKeyValueMap.get(sourceKey); |
| | | if (attrMapConfigMap.containsKey(sourceKey)) { |
| | | String targetKey = attrMapConfigMap.get(sourceKey); |
| | | keyValueMap.put(targetKey, StringUtils.isBlank(dataValue)?"":dataValue); |
| | | } |
| | | }); |
| | | } else { |
| | | sourceKeyValueMap.forEach((filed,value)->{ |
| | | keyValueMap.put(filed,StringUtils.isBlank(value)?"":value) ; |
| | | }); |
| | | } |
| | | |
| | | filedIndexMap.forEach((attrKey, column) -> { |
| | | String keyValue = ""; |
| | | if (keyValueMap.containsKey(attrKey)) { |
| | | keyValue =StringUtils.isBlank(keyValueMap.get(attrKey))?"":keyValueMap.get(attrKey); |
| | | } |
| | | integerValueMap.put(column, keyValue); |
| | | filedValueMap.put(attrKey, keyValue); |
| | | }); |
| | | } |
| | | rowDatas.setData(integerValueMap); |
| | | rowDatas.setFiledValue(filedValueMap); |
| | | rowDataList.add(rowDatas); |
| | | }); |
| | | dataObjectVO.setRowData(rowDataList); |
| | | }catch (Throwable e){ |
| | | objerrorCode="1"; |
| | | throw new Throwable("ç»ç»æ°æ®æ å°å¼å¤±è´¥"); |
| | | } |
| | | } |
| | | /*** |
| | | * è®°å½æ¥å¿ä¿¡æ¯ |
| | | * @param systemId |
| | | * @param parmaData |
| | | * @param result |
| | | * @return |
| | | */ |
| | | private void saveLogs(String systemId,String systemName,String parmaData, String result,boolean isSucess,String msg,String operation){ |
| | | //è®°å½æ¥å¿ä¿¡æ¯ |
| | | DockingLog dockingLoge=new DockingLog(); |
| | | //String oid=redisService.getUUIDEveryDay(); |
| | | dockingLoge.setSystemCode(StringUtils.isBlank(systemId)?"-":systemId);//è®¾ç½®ç³»ç»æ è¯ |
| | | dockingLoge.setSystemName(StringUtils.isBlank(systemName)?"-":systemName); |
| | | dockingLoge.setMsg(msg);//æ¥å¿æ¶æ¯ |
| | | dockingLoge.setClassifyId("-");//åç±»ç¼å· |
| | | dockingLoge.setClassifyName("-");//åç±»åç§° |
| | | dockingLoge.setClassifyOid("-");//åç±»ä¸»é® |
| | | dockingLoge.setUniqueCode("-");//å¯ä¸æ è¯ |
| | | dockingLoge.setSystemOid("-");//ç³»ç»æ è¯ |
| | | // dockingLogeDO.setName(operation); |
| | | //dockingLogeDO.setOid(oid);//æ¥å¿ä¸»é® |
| | | dockingLoge.setParamString(parmaData);//åæ°ä¿¡æ¯ |
| | | dockingLoge.setReturnString(result);//è¿åä¿¡æ¯ |
| | | dockingLoge.setType(operation);//æ¥å¿æä½ç±»å |
| | | if(isSucess) { |
| | | dockingLoge.setInterfaceStatus("true");//æ¥å£éæç¶æ |
| | | }else{ |
| | | dockingLoge.setInterfaceStatus("false");//æ¥å£éæç¶æ |
| | | } |
| | | dockingLogeService.save(dockingLoge); |
| | | log.info("éææ¨éæ°æ®æå,systemId:"+systemId+",systemname:"+systemName+",operation:"+operation+",param:"+parmaData); |
| | | } |
| | | |
| | | /*** |
| | | * æ°æ®ç»´æ¤ä¸ç¼ç ç³è¯·è¿å |
| | | * @param resultSystemVO |
| | | * @param dataType |
| | | * @return |
| | | */ |
| | | private String transferResultXMl(XMLResultSystemVO resultSystemVO,String dataType){ |
| | | String resultStr=""; |
| | | if ("xml".equals(dataType)) { |
| | | //ç»ç»è¿åæ¥å£ä¿¡æ¯ |
| | | XStream xStream = new XStream(new DomDriver()); |
| | | xStream.processAnnotations(XMLResultSystemVO.class); |
| | | xStream.autodetectAnnotations(true); |
| | | resultStr = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" + xStream.toXML(resultSystemVO); |
| | | } else { |
| | | List<XMLResultClassfyVO> resultClassfyVOList =resultSystemVO.getClassifys(); |
| | | JSONResultDataVO resultDataVO = new JSONResultDataVO(); |
| | | JSONResultSystemVO jsonResultSystemVO = new JSONResultSystemVO(); |
| | | JSONResultClassfysVO jsonResultClassfysVO = new JSONResultClassfysVO(); |
| | | List<JSONResultClassfyVO> jSONResultClassfyVOList = new ArrayList<>(); |
| | | resultClassfyVOList.stream().forEach(resultClassfyVO -> { |
| | | List<XMLResultDataObjectDetailDO> xmlResultDataObjectDetailDOS = resultClassfyVO.getObjects(); |
| | | List<JSONResultDataObjectDetailDO> JSONResultDataObjectDetailDOList = new ArrayList<>(); |
| | | xmlResultDataObjectDetailDOS.stream().forEach(xmlResultDataObjectDetail -> { |
| | | JSONResultDataObjectDetailDO jsonResultDataObjectDetail = new JSONResultDataObjectDetailDO(); |
| | | BeanUtilForVCI.copyPropertiesIgnoreCase(xmlResultDataObjectDetail, jsonResultDataObjectDetail); |
| | | JSONResultDataObjectDetailDOList.add(jsonResultDataObjectDetail); |
| | | }); |
| | | JSONResultClassfyVO jsonResultClassfyVO = new JSONResultClassfyVO(); |
| | | jsonResultClassfyVO.setClassCode(resultClassfyVO.getClassCode()); |
| | | jsonResultClassfyVO.setLibrary(resultClassfyVO.getLibrary()); |
| | | jsonResultClassfyVO.setFullclsfNamePath(resultClassfyVO.getFullclsfNamePath()); |
| | | JSONResultDataObjectDO JSONResultDataObjectDO = new JSONResultDataObjectDO(); |
| | | JSONResultDataObjectDO.setObject(JSONResultDataObjectDetailDOList); |
| | | jsonResultClassfyVO.setObjects(JSONResultDataObjectDO); |
| | | jSONResultClassfyVOList.add(jsonResultClassfyVO); |
| | | }); |
| | | jsonResultClassfysVO.setClassify(jSONResultClassfyVOList); |
| | | jsonResultSystemVO.setClassifys(jsonResultClassfysVO); |
| | | jsonResultSystemVO.setErrorid(resultSystemVO.getErrorid()); |
| | | jsonResultSystemVO.setMsg(resultSystemVO.getMsg()); |
| | | resultDataVO.setData(jsonResultSystemVO); |
| | | Object object = JSONObject.toJSON(resultDataVO); |
| | | resultStr = object.toString(); |
| | | |
| | | } |
| | | return resultStr; |
| | | } |
| | | |
| | | |
| | | } |