From d0ae279ff3b83358d1c07f4481a041c4ad335026 Mon Sep 17 00:00:00 2001 From: dangsn <dangsn@chicecm.com> Date: 星期二, 03 十二月 2024 11:57:38 +0800 Subject: [PATCH] 提取业务系统使用的功能,独立出一个单独的模块 --- Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsLinkTypeServiceImpl.java | 160 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 143 insertions(+), 17 deletions(-) diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsLinkTypeServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsLinkTypeServiceImpl.java index 58a4810..edf8025 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsLinkTypeServiceImpl.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsLinkTypeServiceImpl.java @@ -4,18 +4,17 @@ import cn.hutool.core.util.ZipUtil; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; +import com.vci.common.qt.object.QTConstants; 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.ltm.LinkType; -import com.vci.corba.omd.ltm.LinkTypeServicePrx; -import com.vci.dto.OsAttributeDTO; -import com.vci.omd.constants.LinkTypeConstants; +import com.vci.model.OsLinkTypeDO; +import com.vci.omd.constants.AttributeConstants; import com.vci.omd.utils.ObjectTool; import com.vci.pagemodel.*; -import com.vci.po.OsAttributePO; import com.vci.po.OsLinkTypePO; import com.vci.starter.poi.bo.ReadExcelOption; import com.vci.starter.poi.bo.WriteExcelData; @@ -23,19 +22,16 @@ 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.ResultCodeEnum; import com.vci.starter.web.enumpck.VciFieldTypeEnum; import com.vci.starter.web.exception.VciBaseException; import com.vci.starter.web.pagemodel.BaseQueryObject; import com.vci.starter.web.pagemodel.BaseResult; import com.vci.starter.web.pagemodel.DataGrid; import com.vci.starter.web.util.*; -import com.vci.model.OsLinkTypeDO; +import com.vci.starter.web.util.Lcm.Func; import com.vci.web.service.*; -import com.vci.web.util.Func; import com.vci.web.util.PlatformClientUtil; import com.vci.web.util.WebUtil; -import javafx.scene.shape.HLineTo; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -46,7 +42,10 @@ import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; -import java.io.*; +import java.io.File; +import java.io.IOException; +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.*; import java.util.stream.Collectors; @@ -192,7 +191,7 @@ List<OsLinkTypeAttributeVO> linkTypeAttributeVOS = new ArrayList<>(); Optional.ofNullable(attributeVOS).orElseGet(()->new ArrayList<>()).stream().forEach(attributeVO->{ OsLinkTypeAttributeVO linkTypeAttributeVO = new OsLinkTypeAttributeVO(); - BeanUtil.convert(attributeVO,linkTypeAttributeVO); + BeanUtilForVCI.convert(attributeVO,linkTypeAttributeVO); linkTypeAttributeVO.setPkLinkType(vo.getOid()); if(StringUtils.isNotBlank(attributeVO.getBtmTypeId())){ linkTypeAttributeVO.setReferFlag(true); @@ -237,11 +236,12 @@ * @return 閾炬帴绫诲瀷 */ @Override - public OsLinkTypeVO getLinkTypeById(String id) { + public OsLinkTypeVO getLinkTypeById(String id) throws PLException { if(StringUtils.isBlank(id)){ return null; } - return self.selectAllLinkMap().getOrDefault(id.toLowerCase(),null); + LinkType linkType = platformClientUtil.getLinkTypeService().getLinkType(id); + return this.linkTypeDO2VO(linkType); } /** @@ -251,7 +251,7 @@ * @return 閾炬帴绫诲瀷鐨勫睘鎬� */ @Override - public List<OsLinkTypeAttributeVO> listAttributeByLinkId(String linkTypeId) { + public List<OsLinkTypeAttributeVO> listAttributeByLinkId(String linkTypeId) throws PLException { OsLinkTypeVO linkTypeVO = getLinkTypeById(linkTypeId); return linkTypeVO.getAttributes(); } @@ -315,7 +315,7 @@ } OsBtmTypeAttributeVO attributeVO = attributeVOMap.getOrDefault(attrId.toLowerCase(Locale.ROOT), null); if(attributeVO!=null){ - String vtType = attributeVO.getAttrDataType(); + String vtType = attributeVO.getAttributeDataType(); String attrType = ""; VciFieldTypeEnum fieldTypeEnum = VciFieldTypeEnum.forValue(vtType); if(fieldTypeEnum == null) { @@ -607,7 +607,7 @@ return BaseResult.fail(FrameWorkLangCodeConstant.IMPORT_FAIL, new String[]{"娌℃湁瀵煎叆鐨勫睘鎬ф枃浠躲�傚鍏ョ粓姝紒"}); } } - BaseResult baseResult = attributeService.importAttributes(attrExcel); + BaseResult baseResult = attributeService.importAttributes(attrExcel,true); if(!baseResult.isSuccess()){ //鍒犻櫎涓婁紶鐨勬枃浠跺す FileUtil.del(defaultTempFolder + File.separator); @@ -644,7 +644,7 @@ }else if(!osLinkTypePO.getName().matches("^[A-Za-z]+$")){ throw new VciBaseException("绗��"+osLinkTypePO.getRowIndex()+"銆戣锛岄摼鎺ョ被鍨嬪悕绉板彧鑳戒负鑻辨枃瀛楁瘝"); }else if(excelReapeat.containsKey(osLinkTypePO.getName())){//灞炴�у悕琛ㄦ牸涓垽閲� - throw new VciBaseException("绗��"+excelReapeat.get(osLinkTypePO.getName())+"銆戣鍜岀銆�"+osLinkTypePO.getRowIndex()+"銆戣鏁版嵁锛屽睘鎬у悕閲嶅"); + throw new VciBaseException("绗��"+excelReapeat.get(osLinkTypePO.getName())+"銆戣鍜岀銆�"+osLinkTypePO.getRowIndex()+"銆戣鏁版嵁锛岄摼鎺ョ被鍨嬪悕閲嶅"); } try { LinkType historyLink = platformClientUtil.getLinkTypeService().getLinkType(osLinkTypePO.getName()); @@ -683,7 +683,7 @@ }); }catch (Exception e){ if(logger.isErrorEnabled()){ - logger.error("璇诲彇excel鍐呭鏃舵垨淇濆瓨鐢ㄦ埛淇℃伅鏃跺嚭鐜颁簡閿欒锛屽叿浣撳師鍥狅細",VciBaseUtil.getExceptionMessage(e)); + logger.error("璇诲彇excel鍐呭鏃舵垨淇濆瓨閾炬帴绫诲瀷淇℃伅鏃跺嚭鐜颁簡閿欒锛屽叿浣撳師鍥狅細",VciBaseUtil.getExceptionMessage(e)); } e.printStackTrace(); return BaseResult.fail(VciBaseUtil.getExceptionMessage(e),new String[]{},e); @@ -691,6 +691,87 @@ //鍒犻櫎涓婁紶鐨勬枃浠跺す FileUtil.del(defaultTempFolder + File.separator); return BaseResult.success("閾炬帴绫诲瀷瀵煎叆鎴愬姛锛�"); + } + /** + * 鑾峰彇閾炬帴绫诲瀷鍖呭惈鐨勫睘鎬� + * @param name 閾炬帴绫诲瀷鐨勭紪鍙� + * @return 灞炴�х殑淇℃伅 + */ + @Override + public List<OsLinkTypeAttributeVO> getAllAttributeByLink(String name) throws PLException, ParseException { + AttributeDef[] attributes = platformClientUtil.getLinkTypeService().getAttributes(name); + Map<String, AttributeDef> collect = Arrays.stream(platformClientUtil.getLinkTypeService().getSysAttributeDefs()) + .collect(Collectors.toMap(str -> str.name, str -> str)); + + List<OsLinkTypeAttributeVO> links = new ArrayList<>(); + String[] sysAttibutes = { "OID", "Creator", "CreateTime", "LastModifier", "LASTMODIFYTIME", "F_OID", + "F_REVISIONOID", "F_NAMEOID", "F_BtwName", "T_OID", "T_REVISIONOID", "T_NAMEOID", "T_BtwName", "TS" }; + for (String sysname : sysAttibutes) { + AttributeDef sysAttributeDef = collect.get(sysname.toLowerCase()); + OsLinkTypeAttributeVO vo = new OsLinkTypeAttributeVO(); + vo.setOid(sysAttributeDef.oid); + vo.setAttrDataType(sysAttributeDef.vtDataType); + vo.setPkLinkType(name); + vo.setCreateTime(new Date(sysAttributeDef.createTime)); + vo.setCreator(sysAttributeDef.creator); + vo.setDefaultValue(sysAttributeDef.defValue); + vo.setDescription(sysAttributeDef.description); + vo.setRange(sysAttributeDef.rage); + vo.setId(sysname); + vo.setName(sysAttributeDef.label); + vo.setLastModifier(sysAttributeDef.modifier); + vo.setLastModifyTime(new Date(sysAttributeDef.modifyTime)); + links.add(vo); + } + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + for (AttributeDef attribute : attributes) { + OsLinkTypeAttributeVO vo = new OsLinkTypeAttributeVO(); + vo.setOid(attribute.oid); + vo.setAttrDataType(attribute.vtDataType); + vo.setPkLinkType(name); + vo.setCreateTime(new Date(attribute.createTime)); + vo.setCreator(attribute.creator); + vo.setDefaultValue(attribute.defValue); + vo.setDescription(attribute.description); + vo.setRange(attribute.rage); + vo.setId(attribute.name); + vo.setName(attribute.label); + vo.setTs(formatter.parse(attribute.ts)); + vo.setLastModifier(attribute.modifier); + vo.setOwner(attribute.creator); + vo.setLastModifyTime(new Date(attribute.modifyTime)); + String maxLength = AttributeConstants.getOtherValueByType(attribute.other, AttributeConstants.LENGTH); + if(StringUtils.isNotBlank(maxLength)){ + vo.setAttributeLength(Integer.valueOf(maxLength)); + } + links.add(vo); + } + return links; + } + /** + * 鑾峰彇璁剧疆鎺掑簭瀛楁鐨勬帓搴忓瓧娈� + * @param linkType 閾炬帴绫诲瀷鐨勭紪鍙� + * @param btmType 涓氬姟绫诲瀷鐨勭紪鍙� + * @param direction 姝�/鍙嶅悜 + * @return 灞炴�х殑淇℃伅 + */ + @Override + public List<String> getAllOrderbyAttributeByLink(String linkType, String btmType, String direction) throws PLException, ParseException { + List<String> abNames = new ArrayList<>(Arrays.asList("OID", "Creator", "CreateTime", "LastModifier", "LASTMODIFYTIME", "F_OID", + "F_REVISIONOID", "F_NAMEOID", "F_BtwName", "T_OID", "T_REVISIONOID", "T_NAMEOID", "T_BtwName", "TS" )); + AttributeDef[] attributes = platformClientUtil.getLinkTypeService().getAttributes(linkType); + for (AttributeDef attribute : attributes) { + abNames.add(String.valueOf(attribute.name)); + } + String wrapper = "T_OID."; + if(direction.equals(QTConstants.DIRECTION_OPPOSITE)){ + wrapper = "F_OID."; + } + List<OsBtmTypeAttributeVO> bizTypeQTDs = btmService.getBizTypeQTDs(btmType); + for (OsBtmTypeAttributeVO bizTypeQTD : bizTypeQTDs) { + abNames.add(wrapper + bizTypeQTD.getId()); + } + return abNames; } /** @@ -928,4 +1009,49 @@ return null; } + /** + * 鑾峰彇浣跨敤璇ヤ笟鍔$被鍨嬬殑閾炬帴绫诲瀷鍚� + * @param btmName 涓氬姟绫诲瀷鍚嶇О + * @return + */ + @Override + public List<String> getUsedBtmLinkList(String btmName) { + try { + List<String> list = new ArrayList<String>(); + LinkType[] linkTypes = platformClientUtil.getLinkTypeService().getLinkTypes(); + for(int i = 0; i < linkTypes.length; i++){ + LinkType linkType = linkTypes[i]; + if(this.containsBtm(linkType, btmName)){ + list.add(linkType.name); + } + } + return list; + } catch (PLException e) { + e.printStackTrace(); + } + return null; + } + + /** + * 鎸囧畾鐨勯摼鎺ョ被鍨嬫槸鍚︿娇鐢ㄤ簡鎸囧畾鐨勪笟鍔$被鍨� + * @param link + * @param btmName + * @return + */ + private boolean containsBtm(LinkType link, String btmName){ + String[] btms = link.btmItemsFrom; + for(int i = 0; i < btms.length; i++){ + if(btmName.equalsIgnoreCase(btms[i])){ + return true; + } + } + btms = link.btmItemsTo; + for(int i = 0; i < btms.length; i++){ + if(btmName.equalsIgnoreCase(btms[i])){ + return true; + } + } + return false; + } + } -- Gitblit v1.9.3