Blame view

src/main/java/com/huaheng/api/acs/controller/AcsController.java 8.33 KB
1
2
package com.huaheng.api.acs.controller;
3
import java.math.BigDecimal;
4
import java.util.ArrayList;
5
import java.util.List;
6
7
8

import javax.annotation.Resource;
9
10
import com.huaheng.api.acs.domain.StackInfo;
import com.huaheng.api.acs.domain.StackPoint;
11
12
import com.huaheng.api.wcs.controller.EmptyContainerController;
import com.huaheng.api.wcs.domain.ManyEmptyDomain;
13
14
import org.springframework.web.bind.annotation.*;
tongzhonghao authored
15
import com.alibaba.fastjson.JSON;
16
import com.huaheng.api.acs.domain.AGVCallParam;
17
import com.huaheng.api.acs.domain.AcsStatus;
18
import com.huaheng.api.acs.service.AcsReceiptService;
19
import com.huaheng.api.acs.service.AcsService;
tongzhonghao authored
20
21
22
import com.huaheng.common.constant.QuantityConstant;
import com.huaheng.common.utils.StringUtils;
import com.huaheng.common.utils.http.OkHttpUtils;
23
24
25
import com.huaheng.framework.aspectj.lang.annotation.ApiLogger;
import com.huaheng.framework.web.controller.BaseController;
import com.huaheng.framework.web.domain.AjaxResult;
26
import com.huaheng.mobile.receipt.ReceiptBill;
tongzhonghao authored
27
28
29
30
import com.huaheng.pc.config.address.service.AddressService;
import com.huaheng.pc.sap.domain.WeightRollNumberInfo;
import com.huaheng.pc.sap.service.WeightRollNumberInfoService;
31
import io.swagger.annotations.ApiOperation;
32
33

@RestController
周鸿 authored
34
@RequestMapping("/agv")
35
36
37
38
public class AcsController extends BaseController {

    @Resource
    private AcsService acsService;
tongzhonghao authored
39
40
    @Resource
    private WeightRollNumberInfoService weightRollNumberInfoService;
41
    @Resource
tongzhonghao authored
42
    private AddressService addressService;
43
44
    @Resource
    private AcsReceiptService acsReceiptService;
45
46
    @Resource
    private EmptyContainerController emptyContainerController;
周鸿 authored
47
48
    /**
49
50
     * status 20 任务执行中;
     * 50 取货完成;
tongzhonghao authored
51
     * 90 任务完成;
52
     * @param  acsStatus
53
54
     * @return
     */
周鸿 authored
55
    @PostMapping("/notifyAGVTask")
56
57
    @ApiOperation("更新AGV状态")
    @ResponseBody
58
    @ApiLogger(apiName = "更新AGV状态", from = "acs")
周鸿 authored
59
    public AjaxResult notifyAGVTask(@RequestBody AcsStatus acsStatus) {
肖超群 authored
60
        AjaxResult ajaxResult = handleMultiProcess("notifyAGVTask", new MultiProcessListener() {
61
62
            @Override
            public AjaxResult doProcess() {
63
                AjaxResult ajaxResult = acsService.notifyAGVTask(acsStatus);
64
65
66
                return ajaxResult;
            }
        });
周鸿 authored
67
        return ajaxResult;
68
69
70
71
72
73
74
75
76
77
78
79
80
81
    }

    /**
     * status 20 任务执行中;
     * 50 取货完成;
     * 90 任务完成;
     * @param  acsStatus
     * @return
     */
    @PostMapping("/bindContainer")
    @ApiOperation("玻璃布物料绑定托盘")
    @ResponseBody
    @ApiLogger(apiName = "玻璃布物料绑定托盘", from = "acs")
    public AjaxResult bindContainer(@RequestBody AcsStatus acsStatus) {
肖超群 authored
82
        AjaxResult ajaxResult = handleMultiProcess("bindContainer", new MultiProcessListener() {
83
84
            @Override
            public AjaxResult doProcess() {
85
86
                AjaxResult ajaxResult = acsService.bindContainer(acsStatus);
                return ajaxResult;
87
88
89
            }
        });
        return ajaxResult;
90
91
    }
tongzhonghao authored
92
93
周鸿 authored
94
    /**
95
     * pltype 1->片状托架0->卷状托架,2->特殊托架
周鸿 authored
96
97
98
99
100
101
     * containerType 1.请求入库卷托盘;2.请求入库片托盘;
     * 3.请求出库卷托盘;0.请求出片状托盘
     * @param  param
     * @return
     */
102
    @PostMapping("/agvCallEmptyOut")
103
    @ApiOperation("ACS呼叫空托盘出库")
104
    @ResponseBody
105
    @ApiLogger(apiName = "ACS呼叫空托盘出库", from = "acs")
106
107
108
109
110
    public AjaxResult agvCallEmptyOut(@RequestBody AGVCallParam param) {
        Integer containerType = param.getContainerType();
        String port = param.getPort();
        int area = param.getArea();
        String warehouseCode = param.getWarehouseCode();
111
112
113
        if (area == 0) {
            return AjaxResult.error("库区不嫩为空");
        }
周鸿 authored
114
        if (area == 1) {
115
116
            containerType = 0;
        }
117
        if (containerType == null) {
118
119
            return AjaxResult.error("容器类型不存在");
        }
120
        if (StringUtils.isEmpty(port)) {
121
122
            return AjaxResult.error("站台不能为空");
        }
123
        if (StringUtils.isEmpty(warehouseCode)) {
124
125
            return AjaxResult.error("仓库不能为空");
        }
126
        AjaxResult ajaxResult = null;
127
        Integer finalContainerType = containerType;
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
        if(area == 1){
            ManyEmptyDomain domain = new ManyEmptyDomain();
            domain.setWarehouseCode(QuantityConstant.WAREHOUSECODE);
            domain.setArea(1+"");
            domain.setPort(port);
            ajaxResult = emptyContainerController.wcsCallEmptyOut(domain);
        }else{
            ajaxResult = handleQuest("agvCallEmptyOut", new MultiProcessListener() {
                @Override
                public AjaxResult doProcess() {
                    AjaxResult ajaxResult = acsService.agvCallEmptyOut(area, port, warehouseCode, finalContainerType);
                    return ajaxResult;
                }
            });
        }
144
145
146
        return ajaxResult;
    }
147
148
149
150
    @PostMapping("/getReceiptContainerByB")
    @ApiOperation("ACS传入入库数据")
    @ResponseBody
    @ApiLogger(apiName = "ACS传入入库数据", from = "acs")
周鸿 authored
151
    public AjaxResult getReceiptContainerByB(@RequestBody List<ReceiptBill> receiptBills) {
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

        List<StackPoint> stackPoints = new ArrayList<>();
        StackInfo stackInfo = new StackInfo();
        String stackType = null;
        Integer totalQty = 0;
        String containerCode = null;
        for (ReceiptBill receiptBill : receiptBills) {
            StackPoint stackPoint = new StackPoint();
            String allCode = receiptBill.getAllCode();
            if(StringUtils.isNotEmpty(allCode)){
                String[] materialInfo = allCode.split(" ");
                stackPoint.setPosition(receiptBill.getContainerNumber());
                stackPoint.setMaterialCode(materialInfo[0]);
                stackPoint.setQty(BigDecimal.valueOf(Integer.valueOf(materialInfo[1])));
                stackPoint.setLot(materialInfo[2]);
                stackPoints.add(stackPoint);
            }
            if(StringUtils.isEmpty(receiptBill.getStackType())){
                return AjaxResult.error("明细没有垛型");
            }
            stackType = receiptBill.getStackType();
            totalQty = receiptBill.getTotalQty();
            containerCode = receiptBill.getContainerCode();
        }
        stackInfo.setArea(11);
        stackInfo.setContainerCode(containerCode);
        stackInfo.setStackType(stackType);
        stackInfo.setBoxTotalQty(totalQty);
        stackInfo.setStackPoints(stackPoints);
肖超群 authored
182
        AjaxResult ajaxResult = handleMultiProcess("getReceiptContainerByB", new MultiProcessListener() {
183
184
            @Override
            public AjaxResult doProcess() {
185
                AjaxResult ajaxResult = acsReceiptService.getReceiptContainerByB(stackInfo);
186
187
188
189
190
                return ajaxResult;
            }
        });
        return ajaxResult;
    }
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

    @PostMapping("/pushWeightRollNumber")
    @ApiOperation("推送卷号重量信息")
    @ResponseBody
    @ApiLogger(apiName = "推送卷号重量信息", from = "acs")
    public AjaxResult pushWeightRollNumber(@RequestBody WeightRollNumberInfo weightRollNumberInfo) {

        String rollNumber = weightRollNumberInfo.getRollNumber();
        if (StringUtils.isEmpty(rollNumber)) {
            return AjaxResult.error("卷号不为空:");
        }
        AjaxResult ajaxResult = handleQuest("pushWeightRollNumber", new MultiProcessListener() {
            @Override
            public AjaxResult doProcess() {
                boolean save = weightRollNumberInfoService.save(weightRollNumberInfo);
                String bodypost = null;
                try {
                    String url = addressService.selectAddress(QuantityConstant.WEIGHT_ROLLNUMBER_URL, weightRollNumberInfo.getWarehouseCode(),
                            weightRollNumberInfo.getArea());
                    String param = JSON.toJSONString(weightRollNumberInfo);
                    bodypost = OkHttpUtils.bodypost(url, param);
                    weightRollNumberInfo.setSend(1);
                    weightRollNumberInfoService.updateById(weightRollNumberInfo);
                } catch (Exception e) {
                    e.printStackTrace();
                } finally {
                    return AjaxResult.toAjax(save).setData(bodypost);
                }
            }
        });
        return ajaxResult;
    }
223
}