自动化立体仓库 - WMS系统
zyx
2024-01-05 0e46bb0cfc8b59ad5527f0b70c49f95aeac4bbbd
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
package com.zy.asrs.service.impl;
 
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.core.common.Cools;
import com.zy.asrs.entity.OrderDetl;
import com.zy.asrs.entity.Pla;
import com.zy.asrs.entity.PlaQty;
import com.zy.asrs.mapper.PlaMapper;
import com.zy.asrs.service.PlaQtyService;
import com.zy.asrs.service.PlaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import java.util.Date;
import java.util.List;
 
@Service("plaService")
public class PlaServiceImpl extends ServiceImpl<PlaMapper, Pla> implements PlaService {
    @Autowired
    private PlaQtyService plaQtyService;
 
    public Pla selectByBatchAndPackageNo(String batch, String packageNo) {
        return this.selectOne(new EntityWrapper<Pla>().eq("batch",batch).eq("package_no",packageNo));
    }
 
    @Override
    @Transactional
    public void queryStock(OrderDetl orderDetl, List<PlaQty> plaQties) {
 
        //筛选条件 批号、包好、熔点、熔指、黄度、不透明度
        Wrapper<Pla> wrapper = new EntityWrapper<Pla>();
        if(!Cools.isEmpty(orderDetl.getBatch())){
            wrapper.eq("batch",orderDetl.getBatch());
        }
        if(!Cools.isEmpty(orderDetl.getBrand())){
            wrapper.eq("package_no",orderDetl.getBrand());
        }
        wrapper.eq("status","已入库");
        wrapper.ge("finger_melting", orderDetl.getFingerMeltingMin()).le("finger_melting", orderDetl.getFingerMeltingMax());
        wrapper.ge("fusing_point", orderDetl.getFusingPointMin()).le("fusing_point", orderDetl.getFusingPointMax());
        wrapper.ge("yellowness", orderDetl.getYellownessMin()).le("yellowness", orderDetl.getYellownessMax());
        wrapper.ge("opacity", orderDetl.getOpacityMin()).le("opacity", orderDetl.getOpacityMax());
        wrapper.orderBy("pakin_time");
 
        List<Pla> plas = this.selectList(wrapper);
        //总共的出库的数量(总计出库数量-作业数量)
        if(Cools.isEmpty(orderDetl.getWorkQty())){
            orderDetl.setWorkQty(0.0);
        }
        Double anfme = orderDetl.getAnfme() - orderDetl.getWorkQty();
 
        for (Pla pla : plas){
            //库存数量(剩余重量-库存作业数量)
            Double weightAnfme = pla.getWeightAnfme() - pla.getQtyAnfme();
            if(weightAnfme <= 0){
                continue;
            }
            //需要减去此次出库预览其他订单需出库的数量
            for (PlaQty plaQty : plaQties){
                if(Cools.eq(plaQty.getBatch(),pla.getBatch()) && Cools.eq(plaQty.getPackageNo(),pla.getPackageNo())){
                    weightAnfme -= plaQty.getQtyAnfme();
                }
            }
 
            if(weightAnfme > anfme){
                //如果该批次包号剩余重量大于订单明细数量,则返回plaQties
                PlaQty plaQty = new PlaQty(pla.getBatch(),pla.getPackageNo(),orderDetl.getId(),orderDetl.getOrderId(),orderDetl.getOrderNo(),anfme,pla.getLocNo(),new Date());
                anfme = 0.0;
                plaQties.add(plaQty);
                break;
            }else {
                PlaQty plaQty = new PlaQty(pla.getBatch(),pla.getPackageNo(),orderDetl.getId(),orderDetl.getOrderId(),orderDetl.getOrderNo(),weightAnfme,pla.getLocNo(),new Date());
                anfme -= weightAnfme;
                plaQties.add(plaQty);
            }
        }
 
        if(anfme > 0){
            PlaQty plaQty = new PlaQty(orderDetl.getBatch(),orderDetl.getBrand(),orderDetl.getId(),orderDetl.getOrderId(),orderDetl.getOrderNo(),anfme,null,new Date());
            plaQties.add(plaQty);
        }
 
    }
}