From 0146a1483a3368f75daa6eb03aa42c714943e6b2 Mon Sep 17 00:00:00 2001 From: mitao <2763622819@qq.com> Date: 星期三, 17 九月 2025 14:11:28 +0800 Subject: [PATCH] Merge branch 'feature_asset' --- ruoyi-system/src/main/java/com/ruoyi/system/service/impl/AssetTypeServiceImpl.java | 30 ++++++++++++++++++++++++++++++ 1 files changed, 30 insertions(+), 0 deletions(-) diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/AssetTypeServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/AssetTypeServiceImpl.java index e7e0f4d..583b616 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/AssetTypeServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/AssetTypeServiceImpl.java @@ -233,4 +233,34 @@ } } + @Override + public String getAssetCodePrefix(Integer assetTypeId) { + if (assetTypeId == null) { + throw new ServiceException("资产类型ID不能为空"); + } + + // 查询当前资产类型 + AssetType currentAssetType = this.getById(assetTypeId); + if (currentAssetType == null) { + throw new ServiceException("资产类型不存在"); + } + + String parentTypeCode = ""; + String subTypeCode = currentAssetType.getTypeCode(); + + // 如果是二级分类,需要获取父级分类的简写 + if (currentAssetType.getLevel() == 2 && currentAssetType.getParentId() != null && currentAssetType.getParentId() != 0) { + AssetType parentAssetType = this.getById(currentAssetType.getParentId()); + if (parentAssetType != null) { + parentTypeCode = parentAssetType.getTypeCode(); + } + } else if (currentAssetType.getLevel() == 1) { + // 如果是一级分类,父级简写为空,子类简写就是当前类型简写 + parentTypeCode = currentAssetType.getTypeCode(); + subTypeCode = ""; + } + + return parentTypeCode + subTypeCode; + } + } -- Gitblit v1.7.1