无关风月
2024-08-27 b5ef65d0103a71dc7af2b9be6d2ac43aca5bb726
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
package com.ruoyi.management.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.utils.page.BeanUtils;
import com.ruoyi.common.core.utils.page.PageDTO;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.management.domain.*;
import com.ruoyi.management.domain.dto.ManagementimgVolumeProductionZyQuery;
import com.ruoyi.management.domain.dto.SlVolumeProductionZyDTO;
import com.ruoyi.management.domain.dto.SlVolumeProductionZyQuery;
import com.ruoyi.management.domain.vo.*;
import com.ruoyi.management.mapper.*;
import com.ruoyi.management.service.SlVolumeProductionZyglService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.api.domain.getVolumeProductionRkQuery;
import com.ruoyi.system.api.feignClient.SysUserClient;
import com.sun.org.apache.bcel.internal.generic.NEW;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
 
import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;
 
/**
 * <p>
 * 转移管理 服务实现类
 * </p>
 *
 * @author hjl
 * @since 2024-06-25
 */
@Service
public class SlVolumeProductionZyglServiceImpl extends ServiceImpl<SlVolumeProductionZyglMapper, SlVolumeProductionZygl> implements SlVolumeProductionZyglService {
    @Resource
    private SysUserClient sysUserClient;
 
    @Resource
    private SlStoreManagementMapper slStoreManagementMapper;
 
    @Resource
    private SlVolumeProductionZyglMapper slVolumeProductionZyglMapper;
 
    @Resource
    private SlVolumeProductionRkMapper slVolumeProductionRkMapper;
 
    @Resource
    private SlGoodsMaterialsMapper slGoodsMaterialsMapper;
 
    @Resource
    private SlGoodsShelfMapper slGoodsShelfMapper;
 
    @Resource
    private SlVolumeProductionZyMapper slVolumeProductionZyMapper;
 
    @Resource
    private ManagementGoodsMaterialsMapper managementGoodsMaterialsMapper;
 
    @Override
    public PageDTO<VolumeProductionzZyglVO> getVolumeProductionzZyglList(SlVolumeProductionZyQuery slVolumeProductionZyQuery) {
        Page<SlVolumeProductionZygl> page = new Page<>(slVolumeProductionZyQuery.getPageCurr(), slVolumeProductionZyQuery.getPageSize());
        getVolumeProductionRkQuery getVolume=new getVolumeProductionRkQuery();
        getVolume.setSupplierPhone(slVolumeProductionZyQuery.getSupplierPhone());
        getVolume.setSupplierName(slVolumeProductionZyQuery.getSupplierName());
        List<SysUser> data1 = sysUserClient.getUserSupplierList(getVolume).getData();
        Set<Long> goodsSkuIdList = null;
        goodsSkuIdList = data1.stream().map(SysUser::getUserId)
                .collect(Collectors.toSet());
        LambdaQueryWrapper< SlVolumeProductionZygl> wrapper1= Wrappers.lambdaQuery();
        if (slVolumeProductionZyQuery.getPresentState()!=null){
            wrapper1.eq(SlVolumeProductionZygl::getPresentState,slVolumeProductionZyQuery.getPresentState());
        }
        if (slVolumeProductionZyQuery.getAuditStatus()!=null){
            wrapper1.eq(SlVolumeProductionZygl::getAuditStatus,slVolumeProductionZyQuery.getAuditStatus());
 
        }
        if (goodsSkuIdList.size()>0){
            wrapper1.in(SlVolumeProductionZygl::getSysId,goodsSkuIdList);
        }
        wrapper1.eq( SlVolumeProductionZygl::getDelFlag,0);
//        wrapper1.ne(SlVolumeProductionZygl::getAuditStatus,7);
        wrapper1.orderByDesc(SlVolumeProductionZygl::getStartiTime);
        Page<SlVolumeProductionZygl> page2 = this.page(page, wrapper1);
 
        PageDTO<VolumeProductionzZyglVO> SlGoodsShelfDTO = PageDTO.of(page2, VolumeProductionzZyglVO .class);
        List<VolumeProductionzZyglVO> list2 = SlGoodsShelfDTO.getList();
        for(VolumeProductionzZyglVO list:list2){
            SysUser data = sysUserClient.getSysUser(list.getSysId()).getData();
            list.setNickName(data.getNickName());
            list.setPhonenumber(data.getPhonenumber());
            SlStoreManagement slStoreManagement = slStoreManagementMapper.selectById(list.getManagementId());
            list.setStoreManagementName(slStoreManagement.getStoreManagementName());
 
            SlStoreManagement bslStoreManagement = slStoreManagementMapper.selectById(list.getBmanagementId());
            list.setBstoreManagementName(bslStoreManagement.getStoreManagementName());
        }
        return SlGoodsShelfDTO;
    }
 
    @Override
    public String addsVolumeProductionzZygl(SlVolumeProductionZyDTO slVolumeProductionZyDTO) {
                Long userid = SecurityUtils.getUserId();
                if (slVolumeProductionZyDTO.getId()==null){
                    SlVolumeProductionZygl slVolumeProductionZygl=new SlVolumeProductionZygl();
                    slVolumeProductionZygl.setAttachmentUrl(slVolumeProductionZyDTO.getAttachmentUrl());
                    slVolumeProductionZygl.setAuthorizationUrl(slVolumeProductionZyDTO.getAuthorization());
                    slVolumeProductionZygl.setSource(slVolumeProductionZyDTO.getSource());
                    slVolumeProductionZygl.setManagementId(slVolumeProductionZyDTO.getManagementId());
                    slVolumeProductionZygl.setBmanagementId(slVolumeProductionZyDTO.getBmanagementId());
                    slVolumeProductionZygl.setSysId(userid);
                    slVolumeProductionZygl.setStartiTime(new Date());
                    slVolumeProductionZygl.setAuditStatus(1);
                    slVolumeProductionZygl.setPresentState(1);
                    this.save(slVolumeProductionZygl);
                    return slVolumeProductionZygl.getId().toString();
                }else {
                    SlVolumeProductionZygl byId = this.getById(slVolumeProductionZyDTO.getId());
                    if (slVolumeProductionZyDTO.getSource()!=null){
                        byId.setSource(slVolumeProductionZyDTO.getSource());
                    }
                    if (slVolumeProductionZyDTO.getAttachmentUrl()!=null){
                        byId.setAttachmentUrl(slVolumeProductionZyDTO.getAttachmentUrl());
                    }
                    if (slVolumeProductionZyDTO.getAuthorization()!=null){
                        byId.setAuthorizationUrl(slVolumeProductionZyDTO.getAuthorization());
                    }
                    this.updateById(byId);
                    return slVolumeProductionZyDTO.getId().toString();
                }
 
    }
 
    @Override
    public VolumeProductionZyglInfoVO getVolumeProductionzZyglnfo(ManagementimgVolumeProductionZyQuery managementimgVolumeProductionZyQuery) {
        SlVolumeProductionZygl byId = this.getById(managementimgVolumeProductionZyQuery.getVolumeProductionzyglId());
        VolumeProductionZyglInfoVO v= BeanUtils.copyBean(byId, VolumeProductionZyglInfoVO.class);
        SlStoreManagement slStoreManagement2 = slStoreManagementMapper.selectById(byId.getManagementId());
        v.setZhuren(slStoreManagement2.getDirectorId());
        v.setZhuguan(slStoreManagement2.getCompetentId());
        v.setGuanliyuan(slStoreManagement2.getAdministratorId());
        SlStoreManagement slStoreManagement = slStoreManagementMapper.selectById(byId.getManagementId());
        v.setStoreManagementName(slStoreManagement.getStoreManagementName());
        SlStoreManagement bslStoreManagement = slStoreManagementMapper.selectById(byId.getBmanagementId());
        v.setBstoreManagementName(bslStoreManagement.getStoreManagementName());
        SysUser data1 = sysUserClient.getSysUser(Long.valueOf(byId.getSysId())).getData();
        v.setSysName(data1.getNickName());
        v.setSysPhone(data1.getPhonenumber());
        // 查询楼层数据
        SlStoreManagement slStoreManagement1 = slStoreManagementMapper.selectById(byId.getBmanagementId());
        List<String> number = new ArrayList<>();
        for (Integer i = 1; i <= slStoreManagement1.getStoreManagementNumber(); i++) {
            switch (i){
                case 1:
                    number.add("一层");
                    break;
                case 2:
                    number.add("二层");
                    break;
                case 3:
                    number.add("三层");
                    break;
            }
        }
        v.setNumber(number);
        if (managementimgVolumeProductionZyQuery.getStoreManagementNumber()==null){
            managementimgVolumeProductionZyQuery.setStoreManagementNumber(1);
        }
        QueryWrapper<SlGoodsShelf> eq = new QueryWrapper<SlGoodsShelf>()
                .eq("del_flag", "0")
                .eq("store_management_id", byId.getBmanagementId())
                .eq("store_management_number",managementimgVolumeProductionZyQuery.getStoreManagementNumber());
        List<SlGoodsShelf> slGoodsShelves = slGoodsShelfMapper.selectList(eq);
        v.setGoodsShelfList(slGoodsShelves);
        // 根据转移id 查询转移数据 收集入库ids
        LambdaQueryWrapper<SlVolumeProductionZy> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(SlVolumeProductionZy::getZyglId, byId.getId());
        wrapper.eq(SlVolumeProductionZy::getDelFlag, 0);
        if (managementimgVolumeProductionZyQuery.getShelfId()==null){
            if (!slGoodsShelves.isEmpty()){
                wrapper.eq(SlVolumeProductionZy::getShelfId,slGoodsShelves.get(0).getId());
            }
        }else{
            wrapper.eq(SlVolumeProductionZy::getShelfId,managementimgVolumeProductionZyQuery.getShelfId());
        }
        if (managementimgVolumeProductionZyQuery.getStoreManagementNumber()==null){
            wrapper.eq(SlVolumeProductionZy::getStoreManagementNumber,1);
        }else{
            wrapper.eq(SlVolumeProductionZy::getStoreManagementNumber,managementimgVolumeProductionZyQuery.getStoreManagementNumber());
        }
        List<Long> collect = new ArrayList<>();
 
        if (StringUtils.hasLength(byId.getAuthorizationUrl())){
            collect = slVolumeProductionZyMapper.selectList(wrapper)
                    .stream().map(SlVolumeProductionZy::getScrkId).collect(Collectors.toList());
        }else{
            collect = slVolumeProductionZyMapper.selectList(wrapper)
                    .stream().map(SlVolumeProductionZy::getRkId).collect(Collectors.toList());
        }
        // 入库ids
 
        if (collect.isEmpty()){
            // 如果为空 那么插入-1 不查询数据
            collect.add(-1L);
        }
        // 查询物资列表
        LambdaQueryWrapper<SlVolumeProductionRk> wrapper2= Wrappers.lambdaQuery();
        wrapper2.in(SlVolumeProductionRk::getId,collect);
        wrapper2.eq( SlVolumeProductionRk::getDelFlag,0);
        wrapper2.orderByDesc(SlVolumeProductionRk::getCreateTime);
        List<SlVolumeProductionRk> page1 = slVolumeProductionRkMapper.selectList(wrapper2);
 
        Set<Long> goodsSkuIdList = null;
        goodsSkuIdList = page1.stream().map(SlVolumeProductionRk::getId)
                .collect(Collectors.toSet());
        Page<SlVolumeProductionZy> page = new Page<>(managementimgVolumeProductionZyQuery.getPageCurr(), managementimgVolumeProductionZyQuery.getPageSize());
        LambdaQueryWrapper< SlVolumeProductionZy> wrapper1= Wrappers.lambdaQuery();
        wrapper1.eq(SlVolumeProductionZy::getDelFlag,0);
        wrapper1.eq(SlVolumeProductionZy::getZyglId,managementimgVolumeProductionZyQuery.getVolumeProductionzyglId());
        if (managementimgVolumeProductionZyQuery.getShelfId()==null){
            if (!slGoodsShelves.isEmpty()) {
                wrapper1.eq(SlVolumeProductionZy::getShelfId, slGoodsShelves.get(0).getId());
            }
        }else{
            wrapper1.eq(SlVolumeProductionZy::getShelfId,managementimgVolumeProductionZyQuery.getShelfId());
        }
        if (managementimgVolumeProductionZyQuery.getStoreManagementNumber()==null){
            wrapper1.eq(SlVolumeProductionZy::getStoreManagementNumber,1);
        }else{
            wrapper1.eq(SlVolumeProductionZy::getStoreManagementNumber,managementimgVolumeProductionZyQuery.getStoreManagementNumber());
        }
 
        if (goodsSkuIdList.isEmpty()){
            goodsSkuIdList.add(-1L);
        }
        // 已经确认了转移
        if (StringUtils.hasLength(byId.getAuthorizationUrl())){
            wrapper1.in(SlVolumeProductionZy::getScrkId,goodsSkuIdList);
 
        }else{
            wrapper1.in(SlVolumeProductionZy::getRkId,goodsSkuIdList);
 
        }
 
 
        wrapper1.eq( SlVolumeProductionZy::getDelFlag,0);
        wrapper1.orderByDesc(SlVolumeProductionZy::getCreateTime);
        Page<SlVolumeProductionZy> page2 = slVolumeProductionZyMapper.selectPage(page, wrapper1);
        PageDTO<com.ruoyi.management.domain.dto.ManagementimgVolumeProductionZyVO> sl = PageDTO.of(page2, com.ruoyi.management.domain.dto.ManagementimgVolumeProductionZyVO.class);
        List<com.ruoyi.management.domain.dto.ManagementimgVolumeProductionZyVO> list2 = sl.getList();
        for(com.ruoyi.management.domain.dto.ManagementimgVolumeProductionZyVO list:list2) {
            SlVolumeProductionRk slVolumeProductionRk = slVolumeProductionRkMapper.selectById(list.getRkId());
            list.setStoreManagementNumber(slVolumeProductionRk.getStoreManagementNumber());
            list.setRkNumber(slVolumeProductionRk.getRkNumber());
            list.setRepertoryZhai(slVolumeProductionRk.getRepertoryZhai());
            SlGoodsMaterials slGoodsMaterials = slGoodsMaterialsMapper.selectById(slVolumeProductionRk.getMaterialsId());
            list.setGoodsMaterialsName(slGoodsMaterials.getGoodsMaterialsName());
            list.setIsConsume(slGoodsMaterials.getIsConsume());
            SlGoodsShelf slGoodsShelf = slGoodsShelfMapper.selectById(list.getShelfId());
            list.setGoodsShelfName(slGoodsShelf.getGoodsShelfName());
            list.setShelfId(slGoodsShelf.getId());
            if(list.getScrkId()!=null){
                SlVolumeProductionRk slVolumeProductionRk1 = slVolumeProductionRkMapper.selectById(list.getScrkId());
                list.setStoreManagementNumber(slVolumeProductionRk1.getStoreManagementNumber());
                list.setZyNumber(slVolumeProductionRk1.getRkNumber());
            }
            list.setZkNum(list.getRepertoryZhai());
        }
        v.setList(sl);
 
        return v;
    }
 
    @Override
    public VolumeProductionZyglInventoryVO getVolumeProductionZyglnventory(String id) {
        SlVolumeProductionZygl byId = this.getById(id);
        VolumeProductionZyglInventoryVO vo = new VolumeProductionZyglInventoryVO();
 
 
        SysUser data = sysUserClient.getSysUser(byId.getSysId()).getData();
        vo.setSysPhone(data.getPhonenumber());
        vo.setSysName(data.getNickName());
        vo.setStartiTime(byId.getStartiTime());
        SlStoreManagement slStoreManagement = slStoreManagementMapper.selectById(byId.getManagementId());
        vo.setStoreManagementName(slStoreManagement.getStoreManagementName());
        SlStoreManagement bslStoreManagement = slStoreManagementMapper.selectById(byId.getBmanagementId());
        vo.setBstoreManagementName(bslStoreManagement.getStoreManagementName());
        String directorId = slStoreManagement.getDirectorId();
        List<String> stri = Arrays.asList(directorId.split(","));
        String str1 = "";
        if (stri.size() > 0) {
            for (String str : stri) {
                SysUser data1 = sysUserClient.getSysUser(Long.valueOf(str)).getData();
                str1 += data1.getNickName() + ",";
            }
        }
        vo.setDirectorName(str1.substring(0, str1.length() - 1));
 
        String competentId = slStoreManagement.getCompetentId();
        List<String> stri1 = Arrays.asList(competentId.split(","));
        String str11 = "";
        if (stri1.size() > 0) {
            for (String str : stri1) {
                SysUser data1 = sysUserClient.getSysUser(Long.valueOf(str)).getData();
                str11 += data1.getNickName() + ",";
            }
        }
        vo.setCompetentName(str11.substring(0, str11.length() - 1));
 
        String administratorId = slStoreManagement.getAdministratorId();
        List<String> stri11 = Arrays.asList(administratorId.split(","));
        String str111 = "";
        if (stri11.size() > 0) {
            for (String str : stri11) {
                SysUser data1 = sysUserClient.getSysUser(Long.valueOf(str)).getData();
                str111 += data1.getNickName() + ",";
            }
        }
        vo.setAdministratorName(str111.substring(0, str111.length() - 1));
 
 
        LambdaQueryWrapper< SlVolumeProductionZy> wrapper2= Wrappers.lambdaQuery();
        wrapper2.eq(SlVolumeProductionZy::getZyglId,id);
        wrapper2.eq( SlVolumeProductionZy::getDelFlag,0);
        wrapper2.orderByDesc(SlVolumeProductionZy::getCreateTime);
        List<SlVolumeProductionZy> page2 = slVolumeProductionZyMapper.selectList(wrapper2);
        List<ManagementimgVolumeProductionZyVO> SlGoodsShelfDTO=new ArrayList<>();
        for(SlVolumeProductionZy list1:page2) {
            ManagementimgVolumeProductionZyVO list=new ManagementimgVolumeProductionZyVO();
            list.setId(list1.getId());
            list.setZyNum(list1.getZyNum());
            SlVolumeProductionRk slVolumeProductionRk = slVolumeProductionRkMapper.selectById(list1.getRkId());
            list.setStoreManagementNumber(slVolumeProductionRk.getStoreManagementNumber());
            list.setRkNumber(slVolumeProductionRk.getRkNumber());
            list.setRepertoryZhai(slVolumeProductionRk.getRepertoryZhai());
            SlGoodsMaterials slGoodsMaterials = slGoodsMaterialsMapper.selectById(slVolumeProductionRk.getMaterialsId());
            list.setGoodsMaterialsName(slGoodsMaterials.getGoodsMaterialsName());
            list.setIsConsume(slGoodsMaterials.getIsConsume());
            SlGoodsShelf slGoodsShelf = slGoodsShelfMapper.selectById(slVolumeProductionRk.getShelfId());
            list.setGoodsShelfName(slGoodsShelf.getGoodsShelfName());
 
            SlGoodsShelfDTO.add(list);
        }
        vo.setManagementimgVolumeProductionCkVOList(SlGoodsShelfDTO);
        return vo;
    }
 
    @Override
    public void zy(Long id,String authorizationUrl) {
        SlVolumeProductionZygl byId = this.getById(id);
        byId.setAuthorizationUrl(authorizationUrl);
        byId.setAuditStatus(6);
        byId.setPresentState(4);
        byId.setEndTime(new Date());
        this.updateById(byId);
        LambdaQueryWrapper<SlVolumeProductionZy> wrapper1 = Wrappers.lambdaQuery();
        wrapper1.eq(SlVolumeProductionZy::getZyglId, id);
        wrapper1.eq(SlVolumeProductionZy::getDelFlag, 0);
        wrapper1.orderByDesc(SlVolumeProductionZy::getCreateTime);
        List<SlVolumeProductionZy> page2 = slVolumeProductionZyMapper.selectList(wrapper1);
        // 新入库ids
        List<Long> collect = page2.stream().map(SlVolumeProductionZy::getScrkId).collect(Collectors.toList());
        for (SlVolumeProductionZy zy : page2) {
            // 确认转移之后扣库存
            SlVolumeProductionRk slVolumeProductionRk1 = slVolumeProductionRkMapper.selectById(zy.getRkId());
            slVolumeProductionRk1.setRepertoryZhai(slVolumeProductionRk1.getRepertoryZhai()-Long.valueOf(zy.getZyNum()));
            slVolumeProductionRkMapper.updateById(slVolumeProductionRk1);
            // 给被转移入仓库加库存数量
            LambdaQueryWrapper<ManagementGoodsMaterials> wrapper2 = Wrappers.lambdaQuery();
            wrapper2.eq(ManagementGoodsMaterials::getGoodsMaterialsId,zy.getMaterialsId());
            wrapper2.eq(ManagementGoodsMaterials::getManagementId,byId.getBmanagementId());
            wrapper2.eq(ManagementGoodsMaterials::getDelFlag, 0);
            ManagementGoodsMaterials managementGoodsMaterials = managementGoodsMaterialsMapper.selectOne(wrapper2);
            if (managementGoodsMaterials!=null){
                Long repertorySum = managementGoodsMaterials.getRepertorySum();
                Long repertoryZhai = managementGoodsMaterials.getRepertoryZhai();
                Long re=repertorySum+Long.valueOf(zy.getZyNum());
                Long re1=repertoryZhai+Long.valueOf(zy.getZyNum());
                managementGoodsMaterials.setRepertorySum(re);
                managementGoodsMaterials.setRepertoryZhai(re1);
                managementGoodsMaterials.setRepertoryChu(0);
                managementGoodsMaterialsMapper.updateById(managementGoodsMaterials);
            }else{
                ManagementGoodsMaterials managementGoodsMaterials1=new ManagementGoodsMaterials();
                managementGoodsMaterials1.setManagementId(byId.getBmanagementId());
                managementGoodsMaterials1.setGoodsMaterialsId(zy.getMaterialsId());
                managementGoodsMaterials1.setRepertoryZhai(Long.valueOf(zy.getZyNum()));
                managementGoodsMaterials1.setRepertorySum(Long.valueOf(zy.getZyNum()));
                managementGoodsMaterials1.setRepertoryChu(0);
                managementGoodsMaterials1.setCreateTime(new Date());
                managementGoodsMaterialsMapper.insert(managementGoodsMaterials1);
            }
            // 给转移仓库减去库存数量
            LambdaQueryWrapper<ManagementGoodsMaterials> wrapper3 = Wrappers.lambdaQuery();
            wrapper3.eq(ManagementGoodsMaterials::getGoodsMaterialsId,zy.getMaterialsId());
            wrapper3.eq(ManagementGoodsMaterials::getManagementId,byId.getManagementId());
            wrapper3.eq(ManagementGoodsMaterials::getDelFlag, 0);
            ManagementGoodsMaterials managementGoodsMaterials1 = managementGoodsMaterialsMapper.selectOne(wrapper3);
            if (managementGoodsMaterials1!=null){
                Long repertorySum = managementGoodsMaterials1.getRepertorySum();
                Long repertoryZhai = managementGoodsMaterials1.getRepertoryZhai();
                Long re=repertorySum-Long.valueOf(zy.getZyNum());
                Long re1=repertoryZhai-Long.valueOf(zy.getZyNum());
//                managementGoodsMaterials1.setRepertorySum(re);
                managementGoodsMaterials1.setRepertoryZhai(re1);
                managementGoodsMaterials1.setRepertoryChu(managementGoodsMaterials1.getRepertoryChu()+zy.getZyNum());
                managementGoodsMaterialsMapper.updateById(managementGoodsMaterials1);
            }
        }
 
    }
}