自动化立体仓库 - WMS系统
dubin
2025-12-17 ed62b1bb0e4bbb8b7d4b6f4d980c941cfd11233e
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
package com.zy.asrs.service.impl;
 
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.core.common.Cools;
import com.core.exception.CoolException;
import com.zy.asrs.entity.*;
import com.zy.asrs.mapper.InOutMapper;
import com.zy.asrs.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import java.util.List;
 
@Service("InOutService")
public class InOutServiceImpl extends ServiceImpl<InOutMapper, InOut> implements InOutService {
 
    @Autowired
    private InOutMapper inOutMapper;
    @Autowired
    private LocDetlService locDetlService;
    @Autowired
    private MatBarcodeService matBarcodeService;
    @Autowired
    private WrkDetlService wrkDetlService;
    @Autowired
    private WaitPakinService waitPakinService;
    @Autowired
    private MatService matService;
    @Autowired
    private WrkMastService wrkMastService;
 
    @Override
    public InOut selectByMatnr(String matnr) {
        return inOutMapper.selectByMatnr(matnr);
    }
 
    @Transactional
    @Override
    public void deleteInOut(List<InOut> inOutList) {
        for (InOut inOut : inOutList) {
            //没有商品编号  直接删除
            if (inOut.getMatnr() == null){
                inOutMapper.deleteById(inOut.getId());
            }
            //判断是否有库存
            LocDetl locDetl = locDetlService.selectOne(new EntityWrapper<LocDetl>().eq("matnr", inOut.getMatnr()));
            if (locDetl != null){
                throw new CoolException("该模具存在库存,不能删除--->" + inOut.getMatnr());
            }
            //判断是否绑定
            MatBarcode matBarcode = matBarcodeService.selectbyMatnr(inOut.getMatnr());
            if (matBarcode != null){
                throw new CoolException("该模具已绑定托盘,不能删除--->" + inOut.getMatnr());
            }
            //判断是否有工作档
            WrkDetl wrkDetl = wrkDetlService.selectOne(new EntityWrapper<WrkDetl>().eq("matnr", inOut.getMatnr()));
            if (wrkDetl != null){
                WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_no", wrkDetl.getWrkNo()));
                if (wrkMast == null){
                    throw new CoolException("工作档异常,有工作明细档,无工作主档");
                }
                if ((wrkMast.getIoType() != 101 && wrkMast.getWrkSts() != 15) || (wrkMast.getIoType() != 103 && wrkMast.getWrkSts() != 14)){
                    throw new CoolException("该模具存在工作档,不能删除--->" + inOut.getMatnr());
                }
            }
            //判断是否组托
            List<WaitPakin> waitPakins = waitPakinService.selectList(new EntityWrapper<WaitPakin>().eq("matnr", inOut.getMatnr()));
            if (!Cools.isEmpty(waitPakins)){
                throw new CoolException("该模具已组托,不能删除--->" + inOut.getMatnr());
            }
            //判断是否有商品档案
            Mat mat = matService.selectByMatnr(inOut.getMatnr());
            if (mat != null){
                throw new CoolException("商品档案存在该模具,不能删除--->" + inOut.getMatnr());
            }
 
            inOutMapper.deleteById(inOut.getId());
        }
    }
}