From 1093b185322515aebcccee208018346e7f9edbb3 Mon Sep 17 00:00:00 2001
From: mitao <2763622819@qq.com>
Date: 星期二, 14 十月 2025 16:51:25 +0800
Subject: [PATCH] 资产盘点任务接口
---
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/AssetTypeServiceImpl.java | 62 ++++++++++++++++++++++--------
1 files changed, 45 insertions(+), 17 deletions(-)
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/AssetTypeServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/AssetTypeServiceImpl.java
index 4e0f965..5b636b6 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/AssetTypeServiceImpl.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/AssetTypeServiceImpl.java
@@ -6,7 +6,6 @@
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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.common.utils.SecurityUtils;
import com.ruoyi.system.dto.asset.AssetTypeDTO;
@@ -21,14 +20,12 @@
import com.ruoyi.system.service.AssetInventoryRecordService;
import com.ruoyi.system.service.AssetMainService;
import com.ruoyi.system.service.AssetTypeService;
+import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.system.vo.AssetIdleListVO;
import com.ruoyi.system.vo.AssetInventoryVO;
import com.ruoyi.system.vo.AssetStatisticsDetailVO;
import com.ruoyi.system.vo.AssetStatisticsVO;
import com.ruoyi.system.vo.asset.AssetTypeTreeVO;
-import com.ruoyi.system.vo.system.NotificationVO;
-import io.swagger.annotations.ApiModelProperty;
-import io.swagger.models.auth.In;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
@@ -37,7 +34,12 @@
import java.math.BigDecimal;
import java.math.RoundingMode;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
import java.util.stream.Collectors;
/**
@@ -55,6 +57,7 @@
private final AssetMainService assetMainService;
private final AssetTypeService assetTypeService;
private final AssetInventoryRecordService assetInventoryRecordService;
+ private final ISysUserService sysUserService;
@Override
public List<AssetTypeTreeVO> getAssetTypeTree() {
@@ -402,22 +405,24 @@
@Override
public PageInfo<AssetInventoryVO> pageListInventory(AssetInventoryListQuery query) {
- AssetType assetType = this.baseMapper.selectById(query.getAssetTypeId());
- if (assetType.getParentId()==0){
- List<Integer> assetTypeChild = this.baseMapper.selectList(new LambdaQueryWrapper<AssetType>()
- .eq(AssetType::getParentId, assetType.getId())).stream().map(AssetType::getId)
- .collect(Collectors.toList());
- List<Integer> list = new ArrayList<>(assetTypeChild);
- list.add(assetType.getId());
- query.setAssetTypeIds( list);
- }else{
- query.setAssetTypeIds(Collections.singletonList(assetType.getId()));
+ if (query.getAssetTypeId()!=null){
+ AssetType assetType = this.baseMapper.selectById(query.getAssetTypeId());
+ if (assetType.getParentId()==0){
+ List<Integer> assetTypeChild = this.baseMapper.selectList(new LambdaQueryWrapper<AssetType>()
+ .eq(AssetType::getParentId, assetType.getId())).stream().map(AssetType::getId)
+ .collect(Collectors.toList());
+ List<Integer> list = new ArrayList<>(assetTypeChild);
+ list.add(assetType.getId());
+ query.setAssetTypeIds( list);
+ }else{
+ query.setAssetTypeIds(Collections.singletonList(assetType.getId()));
+ }
}
PageInfo<AssetInventoryVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
List<AssetInventoryVO> list = this.baseMapper.pageListInventory(query,pageInfo);
- Map<Integer, List<AssetMain>> assetMainMap = assetMainService.lambdaQuery().in(AssetMain::getId, query.getAssetMainIds()).list()
+ Map<Integer, List<AssetMain>> assetMainMap = assetMainService.lambdaQuery().in(query.getAssetMainIds()!=null&&!query.getAssetMainIds().isEmpty(),AssetMain::getId, query.getAssetMainIds()).list()
.stream().collect(Collectors.groupingBy(AssetMain::getAssetTypeId));
- List<AssetInventoryRecord> assetInventoryRecords = assetInventoryRecordService.lambdaQuery().in(AssetInventoryRecord::getAssetMainId, query.getAssetMainIds()).list();
+ List<AssetInventoryRecord> assetInventoryRecords = assetInventoryRecordService.lambdaQuery().in(query.getAssetMainIds()!=null&&!query.getAssetMainIds().isEmpty(),AssetInventoryRecord::getAssetMainId, query.getAssetMainIds()).list();
for (AssetInventoryVO assetInventoryVO : list) {
int inCount = 0;
int outCount = 0;
@@ -428,6 +433,14 @@
BigDecimal outMoney = new BigDecimal("0");
List<AssetMain> assetMains = assetMainMap.get(assetInventoryVO.getAssetTypeIdSecond());
for (AssetInventoryRecord assetInventoryRecord : assetInventoryRecords) {
+ if (assetMains==null){
+ assetInventoryVO.setInCount(inCount);
+ assetInventoryVO.setOutCount(outCount);
+ assetInventoryVO.setInMoney(inMoney);
+ assetInventoryVO.setOutMoney(outMoney);
+
+ continue;
+ }
if (assetInventoryRecord.getType()==0){
AssetMain assetMain = assetMains.stream().filter(e -> e.getId().equals(assetInventoryRecord.getAssetMainId()))
.findFirst().orElse(null);
@@ -450,6 +463,11 @@
assetInventoryVO.setOutCount(outCount);
assetInventoryVO.setInMoney(inMoney);
assetInventoryVO.setOutMoney(outMoney);
+ if (assetMains==null){
+ assetInventoryVO.setInStockCount(inStockCount);
+ assetInventoryVO.setInStockMoney(inStockMoney);
+ continue;
+ }
List<AssetMain> inStorage = assetMains.stream().filter(e -> e.getDisposed() == 0 && e.getInUse() == 0 && e.getBorrowed() == 0).collect(Collectors.toList());
for (AssetMain assetMain : inStorage) {
inStockCount+=assetMain.getQuantity();
@@ -518,4 +536,14 @@
return list;
}
+ @Override
+ public String getAssetTypeNameById(Integer assetTypeId) {
+ if (assetTypeId != null) {
+ AssetType assetType = this.getById(assetTypeId);
+ if (assetType != null) {
+ return assetType.getTypeName();
+ }
+ }
+ return null;
+ }
}
--
Gitblit v1.7.1