|
1
2
3
|
package com.huaheng.api.wcs.controller;
|
|
4
|
import com.alibaba.fastjson.JSONArray;
|
|
5
6
7
8
9
10
11
12
13
14
15
16
17
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.huaheng.api.wcs.domain.ManyEmptyDomain;
import com.huaheng.api.wcs.service.warecellAllocation.LocationAllocationService;
import com.huaheng.common.constant.QuantityConstant;
import com.huaheng.common.exception.service.ServiceException;
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.controller.BaseController;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.framework.web.service.ConfigService;
|
|
18
|
import com.huaheng.pc.config.address.service.AddressService;
|
|
19
20
21
22
23
24
25
26
27
28
|
import com.huaheng.pc.config.container.domain.Container;
import com.huaheng.pc.config.container.service.ContainerService;
import com.huaheng.pc.config.locationHigh.domain.LocationHigh;
import com.huaheng.pc.config.locationHigh.service.LocationHighService;
import com.huaheng.pc.config.locationType.domain.LocationType;
import com.huaheng.pc.config.locationType.service.LocationTypeService;
import com.huaheng.pc.config.zone.domain.Zone;
import com.huaheng.pc.config.zone.service.ZoneService;
import com.huaheng.pc.inventory.inventoryHeader.domain.InventoryHeader;
import com.huaheng.pc.inventory.inventoryHeader.service.InventoryHeaderService;
|
|
29
30
|
import com.huaheng.pc.task.taskHeader.domain.TaskHeader;
import com.huaheng.pc.task.taskHeader.service.TaskHeaderService;
|
|
31
|
import com.huaheng.pc.task.taskHeader.service.WorkTaskService;
|
|
32
|
import com.sun.javafx.tk.Toolkit;
|
|
33
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
34
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
35
36
37
38
|
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
|
|
39
|
import java.util.ArrayList;
|
|
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
@RestController
@RequestMapping("/API/WMS/v2")
public class EmptyContainerController extends BaseController {
@Resource
private WorkTaskService workTaskService;
@Resource
private LocationAllocationService allocationService;
@Resource
private ConfigService configService;
@Resource
private ZoneService zoneService;
@Resource
private LocationTypeService locationTypeService;
@Resource
private LocationHighService locationHighService;
@Resource
private ContainerService containerService;
|
|
62
63
64
65
|
@Autowired
private AddressService addressService;
@Resource
private TaskHeaderService taskHeaderService;
|
|
66
67
68
69
70
71
72
73
74
75
76
77
78
|
/**
* 生成空托盘入库任务
* @return
*/
@PostMapping("/manyEmptyIn")
@Log(title = "任务-任务管理", operating = "生成空托盘组入库任务", action = BusinessType.INSERT)
@ResponseBody
@Transactional
public AjaxResult manyEmptyIn(@RequestBody ManyEmptyDomain manyEmptyDomain) {
if(manyEmptyDomain == null){
throw new ServiceException("空托盘组参数不对!");
}
String containerCode = manyEmptyDomain.getContainerCode();
|
|
79
|
String warehouseCode = manyEmptyDomain.getWarehouseCode();
|
|
80
81
|
String area = manyEmptyDomain.getArea();
String roadWay = manyEmptyDomain.getRoadWay();
|
|
82
83
84
85
86
87
|
JSONArray jsonArray = JSONArray.parseArray(roadWay);
List<String> roadWays = new ArrayList<>();
for(int i=0; i< jsonArray.size(); i++) {
Integer json = (Integer)jsonArray.get(i);
roadWays.add(String.valueOf(json));
}
|
|
88
89
90
91
92
93
94
95
96
97
98
99
|
String value = configService.getKey(QuantityConstant.RULE_ALLOCATION);
String height = manyEmptyDomain.getHeight();
if (StringUtils.isEmpty(value)) {
return AjaxResult.error("未绑定定位规则");
}
int allocationRule = Integer.parseInt(value);
LambdaQueryWrapper<Zone> zoneLambdaQueryWrapper = Wrappers.lambdaQuery();
zoneLambdaQueryWrapper.eq(Zone::getArea, area);
Zone zone = zoneService.getOne(zoneLambdaQueryWrapper);
if(zone == null) {
return AjaxResult.error("分配库位时,没有找到库区");
}
|
|
100
101
102
103
104
105
106
107
|
LambdaQueryWrapper<TaskHeader> taskHeaderLambdaQueryWrapper = Wrappers.lambdaQuery();
taskHeaderLambdaQueryWrapper.eq(TaskHeader::getContainerCode, containerCode)
.eq(TaskHeader::getWarehouseCode, warehouseCode)
.lt(TaskHeader::getStatus, QuantityConstant.TASK_STATUS_COMPLETED);
TaskHeader taskHeader = taskHeaderService.getOne(taskHeaderLambdaQueryWrapper);
if(taskHeader != null) {
return AjaxResult.success("已经生成空托盘组任务");
}
|
|
108
109
110
111
112
113
114
115
116
117
|
//查询满足条件的库位类型
LambdaQueryWrapper<LocationType> lambdaQueryWrapper = Wrappers.lambdaQuery();
lambdaQueryWrapper.eq(LocationType::getZoneCode, zone.getCode())
.eq(LocationType::getWarehouseCode, warehouseCode);
List<LocationType> locationTypeList = locationTypeService.list(lambdaQueryWrapper);
if(locationTypeList == null) {
return AjaxResult.error("分配库位时,没有找到库位类型");
}
List<String> locationTypeCodeList = locationTypeList.stream().
map(t -> t.getCode()).collect(Collectors.toList());
|
|
118
|
int highHeight = Float.valueOf(height).intValue();
|
|
119
|
LambdaQueryWrapper<LocationHigh> locationHighLambdaQueryWrapper = Wrappers.lambdaQuery();
|
|
120
|
locationHighLambdaQueryWrapper.eq(LocationHigh::getHighLevel, highHeight)
|
|
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
.in(LocationHigh::getLocationTypeCode, locationTypeCodeList);
LocationHigh locationHigh = locationHighService.getOne(locationHighLambdaQueryWrapper);
int high = locationHigh.getHigh();
String locationCode = allocationService.allocation(allocationRule, locationTypeCodeList, high, area,
roadWays, warehouseCode, containerCode, null);
if(locationCode == null) {
return AjaxResult.error("分配库位时,没有找到库位");
}
return workTaskService.createManyEmptyIn(containerCode, locationCode, warehouseCode);
}
/**
* 生成空托盘入库任务
* @return
*/
@PostMapping("/manyEmptyOut")
@Log(title = "任务-任务管理", operating = "生成空托盘组出库任务", action = BusinessType.INSERT)
@ResponseBody
@Transactional
public AjaxResult manyEmptyOut(@RequestBody ManyEmptyDomain manyEmptyDomain) {
if(manyEmptyDomain == null){
throw new ServiceException("空托盘组参数不对!");
}
|
|
144
|
|
|
145
|
String containerCode = manyEmptyDomain.getContainerCode();
|
|
146
|
String warehouseCode = manyEmptyDomain.getWarehouseCode();
|
|
147
148
149
|
if(StringUtils.isEmpty(containerCode)){
throw new ServiceException("托盘号为空“");
}
|
|
150
|
Container container = containerService.getContainerByCode(containerCode, warehouseCode);
|
|
151
152
153
|
if(container == null){
throw new ServiceException("没有找到托盘“");
}
|
|
154
155
|
String port = addressService.selectAddress(QuantityConstant.ADDRESS_WCS_MANY_EMPTY_CONTAINER, warehouseCode);
return workTaskService.createManyEmptyOut(containerCode,warehouseCode,port);
|
|
156
157
|
}
}
|