MobileBatchReceiptController.java
6.49 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
package com.huaheng.mobile.receipt;
import com.alibaba.fastjson.JSONException;
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.general.container.service.IContainerService;
import com.huaheng.pc.general.location.service.ILocationService;
import com.huaheng.pc.general.material.domain.Material;
import com.huaheng.pc.general.material.service.IMaterialService;
import com.huaheng.pc.receipt.receiptContainerDetail.service.IReceiptContainerDetailService;
import com.huaheng.pc.receipt.receiptContainerHeader.domain.ReceiptContainerView;
import com.huaheng.pc.receipt.receiptContainerHeader.service.IReceiptContainerHeaderService;
import com.huaheng.pc.receipt.receiptDetail.service.IReceiptDetailService;
import com.huaheng.pc.receipt.receiptHeader.service.IReceiptHeaderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
@CrossOrigin
@RestController
@RequestMapping("/mobile/receipt/batch")
@Api(tags = {"MobileBatchReceiptController"}, description = "移动端收货")
public class MobileBatchReceiptController {
@Resource
private IReceiptContainerHeaderService receiptContainerHeaderService;
@Resource
private IMaterialService materialService;
@Resource
private ILocationService locationService;
@Resource
private IReceiptHeaderService receiptHeaderService;
@Resource
private IReceiptDetailService receiptDetailService;
@Resource
private IReceiptContainerDetailService receiptContainerDetailService;
@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)不能为空");
AjaxResult result = receiptContainerHeaderService.scanReceiptCode(param.get("code"));
return result;
}
@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)不能为空");
AjaxResult result = receiptContainerHeaderService.checkContainer(param.get("code"));
return result;
}
@PostMapping("/save")
@ApiOperation("移动端收货保存")
@Log(title = "移动端收货保存", action = BusinessType.OTHER)
public AjaxResult save(@RequestBody @ApiParam(value="收货单") List<ReceiptContainerView> record) throws Exception {
AjaxResult result = receiptContainerHeaderService.mobileBatchSave(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)不能为空");
Material material = materialService.getMaterial(param.get("code"));
if(material == null) {
return AjaxResult.error("没有该物料");
}
MaterialInfo materialInfo = new MaterialInfo();
materialInfo.setMaterialCode(material.getCode());
materialInfo.setMaterialName(material.getName());
materialInfo.setType(material.getType());
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("/quickSaveGoods")
@ApiOperation("移动端收货保存")
@Log(title = "移动端收货保存", action = BusinessType.OTHER)
public AjaxResult quickSaveGoods(@RequestBody @ApiParam(value="收货单") List<ReceiptBill> receiptBills) throws Exception {
if (receiptBills == null || receiptBills.size() <=0) {
throw new JSONException("没有收货信息");
}
boolean result = locationService.checkLocation(receiptBills.get(0).locationCode);
if(!result) {
return AjaxResult.error("没有该库位");
}
receiptContainerHeaderService.checkContainer(receiptBills.get(0).getReceiptContainerCode());
int receiptHeaderId = receiptHeaderService.createTodayHeader();
List<Integer> receiptDetailIds = receiptDetailService.insertTodayReceiptDetail(receiptHeaderId, receiptBills);
if(receiptDetailIds != null && receiptDetailIds.size() > 0) {
int containerHeaderId = receiptContainerHeaderService.insertTodayReceiptHeader(receiptBills.get(0).getReceiptContainerCode(), receiptBills.get(0).getLocationCode());
if(containerHeaderId > 0) {
List<Integer> receiptContainerDetailIds = receiptContainerDetailService.insertTodayReceiptcContainerDetail(containerHeaderId, receiptHeaderId, receiptDetailIds, receiptBills);
if(receiptContainerDetailIds != null && receiptContainerDetailIds.size() > 0) {
} else {
return AjaxResult.error("入库组盘失败");
}
} else {
return AjaxResult.error("插入入库容器表单头失败");
}
} else {
return AjaxResult.error("插入入库明细表单失败");
}
return AjaxResult.success("收货成功");
}
}