| | |
| | | package com.vci.web.service.impl; |
| | | |
| | | import cn.hutool.core.io.FileUtil; |
| | | import cn.hutool.core.util.ZipUtil; |
| | | import com.fasterxml.jackson.core.type.TypeReference; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.vci.constant.FrameWorkLangCodeConstant; |
| | | import com.vci.client.common.oq.OQTool; |
| | | import com.vci.common.qt.object.QTConstants; |
| | | import com.vci.common.qt.object.QueryTemplate; |
| | | 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.ltm.LinkType; |
| | | import com.vci.corba.omd.data.LinkObject; |
| | | import com.vci.corba.omd.qtm.QTD; |
| | | import com.vci.model.OsLinkTypeDO; |
| | | import com.vci.omd.utils.ObjectTool; |
| | | import com.vci.pagemodel.*; |
| | | 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.annotation.log.VciUnLog; |
| | | import com.vci.starter.web.enumpck.VciFieldTypeEnum; |
| | | import com.vci.starter.web.exception.VciBaseException; |
| | | import com.vci.starter.web.pagemodel.BaseQueryObject; |
| | | import com.vci.corba.omd.qtm.QTInfo; |
| | | import com.vci.dto.QTInfoDTO; |
| | | import com.vci.starter.web.pagemodel.BaseResult; |
| | | import com.vci.starter.web.pagemodel.DataGrid; |
| | | import com.vci.starter.web.util.*; |
| | | import com.vci.web.service.*; |
| | | import com.vci.web.util.Func; |
| | | import com.vci.web.util.DateUtil; |
| | | import com.vci.web.util.PlatformClientUtil; |
| | | import com.vci.web.util.WebUtil; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.apache.commons.lang3.time.DateFormatUtils; |
| | | import org.dom4j.DocumentException; |
| | | import org.dom4j.DocumentHelper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 查询模板服务 |
| | |
| | | throw new PLException("500", new String[]{"增加业务类型查询模板失败"}); |
| | | } |
| | | } |
| | | /** |
| | | * 修改查询模板 |
| | | * @param qtd 查询模板实体类 |
| | | * @return 保存结果 |
| | | */ |
| | | @Override |
| | | public BaseResult updateTemplate(QTD qtd) throws PLException { |
| | | //校验参数 |
| | | if (qtd.name.equals("")) { |
| | | throw new PLException("500", new String[]{"请输入模板定义名"}); |
| | | } |
| | | if (!qtd.name.matches("[a-z A-Z]*")) { |
| | | throw new PLException("500", new String[]{"模板定义名只能为英文字母"}); |
| | | } |
| | | qtd.createTime = System.currentTimeMillis(); |
| | | boolean updateFlag = false; |
| | | //进行保存 |
| | | updateFlag = platformClientUtil.getQTDService().modifyQTD(qtd); |
| | | if (updateFlag) { |
| | | return BaseResult.success("修改业务类型查询模板成功"); |
| | | } else { |
| | | throw new PLException("500", new String[]{"修改业务类型查询模板失败"}); |
| | | } |
| | | } |
| | | /** |
| | | * 删除查询模板 |
| | | * @param name 查询模板名 |
| | | * @return 保存结果 |
| | | */ |
| | | @Override |
| | | public BaseResult deleteTemplate(String name) throws PLException { |
| | | boolean flag = false; |
| | | flag = platformClientUtil.getQTDService().deleteQTD(name); |
| | | if (flag) { |
| | | return BaseResult.success("删除查询模板成功"); |
| | | } else { |
| | | return BaseResult.fail("删除查询模板失败"); |
| | | } |
| | | } |
| | | /** |
| | | * |
| | | * @param dataMap 传输的数据对象: |
| | | * linkTypeName 链接类型、 |
| | | * rdPositive 方向,true正向,false反向 |
| | | * btmName 业务类型名称 |
| | | * combRelaType 业务类型选择值 |
| | | * versionValue 版本班次值 |
| | | * isQueryIsLeaf 是否选择下级 |
| | | * level 子节点层数 |
| | | * @return 查询结果 |
| | | */ |
| | | @Override |
| | | public BaseResult getCriteria(HashMap<String,Object> dataMap) throws PLException { |
| | | QueryTemplate qt = getQT(dataMap); |
| | | String checkInfo = OQTool.checkQT(qt); |
| | | if(!checkInfo.equals("OK")){ |
| | | throw new PLException("500", new String[]{checkInfo}); |
| | | } |
| | | qt.setId("qt1"); |
| | | LinkObject[] result = platformClientUtil.getQueryService().findLTObjects(qt.getId(), OQTool.qtTOXMl(qt).asXML()); |
| | | return BaseResult.dataList(Arrays.asList(result)); |
| | | } |
| | | |
| | | /** |
| | | * 查询模板列表 |
| | | * @param btName 类型名称 |
| | | * @return 查询结果 |
| | | */ |
| | | @Override |
| | | public BaseResult getObjTypeQTs(String btName) throws PLException, DocumentException { |
| | | VciBaseUtil.alertNotNull(btName,"类型名"); |
| | | QTInfo[] objTypeQTs = platformClientUtil.getQTDService().getObjTypeQTs(btName); |
| | | List<QTInfoDTO> dtos = new ArrayList<>(); |
| | | for (QTInfo obj : objTypeQTs) { |
| | | QTInfoDTO qtInfoDTO = new QTInfoDTO(); |
| | | qtInfoDTO.setCreator(obj.creator); |
| | | qtInfoDTO.setBtmName(obj.btmName); |
| | | qtInfoDTO.setQtName(obj.qtName); |
| | | qtInfoDTO.setLevelFlag(obj.levelFlag); |
| | | // qtInfoDTO.setQtText(obj.qtText); |
| | | qtInfoDTO.setQtUIText(obj.qtUIText); |
| | | qtInfoDTO.setQueryTemplate(OQTool.getQTByDoc(DocumentHelper.parseText(obj.qtText), obj.qtName)); |
| | | qtInfoDTO.setCreateTimeText(DateFormatUtils.format(new Date(obj.createTime), DateUtil.PATTERN_DATETIME)); |
| | | dtos.add(qtInfoDTO); |
| | | } |
| | | return BaseResult.dataList(dtos); |
| | | } |
| | | /** |
| | | * 检查查询模板名字是否存在 |
| | | * @param name 查询模板名字 |
| | | * @return 查询结果 |
| | | */ |
| | | @Override |
| | | public BaseResult isExistsQT(String name) throws PLException { |
| | | VciBaseUtil.alertNotNull(name,"询模板名"); |
| | | return BaseResult.success(platformClientUtil.getQTDService().isExistsQT(name)); |
| | | } |
| | | |
| | | /** |
| | | * 组装查询模板 |
| | | * @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 |
| | | */ |
| | | public int getVersion(String versionValue){ |
| | | int version = 0; |
| | | if(versionValue.equals("当前版本当前版次")){ |
| | | version = 1; |
| | | }else if(versionValue.equals("当前版本最新版次")){ |
| | | version = 2; |
| | | }else if(versionValue.equals("最新版本最新版次")){ |
| | | version = 3; |
| | | }else if(versionValue.equals("当前版次")){ |
| | | version = 4; |
| | | }else if(versionValue.equals("当前版本")){ |
| | | version = 5; |
| | | }else if(versionValue.equals("当前命名对象")){ |
| | | version = 6; |
| | | }else if(versionValue.equals("已发布的最新版本")){ |
| | | version = 7; |
| | | } |
| | | return version; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 校验参数 |