自动化立体仓库 - WMS系统
lty
2026-04-16 d514c4c031247ba2903f2eca14ac266e3a36c994
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
package com.zy.asrs.task.handler;
 
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.core.common.Cools;
import com.zy.asrs.entity.LocMast;
import com.zy.asrs.entity.StaDesc;
import com.zy.asrs.entity.WrkMast;
import com.zy.asrs.entity.param.EmptyPlateOutParam;
import com.zy.asrs.service.BasDevpService;
import com.zy.asrs.service.LocMastService;
import com.zy.asrs.service.StaDescService;
import com.zy.asrs.service.WorkService;
import com.zy.asrs.service.WrkMastService;
import com.zy.asrs.task.AbstractHandler;
import com.zy.asrs.task.core.ReturnT;
import com.zy.system.entity.Config;
import com.zy.system.service.ConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
 
import java.util.ArrayList;
import java.util.List;
 
@Slf4j
@Service
public class AutoEmptyOutHandler extends AbstractHandler<String> {
    @Autowired
    private ConfigService configService;
    @Autowired
    private WrkMastService wrkMastService;
    @Autowired
    private LocMastService locMastService;
    @Autowired
    private WorkService workService;
    @Autowired
    private BasDevpService basDevpService;
    @Autowired
    private StaDescService staDescService;
    @Transactional
    public ReturnT<String> start() {
        try {
            Config config = configService.selectConfigByCode("EmptyMax");
            Integer max;
            if (Cools.isEmpty(config)) {
                max = 10;
            }else{
                max = Integer.valueOf(config.getValue());
            }
            for(Integer crnNo = 1; crnNo < 5; crnNo++){
                List<WrkMast> wrkMastList = wrkMastService.selectList(new EntityWrapper<WrkMast>()
                        .eq("crn_no", crnNo)
                        .eq("io_type", 110)
                );
                if(!wrkMastList.isEmpty()){continue;}
                Integer emptyLocCount = locMastService.selectCount(new EntityWrapper<LocMast>()
                        .eq("crn_no", crnNo)
                        .eq("loc_sts", "O")
                        .eq("frozen", 0)
                        .eq("deleted", 0)
                        .eq("whs_type", 1));
                if (emptyLocCount == null || emptyLocCount >= max) {
                    continue;
                }
 
                List<LocMast> locMastDList = locMastService.selectPage(
                        new Page<>(1, 3), //选三个空轴库位
                        new EntityWrapper<LocMast>()
                                .eq("crn_no", crnNo)
                                .eq("loc_sts", "D")
                                .eq("frozen", 0)
                                .eq("deleted", 0)
                                .eq("whs_type", 1)
                                .orderBy("lev1,bay1")
                ).getRecords();
                if (Cools.isEmpty(locMastDList)) {
                    continue;
                }
 
                List<String> locNos = new ArrayList<>();
                for (LocMast locMast : locMastDList) {
                    locNos.add(locMast.getLocNo());
                }
                EmptyPlateOutParam emptyPlateOutParam = new EmptyPlateOutParam();
                emptyPlateOutParam.setOutSite(1076);
                emptyPlateOutParam.setLocNos(locNos);
                workService.emptyPlateOut(emptyPlateOutParam, 1L);
 
            }
 
        } catch (Exception e) {
            log.error("fail", e);
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            return FAIL.setMsg(e.getMessage());
        }
        return SUCCESS;
    }
 
 
}