123
ZY
2025-05-14 ce641926a957d238b202aa0d9dac3b8f15aff153
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
//package com.zy.core;
//
//import com.core.exception.CoolException;
//import com.zy.asrs.entity.LocMast;
//import com.zy.asrs.entity.WrkMast;
//import com.zy.asrs.service.WrkMastService;
//import com.zy.core.cache.MessageQueue;
//import com.zy.core.cache.SlaveConnection;
//import com.zy.core.enums.SlaveType;
//import com.zy.core.model.Task;
//import com.zy.core.model.protocol.StaProtocol;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.transaction.interceptor.TransactionAspectSupport;
//
//import java.util.Date;
//
//public class Test {
//
//    public synchronized void autoEmptyOut() {
//        DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, 1);
//        Integer autoOutSite = 103;
//        //如果站点可出禁用,则不生成空盘出库任务
//        StaProtocol staProtocol = devpThread.getStation().get(autoOutSite);
//        if (staProtocol == null) {
//            return;
//        } else {
//            staProtocol = staProtocol.clone();
//        }
//        if (staProtocol.isAutoing()  //自动
//                && !staProtocol.isLoading()  //无物
////                && staProtocol.isOutEnable()  //可出信号
//                && staProtocol.getWorkNo() == 0) {
////            WrkMast pakoutEmpty = wrkMastMapper.selectPakoutEmpty(autoOutSite);
////            if (null != pakoutEmpty) {
////                return;
////            }
//
//            LocMast locMast = locMastService.getById("0200404");
//            if (locMast != null && locMast.getLocSts().equalsIgnoreCase("D")) {
//                try {
//                    Date now = new Date();
//                    // 保存工作档
//                    WrkMast wrkMast = new WrkMast();
//                    int workNo = commonService.getWorkNo(0);
//                    wrkMast.setWrkNo(workNo);
//                    wrkMast.setIoTime(now);
//                    wrkMast.setWrkSts(11L); // 工作状态:11.生成出库ID
//                    wrkMast.setIoType(110); // 入出库状态: 110.空板出库
//                    wrkMast.setIoPri(999D);
//                    wrkMast.setSourceStaNo(103); // 源站
//                    wrkMast.setStaNo(0); // 目标站
//                    wrkMast.setCrnNo(1);
//                    wrkMast.setSourceLocNo("0200404"); // 源库位
//                    wrkMast.setFullPlt("N"); // 满板:Y
//                    wrkMast.setPicking("N"); // 拣料
//                    wrkMast.setExitMk("N"); // 退出
//                    wrkMast.setEmptyMk("Y"); // 空板
//                    wrkMast.setLinkMis("N");
//                    wrkMast.setAppeUser(1L);
//                    wrkMast.setTenant(1L);
//                    wrkMast.setAppeTime(now);
//                    wrkMast.setModiUser(1L);
//                    wrkMast.setModiTime(now);
//                    wrkMast.setMemo("生成自动空板出库");
//                    boolean res = wrkMastService.save(wrkMast);
//                    // 更新库位状态 D.空板 -> R.出库预约
//                    if (locMast.getLocSts().equals("D")) {
//                        locMast.setLocSts("R");
//                        locMast.setModiUser(1L);
//                        locMast.setModiTime(now);
//                        if (!locMastService.updateById(locMast)) {
//                            throw new CoolException("更新库位状态失败");
//                        }
//                    }
//                } catch (Exception e) {
//                    e.printStackTrace();
//                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
//                }
//            }
//        }
//    }
//
//    @Autowired
//    private WrkMastService wrkMastService;
//
//    public synchronized void autoEmptyIn() {
//        DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, 1);
//        StaProtocol staProtocol = devpThread.getStation().get(103);
//        if (staProtocol == null) {
//            return;
//        } else {
//            staProtocol = staProtocol.clone();
//        }
//        if (staProtocol.isAutoing()  //自动
//                && staProtocol.isLoading()  //有物
////                && staProtocol.isInEnable()  //可入信号
//            // && (staProtocol.getWorkNo() == 0 || staProtocol.getWorkNo() >= 9990) //工作号为0或者工作号是9991~9999(输送机留用)
//        ) {
//            LocMast locMast = locMastService.getById("0200404");
//            if (locMast != null && locMast.getLocSts().equalsIgnoreCase("O")) {
//                try {
//                    Date now = new Date();
//                    // 生成工作档
//                    WrkMast wrkMast = new WrkMast();
//                    int workNo = commonService.getWorkNo(0);
//                    wrkMast.setWrkNo(workNo);
//                    wrkMast.setIoTime(now);
//                    wrkMast.setWrkSts(2L);
//                    wrkMast.setIoPri(999D);
//                    wrkMast.setIoType(10);
//                    wrkMast.setTenant(1L);
//                    wrkMast.setCrnNo(1);
//                    wrkMast.setSourceStaNo(101);
//                    wrkMast.setStaNo(103);
//                    wrkMast.setLocNo("0200404");
//                    wrkMast.setFullPlt("N"); // 满板:N
//                    wrkMast.setPicking("N"); // 拣料
//                    wrkMast.setExitMk("N"); // 退出
//                    wrkMast.setEmptyMk("Y"); // 空板
//                    wrkMast.setLinkMis("Y");
//                    // 操作人员数据
//                    wrkMast.setAppeTime(now);
//                    wrkMast.setModiTime(now);
//                    wrkMast.setMemo("自动空托入库");
//                    boolean res = wrkMastService.save(wrkMast);
//                    staProtocol.setWorkNo(Short.parseShort(wrkMast.getWrkNo() + ""));
//                    staProtocol.setStaNo(Short.parseShort(wrkMast.getStaNo() + ""));
//                    boolean result = MessageQueue.offer(SlaveType.Devp, 1, new Task(2, staProtocol));
//                    log.info("输送线下发(存在设备上走的工作档,直接下发!)):" + wrkMast.getWrkNo() + "," + wrkMast.getStaNo());
//                    // 更新目标库位状态
//                    if (locMast.getLocSts().equals("O")) {
//                        locMast.setLocSts("S"); // S.入库预约
//                        locMast.setModiUser(789L);
//                        locMast.setModiTime(now);
//                        if (!locMastService.updateById(locMast)) {
//                            throw new CoolException("改变库位状态失败");
//                        }
//                    }
//                } catch (Exception e) {
//                    e.printStackTrace();
//                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
//                }
//            }
//        }
//    }
//}