Junjie
2024-08-02 71fb0226eba99f4bd9503c1da89925f53fd54d8a
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
package com.zy.asrs.wms.asrs.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zy.asrs.framework.exception.CoolException;
import com.zy.asrs.wms.asrs.entity.WaitPakin;
import com.zy.asrs.wms.asrs.mapper.WaitPakinRuleMapper;
import com.zy.asrs.wms.asrs.entity.WaitPakinRule;
import com.zy.asrs.wms.asrs.service.WaitPakinRuleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zy.asrs.wms.asrs.service.WaitPakinService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.List;
 
@Service("waitPakinRuleService")
public class WaitPakinRuleServiceImpl extends ServiceImpl<WaitPakinRuleMapper, WaitPakinRule> implements WaitPakinRuleService {
 
    @Autowired
    private WaitPakinService waitPakinService;
 
    @Override
    public boolean rule(WaitPakin waitPakin) {
        List<WaitPakinRule> list = this.list(new LambdaQueryWrapper<WaitPakinRule>().eq(WaitPakinRule::getStatus, 1).orderByDesc(WaitPakinRule::getId));
        if (list.isEmpty()) {
            return true;//无规则,直接放行
        }
 
        List<WaitPakin> waitPakins = waitPakinService.list(new LambdaQueryWrapper<WaitPakin>().eq(WaitPakin::getBarcode, waitPakin.getBarcode()));
        if(waitPakins.isEmpty()) {
            return true;//无托盘,放行
        }
 
        WaitPakinRule waitPakinRule = list.get(0);
        //判断是否混载
        if (waitPakinRule.getPalletMixed() == 1) {
            //混载
            //判断是否允许多订单
            if (waitPakinRule.getPalletOrder() == 0) {
                //单订单
                for (WaitPakin pakin : waitPakins) {
                    if (!pakin.getOrderId().equals(waitPakin.getOrderId())) {
                        throw new CoolException("托盘不允许多订单");
                    }
                }
            }
 
        }else {
            //单放
            //判断组托通知档是否已经存在托盘
            if(!waitPakins.isEmpty()) {
                throw new CoolException("托盘已组托");
            }
        }
 
        return false;
    }
}