MobileInventoryController.java
4.86 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
package com.huaheng.mobile.inventory;
import com.alibaba.fastjson.JSONException;
import com.huaheng.common.support.Convert;
import com.huaheng.common.utils.StringUtils;
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.location.domain.Location;
import com.huaheng.pc.general.location.service.ILocationService;
import com.huaheng.pc.inventory.inventory.domain.Inventory;
import com.huaheng.pc.inventory.inventory.service.IInventoryService;
import com.huaheng.pc.task.task.service.ITaskService;
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.Map;
@CrossOrigin
@RestController
@RequestMapping("/mobile/inventory")
@Api(tags = {"MobileInventoryController"}, description = "手机立体库库存相关")
public class MobileInventoryController {
@Resource
private IInventoryService inventoryService;
@Resource
private ITaskService taskService;
@Resource
private ILocationService locationService;
@PostMapping("/getInventoryInfo")
@ApiOperation("移动端获得库存详情")
@Log(title = "移动端获得库存详情", action = BusinessType.OTHER)
public AjaxResult getInventoryInfo(@RequestBody @ApiParam(value="物料编码或者库位号") Map<String, String> param) {
if (param.get("code") == null || param.get("code").trim().length() < 1)
throw new JSONException("查询码(code)不能为空");
return inventoryService.selectListEntityByCode(param.get("code"));
}
@PostMapping("/getInventoryForecast")
@ApiOperation("移动端获得库存联想词")
@Log(title = "移动端获得库存联想词", action = BusinessType.OTHER)
public AjaxResult getInventoryForecast(@RequestBody @ApiParam(value="物料编码或者库位号") Map<String, String> param) {
if (param.get("code") == null || param.get("code").trim().length() < 1)
throw new JSONException("查询码(code)不能为空");
return inventoryService.getInventoryForecast(param.get("code"));
}
@PostMapping("/createCheckOutTask")
@ApiOperation("移动端创建出库查看任务")
@ResponseBody
public AjaxResult createCheckOutTask(@RequestBody @ApiParam(value="库存ids") Map<String, String> param){
String ids = param.get("ids");
if(StringUtils.isEmpty(ids)){
return AjaxResult.error("ids不能为空");
}
return taskService.createMobileCheckOutTask(ids.split(","));
}
@PostMapping("/transfer")
@ApiOperation("移动端创建移库任务")
@ResponseBody
public AjaxResult transfer(@RequestBody @ApiParam(value="库位情况") Map<String, String> param){
String sourceLocation = param.get("sourceLocation");
String destinationLocation = param.get("destinationLocation");
return taskService.createMobileTransferTask(sourceLocation,destinationLocation);
}
@PostMapping( "/execute")
@ApiOperation("执行立库任务")
@ResponseBody
public AjaxResult execute(@RequestBody @ApiParam(value="任务id") Map<String, String> param)
{
String taskId = param.get("taskId");
if (StringUtils.isEmpty(taskId))
return AjaxResult.error("taskId不能为空");
AjaxResult ajaxResult = taskService.sendTaskToWcs(Convert.toIntArray(taskId));
return ajaxResult;
}
@PostMapping( "/isLocation")
@ApiOperation("判断是不是库位")
@ResponseBody
public AjaxResult isLocation(@RequestBody @ApiParam(value="任务id") Map<String, String> param)
{
String code = param.get("code");
if (StringUtils.isEmpty(code))
return AjaxResult.error("location不能为空");
Location condition = new Location();
condition.setCode(code);
Location location = locationService.selectFirstEntity(condition);
if(location == null) {
return AjaxResult.error("没有这个库位");
}
return AjaxResult.success("库位存在");
}
@PostMapping("/getLocationCode")
@ApiOperation("移动端获得库位联想词")
@Log(title = "移动端获得库位联想词", action = BusinessType.OTHER)
public AjaxResult getLocationCode(@RequestBody @ApiParam(value="库位号") Map<String, String> param) {
if (param.get("code") == null || param.get("code").trim().length() < 1)
throw new JSONException("查询码(code)不能为空");
String type = param.get("type");
if (type == null || type.trim().length() < 1)
throw new JSONException("type不能为空");
return inventoryService.getLocationForecast(param.get("code"), Integer.parseInt(type));
}
}