ReceiptContainerHeaderController.java
12.2 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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
package com.huaheng.pc.receipt.receiptContainerHeader.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.huaheng.common.utils.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.huaheng.common.constant.HttpConstant;
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.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.controller.BaseController;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.framework.web.page.PageDomain;
import com.huaheng.framework.web.page.TableDataInfo;
import com.huaheng.framework.web.page.TableSupport;
import com.huaheng.pc.receipt.receiptContainerDetail.domain.ReceiptContainerDetail;
import com.huaheng.pc.receipt.receiptContainerDetail.service.ReceiptContainerDetailService;
import com.huaheng.pc.receipt.receiptContainerHeader.domain.PositionBean;
import com.huaheng.pc.receipt.receiptContainerHeader.domain.ReceiptContainerHeader;
import com.huaheng.pc.receipt.receiptContainerHeader.service.ReceiptContainerHeaderService;
import com.huaheng.pc.receipt.receiving.service.ReceivingService;
import com.huaheng.pc.task.taskHeader.domain.TaskHeader;
import com.huaheng.pc.task.taskHeader.service.ReceiptTaskService;
import com.huaheng.pc.task.taskHeader.service.TaskHeaderService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
/**
* 入库组盘头表控制
* @author mahuaheng
*/
@Controller
@RequestMapping("/receipt/receiptContainerHeader")
public class ReceiptContainerHeaderController extends BaseController {
@Resource
private ReceiptContainerHeaderService receiptContainerHeaderService;
@Resource
private TaskHeaderService taskHeaderService;
@Resource
private ReceivingService receivingService;
@Resource
private ReceiptContainerDetailService receiptContainerDetailService;
@Resource
private ReceiptTaskService receiptTaskService;
private String prefix = "receipt/receiptContainerHeader";
@RequiresPermissions("receipt:receiptContainer:view")
@GetMapping()
public String containerCapacity()
{
return prefix + "/receiptContainerHeader";
}
/**
* 查询入库组盘
*/
@RequiresPermissions("receipt:receiptContainer:list")
@Log(title = "入库-入库单组盘", operating = "查看入库组盘列表", action = BusinessType.GRANT)
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(@ApiParam(name="receiptDetail",value="入库组盘头表") ReceiptContainerHeader receiptContainerHeader,
@ApiParam(name = "receiptCode",value = "入库单号")String receiptCode,
@ApiParam(name = "createdBegin", value = "起止时间") String createdBegin,
@ApiParam(name = "createdEnd", value = "结束时间") String createdEnd) {
LambdaQueryWrapper<ReceiptContainerHeader> lambdaQueryWrapper = Wrappers.lambdaQuery();
PageDomain pageDomain = TableSupport.buildPageRequest();
Integer pageNum = pageDomain.getPageNum();
Integer pageSize = pageDomain.getPageSize();
String sql = null;
if (StringUtils.isNotEmpty(receiptCode)) {
sql = "select receiptContainerId from receipt_container_detail where receiptCode = \'"+receiptCode+"\'";
}
lambdaQueryWrapper.ge(StringUtils.isNotEmpty(createdBegin), ReceiptContainerHeader::getCreated, createdBegin)
.le(StringUtils.isNotEmpty(createdEnd), ReceiptContainerHeader::getCreated, createdEnd)
.eq(ReceiptContainerHeader::getWarehouseCode, ShiroUtils.getWarehouseCode())
.eq(StringUtils.isNotEmpty(receiptContainerHeader.getContainerCode()),ReceiptContainerHeader::getContainerCode, receiptContainerHeader.getContainerCode())
.eq(StringUtils.isNotEmpty(receiptContainerHeader.getToLocation()),ReceiptContainerHeader::getToLocation, receiptContainerHeader.getToLocation())
.eq(StringUtils.isNotNull(receiptContainerHeader.getTaskType()),ReceiptContainerHeader::getTaskType, receiptContainerHeader.getTaskType())
.eq(StringUtils.isNotNull(receiptContainerHeader.getStatus()),ReceiptContainerHeader::getStatus, receiptContainerHeader.getStatus())
.eq(StringUtils.isNotEmpty(receiptContainerHeader.getCreatedBy()),ReceiptContainerHeader::getCreatedBy, receiptContainerHeader.getCreatedBy())
.inSql(StringUtils.isNotEmpty(receiptCode), ReceiptContainerHeader::getId, sql)
.orderByAsc(ReceiptContainerHeader::getStatus)
.orderByDesc(ReceiptContainerHeader::getId);
if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)){
Page<ReceiptContainerHeader> page = new Page<>(pageNum, pageSize);
IPage<ReceiptContainerHeader> iPage = receiptContainerHeaderService.page(page, lambdaQueryWrapper);
return getMpDataTable(iPage.getRecords(),iPage.getTotal());
} else {
List<ReceiptContainerHeader> list = receiptContainerHeaderService.list(lambdaQueryWrapper);
return getDataTable(list);
}
}
/**
* 删除入库组盘
*/
@ApiOperation(value="取消", notes="取消入库组盘", httpMethod = "POST")
@RequiresPermissions("receipt:receiptContainer:remove")
@Log(title = "入库-入库单 ",operating = "取消入库组盘", action = BusinessType.UPDATE)
@PostMapping("/remove")
@ResponseBody
public AjaxResult remove(@ApiParam(name = "id", value = "入库头表id字符串")String ids){
if (StringUtils.isNull(ids)){
return AjaxResult.error("id为空");
}
List<Integer> idList = Arrays.asList(Convert.toIntArray(ids));
return toAjax(receiptContainerHeaderService.cancelByIds(idList));
}
/**
* 选择出库口
*/
@GetMapping("/chooseStation/{ids}")
public String chooseStation(@PathVariable("ids")String ids, ModelMap mmap) {
List<Integer> idList = Arrays.asList(Convert.toIntArray(ids));
List<Integer> idsList = idList.stream().distinct().collect(Collectors.toList());
ReceiptContainerHeader receiptContainerHeader = receiptContainerHeaderService.getById(idsList.get(0));
String containerCode = receiptContainerHeader.getContainerCode();
mmap.put("containerCode", containerCode);
mmap.put("id", ids);
int taskType = receiptContainerHeader.getTaskType().intValue();
if(taskType == QuantityConstant.TASK_TYPE_WHOLESHIPMENT ||
taskType == QuantityConstant.TASK_TYPE_EMPTYSHIPMENT) {
mmap.put("type", QuantityConstant.STATION_OUT);
} else if(taskType == QuantityConstant.TASK_TYPE_SUPPLEMENTRECEIPT ||
taskType == QuantityConstant.TASK_TYPE_SORTINGSHIPMENT ||
taskType == QuantityConstant.TASK_TYPE_VIEW ||
taskType == QuantityConstant.TASK_TYPE_CYCLECOUNT) {
mmap.put("type", QuantityConstant.STATION_PICK);
} else {
throw new ServiceException("任务类型不需要选站台");
}
return prefix + "/chooseStation";
}
@Log(title = "设置站台", operating = "设置站台", action = BusinessType.GRANT)
@PostMapping("/setStation")
@ResponseBody
public AjaxResult setStation (String ids, String type, String containerCode, String port){
List<Integer> idList = Arrays.asList(Convert.toIntArray(ids));
List<Integer> idsList = idList.stream().distinct().collect(Collectors.toList());
for(Integer id : idsList) {
LambdaQueryWrapper<ReceiptContainerHeader> receiptContainerHeaderLambdaQueryWrapper = Wrappers.lambdaQuery();
receiptContainerHeaderLambdaQueryWrapper.eq(ReceiptContainerHeader::getId, id);
ReceiptContainerHeader receiptContainerHeader1 = receiptContainerHeaderService.getOne(receiptContainerHeaderLambdaQueryWrapper);
receiptContainerHeader1.setPort(port);
receiptContainerHeaderService.update(receiptContainerHeader1, receiptContainerHeaderLambdaQueryWrapper);
}
return addTask(ids);
}
/**
* 生成任务
*/
@RequiresPermissions("receipt:receiptContainer:createTask")
@Log(title = "入库-任务生成", operating = "生成入库任务", action = BusinessType.INSERT)
@PostMapping( "/createTask")
@ResponseBody
public AjaxResult addTask(String ids) {
if (StringUtils.isEmpty(ids)){
return AjaxResult.error("id不能为空");
}
List<Integer> idList = Arrays.asList(Convert.toIntArray(ids));
List<Integer> idsList = idList.stream().distinct().collect(Collectors.toList());
AjaxResult ajaxResult1 = handleMultiProcess(new MultiProcessListener() {
@Override
public AjaxResult doProcess() {
AjaxResult ajaxResult =receiptTaskService.createReceiptTask(idsList);
return ajaxResult;
}
});
return ajaxResult1;
}
/**
* 定位
*/
@RequiresPermissions("receipt:receiptContainer:position")
@Log(title = "入库-定位", operating = "定位", action = BusinessType.INSERT)
@PostMapping( "/position")
@ResponseBody
public AjaxResult position(PositionBean positionBean){
if (StringUtils.isEmpty(positionBean.getIds())){
return AjaxResult.error("id不能为空");
}
boolean result = false;
List<Integer> idList = Arrays.asList(Convert.toIntArray(positionBean.getIds()));
List<Integer> idsList = idList.stream().distinct().collect(Collectors.toList());
for (int i = 0; i<idsList.size(); i++) {
LambdaQueryWrapper<ReceiptContainerDetail> lambda = Wrappers.lambdaQuery();
lambda.eq(ReceiptContainerDetail::getReceiptContainerId, idsList.get(i));
List<ReceiptContainerDetail> receiptContainerDetails = receiptContainerDetailService.list(lambda);
for (ReceiptContainerDetail receiptContainerDetail : receiptContainerDetails) {
result = receivingService.position(receiptContainerDetail, positionBean.getArea());
}
}
if(!result) {
return AjaxResult.error("定位失败");
}
return AjaxResult.success("定位成功");
}
/**
* 取消定位
*/
@RequiresPermissions("receipt:receiptContainer:canalPosition")
@Log(title = "入库-取消定位", operating = "取消定位", action = BusinessType.OTHER)
@PostMapping( "/cancelPosition")
@ResponseBody
public AjaxResult cancelPosition(String ids){
if (StringUtils.isEmpty(ids)){
return AjaxResult.error("id不能为空");
}
List<Integer> idList = Arrays.asList(Convert.toIntArray(ids));
for (int i = 0; i<idList.size(); i++){
LambdaQueryWrapper<ReceiptContainerDetail> lambda = Wrappers.lambdaQuery();
lambda.eq(ReceiptContainerDetail::getReceiptContainerId, idList.get(i));
List<ReceiptContainerDetail> receiptContainerDetails = receiptContainerDetailService.list(lambda);
for (ReceiptContainerDetail receiptContainerDetail : receiptContainerDetails) {
receivingService.cancelPosition(receiptContainerDetail);
}
}
return AjaxResult.success("取消定位成功");
}
/**
* 定位
*/
@GetMapping("/positioning/{ids}")
public String positioning(@PathVariable("ids")String ids, ModelMap mmap){
mmap.put("ids", ids);
return "receipt/receiving" + "/positioning";
}
}