rentaiming
2024-07-03 2df8a92c7affbb7bf04659cab7d784b57a3e1bf5
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
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.InventoriesSuppliesInfoMapper;
import com.ruoyi.management.mapper.SlGoodsMaterialsMapper;
import com.ruoyi.management.mapper.SlVolumeProductionRkMapper;
import com.ruoyi.management.service.InventoriesSuppliesInfoService;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.HashSet;
import java.util.List;
import java.util.ListResourceBundle;
import java.util.Set;
 
/**
 * <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;
    @Override
    public PageDTO<InventoriesSuppliesInfoVO> inventoriesSuppliesInfoService(InventoriesSuppliesInfoQuery inventoriesSuppliesInfoQuery) {
 
        Page<InventoriesSuppliesInfo> page = new Page<>(inventoriesSuppliesInfoQuery.getPageCurr(), inventoriesSuppliesInfoQuery.getPageSize());
        LambdaQueryWrapper< InventoriesSuppliesInfo> wrapper1= Wrappers.lambdaQuery();
        wrapper1.gt(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());
            SlGoodsMaterials slGoodsMaterials = slGoodsMaterialsMapper.selectById(slVolumeProductionRk.getMaterialsId());
            sl.setGoodsMaterialsName(slGoodsMaterials.getGoodsMaterialsName());
            sl.setIsConsume(slGoodsMaterials.getIsConsume());
 
        }
        return slGoodsMaterialsVO;
    }
 
    @Override
    public void addInventoriesSuppliesInfo(InventoriesSuppliesInfoDTO inventoriesSuppliesInfoDTO) {
        if (inventoriesSuppliesInfoDTO.getId()==0){
            InventoriesSuppliesInfo inventoriesSuppliesInf=new InventoriesSuppliesInfo();
            inventoriesSuppliesInf.setSuppliesId(inventoriesSuppliesInfoDTO.getSuppliesId());
            inventoriesSuppliesInf.setRkId(inventoriesSuppliesInfoDTO.getRkId());
            SlVolumeProductionRk slVolumeProductionRk = slVolumeProductionRkMapper.selectById(inventoriesSuppliesInfoDTO.getRkId());
            inventoriesSuppliesInf.setZkNum(slVolumeProductionRk.getRepertoryZhai());
            inventoriesSuppliesInf.setSuppliesNum(inventoriesSuppliesInfoDTO.getSuppliesNum());
            this.save(inventoriesSuppliesInf);
        }else{
            InventoriesSuppliesInfo byId = this.getById(inventoriesSuppliesInfoDTO.getId());
            byId.setSuppliesNum(inventoriesSuppliesInfoDTO.getSuppliesNum());
            this.updateById(byId);
 
        }
    }
 
    @Override
    public InventoriesSuppliesInfo getInventoriesSuppliesInfo(InventoriesSuppliesInfoDTO inventoriesSuppliesInfoDTO) {
        LambdaQueryWrapper< InventoriesSuppliesInfo> wrapper1= Wrappers.lambdaQuery();
        wrapper1.gt(InventoriesSuppliesInfo::getSuppliesId, inventoriesSuppliesInfoDTO.getSuppliesId());
        wrapper1.gt(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.gt(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.gt(InventoriesSuppliesInfo::getSuppliesId, inventoriesSuppliesInfoDTO.getSuppliesId());
        wrapper1.gt(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);
        }
 
    }
}