无关风月
2024-08-01 8876b1b9cd27fad076ea9e5f3e04197b84ba02bd
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
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.utils.page.PageDTO;
import com.ruoyi.management.domain.*;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.management.domain.dto.InventoriesSuppliesInfoDTO;
import com.ruoyi.management.domain.dto.InventoriesSuppliesInfoQuery;
import com.ruoyi.management.domain.vo.InventoriesSuppliesInfoVO;
import com.ruoyi.management.domain.vo.InventoriesSuppliesVO;
import com.ruoyi.management.mapper.*;
import com.ruoyi.management.service.InventoriesSuppliesInfoService;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.*;
 
/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author hjl
 * @since 2024-07-01
 */
@Service
public class InventoriesSuppliesInfoServiceImpl extends ServiceImpl<InventoriesSuppliesInfoMapper, InventoriesSuppliesInfo> implements InventoriesSuppliesInfoService {
 
 
    @Resource
    private SlVolumeProductionRkMapper slVolumeProductionRkMapper;
 
    @Resource
    private SlGoodsMaterialsMapper slGoodsMaterialsMapper;
 
    @Resource
    private ManagementGoodsMaterialsMapper managementGoodsMaterialsMapper;
 
    @Resource
    private SlGoodsShelfMapper slGoodsShelfMapper;
    @Override
    public PageDTO<InventoriesSuppliesInfoVO> inventoriesSuppliesInfoService(InventoriesSuppliesInfoQuery inventoriesSuppliesInfoQuery) {
 
        Page<InventoriesSuppliesInfo> page = new Page<>(inventoriesSuppliesInfoQuery.getPageCurr(), inventoriesSuppliesInfoQuery.getPageSize());
        LambdaQueryWrapper< InventoriesSuppliesInfo> wrapper1= Wrappers.lambdaQuery();
        wrapper1.eq(InventoriesSuppliesInfo::getSuppliesId, inventoriesSuppliesInfoQuery.getSuppliesId());
        wrapper1.eq( InventoriesSuppliesInfo::getDelFlag,0);
        wrapper1.orderByDesc(InventoriesSuppliesInfo::getCreateTime);
        wrapper1.orderByDesc(InventoriesSuppliesInfo::getType);
        Page<InventoriesSuppliesInfo> page2 = this.page(page, wrapper1);
        PageDTO<InventoriesSuppliesInfoVO> slGoodsMaterialsVO = PageDTO.of(page2, InventoriesSuppliesInfoVO.class);
        List<InventoriesSuppliesInfoVO> list = slGoodsMaterialsVO.getList();
        for (InventoriesSuppliesInfoVO sl:list){
            SlVolumeProductionRk slVolumeProductionRk = slVolumeProductionRkMapper.selectById(sl.getRkId());
            sl.setRkNumber(slVolumeProductionRk.getRkNumber());
            sl.setRkModel(slVolumeProductionRk.getRkModel());
            sl.setZkNum(slVolumeProductionRk.getRepertoryZhai());
            SlGoodsMaterials slGoodsMaterials = slGoodsMaterialsMapper.selectById(slVolumeProductionRk.getMaterialsId());
            sl.setGoodsMaterialsName(slGoodsMaterials.getGoodsMaterialsName());
            sl.setIsConsume(slGoodsMaterials.getIsConsume());
            sl.setStoreManagementNumber(slVolumeProductionRk.getStoreManagementNumber());
            SlGoodsShelf slGoodsShelf = slGoodsShelfMapper.selectById(slVolumeProductionRk.getShelfId());
            sl.setGoodsShelfName(slGoodsShelf.getGoodsShelfName());
 
        }
        return slGoodsMaterialsVO;
    }
 
    @Override
    public void addInventoriesSuppliesInfo(List<InventoriesSuppliesInfoDTO> inventoriesSuppliesInfoDTO) {
        for (InventoriesSuppliesInfoDTO m:inventoriesSuppliesInfoDTO)
        if (m.getId()==null){
            InventoriesSuppliesInfo inventoriesSuppliesInf=new InventoriesSuppliesInfo();
            inventoriesSuppliesInf.setSuppliesId(m.getSuppliesId());
            inventoriesSuppliesInf.setRkId(m.getRkId());
            inventoriesSuppliesInf.setCreateTime(new Date());
            SlVolumeProductionRk slVolumeProductionRk = slVolumeProductionRkMapper.selectById(m.getRkId());
            inventoriesSuppliesInf.setZkNum(slVolumeProductionRk.getRepertoryZhai());
            inventoriesSuppliesInf.setSuppliesNum(m.getSuppliesNum());
            this.save(inventoriesSuppliesInf);
        }else{
            InventoriesSuppliesInfo byId = this.getById(m.getId());
            byId.setSuppliesNum(m.getSuppliesNum());
            this.updateById(byId);
 
        }
    }
 
    @Override
    public InventoriesSuppliesInfo getInventoriesSuppliesInfo(InventoriesSuppliesInfoDTO inventoriesSuppliesInfoDTO) {
        LambdaQueryWrapper< InventoriesSuppliesInfo> wrapper1= Wrappers.lambdaQuery();
        wrapper1.eq(InventoriesSuppliesInfo::getSuppliesId, inventoriesSuppliesInfoDTO.getSuppliesId());
        wrapper1.eq(InventoriesSuppliesInfo::getRkId, inventoriesSuppliesInfoDTO.getSuppliesId());
        wrapper1.eq( InventoriesSuppliesInfo::getDelFlag,0);
        InventoriesSuppliesInfo page2 = this.getOne(wrapper1);
        return page2;
    }
 
    @Override
    public void submitInventoriesSuppliesInfo(InventoriesSuppliesInfoDTO inventoriesSuppliesInfoDTO) {
        LambdaQueryWrapper< InventoriesSuppliesInfo> wrapper1= Wrappers.lambdaQuery();
        wrapper1.eq(InventoriesSuppliesInfo::getSuppliesId, inventoriesSuppliesInfoDTO.getSuppliesId());
        wrapper1.eq( InventoriesSuppliesInfo::getDelFlag,0);
        List<InventoriesSuppliesInfo> page2 = this.list(wrapper1);
        for (InventoriesSuppliesInfo page:page2){
            if (page.getZkNum()!=page.getSuppliesNum()){
                page.setType(2);
            }
            this.updateById(page);
        }
    }
 
    @Override
    public void accomplishInventoriesSuppliesInfo(InventoriesSuppliesInfoDTO inventoriesSuppliesInfoDTO) {
 
        LambdaQueryWrapper< InventoriesSuppliesInfo> wrapper1= Wrappers.lambdaQuery();
        wrapper1.eq(InventoriesSuppliesInfo::getSuppliesId, inventoriesSuppliesInfoDTO.getSuppliesId());
        wrapper1.eq(InventoriesSuppliesInfo::getType, 2);
        wrapper1.eq( InventoriesSuppliesInfo::getDelFlag,0);
        List<InventoriesSuppliesInfo> page2 = this.list(wrapper1);
        for (InventoriesSuppliesInfo page:page2){
            SlVolumeProductionRk slVolumeProductionRk = slVolumeProductionRkMapper.selectById(page.getRkId());
            slVolumeProductionRk.setRepertoryZhai(page.getSuppliesNum());
            slVolumeProductionRkMapper.updateById(slVolumeProductionRk);
 
 
            LambdaQueryWrapper<ManagementGoodsMaterials> wrapper2 = Wrappers.lambdaQuery();
            wrapper2.eq(ManagementGoodsMaterials::getGoodsMaterialsId,slVolumeProductionRk.getMaterialsId());
            wrapper2.eq(ManagementGoodsMaterials::getManagementId,slVolumeProductionRk.getManagementId());
            wrapper2.eq(ManagementGoodsMaterials::getDelFlag, 0);
            ManagementGoodsMaterials managementGoodsMaterials = managementGoodsMaterialsMapper.selectOne(wrapper2);
            if (managementGoodsMaterials!=null){
                managementGoodsMaterials.setRepertoryZhai(page.getSuppliesNum());
                managementGoodsMaterialsMapper.updateById(managementGoodsMaterials);
            }
        }
 
    }
}