|
1
2
|
package com.huaheng.api.sap.controller;
|
|
3
4
|
import java.util.List;
|
|
5
6
7
|
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.*;
|
|
8
9
|
import com.huaheng.api.sap.domain.ZarDomain;
|
|
10
|
import com.huaheng.api.sap.service.ReturnSapTaskService;
|
|
11
|
import com.huaheng.api.sap.service.ZarApiService;
|
|
12
13
|
import com.huaheng.common.exception.service.ServiceException;
import com.huaheng.common.utils.StringUtils;
|
|
14
15
16
17
18
|
import com.huaheng.framework.aspectj.lang.annotation.ApiLogger;
import com.huaheng.framework.aspectj.lang.annotation.Log;
import com.huaheng.framework.aspectj.lang.constant.BusinessType;
import com.huaheng.framework.web.controller.BaseController;
import com.huaheng.framework.web.domain.AjaxResult;
|
|
19
|
import com.huaheng.pc.sap.domain.ReturnSapTaskLog;
|
|
20
|
import com.huaheng.pc.sap.domain.Zarsh;
|
|
21
|
import com.huaheng.pc.sap.service.BackSapStatusService;
|
|
22
|
import com.huaheng.pc.sap.service.LockSapUniqueIdService;
|
|
23
|
import com.huaheng.pc.sap.service.ReturnSapTaskLogService;
|
|
24
|
import com.huaheng.pc.sap.service.SapTaskLogService;
|
|
25
|
|
|
26
27
28
29
|
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@RestController
|
|
30
|
@RequestMapping("/api/zarapi")
|
|
31
|
@Api(tags = {"入库单接口"}, value = "入库单接口receipt")
|
|
32
|
public class SAPApiController extends BaseController {
|
|
33
34
35
|
@Resource
private ZarApiService zarApiService;
|
|
36
37
|
@Resource
private BackSapStatusService backSapStatusService;
|
|
38
39
|
@Resource
private SapTaskLogService sapTaskLogService;
|
|
40
41
|
@Resource
private LockSapUniqueIdService lockSapUniqueIdService;
|
|
42
43
44
45
|
@Resource
private ReturnSapTaskService returnSapTaskService;
@Resource
private ReturnSapTaskLogService returnSapTaskLogService;
|
|
46
47
|
/**
|
|
48
|
* SAP下发任务单据
|
|
49
|
*/
|
|
50
|
@Log(title = "SAP下发任务单据", action = BusinessType.INSERT)
|
|
51
|
@PostMapping("/save")
|
|
52
|
@ApiOperation("SAP下发任务单据")
|
|
53
|
@ResponseBody
|
|
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
@ApiLogger(apiName = "SAP下发任务单据", from = "ERP")
public AjaxResult save(@RequestBody ZarDomain zarDomain) {
if (StringUtils.isNull(zarDomain)) {
throw new ServiceException("参数为空");
}
Zarsh zarsh = zarDomain.getZarsh();
if (zarsh == null) {
throw new ServiceException("zarsh参数为空");
}
if (StringUtils.isEmpty(zarsh.getUniqueId())) {
throw new ServiceException("唯一号uniqueId参数为空");
}
// 判断出库、入库,然后在判断是否空托盘出入库
if (StringUtils.isEmpty(zarsh.getLgnum())) {
throw new ServiceException("仓库号为空");
}
|
|
70
|
if (StringUtils.isEmpty(zarsh.getMFlag())) {
|
|
71
72
|
throw new ServiceException("入库出库标志为空");
}
|
|
73
|
AjaxResult ajaxResult = handleMultiProcess("save", new MultiProcessListener() {
|
|
74
75
|
@Override
public AjaxResult doProcess() {
|
|
76
77
78
|
AjaxResult ajaxResult = null;
try {
ajaxResult = zarApiService.saveSapData(zarDomain);
|
|
79
|
sapTaskLogService.addSapTaskLog(zarDomain, ajaxResult.getMsg(), 0);
|
|
80
81
82
83
84
|
if (ajaxResult.hasErr()) {
lockSapUniqueIdService.lockStaionByUniqueId(zarsh);
} else {
lockSapUniqueIdService.unlockStaionByUniqueId(zarsh);
}
|
|
85
86
87
88
|
} catch (Exception e) {
// 调用sap的api,传递任务状态
ajaxResult = AjaxResult.error(e.getMessage());
backSapStatusService.addBackSapStatus(zarsh.getUniqueId(), zarsh.getLgnum(), null, "1", "C", null, e.getMessage());
|
|
89
|
sapTaskLogService.addSapTaskLog(zarDomain, e.getMessage(), 1);
|
|
90
|
lockSapUniqueIdService.lockStaionByUniqueId(zarsh);
|
|
91
|
}
|
|
92
93
94
|
return ajaxResult;
}
});
|
|
95
96
97
98
99
100
101
102
|
// if (ajaxResult == null || ajaxResult.hasErr()) {
// String msg = ajaxResult == null ? "" : ajaxResult.getMsg();
// // 调用sap的api,传递任务状态
// backSapStatusService.addBackSapStatus(zarsh.getUniqueId(), zarsh.getLgnum(), null, "1", "C", null, msg);
// sapTaskLogService.addSapTaskLog(zarsh, msg, 1);
// } else {
// sapTaskLogService.addSapTaskLog(zarsh, null, 0);
// }
|
|
103
104
105
|
return ajaxResult;
}
|
|
106
|
/**
|
|
107
|
* SAP同步WMS库存
|
|
108
|
*/
|
|
109
110
111
|
@Log(title = "SAP同步WMS库存", action = BusinessType.INSERT)
@PostMapping("/saveSapInventory")
@ApiOperation("SAP同步WMS库存")
|
|
112
|
@ResponseBody
|
|
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
@ApiLogger(apiName = "SAP同步WMS库存", from = "ERP")
public AjaxResult saveSapInventory(@RequestBody List<ReturnSapTaskLog> returnSapTaskLogs) {
if (returnSapTaskLogs == null) {
return AjaxResult.error("sap同步wms:参数为空");
}
ReturnSapTaskLog returnSapTaskLog = returnSapTaskLogs.get(0);
if (StringUtils.isNull(returnSapTaskLog)) {
return AjaxResult.error("sap同步wms:参数为空");
}
if (StringUtils.isEmpty(returnSapTaskLog.getLgnum())) {
return AjaxResult.error("sap同步wms:仓库号为空");
}
if (StringUtils.isEmpty(returnSapTaskLog.getLgort())) {
return AjaxResult.error("sap同步wms:参数为空");
}
if (StringUtils.isEmpty(returnSapTaskLog.getDrum_id())) {
return AjaxResult.error("sap同步wms:库存地点不能为空");
}
if (StringUtils.isEmpty(returnSapTaskLog.getLgpla())) {
return AjaxResult.error("sap同步wms:库位不能为空");
}
|
|
134
|
|
|
135
136
137
138
139
|
AjaxResult ajaxResult = handleMultiProcess("saveSapInventory", new MultiProcessListener() {
@Override
public AjaxResult doProcess() {
AjaxResult ajaxResult = null;
try {
|
|
140
141
|
ajaxResult = returnSapTaskService.saveSapInventory(returnSapTaskLogs);
returnSapTaskLogService.saveReturnSapTaskLog(returnSapTaskLogs, ajaxResult.getMsg());
|
|
142
|
} catch (Exception e) {
|
|
143
|
returnSapTaskLogService.saveReturnSapTaskLog(returnSapTaskLogs, e.getMessage());
|
|
144
145
146
147
148
149
|
e.printStackTrace();
}
return ajaxResult;
}
});
return ajaxResult;
|
|
150
151
|
}
|
|
152
|
}
|