自动化立体仓库 - WMS系统
野心家
2025-03-31 0823adb64bcb21d38ba022888ea8f2a0dc1a8541
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
package com.zy.common.model;
 
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.common.Cools;
import com.core.common.SpringUtils;
import com.core.exception.CoolException;
import com.zy.asrs.entity.LocDetl;
import com.zy.asrs.service.LocDetlService;
import lombok.Data;
 
import java.util.*;
 
/**
 * Created by vincent on 2020/6/17
 */
@Data
public class OutLocDto {
 
    private String locNo;
 
    private List<LocDetlDto> locDetlDtos = new ArrayList<>();
 
    public OutLocDto() {
    }
 
    public OutLocDto(String locNo, LocDetlDto locDetlDto) {
        this.locNo = locNo;
        this.locDetlDtos.add(locDetlDto);
    }
 
    public boolean isAll(){
        List<LocDetlDto> locDetlDtosCp = new ArrayList<>(this.locDetlDtos);
        // 查询当前库位号所有的库存明细
        LocDetlService locDetlService = SpringUtils.getBean(LocDetlService.class);
        List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", this.locNo));
        if (locDetls == null || locDetls.isEmpty()){
            throw new CoolException("检索库存明细失败,库位号=" + this.locNo);
        }
        int sameNumber = 0;
        for (LocDetl locDetl : locDetls) {
            Iterator<LocDetlDto> iterator = locDetlDtosCp.iterator();
            while (iterator.hasNext()) {
                LocDetlDto next = iterator.next();
                if (!next.getLocDetl().getMatnr().equals(locDetl.getMatnr())) {
                    continue;
                }
                if (!Cools.eq(next.getLocDetl().getBatch(), locDetl.getBatch())) {
                    continue;
                }
                if (next.getCount() > locDetl.getAnfme()) {
                    throw new CoolException("服务器内部错误");
                }
                if (next.getCount().equals(locDetl.getAnfme())) {
                    sameNumber++;
                    iterator.remove();
                    break;
                }
            }
        }
        return sameNumber == locDetls.size();
    }
 
}