rentaiming
2024-07-01 68eb77aede3e5c1c7ccde2aa1f28fd2adaa07d28
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package com.ruoyi.management.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.page.PageDTO;
import com.ruoyi.management.domain.InventoriesSupplies;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.management.domain.SlGoodsShelf;
import com.ruoyi.management.domain.SlStoreManagement;
import com.ruoyi.management.domain.dto.InventoriesSuppDTO;
import com.ruoyi.management.domain.dto.InventoriesSuppliesQuery;
import com.ruoyi.management.domain.vo.InventoriesSuppliesVO;
import com.ruoyi.management.domain.vo.SlGoodsMaterialsVO;
import com.ruoyi.management.domain.vo.SlGoodsShelfVO;
import com.ruoyi.management.mapper.InventoriesSuppliesMapper;
import com.ruoyi.management.mapper.SlStoreManagementMapper;
import com.ruoyi.management.service.InventoriesSuppliesService;
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.api.feignClient.SysUserClient;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
 
/**
 * <p>
 * 物资盘点 服务实现类
 * </p>
 *
 * @author hjl
 * @since 2024-07-01
 */
@Service
public class InventoriesSuppliesServiceImpl extends ServiceImpl<InventoriesSuppliesMapper, InventoriesSupplies> implements InventoriesSuppliesService {
 
    @Resource
    private SlStoreManagementMapper slStoreManagementMapper;
 
    @Resource
    private SysUserClient sysUserClient;
 
    @Override
    public PageDTO<InventoriesSuppliesVO> getInventoriesSuppliesList(InventoriesSuppliesQuery inventoriesSuppliesQuery) {
        LambdaQueryWrapper<SlStoreManagement> wrapper= Wrappers.lambdaQuery();
        if (inventoriesSuppliesQuery.getStoreManagementName()!=null){
            wrapper.eq(SlStoreManagement::getStoreManagementName,inventoriesSuppliesQuery.getStoreManagementName());
        }
        if (inventoriesSuppliesQuery.getStoreManagementNo()!=null){
        wrapper.eq(SlStoreManagement::getStoreManagementNo,inventoriesSuppliesQuery.getStoreManagementNo());
        }
        List<SlStoreManagement> slStoreManagements = slStoreManagementMapper.selectList(wrapper);
 
        Set<Long> slStoreManagementIdList = null;
        slStoreManagementIdList = slStoreManagements.stream().map(SlStoreManagement::getId)
                .collect(Collectors.toSet());
 
        Page<InventoriesSupplies> page = new Page<>(inventoriesSuppliesQuery.getPageCurr(), inventoriesSuppliesQuery.getPageSize());
        LambdaQueryWrapper< InventoriesSupplies> wrapper1= Wrappers.lambdaQuery();
        wrapper1.like(InventoriesSupplies::getPdrName,inventoriesSuppliesQuery.getPdrName());
        if (slStoreManagementIdList.size()>0){
            wrapper1.in(InventoriesSupplies::getMaterialsId,slStoreManagementIdList);
        }else {
                Set<Long> goodsSkuIdList1 = new HashSet<>();
                goodsSkuIdList1.add(0L);
                wrapper1.in(InventoriesSupplies::getMaterialsId,goodsSkuIdList1);
        }
        if (inventoriesSuppliesQuery.getStartpdTime()!=null){
 
            wrapper1.gt(InventoriesSupplies::getPdTime, inventoriesSuppliesQuery.getStartpdTime());
        }
        if (inventoriesSuppliesQuery.getEndpdTime()!=null){
            wrapper1.le(InventoriesSupplies::getPdTime, inventoriesSuppliesQuery.getEndpdTime());
       }
 
 
        wrapper1.eq( InventoriesSupplies::getDelFlag,0);
        wrapper1.orderByDesc(InventoriesSupplies::getCreateTime);
        Page<InventoriesSupplies> page2 = this.page(page, wrapper1);
        PageDTO<InventoriesSuppliesVO> slGoodsMaterialsVO = PageDTO.of(page2, InventoriesSuppliesVO.class);
        List<InventoriesSuppliesVO> list = slGoodsMaterialsVO.getList();
        for (InventoriesSuppliesVO sl:list){
            SlStoreManagement slStoreManagementzs = slStoreManagementMapper.selectById(sl.getMaterialsId());
            sl.setStoreManagementName(slStoreManagementzs.getStoreManagementName());
            sl.setStoreManagementNo(slStoreManagementzs.getStoreManagementNo());
        }
 
        return slGoodsMaterialsVO;
    }
 
    @Override
    public void addInventoriesSupp(InventoriesSuppDTO inventoriesSuppDTO) {
        InventoriesSupplies inventoriesSupplies=new InventoriesSupplies();
        inventoriesSupplies.setMaterialsId(inventoriesSuppDTO.getMaterialsId());
        inventoriesSupplies.setPdTime(new Date());
        inventoriesSupplies.setPdrId(inventoriesSuppDTO.getPdrId());
        R<SysUser> sysUser = sysUserClient.getSysUser(inventoriesSuppDTO.getPdrId());
        inventoriesSupplies.setPdrName(sysUser.getData().getNickName());
        this.save(inventoriesSupplies);
    }
}