ReceiptContainerHeaderController.java
9.32 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
package com.huaheng.pc.receipt.receiptContainerHeader.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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.ReceiptContainerHeader;
import com.huaheng.pc.receipt.receiptContainerHeader.service.ReceiptContainerHeaderService;
import com.huaheng.pc.receipt.receiptDetail.domain.ReceiptDetail;
import com.huaheng.pc.receipt.receiptDetail.service.ReceiptDetailService;
import com.huaheng.pc.receipt.receiptHeader.domain.ReceiptHeader;
import com.huaheng.pc.receipt.receiving.service.ReceivingService;
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.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
/**
* 入库组盘头表控制
* @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;
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.isNotEmpty(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)
.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));
}
/**
* 生成任务
*/
@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不能为空");
}
this.position(ids);
List<Integer> idList = Arrays.asList(Convert.toIntArray(ids));
Integer maxId = idList.stream().max(Comparator.comparing(Integer::intValue)).orElse(null);
LambdaQueryWrapper<ReceiptContainerHeader> lambda = Wrappers.lambdaQuery();
lambda.select(ReceiptContainerHeader::getId)
.lt(ReceiptContainerHeader::getStatus, 10)
.le(ReceiptContainerHeader::getId, maxId);
return taskHeaderService.createReceiptTask(idList);
}
/**
* 定位
*/
@RequiresPermissions("receipt:receiptContainer:position")
@Log(title = "入库-定位", operating = "定位", action = BusinessType.INSERT)
@PostMapping( "/position")
@ResponseBody
public AjaxResult position(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.position(receiptContainerDetail);
}
}
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("取消定位成功");
}
}