无关风月
2 天以前 60afc1c228318d136a273cd0b389217f87583277
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/AssetTypeServiceImpl.java
@@ -342,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();
@@ -405,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;
@@ -431,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);
@@ -453,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();