From 4106bd3d06127ae542ef9ef975862eecc4ae1ff0 Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期六, 11 十月 2025 18:43:26 +0800
Subject: [PATCH] 房屋巡检记录
---
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/AssetTypeServiceImpl.java | 191 ++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 185 insertions(+), 6 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 a28fcd9..0df58f2 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,20 +6,26 @@
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;
import com.ruoyi.system.mapper.AssetTypeMapper;
+import com.ruoyi.system.model.AssetInventoryRecord;
import com.ruoyi.system.model.AssetMain;
import com.ruoyi.system.model.AssetType;
+import com.ruoyi.system.query.AsseIdleListQuery;
+import com.ruoyi.system.query.AssetInventoryListQuery;
+import com.ruoyi.system.query.AssetStatisticsListDetailQuery;
import com.ruoyi.system.query.AssetStatisticsListQuery;
+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 lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
@@ -29,6 +35,7 @@
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@@ -48,6 +55,9 @@
public class AssetTypeServiceImpl extends ServiceImpl<AssetTypeMapper, AssetType> implements AssetTypeService {
private final AssetMainService assetMainService;
+ private final AssetTypeService assetTypeService;
+ private final AssetInventoryRecordService assetInventoryRecordService;
+ private final ISysUserService sysUserService;
@Override
public List<AssetTypeTreeVO> getAssetTypeTree() {
@@ -307,7 +317,7 @@
.stream()
.map(AssetMain::getAssetTypeId)
.collect(Collectors.toList());
- query.setAssetTypeIds(assetTypeIds);
+ query.setAssetMainIds(assetTypeIds);
if (assetTypeIds.isEmpty()){
return new PageInfo<>();
}
@@ -319,7 +329,9 @@
if (assetTypeIds.isEmpty()){
return new PageInfo<>();
}
- Map<Integer, List<AssetMain>> assetMainMap = assetMainService.lambdaQuery().in(AssetMain::getAssetTypeId, assetTypeIds).list()
+ Map<Integer, List<AssetMain>> assetMainMap = assetMainService.lambdaQuery()
+ .in(!query.getDeptIds().isEmpty(),AssetMain::getOwnershipDeptId, query.getDeptIds())
+ .in(AssetMain::getAssetTypeId, assetTypeIds).list()
.stream()
.collect(Collectors.groupingBy(AssetMain::getAssetTypeId));
for (AssetStatisticsVO asset : list) {
@@ -330,7 +342,7 @@
Integer otherCount= 0;
BigDecimal totalValue = new BigDecimal("0");
List<AssetMain> assetMains = assetMainMap.get(asset.getAssetTypeIdSecond());
- if (!assetMains.isEmpty()){
+ if (assetMains!=null&& !assetMains.isEmpty()){
for (AssetMain assetMain : assetMains) {
if (assetMain.getAssetStatus().contains("闲置")){
idleCount += assetMain.getQuantity();
@@ -357,4 +369,171 @@
return pageInfo;
}
+ @Override
+ public PageInfo<AssetStatisticsDetailVO> pageListDetail(AssetStatisticsListDetailQuery query) {
+ String assetTypeName = null;
+ AssetType assetType = assetTypeService.getById(query.getAssetTypeIdSecond());
+ if (assetType!=null){
+ AssetType assetTypeParent = assetTypeService.getById(assetType.getParentId());
+ if (assetTypeParent!=null){
+ assetTypeName = assetTypeParent.getTypeName()+">"+assetType.getTypeName();
+ }
+ }
+
+ if (StringUtils.hasLength(query.getNameOrCode())){
+ // 查询出资产名称或者资产编号符合条件的code
+ List<Integer> assetTypeIds = assetMainService.lambdaQuery().like(AssetMain::getAssetName, query.getNameOrCode())
+ .or()
+ .like(AssetMain::getAssetCode, query.getNameOrCode())
+ .list()
+ .stream()
+ .map(AssetMain::getAssetTypeId)
+ .collect(Collectors.toList());
+ query.setAssetMainIds(assetTypeIds);
+ if (assetTypeIds.isEmpty()){
+ return new PageInfo<>();
+ }
+ }
+ PageInfo<AssetStatisticsDetailVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
+ List<AssetStatisticsDetailVO> list = this.baseMapper.pageListDetail(query,pageInfo);
+ for (AssetStatisticsDetailVO assetStatisticsDetailVO : list) {
+ assetStatisticsDetailVO.setAssetTypeName(assetTypeName);
+ }
+ pageInfo.setRecords(list);
+ return pageInfo;
+ }
+
+ @Override
+ public PageInfo<AssetInventoryVO> pageListInventory(AssetInventoryListQuery query) {
+ 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(query.getAssetMainIds()!=null&&!query.getAssetMainIds().isEmpty(),AssetMain::getId, query.getAssetMainIds()).list()
+ .stream().collect(Collectors.groupingBy(AssetMain::getAssetTypeId));
+ 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;
+ int inStockCount = 0;
+
+ BigDecimal inStockMoney = new BigDecimal("0");
+ BigDecimal inMoney = new BigDecimal("0");
+ 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);
+ if (assetMain!=null){
+ inCount+=assetMain.getQuantity();
+ inMoney = inMoney.add(new BigDecimal(assetMain.getQuantity())
+ .multiply(assetMain.getUnitPrice()).setScale(2, RoundingMode.HALF_DOWN));
+ }
+ }else{
+ AssetMain assetMain = assetMains.stream().filter(e -> e.getId().equals(assetInventoryRecord.getAssetMainId()))
+ .findFirst().orElse(null);
+ if (assetMain!=null){
+ outCount+=assetMain.getQuantity();
+ outMoney = outMoney.add(new BigDecimal(assetMain.getQuantity())
+ .multiply(assetMain.getUnitPrice()).setScale(2, RoundingMode.HALF_DOWN));
+ }
+ }
+ }
+ assetInventoryVO.setInCount(inCount);
+ 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();
+ inStockMoney = inStockMoney.add(new BigDecimal(assetMain.getQuantity())
+ .multiply(assetMain.getUnitPrice()).setScale(2, RoundingMode.HALF_DOWN));
+ }
+ assetInventoryVO.setInStockCount(inStockCount);
+ assetInventoryVO.setInStockMoney(inStockMoney);
+ }
+ pageInfo.setRecords(list);
+ return pageInfo;
+ }
+
+ @Override
+ public PageInfo<AssetStatisticsDetailVO> pageListInventoryDetail(AssetStatisticsListDetailQuery query) {
+ PageInfo<AssetStatisticsDetailVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
+ List<AssetStatisticsDetailVO> list = this.baseMapper.pageListInventoryDetail(query,pageInfo);
+ List<AssetType> assetTypes = assetTypeService.list();
+ for (AssetStatisticsDetailVO assetStatisticsDetailVO : list) {
+ Integer type = assetStatisticsDetailVO.getType();
+ if (type==0){
+ String typeName = "入库";
+
+ AssetType assetType = assetTypes.stream().filter(e -> e.getId().equals(assetStatisticsDetailVO.getAssetTypeId()))
+ .findFirst().orElse(null);
+ if (assetType!=null){
+ typeName =typeName+"("+assetType.getTypeName()+")";
+ }
+ assetStatisticsDetailVO.setTypeName(typeName);
+ }else{
+ String typeName = "出库";
+ AssetType assetType = assetTypes.stream().filter(e -> e.getId().equals(assetStatisticsDetailVO.getAssetTypeId()))
+ .findFirst().orElse(null);
+ if (assetType!=null){
+ typeName =typeName+"("+assetType.getTypeName()+")";
+ }
+ assetStatisticsDetailVO.setTypeName(typeName);
+ }
+ }
+ pageInfo.setRecords(list);
+ return pageInfo;
+ }
+
+ @Override
+ public PageInfo<AssetIdleListVO> pageListIdle(AsseIdleListQuery query) {
+ Map<Integer, AssetType> assetTypeMap = assetTypeService.list().stream().collect(
+ Collectors.toMap(AssetType::getId, e -> e)
+ );
+ PageInfo<AssetIdleListVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
+ List<AssetIdleListVO> list = this.baseMapper.pageListIdle(query,pageInfo);
+ for (AssetIdleListVO assetIdleListVO : list) {
+ AssetType assetType = assetTypeMap.get(assetIdleListVO.getAssetTypeId());
+ if (assetType!=null){
+ AssetType parent = assetTypeMap.get(assetType.getParentId());
+ assetIdleListVO.setAssetTypeName(parent.getTypeName()+">"+assetType.getTypeName());
+ }
+ }
+ pageInfo.setRecords(list);
+ return pageInfo;
+ }
+
+ @Override
+ public List<AssetIdleListVO> pageListIdleNoLimit(AsseIdleListQuery query) {
+ List<AssetIdleListVO> list = this.baseMapper.pageListIdleNoLimit(query);
+
+ return list;
+ }
+
}
--
Gitblit v1.7.1