From 03587b58b343956f910a653c37b9a7bcd84e4af9 Mon Sep 17 00:00:00 2001
From: mitao <2763622819@qq.com>
Date: 星期五, 19 九月 2025 18:54:03 +0800
Subject: [PATCH] 资产管理-资产领用列表 阿里云OSS文件上传

---
 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/OaApprovalApplicationStorageServiceImpl.java |  611 ++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 426 insertions(+), 185 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 1e91e6b..a197e1c 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
@@ -1,9 +1,9 @@
 package com.ruoyi.system.service.impl;
 
-import cn.hutool.core.collection.CollUtil;
+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.core.domain.entity.SysDept;
-import com.ruoyi.common.core.domain.entity.SysUser;
+import com.ruoyi.common.core.domain.entity.TDept;
 import com.ruoyi.common.exception.ServiceException;
 import com.ruoyi.system.dto.asset.OaApprovalApplicationStorageGeneralDTO;
 import com.ruoyi.system.dto.asset.OaApprovalApplicationStoragePropertyDTO;
@@ -12,21 +12,43 @@
 import com.ruoyi.system.emums.ApprovalTypeEnum;
 import com.ruoyi.system.emums.AssetTypeEnum;
 import com.ruoyi.system.mapper.OaApprovalApplicationStorageMapper;
-import com.ruoyi.system.model.*;
-import com.ruoyi.system.service.*;
+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.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.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.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.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;
-import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
 import java.math.BigDecimal;
 import java.time.LocalDate;
-import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.List;
+import java.util.Map;
 import java.util.stream.Collectors;
 
 /**
@@ -51,6 +73,8 @@
     private final OaApprovalTodoService oaApprovalTodoService;
     private final ISysUserService sysUserService;
     private final ISysDeptService sysDeptService;
+    private final TDeptService tDeptService;
+    private final AssetWarehouseService assetWarehouseService;
 
     @Override
     @Transactional(rollbackFor = Exception.class)
@@ -63,15 +87,15 @@
         applications.setCurrentFlowNodeId(firstFlowNode.getId());
         oaApprovalApplicationsService.save(applications);
 
-        // 3. 创建待办事项记录
-        createApprovalTodo(applications.getId(), applications.getApplicationCode(), firstFlowNode, dto.getDeptId());
+        // 3. 创建待办事项记录(公共服务)
+        oaApprovalTodoService.createApprovalTodos(applications.getId(), applications.getApplicationCode(), firstFlowNode, dto.getDeptId());
 
         // 4. 保存资产入库申请明细数据
         OaApprovalApplicationStorage storage = buildOaApprovalApplicationStorage(dto, applications.getId());
         save(storage);
 
         // 5. 保存通用资产数据
-        saveGeneralAssets(dto.getAssetItems(), applications.getId(), dto.getAssetTypeId(), dto.getStorageTime());
+        saveGeneralAssets(dto.getAssetItems(), applications.getId(), dto.getAssetTypeId(), dto.getStorageTime(), dto);
     }
 
     @Override
@@ -85,15 +109,15 @@
         applications.setCurrentFlowNodeId(firstFlowNode.getId());
         oaApprovalApplicationsService.save(applications);
 
-        // 3. 创建待办事项记录
-        createApprovalTodo(applications.getId(), applications.getApplicationCode(), firstFlowNode, dto.getDeptId());
+        // 3. 创建待办事项记录(公共服务)
+        oaApprovalTodoService.createApprovalTodos(applications.getId(), applications.getApplicationCode(), firstFlowNode, dto.getDeptId());
 
         // 4. 保存资产入库申请明细数据
         OaApprovalApplicationStorage storage = buildOaApprovalApplicationStorage(dto, applications.getId());
         save(storage);
 
         // 5. 保存房产资产数据
-        savePropertyAssets(dto.getAssetItems(), applications.getId(), dto.getAssetTypeId(), dto.getStorageTime());
+        savePropertyAssets(dto.getAssetItems(), applications.getId(), dto.getAssetTypeId(), dto.getStorageTime(), dto);
     }
 
     @Override
@@ -107,29 +131,28 @@
         applications.setCurrentFlowNodeId(firstFlowNode.getId());
         oaApprovalApplicationsService.save(applications);
 
-        // 3. 创建待办事项记录
-        createApprovalTodo(applications.getId(), applications.getApplicationCode(), firstFlowNode, dto.getDeptId());
+        // 3. 创建待办事项记录(公共服务)
+        oaApprovalTodoService.createApprovalTodos(applications.getId(), applications.getApplicationCode(), firstFlowNode, dto.getDeptId());
 
         // 4. 保存资产入库申请明细数据
         OaApprovalApplicationStorage storage = buildOaApprovalApplicationStorage(dto, applications.getId());
         save(storage);
 
         // 5. 保存车辆资产数据
-        saveVehicleAssets(dto.getAssetItems(), applications.getId(), dto.getAssetTypeId(), dto.getStorageTime());
+        saveVehicleAssets(dto.getAssetItems(), applications.getId(), dto.getAssetTypeId(), dto.getStorageTime(), dto);
     }
 
     /**
      * 保存通用资产数据
      */
-    private void saveGeneralAssets(List<OaApprovalApplicationStorageGeneralDTO.GeneralAssetItemDTO> assetItems, Integer applicationId, Integer assetTypeId, LocalDate storageDate) {
+    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();
             for (int i = 0; i < quantity; i++) {
-                AssetMain assetMain = buildAssetMain(item, applicationId, assetTypeId, storageDate);
+                AssetMain assetMain = buildAssetMain(item, applicationId, assetTypeId, storageDate, baseDto);
                 assetMain.setAssetMainType(AssetTypeEnum.GENERAL.getCode());
                 assetMain.setQuantity(BigDecimal.ONE); // 每个资产记录数量为1
                 assetMain.setTotalValue(item.getUnitPrice()); // 总价值等于单价
@@ -139,25 +162,12 @@
         
         // 批量保存资产主表数据
         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);
     }
 
     /**
      * 保存房产资产数据
      */
-    private void savePropertyAssets(List<OaApprovalApplicationStoragePropertyDTO.PropertyAssetItemDTO> assetItems, Integer applicationId, Integer assetTypeId, LocalDate storageDate) {
+    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<>();
         
@@ -165,7 +175,7 @@
             // 根据数量创建对应数量的资产记录
             int quantity = item.getQuantity().intValue();
             for (int i = 0; i < quantity; i++) {
-                AssetMain assetMain = buildAssetMainFromProperty(item, applicationId, assetTypeId, storageDate);
+                AssetMain assetMain = buildAssetMainFromProperty(item, applicationId, assetTypeId, storageDate, baseDto);
                 assetMain.setAssetMainType(AssetTypeEnum.HOUSE.getCode());
                 assetMain.setQuantity(BigDecimal.ONE); // 每个资产记录数量为1
                 assetMain.setTotalValue(item.getUnitPrice()); // 总价值等于单价
@@ -193,7 +203,7 @@
     /**
      * 保存车辆资产数据
      */
-    private void saveVehicleAssets(List<OaApprovalApplicationStorageVehicleDTO.VehicleAssetItemDTO> assetItems, Integer applicationId, Integer assetTypeId, LocalDate storageDate) {
+    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<>();
         
@@ -201,7 +211,7 @@
             // 根据数量创建对应数量的资产记录
             int quantity = item.getQuantity().intValue();
             for (int i = 0; i < quantity; i++) {
-                AssetMain assetMain = buildAssetMainFromVehicle(item, applicationId, assetTypeId, storageDate);
+                AssetMain assetMain = buildAssetMainFromVehicle(item, applicationId, assetTypeId, storageDate, baseDto);
                 assetMain.setAssetMainType(AssetTypeEnum.VEHICLE.getCode());
                 assetMain.setQuantity(BigDecimal.ONE); // 每个资产记录数量为1
                 assetMain.setTotalValue(item.getUnitPrice()); // 总价值等于单价
@@ -229,23 +239,31 @@
     /**
      * 构建通用资产主表数据
      */
-    private AssetMain buildAssetMain(OaApprovalApplicationStorageGeneralDTO.GeneralAssetItemDTO item, Integer applicationId, Integer assetTypeId, LocalDate storageDate) {
+    private AssetMain buildAssetMain(OaApprovalApplicationStorageGeneralDTO.GeneralAssetItemDTO item, Integer applicationId, Integer assetTypeId, LocalDate storageDate, OaApprovalApplicationStorageGeneralDTO baseDto) {
         AssetMain assetMain = new AssetMain();
         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());
-        assetMain.setUseDeptId(item.getUseDeptId());
-        assetMain.setWarehouseId(item.getWarehouseId());
-        assetMain.setWarehouseName(item.getWarehouseName());
-        assetMain.setAddress(item.getAddress());
+        // 根据整单 addressType 写入使用部门ID或仓库ID
+        applyAddressToAssetMain(assetMain, baseDto.getAddressType(), baseDto.getUseDeptName(), baseDto.getWarehouseName(), baseDto.getAddress());
+        assetMain.setAssetMainType(baseDto.getAddressType());
         assetMain.setAssetStatus(item.getAssetStatus());
         assetMain.setRemarks(item.getRemarks());
         assetMain.setAccountingStatus(item.getAccountingStatus());
@@ -260,23 +278,29 @@
     /**
      * 构建房产资产主表数据
      */
-    private AssetMain buildAssetMainFromProperty(OaApprovalApplicationStoragePropertyDTO.PropertyAssetItemDTO item, Integer applicationId, Integer assetTypeId, LocalDate storageDate) {
+    private AssetMain buildAssetMainFromProperty(OaApprovalApplicationStoragePropertyDTO.PropertyAssetItemDTO item, Integer applicationId, Integer assetTypeId, LocalDate storageDate, OaApprovalApplicationStoragePropertyDTO baseDto) {
         AssetMain assetMain = new AssetMain();
         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());
-        assetMain.setUseDeptId(item.getUseDeptId());
-        assetMain.setWarehouseId(item.getWarehouseId());
-        assetMain.setWarehouseName(item.getWarehouseName());
-        assetMain.setAddress(item.getAddress());
+        applyAddressToAssetMain(assetMain, baseDto.getAddressType(), baseDto.getUseDeptName(), baseDto.getWarehouseName(), baseDto.getAddress());
+        assetMain.setAssetMainType(baseDto.getAddressType());
         assetMain.setAssetStatus(item.getAssetStatus());
         assetMain.setRemarks(item.getRemarks());
         assetMain.setAccountingStatus(item.getAccountingStatus());
@@ -291,23 +315,29 @@
     /**
      * 构建车辆资产主表数据
      */
-    private AssetMain buildAssetMainFromVehicle(OaApprovalApplicationStorageVehicleDTO.VehicleAssetItemDTO item, Integer applicationId, Integer assetTypeId, LocalDate storageDate) {
+    private AssetMain buildAssetMainFromVehicle(OaApprovalApplicationStorageVehicleDTO.VehicleAssetItemDTO item, Integer applicationId, Integer assetTypeId, LocalDate storageDate, OaApprovalApplicationStorageVehicleDTO baseDto) {
         AssetMain assetMain = new AssetMain();
         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());
-        assetMain.setUseDeptId(item.getUseDeptId());
-        assetMain.setWarehouseId(item.getWarehouseId());
-        assetMain.setWarehouseName(item.getWarehouseName());
-        assetMain.setAddress(item.getAddress());
+        applyAddressToAssetMain(assetMain, baseDto.getAddressType(), baseDto.getUseDeptName(), baseDto.getWarehouseName(), baseDto.getAddress());
+        assetMain.setAssetMainType(baseDto.getAddressType());
         assetMain.setAssetStatus(item.getAssetStatus());
         assetMain.setRemarks(item.getRemarks());
         assetMain.setAccountingStatus(item.getAccountingStatus());
@@ -320,21 +350,51 @@
     }
 
     /**
+     * 按整单地址类型设置资产主表位置信息(使用部门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 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;
     }
@@ -356,7 +416,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());
@@ -400,119 +460,6 @@
         return flowNodes.get(0);
     }
 
-    /**
-     * 创建待办数据
-     */
-    private void createApprovalTodo(Integer applicationId, String applicationCode, OaApprovalFlowNode flowNode, Integer deptId) {
-        Integer approvalType = flowNode.getApprovalType();
-        if (approvalType == null) {
-            throw new ServiceException("审批类型不能为空");
-        }
-
-        switch (approvalType) {
-            case 0:
-                createUpperDeptTodo(applicationId, applicationCode, flowNode, deptId);
-                break;
-            case 1:
-                createSpecifiedDeptTodo(applicationId, applicationCode, flowNode);
-                break;
-            case 2:
-                createSpecifiedUserTodo(applicationId, applicationCode, flowNode);
-                break;
-            default:
-                throw new ServiceException("不支持的审批类型: " + approvalType);
-        }
-    }
-
-    /**
-     * 创建上级部门审批待办
-     */
-    private void createUpperDeptTodo(Integer applicationId, String applicationCode, OaApprovalFlowNode flowNode, Integer deptId) {
-        if (deptId == null) {
-            throw new ServiceException("未填写申请部门信息");
-        }
-
-        SysDept currentDept = sysDeptService.selectDeptById(Long.valueOf(deptId));
-        if (currentDept == null) {
-            throw new ServiceException("申请部门信息不存在");
-        }
-
-        if (currentDept.getParentId() == null || currentDept.getParentId() == 0) {
-            throw new ServiceException("当前部门没有上级部门");
-        }
-
-        SysDept parentDept = sysDeptService.selectDeptById(currentDept.getParentId());
-        if (parentDept == null) {
-            throw new ServiceException("上级部门信息不存在");
-        }
-
-        List<SysUser> users = sysUserService.selectListByDeptId(parentDept.getDeptId().toString());
-        if (CollUtil.isEmpty(users)) {
-            throw new ServiceException("上级部门下没有找到用户");
-        }
-
-        createTodoItem(applicationId, applicationCode, flowNode, users);
-    }
-
-    /**
-     * 创建指定部门审批待办
-     */
-    private void createSpecifiedDeptTodo(Integer applicationId, String applicationCode, OaApprovalFlowNode flowNode) {
-        if (StringUtils.isBlank(flowNode.getApprovalIds())) {
-            throw new ServiceException("操作失败,审批流程配置异常");
-        }
-        
-        List<String> deptIdList = Arrays.stream(flowNode.getApprovalIds().split(",")).collect(Collectors.toList());
-        List<SysUser> users = sysUserService.selectListByDeptIds(deptIdList);
-        if (CollUtil.isEmpty(users)) {
-            throw new ServiceException("指定部门下没有找到用户");
-        }
-
-        createTodoItem(applicationId, applicationCode, flowNode, users);
-    }
-
-    /**
-     * 创建指定人员审批待办
-     */
-    private void createSpecifiedUserTodo(Integer applicationId, String applicationCode, OaApprovalFlowNode flowNode) {
-        if (StringUtils.isBlank(flowNode.getApprovalIds())) {
-            throw new ServiceException("操作失败,审批流程配置异常");
-        }
-        
-        List<Integer> userIds = Arrays.stream(flowNode.getApprovalIds().split(","))
-                .map(Integer::valueOf).collect(Collectors.toList());
-        List<SysUser> users = sysUserService.selectListByUserIds(userIds);
-        if (CollUtil.isEmpty(users)) {
-            throw new ServiceException("没有找到指定审批用户");
-        }
-        
-        createTodoItem(applicationId, applicationCode, flowNode, users);
-    }
-
-    /**
-     * 创建待办数据项
-     */
-    private void createTodoItem(Integer applicationId, String applicationCode, OaApprovalFlowNode flowNode, List<SysUser> userList) {
-        List<OaApprovalTodo> approvalTodoList = userList.stream().map(item -> {
-            OaApprovalTodo todo = new OaApprovalTodo();
-            todo.setApplicationId(applicationId);
-            todo.setApplicationCode(applicationCode);
-            todo.setFlowNodeId(flowNode.getId());
-            todo.setUserId(item.getUserId().intValue());
-            todo.setUserName(item.getNickName());
-
-            if (item.getDeptId() != null) {
-                todo.setDeptId(Integer.valueOf(item.getDeptId()));
-            }
-
-            todo.setSortOrder(flowNode.getSortOrder());
-            todo.setStatus(0);
-            todo.setCreateTime(LocalDateTime.now());
-            return todo;
-        }).collect(Collectors.toList());
-        
-        oaApprovalTodoService.saveBatch(approvalTodoList);
-    }
 
     /**
      * 构建审批申请主表数据
@@ -520,14 +467,14 @@
     private OaApprovalApplications buildOaApprovalApplications(Object dto) {
         OaApprovalApplications applications = new OaApprovalApplications();
         applications.setApprovalId(ApprovalTypeEnum.IN_STOCK.getCode());
-
+        applications.setApplicationDate(LocalDate.now());
         if (dto instanceof OaApprovalApplicationStorageGeneralDTO) {
             OaApprovalApplicationStorageGeneralDTO generalDTO = (OaApprovalApplicationStorageGeneralDTO) dto;
             applications.setApplicantUserId(generalDTO.getApplicantUserId());
             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) {
@@ -536,7 +483,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) {
@@ -545,7 +492,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());
         }
@@ -630,4 +577,298 @@
         
         return prefix + sequenceStr;
     }
-}
\ No newline at end of file
+    
+    @Override
+    public IPage<OaApprovalApplicationStoragePageVO> getPageList(OaApprovalApplicationStoragePageQuery pageQuery) {
+        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<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.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());
+                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.setAccountingStatus(m.getAccountingStatus());
+                item.setAccountingDate(m.getAccountingDate());
+                item.setAccountingVoucherNo(m.getAccountingVoucherNo());
+                item.setAccountingSubject(m.getAccountingSubject());
+                item.setAccountingAmount(m.getAccountingAmount());
+                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<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.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());
+                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.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.setMortgaged(ext.getMortgaged());
+                    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<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.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());
+                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.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