| | |
| | | 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.dto.*; |
| | | import com.vci.omd.constants.SystemAttribute; |
| | | 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.starter.web.util.ControllerUtil; |
| | | import com.vci.starter.web.util.Lcm.DateUtil; |
| | | import com.vci.starter.web.util.Lcm.Func; |
| | | import com.vci.starter.web.util.LocalFileUtil; |
| | | import com.vci.starter.web.util.VciBaseUtil; |
| | | 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.service.OsQuereyTemplateServiceI; |
| | | 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; |
| | | |
| | | /** |
| | |
| | | }else { |
| | | qtdArray = platformClientUtil.getQTDService().getBizTypeQTDs(btmName); |
| | | } |
| | | return BaseResult.dataList(Arrays.asList(qtdArray)); |
| | | List<QTD> qtdList = Arrays.asList(qtdArray).stream().sorted(Comparator.comparing(s -> s.name,String.CASE_INSENSITIVE_ORDER)).collect(Collectors.toList()); |
| | | return BaseResult.dataList(qtdList); |
| | | } |
| | | |
| | | /** |
| | |
| | | throw new PLException("500", new String[]{"增加业务类型查询模板失败"}); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 修改查询模板 |
| | | * @param qtd 查询模板实体类 |
| | |
| | | return BaseResult.fail("删除查询模板失败"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @param qtInfoDTO 传输的数据对象: |
| | | * linkTypeName 链接类型、 |
| | |
| | | public BaseResult getObjTypeQTs(String btName) throws PLException, DocumentException { |
| | | VciBaseUtil.alertNotNull(btName,"类型名"); |
| | | QTInfo[] objTypeQTs = platformClientUtil.getQTDService().getObjTypeQTs(btName); |
| | | if(Func.isEmpty(objTypeQTs)){ |
| | | return BaseResult.success(); |
| | | } |
| | | List<QTInfoDTO> dtos = new ArrayList<>(); |
| | | Map<String, AttributeDef> allSysAttr = Arrays.stream(platformClientUtil.getBtmService().getSysAttributeDefs()).collect(Collectors.toMap(e -> e.name, e -> e)); |
| | | allSysAttr.putAll(Arrays.stream(platformClientUtil.getLinkTypeService().getSysAttributeDefs()).collect(Collectors.toMap(e -> e.name, e -> e))); |
| | |
| | | qtInfoDTO.setCreateTimeText(DateFormatUtils.format(new Date(obj.createTime), DateUtil.PATTERN_DATETIME)); |
| | | dtos.add(qtInfoDTO); |
| | | } |
| | | // TODO: 2024/12/2 Ludc 返回值排序 |
| | | dtos = dtos.stream().sorted(Comparator.comparing(QTInfoDTO::getQtName,String.CASE_INSENSITIVE_ORDER)).collect(Collectors.toList()); |
| | | return BaseResult.dataList(dtos); |
| | | } |
| | | |
| | |
| | | if(column.contains(".")){ |
| | | column = StringUtils.substringAfterLast(column, "."); |
| | | } |
| | | if(column.contains(" ")){ |
| | | column = StringUtils.substringBefore(column, " "); |
| | | } |
| | | AttributeDef att = platformClientUtil.getAttributeService().getAttributeDefByName(column); |
| | | if(att == null || "".equals(att.oid)){ |
| | | att = allSysAttr.get(column.toLowerCase()); |
| | | } |
| | | if(att == null){ |
| | | throw new PLException("500", new String[]{"属性字段:" + column + "在属性池中未查询到,请确认!!"}); |
| | | } |
| | | leafInfoDTO.setClause(leafInfo.getClause()); |
| | | |
| | |
| | | HashMap<String, String> data = new HashMap<>(); |
| | | data.put("column",child.getText().trim()); |
| | | data.put("type",att.vtDataType); |
| | | childList.add(data); |
| | | } |
| | | } |
| | | treeMap.put("child",childList); |
| | |
| | | //添加业务类型根节点 |
| | | for (LinkType plAction : linkTypes) { |
| | | HashMap<String,Object> childTree = new HashMap(); |
| | | childTree.put("text", plAction.tag + "/" +plAction.name); |
| | | childTree.put("text", plAction.label + "/" +plAction.name); |
| | | childTree.put("oid", plAction.oid); |
| | | // tree.put("children", childTree); |
| | | addExportTreeNode(plAction, qts, childTree); |
| | |
| | | } |
| | | return ciMap; |
| | | } |
| | | |
| | | /** |
| | | * 树化一个查询条件组节点 |
| | | * @param children |
| | |
| | | } |
| | | return ciList; |
| | | } |
| | | |
| | | /** |
| | | * 高级查询 |
| | | * 把Node内容解析成ConditionItem |
| | |
| | | return ci; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取参照的查询模板 |
| | | * @param refAbName: 参照属性名 |
| | |
| | | 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); |
| | | // Condition con = new Condition(); |
| | | // qt.setCondition(con); |
| | | // HashMap<String, ConditionItem> ciMap = getCIMap(); |
| | | // con.setCIMap(ciMap); |
| | | // con.setRootCIName(con.getRootCINameByCIMap(ciMap)); |
| | | // return qt; |
| | | // } |
| | | |
| | | /** |
| | | * 返回查询的版本 |
| | | * @return |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | public void expLinkTemplate(List<String> names, HttpServletResponse response) throws PLException, IOException { |
| | | public void expLinkTemplate(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) { |
| | | String[] splits = names.split(","); |
| | | for (String name : splits) { |
| | | QTInfo qt = platformClientUtil.getQTDService().getQT(name); |
| | | exportData.getAllQTs().put(qt.qtName,qt); |
| | | LinkType linkType = platformClientUtil.getLinkTypeService().getLinkType(qt.btmName); |
| | |
| | | ControllerUtil.writeFileToResponse(response,vciqtmfFileName); |
| | | FileUtil.del(defaultTempFolder + File.separator); |
| | | } |
| | | |
| | | /** |
| | | * 导入链接类型查询模板 |
| | | * @param file 上传的文件 |
| | |
| | | //添加业务类型根节点 |
| | | for (LinkType plAction : ltsNew) { |
| | | HashMap<String,Object> childTree = new HashMap(); |
| | | childTree.put("text", plAction.tag + "/" +plAction.name); |
| | | childTree.put("text", plAction.label + "/" +plAction.name); |
| | | childTree.put("oid", plAction.oid); |
| | | addExportTreeNode(plAction, qts, childTree); |
| | | childList.add(childTree); |
| | |
| | | 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)); |
| | | try { |
| | | BusinessObject[] result = platformClientUtil.getQueryService().findBTMObjects(qt.getId(), OQTool.qtTOXMl(qt).asXML()); |
| | | return BaseResult.dataList(Arrays.asList(result)); |
| | | }catch (Exception e){ |
| | | String errorLog = "查询时出现问题,请检查配置的条件是否存在问题,具体原因:"+VciBaseUtil.getExceptionMessage(e); |
| | | throw new VciBaseException(errorLog); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | if(!checkInfo.equals("OK")){ |
| | | throw new PLException("500", new String[]{checkInfo}); |
| | | } |
| | | qt.setId(qtInfoDTO.getQtName()); |
| | | //设置排序信息 |
| | | qt.setOrderInfoList(qtInfoDTO.getQueryTemplate().getOrderInfoList()); |
| | | QTInfo qtWrapper = new QTInfo(); |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | public void expBtmQTTemplate(List<String> names, HttpServletResponse response) throws PLException, IOException { |
| | | public String expBtmQTTemplate(String qtNames) throws PLException, IOException { |
| | | String defaultTempFolder = LocalFileUtil.getDefaultTempFolder(); |
| | | String vciqtmfFileName = defaultTempFolder + File.separator + "BtmTemplateExp" + new Date().getTime() + ".vciqtf"; |
| | | String[] names = qtNames.split(","); |
| | | BtmQTExportData exportData = new BtmQTExportData(); |
| | | for (String name : names) { |
| | | QTInfo qt = platformClientUtil.getQTDService().getQT(name); |
| | |
| | | throw new PLException("500",new String[]{"导出流关闭异常!"}); |
| | | } |
| | | } |
| | | ControllerUtil.writeFileToResponse(response,vciqtmfFileName); |
| | | FileUtil.del(defaultTempFolder + File.separator); |
| | | //ControllerUtil.writeFileToResponse(response,vciqtmfFileName); |
| | | //FileUtil.del(defaultTempFolder + File.separator); |
| | | return vciqtmfFileName; |
| | | } |
| | | |
| | | /** |
| | |
| | | @Override |
| | | public BaseResult getAllQTs() throws PLException { |
| | | QTInfo[] allQTs = platformClientUtil.getQTDService().getAllQTs(); |
| | | List<QTInfo> allQTList = Arrays.stream(allQTs).sorted(Comparator.comparing(o -> o.qtName, String.CASE_INSENSITIVE_ORDER)).collect(Collectors.toList()); |
| | | DataGrid<QTInfo> dataGrid = new DataGrid<>(); |
| | | dataGrid.setData(Arrays.asList(allQTs)); |
| | | dataGrid.setData(allQTList); |
| | | dataGrid.setTotal(allQTs.length); |
| | | return BaseResult.dataGrid(dataGrid); |
| | | } |
| | |
| | | tree.put("children", childList); |
| | | return BaseResult.success(tree); |
| | | } |
| | | |
| | | /** |
| | | * 查询模板的列表添加了字段的相关属性 |
| | | * @param btmName 类型 |
| | |
| | | if(direction != null) { |
| | | if (direction.equals(QTConstants.DIRECTION_POSITIVE)) { |
| | | if(att == null ){ |
| | | throw new PLException("500",new String[]{"属性字段:"+ abName +"未查询到,请确认!"}); |
| | | continue; |
| | | // throw new PLException("500",new String[]{"属性字段:"+ abName +"未查询到,请确认!"}); |
| | | } |
| | | att.name = "T_OID." + abName; |
| | | } else if (direction.equals(QTConstants.DIRECTION_OPPOSITE)) { |
| | | if(att == null ){ |
| | | throw new PLException("500",new String[]{"属性字段:"+ abName +"未查询到,请确认!"}); |
| | | continue; |
| | | // throw new PLException("500",new String[]{"属性字段:"+ abName +"未查询到,请确认!"}); |
| | | } |
| | | att.name = "F_OID." + abName; |
| | | } |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | // 数据过滤 |
| | | private void addImportBtmData(BtmQTExportData qtExportData, List<BizType> ltsNew, List<QTInfo> qTWrapperNew, |
| | | Map<String/* 类型名称 */, QTD[]/* 查询模板定义 */> norepQTDs) { |