| | |
| | | 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; |
| | |
| | | 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.enumpck.BooleanEnum; |
| | | import com.vci.starter.web.exception.VciBaseException; |
| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | } |
| | | 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); |
| | |
| | | vo.setTableName(VciBaseUtil.getTableName(vo.getId())); |
| | | vo.setInputRevisionFlag(btmItem.revInput); |
| | | vo.setDelimiter(btmItem.delimiter); |
| | | vo.setfName(btmItem.fName); |
| | | if(StringUtils.isNotBlank(vo.getRevisionRuleId()) || vo.isInputRevisionFlag()){ |
| | | vo.setRevisionFlag(true); |
| | | } |
| | | vo.setVersionRule(String.valueOf(btmItem.verRuleName)); |
| | | vo.setSubLifeCycleId(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->{ |
| | |
| | | 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); |
| | | } |
| | | } |
| | |
| | | * @param bizTypes |
| | | * @return |
| | | */ |
| | | @Override |
| | | /* @Override |
| | | public boolean addBtmTypes(List<BizType> bizTypes) { |
| | | VciBaseUtil.alertNotNull(bizTypes,"å建çä¸å¡ç±»å对象å表"); |
| | | bizTypes.stream().forEach(bizType->{ |
| | |
| | | throw new VciBaseException(exceptionMessage); |
| | | } |
| | | }); |
| | | |
| | | return true; |
| | | } |
| | | }*/ |
| | | |
| | | /** |
| | | * æ£æ¥ä¸å¡ç±»ååç§°æ¯å¦åè§ |
| | |
| | | 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[]{"çæ¬åæ´é误ï¼ä¸è½ä»äºçº§å为ä¸çº§æä¸å¯ä¿®è®¢"}); |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®ä¸å¡ç±»ååç§°åå
¶ä¸ç屿§åç§°è·å乿çç´¢å¼ |
| | | * @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); |
| | | 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; |
| | | } |
| | | |
| | | /** |
| | | * 导åºä¸å¡ç±»å |
| | | * name ä¸å¡ç±»ååç§° |
| | | * @return åå»ºç»æ |
| | | */ |
| | | @Override |
| | | public void expData(String names, HttpServletResponse response) throws PLException, IOException { |
| | | String defaultTempFolder = LocalFileUtil.getDefaultTempFolder(); |
| | | //åexcel |
| | | 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); |
| | | //ç§»å¨å±æ§å°é¾æ¥ç±»åæä»¶å¤¹éé¢å» |
| | | cn.hutool.core.io.FileUtil.move(new File(attrPath), new File(defaultTempFolder),true); |
| | | cn.hutool.core.io.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()) { |
| | | //å¢å è§£åçè·¯å¾ï¼çæä»¶è¿å¨æ²¡æ |
| | | 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()) { |
| | | //å¢å è§£åçè·¯å¾ï¼çæä»¶è¿å¨æ²¡æ |
| | | 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ã读åexcelä¸çæ°æ®ï¼ç»æå¯¹è±¡ |
| | | 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䏿¯å¦éå¤ç¨çå¤éMap:ï¼keyï¼å¤é屿§ï¼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()+"ãè¡ï¼name"); |
| | | }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("ä¸å¡ç±»å导å
¥æåï¼"); |
| | | } |
| | | |
| | | /** |
| | |
| | | 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.getName())){ |
| | | 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); |
| | | } |
| | | } |