| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.common.core.domain.entity.TDept; |
| | | import com.ruoyi.system.model.AssetType; |
| | | import com.ruoyi.system.service.TDeptService; |
| | | import com.ruoyi.system.vo.asset.AssetMainVO; |
| | | import org.springframework.util.CollectionUtils; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 资产主表 服务实现类 |
| | |
| | | private final OaApprovalApplicationStorageAssetVehicleExtMapper oaApprovalApplicationStorageAssetVehicleExtMapper; |
| | | private final AssetPropertyExtMapper assetPropertyExtMapper; |
| | | private final AssetVehicleExtMapper assetVehicleExtMapper; |
| | | private final TDeptService tDeptService; |
| | | @Override |
| | | public IPage<AssetMainPageVO> getApprovedPageList(AssetMainPageQuery pageQuery) { |
| | | Page<AssetMainPageVO> page = new Page<>(pageQuery.getPageNum(), pageQuery.getPageSize()); |
| | |
| | | public void saveAssetByApprovalApplicationId(Integer approvalApplicationId) { |
| | | // 1. 根据approvalApplicationId查询审批通过的资产列表 |
| | | List<OaApprovalApplicationStorageAsset> storageAssets = oaApprovalApplicationStorageAssetMapper |
| | | .selectList(new QueryWrapper<OaApprovalApplicationStorageAsset>() |
| | | .eq("approval_application_id", approvalApplicationId)); |
| | | .selectList(new LambdaQueryWrapper<OaApprovalApplicationStorageAsset>() |
| | | .eq(OaApprovalApplicationStorageAsset::getApprovalApplicationId, approvalApplicationId)); |
| | | |
| | | if (CollectionUtils.isEmpty(storageAssets)) { |
| | | return; |
| | |
| | | private void savePropertyExtension(Integer storageAssetId, Integer assetMainId) { |
| | | // 查询房产扩展信息 |
| | | OaApprovalApplicationStorageAssetPropertyExt propertyExt = oaApprovalApplicationStorageAssetPropertyExtMapper |
| | | .selectOne(new QueryWrapper<OaApprovalApplicationStorageAssetPropertyExt>() |
| | | .eq("storage_asset_id", storageAssetId)); |
| | | .selectOne(new LambdaQueryWrapper<OaApprovalApplicationStorageAssetPropertyExt>() |
| | | .eq(OaApprovalApplicationStorageAssetPropertyExt::getStorageAssetId, storageAssetId)); |
| | | |
| | | if (propertyExt != null) { |
| | | AssetPropertyExt assetPropertyExt = new AssetPropertyExt(); |
| | |
| | | assetVehicleExtMapper.insert(assetVehicleExt); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public List<AssetMainVO> getListByIds(List<Integer> assetMainIds) { |
| | | if (!CollectionUtils.isEmpty(assetMainIds)) { |
| | | List<AssetMain> assetMains = this.lambdaQuery() |
| | | .in(AssetMain::getId, assetMainIds) |
| | | .list(); |
| | | //查询资产类型名称 |
| | | List<Integer> assetTypeIds = assetMains.stream().map(AssetMain::getAssetTypeId).distinct().collect(Collectors.toList()); |
| | | Map<Integer, String> typeNameMap = assetTypeIds.isEmpty() ? Collections.emptyMap() : assetTypeService.listByIds(assetTypeIds).stream() |
| | | .collect(Collectors.toMap(AssetType::getId, AssetType::getTypeName)); |
| | | //查询归属部门名称 |
| | | List<Integer> deptIds = assetMains.stream().map(AssetMain::getOwnershipDeptId).distinct().collect(Collectors.toList()); |
| | | Map<Integer, String> deptNameMap = deptIds.isEmpty() ? Collections.emptyMap() : tDeptService.listByIds(deptIds).stream() |
| | | .collect(Collectors.toMap(TDept::getId, TDept::getDeptName)); |
| | | List<AssetMainVO> voList = BeanUtil.copyToList(assetMains, AssetMainVO.class); |
| | | for (AssetMainVO assetMainVO : voList) { |
| | | assetMainVO.setAssetTypeName(typeNameMap.get(assetMainVO.getAssetTypeId())); |
| | | assetMainVO.setOwnershipDeptName(deptNameMap.get(assetMainVO.getOwnershipDeptId())); |
| | | } |
| | | return voList; |
| | | } |
| | | return Collections.emptyList(); |
| | | } |
| | | } |