From 7c3331d7be7c10059cc82586852d562f566a5087 Mon Sep 17 00:00:00 2001 From: mitao <2763622819@qq.com> Date: 星期五, 19 九月 2025 14:08:11 +0800 Subject: [PATCH] 资产管理-资产入库列表详情、撤销接口 --- ruoyi-system/src/main/java/com/ruoyi/system/service/impl/OaApprovalApplicationStorageServiceImpl.java | 284 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 284 insertions(+), 0 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 f56632b..8b336fd 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 @@ -34,6 +34,9 @@ import com.ruoyi.system.service.OaApprovalTodoService; import com.ruoyi.system.service.TDeptService; import com.ruoyi.system.vo.asset.OaApprovalApplicationStoragePageVO; +import com.ruoyi.system.vo.asset.OaApprovalApplicationStorageGeneralDetailVO; +import com.ruoyi.system.vo.asset.OaApprovalApplicationStoragePropertyDetailVO; +import com.ruoyi.system.vo.asset.OaApprovalApplicationStorageVehicleDetailVO; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -44,6 +47,8 @@ import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; /** * <p> @@ -576,4 +581,283 @@ Page<OaApprovalApplicationStoragePageVO> page = new Page<>(pageQuery.getPageNum(), pageQuery.getPageSize()); return this.baseMapper.selectApplicationStoragePage(page, pageQuery); } + + @Override + public OaApprovalApplicationStorageGeneralDetailVO getGeneralDetail(Integer storageId) { + OaApprovalApplicationStorage storage = this.getById(storageId); + if (storage == null) { + throw new ServiceException("入库申请不存在"); + } + OaApprovalApplications app = oaApprovalApplicationsService.getById(storage.getApprovalApplicationId()); + if (app == null) { + throw new ServiceException("审批主记录不存在"); + } + + OaApprovalApplicationStorageGeneralDetailVO vo = new OaApprovalApplicationStorageGeneralDetailVO(); + fillBaseFields(vo, app, storage); + + List<AssetMain> mains = assetMainService.lambdaQuery() + .eq(AssetMain::getApprovalApplicationId, app.getId()) + .eq(AssetMain::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<OaApprovalApplicationStorageGeneralDetailVO.GeneralAssetItemVO> items = mains.stream().map(m -> { + OaApprovalApplicationStorageGeneralDetailVO.GeneralAssetItemVO item = new OaApprovalApplicationStorageGeneralDetailVO.GeneralAssetItemVO(); + item.setAssetOriginalCode(m.getAssetOriginalCode()); + item.setAssetName(m.getAssetName()); + item.setSpecificationModel(m.getSpecificationModel()); + item.setMeasurementUnit(m.getMeasurementUnit()); + item.setQuantity(m.getQuantity()); + item.setUnitPrice(m.getUnitPrice()); + item.setUsefulLife(m.getUsefulLife()); + item.setOwnershipDeptId(m.getOwnershipDeptId()); + item.setUserName(m.getUserName()); + item.setAssetStatus(m.getAssetStatus()); + item.setRemarks(m.getRemarks()); + item.setAccountingStatus(m.getAccountingStatus()); + item.setAccountingDate(m.getAccountingDate()); + 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); + } + return vo; + } + + @Override + public OaApprovalApplicationStoragePropertyDetailVO getPropertyDetail(Integer storageId) { + OaApprovalApplicationStorage storage = this.getById(storageId); + if (storage == null) { + throw new ServiceException("入库申请不存在"); + } + OaApprovalApplications app = oaApprovalApplicationsService.getById(storage.getApprovalApplicationId()); + if (app == null) { + throw new ServiceException("审批主记录不存在"); + } + + OaApprovalApplicationStoragePropertyDetailVO vo = new OaApprovalApplicationStoragePropertyDetailVO(); + fillBaseFields(vo, app, storage); + + List<AssetMain> mains = assetMainService.lambdaQuery() + .eq(AssetMain::getApprovalApplicationId, app.getId()) + .eq(AssetMain::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<OaApprovalApplicationStoragePropertyDetailVO.PropertyAssetItemVO> items = mains.stream().map(m -> { + OaApprovalApplicationStoragePropertyDetailVO.PropertyAssetItemVO item = new OaApprovalApplicationStoragePropertyDetailVO.PropertyAssetItemVO(); + item.setAssetOriginalCode(m.getAssetOriginalCode()); + item.setAssetName(m.getAssetName()); + item.setSpecificationModel(m.getSpecificationModel()); + item.setMeasurementUnit(m.getMeasurementUnit()); + item.setQuantity(m.getQuantity()); + item.setUnitPrice(m.getUnitPrice()); + item.setUsefulLife(m.getUsefulLife()); + item.setOwnershipDeptId(m.getOwnershipDeptId()); + item.setUserName(m.getUserName()); + item.setAssetStatus(m.getAssetStatus()); + item.setRemarks(m.getRemarks()); + item.setAccountingStatus(m.getAccountingStatus()); + item.setAccountingDate(m.getAccountingDate()); + item.setAccountingVoucherNo(m.getAccountingVoucherNo()); + item.setAccountingSubject(m.getAccountingSubject()); + item.setAccountingAmount(m.getAccountingAmount()); + AssetPropertyExt ext = extMap.get(m.getId()); + if (ext != null) { + item.setRegion(ext.getRegion()); + item.setDesignPurpose(ext.getDesignPurpose()); + item.setBuilding(ext.getBuilding()); + item.setRoomNumber(ext.getRoomNumber()); + item.setConstructionArea(ext.getConstructionArea()); + item.setStructureType(ext.getStructureType()); + item.setCertificateNumber(ext.getCertificateNumber()); + item.setCompletionDate(ext.getCompletionDate()); + item.setDetailedLocation(ext.getDetailedLocation()); + item.setProvincialPlatformValue(ext.getProvincialPlatformValue()); + item.setResettlementSituation(ext.getResettlementSituation()); + item.setIsMortgaged(ext.getIsMortgaged()); + item.setTenantName(ext.getTenantName()); + item.setRentalAmount(ext.getRentalAmount()); + item.setLeaseStartDate(ext.getLeaseStartDate()); + item.setLeaseEndDate(ext.getLeaseEndDate()); + } + return item; + }).collect(Collectors.toList()); + vo.setAssetItems(items); + } + return vo; + } + + @Override + public OaApprovalApplicationStorageVehicleDetailVO getVehicleDetail(Integer storageId) { + OaApprovalApplicationStorage storage = this.getById(storageId); + if (storage == null) { + throw new ServiceException("入库申请不存在"); + } + OaApprovalApplications app = oaApprovalApplicationsService.getById(storage.getApprovalApplicationId()); + if (app == null) { + throw new ServiceException("审批主记录不存在"); + } + + OaApprovalApplicationStorageVehicleDetailVO vo = new OaApprovalApplicationStorageVehicleDetailVO(); + fillBaseFields(vo, app, storage); + + List<AssetMain> mains = assetMainService.lambdaQuery() + .eq(AssetMain::getApprovalApplicationId, app.getId()) + .eq(AssetMain::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<OaApprovalApplicationStorageVehicleDetailVO.VehicleAssetItemVO> items = mains.stream().map(m -> { + OaApprovalApplicationStorageVehicleDetailVO.VehicleAssetItemVO item = new OaApprovalApplicationStorageVehicleDetailVO.VehicleAssetItemVO(); + item.setAssetOriginalCode(m.getAssetOriginalCode()); + item.setAssetName(m.getAssetName()); + item.setSpecificationModel(m.getSpecificationModel()); + item.setMeasurementUnit(m.getMeasurementUnit()); + item.setQuantity(m.getQuantity()); + item.setUnitPrice(m.getUnitPrice()); + item.setUsefulLife(m.getUsefulLife()); + item.setOwnershipDeptId(m.getOwnershipDeptId()); + item.setUserName(m.getUserName()); + item.setAssetStatus(m.getAssetStatus()); + item.setRemarks(m.getRemarks()); + item.setAccountingStatus(m.getAccountingStatus()); + item.setAccountingDate(m.getAccountingDate()); + item.setAccountingVoucherNo(m.getAccountingVoucherNo()); + item.setAccountingSubject(m.getAccountingSubject()); + item.setAccountingAmount(m.getAccountingAmount()); + AssetVehicleExt ext = extMap.get(m.getId()); + if (ext != null) { + item.setLicensePlate(ext.getLicensePlate()); + item.setVinCode(ext.getVinCode()); + item.setEngineNumber(ext.getEngineNumber()); + item.setDisplacement(ext.getDisplacement()); + item.setStaffingSituation(ext.getStaffingSituation()); + item.setOrigin(ext.getOrigin()); + item.setAcquisitionDate(ext.getAcquisitionDate()); + item.setPropertyRightForm(ext.getPropertyRightForm()); + } + return item; + }).collect(Collectors.toList()); + vo.setAssetItems(items); + } + return vo; + } + + private void fillBaseFields(Object vo, OaApprovalApplications app, OaApprovalApplicationStorage storage) { + if (vo instanceof OaApprovalApplicationStorageGeneralDetailVO) { + OaApprovalApplicationStorageGeneralDetailVO v = (OaApprovalApplicationStorageGeneralDetailVO) vo; + v.setDeptId(app.getDeptId()); + v.setDeptName(app.getDeptName()); + v.setApplicantUserId(app.getApplicantUserId()); + v.setApplicantName(app.getApplicantName()); + v.setApplicationDate(app.getApplicationDate()); + v.setApplicationReason(app.getApplicationReason()); + v.setAttachmentUrl(app.getAttachmentUrl()); + v.setTitle(storage.getTitle()); + v.setAssetTypeId(storage.getAssetTypeId()); + v.setStorageType(storage.getStorageType()); + v.setStorageTime(storage.getStorageTime()); + } else if (vo instanceof OaApprovalApplicationStoragePropertyDetailVO) { + OaApprovalApplicationStoragePropertyDetailVO v = (OaApprovalApplicationStoragePropertyDetailVO) vo; + v.setDeptId(app.getDeptId()); + v.setDeptName(app.getDeptName()); + v.setApplicantUserId(app.getApplicantUserId()); + v.setApplicantName(app.getApplicantName()); + v.setApplicationDate(app.getApplicationDate()); + v.setApplicationReason(app.getApplicationReason()); + v.setAttachmentUrl(app.getAttachmentUrl()); + v.setTitle(storage.getTitle()); + v.setAssetTypeId(storage.getAssetTypeId()); + v.setStorageType(storage.getStorageType()); + v.setStorageTime(storage.getStorageTime()); + } else if (vo instanceof OaApprovalApplicationStorageVehicleDetailVO) { + OaApprovalApplicationStorageVehicleDetailVO v = (OaApprovalApplicationStorageVehicleDetailVO) vo; + v.setDeptId(app.getDeptId()); + v.setDeptName(app.getDeptName()); + v.setApplicantUserId(app.getApplicantUserId()); + v.setApplicantName(app.getApplicantName()); + v.setApplicationDate(app.getApplicationDate()); + v.setApplicationReason(app.getApplicationReason()); + v.setAttachmentUrl(app.getAttachmentUrl()); + v.setTitle(storage.getTitle()); + v.setAssetTypeId(storage.getAssetTypeId()); + v.setStorageType(storage.getStorageType()); + v.setStorageTime(storage.getStorageTime()); + } + } + + private void setAddressInfo(Object vo, List<AssetMain> mains) { + if (CollectionUtils.isEmpty(mains)) { + return; + } + AssetMain 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(); + } + + if (vo instanceof OaApprovalApplicationStorageGeneralDetailVO) { + OaApprovalApplicationStorageGeneralDetailVO v = (OaApprovalApplicationStorageGeneralDetailVO) vo; + v.setAddressType(addressType); + v.setUseDeptName(useDeptName); + v.setWarehouseName(warehouseName); + v.setAddress(address); + } else if (vo instanceof OaApprovalApplicationStoragePropertyDetailVO) { + OaApprovalApplicationStoragePropertyDetailVO v = (OaApprovalApplicationStoragePropertyDetailVO) vo; + v.setAddressType(addressType); + v.setUseDeptName(useDeptName); + v.setWarehouseName(warehouseName); + v.setAddress(address); + } else if (vo instanceof OaApprovalApplicationStorageVehicleDetailVO) { + OaApprovalApplicationStorageVehicleDetailVO v = (OaApprovalApplicationStorageVehicleDetailVO) vo; + v.setAddressType(addressType); + v.setUseDeptName(useDeptName); + v.setWarehouseName(warehouseName); + v.setAddress(address); + } + } } -- Gitblit v1.7.1