自动化立体仓库 - WMS系统
#
luxiaotao1123
2022-05-12 65770aa39d487c43ff342773c268367d597d3567
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
package com.zy.asrs.controller;
 
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.annotations.ManagerAuth;
import com.core.common.Cools;
import com.core.common.R;
import com.core.exception.CoolException;
import com.zy.asrs.entity.*;
import com.zy.asrs.entity.param.CombParam;
import com.zy.asrs.entity.param.MobileAdjustParam;
import com.zy.asrs.entity.result.MobileAdjustResult;
import com.zy.asrs.service.*;
import com.zy.common.web.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.*;
 
/**
 * 移动端接口控制器
 * Created by vincent on 2020/6/10
 */
@RestController
@RequestMapping("mobile")
public class MobileController extends BaseController  {
 
    @Autowired
    private MobileService mobileService;
    @Autowired
    private LocMastService locMastService;
    @Autowired
    private LocDetlService locDetlService;
    @Autowired
    private OrderService orderService;
    @Autowired
    private DocTypeService docTypeService;
    @Autowired
    private WrkMastService wrkMastService;
    @Autowired
    private WrkDetlService wrkDetlService;
    @Autowired
    private BasDevpService basDevpService;
    @Autowired
    private PackService packService;
 
    // 组托 ----------------------------------------------------------------------------------------------------
 
    /**
     * 根据单号检索单据数据
     * http://localhost:8081/jkwms/mobile/order/serach/orderNo/auth?orderNo=123123
     */
    @RequestMapping("/order/search/orderNo/auth")
    @ManagerAuth
    public R orderSearchByBarcode(@RequestParam String orderNo){
        Order order = orderService.selectByNo(orderNo);
        if (order == null) {
            return R.ok();
        }
        DocType docType = docTypeService.selectById(order.getDocType());
        if (docType.getPakin() == null || docType.getPakin() != 1) {
            return R.ok();
        }
        if (order.getSettle() > 2) {
            return R.ok();
        }
        List<OrderDetl> orderDetls = orderService.selectWorkingDetls(order.getId());
        if (Cools.isEmpty(orderDetls)) {
            return R.ok();
        }
        return R.ok().add(orderDetls);
    }
 
    @RequestMapping("/comb/auth")
    @ManagerAuth(memo = "组托")
    public R comb(@RequestBody CombParam combParam){
        mobileService.comb(combParam, getUserId());
        return R.ok("组托成功");
    }
 
    @RequestMapping("/pack/get/auth")
    @ManagerAuth
    public R packGet(@RequestParam String barcode){
        Pack pack = packService.selectByBarcode(barcode);
        if (pack == null) {
            return R.ok();
        }
        if (pack.getSettle() == 1L) {
            return R.ok().add(pack);
        }
        return R.ok("组托成功");
    }
 
    @RequestMapping("/pack/comb/auth")
    @ManagerAuth(memo = "下线组托")
    public R packComb(@RequestBody CombParam combParam){
        mobileService.packComb(combParam, getUserId());
        return R.ok("组托成功");
    }
 
 
    // 出库 ---------------------------------------------------------------------------------------------------
 
    @RequestMapping("/pakout/query/auth")
    @ManagerAuth
    public R pakoutQuery(@RequestParam(required = false) String barcode,
                         @RequestParam(required = false) Integer staNo,
                         @RequestParam(required = false) String matnr){
        if (Cools.isEmpty(barcode) && Cools.isEmpty(matnr)) {
            return R.ok();
        }
        if (!Cools.isEmpty(barcode)) {
            List<WrkDetl> wrkDetls = wrkDetlService.selectList(new EntityWrapper<WrkDetl>().eq("zpallet", barcode));
            return R.ok().add(wrkDetls);
        }
        if (!Cools.isEmpty(matnr)) {
            if (!Cools.isEmpty(staNo)) {
                List<WrkDetl> wrkDetls = wrkDetlService.selectPakoutQuery(staNo, matnr);
                return R.ok().add(wrkDetls);
            }
        }
        return R.ok();
    }
 
    @RequestMapping("/pakout/query/auth/v2")
    @ManagerAuth
    public R pakoutQueryV2(@RequestParam(required = false) String barcode,
                           @RequestParam(required = false) Integer staNo,
                           @RequestParam(required = false) String matnr){
        if (Cools.isEmpty(barcode) && Cools.isEmpty(matnr)) {
            return R.ok();
        }
        if (!Cools.isEmpty(barcode)) {
            WrkMast wrkMast = wrkMastService.selectByBarcode(barcode);
            if (wrkMast != null) {
                List<WrkDetl> wrkDetls = wrkDetlService.selectByWrkNo(wrkMast.getWrkNo());
                // 去除已出库确认的明细
                wrkDetls.removeIf(wrkDetl -> wrkDetl.getInspect() == 1);
                return R.ok().add(wrkDetls);
            }
        }
        if (!Cools.isEmpty(matnr)) {
            List<WrkDetl> wrkDetls = wrkDetlService.selectPakoutQuery(staNo, matnr);
            return R.ok().add(wrkDetls);
        }
        return R.ok();
    }
 
    @RequestMapping("/pakout/confirm/auth")
    @ManagerAuth
    @Transactional
    public R pakoutConfirm(@RequestBody List<WrkDetl> list) {
        if (Cools.isEmpty(list)) {
            return R.ok();
        }
 
        // todo:luxiaotao 拣料出库可修改工作档明细
 
 
 
        Set<Integer> wrkNos = new HashSet<>();
        for (WrkDetl wrkDetl : list) {
            wrkNos.add(wrkDetl.getWrkNo());
            wrkDetlService.updateInspect(wrkDetl.getWrkNo(), wrkDetl.getMatnr(), wrkDetl.getBatch());
        }
        for (Integer wrkNo : wrkNos) {
            WrkMast wrkMast = wrkMastService.selectById(wrkNo);
            if (wrkMast.getWrkSts() == 14 && (Cools.isEmpty(wrkMast.getInvWh()) || wrkMast.getInvWh().equals("N"))) {
                List<WrkDetl> wrkDetls = wrkDetlService.selectByWrkNo(wrkNo);
                boolean complete = true;
                for (WrkDetl wrkDetl : wrkDetls) {
                    if (wrkDetl.getInspect() == null || wrkDetl.getInspect() == 0) {
                        complete = false;
                        break;
                    }
                }
                if (complete) {
                    wrkMast.setInvWh("Y");
                    wrkMast.setModiTime(new Date());
                    if (!wrkMastService.updateById(wrkMast)) {
                        throw new CoolException("修改工作档" + wrkNo + "失败");
                    }
                }
            }
        }
        return R.ok("完成确认");
    }
 
 
    // 盘点 ----------------------------------------------------------------------------------------------------
 
    @RequestMapping("/checkDetl/auth")
    @ManagerAuth
    public R getCheckDetl(@RequestParam(required = false) Integer staNo) {
        if (null == staNo || staNo == 0) {
            return R.ok();
        }
        BasDevp basDevp = basDevpService.selectById(staNo);
        if (null != basDevp && basDevp.getWrkNo() != null) {
            WrkMast wrkMast = wrkMastService.selectById(basDevp.getWrkNo());
            if (wrkMast != null && wrkMast.getIoType() == 107) {
                List<WrkDetl> wrkDetls = wrkDetlService.selectByWrkNo(wrkMast.getWrkNo());
                if (!Cools.isEmpty(wrkDetls)) {
                    MobileAdjustResult result = new MobileAdjustResult();
                    result.setStaNo(staNo);
                    result.setWrkNo(wrkMast.getWrkNo());
                    result.setWrkDetls(wrkDetls);
                    return R.ok().add(result);
                }
            }
        }
        return R.ok();
    }
 
    @RequestMapping("/adjust/auth")
    @ManagerAuth(memo = "盘点")
    public R adjust(@RequestBody MobileAdjustParam combParam){
        mobileService.adjust(combParam, getUserId());
        return R.ok("盘点成功");
    }
 
 
}