MobileBatchReceiptController.java
10.8 KB
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
227
228
229
package com.huaheng.mobile.receipt;
import com.alibaba.fastjson.JSONException;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.huaheng.api.wcs.domain.WcsTask;
import com.huaheng.common.constant.QuantityConstant;
import com.huaheng.common.utils.security.ShiroUtils;
import com.huaheng.framework.aspectj.lang.annotation.Log;
import com.huaheng.framework.aspectj.lang.constant.BusinessType;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.pc.config.container.domain.Container;
import com.huaheng.pc.config.container.domain.ContainerStatus;
import com.huaheng.pc.config.container.service.ContainerService;
import com.huaheng.pc.config.location.domain.Location;
import com.huaheng.pc.config.location.domain.LocationStatus;
import com.huaheng.pc.config.location.service.LocationService;
import com.huaheng.pc.config.material.domain.Material;
import com.huaheng.pc.config.material.service.MaterialService;
import com.huaheng.pc.receipt.receiptContainerDetail.service.ReceiptContainerDetailService;
import com.huaheng.pc.receipt.receiptContainerHeader.domain.ReceiptContainerView;
import com.huaheng.pc.receipt.receiptContainerHeader.service.ReceiptContainerHeaderService;
import com.huaheng.pc.receipt.receiptDetail.domain.ReceiptDetail;
import com.huaheng.pc.receipt.receiptDetail.service.ReceiptDetailService;
import com.huaheng.pc.receipt.receiptHeader.domain.ReceiptHeader;
import com.huaheng.pc.receipt.receiptHeader.service.ReceiptHeaderService;
import com.huaheng.pc.task.taskHeader.domain.TaskHeader;
import com.huaheng.pc.task.taskHeader.service.TaskHeaderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import javafx.concurrent.Task;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
/**
*
* @author Enzo Cotter
* @date 2019/12/15
*/
@CrossOrigin
@RestController
@RequestMapping("/mobile/receipt/batch")
@Api(tags = {"MobileBatchReceiptController"}, description = "移动端收货")
public class MobileBatchReceiptController {
@Resource
private ReceiptContainerHeaderService receiptContainerHeaderService;
@Resource
private ReceiptHeaderService receiptHeaderService;
@Resource
private ReceiptDetailService receiptDetailService;
@Resource
private ReceiptContainerDetailService receiptContainerDetailService;
@Resource
private ContainerService containerService;
@Resource
private MaterialService materialService;
@Resource
private LocationService locationService;
@Resource
private TaskHeaderService taskHeaderService;
@PostMapping("/scanBill")
@ApiOperation("移动端扫描入库单")
@Log(title = "移动端扫描入库单", action = BusinessType.OTHER)
public AjaxResult scanBill(@RequestBody @ApiParam(value="收货单号") Map<String, String> param) throws Exception {
if (param.get("code") == null || param.get("code").trim().length() < 1) {
throw new JSONException("收货单号(code)不能为空");
}
return receiptContainerDetailService.scanReceiptCode(param.get("code"));
}
@PostMapping("/scanContainer")
@ApiOperation("移动端入库扫描容器")
@Log(title = "移动端入库扫描容器", action = BusinessType.OTHER)
public AjaxResult scanContainer(@RequestBody @ApiParam(value="容器号") Map<String, String> param) throws Exception {
if (param.get("code") == null || param.get("code").trim().length() < 1) {
throw new JSONException("容器号(code)不能为空");
}
ReceiptContainerView receiptContainerView = new ReceiptContainerView();
receiptContainerView.setReceiptContainerCode(param.get("code"));
receiptContainerView.setTaskType((short)100);
AjaxResult result = receiptContainerHeaderService.checkContainer(receiptContainerView);
LambdaQueryWrapper<Container> containerLambdaQueryWrapper = Wrappers.lambdaQuery();
containerLambdaQueryWrapper.eq(Container::getCode, param.get("code"))
.eq(Container::getWarehouseCode, ShiroUtils.getWarehouseCode());
Container container = containerService.getOne(containerLambdaQueryWrapper);
if(!container.getStatus().equals("empty")) {
return AjaxResult.error("托盘状态不为空");
}
return result;
}
@PostMapping("/save")
@ApiOperation("移动端收货保存")
@Log(title = "移动端收货保存", action = BusinessType.OTHER)
public AjaxResult save(@RequestBody @ApiParam(value="收货单") List<ReceiptContainerView> record) throws Exception {
AjaxResult result = receiptContainerHeaderService.batchSave(record);
return result;
}
@PostMapping("/getMaterial")
@ApiOperation("移动端获取物料信息")
@Log(title = "移动端获取物料信息", action = BusinessType.OTHER)
public AjaxResult getMaterial(@RequestBody @ApiParam(value="物料号") Map<String, String> param) throws Exception {
if (param.get("code") == null || param.get("code").trim().length() < 1) {
throw new JSONException("容器号(code)不能为空");
}
if (param.get("companyCode") == null || param.get("companyCode").trim().length() < 1) {
throw new JSONException("(companyCode)不能为空");
}
if (param.get("companyId") == null || param.get("companyId").trim().length() < 1) {
throw new JSONException("(companyId)不能为空");
}
Material material = materialService.findAllByCode(param.get("code"));
if(material == null) {
return AjaxResult.error("没有该物料");
}
MaterialInfo materialInfo = new MaterialInfo();
materialInfo.setMaterialCode(material.getCode());
materialInfo.setMaterialName(material.getName());
materialInfo.setType(material.getSpec());
return AjaxResult.success(materialInfo);
}
@PostMapping("/checkLocation")
@ApiOperation("移动端验证库位")
@Log(title = "移动端验证库位", action = BusinessType.OTHER)
public AjaxResult checkLocation(@RequestBody @ApiParam(value="物料号") Map<String, String> param) throws Exception {
if (param.get("code") == null || param.get("code").trim().length() < 1) {
throw new JSONException("容器号(code)不能为空");
}
boolean result = locationService.checkLocation(param.get("code"));
if(!result) {
return AjaxResult.error("没有该库位");
}
return AjaxResult.success(result);
}
@PostMapping("/getFreeLocation")
@ApiOperation("移动端获得空闲库位")
@Log(title = "移动端获得空闲库位", action = BusinessType.OTHER)
public AjaxResult getFreeLocation(@RequestBody @ApiParam(value="物料号") Map<String, String> param) throws Exception {
if (param.get("materialCode") == null || param.get("materialCode").trim().length() < 1) {
throw new JSONException("materialCode不能为空");
}
if (param.get("batch") == null || param.get("batch").trim().length() < 1) {
throw new JSONException("batch不能为空");
}
String materialCode = param.get("materialCode");
String batch = param.get("batch");
boolean result = locationService.getFreeLocation(materialCode, batch);
if(!result) {
return AjaxResult.error("没有空闲的分区库位");
}
return AjaxResult.success(result);
}
@PostMapping("/getContainerCode")
@ApiOperation("移动端验证库位")
@Log(title = "移动端验证库位", action = BusinessType.OTHER)
public AjaxResult getContainerCode(@RequestBody @ApiParam(value="物料号") Map<String, String> param) throws Exception {
if (param.get("code") == null || param.get("code").trim().length() < 1) {
throw new JSONException("容器号(code)不能为空");
}
LambdaQueryWrapper<Location> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(Location::getCode, param.get("code"))
.eq(Location::getWarehouseCode, ShiroUtils.getWarehouseCode())
.eq(Location::getDeleted, false);
Location location = locationService.getOne(queryWrapper);
if(location == null) {
return AjaxResult.error("没有该库位");
}
return AjaxResult.success("成功", location.getContainerCode());
}
// @PostMapping("/quickSaveGoods")
// @ApiOperation("移动端收货保存")
// @Log(title = "移动端收货保存", action = BusinessType.OTHER)
// @Transactional(rollbackFor = Exception.class)
// public AjaxResult quickSaveGoods(@RequestBody @ApiParam(value="收货单") List<ReceiptBill> receiptBills) throws Exception {
// if (receiptBills == null || receiptBills.size() <=0) {
// throw new JSONException("没有收货信息");
// }
//
// /* 查询未完成的入库任务*/
// LambdaQueryWrapper<TaskHeader> taskQueryWrapper = Wrappers.lambdaQuery();
// taskQueryWrapper.eq(TaskHeader::getWarehouseCode, ShiroUtils.getWarehouseCode())
// .in(TaskHeader::getTaskType, QuantityConstant.TASK_TYPE_WHOLERECEIPT,
// QuantityConstant.TASK_TYPE_SUPPLEMENTRECEIPT)
// .lt(TaskHeader::getStatus, QuantityConstant.TASK_STATUS_COMPLETED);
//
// List<TaskHeader> taskHeaderList = taskHeaderService.list(taskQueryWrapper);
// if(!taskHeaderList.isEmpty()) {
// throw new JSONException("入库任务没有完成");
// }
//
// ReceiptContainerView record = new ReceiptContainerView();
// record.setReceiptContainerCode(receiptBills.get(0).getReceiptContainerCode());
// record.setLocationCode(receiptBills.get(0).getLocationCode());
// record.setTaskType((short)100);
// record.setCompanyCode(receiptBills.get(0).getCompanyCode());
//
// /* 验证容器*/
// LambdaQueryWrapper<Container> containerQueryWrapper = Wrappers.lambdaQuery();
// containerQueryWrapper.eq(Container::getCode, receiptBills.get(0).getReceiptContainerCode())
// .eq(Container::getWarehouseCode, ShiroUtils.getWarehouseCode());
//
// Container container = containerService.getOne(containerQueryWrapper);
// if(container == null) {
// throw new SecurityException("容器编码不存在");
// }
// if(!container.getStatus().equals("empty")) {
// return AjaxResult.error("托盘状态不为空");
// }
//
// receiptContainerHeaderService.mobileCheckLocationCode(record);
// return AjaxResult.success("收货成功");
// }
}