| | |
| | | package com.vci.web.service.impl; |
| | | |
| | | import cn.hutool.core.io.FileUtil; |
| | | import cn.hutool.core.util.ZipUtil; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.vci.client.ClientSession; |
| | | import com.vci.client.common.oq.OQTool; |
| | | import com.vci.client.common.providers.ClientServiceProvider; |
| | | import com.vci.common.qt.object.*; |
| | | import com.vci.constant.FrameWorkLangCodeConstant; |
| | | import com.vci.corba.common.PLException; |
| | | import com.vci.corba.omd.atm.AttributeDef; |
| | | import com.vci.corba.omd.btm.BizType; |
| | | import com.vci.corba.omd.data.BusinessObject; |
| | | import com.vci.corba.omd.data.LinkObject; |
| | | import com.vci.corba.omd.ltm.LinkType; |
| | | import com.vci.corba.omd.qtm.QTD; |
| | | import com.vci.corba.omd.qtm.QTInfo; |
| | | import com.vci.dto.QTInfoDTO; |
| | | import com.vci.omd.objects.OtherInfo; |
| | | import com.vci.po.OsLinkTypePO; |
| | | import com.vci.starter.poi.bo.ReadExcelOption; |
| | | import com.vci.starter.poi.bo.WriteExcelData; |
| | | import com.vci.starter.poi.bo.WriteExcelOption; |
| | | import com.vci.starter.poi.constant.ExcelLangCodeConstant; |
| | | import com.vci.starter.poi.util.ExcelUtil; |
| | | 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.Tree; |
| | | import com.vci.starter.web.util.*; |
| | | import com.vci.web.other.BtmQTExportData; |
| | | import com.vci.web.other.LinkQTExportData; |
| | | import com.vci.web.service.*; |
| | | import com.vci.web.util.DateUtil; |
| | | import com.vci.web.util.Func; |
| | | import com.vci.web.util.PlatformClientUtil; |
| | | import com.vci.web.util.WebUtil; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.commons.lang3.time.DateFormatUtils; |
| | | import org.dom4j.Document; |
| | | import org.dom4j.DocumentException; |
| | | import org.dom4j.DocumentHelper; |
| | | import org.dom4j.Element; |
| | | import org.jdesktop.swingx.JXDatePicker; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.swing.*; |
| | | import java.awt.*; |
| | | import java.io.*; |
| | | import java.util.*; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 查询模板服务 |
| | |
| | | } |
| | | |
| | | /** |
| | | * 查询模板 |
| | | * 保存查询模板 |
| | | * @param qtd 查询模板实体类 |
| | | * @return 保存结果 |
| | | */ |
| | |
| | | } |
| | | } |
| | | /** |
| | | * |
| | | * @param dataMap 传输的数据对象: |
| | | * @param qtInfoDTO 传输的数据对象: |
| | | * linkTypeName 链接类型、 |
| | | * rdPositive 方向,true正向,false反向 |
| | | * btmName 业务类型名称 |
| | |
| | | * @return 查询结果 |
| | | */ |
| | | @Override |
| | | public BaseResult getCriteria(HashMap<String,Object> dataMap) throws PLException { |
| | | QueryTemplate qt = getQT(dataMap); |
| | | public BaseResult getCriteria(QTInfoDTO qtInfoDTO) throws PLException { |
| | | QueryTemplate qt = getQT(qtInfoDTO,true); |
| | | String checkInfo = OQTool.checkQT(qt); |
| | | if(!checkInfo.equals("OK")){ |
| | | throw new PLException("500", new String[]{checkInfo}); |
| | |
| | | qtInfoDTO.setBtmName(obj.btmName); |
| | | qtInfoDTO.setQtName(obj.qtName); |
| | | qtInfoDTO.setLevelFlag(obj.levelFlag); |
| | | // qtInfoDTO.setQtText(obj.qtText); |
| | | //qtInfoDTO.setQtText(obj.qtText); |
| | | qtInfoDTO.setQtUIText(obj.qtUIText); |
| | | if(StringUtils.isNotBlank(obj.qtUIText)){ |
| | | //将给定的String文本解析为XML文档并返回新创建的document |
| | |
| | | */ |
| | | @Override |
| | | public BaseResult linkSave(QTInfoDTO qtInfoDTO) throws PLException { |
| | | QueryTemplate qt = getQT(qtInfoDTO); |
| | | QueryTemplate qt = getQT(qtInfoDTO,true); |
| | | String checkInfo = OQTool.checkQT(qt); |
| | | if(!checkInfo.equals("OK")){ |
| | | throw new PLException("500", new String[]{checkInfo}); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 链接类型查询模板树查询,用于界面的导出功能 |
| | | * @return 查询结果 |
| | | */ |
| | | @Override |
| | | public BaseResult getLinkTree() throws PLException { |
| | | LinkType[] linkTypes= null; |
| | | QTInfo[] qts = null; |
| | | HashMap<String,Object> tree = new HashMap(); |
| | | tree.put("text","业务类型"); |
| | | if (linkTypes == null) { |
| | | List<LinkType> es = new ArrayList<LinkType>(); |
| | | linkTypes = platformClientUtil.getLinkTypeService().getLinkTypes(); |
| | | for (LinkType lt : linkTypes) { |
| | | QTInfo[] qtWrappers = platformClientUtil.getQTDService().getObjTypeQTs(lt.name); |
| | | if (qtWrappers.length!=0) { |
| | | es.add(lt); |
| | | } |
| | | } |
| | | linkTypes = es.toArray(new LinkType[es.size()]); |
| | | //TODO:需修正没有关联查询模板业务类型去掉 |
| | | qts = platformClientUtil.getQTDService().getAllQTs();//获取所有查询模板 |
| | | } |
| | | List<HashMap<String,Object>> childList = new ArrayList<>(); |
| | | //添加业务类型根节点 |
| | | for (LinkType plAction : linkTypes) { |
| | | HashMap<String,Object> childTree = new HashMap(); |
| | | childTree.put("text", plAction.tag + "/" +plAction.name); |
| | | childTree.put("oid", plAction.oid); |
| | | // tree.put("children", childTree); |
| | | addExportTreeNode(plAction, qts, childTree); |
| | | childList.add(childTree); |
| | | } |
| | | tree.put("children", childList); |
| | | return BaseResult.success(tree); |
| | | } |
| | | |
| | | /** |
| | | * 生成导出树选择以及导入树显示 |
| | | * @param linkType |
| | | * @param qts |
| | | * @param tree |
| | | */ |
| | | private void addExportTreeNode(LinkType linkType/*业务类型*/,QTInfo[] qts/*查询模板对象*/,HashMap<String,Object> tree) { |
| | | List<String> childList = new ArrayList<>(); |
| | | // 添加查询模板对象子节点 |
| | | for (QTInfo qtItem : qts) { |
| | | //处理导入时无法进行类型判断 |
| | | int splitLength = linkType.name.indexOf("【"); |
| | | if(splitLength == -1){ |
| | | splitLength = linkType.name.length(); |
| | | } |
| | | if (qtItem.btmName.equals(linkType.name.substring(0, |
| | | splitLength))) { |
| | | childList.add(qtItem.qtName); |
| | | } |
| | | } |
| | | tree.put("children",childList); |
| | | } |
| | | |
| | | /** |
| | | * 将高级条件数据转为xml |
| | | * @param qtInfoDTO 查询模板列表传输对象 |
| | | * @return xml数据 |
| | | */ |
| | | private String getSeniorXML(QTInfoDTO qtInfoDTO){ |
| | | HashMap<String, Object> tree = qtInfoDTO.getTree(); |
| | | if(tree.isEmpty()){ |
| | |
| | | return xmlStr.append("</root>").toString(); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 将高级条件数据转为xml |
| | | * @param childs 高级条件数据 |
| | | * @return xml数据 |
| | | */ |
| | | private String getSeniorChildXML(JSONObject childs){ |
| | | |
| | | StringBuilder xmlStr = new StringBuilder("<child>" + childs.get("connector")); |
| | |
| | | * 组装查询模板 |
| | | * @return |
| | | */ |
| | | public QueryTemplate getQT(QTInfoDTO qtInfoDTO) throws PLException { |
| | | public QueryTemplate getQT(QTInfoDTO qtInfoDTO,boolean isLinkType) throws PLException { |
| | | QueryTemplate qt = new QueryTemplate(); |
| | | qt.setType(QTConstants.TYPE_LINK); |
| | | //TODO String qtId = |
| | | qt.setLinkType(qtInfoDTO.getBtmName()); |
| | | qt.setDirection(qtInfoDTO.getQueryTemplate().getDirection()); |
| | | qt.setBtmType(qtInfoDTO.getQueryTemplate().getBtmType()); |
| | | |
| | | qt.setVersion(qtInfoDTO.getQueryTemplate().getVersion()); |
| | | qt.setQueryISLeaf(qtInfoDTO.getQueryTemplate().isQueryISLeaf()); |
| | | qt.setLevel(qtInfoDTO.getQueryTemplate().getLevel()); |
| | | if(isLinkType){ |
| | | qt.setType(QTConstants.TYPE_LINK); |
| | | qt.setLinkType(qtInfoDTO.getBtmName()); |
| | | qt.setDirection(qtInfoDTO.getQueryTemplate().getDirection()); |
| | | qt.setBtmType(qtInfoDTO.getQueryTemplate().getBtmType()); |
| | | qt.setVersion(qtInfoDTO.getQueryTemplate().getVersion()); |
| | | qt.setQueryISLeaf(qtInfoDTO.getQueryTemplate().isQueryISLeaf()); |
| | | qt.setLevel(qtInfoDTO.getQueryTemplate().getLevel()); |
| | | }else{ |
| | | qt.setType(QTConstants.TYPE_BTM); |
| | | qt.setBtmType(qtInfoDTO.getBtmName()); |
| | | } |
| | | |
| | | List<String> clauseList = new ArrayList<String>(); |
| | | //TODO 查询列 显示列 |
| | | clauseList.add("*"); |
| | |
| | | //高级查询条件 |
| | | }else if(qtInfoDTO.getLevelFlag() == 1){ |
| | | ciMap = getCIMapForSeniorTree(qtInfoDTO); |
| | | |
| | | // OQTool.parseTreeToDoc(seniorTree); |
| | | } |
| | | return ciMap; |
| | | } |
| | |
| | | return qt; |
| | | } |
| | | |
| | | /** |
| | | * 组装查询模板 |
| | | * @return |
| | | */ |
| | | public QueryTemplate getQT(HashMap<String,Object> dataMap){ |
| | | QueryTemplate qt = new QueryTemplate(); |
| | | qt.setType(QTConstants.TYPE_LINK); |
| | | //TODO String qtId = |
| | | qt.setLinkType((String) dataMap.get("linkTypeName")); |
| | | qt.setDirection( (Boolean)dataMap.get("rdPositive") ? QTConstants.DIRECTION_POSITIVE : QTConstants.DIRECTION_OPPOSITE); |
| | | qt.setBtmType((String) dataMap.get("btmName")); |
| | | if("所有类型".equals(dataMap.get("combRelaType"))){ |
| | | qt.setBtmType("*"); |
| | | } |
| | | qt.setVersion(getVersion((String) dataMap.get("versionValue"))); |
| | | qt.setQueryISLeaf((Boolean) dataMap.get("isQueryIsLeaf")); |
| | | qt.setLevel(StringUtils.isBlank((CharSequence) dataMap.get("level")) ? 1 : Integer.valueOf(String.valueOf(dataMap.get("level")))); |
| | | List<String> clauseList = new ArrayList<String>(); |
| | | //TODO 查询列 显示列 |
| | | clauseList.add("*"); |
| | | qt.setClauseList(clauseList); |
| | | // /** |
| | | // * 组装查询模板 |
| | | // * @return |
| | | // */ |
| | | // public QueryTemplate getQT(HashMap<String,Object> dataMap){ |
| | | // QueryTemplate qt = new QueryTemplate(); |
| | | // qt.setType(QTConstants.TYPE_LINK); |
| | | // //TODO String qtId = |
| | | // qt.setLinkType((String) dataMap.get("linkTypeName")); |
| | | // qt.setDirection( (Boolean)dataMap.get("rdPositive") ? QTConstants.DIRECTION_POSITIVE : QTConstants.DIRECTION_OPPOSITE); |
| | | // qt.setBtmType((String) dataMap.get("btmName")); |
| | | // if("所有类型".equals(dataMap.get("combRelaType"))){ |
| | | // qt.setBtmType("*"); |
| | | // } |
| | | // qt.setVersion(getVersion((String) dataMap.get("versionValue"))); |
| | | // qt.setQueryISLeaf((Boolean) dataMap.get("isQueryIsLeaf")); |
| | | // qt.setLevel(StringUtils.isBlank((CharSequence) dataMap.get("level")) ? 1 : Integer.valueOf(String.valueOf(dataMap.get("level")))); |
| | | // List<String> clauseList = new ArrayList<String>(); |
| | | // //TODO 查询列 显示列 |
| | | // clauseList.add("*"); |
| | | // qt.setClauseList(clauseList); |
| | | // Condition con = new Condition(); |
| | | // qt.setCondition(con); |
| | | // HashMap<String, ConditionItem> ciMap = getCIMap(); |
| | | // con.setCIMap(ciMap); |
| | | // con.setRootCIName(con.getRootCINameByCIMap(ciMap)); |
| | | return qt; |
| | | } |
| | | |
| | | // return qt; |
| | | // } |
| | | |
| | | /** |
| | | * 返回查询的版本 |
| | |
| | | return version; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 校验参数 |
| | | * @param qtd |
| | |
| | | throw new PLException("500", new String[]{"该模板定义名已经被使用, 请更换"}); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 导出链接类型查询模板 |
| | | * names 查询模板名 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public void expLinkTemplate(List<String> names, HttpServletResponse response) throws PLException, IOException { |
| | | String defaultTempFolder = LocalFileUtil.getDefaultTempFolder(); |
| | | String vciqtmfFileName = defaultTempFolder + File.separator + "LinkTemplateExp" + new Date().getTime() + ".vciqtf"; |
| | | LinkQTExportData exportData = new LinkQTExportData(); |
| | | for (String name : names) { |
| | | QTInfo qt = platformClientUtil.getQTDService().getQT(name); |
| | | exportData.getAllQTs().put(qt.qtName,qt); |
| | | LinkType linkType = platformClientUtil.getLinkTypeService().getLinkType(qt.btmName); |
| | | if(linkType != null && !linkType.oid.equals("")){ |
| | | exportData.getSelectedBtmItems().put(linkType.name, linkType); |
| | | exportData.getSelectedBtmAttrs().put(linkType.name, linkType.attributes); |
| | | exportData.getAllQTDs().put(linkType.name, platformClientUtil.getQTDService().getLinkTypeQTDs(linkType.name)); |
| | | } |
| | | } |
| | | ObjectOutputStream vciamfFileStream = null; |
| | | try { |
| | | File vciqtmfFile = new File(vciqtmfFileName); |
| | | vciamfFileStream = new ObjectOutputStream(new FileOutputStream(vciqtmfFile)); |
| | | vciamfFileStream.writeObject(exportData); |
| | | }finally { |
| | | try { |
| | | if (vciamfFileStream != null) { |
| | | vciamfFileStream.flush(); |
| | | vciamfFileStream.close(); |
| | | } |
| | | } catch (Exception e) { |
| | | throw new PLException("500",new String[]{"导出流关闭异常!"}); |
| | | } |
| | | } |
| | | ControllerUtil.writeFileToResponse(response,vciqtmfFileName); |
| | | FileUtil.del(defaultTempFolder + File.separator); |
| | | } |
| | | /** |
| | | * 导入链接类型查询模板 |
| | | * @param file 上传的文件 |
| | | * @return 导入结果 |
| | | */ |
| | | @Override |
| | | public BaseResult impLinkTemplate(MultipartFile file) throws IOException, ClassNotFoundException { |
| | | |
| | | if (file == null) { |
| | | return BaseResult.fail(FrameWorkLangCodeConstant.IMPORT_FAIL, new String[]{"无导入的文件"}); |
| | | } |
| | | if (!file.getOriginalFilename().endsWith(".vciqtf")) { |
| | | throw new VciBaseException("仅能上传.vciqtf格式文件,请重新上传!"); |
| | | } |
| | | ObjectInputStream obj = new ObjectInputStream( |
| | | file.getInputStream()); |
| | | LinkQTExportData qtExportData = (LinkQTExportData) obj.readObject(); |
| | | List<LinkType> ltsNew = new ArrayList<>(); |
| | | List<QTInfo> qTWrapperNew = new ArrayList<>(); |
| | | Map<String/* 类型名称 */, QTD[]/* 查询模板定义 */> norepQTDs = new HashMap<String, QTD[]>(); |
| | | addImportData(qtExportData, ltsNew, qTWrapperNew, norepQTDs); |
| | | QTInfo[] qts = qTWrapperNew |
| | | .toArray(new QTInfo[qTWrapperNew.size()]); |
| | | //处理树的返回 |
| | | HashMap<String,Object> tree = new HashMap(); |
| | | tree.put("text","链接类型"); |
| | | List<HashMap<String,Object>> childList = new ArrayList<>(); |
| | | //添加业务类型根节点 |
| | | for (LinkType plAction : ltsNew) { |
| | | HashMap<String,Object> childTree = new HashMap(); |
| | | childTree.put("text", plAction.tag + "/" +plAction.name); |
| | | childTree.put("oid", plAction.oid); |
| | | addExportTreeNode(plAction, qts, childTree); |
| | | childList.add(childTree); |
| | | } |
| | | tree.put("children", childList); |
| | | return BaseResult.success(tree); |
| | | } |
| | | |
| | | // 数据过滤 |
| | | private void addImportData(LinkQTExportData qtExportData, List<LinkType> ltsNew, List<QTInfo> qTWrapperNew, |
| | | Map<String/* 类型名称 */, QTD[]/* 查询模板定义 */> norepQTDs) { |
| | | Map<String/* 类型名称 */, QTD[]/* 查询模板定义 */> allQTDs = qtExportData |
| | | .getAllQTDs(); |
| | | Map<String/* 类型名称 */, LinkType/* 类型对象 */> selectedBtmItems = qtExportData |
| | | .getSelectedBtmItems(); |
| | | Map<String/* 类型名称 */, String[]/* 类型所属属性 */> selectedBtmAttrs = qtExportData |
| | | .getSelectedBtmAttrs(); |
| | | Map<String/* 查询模板名称 */, QTInfo/* 查询模板对象 */> allSelectedQTs = qtExportData |
| | | .getAllQTs(); |
| | | if (allQTDs.size() == 0 || allQTDs == null |
| | | || selectedBtmItems.size() == 0 || selectedBtmItems == null |
| | | || selectedBtmAttrs.size() == 0 || selectedBtmAttrs == null |
| | | || allSelectedQTs.size() == 0 || allSelectedQTs == null) { |
| | | throw new VciBaseException("导入的模板数据有误!!!"); |
| | | } |
| | | Set<Map.Entry<String, QTD[]>> pLActions = allQTDs.entrySet(); |
| | | Set<Map.Entry<String, QTInfo>> pLQts = allSelectedQTs.entrySet(); |
| | | Set<Map.Entry<String, LinkType>> LinkpLQts = selectedBtmItems.entrySet(); |
| | | for (Map.Entry<String, QTD[]> entry : pLActions) { |
| | | String string = entry.getKey(); |
| | | QTD[] qtds = entry.getValue(); |
| | | getPLQtIsInDB(string, qtds, norepQTDs); |
| | | } |
| | | for (Map.Entry<String, LinkType> entry : LinkpLQts) { |
| | | String string = entry.getKey(); |
| | | LinkType LinkType = entry.getValue(); |
| | | getPLQtBtmItem(string, LinkType, ltsNew); |
| | | } |
| | | Map<String/*类型名称*/, QTD[]/*查询模板定义*/> newNorepQTDs = getnewNorepQTDs(norepQTDs,allSelectedQTs); |
| | | for (Map.Entry<String, QTInfo> entry : pLQts) { |
| | | String string = entry.getKey(); |
| | | QTInfo qtWrapper = entry.getValue(); |
| | | getPLQtWrapper(string, qtWrapper, ltsNew, qTWrapperNew, newNorepQTDs); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 查询模板定义的处理 |
| | | * @param string |
| | | * @param qtds |
| | | */ |
| | | private void getPLQtIsInDB(String string, QTD[] qtds, Map<String/* 类型名称 */, QTD[]/* 查询模板定义 */> norepQTDs) { |
| | | // TODO Auto-generated method stub |
| | | try { |
| | | QTD[] qtds2 = platformClientUtil.getQTDService().getBizTypeQTDs(string); |
| | | QTD[] qtdsNewQtds = null; |
| | | List<QTD> es = new ArrayList<>(); |
| | | for (QTD qtd : qtds) { |
| | | boolean isleat = true; |
| | | for (int i = 0; i < qtds2.length; i++) { |
| | | if (qtd.name.equals(qtds2[i].name)) { |
| | | isleat = false; |
| | | break; |
| | | } |
| | | } |
| | | if (isleat) { |
| | | es.add(qtd); |
| | | } |
| | | } |
| | | if (es.size() != 0) { |
| | | qtdsNewQtds = es.toArray(new QTD[es.size()]); |
| | | norepQTDs.put(string, qtdsNewQtds); |
| | | } |
| | | } catch (PLException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | private void getPLQtBtmItem(String string, LinkType linkType, List<LinkType> ltsNew) { |
| | | // TODO Auto-generated method stub |
| | | try { |
| | | LinkType queryLinkType = platformClientUtil.getLinkTypeService().getLinkType(string); |
| | | LinkType[] btmArray = platformClientUtil.getLinkTypeService().getLinkTypes(); |
| | | String[] strings = queryLinkType.attributes; |
| | | String[] stringsFrom = queryLinkType.btmItemsFrom; |
| | | String[] stringsTo = queryLinkType.btmItemsTo; |
| | | boolean b = true; |
| | | for (int i = 0; i < btmArray.length; i++) { |
| | | if (btmArray[i].name.equals(string)) { |
| | | b = false; |
| | | if (Arrays.equals(linkType.attributes, strings) |
| | | && Arrays |
| | | .equals(linkType.btmItemsFrom, stringsFrom) |
| | | && Arrays.equals(linkType.btmItemsTo, stringsTo)) { |
| | | btmArray[i].name += "【链接类型已存在】"; |
| | | /* this.btmArray[i] = btmArray[i]; */ |
| | | ltsNew.add(btmArray[i]); |
| | | } else { |
| | | btmArray[i].name += "【链接类型存在但属性不一致】"; |
| | | ltsNew.add(btmArray[i]); |
| | | } |
| | | } |
| | | } |
| | | if (b) { |
| | | linkType.name += "【链接类型不存在】"; |
| | | ltsNew.add(linkType); |
| | | } |
| | | } catch (PLException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | private void getPLQtBtmItem2(String string, BizType bizType, List<BizType> ltsNew) { |
| | | // TODO Auto-generated method stub |
| | | try { |
| | | BizType queryBizType = platformClientUtil.getBtmService().getBizTypes(string)[0]; |
| | | BizType[] btmArray = platformClientUtil.getBtmService().getBizTypes(""); |
| | | String[] strings = queryBizType.apNameArray; |
| | | boolean b = true; |
| | | for (int i = 0; i < btmArray.length; i++) { |
| | | if (btmArray[i].name.equals(string)) { |
| | | b = false; |
| | | if (Arrays.equals(bizType.apNameArray, strings)) { |
| | | btmArray[i].name += "【业务类型已存在】"; |
| | | ltsNew.add(btmArray[i]); |
| | | } else { |
| | | btmArray[i].name += "【业务类型存在但属性不一致】"; |
| | | ltsNew.add(btmArray[i]); |
| | | } |
| | | } |
| | | } |
| | | if (b) { |
| | | bizType.name += "【业务类型不存在】"; |
| | | ltsNew.add(bizType); |
| | | } |
| | | } catch (PLException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | private void getPLQtWrapper(String string, QTInfo qtWrapper, List<LinkType> ltsNew, List<QTInfo> qTWrapperNew, Map<String/*类型名称*/, QTD[]/*查询模板定义*/> newNorepQTDs) { |
| | | try { |
| | | QTInfo[] qtws = platformClientUtil.getQTDService().getAllQTs(); |
| | | boolean islaet = true; |
| | | for (int i = 0; i < qtws.length; i++) { |
| | | if (string.equals(qtws[i].qtName)) { |
| | | islaet = false; |
| | | for (LinkType lt : ltsNew) { |
| | | if (qtWrapper.btmName.equals(lt.name.substring(0, |
| | | lt.name.indexOf("【")))) { |
| | | if (lt.name.endsWith("【链接类型已存在】")) { |
| | | qtWrapper.qtName += "【查询模板已存在,不导入】"; |
| | | qTWrapperNew.add(qtWrapper); |
| | | }else if(lt.name.endsWith("【链接类型存在但属性不一致】")){ |
| | | qtWrapper.qtName += "【查询模板所属链接类型属性不一致,不导入】"; |
| | | qTWrapperNew.add(qtWrapper); |
| | | }else{ |
| | | qtWrapper.qtName += "【查询模板所属链接类型不存在,不导入】"; |
| | | qTWrapperNew.add(qtWrapper); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if (islaet) { |
| | | for (LinkType btmItem : ltsNew) { |
| | | if (qtWrapper.btmName.equals(btmItem.name.substring(0, |
| | | btmItem.name.indexOf("【")))) { |
| | | if (btmItem.name.endsWith("【链接类型已存在】")) { |
| | | //判断查询模板定义是否存在,进行保存 |
| | | QTD[] qtds = newNorepQTDs.get(qtWrapper.btmName); |
| | | if(qtds != null){ |
| | | for (QTD qtd : qtds) { |
| | | QTD qtdByName = platformClientUtil.getQTDService().getQTDByName(qtd.name); |
| | | if(!(qtdByName != null && StringUtils.isNotBlank(qtdByName.name))){ |
| | | boolean b = platformClientUtil.getQTDService().addQTD(qtd); |
| | | if(!b){ |
| | | qtWrapper.qtName += qtWrapper.qtName+"导入查询模板定义【" + qtdByName.name + "】失败!"; |
| | | } |
| | | } |
| | | } |
| | | newNorepQTDs.remove(qtWrapper.btmName); |
| | | } |
| | | boolean success = platformClientUtil.getQTDService().saveQT(qtWrapper); |
| | | if(!success){ |
| | | qtWrapper.qtName += qtWrapper.qtName+"导入失败!"; |
| | | }else { |
| | | qtWrapper.qtName += "【查询模板导入成功!】"; |
| | | } |
| | | qTWrapperNew.add(qtWrapper); |
| | | }else if(btmItem.name.endsWith("【链接类型存在但属性不一致】")){ |
| | | qtWrapper.qtName += "【查询模板所属链接类型属性不一致,不导入】"; |
| | | qTWrapperNew.add(qtWrapper); |
| | | }else{ |
| | | qtWrapper.qtName += "【查询模板所属链接类型不存在,不导入】"; |
| | | qTWrapperNew.add(qtWrapper); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } catch (PLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | private void getPLBtmQtWrapper(String string, QTInfo qtWrapper, List<BizType> ltsNew, List<QTInfo> qTWrapperNew, Map<String/*类型名称*/, QTD[]/*查询模板定义*/> newNorepQTDs) { |
| | | try { |
| | | QTInfo[] qtws = platformClientUtil.getQTDService().getAllQTs(); |
| | | boolean islaet = true; |
| | | for (int i = 0; i < qtws.length; i++) { |
| | | if (string.equals(qtws[i].qtName)) { |
| | | islaet = false; |
| | | for (BizType lt : ltsNew) { |
| | | if (qtWrapper.btmName.equals(lt.name.substring(0, |
| | | lt.name.indexOf("【")))) { |
| | | if (lt.name.endsWith("【业务类型已存在】")) { |
| | | qtWrapper.qtName += "【查询模板已存在,不导入】"; |
| | | qTWrapperNew.add(qtWrapper); |
| | | }else if(lt.name.endsWith("【业务类型存在但属性不一致】")){ |
| | | qtWrapper.qtName += "【查询模板所属业务类型属性不一致,不导入】"; |
| | | qTWrapperNew.add(qtWrapper); |
| | | }else{ |
| | | qtWrapper.qtName += "【查询模板所属业务类型不存在,不导入】"; |
| | | qTWrapperNew.add(qtWrapper); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if (islaet) { |
| | | for (BizType btmItem : ltsNew) { |
| | | if (qtWrapper.btmName.equals(btmItem.name.substring(0, |
| | | btmItem.name.indexOf("【")))) { |
| | | if (btmItem.name.endsWith("【业务类型已存在】")) { |
| | | //判断查询模板定义是否存在,进行保存 |
| | | QTD[] qtds = newNorepQTDs.get(qtWrapper.btmName); |
| | | if(qtds != null){ |
| | | for (QTD qtd : qtds) { |
| | | QTD qtdByName = platformClientUtil.getQTDService().getQTDByName(qtd.name); |
| | | if(!(qtdByName != null && StringUtils.isNotBlank(qtdByName.name))){ |
| | | boolean b = platformClientUtil.getQTDService().addQTD(qtd); |
| | | if(!b){ |
| | | qtWrapper.qtName += qtWrapper.qtName+"导入查询模板定义【" + qtdByName.name + "】失败!"; |
| | | } |
| | | } |
| | | } |
| | | newNorepQTDs.remove(qtWrapper.btmName); |
| | | } |
| | | boolean success = platformClientUtil.getQTDService().saveQT(qtWrapper); |
| | | if(!success){ |
| | | qtWrapper.qtName += qtWrapper.qtName+"导入失败!"; |
| | | }else { |
| | | qtWrapper.qtName += "【查询模板导入成功!】"; |
| | | } |
| | | qTWrapperNew.add(qtWrapper); |
| | | }else if(btmItem.name.endsWith("【业务类型存在但属性不一致】")){ |
| | | qtWrapper.qtName += "【查询模板所属业务类型属性不一致,不导入】"; |
| | | qTWrapperNew.add(qtWrapper); |
| | | }else{ |
| | | qtWrapper.qtName += "【查询模板所属业务类型不存在,不导入】"; |
| | | qTWrapperNew.add(qtWrapper); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } catch (PLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | //根据选择的查询模板过滤模板定义 |
| | | private Map<String, QTD[]> getnewNorepQTDs(Map<String, QTD[]> norepQTDs, |
| | | Map<String, QTInfo> allQTs) { |
| | | // TODO Auto-generated method stub |
| | | Map<String, QTD[]> map = new HashMap<String, QTD[]>(); |
| | | Set<Map.Entry<String, QTInfo>> pLQts = allQTs.entrySet(); |
| | | Set<Map.Entry<String, QTD[]>> pLActions = norepQTDs.entrySet(); |
| | | for (Map.Entry<String, QTD[]> entrys : pLActions) { |
| | | for (Map.Entry<String, QTInfo> entry : pLQts) { |
| | | if(entry.getValue().btmName.equals(entrys.getKey())){ |
| | | map.put(entrys.getKey(), entrys.getValue()); |
| | | } |
| | | } |
| | | } |
| | | return map; |
| | | } |
| | | /** |
| | | * 查询方案删除 |
| | | * @param templateNames 查询方案名 |
| | | * @return 操作结果 |
| | | */ |
| | | @Override |
| | | public BaseResult deleteLinkTemplate(List<String> templateNames) throws PLException { |
| | | boolean b = platformClientUtil.getQTDService().deleteQTs(templateNames.toArray(new String[0])); |
| | | if(!b){ |
| | | return BaseResult.fail("删除失败!!!"); |
| | | } |
| | | return BaseResult.success("查询模板删除成功!"); |
| | | } |
| | | |
| | | /** |
| | | * @param qtInfoDTO 传输的数据对象: |
| | | * linkTypeName 链接类型、 |
| | | * rdPositive 方向,true正向,false反向 |
| | | * btmName 业务类型名称 |
| | | * combRelaType 业务类型选择值 |
| | | * versionValue 版本班次值 |
| | | * isQueryIsLeaf 是否选择下级 |
| | | * level 子节点层数 |
| | | * @return 查询结果 |
| | | */ |
| | | @Override |
| | | public BaseResult getCriteriaBtm(QTInfoDTO qtInfoDTO) throws PLException { |
| | | QueryTemplate qt = getQT(qtInfoDTO,false); |
| | | String checkInfo = OQTool.checkQT(qt); |
| | | if(!checkInfo.equals("OK")){ |
| | | throw new PLException("500", new String[]{checkInfo}); |
| | | } |
| | | qt.setId("qt1"); |
| | | BusinessObject[] result = platformClientUtil.getQueryService().findBTMObjects(qt.getId(), OQTool.qtTOXMl(qt).asXML()); |
| | | return BaseResult.dataList(Arrays.asList(result)); |
| | | } |
| | | |
| | | /** |
| | | * 业务类型查询模板保存 |
| | | * @param qtInfoDTO 保存传输对象 |
| | | * @return 保存结果 |
| | | */ |
| | | @Override |
| | | public BaseResult btmSave(QTInfoDTO qtInfoDTO) throws PLException { |
| | | VciBaseUtil.alertNotNull( |
| | | qtInfoDTO,"保存的业务类型模板对象", |
| | | qtInfoDTO.getBtmName(),"请选择业务类型和查询模板定义来创建查询模板" |
| | | ); |
| | | |
| | | //add by caill start 遍历普通查询模板输入框中的值做校验 |
| | | // ArrayList<String> list = cpm_centerPanel.getList(); |
| | | // for(int i=0;i<list.size();i++){ |
| | | // String text = (String) list.get(i); |
| | | // if(text.contains("'")){ |
| | | // JOptionPane.showMessageDialog(cp_mainPanel, "条件值中包含了非法字符", "非法字符", JOptionPane.ERROR_MESSAGE); |
| | | // return; |
| | | // } |
| | | // } |
| | | //保存之前带出已选择的qtName |
| | | QueryTemplate qt = getQT(qtInfoDTO,false); |
| | | //前端调用这个方法isExistsQT() |
| | | /*if(isExists(qtName)){ |
| | | return BaseResult.success("","该查询模板名已经存在,是否覆盖?"); |
| | | }*/ |
| | | String checkInfo = OQTool.checkQT(qt); |
| | | if(!checkInfo.equals("OK")){ |
| | | throw new PLException("500", new String[]{checkInfo}); |
| | | } |
| | | //设置排序信息 |
| | | qt.setOrderInfoList(qtInfoDTO.getQueryTemplate().getOrderInfoList()); |
| | | QTInfo qtWrapper = new QTInfo(); |
| | | qtWrapper.qtName = qtInfoDTO.getQtName(); |
| | | qtWrapper.btmName = qt.getBtmType(); |
| | | qtWrapper.creator = WebUtil.getCurrentUserId(); |
| | | qtWrapper.createTime = System.currentTimeMillis(); |
| | | if(qtInfoDTO.getTree() == null){ |
| | | qtWrapper.qtUIText = ""; |
| | | }else{ |
| | | //当勾选了高级查询时需要处理高级查询的相关条件 |
| | | qtWrapper.qtUIText = getSeniorXML(qtInfoDTO); |
| | | } |
| | | qtWrapper.levelFlag = qtInfoDTO.getLevelFlag(); |
| | | qtWrapper.qtText = OQTool.qtTOXMl(qt).asXML(); |
| | | boolean saveFlag = platformClientUtil.getQTDService().saveQT(qtWrapper); |
| | | if(saveFlag){ |
| | | return BaseResult.success("保存查询模板成功"); |
| | | }else{ |
| | | return BaseResult.fail("保存查询模板失败"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 更新数据库结构 |
| | | * @return 保存结果 |
| | | */ |
| | | @Override |
| | | public BaseResult updateDBStructure() throws PLException { |
| | | boolean f = platformClientUtil.getQTDService().updateQT(); |
| | | if(f){ |
| | | return BaseResult.success("更新成功"); |
| | | }else{ |
| | | return BaseResult.fail("更新失败"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 业务类型查询模板树查询,用于界面的导出功能 |
| | | * @return 查询结果 |
| | | */ |
| | | @Override |
| | | public BaseResult getBtmQtTree() throws PLException { |
| | | BizType[] bizTypes= null; |
| | | QTInfo[] qts = null; |
| | | HashMap<String,Object> tree = new HashMap(); |
| | | tree.put("text","业务类型"); |
| | | if (bizTypes == null) { |
| | | List<BizType> es = new ArrayList<>(); |
| | | bizTypes = platformClientUtil.getBtmService().getBizTypes(""); |
| | | for (BizType lt : bizTypes) { |
| | | QTInfo[] qtWrappers = platformClientUtil.getQTDService().getObjTypeQTs(lt.name); |
| | | if (qtWrappers.length!=0) { |
| | | es.add(lt); |
| | | } |
| | | } |
| | | bizTypes = es.toArray(new BizType[es.size()]); |
| | | //TODO:需修正没有关联查询模板业务类型去掉 |
| | | qts = platformClientUtil.getQTDService().getAllQTs();//获取所有查询模板 |
| | | } |
| | | List<HashMap<String,Object>> childList = new ArrayList<>(); |
| | | //添加业务类型根节点 |
| | | for (BizType plAction : bizTypes) { |
| | | HashMap<String,Object> childTree = new HashMap(); |
| | | childTree.put("text", plAction.label + "/" +plAction.name); |
| | | childTree.put("oid", plAction.oid); |
| | | //tree.put("children", childTree); |
| | | addExportTreeNode(plAction, qts, childTree); |
| | | childList.add(childTree); |
| | | } |
| | | tree.put("children", childList); |
| | | return BaseResult.success(tree); |
| | | } |
| | | |
| | | /** |
| | | * 导出业务类型查询模板 |
| | | * names 查询模板名 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public void expBtmQTTemplate(List<String> names, HttpServletResponse response) throws PLException, IOException { |
| | | String defaultTempFolder = LocalFileUtil.getDefaultTempFolder(); |
| | | String vciqtmfFileName = defaultTempFolder + File.separator + "BtmTemplateExp" + new Date().getTime() + ".vciqtf"; |
| | | BtmQTExportData exportData = new BtmQTExportData(); |
| | | for (String name : names) { |
| | | QTInfo qt = platformClientUtil.getQTDService().getQT(name); |
| | | exportData.getAllQTs().put(qt.qtName,qt); |
| | | BizType[] bizTypes = platformClientUtil.getBtmService().getBizTypes(qt.btmName); |
| | | for (int i = 0; i < bizTypes.length; i++) { |
| | | BizType bizType = bizTypes[i]; |
| | | if(bizTypes != null && !bizType.oid.equals("")){ |
| | | exportData.getSelectedBtmItems().put(bizType.name, bizType); |
| | | exportData.getSelectedBtmAttrs().put(bizType.name, bizType.apNameArray); |
| | | exportData.getAllQTDs().put(bizType.name, platformClientUtil.getQTDService().getBizTypeQTDs(bizType.name)); |
| | | } |
| | | } |
| | | } |
| | | ObjectOutputStream vciamfFileStream = null; |
| | | try { |
| | | File vciqtmfFile = new File(vciqtmfFileName); |
| | | vciamfFileStream = new ObjectOutputStream(new FileOutputStream(vciqtmfFile)); |
| | | vciamfFileStream.writeObject(exportData); |
| | | }finally { |
| | | try { |
| | | if (vciamfFileStream != null) { |
| | | vciamfFileStream.flush(); |
| | | vciamfFileStream.close(); |
| | | } |
| | | } catch (Exception e) { |
| | | throw new PLException("500",new String[]{"导出流关闭异常!"}); |
| | | } |
| | | } |
| | | ControllerUtil.writeFileToResponse(response,vciqtmfFileName); |
| | | FileUtil.del(defaultTempFolder + File.separator); |
| | | } |
| | | |
| | | /** |
| | | * 查询条件下的选择查询模板对话框(查询全部模板和所对应的业务类型或链接类型名) |
| | | * @return |
| | | */ |
| | | @Override |
| | | public BaseResult getAllQTs() throws PLException { |
| | | QTInfo[] allQTs = platformClientUtil.getQTDService().getAllQTs(); |
| | | DataGrid<QTInfo> dataGrid = new DataGrid<>(); |
| | | dataGrid.setData(Arrays.asList(allQTs)); |
| | | dataGrid.setTotal(allQTs.length); |
| | | return BaseResult.dataGrid(dataGrid); |
| | | } |
| | | |
| | | /** |
| | | * 导入业务类型查询模板 |
| | | * @param file 上传的文件 |
| | | * @return 导入结果 |
| | | */ |
| | | @Override |
| | | public BaseResult impBtmTemplate(MultipartFile file) throws IOException, ClassNotFoundException { |
| | | if (file == null) { |
| | | return BaseResult.fail(FrameWorkLangCodeConstant.IMPORT_FAIL, new String[]{"无导入的文件"}); |
| | | } |
| | | if (!file.getOriginalFilename().endsWith(".vciqtf")) { |
| | | throw new VciBaseException("仅能上传.vciqtf格式文件,请重新上传!"); |
| | | } |
| | | ObjectInputStream obj = new ObjectInputStream( |
| | | file.getInputStream()); |
| | | BtmQTExportData qtExportData = (BtmQTExportData) obj.readObject(); |
| | | List<BizType> ltsNew = new ArrayList<>(); |
| | | List<QTInfo> qTWrapperNew = new ArrayList<>(); |
| | | Map<String/* 类型名称 */, QTD[]/* 查询模板定义 */> norepQTDs = new HashMap<String, QTD[]>(); |
| | | addImportBtmData(qtExportData, ltsNew, qTWrapperNew, norepQTDs); |
| | | QTInfo[] qts = qTWrapperNew |
| | | .toArray(new QTInfo[qTWrapperNew.size()]); |
| | | //处理树的返回 |
| | | HashMap<String,Object> tree = new HashMap(); |
| | | tree.put("text","业务类型"); |
| | | List<HashMap<String,Object>> childList = new ArrayList<>(); |
| | | //添加业务类型根节点 |
| | | for (BizType plAction : ltsNew) { |
| | | HashMap<String,Object> childTree = new HashMap(); |
| | | childTree.put("text", plAction.label + "/" +plAction.name); |
| | | childTree.put("oid", plAction.oid); |
| | | addExportTreeNode(plAction, qts, childTree); |
| | | childList.add(childTree); |
| | | } |
| | | tree.put("children", childList); |
| | | return BaseResult.success(tree); |
| | | } |
| | | |
| | | // 数据过滤 |
| | | private void addImportBtmData(BtmQTExportData qtExportData, List<BizType> ltsNew, List<QTInfo> qTWrapperNew, |
| | | Map<String/* 类型名称 */, QTD[]/* 查询模板定义 */> norepQTDs) { |
| | | Map<String/* 类型名称 */, QTD[]/* 查询模板定义 */> allQTDs = qtExportData |
| | | .getAllQTDs(); |
| | | Map<String/* 类型名称 */, BizType/* 类型对象 */> selectedBtmItems = qtExportData |
| | | .getSelectedBtmItems(); |
| | | Map<String/* 类型名称 */, String[]/* 类型所属属性 */> selectedBtmAttrs = qtExportData |
| | | .getSelectedBtmAttrs(); |
| | | Map<String/* 查询模板名称 */, QTInfo/* 查询模板对象 */> allSelectedQTs = qtExportData |
| | | .getAllQTs(); |
| | | if (allQTDs.size() == 0 || allQTDs == null |
| | | || selectedBtmItems.size() == 0 || selectedBtmItems == null |
| | | || selectedBtmAttrs.size() == 0 || selectedBtmAttrs == null |
| | | || allSelectedQTs.size() == 0 || allSelectedQTs == null) { |
| | | throw new VciBaseException("导入的模板数据有误!!!"); |
| | | } |
| | | Set<Map.Entry<String, QTD[]>> pLActions = allQTDs.entrySet(); |
| | | Set<Map.Entry<String, QTInfo>> pLQts = allSelectedQTs.entrySet(); |
| | | Set<Map.Entry<String, BizType>> btmpLQts = selectedBtmItems.entrySet(); |
| | | for (Map.Entry<String, QTD[]> entry : pLActions) { |
| | | String string = entry.getKey(); |
| | | QTD[] qtds = entry.getValue(); |
| | | getPLQtIsInDB(string, qtds, norepQTDs); |
| | | } |
| | | for (Map.Entry<String, BizType> entry : btmpLQts) { |
| | | String string = entry.getKey(); |
| | | BizType bizType = entry.getValue(); |
| | | getPLQtBtmItem2(string, bizType, ltsNew); |
| | | } |
| | | Map<String/*类型名称*/, QTD[]/*查询模板定义*/> newNorepQTDs = getnewNorepQTDs(norepQTDs,allSelectedQTs); |
| | | for (Map.Entry<String, QTInfo> entry : pLQts) { |
| | | String string = entry.getKey(); |
| | | QTInfo qtWrapper = entry.getValue(); |
| | | getPLBtmQtWrapper(string, qtWrapper, ltsNew, qTWrapperNew, newNorepQTDs); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 生成导出树选择以及导入树显示 |
| | | * @param bizType |
| | | * @param qts |
| | | * @param tree |
| | | */ |
| | | private void addExportTreeNode(BizType bizType/*业务类型*/,QTInfo[] qts/*查询模板对象*/,HashMap<String,Object> tree) { |
| | | List<String> childList = new ArrayList<>(); |
| | | // 添加查询模板对象子节点 |
| | | for (QTInfo qtItem : qts) { |
| | | //处理导入时无法进行类型判断 |
| | | int splitLength = bizType.name.indexOf("【"); |
| | | if(splitLength == -1){ |
| | | splitLength = bizType.name.length(); |
| | | } |
| | | if (qtItem.btmName.equals(bizType.name.substring(0, |
| | | splitLength))) { |
| | | childList.add(qtItem.qtName); |
| | | } |
| | | } |
| | | tree.put("children",childList); |
| | | } |
| | | |
| | | } |