From e937d0111a52e2c13c50bbc3386d20a12d125899 Mon Sep 17 00:00:00 2001
From: wangting <675591594@qq.com>
Date: 星期五, 06 九月 2024 10:54:54 +0800
Subject: [PATCH] 链接类型查询模板
---
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsBtmServiceImpl.java | 454 +++++++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 394 insertions(+), 60 deletions(-)
diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsBtmServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsBtmServiceImpl.java
index 22c0296..f573031 100644
--- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsBtmServiceImpl.java
+++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsBtmServiceImpl.java
@@ -1,12 +1,21 @@
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.client.common.oq.OQTool;
import com.vci.client.common.providers.ClientServiceProvider;
import com.vci.client.mw.ClientSessionUtility;
+import com.vci.common.qt.object.Condition;
+import com.vci.common.qt.object.QueryTemplate;
+import com.vci.common.utility.ObjectUtility;
+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.AttributeValue;
+import com.vci.corba.omd.data.BusinessObject;
import com.vci.corba.omd.etm.EnumType;
import com.vci.corba.omd.lcm.Bound;
import com.vci.corba.omd.lcm.LifeCycle;
@@ -15,26 +24,31 @@
import com.vci.corba.omd.vrm.VersionRule;
import com.vci.dto.OsBtmTypeDTO;
import com.vci.dto.OsBtmTypeLinkAttributesDTO;
+import com.vci.model.IndexObject;
import com.vci.omd.constants.AttributeConstants;
import com.vci.omd.constants.FileObjectType;
import com.vci.omd.objects.OtherInfo;
+import com.vci.omd.utils.ObjectTool;
import com.vci.pagemodel.*;
+import com.vci.po.OsBtmTypePO;
+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.constant.QueryOptionConstant;
import com.vci.starter.web.enumpck.BooleanEnum;
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.PageHelper;
import com.vci.starter.web.pagemodel.Tree;
+import com.vci.starter.web.util.*;
import com.vci.starter.web.util.BeanUtil;
-import com.vci.starter.web.util.VciBaseUtil;
-import com.vci.starter.web.util.VciDateUtil;
-import com.vci.starter.web.util.WebThreadLocalUtil;
import com.vci.web.service.*;
-import com.vci.web.util.ConcurrentDateFormat;
-import com.vci.web.util.Func;
-import com.vci.web.util.PlatformClientUtil;
-import com.vci.web.util.WebUtil;
+import com.vci.web.util.*;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -42,8 +56,11 @@
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 javax.swing.*;
+import java.io.File;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@@ -186,13 +203,13 @@
//vo.setCreateTime(VciDateUtil.str2Date(String.valueOf(btmItem.createTime),VciDateUtil.DateTimeFormat));
vo.setCreateTime(Func.parse(btmItem.createTime, ConcurrentDateFormat.of(VciDateUtil.DateTimeFormat)));
vo.setLastModifyTime( Func.parse(btmItem.modifyTime, ConcurrentDateFormat.of(VciDateUtil.DateTimeFormat)));
- vo.setTs(Func.parse(btmItem.ts, ConcurrentDateFormat.of(VciDateUtil.DateTimeFormat)));
+ vo.setTs(Func.parse(btmItem.ts, ConcurrentDateFormat.of(VciDateUtil.DateTimeMillFormat)));
} catch (Exception e) {
e.printStackTrace();
}
vo.setDescription(btmItem.description);
vo.setId(btmItem.name);
- vo.setName(btmItem.label);
+ vo.setName(btmItem.label);
vo.setLifeCycleId(btmItem.lifeCycle);
vo.setAbstractFlag(btmItem.isAbstract);
vo.setImplClass(btmItem.implClass);
@@ -202,11 +219,13 @@
vo.setTableName(VciBaseUtil.getTableName(vo.getId()));
vo.setInputRevisionFlag(btmItem.revInput);
vo.setDelimiter(btmItem.delimiter);
- if(StringUtils.isNotBlank(vo.getRevisionRuleId()) || vo.isInputRevisionFlag()){
+ vo.setfName(btmItem.fName);
+ vo.setVersionRule(String.valueOf(btmItem.verRuleName));
+ if(StringUtils.isNotBlank(vo.getRevisionRuleName()) || vo.isInputRevisionFlag()){
vo.setRevisionFlag(true);
}
- vo.setVersionRule(String.valueOf(btmItem.verRuleName));
- vo.setSubLifeCycleId(Arrays.stream(btmItem.lifeCycles).collect(Collectors.joining(",")));
+ vo.setLifeCycleIds(Arrays.stream(btmItem.lifeCycles).collect(Collectors.joining(",")));
+ vo.setApNameArray(btmItem.apNameArray);
List<OsAttributeVO> attributeVOS = attributeService.listAttrByIds(Arrays.stream(btmItem.apNameArray).collect(Collectors.toList()));
List<OsBtmTypeAttributeVO> btmTypeAttributeVOS = new ArrayList<>();
Optional.ofNullable(attributeVOS).orElseGet(()->new ArrayList<>()).stream().forEach(attributeVO->{
@@ -214,7 +233,7 @@
BeanUtil.convert(attributeVO,btmTypeAttributeVO);
btmTypeAttributeVO.setPkBtmType(vo.getOid());
btmTypeAttributeVO.setBtmTypeId(vo.getId());
- btmTypeAttributeVO.setAttrDataType(attributeVO.getAttributeDataType());
+ btmTypeAttributeVO.setAttributeDataType(attributeVO.getAttributeDataType());
btmTypeAttributeVO.setAttributeLength(attributeVO.getAttrLength());
btmTypeAttributeVO.setDefaultValue(attributeVO.getDefaultValue());
if("secretgrade".equalsIgnoreCase(attributeVO.getId())){
@@ -340,9 +359,14 @@
* @return 灞炴�х殑鍐呭
*/
@Override
- public List<OsBtmTypeAttributeVO> listAttributeByBtmId(String btmId) {
+ public List<OsBtmTypeAttributeVO> listAttributeByBtmId(String btmId) throws PLException {
VciBaseUtil.alertNotNull(btmId,"涓氬姟绫诲瀷鐨勭紪鍙�");
- OsBtmTypeVO btmTypeVO = getBtmById(btmId);
+ BizType[] bizTypes = platformClientUtil.getBtmService().getBizTypes(btmId);
+ if(Func.isEmpty(bizTypes)){
+ return new ArrayList<>();
+ }
+ BizType bizType = bizTypes[0];
+ OsBtmTypeVO btmTypeVO = btmDO2VO(bizType);
List<OsBtmTypeAttributeVO> attributes = btmTypeVO.getAttributes();
if(attributes == null){
attributes = new ArrayList<>();
@@ -357,7 +381,7 @@
* @return 灞炴�х殑鍐呭
*/
@Override
- public List<OsBtmTypeAttributeVO> listAttributeByBtmIdHasDefault(String btmId) {
+ public List<OsBtmTypeAttributeVO> listAttributeByBtmIdHasDefault(String btmId) throws PLException {
List<OsBtmTypeAttributeVO> attrVOs = listAttributeByBtmId(btmId);
if(attrVOs == null){
attrVOs = new ArrayList<>();
@@ -367,7 +391,7 @@
attributeService.getDefaultAttributeVOs().stream().forEach(attr->{
OsBtmTypeAttributeVO attributeVO = new OsBtmTypeAttributeVO();
BeanUtil.convert(attr, attributeVO);
- attributeVO.setAttrDataType(attr.getAttributeDataType());
+ attributeVO.setAttributeDataType(attr.getAttributeDataType());
attributeVO.setAttributeLength(attr.getAttrLength());
attributeVO.setReferBtmTypeId(attr.getBtmTypeId());
attributeVO.setReferBtmTypeName(attr.getBtmTypeName());
@@ -466,6 +490,42 @@
btmName = "";
}
return platformClientUtil.getBtmService().getBizTypes(btmName);
+ }
+
+ /**
+ * 涓氬姟绫诲瀷鍒楄〃鏌ヨ锛岄潪鏍戠粨鏋勶細鐢ㄤ簬UI瀹氫箟宸︿晶涓氬姟绫诲瀷鏌ヨ锛屽彧杩斿洖name鍜宭able
+ * @param btmName
+ * @return
+ * @throws PLException
+ */
+ @Override
+ public Tree getBizTree(String btmName) throws PLException {
+ if(null == btmName){
+ btmName = "";
+ }
+ Tree returnTree = new Tree();
+ BizType[] bizTypes = platformClientUtil.getBtmService().getBizTypes(btmName);
+ if(Func.isEmpty(bizTypes)){
+ return returnTree;
+ }
+ returnTree.setOid("");
+ returnTree.setText("涓氬姟绫诲瀷");
+ returnTree.setLeaf(false);
+ List<Tree> trees = new ArrayList<>();
+ Arrays.stream(bizTypes).forEach(bizType -> {
+ Tree tree = new Tree();
+ tree.setText(bizType.name + " " +bizType.label);
+ tree.setOid(bizType.oid);
+ tree.setLeaf(true);
+ tree.setParentName(bizType.fName);
+ Map<String, String> atrrMap = new HashMap<>();
+ atrrMap.put("name",bizType.name);
+ atrrMap.put("lable",bizType.label);
+ tree.setAttributes(atrrMap);
+ trees.add(tree);
+ });
+ returnTree.setChildren(trees);
+ return returnTree;
}
/**
@@ -580,18 +640,20 @@
public List<Tree> getTreeBizTypes() throws PLException {
List<Tree> rootTreeList = new ArrayList<>();
BizType[] bizTypes = getBizTypes("");
- BizType btItem = null;
- for(int i = 0; i < bizTypes.length; i++){
- btItem = bizTypes[i];
- if(btItem.fName.equals("")){
+ OsBtmTypeVO osBtmTypeVO = null;
+ List<OsBtmTypeVO> osBtmTypeVOS = btmDO2VOs(Arrays.asList(bizTypes));
+ for(int i = 0; i < osBtmTypeVOS.size(); i++){
+ osBtmTypeVO = osBtmTypeVOS.get(i);
+
+ if(osBtmTypeVO.getfName().equals("")){
Tree tree = new Tree();
- tree.setOid(btItem.oid);
+ tree.setOid(osBtmTypeVO.getOid());
tree.setParentName(null);
tree.setParentId(null);
tree.setLeaf(true);
- tree.setText(btItem.description);
- tree.setAttributes(WebUtil.objectToMapString(btItem));
- tree.setChildren(getChildren(bizTypes,btItem));
+ tree.setText(osBtmTypeVO.getDescription());
+ tree.setAttributes(WebUtil.objectToMapString(osBtmTypeVO));
+ tree.setChildren(getChildren(osBtmTypeVOS,osBtmTypeVO));
rootTreeList.add(tree);
}
}
@@ -628,7 +690,7 @@
AttributeDef sysAttributeDef = collect.get(attrName.toLowerCase());
OsBtmTypeAttributeVO vo = new OsBtmTypeAttributeVO();
vo.setOid(sysAttributeDef.oid);
- vo.setAttrDataType(sysAttributeDef.vtDataType);
+ vo.setAttributeDataType(sysAttributeDef.vtDataType);
vo.setPkBtmType(btmName);
vo.setCreateTime(new Date(sysAttributeDef.createTime));
vo.setCreator(sysAttributeDef.creator);
@@ -647,7 +709,7 @@
for (AttributeDef attribute : attributeDefs) {
OsBtmTypeAttributeVO vo = new OsBtmTypeAttributeVO();
vo.setOid(attribute.oid);
- vo.setAttrDataType(attribute.vtDataType);
+ vo.setAttributeDataType(attribute.vtDataType);
vo.setPkBtmType(btmName);
vo.setCreateTime(new Date(attribute.createTime));
vo.setCreator(attribute.creator);
@@ -675,6 +737,7 @@
*/
private BizType dto2BizType(OsBtmTypeDTO dto){
BizType bizType = new BizType();
+ bizType.oid = dto.getOid();
bizType.name =dto.getId();
bizType.isAbstract = dto.isAbstractFlag();
bizType.label = dto.getName();
@@ -690,24 +753,24 @@
}
bizType.description = dto.getDescription();
bizType.revLevel = dto.getRevLevel();
-
- bizType.revRuleName = dto.getRevisionRuleName();
+ bizType.revRuleName = dto.getRevisionRuleId();
bizType.revInput = dto.isInputRevisionFlag();
bizType.delimiter = (dto.getDelimiter() == null ? "" : dto.getDelimiter());
- bizType.verRuleName = Short.parseShort(dto.getRevisionRuleName());
+ bizType.verRuleName = Func.isBlank(dto.getVersionRule()) ? 0:Short.parseShort(dto.getVersionRule());
//bizType.imageName = dto.get;
//List<String> attrIdList = dto.getAttributesDTOList().stream().map(OsBtmTypeLinkAttributesDTO::getId).collect(Collectors.toList());
- bizType.apNameArray = dto.getApNameArray();//attrIdList.toArray(new String[attrIdList.size()]);
+ bizType.apNameArray = dto.getApNameArray().split(",");//attrIdList.toArray(new String[attrIdList.size()]);
String userId = WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId();
long timeMillis = System.currentTimeMillis();
bizType.creator = Func.isBlank(dto.getCreator()) ? userId:dto.getCreator();
bizType.createTime = Func.isEmpty(dto.getCreateTime()) ? timeMillis:dto.getCreateTime().getTime();
bizType.modifier = userId;
bizType.modifyTime = timeMillis;
+ bizType.ts = Func.isEmpty(dto.getTs())? timeMillis:dto.getTs().getTime();
return bizType;
}
@@ -734,7 +797,7 @@
* @param bizTypes
* @return
*/
- @Override
+/* @Override
public boolean addBtmTypes(List<BizType> bizTypes) {
VciBaseUtil.alertNotNull(bizTypes,"鍒涘缓鐨勪笟鍔$被鍨嬪璞″垪琛�");
bizTypes.stream().forEach(bizType->{
@@ -747,9 +810,8 @@
throw new VciBaseException(exceptionMessage);
}
});
-
return true;
- }
+ }*/
/**
* 妫�鏌ヤ笟鍔$被鍨嬪悕绉版槸鍚﹀悎瑙�
@@ -792,9 +854,11 @@
* @return
*/
private void checkVersionInfo(OsBtmTypeDTO dto) throws PLException {
- //闇�瑕佹墜鍔ㄨ緭鍏ョ増鏈椂revisionRuleName涓嶈兘涓虹┖
- if (dto.isInputRevisionFlag() && Func.isBlank(dto.getRevisionRuleName())) {
- throw new PLException("500",new String[]{"鐗堟湰鍙疯鍒欎笉鑳戒负绌�"});
+ //闇�瑕佹墜鍔ㄨ緭鍏ョ増鏈椂revisionRuleId涓嶈兘涓虹┖
+ if (dto.getRevLevel() == 1 || dto.getRevLevel() == 2) {
+ if (Func.isBlank(dto.getRevisionRuleId()) && !dto.isInputRevisionFlag()) {
+ throw new PLException("500",new String[]{"鐗堟湰鍙疯鍒欎笉鑳戒负绌�"});
+ }
}
}
@@ -809,7 +873,6 @@
if (dbBizType.revLevel == 1 && dto.getRevLevel()==0) {
throw new PLException("500",new String[]{"鐗堟湰鍙樻洿閿欒锛氫笉鑳戒粠涓�绾у彉涓轰笉鍙慨璁�"});
}
-
if (dbBizType.revLevel == 2 && (dto.getRevLevel() == 1 || dto.getRevLevel() == 0)) {
throw new PLException("500",new String[]{"鐗堟湰鍙樻洿閿欒锛氫笉鑳戒粠浜岀骇鍙樹负涓�绾ф垨涓嶅彲淇"});
}
@@ -836,14 +899,14 @@
checkRevLevel(dbBizType,btmTypeDTO);
checkVersionInfo(btmTypeDTO);
//澶勭悊涓氬姟绫诲瀷涓嬬殑灞炴��
- List<String> lastAttrList = new ArrayList<>(Arrays.asList(btmTypeDTO.getApNameArray()));
+ List<String> lastAttrList = new ArrayList<>(Arrays.asList(btmTypeDTO.getApNameArray().split(",")));
//涓嶈兘绉婚櫎鐨勫睘鎬�
String[] unRemovableFields = null;
List<String> unRemovableFields_ = null;
//闇�瑕佺Щ闄ょ殑灞炴��
List<String> removableFields = null;
//淇敼鍓嶄笟鍔$被鍨嬪湪鏁版嵁搴撲腑宸插瓨鍦ㄧ殑鎵�鏈夊睘鎬�
- String[] apNameArray = btmTypeDTO.getApNameArray();
+ String[] apNameArray = btmTypeDTO.getApNameArray().split(",");
Set<String> dbApNameArray = Arrays.stream(dbBizType.apNameArray)
.collect(Collectors.toSet());
//杩囨护鍑洪渶瑕佺Щ闄ょ殑灞炴��
@@ -1119,35 +1182,306 @@
}
/**
- * 鏍规嵁涓氬姟绫诲瀷鍚嶇О鍜屽叾涓嬬殑灞炴�у悕绉拌幏鍙栦篃鏈夌殑绱㈠紩
- * @param btmName
- * @param attrName
+ * 鏍规嵁涓氬姟绫诲瀷鍚嶇О鍜屽叾涓嬬殑灞炴�у悕绉拌幏鍙栧凡鏈夌殑绱㈠紩
+ * @param conditionMap 鏍规嵁鏌ヨ鏉′欢浼犲弬: typename:涓氬姟绫诲瀷鍚�;
* @return
*/
@Override
- public List<String> getIndexByBtmAndAttrName(String btmName, String attrName) {
- return null;
+ public List<IndexObject> getIndexByCondition(Map<String,String> conditionMap) throws PLException {
+ if(Func.isEmpty(conditionMap)){
+ return new ArrayList<>();
+ }
+ List<String> indexNameList = new ArrayList<String>();
+ QueryTemplate qtl = new QueryTemplate();
+ List<String> list = new ArrayList<String>();
+ list.add("*");
+ qtl.setBtmType("indexobject");
+ qtl.setClauseList(list);
+ qtl.setId("p");
+ qtl.setType("btm");
+ qtl.setRightFlag(false);
+ Condition condition = OQTool.getCondition(conditionMap);
+ qtl.setCondition(condition);
+ //HashMap<String, String> indexmap = new HashMap<String, String>();
+ BusinessObject findBTMObjects[] = platformClientUtil.getQueryService().findBTMObjects(qtl.getId(), OQTool.qtTOXMl(qtl).asXML());
+ List<IndexObject> indexObjects = new ArrayList<>();
+ for(int i = 0; i < findBTMObjects.length; i++) {
+ BusinessObject findBTMObject = findBTMObjects[i];
+ IndexObject indexObject = new IndexObject();
+ indexObject.setOid(findBTMObject.oid);
+ indexObject.setDescription(findBTMObject.description);
+ indexObject.setCreateTime(Func.format(new Date(findBTMObject.createTime),DateUtil.PATTERN_DATE));
+ indexObject.setIndexName(ObjectTool.getBOAttributeValue(findBTMObject,"indexname"));
+ indexObject.setTypeName(ObjectTool.getBOAttributeValue(findBTMObject,"typename"));
+ indexObject.setAttrNames(ObjectTool.getBOAttributeValue(findBTMObject,"attrname"));
+ indexObjects.add(indexObject);
+ }
+ return indexObjects;
}
/**
* 鏍规嵁涓氬姟绫诲瀷鍚嶇О鍜屽叾涓嬬殑灞炴�у悕绉板垹闄ょ储寮�
* @param btmName
- * @param attrName
+ * @param indexName
* @return
*/
@Override
- public boolean delIndexByBtmAndAttrName(String btmName, String attrName) {
- return false;
+ public boolean delIndex(String btmName, String indexName) throws PLException {
+ VciBaseUtil.alertNotNull(btmName,"涓氬姟绫诲瀷鍚�",indexName,"绱㈠紩鍚�");
+ Map<String, String> conditionMap = new HashMap<>();
+ conditionMap.put("typename",btmName);
+ conditionMap.put("indexname",indexName);
+ List<IndexObject> bo2 = getIndexByCondition(conditionMap);
+ if(bo2!=null && bo2.size()>0) {
+ String[] indexAttr = {indexName};
+
+ boolean alterFlag = platformClientUtil.getBtmService().dropIndex(btmName, indexAttr);
+
+ if (!alterFlag) {
+ return false;
+ }
+ for (int i = 0; i < bo2.size(); i++) {
+ String oid = bo2.get(i).getOid();
+ BusinessObject bo = platformClientUtil.getBOFactoryService().readBusinessObject(oid, "indexobject");
+ platformClientUtil.getBOFactoryService().deleteBusinessObject(bo,1);
+ }
+ }
+ return true;
}
/**
* 缁欎笟鍔$被鍨嬩笅鐨勬寚瀹氬睘鎬ф柊澧炵储寮�
- * @param addMap 濡傦細(btmName:part attrName:name indexName: PARTNAMEINDEX)
+ * @param indexObjectList
* @return
*/
@Override
- public boolean addIndex(Map<String, String> addMap) {
- return false;
+ public boolean addIndex(List<IndexObject> indexObjectList) throws PLException {
+ VciBaseUtil.alertNotNull(indexObjectList,"鏂板鐨勭储寮曚俊鎭�");
+ String btmName = indexObjectList.get(0).getTypeName();
+ String indexNames = indexObjectList.stream().map(IndexObject::getIndexName).collect(Collectors.joining(","));
+ String[] oldindexAttr = {indexNames};
+ BusinessObject bo;
+ List<BusinessObject> boList = new ArrayList<>();
+ //鍏堟煡璇㈠綋鍓嶆坊鍔犵储寮曟槸鍚﹀凡缁忓瓨鍦紝濡傛灉瀛樺湪灏卞厛鍒犻櫎鍐嶆柊澧炲疄鐜版浛鎹㈡搷浣�
+ Map<String, String> conditionMap = new HashMap<>();
+ conditionMap.put("typename",btmName);
+ //鍏堣繖鏍峰鐞嗭紝鍓嶇鐜板湪鍙仛浜嗗崟娆′繚瀛橈紝鎵�浠ヤ笉鐢╥n
+ conditionMap.put("indexname", indexNames);
+ List<IndexObject> indexObjects = getIndexByCondition(conditionMap);
+ if(indexObjects!=null && indexObjects.size()>0){
+ //绱㈠紩涓嶅瓨鍦ㄦ椂鍒犻櫎灏变細鎶ラ敊绱㈠紩涓嶅瓨鍦紝鎵�浠ヨ繖閲屾湁绱㈠紩鎵嶅幓鍒犻櫎
+ boolean b = platformClientUtil.getBtmService().dropIndex(btmName, oldindexAttr);
+ if(b){
+ for(int i = 0; i < indexObjects.size(); i ++){
+ String oid = (String) indexObjects.get(i).getOid();
+ bo = platformClientUtil.getBOFactoryService().readBusinessObject(oid,"indexobject");
+ platformClientUtil.getBOFactoryService().deleteBusinessObject(bo,1);
+ }
+ }
+ }
+
+ for(int i = 0; i < indexObjectList.size(); i ++){
+ IndexObject indexObject = indexObjectList.get(i);
+ //bo = platformClientUtil.getBOFService().initBusinessObject("indexobject");
+ bo = boService.createCBOByBtmName("indexobject");
+ List<AttributeValue> attributeValues = new ArrayList<>();
+ attributeValues.add(new AttributeValue("typename", btmName));
+ attributeValues.add(new AttributeValue("indexname", indexObject.getIndexName()));
+ attributeValues.add(new AttributeValue("attrname", indexObject.getAttrNames()));
+ bo.newAttrValList = attributeValues.toArray(new AttributeValue[attributeValues.size()]);
+ bo.description = indexObject.getDescription();
+ String[] indexAttr = {indexObject.getIndexName(),indexObject.getAttrNames()};
+ //缁欐寚瀹氫笟鍔$被鍨嬬殑鎸囧畾灞炴�у垱寤虹储寮�
+ boolean alterFlag = platformClientUtil.getBtmService().addIndex(btmName, indexAttr);
+ //绱㈠紩鍒涘缓鎴愬姛涔嬪悗锛岄渶瑕佸瓨鍌ㄦ垚鍔熺储寮曞埌绱㈠紩琛ㄤ腑
+ if(!alterFlag){
+ return false;
+ }
+ boList.add(bo);
+ //娣诲姞绱㈠紩淇℃伅鍒扮储寮曠殑涓氬姟琛ㄤ腑
+ //platformClientUtil.getBOFactoryService().createBusinessObject(bo,false,false);
+ }
+ //娣诲姞绱㈠紩淇℃伅鍒扮储寮曠殑涓氬姟琛ㄤ腑
+ platformClientUtil.getBOFactoryService().batchCreateBusinessObject(boList.toArray(new BusinessObject[boList.size()]),false,false);
+ return true;
+ }
+
+ /**
+ * 瀵煎嚭涓氬姟绫诲瀷
+ * oid 涓氬姟绫诲瀷鍚嶇О
+ * @return 鍒涘缓缁撴灉
+ */
+ @Override
+ public void expData(String names, HttpServletResponse response) throws PLException, IOException {
+ String defaultTempFolder = LocalFileUtil.getDefaultTempFolder();
+ //鍐檈xcel
+ String excelPath = defaultTempFolder + File.separator + "btm.xls";
+ //璁剧疆鍒楀悕
+ List<String> columns = new ArrayList<>(
+ Arrays.asList("绫诲瀷鍚嶇О", "鏍囩", "缁ф壙鑷�", "瀹炵幇绫�", "鎻忚堪", "鐗堟湰瑙勫垯", "鐗堟湰鍙疯鍒�",
+ "鏄惁鎵嬪伐杈撳叆","鍒嗛殧绗�", "鐗堟鍙疯鍒�","鐢熷懡鍛ㄦ湡", "澶囬�夌敓鍛藉懆鏈熷垪琛�","灞炴�у垪琛�")
+ );
+ try {
+ new File(excelPath).createNewFile();
+ //璁剧疆鍒�
+ List<WriteExcelData> excelDataList = new ArrayList<>();
+ //璁剧疆鍒楀ご
+ for (int index = 0; index < columns.size(); index++) {
+ excelDataList.add(new WriteExcelData(0,index, columns.get(index)));
+ }
+ HashSet<String> attributes = new HashSet<>();
+ int i = 0;
+ for (String name : names.split(",")) {
+ BizType bizType = platformClientUtil.getBtmService().getBizTypeByName(name);
+ excelDataList.add(new WriteExcelData(i+1,0, bizType.name));
+ excelDataList.add(new WriteExcelData(i+1,1, bizType.label));
+ excelDataList.add(new WriteExcelData(i+1,2, bizType.fName));
+ excelDataList.add(new WriteExcelData(i+1,3, bizType.implClass));
+ excelDataList.add(new WriteExcelData(i+1,4, bizType.description));
+ excelDataList.add(new WriteExcelData(i+1,5, bizType.revLevel));
+ excelDataList.add(new WriteExcelData(i+1,6, bizType.revRuleName));
+ excelDataList.add(new WriteExcelData(i+1,7, bizType.revInput));
+ excelDataList.add(new WriteExcelData(i+1,8, bizType.delimiter));
+ excelDataList.add(new WriteExcelData(i+1,9, bizType.verRuleName));
+ excelDataList.add(new WriteExcelData(i+1,10, bizType.lifeCycle));
+ excelDataList.add(new WriteExcelData(i+1,11, String.join(",",bizType.lifeCycles)));
+ excelDataList.add(new WriteExcelData(i+1,12, String.join(",",bizType.apNameArray)));
+ attributes.addAll(Arrays.asList(bizType.apNameArray));
+ i++;
+ }
+ WriteExcelOption excelOption = new WriteExcelOption(excelDataList);
+ ExcelUtil.writeDataToFile(excelPath, excelOption);
+ //瀵煎嚭灞炴��
+ String attrPath = attributeService.exportAttributes("btmattr",
+ attributes.stream().collect(Collectors.joining(",")),true);
+ //绉诲姩灞炴�у埌閾炬帴绫诲瀷鏂囦欢澶归噷闈㈠幓
+ FileUtil.move(new File(attrPath), new File(defaultTempFolder),true);
+ FileUtil.del(attrPath.substring(0,attrPath.lastIndexOf("\\")));
+ }catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ File zip = ZipUtil.zip(defaultTempFolder);
+ FileUtil.del(defaultTempFolder + File.separator);
+ ControllerUtil.writeFileToResponse(response,zip.getAbsoluteFile());
+ }
+
+ /**
+ * 瀵煎叆涓氬姟绫诲瀷
+ * @param file 涓婁紶鐨勬枃浠�
+ * @return
+ */
+ @Override
+ public BaseResult impData(MultipartFile file) throws Exception {
+ String defaultTempFolder = LocalFileUtil.getDefaultTempFolder();
+ String fileName = defaultTempFolder + File.separator + LocalFileUtil.getFileNameForIE(file.getOriginalFilename());
+ file.transferTo(new File(fileName));
+ if (file == null) {
+ return BaseResult.fail(FrameWorkLangCodeConstant.IMPORT_FAIL, new String[]{"鏃犲鍏ョ殑鏂囦欢"});
+ }
+ if (!fileName.endsWith(".zip") || !fileName.endsWith(".rar")) {
+ throw new VciBaseException("浠呰兘涓婁紶zip鍘嬬缉鏂囦欢锛岃閲嶆柊涓婁紶锛�");
+ }
+ File unzip = ZipUtil.unzip(fileName);
+ File btmExcel = new File(unzip.getAbsolutePath() + File.separator + "btm.xls");
+ File attrExcel = new File(unzip.getAbsolutePath() + File.separator + "btmattr.xls");
+ if (!attrExcel.exists()) {
+ //澧炲姞瑙e帇鐨勮矾寰勶紝鐪嬫枃浠惰繕鍦ㄦ病鏈�
+ attrExcel = new File(unzip.getAbsolutePath() + File.separator + unzip.getName() + File.separator + "btmattr.xls");
+ if (!attrExcel.exists()) {
+ return BaseResult.fail(FrameWorkLangCodeConstant.IMPORT_FAIL, new String[]{"娌℃湁瀵煎叆鐨勫睘鎬ф枃浠躲�傚鍏ョ粓姝紒"});
+ }
+ }
+ //TODO锛氬鍏ュ睘鎬э紝浣嗘槸杩欎釜閫昏緫瀹為檯涓婂瓨鍦ㄤ竴浜涢棶棰橈紝瀵煎叆鐨勫睘鎬у彧鏄笟鍔$被鍨嬬殑灞炴�т笉搴旇鍘荤粰灞炴�ф睜瀵煎叆锛屽彲鑳芥槸鎯崇殑灞炴�т笉瀛樺湪鐨勫氨鏂板涓�娆�
+ BaseResult baseResult = attributeService.importAttributes(attrExcel,true);
+ if(!baseResult.isSuccess()){
+ //鍒犻櫎涓婁紶鐨勬枃浠跺す
+ FileUtil.del(defaultTempFolder + File.separator);
+ return baseResult;
+ }
+ //鍏ヤ笟鍔$被鍨�
+ if (!btmExcel.exists()) {
+ //澧炲姞瑙e帇鐨勮矾寰勶紝鐪嬫枃浠惰繕鍦ㄦ病鏈�
+ btmExcel = new File(unzip.getAbsolutePath() + File.separator + unzip.getName() + File.separator + "btm.xls");
+ if (!btmExcel.exists()) {
+ //鍒犻櫎涓婁紶鐨勬枃浠跺す
+ FileUtil.del(defaultTempFolder + File.separator);
+ return BaseResult.fail(FrameWorkLangCodeConstant.IMPORT_FAIL, new String[]{"娌℃湁瀵煎叆鐨勯摼鎺ユ枃浠躲�傚鍏ョ粓姝紒"});
+ }
+ }
+ try{
+ //1銆佽鍙杄xcel涓殑鏁版嵁锛岀粍鎴愬璞�
+ ReadExcelOption excelOption = new ReadExcelOption();
+ List<OsBtmTypePO> poList = ExcelUtil.readDataObjectFromExcel(btmExcel, OsBtmTypePO.class,excelOption,(value, po, fieldName)->{});
+ //鍘婚櫎閮芥槸绌虹殑鎯呭喌
+ if(CollectionUtils.isEmpty(poList)){
+ return BaseResult.fail(ExcelLangCodeConstant.IMPORT_CONTENT_NULL,new String[]{});
+ }
+ //褰撳墠excel涓槸鍚﹂噸澶嶇敤鐨勫垽閲峂ap:锛坘ey锛氬垽閲嶅睘鎬э紝value锛氳鍙凤級
+ Map<String, String> excelReapeat = new HashMap<>();
+ int maxLength = platformClientUtil.getLinkTypeService().getLTNameMaxLength();
+
+ //鍒ゆ柇蹇呭~灞炴�ф槸鍚︿负绌猴紝鐢ㄦ埛鏄惁宸插瓨鍦紝浠ュ強閮ㄩ棬鏄惁濉敊绛夋牎楠岄�昏緫
+ poList.stream().forEach(osBtmTypePO -> {
+ if(Func.isBlank(osBtmTypePO.getName())){//灞炴�у悕鍒ょ┖
+ throw new VciBaseException("绗��"+osBtmTypePO.getRowIndex()+"銆戣锛宯ame");
+ }else if(osBtmTypePO.getName().length() > maxLength){
+ throw new VciBaseException("绗��"+osBtmTypePO.getRowIndex()+"銆戣锛屼笟鍔$被鍨嬪悕闀垮害涓嶈兘瓒呰繃" + maxLength);
+ }else if(!osBtmTypePO.getName().matches("^[A-Za-z]+$")){
+ throw new VciBaseException("绗��"+osBtmTypePO.getRowIndex()+"銆戣锛屼笟鍔$被鍨嬪悕绉板彧鑳戒负鑻辨枃瀛楁瘝");
+ }else if (osBtmTypePO.getName().length() > maxLength) {
+ throw new VciBaseException("绗��"+osBtmTypePO.getRowIndex()+"銆戣锛屼笟鍔$被鍨嬪悕闀垮害涓嶈兘瓒呰繃" + maxLength);
+ }else if(excelReapeat.containsKey(osBtmTypePO.getName())){//涓氬姟绫诲瀷鍚嶅湪琛ㄦ牸涓垽閲�
+ throw new VciBaseException("绗��"+excelReapeat.get(osBtmTypePO.getName())+"銆戣鍜岀銆�"+osBtmTypePO.getRowIndex()+"銆戣鏁版嵁锛屼笟鍔$被鍨嬪悕閲嶅");
+ }else if (Func.isBlank(osBtmTypePO.getLifeCycle())) {
+ throw new VciBaseException("绗��"+osBtmTypePO.getRowIndex()+"銆戣锛岀敓鍛藉懆鏈熶笉鑳戒负绌�");
+ }else if ("true".equalsIgnoreCase(osBtmTypePO.getRevInput()) && Func.isBlank(osBtmTypePO.getRevRuleName())) {
+ throw new VciBaseException("绗��"+osBtmTypePO.getRowIndex()+"銆戣锛岀増鏈彿瑙勫垯涓嶈兘涓虹┖");
+ }
+ try {
+ BizType historyBtm = platformClientUtil.getBtmService().getBizTypeByName(osBtmTypePO.getName());
+ //宸叉湁姝ゆ暟鎹繘琛屽垹闄よ鐩�
+ if(historyBtm != null && !historyBtm.name.equals("")){
+ platformClientUtil.getBtmService().deleteBizType(historyBtm);
+ }
+ } catch (PLException e) {
+ throw new RuntimeException(e);
+ }
+
+ //灞炴�у悕excel涓垽閲嶅鐞�
+ excelReapeat.put(osBtmTypePO.getName(),osBtmTypePO.getRowIndex());
+ BizType bizType = new BizType();
+ bizType.name = osBtmTypePO.getName();
+ bizType.label = osBtmTypePO.getLable();
+ bizType.description = osBtmTypePO.getDescription();
+ bizType.fName = osBtmTypePO.getFName();
+ bizType.implClass = osBtmTypePO.getImplClass();
+ bizType.revLevel = osBtmTypePO.getRevLevel();
+ bizType.revRuleName = osBtmTypePO.getRevRuleName();
+ bizType.revInput = Boolean.parseBoolean(osBtmTypePO.getRevInput().toLowerCase(Locale.ROOT));
+ bizType.delimiter = osBtmTypePO.getDelimiter();
+ bizType.verRuleName = osBtmTypePO.getVerRuleName();
+ bizType.lifeCycle = osBtmTypePO.getLifeCycle();
+ bizType.lifeCycles = osBtmTypePO.getLifeCycles().split(",");
+ bizType.apNameArray = osBtmTypePO.getApNameArray().split(",");
+ String userId = WebUtil.getCurrentUserId();
+ bizType.modifier = userId;
+ bizType.creator = userId;
+ try {
+ platformClientUtil.getBtmService().addBizType(bizType);
+ } catch (PLException e) {
+ throw new RuntimeException(e);
+ }
+ });
+ }catch (Exception e){
+ if(logger.isErrorEnabled()){
+ logger.error("璇诲彇excel鍐呭鏃舵垨淇濆瓨涓氬姟绫诲瀷淇℃伅鏃跺嚭鐜颁簡閿欒锛屽叿浣撳師鍥狅細",VciBaseUtil.getExceptionMessage(e));
+ }
+ e.printStackTrace();
+ return BaseResult.fail(VciBaseUtil.getExceptionMessage(e),new String[]{},e);
+ }
+ //鍒犻櫎涓婁紶鐨勬枃浠跺す
+ FileUtil.del(defaultTempFolder + File.separator);
+ return BaseResult.success("涓氬姟绫诲瀷瀵煎叆鎴愬姛锛�");
}
/**
@@ -1186,21 +1520,21 @@
return flag;
}
- private List<Tree> getChildren(BizType[] bizTypes,BizType parentBIzType){
+ private List<Tree> getChildren(List<OsBtmTypeVO> osBtmTypeVOS,OsBtmTypeVO parentBIzType){
List<Tree> trees= new ArrayList<>();
- for (BizType bizType : bizTypes) {
- if(StringUtils.isBlank(bizType.fName)){
+ for (OsBtmTypeVO bizType : osBtmTypeVOS) {
+ if(StringUtils.isBlank(bizType.getfName())){
continue;
}
- if(bizType.fName.equals(parentBIzType.name)){
+ if(bizType.getfName().equals(parentBIzType.getId())){
Tree tree = new Tree();
- tree.setOid(bizType.oid);
- tree.setParentName(parentBIzType.fName);
- tree.setParentId(parentBIzType.oid);
+ tree.setOid(bizType.getOid());
+ tree.setParentName(parentBIzType.getfName());
+ tree.setParentId(parentBIzType.getOid());
tree.setLeaf(true);
- tree.setText(bizType.description);
+ tree.setText(bizType.getDescription());
tree.setAttributes(WebUtil.objectToMapString(bizType));
- tree.setChildren(getChildren(bizTypes,bizType));
+ tree.setChildren(getChildren(osBtmTypeVOS,bizType));
trees.add(tree);
}
}
--
Gitblit v1.9.3