From 0e6da184ed0a6d511a17e1ed86a470cda71c0f3b Mon Sep 17 00:00:00 2001 From: mitao <2763622819@qq.com> Date: 星期一, 22 九月 2025 16:51:13 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- ruoyi-system/src/main/java/com/ruoyi/system/service/impl/OaApprovalApplicationStorageServiceImpl.java | 393 +++++++++++++++++++++++++------------------------------ 1 files changed, 177 insertions(+), 216 deletions(-) diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/OaApprovalApplicationStorageServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/OaApprovalApplicationStorageServiceImpl.java index 8b336fd..5bfb9d1 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/OaApprovalApplicationStorageServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/OaApprovalApplicationStorageServiceImpl.java @@ -3,6 +3,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.common.basic.PageInfo; import com.ruoyi.common.core.domain.entity.TDept; import com.ruoyi.common.exception.ServiceException; import com.ruoyi.system.dto.asset.OaApprovalApplicationStorageGeneralDTO; @@ -12,29 +13,33 @@ import com.ruoyi.system.emums.ApprovalTypeEnum; import com.ruoyi.system.emums.AssetTypeEnum; import com.ruoyi.system.mapper.OaApprovalApplicationStorageMapper; -import com.ruoyi.system.model.AssetGeneralExt; import com.ruoyi.system.model.AssetMain; -import com.ruoyi.system.model.AssetPropertyExt; -import com.ruoyi.system.model.AssetVehicleExt; import com.ruoyi.system.model.AssetWarehouse; import com.ruoyi.system.model.OaApprovalApplicationStorage; +import com.ruoyi.system.model.OaApprovalApplicationStorageAsset; +import com.ruoyi.system.model.OaApprovalApplicationStorageAssetPropertyExt; +import com.ruoyi.system.model.OaApprovalApplicationStorageAssetVehicleExt; import com.ruoyi.system.model.OaApprovalApplications; import com.ruoyi.system.model.OaApprovalFlowNode; -import com.ruoyi.system.service.AssetGeneralExtService; +import com.ruoyi.system.query.ApprovalDetailQuery; +import com.ruoyi.system.query.OaApprovalApplicationStoragePageQuery; import com.ruoyi.system.service.AssetMainService; import com.ruoyi.system.service.AssetPropertyExtService; import com.ruoyi.system.service.AssetTypeService; import com.ruoyi.system.service.AssetVehicleExtService; import com.ruoyi.system.service.AssetWarehouseService; -import com.ruoyi.system.service.ISysDeptService; -import com.ruoyi.system.service.ISysUserService; +import com.ruoyi.system.service.OaApprovalApplicationStorageAssetPropertyExtService; +import com.ruoyi.system.service.OaApprovalApplicationStorageAssetService; +import com.ruoyi.system.service.OaApprovalApplicationStorageAssetVehicleExtService; import com.ruoyi.system.service.OaApprovalApplicationStorageService; import com.ruoyi.system.service.OaApprovalApplicationsService; import com.ruoyi.system.service.OaApprovalFlowNodeService; import com.ruoyi.system.service.OaApprovalTodoService; import com.ruoyi.system.service.TDeptService; -import com.ruoyi.system.vo.asset.OaApprovalApplicationStoragePageVO; +import com.ruoyi.system.vo.PurchaseListVO; +import com.ruoyi.system.vo.StorageListVO; import com.ruoyi.system.vo.asset.OaApprovalApplicationStorageGeneralDetailVO; +import com.ruoyi.system.vo.asset.OaApprovalApplicationStoragePageVO; import com.ruoyi.system.vo.asset.OaApprovalApplicationStoragePropertyDetailVO; import com.ruoyi.system.vo.asset.OaApprovalApplicationStorageVehicleDetailVO; import lombok.RequiredArgsConstructor; @@ -42,7 +47,6 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; -import java.math.BigDecimal; import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.util.ArrayList; @@ -63,15 +67,15 @@ public class OaApprovalApplicationStorageServiceImpl extends ServiceImpl<OaApprovalApplicationStorageMapper, OaApprovalApplicationStorage> implements OaApprovalApplicationStorageService { private final OaApprovalApplicationsService oaApprovalApplicationsService; + private final OaApprovalApplicationStorageAssetService oaApprovalApplicationStorageAssetService; + private final OaApprovalApplicationStorageAssetPropertyExtService oaApprovalApplicationStorageAssetPropertyExtService; + private final OaApprovalApplicationStorageAssetVehicleExtService oaApprovalApplicationStorageAssetVehicleExtService; private final AssetMainService assetMainService; - private final AssetGeneralExtService assetGeneralExtService; private final AssetPropertyExtService assetPropertyExtService; private final AssetVehicleExtService assetVehicleExtService; private final AssetTypeService assetTypeService; private final OaApprovalFlowNodeService oaApprovalFlowNodeService; private final OaApprovalTodoService oaApprovalTodoService; - private final ISysUserService sysUserService; - private final ISysDeptService sysDeptService; private final TDeptService tDeptService; private final AssetWarehouseService assetWarehouseService; @@ -145,129 +149,98 @@ * 保存通用资产数据 */ private void saveGeneralAssets(List<OaApprovalApplicationStorageGeneralDTO.GeneralAssetItemDTO> assetItems, Integer applicationId, Integer assetTypeId, LocalDate storageDate, OaApprovalApplicationStorageGeneralDTO baseDto) { - List<AssetMain> allAssetMains = new ArrayList<>(); - List<AssetGeneralExt> allGeneralExts = new ArrayList<>(); - + List<OaApprovalApplicationStorageAsset> storageAssets = new ArrayList<>(); + for (OaApprovalApplicationStorageGeneralDTO.GeneralAssetItemDTO item : assetItems) { // 根据数量创建对应数量的资产记录 - int quantity = item.getQuantity().intValue(); - for (int i = 0; i < quantity; i++) { - AssetMain assetMain = buildAssetMain(item, applicationId, assetTypeId, storageDate, baseDto); - assetMain.setAssetMainType(AssetTypeEnum.GENERAL.getCode()); - assetMain.setQuantity(BigDecimal.ONE); // 每个资产记录数量为1 - assetMain.setTotalValue(item.getUnitPrice()); // 总价值等于单价 - allAssetMains.add(assetMain); - } + OaApprovalApplicationStorageAsset assetMain = buildAssetMain(item, applicationId, assetTypeId, storageDate, baseDto); + assetMain.setAssetMainType(AssetTypeEnum.GENERAL.getCode()); + storageAssets.add(assetMain); } - // 批量保存资产主表数据 - assetMainService.saveBatch(allAssetMains); - - // 为每个资产主表记录创建对应的扩展信息 - int assetMainIndex = 0; - for (OaApprovalApplicationStorageGeneralDTO.GeneralAssetItemDTO item : assetItems) { - int quantity = item.getQuantity().intValue(); - for (int i = 0; i < quantity; i++) { - AssetGeneralExt generalExt = buildAssetGeneralExt(item, allAssetMains.get(assetMainIndex).getId()); - allGeneralExts.add(generalExt); - assetMainIndex++; - } - } - - assetGeneralExtService.saveBatch(allGeneralExts); + oaApprovalApplicationStorageAssetService.saveBatch(storageAssets); } /** * 保存房产资产数据 */ private void savePropertyAssets(List<OaApprovalApplicationStoragePropertyDTO.PropertyAssetItemDTO> assetItems, Integer applicationId, Integer assetTypeId, LocalDate storageDate, OaApprovalApplicationStoragePropertyDTO baseDto) { - List<AssetMain> allAssetMains = new ArrayList<>(); - List<AssetPropertyExt> allPropertyExts = new ArrayList<>(); + List<OaApprovalApplicationStorageAsset> allAssetMains = new ArrayList<>(); + List<OaApprovalApplicationStorageAssetPropertyExt> allPropertyExts = new ArrayList<>(); for (OaApprovalApplicationStoragePropertyDTO.PropertyAssetItemDTO item : assetItems) { - // 根据数量创建对应数量的资产记录 - int quantity = item.getQuantity().intValue(); - for (int i = 0; i < quantity; i++) { - AssetMain assetMain = buildAssetMainFromProperty(item, applicationId, assetTypeId, storageDate, baseDto); - assetMain.setAssetMainType(AssetTypeEnum.HOUSE.getCode()); - assetMain.setQuantity(BigDecimal.ONE); // 每个资产记录数量为1 - assetMain.setTotalValue(item.getUnitPrice()); // 总价值等于单价 - allAssetMains.add(assetMain); - } + OaApprovalApplicationStorageAsset assetMain = buildAssetMainFromProperty(item, applicationId, assetTypeId, storageDate, baseDto); + assetMain.setAssetMainType(AssetTypeEnum.HOUSE.getCode()); + allAssetMains.add(assetMain); } // 批量保存资产主表数据 - assetMainService.saveBatch(allAssetMains); + oaApprovalApplicationStorageAssetService.saveBatch(allAssetMains); // 为每个资产主表记录创建对应的扩展信息 - int assetMainIndex = 0; - for (OaApprovalApplicationStoragePropertyDTO.PropertyAssetItemDTO item : assetItems) { - int quantity = item.getQuantity().intValue(); - for (int i = 0; i < quantity; i++) { - AssetPropertyExt propertyExt = buildAssetPropertyExt(item, allAssetMains.get(assetMainIndex).getId()); + for (OaApprovalApplicationStorageAsset allAssetMain : allAssetMains) { + for (OaApprovalApplicationStoragePropertyDTO.PropertyAssetItemDTO item : assetItems) { + OaApprovalApplicationStorageAssetPropertyExt propertyExt = buildAssetPropertyExt(item, allAssetMain.getId()); allPropertyExts.add(propertyExt); - assetMainIndex++; } } - - assetPropertyExtService.saveBatch(allPropertyExts); + oaApprovalApplicationStorageAssetPropertyExtService.saveBatch(allPropertyExts); } /** * 保存车辆资产数据 */ private void saveVehicleAssets(List<OaApprovalApplicationStorageVehicleDTO.VehicleAssetItemDTO> assetItems, Integer applicationId, Integer assetTypeId, LocalDate storageDate, OaApprovalApplicationStorageVehicleDTO baseDto) { - List<AssetMain> allAssetMains = new ArrayList<>(); - List<AssetVehicleExt> allVehicleExts = new ArrayList<>(); - + List<OaApprovalApplicationStorageAsset> allAssetMains = new ArrayList<>(); + List<OaApprovalApplicationStorageAssetVehicleExt> allVehicleExts = new ArrayList<>(); + for (OaApprovalApplicationStorageVehicleDTO.VehicleAssetItemDTO item : assetItems) { - // 根据数量创建对应数量的资产记录 - int quantity = item.getQuantity().intValue(); - for (int i = 0; i < quantity; i++) { - AssetMain assetMain = buildAssetMainFromVehicle(item, applicationId, assetTypeId, storageDate, baseDto); - assetMain.setAssetMainType(AssetTypeEnum.VEHICLE.getCode()); - assetMain.setQuantity(BigDecimal.ONE); // 每个资产记录数量为1 - assetMain.setTotalValue(item.getUnitPrice()); // 总价值等于单价 - allAssetMains.add(assetMain); - } + OaApprovalApplicationStorageAsset assetMain = buildAssetMainFromVehicle(item, applicationId, assetTypeId, storageDate, baseDto); + assetMain.setAssetMainType(AssetTypeEnum.VEHICLE.getCode()); + allAssetMains.add(assetMain); } // 批量保存资产主表数据 - assetMainService.saveBatch(allAssetMains); + oaApprovalApplicationStorageAssetService.saveBatch(allAssetMains); // 为每个资产主表记录创建对应的扩展信息 - int assetMainIndex = 0; - for (OaApprovalApplicationStorageVehicleDTO.VehicleAssetItemDTO item : assetItems) { - int quantity = item.getQuantity().intValue(); - for (int i = 0; i < quantity; i++) { - AssetVehicleExt vehicleExt = buildAssetVehicleExt(item, allAssetMains.get(assetMainIndex).getId()); + for (OaApprovalApplicationStorageAsset allAssetMain : allAssetMains) { + for (OaApprovalApplicationStorageVehicleDTO.VehicleAssetItemDTO item : assetItems) { + OaApprovalApplicationStorageAssetVehicleExt vehicleExt = buildAssetVehicleExt(item, allAssetMain.getId()); allVehicleExts.add(vehicleExt); - assetMainIndex++; } + } - - assetVehicleExtService.saveBatch(allVehicleExts); + oaApprovalApplicationStorageAssetVehicleExtService.saveBatch(allVehicleExts); } /** * 构建通用资产主表数据 */ - private AssetMain buildAssetMain(OaApprovalApplicationStorageGeneralDTO.GeneralAssetItemDTO item, Integer applicationId, Integer assetTypeId, LocalDate storageDate, OaApprovalApplicationStorageGeneralDTO baseDto) { - AssetMain assetMain = new AssetMain(); + private OaApprovalApplicationStorageAsset buildAssetMain(OaApprovalApplicationStorageGeneralDTO.GeneralAssetItemDTO item, Integer applicationId, Integer assetTypeId, LocalDate storageDate, OaApprovalApplicationStorageGeneralDTO baseDto) { + OaApprovalApplicationStorageAsset assetMain = new OaApprovalApplicationStorageAsset(); assetMain.setApprovalApplicationId(applicationId.intValue()); assetMain.setAssetOriginalCode(item.getAssetOriginalCode()); - assetMain.setAssetCode(generateAssetCode(assetTypeId, storageDate)); // 系统生成资产编码 assetMain.setAssetName(item.getAssetName()); + assetMain.setCategory(item.getCategory()); assetMain.setSpecificationModel(item.getSpecificationModel()); assetMain.setAssetTypeId(assetTypeId); assetMain.setMeasurementUnit(item.getMeasurementUnit()); assetMain.setUnitPrice(item.getUnitPrice()); assetMain.setUsefulLife(item.getUsefulLife()); - assetMain.setOwnershipDeptId(item.getOwnershipDeptId()); + // 根据权属单位/部门名称填充ID + if (item.getOwnershipDeptName() != null && !item.getOwnershipDeptName().isEmpty()) { + TDept ownerDept = tDeptService.lambdaQuery() + .eq(TDept::getDeptName, item.getOwnershipDeptName()) + .one(); + if (ownerDept != null) { + assetMain.setOwnershipDeptId(ownerDept.getId()); + } + } assetMain.setUserName(item.getUserName()); // 根据整单 addressType 写入使用部门ID或仓库ID - applyAddressToAssetMain(assetMain, baseDto.getAddressType(), baseDto.getUseDeptName(), baseDto.getWarehouseName(), baseDto.getAddress()); - assetMain.setAssetMainType(baseDto.getAddressType()); + applyUseDeptInfoToAssetMain(assetMain, baseDto.getUseDeptName()); + assetMain.setAssetMainType(AssetTypeEnum.GENERAL.getCode()); assetMain.setAssetStatus(item.getAssetStatus()); assetMain.setRemarks(item.getRemarks()); assetMain.setAccountingStatus(item.getAccountingStatus()); @@ -282,21 +255,28 @@ /** * 构建房产资产主表数据 */ - private AssetMain buildAssetMainFromProperty(OaApprovalApplicationStoragePropertyDTO.PropertyAssetItemDTO item, Integer applicationId, Integer assetTypeId, LocalDate storageDate, OaApprovalApplicationStoragePropertyDTO baseDto) { - AssetMain assetMain = new AssetMain(); + private OaApprovalApplicationStorageAsset buildAssetMainFromProperty(OaApprovalApplicationStoragePropertyDTO.PropertyAssetItemDTO item, Integer applicationId, Integer assetTypeId, LocalDate storageDate, OaApprovalApplicationStoragePropertyDTO baseDto) { + OaApprovalApplicationStorageAsset assetMain = new OaApprovalApplicationStorageAsset(); assetMain.setApprovalApplicationId(applicationId.intValue()); assetMain.setAssetOriginalCode(item.getAssetOriginalCode()); - assetMain.setAssetCode(generateAssetCode(assetTypeId, storageDate)); assetMain.setAssetName(item.getAssetName()); + assetMain.setCategory(item.getCategory()); assetMain.setSpecificationModel(item.getSpecificationModel()); assetMain.setAssetTypeId(assetTypeId); assetMain.setMeasurementUnit(item.getMeasurementUnit()); assetMain.setUnitPrice(item.getUnitPrice()); assetMain.setUsefulLife(item.getUsefulLife()); - assetMain.setOwnershipDeptId(item.getOwnershipDeptId()); + if (item.getOwnershipDeptName() != null && !item.getOwnershipDeptName().isEmpty()) { + TDept ownerDept = tDeptService.lambdaQuery() + .eq(TDept::getDeptName, item.getOwnershipDeptName()) + .one(); + if (ownerDept != null) { + assetMain.setOwnershipDeptId(ownerDept.getId()); + } + } assetMain.setUserName(item.getUserName()); - applyAddressToAssetMain(assetMain, baseDto.getAddressType(), baseDto.getUseDeptName(), baseDto.getWarehouseName(), baseDto.getAddress()); - assetMain.setAssetMainType(baseDto.getAddressType()); + applyUseDeptInfoToAssetMain(assetMain, baseDto.getUseDeptName()); + assetMain.setAssetMainType(AssetTypeEnum.HOUSE.getCode()); assetMain.setAssetStatus(item.getAssetStatus()); assetMain.setRemarks(item.getRemarks()); assetMain.setAccountingStatus(item.getAccountingStatus()); @@ -311,21 +291,28 @@ /** * 构建车辆资产主表数据 */ - private AssetMain buildAssetMainFromVehicle(OaApprovalApplicationStorageVehicleDTO.VehicleAssetItemDTO item, Integer applicationId, Integer assetTypeId, LocalDate storageDate, OaApprovalApplicationStorageVehicleDTO baseDto) { - AssetMain assetMain = new AssetMain(); + private OaApprovalApplicationStorageAsset buildAssetMainFromVehicle(OaApprovalApplicationStorageVehicleDTO.VehicleAssetItemDTO item, Integer applicationId, Integer assetTypeId, LocalDate storageDate, OaApprovalApplicationStorageVehicleDTO baseDto) { + OaApprovalApplicationStorageAsset assetMain = new OaApprovalApplicationStorageAsset(); assetMain.setApprovalApplicationId(applicationId.intValue()); assetMain.setAssetOriginalCode(item.getAssetOriginalCode()); - assetMain.setAssetCode(generateAssetCode(assetTypeId, storageDate)); assetMain.setAssetName(item.getAssetName()); + assetMain.setCategory(item.getCategory()); assetMain.setSpecificationModel(item.getSpecificationModel()); assetMain.setAssetTypeId(assetTypeId); assetMain.setMeasurementUnit(item.getMeasurementUnit()); assetMain.setUnitPrice(item.getUnitPrice()); assetMain.setUsefulLife(item.getUsefulLife()); - assetMain.setOwnershipDeptId(item.getOwnershipDeptId()); + if (item.getOwnershipDeptName() != null && !item.getOwnershipDeptName().isEmpty()) { + TDept ownerDept = tDeptService.lambdaQuery() + .eq(TDept::getDeptName, item.getOwnershipDeptName()) + .one(); + if (ownerDept != null) { + assetMain.setOwnershipDeptId(ownerDept.getId()); + } + } assetMain.setUserName(item.getUserName()); - applyAddressToAssetMain(assetMain, baseDto.getAddressType(), baseDto.getUseDeptName(), baseDto.getWarehouseName(), baseDto.getAddress()); - assetMain.setAssetMainType(baseDto.getAddressType()); + applyUseDeptInfoToAssetMain(assetMain, baseDto.getUseDeptName()); + assetMain.setAssetMainType(AssetTypeEnum.VEHICLE.getCode()); assetMain.setAssetStatus(item.getAssetStatus()); assetMain.setRemarks(item.getRemarks()); assetMain.setAccountingStatus(item.getAccountingStatus()); @@ -340,69 +327,25 @@ /** * 按整单地址类型设置资产主表位置信息(使用部门ID或仓库ID或地址) */ - private void applyAddressToAssetMain(AssetMain assetMain, Integer addressType, String useDeptName, String warehouseName, String address) { - if (addressType == null) { - return; - } - switch (addressType) { - case 0: - // 使用部门 - if (useDeptName != null && !useDeptName.isEmpty()) { - TDept dept = tDeptService.lambdaQuery() - .eq(TDept::getDeptName, useDeptName) - .one(); - if (dept != null) { - assetMain.setUseDeptId(dept.getId()); - } - } - break; - case 1: - if (warehouseName != null && !warehouseName.isEmpty()) { - AssetWarehouse warehouse = assetWarehouseService.lambdaQuery() - .eq(AssetWarehouse::getWarehouseName, warehouseName) - .one(); - if (warehouse != null) { - assetMain.setWarehouseId(warehouse.getId()); - assetMain.setWarehouseName(warehouse.getWarehouseName()); - } - } - break; - case 2: - if (address != null && !address.isEmpty()) { - assetMain.setAddress(address); - } - break; - default: - // ignore + private void applyUseDeptInfoToAssetMain(OaApprovalApplicationStorageAsset assetMain, String useDeptName) { + // 使用部门 + if (useDeptName != null && !useDeptName.isEmpty()) { + TDept dept = tDeptService.lambdaQuery() + .eq(TDept::getDeptName, useDeptName) + .one(); + if (dept != null) { + assetMain.setUseDeptId(dept.getId()); + } } } - /** - * 构建通用资产扩展数据 - */ - private AssetGeneralExt buildAssetGeneralExt(OaApprovalApplicationStorageGeneralDTO.GeneralAssetItemDTO item, Integer assetMainId) { - AssetGeneralExt generalExt = new AssetGeneralExt(); - generalExt.setAssetMainId(assetMainId); - generalExt.setSupplierName(item.getSupplierName()); - generalExt.setPurchaseDate(item.getPurchaseDate()); - generalExt.setWarrantyPeriod(item.getWarrantyPeriod()); - generalExt.setWarrantyExpireDate(item.getWarrantyExpireDate()); - generalExt.setDepreciationMethod(item.getDepreciationMethod()); - generalExt.setDepreciationRate(item.getDepreciationRate()); - generalExt.setNetValue(item.getNetValue()); - generalExt.setMaintenanceCycle(item.getMaintenanceCycle()); - generalExt.setLastMaintenanceDate(item.getLastMaintenanceDate()); - generalExt.setNextMaintenanceDate(item.getNextMaintenanceDate()); - generalExt.setDisabled(false); - return generalExt; - } /** * 构建房产资产扩展数据 */ - private AssetPropertyExt buildAssetPropertyExt(OaApprovalApplicationStoragePropertyDTO.PropertyAssetItemDTO item, Integer assetMainId) { - AssetPropertyExt propertyExt = new AssetPropertyExt(); - propertyExt.setAssetMainId(assetMainId); + private OaApprovalApplicationStorageAssetPropertyExt buildAssetPropertyExt(OaApprovalApplicationStoragePropertyDTO.PropertyAssetItemDTO item, Integer assetMainId) { + OaApprovalApplicationStorageAssetPropertyExt propertyExt = new OaApprovalApplicationStorageAssetPropertyExt(); + propertyExt.setStorageAssetId(assetMainId); propertyExt.setRegion(item.getRegion()); propertyExt.setDesignPurpose(item.getDesignPurpose()); propertyExt.setBuilding(item.getBuilding()); @@ -414,7 +357,7 @@ propertyExt.setDetailedLocation(item.getDetailedLocation()); propertyExt.setProvincialPlatformValue(item.getProvincialPlatformValue()); propertyExt.setResettlementSituation(item.getResettlementSituation()); - propertyExt.setIsMortgaged(item.getIsMortgaged()); + propertyExt.setMortgaged(item.getMortgaged()); propertyExt.setTenantName(item.getTenantName()); propertyExt.setRentalAmount(item.getRentalAmount()); propertyExt.setLeaseStartDate(item.getLeaseStartDate()); @@ -426,9 +369,9 @@ /** * 构建车辆资产扩展数据 */ - private AssetVehicleExt buildAssetVehicleExt(OaApprovalApplicationStorageVehicleDTO.VehicleAssetItemDTO item, Integer assetMainId) { - AssetVehicleExt vehicleExt = new AssetVehicleExt(); - vehicleExt.setAssetMainId(assetMainId); + private OaApprovalApplicationStorageAssetVehicleExt buildAssetVehicleExt(OaApprovalApplicationStorageVehicleDTO.VehicleAssetItemDTO item, Integer assetMainId) { + OaApprovalApplicationStorageAssetVehicleExt vehicleExt = new OaApprovalApplicationStorageAssetVehicleExt(); + vehicleExt.setStorageAssetId(assetMainId); vehicleExt.setLicensePlate(item.getLicensePlate()); vehicleExt.setVinCode(item.getVinCode()); vehicleExt.setEngineNumber(item.getEngineNumber()); @@ -472,7 +415,7 @@ applications.setApplicantName(generalDTO.getApplicantName()); applications.setDeptId(generalDTO.getDeptId()); applications.setDeptName(generalDTO.getDeptName()); - applications.setApplicationDate(generalDTO.getApplicationDate()); + applications.setApplicationDate(LocalDate.now()); applications.setApplicationReason(generalDTO.getApplicationReason()); applications.setAttachmentUrl(generalDTO.getAttachmentUrl()); } else if (dto instanceof OaApprovalApplicationStoragePropertyDTO) { @@ -481,7 +424,7 @@ applications.setApplicantName(propertyDTO.getApplicantName()); applications.setDeptId(propertyDTO.getDeptId()); applications.setDeptName(propertyDTO.getDeptName()); - applications.setApplicationDate(propertyDTO.getApplicationDate()); + applications.setApplicationDate(LocalDate.now()); applications.setApplicationReason(propertyDTO.getApplicationReason()); applications.setAttachmentUrl(propertyDTO.getAttachmentUrl()); } else if (dto instanceof OaApprovalApplicationStorageVehicleDTO) { @@ -490,7 +433,7 @@ applications.setApplicantName(vehicleDTO.getApplicantName()); applications.setDeptId(vehicleDTO.getDeptId()); applications.setDeptName(vehicleDTO.getDeptName()); - applications.setApplicationDate(vehicleDTO.getApplicationDate()); + applications.setApplicationDate(LocalDate.now()); applications.setApplicationReason(vehicleDTO.getApplicationReason()); applications.setAttachmentUrl(vehicleDTO.getAttachmentUrl()); } @@ -577,7 +520,7 @@ } @Override - public IPage<OaApprovalApplicationStoragePageVO> getPageList(com.ruoyi.system.query.OaApprovalApplicationStoragePageQuery pageQuery) { + public IPage<OaApprovalApplicationStoragePageVO> getPageList(OaApprovalApplicationStoragePageQuery pageQuery) { Page<OaApprovalApplicationStoragePageVO> page = new Page<>(pageQuery.getPageNum(), pageQuery.getPageSize()); return this.baseMapper.selectApplicationStoragePage(page, pageQuery); } @@ -596,16 +539,18 @@ OaApprovalApplicationStorageGeneralDetailVO vo = new OaApprovalApplicationStorageGeneralDetailVO(); fillBaseFields(vo, app, storage); - List<AssetMain> mains = assetMainService.lambdaQuery() - .eq(AssetMain::getApprovalApplicationId, app.getId()) - .eq(AssetMain::getAssetTypeId, storage.getAssetTypeId()) + List<OaApprovalApplicationStorageAsset> mains = oaApprovalApplicationStorageAssetService.lambdaQuery() + .eq(OaApprovalApplicationStorageAsset::getApprovalApplicationId, app.getId()) + .eq(OaApprovalApplicationStorageAsset::getAssetTypeId, storage.getAssetTypeId()) .list(); setAddressInfo(vo, mains); if (!CollectionUtils.isEmpty(mains)) { - List<Integer> mainIds = mains.stream().map(AssetMain::getId).collect(Collectors.toList()); - List<AssetGeneralExt> exts = assetGeneralExtService.lambdaQuery().in(AssetGeneralExt::getAssetMainId, mainIds).list(); - Map<Integer, AssetGeneralExt> extMap = exts.stream().collect(Collectors.toMap(AssetGeneralExt::getAssetMainId, e -> e)); + // 批量查询权属部门,避免循环内查询 + List<Integer> ownerIds = mains.stream().map(OaApprovalApplicationStorageAsset::getOwnershipDeptId) + .filter(id -> id != null).distinct().collect(Collectors.toList()); + Map<Integer, TDept> ownerDeptMap = ownerIds.isEmpty() ? java.util.Collections.emptyMap() + : tDeptService.listByIds(ownerIds).stream().collect(Collectors.toMap(TDept::getId, d -> d)); List<OaApprovalApplicationStorageGeneralDetailVO.GeneralAssetItemVO> items = mains.stream().map(m -> { OaApprovalApplicationStorageGeneralDetailVO.GeneralAssetItemVO item = new OaApprovalApplicationStorageGeneralDetailVO.GeneralAssetItemVO(); @@ -616,7 +561,10 @@ item.setQuantity(m.getQuantity()); item.setUnitPrice(m.getUnitPrice()); item.setUsefulLife(m.getUsefulLife()); - item.setOwnershipDeptId(m.getOwnershipDeptId()); + if (m.getOwnershipDeptId() != null) { + TDept dept = ownerDeptMap.get(m.getOwnershipDeptId()); + item.setOwnerShipDeptName(dept != null ? dept.getDeptName() : null); + } item.setUserName(m.getUserName()); item.setAssetStatus(m.getAssetStatus()); item.setRemarks(m.getRemarks()); @@ -625,19 +573,6 @@ item.setAccountingVoucherNo(m.getAccountingVoucherNo()); item.setAccountingSubject(m.getAccountingSubject()); item.setAccountingAmount(m.getAccountingAmount()); - AssetGeneralExt ext = extMap.get(m.getId()); - if (ext != null) { - item.setSupplierName(ext.getSupplierName()); - item.setPurchaseDate(ext.getPurchaseDate()); - item.setWarrantyPeriod(ext.getWarrantyPeriod()); - item.setWarrantyExpireDate(ext.getWarrantyExpireDate()); - item.setDepreciationMethod(ext.getDepreciationMethod()); - item.setDepreciationRate(ext.getDepreciationRate()); - item.setNetValue(ext.getNetValue()); - item.setMaintenanceCycle(ext.getMaintenanceCycle()); - item.setLastMaintenanceDate(ext.getLastMaintenanceDate()); - item.setNextMaintenanceDate(ext.getNextMaintenanceDate()); - } return item; }).collect(Collectors.toList()); vo.setAssetItems(items); @@ -659,16 +594,21 @@ OaApprovalApplicationStoragePropertyDetailVO vo = new OaApprovalApplicationStoragePropertyDetailVO(); fillBaseFields(vo, app, storage); - List<AssetMain> mains = assetMainService.lambdaQuery() - .eq(AssetMain::getApprovalApplicationId, app.getId()) - .eq(AssetMain::getAssetTypeId, storage.getAssetTypeId()) + List<OaApprovalApplicationStorageAsset> mains = oaApprovalApplicationStorageAssetService.lambdaQuery() + .eq(OaApprovalApplicationStorageAsset::getApprovalApplicationId, app.getId()) + .eq(OaApprovalApplicationStorageAsset::getAssetTypeId, storage.getAssetTypeId()) .list(); setAddressInfo(vo, mains); if (!CollectionUtils.isEmpty(mains)) { - List<Integer> mainIds = mains.stream().map(AssetMain::getId).collect(Collectors.toList()); - List<AssetPropertyExt> exts = assetPropertyExtService.lambdaQuery().in(AssetPropertyExt::getAssetMainId, mainIds).list(); - Map<Integer, AssetPropertyExt> extMap = exts.stream().collect(Collectors.toMap(AssetPropertyExt::getAssetMainId, e -> e)); + List<Integer> mainIds = mains.stream().map(OaApprovalApplicationStorageAsset::getId).collect(Collectors.toList()); + List<OaApprovalApplicationStorageAssetPropertyExt> exts = oaApprovalApplicationStorageAssetPropertyExtService.lambdaQuery().in(OaApprovalApplicationStorageAssetPropertyExt::getStorageAssetId, mainIds).list(); + Map<Integer, OaApprovalApplicationStorageAssetPropertyExt> extMap = exts.stream().collect(Collectors.toMap(OaApprovalApplicationStorageAssetPropertyExt::getStorageAssetId, e -> e)); + // 批量查询权属部门 + List<Integer> ownerIds = mains.stream().map(OaApprovalApplicationStorageAsset::getOwnershipDeptId) + .filter(id -> id != null).distinct().collect(Collectors.toList()); + Map<Integer, TDept> ownerDeptMap = ownerIds.isEmpty() ? java.util.Collections.emptyMap() + : tDeptService.listByIds(ownerIds).stream().collect(Collectors.toMap(TDept::getId, d -> d)); List<OaApprovalApplicationStoragePropertyDetailVO.PropertyAssetItemVO> items = mains.stream().map(m -> { OaApprovalApplicationStoragePropertyDetailVO.PropertyAssetItemVO item = new OaApprovalApplicationStoragePropertyDetailVO.PropertyAssetItemVO(); @@ -679,7 +619,10 @@ item.setQuantity(m.getQuantity()); item.setUnitPrice(m.getUnitPrice()); item.setUsefulLife(m.getUsefulLife()); - item.setOwnershipDeptId(m.getOwnershipDeptId()); + if (m.getOwnershipDeptId() != null) { + TDept dept = ownerDeptMap.get(m.getOwnershipDeptId()); + item.setOwnerShipDeptName(dept != null ? dept.getDeptName() : null); + } item.setUserName(m.getUserName()); item.setAssetStatus(m.getAssetStatus()); item.setRemarks(m.getRemarks()); @@ -688,7 +631,7 @@ item.setAccountingVoucherNo(m.getAccountingVoucherNo()); item.setAccountingSubject(m.getAccountingSubject()); item.setAccountingAmount(m.getAccountingAmount()); - AssetPropertyExt ext = extMap.get(m.getId()); + OaApprovalApplicationStorageAssetPropertyExt ext = extMap.get(m.getId()); if (ext != null) { item.setRegion(ext.getRegion()); item.setDesignPurpose(ext.getDesignPurpose()); @@ -701,7 +644,7 @@ item.setDetailedLocation(ext.getDetailedLocation()); item.setProvincialPlatformValue(ext.getProvincialPlatformValue()); item.setResettlementSituation(ext.getResettlementSituation()); - item.setIsMortgaged(ext.getIsMortgaged()); + item.setMortgaged(ext.getMortgaged()); item.setTenantName(ext.getTenantName()); item.setRentalAmount(ext.getRentalAmount()); item.setLeaseStartDate(ext.getLeaseStartDate()); @@ -728,16 +671,21 @@ OaApprovalApplicationStorageVehicleDetailVO vo = new OaApprovalApplicationStorageVehicleDetailVO(); fillBaseFields(vo, app, storage); - List<AssetMain> mains = assetMainService.lambdaQuery() - .eq(AssetMain::getApprovalApplicationId, app.getId()) - .eq(AssetMain::getAssetTypeId, storage.getAssetTypeId()) + List<OaApprovalApplicationStorageAsset> mains = oaApprovalApplicationStorageAssetService.lambdaQuery() + .eq(OaApprovalApplicationStorageAsset::getApprovalApplicationId, app.getId()) + .eq(OaApprovalApplicationStorageAsset::getAssetTypeId, storage.getAssetTypeId()) .list(); setAddressInfo(vo, mains); if (!CollectionUtils.isEmpty(mains)) { - List<Integer> mainIds = mains.stream().map(AssetMain::getId).collect(Collectors.toList()); - List<AssetVehicleExt> exts = assetVehicleExtService.lambdaQuery().in(AssetVehicleExt::getAssetMainId, mainIds).list(); - Map<Integer, AssetVehicleExt> extMap = exts.stream().collect(Collectors.toMap(AssetVehicleExt::getAssetMainId, e -> e)); + List<Integer> mainIds = mains.stream().map(OaApprovalApplicationStorageAsset::getId).collect(Collectors.toList()); + List<OaApprovalApplicationStorageAssetVehicleExt> exts = oaApprovalApplicationStorageAssetVehicleExtService.lambdaQuery().in(OaApprovalApplicationStorageAssetVehicleExt::getStorageAssetId, mainIds).list(); + Map<Integer, OaApprovalApplicationStorageAssetVehicleExt> extMap = exts.stream().collect(Collectors.toMap(OaApprovalApplicationStorageAssetVehicleExt::getStorageAssetId, e -> e)); + // 批量查询权属部门 + List<Integer> ownerIds = mains.stream().map(OaApprovalApplicationStorageAsset::getOwnershipDeptId) + .filter(id -> id != null).distinct().collect(Collectors.toList()); + Map<Integer, TDept> ownerDeptMap = ownerIds.isEmpty() ? java.util.Collections.emptyMap() + : tDeptService.listByIds(ownerIds).stream().collect(Collectors.toMap(TDept::getId, d -> d)); List<OaApprovalApplicationStorageVehicleDetailVO.VehicleAssetItemVO> items = mains.stream().map(m -> { OaApprovalApplicationStorageVehicleDetailVO.VehicleAssetItemVO item = new OaApprovalApplicationStorageVehicleDetailVO.VehicleAssetItemVO(); @@ -748,7 +696,10 @@ item.setQuantity(m.getQuantity()); item.setUnitPrice(m.getUnitPrice()); item.setUsefulLife(m.getUsefulLife()); - item.setOwnershipDeptId(m.getOwnershipDeptId()); + if (m.getOwnershipDeptId() != null) { + TDept dept = ownerDeptMap.get(m.getOwnershipDeptId()); + item.setOwnerShipDeptName(dept != null ? dept.getDeptName() : null); + } item.setUserName(m.getUserName()); item.setAssetStatus(m.getAssetStatus()); item.setRemarks(m.getRemarks()); @@ -757,7 +708,7 @@ item.setAccountingVoucherNo(m.getAccountingVoucherNo()); item.setAccountingSubject(m.getAccountingSubject()); item.setAccountingAmount(m.getAccountingAmount()); - AssetVehicleExt ext = extMap.get(m.getId()); + OaApprovalApplicationStorageAssetVehicleExt ext = extMap.get(m.getId()); if (ext != null) { item.setLicensePlate(ext.getLicensePlate()); item.setVinCode(ext.getVinCode()); @@ -818,46 +769,56 @@ } } - private void setAddressInfo(Object vo, List<AssetMain> mains) { + private void setAddressInfo(Object vo, List<OaApprovalApplicationStorageAsset> mains) { if (CollectionUtils.isEmpty(mains)) { return; } - AssetMain sample = mains.get(0); + OaApprovalApplicationStorageAsset sample = mains.get(0); Integer addressType = null; String useDeptName = null; String warehouseName = null; String address = null; - if (sample.getUseDeptId() != null) { - addressType = 0; - TDept dept = tDeptService.getById(sample.getUseDeptId()); - useDeptName = dept != null ? dept.getDeptName() : null; - } else if (sample.getWarehouseId() != null) { - addressType = 1; - AssetWarehouse wh = assetWarehouseService.getById(sample.getWarehouseId()); - warehouseName = wh != null ? wh.getWarehouseName() : null; - } else if (sample.getAddress() != null && !sample.getAddress().isEmpty()) { - addressType = 2; - address = sample.getAddress(); + switch (sample.getAddressType()) { + case 0: + TDept dept = tDeptService.getById(sample.getUseDeptId()); + useDeptName = dept != null ? dept.getDeptName() : null; + break; + case 1: + AssetWarehouse wh = assetWarehouseService.getById(sample.getWarehouseId()); + warehouseName = wh != null ? wh.getWarehouseName() : null; + break; + case 2: + break; + default: + return; } if (vo instanceof OaApprovalApplicationStorageGeneralDetailVO) { OaApprovalApplicationStorageGeneralDetailVO v = (OaApprovalApplicationStorageGeneralDetailVO) vo; - v.setAddressType(addressType); + v.setAddressType(sample.getAddressType()); v.setUseDeptName(useDeptName); v.setWarehouseName(warehouseName); - v.setAddress(address); + v.setAddress(sample.getAddress()); } else if (vo instanceof OaApprovalApplicationStoragePropertyDetailVO) { OaApprovalApplicationStoragePropertyDetailVO v = (OaApprovalApplicationStoragePropertyDetailVO) vo; - v.setAddressType(addressType); + v.setAddressType(sample.getAddressType()); v.setUseDeptName(useDeptName); v.setWarehouseName(warehouseName); - v.setAddress(address); + v.setAddress(sample.getAddress()); } else if (vo instanceof OaApprovalApplicationStorageVehicleDetailVO) { OaApprovalApplicationStorageVehicleDetailVO v = (OaApprovalApplicationStorageVehicleDetailVO) vo; - v.setAddressType(addressType); + v.setAddressType(sample.getAddressType()); v.setUseDeptName(useDeptName); v.setWarehouseName(warehouseName); - v.setAddress(address); + v.setAddress(sample.getAddress()); } } + + @Override + public PageInfo<StorageListVO> pageList(ApprovalDetailQuery query) { + PageInfo<StorageListVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); + List<StorageListVO> list = this.baseMapper.pageList(query,pageInfo); + pageInfo.setRecords(list); + return pageInfo; + } } -- Gitblit v1.7.1