1
2
3
4
package com . huaheng . mobile . invenory ;
import com.alibaba.fastjson.JSONException ;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper ;
5
import com.huaheng.common.constant.QuantityConstant ;
6
import com.huaheng.common.exception.service.ServiceException ;
7
8
9
import com.huaheng.common.support.Convert ;
import com.huaheng.common.utils.DataUtils ;
import com.huaheng.common.utils.StringUtils ;
10
import com.huaheng.common.utils.Wrappers ;
11
12
13
14
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.domain.AjaxResult ;
15
import com.huaheng.mobile.receipt.MaterialInfo ;
16
import com.huaheng.mobile.receipt.ReceiptBill ;
17
18
19
20
import com.huaheng.pc.config.container.domain.Container ;
import com.huaheng.pc.config.container.service.ContainerService ;
import com.huaheng.pc.config.location.domain.Location ;
import com.huaheng.pc.config.location.service.LocationService ;
21
22
import com.huaheng.pc.config.material.domain.Material ;
import com.huaheng.pc.config.material.service.MaterialService ;
23
24
25
import com.huaheng.pc.inventory.cycleCountDetail.domain.CycleCountDetail ;
import com.huaheng.pc.inventory.cycleCountDetail.domain.CycleCountDetailChild ;
import com.huaheng.pc.inventory.cycleCountDetail.service.CycleCountDetailChildService ;
26
import com.huaheng.pc.inventory.cycleCountDetail.service.CycleCountDetailService ;
27
28
29
import com.huaheng.pc.inventory.cycleCountHeader.domain.CycleCountHeader ;
import com.huaheng.pc.inventory.cycleCountHeader.mapper.CycleCountHeaderMapper ;
import com.huaheng.pc.inventory.cycleCountHeader.service.CycleCountHeaderService ;
30
31
import com.huaheng.pc.inventory.inventoryDetail.domain.InventoryDetail ;
import com.huaheng.pc.inventory.inventoryDetail.service.InventoryDetailService ;
32
import com.huaheng.pc.inventory.inventoryHeader.domain.InventoryHeader ;
33
import com.huaheng.pc.inventory.inventoryHeader.service.InventoryHeaderService ;
34
35
import com.huaheng.pc.inventory.inventoryTransaction.domain.InventoryTransaction ;
import com.huaheng.pc.inventory.inventoryTransaction.service.InventoryTransactionService ;
36
37
38
39
40
41
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 ;
42
import com.huaheng.pc.receipt.receiptHeader.domain.ReceiptHeader ;
43
import com.huaheng.pc.receipt.receiptHeader.service.ReceiptHeaderService ;
44
import com.huaheng.pc.report.excelReport.mapper.ExcelReportMapper ;
45
46
47
import com.huaheng.pc.task.taskDetail.domain.TaskDetail ;
import com.huaheng.pc.task.taskDetail.service.TaskDetailService ;
import com.huaheng.pc.task.taskHeader.domain.TaskHeader ;
48
import com.huaheng.pc.task.taskHeader.service.TaskHeaderService ;
49
50
import com.huaheng.pc.task.taskHeader.service.TransferTaskService ;
import com.huaheng.pc.task.taskHeader.service.WorkTaskService ;
51
52
53
import io.swagger.annotations.Api ;
import io.swagger.annotations.ApiOperation ;
import io.swagger.annotations.ApiParam ;
54
import org.apache.commons.collections.CollectionUtils ;
55
import org.springframework.transaction.annotation.Transactional ;
56
57
58
59
import org.springframework.web.bind.annotation.* ;
import javax.annotation.Resource ;
import java.math.BigDecimal ;
60
import java.text.SimpleDateFormat ;
61
62
63
64
65
66
67
68
69
import java.util.* ;
/**
* @author Enzo Cotter
* @date 2019 / 12 / 15
*/
@CrossOrigin
@RestController
@RequestMapping ( "/mobile/inventory" )
70
@Api ( tags = { "手机立体库库存相关" }, value = "手机立体库库存相关MobileInventoryController" )
71
72
73
74
75
public class MobileInventoryController {
@Resource
private InventoryHeaderService inventoryService ;
@Resource
76
77
private InventoryDetailService inventoryDetailService ;
@Resource
78
79
private InventoryTransactionService inventoryTransactionService ;
@Resource
80
81
private TaskHeaderService taskService ;
@Resource
82
83
private TaskDetailService taskDetailService ;
@Resource
84
85
86
87
88
private TransferTaskService transferTaskService ;
@Resource
private WorkTaskService workTaskService ;
@Resource
89
90
91
92
93
94
95
private LocationService locationService ;
@Resource
ExcelReportMapper mapper ;
@Resource
private CycleCountDetailService cycleCountDetailService ;
@Resource
private ContainerService containerService ;
96
97
98
99
100
101
@Resource
private CycleCountHeaderService cycleCountHeaderService ;
@Resource
private CycleCountDetailChildService cycleCountDetailChildService ;
@Resource
private CycleCountHeaderMapper cycleCountHeaderMapper ;
102
103
104
105
106
107
108
109
110
111
@Resource
private ReceiptHeaderService receiptHeaderService ;
@Resource
private ReceiptDetailService receiptDetailService ;
@Resource
private ReceiptContainerHeaderService receiptContainerHeaderService ;
@Resource
private ReceiptContainerDetailService receiptContainerDetailService ;
@Resource
private MaterialService materialService ;
112
113
114
115
@PostMapping ( "/getInventoryInfo" )
@ApiOperation ( "移动端获得库存详情" )
@Log ( title = "移动端获得库存详情" , action = BusinessType . OTHER )
116
117
public AjaxResult getInventoryInfo ( @RequestBody @ApiParam ( value = "物料编码或者库位号" ) Map < String , String > param ) {
if ( param . get ( "code" ) == null || param . get ( "code" ). trim (). length () < 1 ) {
118
119
throw new JSONException ( "查询码(code)不能为空" );
}
120
if ( param . get ( "companyCode" ) == null || param . get ( "companyCode" ). trim (). length () < 1 ) {
121
122
throw new JSONException ( "(companyCode)不能为空" );
}
123
return inventoryService . getInventory ( param . get ( "code" ), param . get ( "companyCode" ));
124
125
126
127
128
}
@PostMapping ( "/createCheckOutTask" )
@ApiOperation ( "移动端创建出库查看任务" )
@ResponseBody
129
public AjaxResult createCheckOutTask ( @RequestBody @ApiParam ( value = "库存ids" ) Map < String , String > param ) {
130
String ids = param . get ( "ids" );
131
String port = param . get ( "port" );
132
Integer companyId = DataUtils . getInteger ( param . get ( "companyId" ));
133
String companyCode = param . get ( "companyCode" );
134
if ( StringUtils . isEmpty ( ids )) {
135
136
return AjaxResult . error ( "ids不能为空" );
}
137
return workTaskService . createCheckOutTaskByIds ( Arrays . asList ( Convert . toIntArray ( ids )), port );
138
139
140
141
142
}
@PostMapping ( "/transfer" )
@ApiOperation ( "移动端创建移库任务" )
@ResponseBody
143
public AjaxResult transfer ( @RequestBody @ApiParam ( value = "库位情况" ) Map < String , String > param ) {
144
145
String sourceLocation = param . get ( "sourceLocation" );
String destinationLocation = param . get ( "destinationLocation" );
146
return transferTaskService . createTransferTask ( sourceLocation , destinationLocation , ShiroUtils . getWarehouseCode ());
147
148
}
149
@PostMapping ( "/execute" )
150
151
@ApiOperation ( "执行立库任务" )
@ResponseBody
152
public AjaxResult execute ( @RequestBody @ApiParam ( value = "任务id" ) Map < String , String > param ) {
153
154
155
156
157
158
String taskId = param . get ( "taskId" );
if ( StringUtils . isEmpty ( taskId )) {
return AjaxResult . error ( "taskId不能为空" );
}
AjaxResult ajaxResult = taskService . sendTaskToWcs ( Convert . toIntArray ( taskId ));
159
if ( ajaxResult . hasErr ()) {
160
161
162
163
164
AjaxResult . success ( "执行失败" );
}
return AjaxResult . success ( "下发执行成功" );
}
165
@PostMapping ( "/executeList" )
166
167
168
169
@ApiOperation ( "执行立库任务" )
@Log ( title = "执行立库任务" , action = BusinessType . OTHER )
public AjaxResult executeList ( @RequestBody List < TaskIds > taskDetails ) {
Integer [] taskIds = new Integer [ taskDetails . size ()];
170
for ( int i = 0 ; i < taskDetails . size (); i ++) {
171
172
173
174
175
176
177
TaskIds taskDetail = taskDetails . get ( i );
taskIds [ i ] = taskDetail . getTaskId ();
}
AjaxResult ajaxResult = taskService . sendTaskToWcs ( taskIds );
return ajaxResult ;
}
178
@PostMapping ( "/completeTaskByWMS" )
179
180
@ApiOperation ( "完成立库任务" )
@ResponseBody
181
public AjaxResult completeTaskByWMS ( @RequestBody @ApiParam ( value = "任务id" ) Map < String , String > param ) throws Exception {
182
183
184
185
String taskId = param . get ( "taskId" );
if ( StringUtils . isEmpty ( taskId )) {
return AjaxResult . error ( "taskId不能为空" );
}
huhai
authored
5 years ago
186
187
AjaxResult ajaxResult = taskService . completeTaskByWMS ( Convert . toIntArray ( taskId ), null );
188
189
190
return ajaxResult ;
}
191
@PostMapping ( "/completeTaskListByWMS" )
192
193
194
195
@ApiOperation ( "完成立库任务" )
@ResponseBody
public AjaxResult completeTaskListByWMS ( @RequestBody List < TaskIds > taskDetails ) throws Exception {
Integer [] taskIds = new Integer [ taskDetails . size ()];
196
for ( int i = 0 ; i < taskDetails . size (); i ++) {
197
198
199
TaskIds taskDetail = taskDetails . get ( i );
taskIds [ i ] = taskDetail . getTaskId ();
}
200
AjaxResult ajaxResult = taskService . completeTaskByWMS ( taskIds , null );
201
202
203
return ajaxResult ;
}
204
@PostMapping ( "/isLocation" )
205
206
@ApiOperation ( "判断是不是库位" )
@ResponseBody
207
public AjaxResult isLocation ( @RequestBody @ApiParam ( value = "任务id" ) Map < String , String > param ) {
208
209
210
211
212
213
214
String code = param . get ( "code" );
if ( StringUtils . isEmpty ( code )) {
return AjaxResult . error ( "location不能为空" );
}
LambdaQueryWrapper < Location > queryWrapper = Wrappers . lambdaQuery ();
queryWrapper . eq ( Location: : getCode , code );
Location location = locationService . getOne ( queryWrapper );
215
if ( location == null ) {
216
217
return AjaxResult . error ( "没有这个库位" );
}
218
219
220
return AjaxResult . success ( "库位存在" ). setData ( code );
}
221
@PostMapping ( "/isContainer" )
222
223
@ApiOperation ( "判断是不是库位" )
@ResponseBody
224
public AjaxResult isContainer ( @RequestBody @ApiParam ( value = "任务id" ) Map < String , String > param ) {
225
226
227
228
229
230
231
String code = param . get ( "code" );
if ( StringUtils . isEmpty ( code )) {
return AjaxResult . error ( "location不能为空" );
}
LambdaQueryWrapper < Container > queryWrapper = Wrappers . lambdaQuery ();
queryWrapper . eq ( Container: : getCode , code );
Container container = containerService . getOne ( queryWrapper );
232
if ( container == null ) {
233
234
235
return AjaxResult . error ( "没有这个容器" );
}
return AjaxResult . success ( "容器存在" ). setData ( code );
236
237
238
239
240
}
@PostMapping ( "/getLocationCode" )
@ApiOperation ( "移动端获得库位联想词" )
@Log ( title = "移动端获得库位联想词" , action = BusinessType . OTHER )
241
242
public AjaxResult getLocationCode ( @RequestBody @ApiParam ( value = "库位号" ) Map < String , String > param ) {
if ( param . get ( "code" ) == null || param . get ( "code" ). trim (). length () < 1 ) {
243
244
245
throw new JSONException ( "查询码(code)不能为空" );
}
String type = param . get ( "type" );
246
if ( type == null || type . trim (). length () < 1 ) {
247
248
249
throw new JSONException ( "type不能为空" );
}
250
return inventoryService . getLocationForecast ( param . get ( "code" ), Integer . parseInt ( type ));
251
252
253
254
255
256
}
@PostMapping ( "/createEmptyIn" )
@ApiOperation ( "移动端空托入库" )
@Log ( title = "移动端空托入库" , action = BusinessType . OTHER )
public AjaxResult createEmptyIn ( @RequestBody Map < String , String > param ) {
257
if ( param . get ( "containerCode" ) == null || param . get ( "containerCode" ). trim (). length () < 1 ) {
258
259
260
261
262
263
264
265
throw new JSONException ( "容器号不能为空" );
}
// if (param.get("destinationLocation") == null || param.get("destinationLocation").trim().length() < 1) {
// throw new JSONException("目的库位不能为空");
// }
String containerCode = param . get ( "containerCode" );
String destinationLocation = param . get ( "destinationLocation" );
String companyCode = param . get ( "companyCode" );
266
return inventoryService . createEmptyIn ( containerCode , destinationLocation );
267
268
269
270
271
272
}
@PostMapping ( "/createEmptyOut" )
@ApiOperation ( "移动端空托出库" )
@Log ( title = "移动端空托出库" , action = BusinessType . OTHER )
public AjaxResult createEmptyOut ( @RequestBody Map < String , String > param ) {
273
274
if ( param . get ( "containerCode" ) == null || param . get ( "containerCode" ). trim (). length () < 1 ) {
throw new JSONException ( "容器号不能为空" );
275
}
276
if ( param . get ( "sourceLocation" ) == null || param . get ( "sourceLocation" ). trim (). length () < 1 ) {
277
278
279
280
throw new JSONException ( "源库位不能为空" );
}
String containerCode = param . get ( "containerCode" );
String sourceLocation = param . get ( "sourceLocation" );
281
return inventoryService . createEmptyOut ( containerCode , sourceLocation );
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
}
@PostMapping ( "/get7daysShipment" )
@ApiOperation ( "移动端获取7天收货和出货量" )
@Log ( title = "移动端获取7天收货和出货量" , action = BusinessType . OTHER )
public AjaxResult get7daysShipment ( @RequestBody Map < String , String > param ) {
String sql = "select a.click_date as date,ifnull(b.taskQty,0) as qty\n" +
"from (\n" +
" SELECT curdate() as click_date\n" +
" union all\n" +
" SELECT date_sub(curdate(), interval 1 day) as click_date\n" +
" union all\n" +
" SELECT date_sub(curdate(), interval 2 day) as click_date\n" +
" union all\n" +
" SELECT date_sub(curdate(), interval 3 day) as click_date\n" +
" union all\n" +
" SELECT date_sub(curdate(), interval 4 day) as click_date\n" +
" union all\n" +
" SELECT date_sub(curdate(), interval 5 day) as click_date\n" +
" union all\n" +
" SELECT date_sub(curdate(), interval 6 day) as click_date\n" +
") a left join (\n" +
304
"SELECT DATE(h.created) AS created , SUM(d.qty) AS taskQty from shipment_container_detail d join shipment_container_header h on d.shippingContainerId = h.id and h.warehouseCode='" + ShiroUtils . getWarehouseCode () + "' WHERE h.created >= DATE_SUB(CURDATE(), INTERVAL 7 DAY) AND h.status=30 GROUP BY DATE(h.created)\n" +
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
") b on a.click_date = b.created ORDER BY a.click_date;" ;
List < LinkedHashMap < String , Object >> list = mapper . selectCommon ( sql );
sql = "select a.click_date as date,ifnull(b.taskQty,0) as qty\n" +
"from (\n" +
" SELECT curdate() as click_date\n" +
" union all\n" +
" SELECT date_sub(curdate(), interval 1 day) as click_date\n" +
" union all\n" +
" SELECT date_sub(curdate(), interval 2 day) as click_date\n" +
" union all\n" +
" SELECT date_sub(curdate(), interval 3 day) as click_date\n" +
" union all\n" +
" SELECT date_sub(curdate(), interval 4 day) as click_date\n" +
" union all\n" +
" SELECT date_sub(curdate(), interval 5 day) as click_date\n" +
" union all\n" +
" SELECT date_sub(curdate(), interval 6 day) as click_date\n" +
") a left join (\n" +
324
"SELECT DATE(h.created) AS created , SUM(d.qty) AS taskQty from receipt_container_detail d join receipt_container_header h on d.receiptContainerId = h.id and h.warehouseCode='" + ShiroUtils . getWarehouseCode () + "' WHERE h.created >= DATE_SUB(CURDATE(), INTERVAL 7 DAY) AND d.status=30 GROUP BY DATE(h.created)\n" +
325
326
327
328
") b on a.click_date = b.created ORDER BY a.click_date;" ;
List < LinkedHashMap < String , Object >> list2 = mapper . selectCommon ( sql );
329
List < LinkedHashMap < String , Object >> result = new ArrayList <>();
330
331
332
333
result . addAll ( list );
result . addAll ( list2 );
List < InventoryDetails > inventoryDetailList = new ArrayList <>();
334
for ( LinkedHashMap < String , Object > map : result ) {
335
336
337
338
339
340
341
Iterator iter = map . entrySet (). iterator ();
String date = null ;
BigDecimal qty = new BigDecimal ( 0 );
while ( iter . hasNext ()) {
Map . Entry entry = ( Map . Entry ) iter . next ();
Object key = entry . getKey ();
Object val = entry . getValue ();
342
if ( date == null ) {
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
date = val . toString ();
} else {
qty = ( BigDecimal ) val ;
}
}
inventoryDetailList . add ( newInventoryDetail ( date , qty ));
}
return AjaxResult . success ( inventoryDetailList );
}
private InventoryDetails newInventoryDetail ( String date , BigDecimal qty ) {
InventoryDetails inventoryDetail = new InventoryDetails ();
inventoryDetail . setDate ( date );
inventoryDetail . setQty ( qty );
return inventoryDetail ;
}
@PostMapping ( "/getTodayShipmentDetail" )
@ApiOperation ( "移动端获得今天发货详情" )
@Log ( title = "移动端获得今天发货详情" , action = BusinessType . OTHER )
public AjaxResult getTodayShipmentDetail ( @RequestBody Map < String , String > param ) {
String sql = "select d.materialName, SUM(d.qty) as qty " +
"from shipment_container_header h join shipment_container_detail d " +
"on d.shippingContainerId = h.id WHERE h.created >= CURDATE() AND h.`status`>19 GROUP BY d.materialName" ;
List < LinkedHashMap < String , Object >> list = mapper . selectCommon ( sql );
sql = "select m.name, b.taskQty as qty \n" +
"from material m \n" +
"join (\n" +
"select d.materialCode as material, SUM(d.qty) " +
"as taskQty from receipt_container_header h join receipt_container_detail d " +
"on d.receiptContainerId = h.id WHERE h.created >= CURDATE() AND h.`status`>19 GROUP BY d.materialCode\n" +
") b on m.`code` = b.material ORDER BY m.name" ;
List < LinkedHashMap < String , Object >> list2 = mapper . selectCommon ( sql );
List < com . huaheng . mobile . invenory . ShipmentDetail > shipmentDetails = getShipmentDetails ( list );
shipmentDetails . add ( newShipmentDetail ( "delete" , new BigDecimal ( 0 )));
shipmentDetails . addAll ( getShipmentDetails ( list2 ));
return AjaxResult . success ( shipmentDetails );
}
private List < com . huaheng . mobile . invenory . ShipmentDetail > getShipmentDetails ( List < LinkedHashMap < String , Object >> list ) {
List < com . huaheng . mobile . invenory . ShipmentDetail > shipmentDetails = new ArrayList <>();
for ( LinkedHashMap < String , Object > map : list ) {
Iterator iter = map . entrySet (). iterator ();
String materialName = null ;
BigDecimal qty = new BigDecimal ( 0 );
while ( iter . hasNext ()) {
Map . Entry entry = ( Map . Entry ) iter . next ();
Object key = entry . getKey ();
Object val = entry . getValue ();
if ( materialName == null ) {
materialName = val . toString ();
} else {
qty = ( BigDecimal ) val ;
}
}
shipmentDetails . add ( newShipmentDetail ( materialName , qty ));
}
return shipmentDetails ;
}
405
private com . huaheng . mobile . invenory . ShipmentDetail newShipmentDetail ( String materialName , BigDecimal qty ) {
406
407
408
409
410
411
412
413
com . huaheng . mobile . invenory . ShipmentDetail shipmentDetail = new com . huaheng . mobile . invenory . ShipmentDetail ();
shipmentDetail . setMaterialName ( materialName );
shipmentDetail . setQty ( qty );
return shipmentDetail ;
}
/**
* 移动端根据容器编码获取盘点任务
414
*
415
416
417
418
419
420
421
* @param param
* @return
*/
@ResponseBody
@PostMapping ( "/findTransferByContainerCode" )
public AjaxResult findTransferByContainerCode ( @RequestBody Map < String , String > param ) {
String containCode = param . get ( "containCode" );
422
if ( StringUtils . isEmpty ( containCode )) {
423
424
425
426
427
428
429
430
return AjaxResult . error ( "容器编码为空" );
} else {
return AjaxResult . success ( taskService . mobileFindTransferTask ( containCode ));
}
}
/**
* 移动端实盘登记
431
*
432
433
434
435
* @return
*/
@ResponseBody
@PostMapping ( "/confirmGapQty" )
436
public AjaxResult confirmGapQty ( @RequestBody List < MaterialInfo > materialInfos ) {
437
for ( MaterialInfo materialInfo : materialInfos ) {
438
439
440
441
442
int detailId = materialInfo . getBillDetailId ();
BigDecimal qty = new BigDecimal ( materialInfo . getQty ());
// CycleCountDetail cycleCountDetail = cycleCountDetailService.getById(detailId);
LambdaQueryWrapper < CycleCountDetailChild > cycleCountDetailChildLambdaQueryWrapper = Wrappers . lambdaQuery ();
cycleCountDetailChildLambdaQueryWrapper . eq ( CycleCountDetailChild: : getCycleCountDetailId , detailId )
443
. eq ( CycleCountDetailChild: : getMaterialCode , materialInfo . getMaterialCode ());
444
445
CycleCountDetailChild cycleCountDetailChild = cycleCountDetailChildService . getOne ( cycleCountDetailChildLambdaQueryWrapper );
AjaxResult ajaxResult = cycleCountDetailService . confirmGapQty ( cycleCountDetailChild . getId (), qty );
446
if ( ajaxResult . hasErr ()) {
447
448
449
450
return AjaxResult . error ( "盘点失败" );
}
}
return AjaxResult . success ( "盘点成功" );
451
452
453
454
455
456
}
@PostMapping ( "/getEmptyContainerInLocation" )
@ApiOperation ( "选取空托出库的库位" )
@Log ( title = "选取空托出库的库位" , action = BusinessType . OTHER )
public AjaxResult getEmptyContainerInLocation ( @RequestBody Map < String , String > param ) {
457
458
459
String warehouCOde = ShiroUtils . getWarehouseCode ();
List < Location > list = containerService . getEmptyContainerInLocation ( null , null , null , null , ShiroUtils . getWarehouseCode ());
return AjaxResult . success ( list );
460
461
462
463
464
465
466
467
468
469
470
}
@PostMapping ( "/pickLocation" )
@ApiOperation ( "选取补充入库的库位" )
@Log ( title = "选取补充入库的库位" , action = BusinessType . OTHER )
public AjaxResult pickLocation ( @RequestBody Map < String , String > param ) {
List < Location > locations = locationService . pickLocation ();
Container condition = new Container ();
condition . setWarehouseCode ( ShiroUtils . getWarehouseCode ());
LambdaQueryWrapper lambda3 = Wrappers . lambdaQuery ( condition );
List < Container > containers = containerService . list ( lambda3 );
471
472
473
474
for ( Location location : locations ) {
for ( Container container : containers ) {
if ( container . getCode (). equals ( location . getContainerCode ())) {
if ( QuantityConstant . STATUS_CONTAINER_SOME . equals ( container . getStatus ())) {
475
location . setStatus ( QuantityConstant . STATUS_LOCATION_LOCK );
476
477
478
479
}
}
}
}
480
return AjaxResult . success ( locations );
481
}
482
483
484
485
@PostMapping ( "/searchInventory" )
@ApiOperation ( "移动端查询库存" )
@Log ( title = "移动端查询库存" , action = BusinessType . OTHER )
486
public AjaxResult searchInventory ( @RequestBody @ApiParam ( value = "物料号" ) Map < String , String > param ) {
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
String companyCode = param . get ( "companyCode" );
SimpleDateFormat df = new SimpleDateFormat ( "yyyy-MM-dd HH:mm:ss" );
String now = df . format ( new Date ());
Calendar c = Calendar . getInstance ();
c . setTime ( new Date ());
c . add ( Calendar . DATE , - 7 );
Date first = c . getTime ();
String start = df . format ( first ); //前一天
LambdaQueryWrapper < InventoryDetail > inventoryQueryWrapper = Wrappers . lambdaQuery ();
inventoryQueryWrapper . eq ( InventoryDetail: : getCompanyCode , companyCode )
. eq ( InventoryDetail: : getWarehouseCode , ShiroUtils . getWarehouseCode ())
. orderByDesc ( InventoryDetail: : getCreated );
List < InventoryDetail > inventoryDetailList = inventoryDetailService . list ( inventoryQueryWrapper );
return AjaxResult . success ( inventoryDetailList );
}
503
@PostMapping ( "/searchInventoryInCondition" )
504
505
@ApiOperation ( "移动端查询库存" )
@Log ( title = "移动端查询库存" , action = BusinessType . OTHER )
506
public AjaxResult searchInventoryInCondition ( @RequestBody @ApiParam ( value = "物料号" ) Map < String , String > param ) {
507
508
String companyCode = param . get ( "companyCode" );
String containerCode = param . get ( "containerCode" );
509
510
511
512
513
String materialCode = param . get ( "materialCode" );
String materialName = param . get ( "materialName" );
String materialSpec = param . get ( "materialSpec" );
String startTime = param . get ( "startTime" );
String endTime = param . get ( "endTime" );
514
515
516
LambdaQueryWrapper < InventoryDetail > inventoryQueryWrapper = Wrappers . lambdaQuery ();
inventoryQueryWrapper . eq ( InventoryDetail: : getCompanyCode , companyCode )
. eq ( InventoryDetail: : getWarehouseCode , ShiroUtils . getWarehouseCode ())
517
518
519
520
521
522
. eq ( StringUtils . isNotEmpty ( containerCode ), InventoryDetail: : getContainerCode , containerCode )
. like ( StringUtils . isNotEmpty ( materialCode ), InventoryDetail: : getMaterialCode , materialCode )
. like ( StringUtils . isNotEmpty ( materialName ), InventoryDetail: : getMaterialName , materialName )
. like ( StringUtils . isNotEmpty ( materialSpec ), InventoryDetail: : getMaterialSpec , materialSpec )
. gt ( StringUtils . isNotEmpty ( startTime ), InventoryDetail: : getCreated , startTime )
. le ( StringUtils . isNotEmpty ( endTime ), InventoryDetail: : getCreated , endTime )
523
524
525
526
527
528
529
530
531
. orderByDesc ( InventoryDetail: : getCreated );
List < InventoryDetail > inventoryDetailList = inventoryDetailService . list ( inventoryQueryWrapper );
return AjaxResult . success ( inventoryDetailList );
}
@PostMapping ( "/findInventory" )
@ApiOperation ( "移动端查询库存详情" )
@Log ( title = "移动端查询库存详情" , action = BusinessType . OTHER )
532
public AjaxResult findInventory ( @RequestBody @ApiParam ( value = "物料号" ) Map < String , String > param ) {
533
534
String inventoryDetailId = param . get ( "inventoryDetailId" );
String companyCode = param . get ( "companyCode" );
535
if ( StringUtils . isNull ( inventoryDetailId )) {
536
return AjaxResult . error ( "任务id为空" );
537
} else if ( StringUtils . isNull ( companyCode )) {
538
539
540
541
542
543
544
545
return AjaxResult . error ( "公司编码为空" );
}
/* 查询入库单,如果数据库中不存在,则调用ERP接口拉取单据,成功后再次查询返回结果*/
LambdaQueryWrapper < InventoryDetail > inventoryQueryWrapper = Wrappers . lambdaQuery ();
inventoryQueryWrapper . eq ( InventoryDetail: : getId , inventoryDetailId )
. eq ( InventoryDetail: : getCompanyCode , companyCode );
InventoryDetail inventoryDetail = inventoryDetailService . getOne ( inventoryQueryWrapper );
546
if ( inventoryDetail == null ) {
547
548
549
550
return AjaxResult . error ( "没有找到库存详情" );
}
return AjaxResult . success ( inventoryDetail );
}
551
552
553
554
@PostMapping ( "/searchInventoryTransactionInCondition" )
@ApiOperation ( "移动端查询库存交易记录" )
@Log ( title = "移动端查询库存交易记录" , action = BusinessType . OTHER )
555
public AjaxResult searchInventoryTransactionInCondition ( @RequestBody @ApiParam ( value = "物料号" ) Map < String , String > param ) {
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
String companyCode = param . get ( "companyCode" );
String transactionType = param . get ( "transactionType" );
String containerCode = param . get ( "containerCode" );
String materialCode = param . get ( "materialCode" );
String materialName = param . get ( "materialName" );
String materialSpec = param . get ( "materialSpec" );
String startTime = param . get ( "startTime" );
String endTime = param . get ( "endTime" );
LambdaQueryWrapper < InventoryTransaction > inventoryTransactionLambdaQueryWrapper = Wrappers . lambdaQuery ();
inventoryTransactionLambdaQueryWrapper . eq ( InventoryTransaction: : getCompanyCode , companyCode )
. eq ( InventoryTransaction: : getWarehouseCode , ShiroUtils . getWarehouseCode ())
. eq ( StringUtils . isNotEmpty ( transactionType ), InventoryTransaction: : getTransactionType , transactionType )
. eq ( StringUtils . isNotEmpty ( containerCode ), InventoryTransaction: : getContainerCode , containerCode )
. like ( StringUtils . isNotEmpty ( materialCode ), InventoryTransaction: : getMaterialCode , materialCode )
. like ( StringUtils . isNotEmpty ( materialName ), InventoryTransaction: : getMaterialName , materialName )
. like ( StringUtils . isNotEmpty ( materialSpec ), InventoryTransaction: : getMaterialSpec , materialSpec )
. gt ( StringUtils . isNotEmpty ( startTime ), InventoryTransaction: : getCreated , startTime )
. le ( StringUtils . isNotEmpty ( endTime ), InventoryTransaction: : getCreated , endTime )
. orderByDesc ( InventoryTransaction: : getCreated );
List < InventoryTransaction > inventoryDetailList = inventoryTransactionService . list ( inventoryTransactionLambdaQueryWrapper );
return AjaxResult . success ( inventoryDetailList );
}
578
579
580
581
582
@PostMapping ( "/circleCount" )
@ApiOperation ( "移动端盘点库存" )
@Log ( title = "移动端盘点库存" , action = BusinessType . OTHER )
583
public AjaxResult circleCount ( @RequestBody List < CircleBean > circleBeanList ) {
584
585
586
587
String locaitonCode = circleBeanList . get ( 0 ). getLocaitonCode ();
String containerCode = circleBeanList . get ( 0 ). getContainerCode ();
String circleCode = addCircleHeader ( circleBeanList );
boolean diff = false ;
588
for ( CircleBean circleBean : circleBeanList ) {
589
590
591
592
593
594
595
596
LambdaQueryWrapper < CycleCountDetailChild > lambdaQueryWrapper = Wrappers . lambdaQuery ();
lambdaQueryWrapper . eq ( CycleCountDetailChild: : getContainerCode , containerCode )
. eq ( CycleCountDetailChild: : getLocationCode , locaitonCode )
. eq ( CycleCountDetailChild: : getCycleCountHeadCode , circleCode )
. eq ( CycleCountDetailChild: : getChildStatus , 1 )
. eq ( CycleCountDetailChild: : getMaterialCode , circleBean . getMaterialCode ());
CycleCountDetailChild cycleCountDetailChild = cycleCountDetailChildService . getOne ( lambdaQueryWrapper );
AjaxResult result = cycleCountDetailService . confirmGapQty ( cycleCountDetailChild . getId (), new BigDecimal ( circleBean . getQty ()));
597
cycleCountDetailChild = ( CycleCountDetailChild ) result . getData ();
598
599
600
LambdaQueryWrapper < CycleCountDetail > lambdaQueryWrapper1 = Wrappers . lambdaQuery ();
lambdaQueryWrapper1 . eq ( CycleCountDetail: : getId , cycleCountDetailChild . getCycleCountDetailId ());
CycleCountDetail cycleCountDetail = cycleCountDetailService . getOne ( lambdaQueryWrapper1 );
601
if ( cycleCountDetailChild . getGapQty (). compareTo ( BigDecimal . ZERO ) != 0 ) {
602
603
604
cycleCountDetailChild . setChildStatus ( QuantityConstant . CYCLECOUNT_STATUS_DIFFERENCE );
cycleCountDetail . setEnableStatus ( QuantityConstant . CYCLECOUNT_STATUS_DIFFERENCE );
diff = true ;
605
} else {
606
607
608
609
610
611
612
cycleCountDetailChild . setChildStatus ( QuantityConstant . CYCLECOUNT_STATUS_COMPLETED );
cycleCountDetail . setEnableStatus ( QuantityConstant . CYCLECOUNT_STATUS_COMPLETED );
}
}
LambdaQueryWrapper < CycleCountHeader > lambdaQueryWrapper2 = Wrappers . lambdaQuery ();
lambdaQueryWrapper2 . eq ( CycleCountHeader: : getCode , circleCode );
CycleCountHeader cycleCountHeader = cycleCountHeaderService . getOne ( lambdaQueryWrapper2 );
613
if ( diff ) {
614
615
616
617
618
619
620
621
622
cycleCountHeader . setStatusCyc ( QuantityConstant . CYCLECOUNT_STATUS_DIFFERENCE );
} else {
cycleCountHeader . setStatusCyc ( QuantityConstant . CYCLECOUNT_STATUS_COMPLETED );
}
cycleCountHeaderService . updateById ( cycleCountHeader );
return AjaxResult . success ();
}
private String addCircleHeader ( List < CircleBean > circleBeanList ) {
623
String maxCode = cycleCountHeaderMapper . getLastCode ();
624
625
LambdaQueryWrapper < CycleCountHeader > lambdaQueryWrapper = Wrappers . lambdaQuery ();
lambdaQueryWrapper . eq ( CycleCountHeader: : getCode , maxCode )
626
. le ( CycleCountHeader: : getStatusCyc , 105 );
627
628
CycleCountHeader cycleCountHeader = new CycleCountHeader ();
CycleCountHeader header = cycleCountHeaderService . getOne ( lambdaQueryWrapper );
629
if ( header == null ) {
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
cycleCountHeader . setCreated ( new Date ());
cycleCountHeader . setCreatedBy ( ShiroUtils . getLoginName ());
cycleCountHeader . setCountType ( "static" );
cycleCountHeader . setCode ( createCode ());
cycleCountHeader . setPreferenceCode ( "ccp2019101700001" );
cycleCountHeader . setRound ( 1 );
cycleCountHeader . setWarehouseCode ( ShiroUtils . getWarehouseCode ());
cycleCountHeader . setStatusCyc ( 1 );
cycleCountHeader . setCountAttribute ( 1 );
cycleCountHeader . setTotalLocs ( 0 );
cycleCountHeader . setTotalItems ( 0 );
cycleCountHeader . setLastUpdated ( new Date ());
cycleCountHeader . setLastUpdatedBy ( ShiroUtils . getLoginName ());
cycleCountHeader . setEnable ( true );
cycleCountHeaderService . save ( cycleCountHeader );
} else {
cycleCountHeader = header ;
}
LambdaQueryWrapper < InventoryHeader > inventoryHeaderLambdaQueryWrapper = Wrappers . lambdaQuery ();
inventoryHeaderLambdaQueryWrapper . eq ( InventoryHeader: : getLocationCode , circleBeanList . get ( 0 ). getLocaitonCode ());
InventoryHeader inventoryHeader = inventoryService . getOne ( inventoryHeaderLambdaQueryWrapper );
Integer [] inventoryHeaderIds = new Integer []{ inventoryHeader . getId ()};
cycleCountDetailService . addDetails ( cycleCountHeader . getCode (), inventoryHeaderIds );
return cycleCountHeader . getCode ();
}
/**
* 生成盘点单主 Code
658
*
659
660
661
662
663
664
* @return
*/
public String createCode ( ) {
String code ;
Date now = new Date ();
SimpleDateFormat df = new SimpleDateFormat ( "yyyyMMdd" );
665
666
String maxCode = cycleCountHeaderMapper . getLastCode ();
;
667
//如果指定类型的最后的code存在,并且日期一致。那么 code = 单类型 + 年月日 + (排序号 + 1)
668
669
if ( maxCode != null && maxCode . substring ( maxCode . length () - 13 , maxCode . length () - 5 ). equals ( df . format ( now ))) {
Integer Count = Integer . valueOf ( maxCode . substring ( maxCode . length () - 5 , maxCode . length ()));
670
code = "PD" + df . format ( now ) + String . format ( "%05d" , Count + 1 );
671
} else {
672
673
674
675
676
code = "PD" + df . format ( now ) + "00001" ;
}
return code ;
}
677
678
679
680
681
@PostMapping ( "/callBox" )
@ResponseBody
@ApiOperation ( "呼叫料盒" )
@Log ( title = "呼叫料盒" , action = BusinessType . OTHER )
@Transactional ( rollbackFor = Exception . class )
682
public AjaxResult callBox ( @RequestBody @ApiParam ( value = "物料号" ) Map < String , String > param ) {
683
684
String containerCode = param . get ( "containerCode" );
String destinationLocation = param . get ( "destinationLocation" );
685
686
LambdaQueryWrapper < Container > lambdaQueryWrapper = Wrappers . lambdaQuery ();
lambdaQueryWrapper . eq ( Container: : getCode , containerCode ). eq ( Container: : getWarehouseCode , ShiroUtils . getWarehouseCode ());
687
Container container = containerService . getOne ( lambdaQueryWrapper );
688
if ( container == null ) {
689
690
return AjaxResult . error ( "容器不存在" );
}
691
if (! StringUtils . isNotEmpty ( container . getLocationCode ())) {
692
693
return AjaxResult . error ( "容器不在库位[" + container . getLocationCode () + "]上" );
}
694
if (! container . getLocationCode (). equals ( destinationLocation )) {
695
696
697
698
699
700
return AjaxResult . error ( "容器不在目的库位上" );
}
Location temp = new Location ();
temp . setCode ( destinationLocation );
temp . setWarehouseCode ( ShiroUtils . getWarehouseCode ());
Location location = locationService . selectFirstEntity ( temp );
701
if ( StringUtils . isNotEmpty ( destinationLocation )) {
702
703
704
705
706
707
708
709
710
711
712
713
714
715
//校验目标地址
if ( location == null ) {
return AjaxResult . error ( "目标库位不存在" );
}
if (! QuantityConstant . STATUS_LOCATION_EMPTY . equals ( location . getStatus ())) {
return AjaxResult . error ( "目标库位非空闲" );
}
}
//判断托盘是否已经存在任务
List < TaskHeader > list = taskService . list ( new LambdaQueryWrapper < TaskHeader >()
. eq ( TaskHeader: : getContainerCode , containerCode )
. ne ( TaskHeader: : getStatus , QuantityConstant . TASK_STATUS_COMPLETED )
. eq ( TaskHeader: : getWarehouseCode , ShiroUtils . getWarehouseCode ())
);
716
if ( CollectionUtils . isNotEmpty ( list )) {
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
return AjaxResult . error ( "容器已存在任务" );
}
//创建主任务
TaskHeader taskHeader = new TaskHeader ();
taskHeader . setId ( null );
taskHeader . setWarehouseCode ( ShiroUtils . getWarehouseCode ());
taskHeader . setCompanyCode ( ShiroUtils . getCompanyCode ()); //货主
taskHeader . setType ( QuantityConstant . TASK_TYPE_SUPPLEMENTRECEIPT );
taskHeader . setInternalTaskType ( QuantityConstant . TASK_INTENERTYPE_RECEIPT );
taskHeader . setContainerCode ( container . getCode ());
taskHeader . setStatus ( QuantityConstant . TASK_STATUS_BUILD );
taskHeader . setZoneCode ( location . getZoneCode ());
taskHeader . setFromLocation ( location . getCode ());
taskHeader . setToLocation ( location . getCode ());
taskHeader . setCreated ( new Date ());
733
taskHeader . setCreatedBy ( ShiroUtils . getUserName ());
734
735
taskHeader . setLastUpdatedBy ( ShiroUtils . getLoginName ());
taskHeader . setLastUpdated ( new Date ());
736
if ( taskService . save ( taskHeader )) {
737
//锁定库位状态
738
TaskDetail taskDetail = new TaskDetail ();
739
740
741
742
743
744
745
746
747
748
749
750
taskDetail . setTaskId ( taskHeader . getId ());
taskDetail . setTaskType ( QuantityConstant . TASK_TYPE_SUPPLEMENTRECEIPT );
taskDetail . setInternalTaskType ( QuantityConstant . TASK_INTENERTYPE_RECEIPT );
taskDetail . setWarehouseCode ( ShiroUtils . getWarehouseCode ());
taskDetail . setCompanyCode ( ShiroUtils . getCompanyCode ());
taskDetail . setStatus ( QuantityConstant . TASK_STATUS_BUILD );
taskDetail . setFromLocation ( location . getCode ());
taskDetail . setToLocation ( location . getCode ());
taskDetail . setContainerCode ( containerCode );
taskDetail . setCreated ( new Date ());
taskDetail . setLastUpdated ( new Date ());
taskDetailService . save ( taskDetail );
751
locationService . updateStatus ( location . getCode (), QuantityConstant . STATUS_LOCATION_LOCK );
752
753
754
755
756
757
758
759
760
761
762
763
} else {
throw new ServiceException ( "补充入库主表生成失败!" );
}
return AjaxResult . success ( taskHeader . getId ());
}
@PostMapping ( "/quickReceipt" )
@ResponseBody
@ApiOperation ( "呼叫料盒收货保存" )
@Log ( title = "呼叫料盒收货保存" , action = BusinessType . OTHER )
@Transactional ( rollbackFor = Exception . class )
764
public AjaxResult quickReceipt ( @RequestBody @ApiParam ( value = "收货单" ) List < ReceiptBill > receiptBills ) throws Exception {
765
766
767
if ( receiptBills == null || receiptBills . size () <= 0 ) {
throw new JSONException ( "没有收货信息" );
}
768
769
boolean flag = true ;
for ( ReceiptBill receiptBill : receiptBills ) {
770
771
772
773
//String companyCode = receiptBill.getCompanyCode();
String containerCode = receiptBill . getReceiptContainerCode ();
String locationCode = receiptBill . getLocationCode ();
String receiptDetailId = receiptBill . getReceiptDetailId ();
774
775
LambdaQueryWrapper < Container > lambdaQueryWrapper = Wrappers . lambdaQuery ();
lambdaQueryWrapper . eq ( Container: : getCode , containerCode ). eq ( Container: : getWarehouseCode , ShiroUtils . getWarehouseCode ());
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
Container container = containerService . getOne ( lambdaQueryWrapper );
if ( container == null ) {
throw new JSONException ( "不存在这个托盘" );
}
if ( locationCode != null && locationCode . equals ( container . getLocationCode ())) {
//查询未完成的入库任务
List < TaskHeader > list = taskService . list ( new LambdaQueryWrapper < TaskHeader >()
. eq ( TaskHeader: : getContainerCode , containerCode )
. ne ( TaskHeader: : getTaskType , QuantityConstant . TASK_TYPE_SUPPLEMENTRECEIPT )
. eq ( TaskHeader: : getWarehouseCode , ShiroUtils . getWarehouseCode ())
. ne ( TaskHeader: : getStatus , QuantityConstant . TASK_STATUS_COMPLETED )
);
if ( CollectionUtils . isNotEmpty ( list )) {
throw new JSONException ( "没有找到托盘对应的任务" );
}
ReceiptDetail receiptDetail = receiptDetailService . getById ( Integer . valueOf ( receiptDetailId ));
if ( receiptDetail == null ) {
throw new JSONException ( "没有找到入库单详情" );
}
ReceiptHeader receiptHeader = receiptHeaderService . getById ( receiptDetail . getReceiptId ());
if ( receiptHeader == null ) {
throw new JSONException ( "没有找到入库单" );
}
/* *
* select * from receipt_container_header where containerCode = # { containerCode } and status & lt ; 20
*/
ReceiptContainerHeader receiptContainerHeader = new ReceiptContainerHeader ();
receiptContainerHeader . setContainerCode ( containerCode );
/* List < ReceiptContainerHeader > list = receiptContainerHeaderMapper . selectUnCompletedReceiptContainer ( receiptContainerHeader );
if ( list . size () >= 1 ){
throw new ServiceException ( "容器已经生成任务,不能放物料了!" );
}*/
//如果不存在记录则新建记录
receiptContainerHeader . setWarehouseCode ( ShiroUtils . getWarehouseCode ());
receiptContainerHeader . setTaskType ( QuantityConstant . TASK_TYPE_SUPPLEMENTRECEIPT );
receiptContainerHeader . setCompanyCode ( ShiroUtils . getCompanyCode ());
receiptContainerHeader . setFromLocation ( container . getLocationCode ());
receiptContainerHeader . setToLocation ( container . getLocationCode ());
receiptContainerHeader . setCreatedBy ( ShiroUtils . getLoginName ());
receiptContainerHeader . setStatus ( QuantityConstant . RECEIPT_CONTAINER_TASK );
if ( receiptContainerHeaderService . save ( receiptContainerHeader )) {
throw new ServiceException ( "入库组盘头表保存失败" );
}
receiptHeader . setFirstStatus ( 200 );
receiptHeader . setLastStatus ( 200 );
receiptHeaderService . updateById ( receiptHeader );
TaskHeader taskHeader = list . get ( 0 );
taskHeader . setAllocationHeadId ( receiptContainerHeader . getId ());
taskService . updateById ( taskHeader );
ReceiptDetail receiptDetail2 = receiptDetailService . getById ( Integer . valueOf ( receiptBill . getReceiptDetailId ()));
if ( receiptDetail2 == null ) {
throw new JSONException ( "没有找到入库单详情" );
}
BigDecimal openQty = receiptDetail2 . getTaskQty ();
BigDecimal totalQty = receiptDetail2 . getQty ();
BigDecimal qty = openQty . add ( receiptBill . getQty ());
if ( totalQty . subtract ( qty ). compareTo ( BigDecimal . ZERO ) < 0 ) {
throw new Exception ( "配盘数量大于表单数量" );
}
receiptDetail2 . setTaskQty ( qty );
receiptDetailService . updateById ( receiptDetail2 );
ReceiptContainerDetail receiptContainerDetail = new ReceiptContainerDetail ();
receiptContainerDetail . setReceiptContainerId ( receiptContainerHeader . getId ());
receiptContainerDetail . setReceiptId ( receiptHeader . getId ());
receiptContainerDetail . setReceiptDetailId ( receiptDetail2 . getId ());
receiptContainerDetail . setReceiptCode ( receiptHeader . getCode ());
848
Material material = materialService . getOne ( new LambdaQueryWrapper < Material >(). eq ( Material: : getCode , receiptDetail2 . getMaterialCode ()). eq ( Material: : getWarehouseCode , ShiroUtils . getWarehouseCode ()));
849
850
851
852
853
854
855
856
receiptContainerDetail . setMaterialCode ( material . getCode ());
receiptContainerDetail . setMaterialName ( material . getName ());
receiptContainerDetail . setMaterialSpec ( material . getSpec ());
receiptContainerDetail . setQty ( receiptBill . getQty ());
receiptContainerDetail . setCreatedBy ( ShiroUtils . getLoginName ());
receiptContainerDetailService . save ( receiptContainerDetail );
857
858
859
860
List < TaskDetail > taskDetailList = taskDetailService . list ( new LambdaQueryWrapper < TaskDetail >(). eq ( TaskDetail: : getTaskId , taskHeader . getId ()));
if ( flag ) {
if ( taskDetailList . size () == 1 && taskDetailList != null ) {
TaskDetail taskDetail = taskDetailList . get ( 0 );
861
862
863
864
865
866
867
868
869
870
871
872
873
taskDetail . setContainerCode ( containerCode );
taskDetail . setWarehouseCode ( ShiroUtils . getWarehouseCode ());
taskDetail . setCompanyCode ( ShiroUtils . getCompanyCode ());
taskDetail . setMaterialCode ( material . getCode ());
taskDetail . setMaterialName ( material . getName ());
taskDetail . setBillCode ( receiptHeader . getCode ());
taskDetail . setBillId ( receiptHeader . getId ());
taskDetail . setBillDetailId ( Integer . parseInt ( receiptBill . getReceiptDetailId ()));
taskDetail . setQty ( receiptBill . getQty ());
taskDetail . setFromLocation ( taskHeader . getFromLocation ());
taskDetail . setToLocation ( taskHeader . getToLocation ());
taskDetail . setAllocationId ( receiptContainerDetail . getId ());
taskDetailService . updateById ( taskDetail );
874
flag = false ;
875
}
876
} else {
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
TaskDetail taskDetail = new TaskDetail ();
taskDetail . setContainerCode ( containerCode );
taskDetail . setWarehouseCode ( ShiroUtils . getWarehouseCode ());
taskDetail . setCompanyCode ( ShiroUtils . getCompanyCode ());
taskDetail . setMaterialCode ( material . getCode ());
taskDetail . setMaterialName ( material . getName ());
taskDetail . setBillCode ( receiptHeader . getCode ());
taskDetail . setBillId ( receiptHeader . getId ());
taskDetail . setBillDetailId ( Integer . parseInt ( receiptBill . getReceiptDetailId ()));
taskDetail . setQty ( receiptBill . getQty ());
taskDetail . setFromLocation ( taskHeader . getFromLocation ());
taskDetail . setToLocation ( taskHeader . getToLocation ());
taskDetail . setAllocationId ( receiptContainerDetail . getId ());
taskDetailService . save ( taskDetail );
}
}
}
return AjaxResult . success ( "收货成功" );
}
896
}