| | |
| | | import com.ruoyi.system.model.OaApprovalApplicationStorage; |
| | | import com.ruoyi.system.model.OaApprovalApplications; |
| | | import com.ruoyi.system.model.OaApprovalFlowNode; |
| | | import com.ruoyi.system.query.OaApprovalApplicationStoragePageQuery; |
| | | import com.ruoyi.system.service.AssetGeneralExtService; |
| | | import com.ruoyi.system.service.AssetMainService; |
| | | import com.ruoyi.system.service.AssetPropertyExtService; |
| | |
| | | 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.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; |
| | |
| | | */ |
| | | 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<>(); |
| | | |
| | | |
| | | for (OaApprovalApplicationStorageGeneralDTO.GeneralAssetItemDTO item : assetItems) { |
| | | // 根据数量创建对应数量的资产记录 |
| | | int quantity = item.getQuantity().intValue(); |
| | |
| | | |
| | | // 批量保存资产主表数据 |
| | | 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); |
| | | } |
| | | |
| | | /** |
| | |
| | | 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.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()); |
| | |
| | | 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()); |
| | |
| | | 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; |
| | | } |
| | |
| | | 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()); |
| | |
| | | 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) { |
| | |
| | | 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) { |
| | |
| | | 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()); |
| | | } |
| | |
| | | } |
| | | |
| | | @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); |
| | | } |
| | |
| | | |
| | | 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(AssetMain::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(); |
| | |
| | | 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()); |
| | |
| | | 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); |
| | |
| | | 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> ownerIds = mains.stream().map(AssetMain::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(); |
| | |
| | | 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()); |
| | |
| | | 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()); |
| | |
| | | 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> ownerIds = mains.stream().map(AssetMain::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(); |
| | |
| | | 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()); |