1
2
package com . huaheng . api . mes . controller ;
3
4
import com.alibaba.fastjson.JSONArray ;
import com.alibaba.fastjson.JSONObject ;
5
6
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper ;
import com.baomidou.mybatisplus.core.toolkit.Wrappers ;
7
8
9
import com.huaheng.api.mes.dto.* ;
import com.huaheng.api.mes.dto.otherReceipt.OtherReceiptDetail ;
import com.huaheng.api.mes.dto.otherReceipt.OtherReceiptHeader ;
10
import com.huaheng.api.mes.result.ReturnInfo ;
11
import com.huaheng.api.mes.service.IMesService ;
12
13
import com.huaheng.api.mes.utils.CallaMOM ;
import com.huaheng.api.mes.utils.SqlServer ;
14
import com.huaheng.api.mes.vo.InventoryVO ;
15
import com.huaheng.api.mes.vo.InventoryTransactionVO ;
16
import com.huaheng.common.constant.QuantityConstant ;
17
import com.huaheng.common.exception.service.ServiceException ;
18
import com.huaheng.common.utils.StringUtils ;
19
import com.huaheng.common.utils.reflect.ReflectUtils ;
20
import com.huaheng.common.utils.security.ShiroUtils ;
21
22
23
24
import com.huaheng.framework.aspectj.lang.annotation.ApiLogger ;
import com.huaheng.framework.web.controller.BaseController ;
import com.huaheng.framework.web.domain.AjaxResult ;
import com.huaheng.framework.web.domain.RetCode ;
25
import com.huaheng.pc.config.address.service.AddressService ;
26
import com.huaheng.pc.config.material.domain.Material ;
27
import com.huaheng.pc.config.material.service.MaterialService ;
28
29
import com.huaheng.pc.inventory.inventoryDetail.domain.InventoryDetail ;
import com.huaheng.pc.inventory.inventoryDetail.service.InventoryDetailService ;
30
31
import com.huaheng.pc.inventory.inventoryTransaction.domain.InventoryTransaction ;
import com.huaheng.pc.inventory.inventoryTransaction.service.InventoryTransactionService ;
32
import com.huaheng.pc.momLog.service.IMomLogService ;
33
34
import com.huaheng.pc.receipt.receiptDetail.domain.ReceiptDetail ;
import com.huaheng.pc.receipt.receiptDetail.service.ReceiptDetailService ;
易文鹏
authored
10 months ago
35
36
import com.huaheng.pc.receipt.receiptDetailHistory.domain.ReceiptDetailHistory ;
import com.huaheng.pc.receipt.receiptDetailHistory.service.ReceiptDetailHistoryService ;
37
38
import com.huaheng.pc.receipt.receiptHeader.domain.ReceiptHeader ;
import com.huaheng.pc.receipt.receiptHeader.service.ReceiptHeaderService ;
易文鹏
authored
10 months ago
39
import com.huaheng.pc.receipt.receiptHeaderHistory.domain.ReceiptHeaderHistory ;
易文鹏
authored
10 months ago
40
import com.huaheng.pc.receipt.receiptHeaderHistory.service.ReceiptHeaderHistoryService ;
41
42
import com.huaheng.pc.shipment.shipmentDetail.domain.ShipmentDetail ;
import com.huaheng.pc.shipment.shipmentDetail.service.ShipmentDetailService ;
易文鹏
authored
10 months ago
43
44
import com.huaheng.pc.shipment.shipmentDetailHistory.domain.ShipmentDetailHistory ;
import com.huaheng.pc.shipment.shipmentDetailHistory.service.ShipmentDetailHistoryService ;
45
46
import com.huaheng.pc.shipment.shipmentHeader.domain.ShipmentHeader ;
import com.huaheng.pc.shipment.shipmentHeader.service.ShipmentHeaderService ;
47
48
import com.huaheng.pc.shipment.shipmentHeaderHistory.domain.ShipmentHeaderHistory ;
import com.huaheng.pc.shipment.shipmentHeaderHistory.service.ShipmentHeaderHistoryService ;
49
50
import com.huaheng.pc.system.user.domain.User ;
import com.huaheng.pc.system.user.service.IUserService ;
51
52
import com.huaheng.pc.task.taskDetail.domain.TaskDetail ;
import com.huaheng.pc.task.taskDetail.service.TaskDetailService ;
53
import io.swagger.annotations.ApiOperation ;
54
import lombok.extern.slf4j.Slf4j ;
55
56
import org.slf4j.Logger ;
import org.slf4j.LoggerFactory ;
57
import org.springframework.beans.BeanUtils ;
58
59
60
import org.springframework.web.bind.annotation.* ;
import javax.annotation.Resource ;
61
import java.io.UnsupportedEncodingException ;
易文鹏
authored
about a year ago
62
import java.math.BigDecimal ;
63
64
65
66
import java.sql.ResultSet ;
import java.sql.SQLException ;
import java.time.LocalDateTime ;
import java.time.format.DateTimeFormatter ;
67
import java.util.* ;
易文鹏
authored
about a year ago
68
import java.util.stream.Collectors ;
69
70
71
@RestController
72
@Slf4j
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
@RequestMapping ( "/API/WMS/v2" )
public class MesReceiptController extends BaseController {
@Resource
private ReceiptHeaderService receiptHeaderService ;
@Resource
private ReceiptDetailService receiptDetailService ;
@Resource
private ShipmentHeaderService shipmentHeaderService ;
@Resource
private ShipmentDetailService shipmentDetailService ;
@Resource
private InventoryDetailService inventoryDetailService ;
91
92
@Resource
private TaskDetailService taskDetailService ;
易文鹏
authored
10 months ago
93
94
95
96
@Resource
private ShipmentDetailHistoryService shipmentDetailHistoryService ;
@Resource
private ReceiptDetailHistoryService receiptDetailHistoryService ;
97
98
99
100
@Resource
private InventoryTransactionService inventoryTransactionService ;
@Resource
101
102
private ShipmentHeaderHistoryService shipmentHeaderHistoryService ;
@Resource
易文鹏
authored
10 months ago
103
104
private ReceiptHeaderHistoryService receiptHeaderHistoryService ;
@Resource
105
106
private MaterialService materialService ;
107
108
@Resource
private IMomLogService momLogService ;
109
110
@Resource
private IMesService mesService ;
111
112
@Resource
private IUserService userService ;
113
114
115
116
@Resource
private AddressService addressService ;
117
@PostMapping ( "/receipt" )
118
@ApiLogger ( apiName = "添加入库单及其明细" , from = "ROBOT" )
119
120
@ApiOperation ( "添加入库单及其明细" )
public AjaxResult receipt ( @RequestBody ReceiptDTO receiptDTO ) {
121
122
123
AjaxResult ajaxResult = handleQuest ( "receipt" , new MultiProcessListener () {
@Override
public AjaxResult doProcess ( ) {
124
return mesService . receipt ( receiptDTO );
125
}
126
127
});
return ajaxResult ;
128
129
}
130
131
132
/**
* 添加出库单及其明细
133
*
134
135
136
137
* @param receiptDTO
* @return
*/
@PostMapping ( "/shipment" )
138
@ApiLogger ( apiName = "添加出库单及其明细" , from = "ROBOT" )
139
140
@ApiOperation ( "添加出库单及其明细" )
public AjaxResult shipment ( @RequestBody ReceiptDTO receiptDTO ) {
141
142
143
AjaxResult ajaxResult = handleQuest ( "shipment" , new MultiProcessListener () {
@Override
public AjaxResult doProcess ( ) {
144
return mesService . shipment ( receiptDTO );
145
}
146
});
147
return ajaxResult ;
148
149
}
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
private JSONObject getJsonObject ( Header header , List < Detail > details ) {
JSONObject data = new JSONObject ();
JSONObject Rd_In_M = new JSONObject ();
Rd_In_M . put ( "MGPK" , header . getId ());
Rd_In_M . put ( "cCode" , header . getReferCode ());
JSONArray Rd_In_S = new JSONArray ();
details . forEach ( detail -> {
JSONObject json = new JSONObject ();
json . put ( "MGPK" , header . getId ());
json . put ( "SGPK" , detail . getId ());
json . put ( "cInvCode" , detail . getMaterialCode ());
Rd_In_S . add ( json );
});
data . put ( "Requester" , "WMS" );
data . put ( "Rd_In_M" , Rd_In_M );
data . put ( "Rd_In_S" , Rd_In_S );
return data ;
}
169
170
171
/**
* 入库单参数 _ 判空处理
172
*
173
174
175
176
* @param ajaxResult
* @param shipmentHeader
* @param shipemtnDetails
*/
易文鹏
authored
about a year ago
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
//private boolean enterIsNull(AjaxResult ajaxResult, Header shipmentHeader, List<Detail> shipemtnDetails) {
//
// if (isNullData(ajaxResult, shipmentHeader, shipemtnDetails)) {
// return true;
// }
//
// if (StringUtils.isEmpty(shipmentHeader.getRefeCodeType())) {
// ajaxResult.setCode(RetCode.FAIL).setMsg("单据类型不能为空!!!");
// return true;
// } else if (StringUtils.isEmpty(shipmentHeader.getReferCode())) {
// ajaxResult.setCode(RetCode.FAIL).setMsg("单据单号不能为空!!!");
// return true;
// } else if (shipmentHeader.getTotalQty() == null || shipmentHeader.getTotalQty().intValue() <= 0) {
// ajaxResult.setCode(RetCode.FAIL).setMsg("数量不能为空!!!");
// }
//
// shipemtnDetails.forEach(shipemtnDetail -> {
// if (StringUtils.isEmpty(shipemtnDetail.getMaterialCode())) {
// ajaxResult.setCode(RetCode.FAIL).setMsg("物料编码不能为空!!!");
// } else if (shipemtnDetail.getTotalQty() == null || shipemtnDetail.getQty().intValue() <= 0) {
// ajaxResult.setCode(RetCode.FAIL).setMsg("数量不能为空!!!");
// }
// });
// return StringUtils.isNotEmpty(ajaxResult.getMsg());
//}
202
203
204
/**
* 出库单参数 _ 判空处理
205
*
206
207
208
209
* @param ajaxResult
* @param shipmentHeader
* @param shipemtnDetails
*/
210
211
private boolean outIsNull ( AjaxResult ajaxResult , Header shipmentHeader , List < Detail > shipemtnDetails ) {
if ( isNullData ( ajaxResult , shipmentHeader , shipemtnDetails )) {
212
213
return true ;
}
214
215
216
217
218
219
if ( StringUtils . isEmpty ( shipmentHeader . getReferCode ())) {
ajaxResult . setCode ( RetCode . FAIL ). setMsg ( "单据单号不能为空!!!" );
return true ;
}
220
shipemtnDetails . forEach ( shipemtnDetail -> {
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
if ( StringUtils . isEmpty ( shipemtnDetail . getMaterialCode ())) {
ajaxResult . setCode ( RetCode . FAIL ). setMsg ( "物料编码不能为空!!!" );
}
});
return StringUtils . isNotEmpty ( ajaxResult . getMsg ());
}
/**
* 判空处理
*/
private boolean isNullData ( AjaxResult ajaxResult , Header shipmentHeader , List < Detail > shipemtnDetails ) {
if ( shipmentHeader == null ) {
ajaxResult . setCode ( RetCode . FAIL ). setMsg ( "出库单头表不能为空!!!" );
return true ;
} else if ( shipemtnDetails == null || shipemtnDetails . size () < 1 ) {
ajaxResult . setCode ( RetCode . FAIL ). setMsg ( "出库单明细表集不能为空!!!" );
return true ;
}
return false ;
}
/**
243
* 入库单单据取消
244
*/
245
246
@PostMapping ( "/cancelEnterWarehouse" )
@ApiOperation ( "入库单单据取消" )
247
@ApiLogger ( apiName = "入库单单据取消" , from = "ROBOT" )
248
public AjaxResult cancelEnterWarehouse ( @RequestBody ReceiptDTO receiptDTO ) {
249
250
251
252
253
AjaxResult ajaxResult = handleQuest ( "cancelEnterWarehouse" , new MultiProcessListener () {
@Override
public AjaxResult doProcess ( ) {
AjaxResult ajaxResult = mesService . cancelEnterWarehouse ( receiptDTO );
return ajaxResult ;
254
}
255
256
});
return ajaxResult ;
257
258
259
260
261
262
263
264
}
/**
* 出库单单据取消
*/
@PostMapping ( "/cancelOutWarehouse" )
@ApiOperation ( "出库单单据取消" )
265
@ApiLogger ( apiName = "出库单单据取消" , from = "ROBOT" )
266
public AjaxResult cancelOutWarehouse ( @RequestBody ReceiptDTO receiptDTO ) {
267
268
269
270
271
AjaxResult ajaxResult = handleQuest ( "cancelOutWarehouse" , new MultiProcessListener () {
@Override
public AjaxResult doProcess ( ) {
AjaxResult ajaxResult = mesService . cancelOutWarehouse ( receiptDTO );
return ajaxResult ;
272
}
273
274
});
return ajaxResult ;
275
276
}
易文鹏
authored
about a year ago
277
278
279
280
281
282
283
284
285
286
287
288
289
//private AjaxResult isNull(Header header, List<Detail> details) {
// AjaxResult ajaxResult = new AjaxResult();
// boolean isNull = outIsNull(ajaxResult, header, details);
// details.forEach(detail -> {
// if (detail.getTotalQty() == null || detail.getTotalQty().intValue() <= 0) {
// ajaxResult.setCode(RetCode.FAIL).setMsg("总数量不能为空!!!");
// }
// });
// if (isNull || StringUtils.isNotEmpty(ajaxResult.getMsg())) {
// return ajaxResult;
// }
// return ajaxResult;
//}
290
291
292
293
294
/**
* 查询库存
*/
@PostMapping ( "/searchInventory" )
295
@ApiLogger ( apiName = "查询库存" , from = "ROBOT" )
296
297
public AjaxResult searchInventory ( @RequestBody Detail detailed ) {
298
299
300
301
302
303
304
305
306
307
308
309
310
//List<ShipmentHeader> shipmentHeaders = shipmentHeaderService.list(new LambdaQueryWrapper<ShipmentHeader>()
// .gt(ShipmentHeader::getFirstStatus, QuantityConstant.SHIPMENT_CONTAINER_BUILD)
// .ne(ShipmentHeader::getPushSuccessStatus, 1));
//
//List<ShipmentDetail> shipmentDetails = new ArrayList<>();
//for (ShipmentHeader shipmentHeader : shipmentHeaders) {
// List<ShipmentDetail> details = shipmentDetailService.list(new LambdaQueryWrapper<ShipmentDetail>()
// .gt(ShipmentDetail::getTaskQty, 0)
// .eq(ShipmentDetail::getShipmentId, shipmentHeader.getId()));
// shipmentDetails.addAll(details);
//}
311
String materialName = detailed . getMaterialName ();
312
String materialCode = detailed . getMaterialCode ();
313
String containerCode = detailed . getContainerCode ();
314
315
316
LambdaQueryWrapper < InventoryDetail > lambdaQueryWrapper = Wrappers . lambdaQuery ();
// 物料编码
317
if ( StringUtils . isNotEmpty ( materialName )) {
318
319
lambdaQueryWrapper . eq ( InventoryDetail: : getMaterialName , materialName );
}
320
// 物料名称
321
if ( StringUtils . isNotEmpty ( materialCode )) {
322
323
lambdaQueryWrapper . eq ( InventoryDetail: : getMaterialCode , materialCode );
}
324
// 托盘号
325
if ( StringUtils . isNotEmpty ( containerCode )) {
326
327
lambdaQueryWrapper . eq ( InventoryDetail: : getContainerCode , containerCode );
}
328
329
if ( StringUtils . isEmpty ( materialName ) && StringUtils . isEmpty ( containerCode ) && StringUtils . isEmpty ( containerCode )) {
330
331
lambdaQueryWrapper . gt ( InventoryDetail: : getQty , 0 );
}
332
List < InventoryDetail > detailList = inventoryDetailService . list ( lambdaQueryWrapper );
333
334
List < InventoryVO > inventoryVOList = new ArrayList <>();
335
detailList . forEach ( detail -> {
336
InventoryVO inventoryVO = new InventoryVO ();
337
BeanUtils . copyProperties ( detail , inventoryVO );
易文鹏
authored
about a year ago
338
339
340
341
342
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
if ( StringUtils . isBlank ( detail . getWarehouse ())) {
inventoryVO . setWarehouse ( "035" );
} else {
inventoryVO . setWarehouse ( detail . getWarehouse ());
}
inventoryVOList . add ( inventoryVO );
});
return AjaxResult . success ( inventoryVOList );
}
/**
* 查询已出库部分的库存
* 物料编码、物料名称、已出数量、仓库编码( warehouse )
*/
@PostMapping ( "/queryOutboundInventory" )
@ApiLogger ( apiName = "查询已出库部分的库存" , from = "ROBOT" )
public AjaxResult queryOutboundInventory ( @RequestBody Detail detailed ) {
// 查询符合条件的 ShipmentHeader 集合
List < ShipmentHeader > shipmentHeaders = shipmentHeaderService . list ( new LambdaQueryWrapper < ShipmentHeader >()
. ne ( ShipmentHeader: : getFirstStatus , QuantityConstant . RECEIPT_HEADER_RETURN )
. ne ( ShipmentHeader: : getDeleted , true ));
List < ShipmentDetail > shipmentDetailList = new ArrayList <>();
// 查询符合条件的 ShipmentDetail 集合
for ( ShipmentHeader shipmentHeader : shipmentHeaders ) {
List < ShipmentDetail > shipmentDetails = shipmentDetailService . list ( new LambdaQueryWrapper < ShipmentDetail >()
. ne ( ShipmentDetail: : getTaskQty , 0 )
. eq ( ShipmentDetail: : getShipmentId , shipmentHeader . getId ()));
shipmentDetailList . addAll ( shipmentDetails );
}
//查询符合条件的 库存交易 集合
List < InventoryTransaction > its = new ArrayList <>();
for ( ShipmentDetail shipmentDetail : shipmentDetailList ) {
List < InventoryTransaction > inventoryTransactions = inventoryTransactionService . list ( new LambdaQueryWrapper < InventoryTransaction >()
. eq ( InventoryTransaction: : getTransactionType , 20 )
易文鹏
authored
about a year ago
377
. eq ( InventoryTransaction: : getBillDetailId , shipmentDetail . getId ()));
易文鹏
authored
about a year ago
378
379
380
381
382
383
384
385
386
387
388
if ( inventoryTransactions . size () > 1 ) {
// 如果查出多条数据,将taskQty字段由负数转为正数,并将taskQty的值全部累加放入第一个InventoryTransaction对象中
InventoryTransaction firstTransaction = inventoryTransactions . get ( 0 );
BigDecimal totalTaskQty = BigDecimal . ZERO ;
for ( int i = 1 ; i < inventoryTransactions . size (); i ++) {
InventoryTransaction transaction = inventoryTransactions . get ( i );
BigDecimal positiveTaskQty = transaction . getTaskQty (). abs ();
totalTaskQty = totalTaskQty . add ( positiveTaskQty );
}
firstTransaction . setTaskQty ( totalTaskQty );
its . add ( firstTransaction );
易文鹏
authored
about a year ago
389
//如果只有一个
易文鹏
authored
about a year ago
390
} else if (! inventoryTransactions . isEmpty ()) {
易文鹏
authored
about a year ago
391
392
393
InventoryTransaction inventoryTransaction = inventoryTransactions . get ( 0 );
inventoryTransaction . setTaskQty ( inventoryTransaction . getTaskQty (). abs ());
its . add ( inventoryTransaction );
易文鹏
authored
about a year ago
394
395
396
397
398
399
400
401
402
403
404
}
}
List < InventoryVO > inventoryVOList = new ArrayList <>();
its . forEach ( detail -> {
InventoryVO inventoryVO = new InventoryVO ();
BeanUtils . copyProperties ( detail , inventoryVO );
if ( StringUtils . isBlank ( detail . getWarehouse ())) {
inventoryVO . setWarehouse ( "035" );
} else {
inventoryVO . setWarehouse ( detail . getWarehouse ());
}
405
inventoryVOList . add ( inventoryVO );
406
407
});
408
return AjaxResult . success ( inventoryVOList );
409
410
411
}
易文鹏
authored
about a year ago
412
413
/**
414
* 获取出入库单明细记录
415
*
416
417
418
* @return AjaxResult
*/
@PostMapping ( "/getShipmentDetail" )
419
@ApiLogger ( apiName = "获取出入库单明细记录" , from = "ROBOT" )
420
@ApiOperation ( "获取出入库单明细记录" )
421
422
public AjaxResult getShipmentDetail ( @RequestBody GetOrderHistoryDTO getOrderHistoryDTO ) {
423
if ( StringUtils . isEmpty ( getOrderHistoryDTO . getEndTime ()) || StringUtils . isEmpty ( getOrderHistoryDTO . getStartTime ())) {
424
425
return AjaxResult . error ( "开始时间和结束时间不能为空!!!" );
}
426
LambdaQueryWrapper < InventoryTransaction > lambdaQueryWrapper = Wrappers . lambdaQuery ();
427
lambdaQueryWrapper
428
429
430
431
432
433
434
435
436
437
. ge ( InventoryTransaction: : getCreated , getOrderHistoryDTO . getStartTime ())
. le ( InventoryTransaction: : getCreated , getOrderHistoryDTO . getEndTime ());
List < InventoryTransaction > list = inventoryTransactionService . list ( lambdaQueryWrapper );
List < InventoryTransactionVO > inventoryTransactionVOList = new ArrayList <>();
list . forEach ( inventoryTransaction -> {
InventoryTransactionVO inventoryTransactionVO = new InventoryTransactionVO ();
BeanUtils . copyProperties ( inventoryTransaction , inventoryTransactionVO );
inventoryTransactionVOList . add ( inventoryTransactionVO );
});
return AjaxResult . success ( inventoryTransactionVOList );
438
439
440
441
442
}
/**
* 获取 sqlServer 数据库中物料信息 , 同步到本地数据库中
*/
易文鹏
authored
about a year ago
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
@PostMapping ( "/getAllMaterial" )
@ApiOperation ( "获取所有外部物料信息" )
public List < Material > getAllMaterial () {
List < Material > materialList = new ArrayList <>();
log . error ( "开始同步物料信息!!!" );
final String SQL_QUERY = "SELECT\n" +
"\ta.cinvcode AS '存货编码',\n" +
"\ta.cinvname AS '存货名称',\n" +
"\ta.cDefWareHouse AS '仓库',\n" +
"\te.cWhName AS '仓库名称',\n" +
"\ta.cComUnitCode AS '单位编码',\n" +
"\tb.cComUnitName AS '单位名称',\n" +
"\tc.cidefine6 AS '外形尺寸',\n" +
"\tc.cidefine7 AS '托盘类型',\n" +
"\ta.dModifyDate AS '修改时间',\n" +
"\ta.dSDate AS '启用时间',\n" +
"\ta.cinvstd AS '规格',\n" +
"\ta.Iinvweight AS '重量',\n" +
"\tA.CPLANMETHOD AS '属性',\n" +
"\ta.cinvccode AS '存货类别编码',\n" +
"\td.cInvCName AS '存货类别名称',\n" +
"\ta.cSRPolicy AS '供需政策',\n" +
"\tc.cidefine8 AS '是否批次',\n" +
"\tc.cidefine9 AS '是否可燃',\n" +
"\tc.cidefine10 AS '是否平库' \n" +
"FROM\n" +
"\tInventory a\n" +
"left join ComputationUnit b on a.cComUnitCode=b.cComUnitCode\n" +
"left join Inventory_extradefine c on a.cinvcode=c.cinvcode\n" +
"left join InventoryClass d on a.cinvccode=d.cinvccode\n" +
易文鹏
authored
about a year ago
473
"left join Warehouse e on a.cDefWareHouse = e.cWhCode\n" ;
易文鹏
authored
about a year ago
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
try {
ResultSet resultSet = SqlServer . find ( SQL_QUERY );
if ( resultSet == null ) {
return materialList ;
}
while ( resultSet . next ()) {
// 字段要一致
Material material = new Material ();
material . setWarehouseCode ( "CS0001" );
material . setCompanyCode ( "BHF" );
material . setCode ( resultSet . getString ( "存货编码" )); // 物料编码
material . setName ( resultSet . getString ( "存货名称" )); // 物料名称
material . setDefWareHouse ( resultSet . getString ( "仓库" )); // u8仓库
material . setCWhName ( resultSet . getString ( "仓库名称" )); // 单位编码
material . setUnitCode ( resultSet . getString ( "单位编码" ));
material . setUnit ( resultSet . getString ( "单位名称" ));
material . setPhysicalDimension ( resultSet . getString ( "外形尺寸" ));
material . setIsHigh ( "高托" . equals ( resultSet . getString ( "托盘类型" )) ? 1 : 0 );
material . setSpec ( resultSet . getString ( "规格" ));
material . setWeight ( resultSet . getString ( "重量" ));
material . setCinvccode ( resultSet . getString ( "存货类别编码" ));
material . setCInvCName ( resultSet . getString ( "存货类别名称" ));
material . setAttribute ( resultSet . getString ( "属性" ));
material . setPolicy ( resultSet . getString ( "供需政策" ));
material . setIsBatch ( resultSet . getString ( "是否批次" ));
material . setIsFlammable ( resultSet . getString ( "是否可燃" ));
material . setIsFlat ( resultSet . getString ( "是否平库" ));
materialList . add ( material );
}
} catch ( SQLException e ) {
log . error ( "同步海王物料失败!!!" + e . getMessage ());
}
return materialList ;
}
/**
* 获取 sqlServer 数据库中物料信息 , 同步到本地数据库中
*/
515
516
@PostMapping ( "/getMaterial" )
@ApiOperation ( "获取外部物料信息" )
517
public List < Material > getMaterial () {
518
List < Material > materialList = new ArrayList <>();
519
log . error ( "开始同步物料信息!!!" );
520
521
// 获取新增一天以内和修改四个小时以内的物料数据
//DATEDIFF() 函数返回两个日期之间的天数。
易文鹏
authored
about a year ago
522
//想还原sql改动,可以用cahtgpt
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
final String SQL_QUERY = "SELECT\n" +
"\ta.cinvcode AS '存货编码',\n" +
"\ta.cinvname AS '存货名称',\n" +
"\ta.cDefWareHouse AS '仓库',\n" +
"\te.cWhName AS '仓库名称',\n" +
"\ta.cComUnitCode AS '单位编码',\n" +
"\tb.cComUnitName AS '单位名称',\n" +
"\tc.cidefine6 AS '外形尺寸',\n" +
"\tc.cidefine7 AS '托盘类型',\n" +
"\ta.dModifyDate AS '修改时间',\n" +
"\ta.dSDate AS '启用时间',\n" +
"\ta.cinvstd AS '规格',\n" +
"\ta.Iinvweight AS '重量',\n" +
"\tA.CPLANMETHOD AS '属性',\n" +
"\ta.cinvccode AS '存货类别编码',\n" +
"\td.cInvCName AS '存货类别名称',\n" +
"\ta.cSRPolicy AS '供需政策',\n" +
"\tc.cidefine8 AS '是否批次',\n" +
"\tc.cidefine9 AS '是否可燃',\n" +
"\tc.cidefine10 AS '是否平库' \n" +
"FROM\n" +
"\tInventory a\n" +
易文鹏
authored
about a year ago
546
547
548
"\tLEFT JOIN ComputationUnit b ON a.cComUnitCode = b.cComUnitCode\n" +
"\tLEFT JOIN Inventory_extradefine c ON a.cinvcode = c.cinvcode\n" +
"\tLEFT JOIN InventoryClass d ON a.cinvccode = d.cinvccode\n" +
549
550
551
"\tLEFT JOIN Warehouse e ON a.cDefWareHouse = e.cWhCode \n" +
"WHERE\n" +
"\t(\n" +
易文鹏
authored
about a year ago
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
"\t\tdatediff(\n" +
"\t\t\tDAY,\n" +
"\t\t\ta.dSDate,\n" +
"\t\tgetdate ()) = 0 \n" +
"\t\tOR a.dModifyDate >= DATEADD (\n" +
"\t\t\tHOUR,\n" +
"\t\t\t- 4,\n" +
"\t\tGETDATE ()) \n" +
"\t)" ;
//"\tLEFT JOIN ComputationUnit b ON a.cComUnitCode= b.cComUnitCode\n" +
//"\tLEFT JOIN Inventory_extradefine c ON a.cinvcode= c.cinvcode\n" +
//"\tLEFT JOIN InventoryClass d ON a.cinvccode= d.cinvccode\n" +
//"\tLEFT JOIN Warehouse e ON a.cDefWareHouse = e.cWhCode \n" +
//"WHERE\n" +
//"\t(\n" +
//"\t\tdatediff( DAY, a.dSDate, getdate( ) ) = 0 \n" +
//"\t\tOR a.dModifyDate >= DATEADD( HOUR, - 4, GETDATE( ) ) \n" +
//"\t) \n" +
//"\tAND a.cDefWareHouse IN ( '035', '001', '003' )";
573
574
try {
575
576
ResultSet resultSet = SqlServer . find ( SQL_QUERY );
577
if ( resultSet == null ) {
578
579
return materialList ;
}
580
while ( resultSet . next ()) {
581
// 字段要一致
582
583
584
Material material = new Material ();
material . setWarehouseCode ( "CS0001" );
material . setCompanyCode ( "BHF" );
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
material . setCode ( resultSet . getString ( "存货编码" )); // 物料编码
material . setName ( resultSet . getString ( "存货名称" )); // 物料名称
material . setDefWareHouse ( resultSet . getString ( "仓库" )); // u8仓库
material . setCWhName ( resultSet . getString ( "仓库名称" )); // 单位编码
material . setUnitCode ( resultSet . getString ( "单位编码" ));
material . setUnit ( resultSet . getString ( "单位名称" ));
material . setPhysicalDimension ( resultSet . getString ( "外形尺寸" ));
material . setIsHigh ( "高托" . equals ( resultSet . getString ( "托盘类型" )) ? 1 : 0 );
material . setSpec ( resultSet . getString ( "规格" ));
material . setWeight ( resultSet . getString ( "重量" ));
material . setCinvccode ( resultSet . getString ( "存货类别编码" ));
material . setCInvCName ( resultSet . getString ( "存货类别名称" ));
material . setAttribute ( resultSet . getString ( "属性" ));
material . setPolicy ( resultSet . getString ( "供需政策" ));
material . setIsBatch ( resultSet . getString ( "是否批次" ));
material . setIsFlammable ( resultSet . getString ( "是否可燃" ));
material . setIsFlat ( resultSet . getString ( "是否平库" ));
603
604
materialList . add ( material );
}
605
606
} catch ( SQLException e ) {
log . error ( "同步海王物料失败!!!" + e . getMessage ());
607
608
}
return materialList ;
609
}
610
611
612
613
/**
* 当前时间向推几小时
*/
614
615
616
617
618
619
620
621
622
623
624
625
626
public String dateRoll ( int ihour ) {
DateTimeFormatter dateTimeFormatter = DateTimeFormatter . ofPattern ( "yyyy-MM-dd HH:mm:ss" );
// 获取当前时间
LocalDateTime date = LocalDateTime . now ();
// 获取当前时间的前几小时时间
LocalDateTime localDateTime = date . minusHours ( ihour );
return dateTimeFormatter . format ( localDateTime );
}
/**
* 查询站台任务明细列表
*/
627
@ApiLogger ( apiName = "查询站台任务明细列表" , from = "ROBOT" )
628
@PostMapping ( "/kanbanInfo" )
629
@CrossOrigin
630
public AjaxResult kanbanInfo ( @RequestBody TaskDetail taskDetail ) {
631
String fromLocation = taskDetail . getFromLocation ();
632
if ( StringUtils . isEmpty ( fromLocation )) {
633
return AjaxResult . error ( "站台不能为空!!!" );
634
}
635
636
LambdaQueryWrapper < TaskDetail > wrapper = Wrappers . lambdaQuery ();
wrapper . eq ( TaskDetail: : getFromLocation , fromLocation )
637
. lt ( TaskDetail: : getStatus , "100" );
638
639
640
641
List < TaskDetail > taskDetailList = taskDetailService . list ( wrapper );
return AjaxResult . success ( taskDetailList );
}
642
/**
643
* post 调用 E_Rd_In ( MOM )入库成功接口
644
*/
645
//@ApiLogger(apiName = "post调用E_Rd_In(MOM)入库接口", from="ROBOT")
646
@PostMapping ( "/postE_Rd_In" )
647
public ReturnInfo postE_Rd_In ( @RequestBody ReceiptDetail receiptDetail ) {
648
649
if ( StringUtils . isBlank ( receiptDetail . getLastUpdatedBy ())) {
receiptDetail . setLastUpdatedBy ( "" );
650
}
651
User user = userService . selectUserByEmail ( receiptDetail . getLastUpdatedBy ());
652
653
String loginName = "" ;
if ( user == null ) {
654
loginName = "" ;
655
656
657
658
} else {
loginName = user . getLoginName ();
}
ReceiptHeader receiptHeader = receiptHeaderService . getById ( receiptDetail . getReceiptId ());
659
JSONObject Rd_In_M = new JSONObject ();
660
661
Rd_In_M . put ( "mno" , receiptHeader . getCode ());
Rd_In_M . put ( "MGPK" , receiptHeader . getMOMID ());
662
663
664
Rd_In_M . put ( "cBusType" , receiptHeader . getReceiptType ());
Rd_In_M . put ( "TAID" , receiptHeader . getTAID ());
Rd_In_M . put ( "FAID" , receiptHeader . getFAID ());
665
Rd_In_M . put ( "UserNo" , loginName );
666
Rd_In_M . put ( "warehouse" , receiptHeader . getWarehouse ());
667
668
JSONArray jsonArray = new JSONArray ();
669
JSONObject Rd_In_S = new JSONObject ();
易文鹏
authored
about a year ago
670
671
672
List < TaskDetail > taskDetails = taskDetailService . list ( new LambdaQueryWrapper < TaskDetail >()
. eq ( TaskDetail: : getInternalTaskType , 100 )
. eq ( TaskDetail: : getBillDetailId , receiptDetail . getId ()));
易文鹏
authored
about a year ago
673
674
String str = computeWarehouseType ( taskDetails );
Rd_In_S . put ( "cidefine10" , str );
675
676
677
678
Rd_In_S . put ( "MGPK" , receiptHeader . getMOMID ());
Rd_In_S . put ( "SGPK" , receiptDetail . getMOMID ());
Rd_In_S . put ( "SNNO" , receiptDetail . getSNNO ());
Rd_In_S . put ( "cInvCode" , receiptDetail . getMaterialCode ());
679
680
Rd_In_S . put ( "Iquantity" , receiptDetail . getTaskQty ());
Rd_In_S . put ( "iFQuantity" , receiptDetail . getQty ());
易文鹏
authored
about a year ago
681
//Rd_In_S.put("cwhcode", "");
682
683
684
685
686
Rd_In_S . put ( "MOCode" , receiptDetail . getNoticeNo ());
Rd_In_S . put ( "ISUrgent" , receiptDetail . getIsUrgent ());
Rd_In_S . put ( "receiptBarcode" , receiptDetail . getReceiptBarcode ());
Rd_In_S . put ( "warehouse" , receiptHeader . getWarehouse ());
Rd_In_S . put ( "warehouseName" , receiptHeader . getWarehouseName ());
687
Rd_In_S . put ( "creatorCode" , loginName );
688
Rd_In_S . put ( "creatorName" , receiptDetail . getLastUpdatedBy ());
689
690
Rd_In_S . put ( "productionWorker" , receiptHeader . getProductionWorker ());
Rd_In_S . put ( "productionWorkerName" , receiptHeader . getProductionWorkerName ());
691
692
693
Rd_In_S . put ( "ifrom" , receiptDetail . getIfrom ());
Rd_In_S . put ( "LMPKID" , receiptDetail . getLMPKID ());
Rd_In_S . put ( "LSPKID" , receiptDetail . getLSPKID ());
694
695
696
697
698
699
700
701
jsonArray . add ( Rd_In_S );
JSONObject data = new JSONObject ();
data . put ( "Rd_In_M" , Rd_In_M );
data . put ( "Rd_In_S" , jsonArray );
String action = "E_Rd_In" ;
JSONObject json = new JSONObject ();
json . put ( "data" , data );
702
return postMOM ( action , json , "入库回传" );
703
704
705
706
}
/**
易文鹏
authored
about a year ago
707
* post 调用 E_Rd_In ( MOM )其他入库成功接口(盘点入库回传)
708
*/
709
//@ApiLogger(apiName = "post调用E_Rd_In(MOM)其他入库接口", from="ROBOT")
710
@PostMapping ( "/postOther_E_Rd_In" )
711
public ReturnInfo postOther_E_Rd_In ( @RequestBody List < ReceiptDetail > receiptDetails , ReceiptHeader receiptHeader ) {
712
713
714
715
716
717
718
719
720
721
722
OtherReceiptDomain domain = new OtherReceiptDomain ();
OtherReceiptHeader receiptHeader1 = new OtherReceiptHeader ();
receiptHeader1 . setCode ( receiptHeader . getCode ());
receiptHeader1 . setMomId ( receiptHeader . getMOMID ());
receiptHeader1 . setReceiptType ( receiptHeader . getReceiptType ());
receiptHeader1 . setTaId ( receiptHeader . getTAID ());
receiptHeader1 . setFaId ( receiptHeader . getFAID ());
receiptHeader1 . setLastUpdatedBy ( receiptHeader . getLastUpdatedBy ());
receiptHeader1 . setWarehouse ( receiptHeader . getWarehouse ());
receiptHeader1 . setDepCode ( QuantityConstant . DEFAULT_DEPT );
易文鹏
authored
about a year ago
723
receiptHeader1 . setStock ( receiptHeader . getWarehouse ());
724
725
726
727
List < OtherReceiptDetail > list = new ArrayList <>();
for ( ReceiptDetail receiptDetail : receiptDetails ) {
OtherReceiptDetail detail = new OtherReceiptDetail ();
易文鹏
authored
about a year ago
728
729
730
List < TaskDetail > taskDetails = taskDetailService . list ( new LambdaQueryWrapper < TaskDetail >()
. eq ( TaskDetail: : getInternalTaskType , 100 )
. eq ( TaskDetail: : getBillDetailId , receiptDetail . getId ()));
易文鹏
authored
about a year ago
731
732
String str = computeWarehouseType ( taskDetails );
detail . setIsFlat ( str );
733
734
735
736
737
738
detail . setMomIdByHeader ( receiptHeader . getMOMID ());
detail . setMomId ( receiptDetail . getMOMID ());
detail . setSnNo ( receiptDetail . getSNNO ());
detail . setMaterialCode ( receiptDetail . getMaterialCode ());
detail . setTaskQty ( receiptDetail . getTaskQty ());
detail . setQty ( receiptDetail . getQty ());
易文鹏
authored
about a year ago
739
detail . setWarehouseCode ( receiptHeader . getWarehouse ());
740
741
742
743
744
detail . setNotice ( receiptDetail . getNoticeNo ());
detail . setISUrgent ( receiptDetail . getIsUrgent ());
detail . setReceiptBarcode ( receiptDetail . getReceiptBarcode ());
detail . setWarehouse ( receiptHeader . getWarehouse ());
detail . setWarehouseName ( receiptHeader . getWarehouseName ());
易文鹏
authored
about a year ago
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
String lastUpdatedBy = receiptDetail . getLastUpdatedBy ();
if ( StringUtils . isEmpty ( lastUpdatedBy )) {
detail . setLastUpdatedBy ( "" );
detail . setLastUpdatedByName ( "" );
} else {
User user = userService . selectUserByEmail ( lastUpdatedBy );
String loginName ;
if ( user == null ) {
loginName = "" ;
} else {
loginName = user . getLoginName ();
}
detail . setLastUpdatedBy ( loginName );
detail . setLastUpdatedByName ( lastUpdatedBy );
}
761
762
763
764
765
766
767
768
769
770
771
772
detail . setProductionWorker ( receiptHeader . getProductionWorker ());
detail . setProductionWorkerName ( receiptHeader . getProductionWorkerName ());
list . add ( detail );
}
domain . setReceiptHeader ( receiptHeader1 );
domain . setReceiptDetails ( list );
//返回实体
ReturnDomain data = new ReturnDomain ();
data . setData ( domain );
String str = JSONObject . toJSONString ( data );
JSONObject jsonObject = JSONObject . parseObject ( str );
773
return postMOM ( "E_Rd_In" , jsonObject , "其他入库回传" );
774
775
776
}
/**
777
* post 调用 E_Rd_In ( MOM )出库成功接口
778
*/
779
//@ApiLogger(apiName = "post调用E_Rd_Out(MOM)出库接口", from="ROBOT")
780
@PostMapping ( "/postE_Rd_Out" )
781
public Boolean postE_Rd_Out ( @RequestBody ShipmentHeader shipmentHeader ) {
782
// ShipmentHeader shipmentHeader = shipmentHeaderService.getById(shipmentHeaderID.getId());
783
//StringBuffer keyField = new StringBuffer();
784
785
JSONArray dataArray = new JSONArray ();
// 如果订单为合并类型
786
if ( "merge" . equals ( shipmentHeader . getShipmentType ())) {
787
// 查询所有子表
788
List < ShipmentDetail > shipmentDetailList = shipmentDetailService . list ( new LambdaQueryWrapper < ShipmentDetail >(). eq ( ShipmentDetail: : getShipmentId , shipmentHeader . getId ()));
789
// 查询所有合并前的头表
790
791
792
793
794
795
796
StringBuilder ids = new StringBuilder ();
for ( ShipmentDetail shipmentDetail : shipmentDetailList ) {
ids . append ( "," ). append ( shipmentDetail . getRecordCode ());
}
String codes = ids . substring ( 1 , ids . length ());
String [] headerIdArr = codes . split ( "," );
797
List < ShipmentHeader > shipmentHeaderList = new ArrayList <>();
798
799
800
801
802
803
804
List < ShipmentHeaderHistory > list2 = shipmentHeaderHistoryService . list ( new LambdaQueryWrapper < ShipmentHeaderHistory >(). in ( ShipmentHeaderHistory: : getCode , headerIdArr ));
for ( ShipmentHeaderHistory shipmentHeaderHistory : list2 ) {
ShipmentHeader shipmentHeader1 = new ShipmentHeader ();
BeanUtils . copyProperties ( shipmentHeaderHistory , shipmentHeader1 );
shipmentHeaderList . add ( shipmentHeader1 );
}
805
// 根据合并前的头表id分组
806
Map < String , List < ShipmentDetail >> map = new HashMap <>();
807
for ( ShipmentDetail detail : shipmentDetailList ) {
808
String key = detail . getRecordCode ();
809
810
811
812
813
814
815
if ( key != null ) {
if ( map . containsKey ( key )) {
map . get ( key ). add ( detail );
} else {
List < ShipmentDetail > list = new ArrayList <>();
list . add ( detail );
map . put ( key , list );
816
}
817
}
818
}
819
820
for ( String key : map . keySet ()) {
821
822
823
824
825
JSONObject data = new JSONObject ();
// 合并前的头表
ShipmentHeader header = new ShipmentHeader ();
// 合并前头表对应的子表
List < ShipmentDetail > detailList = new ArrayList <>();
826
for ( ShipmentHeader SH : shipmentHeaderList ) {
827
if ( key . equals ( SH . getCode ())) {
828
829
header = SH ;
detailList = map . get ( key );
830
break ;
831
832
833
}
}
// 查询出库单据表头
834
JSONObject Rd_Out_M = getRd_Out_M ( header , shipmentHeader . getCreatedBy ());
835
836
837
838
839
JSONArray jsonArray = getRd_Out_S ( header , detailList );
data . put ( "Rd_Out_M" , Rd_Out_M );
data . put ( "Rd_Out_S" , jsonArray );
dataArray . add ( data );
}
840
} else {
841
// 查询出库单据表头
842
JSONObject Rd_Out_M = getRd_Out_M ( shipmentHeader , "" );
843
// 查询出库单据明细
844
845
List < ShipmentDetail > shipmentDetailList = shipmentDetailService . list ( new LambdaQueryWrapper < ShipmentDetail >()
. eq ( ShipmentDetail: : getShipmentId , shipmentHeader . getId ()));
846
JSONArray jsonArray = getRd_Out_S ( shipmentHeader , shipmentDetailList );
847
848
849
850
851
852
853
854
855
JSONObject data = new JSONObject ();
data . put ( "Rd_Out_M" , Rd_Out_M );
data . put ( "Rd_Out_S" , jsonArray );
dataArray . add ( data );
}
String action = "E_Rd_Out" ;
JSONObject json = new JSONObject ();
json . put ( "data" , dataArray );
856
857
ReturnInfo returnInfo = postMOM ( action , json , "出库回传" );
if ( returnInfo == null ) {
858
859
860
shipmentHeader . setErrorMsg ( "出库回传:接口地址错误或返回为空" );
shipmentHeader . setPushSuccessStatus ( 2 );
shipmentHeaderService . updateById ( shipmentHeader );
861
return false ;
862
}
863
shipmentHeader . setPushErrorCount ( shipmentHeader . getPushErrorCount () + 1 );
易文鹏
authored
7 months ago
864
if ( returnInfo . noError ()) {
865
shipmentHeader . setPushSuccessStatus ( 1 );
866
867
shipmentHeader . setFirstStatus ( QuantityConstant . SHIPMENT_HEADER_RETURN );
shipmentHeader . setLastStatus ( QuantityConstant . SHIPMENT_HEADER_RETURN );
868
} else {
869
shipmentHeader . setPushSuccessStatus ( 2 );
870
shipmentHeader . setErrorMsg ( returnInfo . getMsg ());
871
}
872
873
shipmentHeaderService . updateById ( shipmentHeader );
return true ;
874
875
}
876
public JSONArray getRd_Out_S ( ShipmentHeader shipmentHeader , List < ShipmentDetail > shipmentDetailList ) {
877
JSONArray jsonArray = new JSONArray ();
878
shipmentDetailList . forEach ( shipmentDetail -> {
879
User user = userService . selectUserByEmail ( shipmentDetail . getLastUpdatedBy ());
880
881
882
if ( user == null ) {
user = userService . selectUserByEmail ( shipmentHeader . getLastUpdatedBy ());
}
883
JSONObject Rd_Out_S = new JSONObject ();
884
Rd_Out_S . put ( "MGPK" , shipmentHeader . getMOMID ());
885
886
887
Rd_Out_S . put ( "SGPK" , shipmentDetail . getMOMID ());
Rd_Out_S . put ( "SNNO" , shipmentDetail . getSNNO ());
Rd_Out_S . put ( "cInvCode" , shipmentDetail . getMaterialCode ());
888
// 实际入库数量
889
Rd_Out_S . put ( "Iquantity" , shipmentDetail . getTaskQty ());
890
// MOM传入的入库数量
891
Rd_Out_S . put ( "iFQuantity" , shipmentDetail . getQty ());
易文鹏
authored
about a year ago
892
//Rd_Out_S.put("cwhcode", "035");
易文鹏
authored
about a year ago
893
894
895
List < TaskDetail > taskDetails = taskDetailService . list ( new LambdaQueryWrapper < TaskDetail >()
. eq ( TaskDetail: : getInternalTaskType , 200 )
. eq ( TaskDetail: : getBillDetailId , shipmentDetail . getId ()));
易文鹏
authored
about a year ago
896
897
String str = computeWarehouseType ( taskDetails );
Rd_Out_S . put ( "cidefine10" , str );
898
899
Rd_Out_S . put ( "MOCode" , shipmentDetail . getNoticeNo ());
Rd_Out_S . put ( "ISUrgent" , shipmentDetail . getIsUrgent ());
900
Rd_Out_S . put ( "updatedByNo" , user . getLoginName ());
901
902
903
Rd_Out_S . put ( "updatedBy" , shipmentDetail . getLastUpdatedBy ());
Rd_Out_S . put ( "warehouse" , shipmentHeader . getWarehouse ());
Rd_Out_S . put ( "warehouseName" , shipmentHeader . getWarehouseName ());
904
905
906
907
908
909
Rd_Out_S . put ( "creatorCode" , shipmentHeader . getCreatorCode ());
Rd_Out_S . put ( "creatorName" , shipmentHeader . getCreatorName ());
// Rd_Out_S.put("requestedStartDate", shipmentHeader.getRequestedStartDate());
Rd_Out_S . put ( "ifrom" , shipmentDetail . getIfrom ());
Rd_Out_S . put ( "LMPKID" , shipmentDetail . getLMPKID ());
Rd_Out_S . put ( "LSPKID" , shipmentDetail . getLSPKID ());
910
911
jsonArray . add ( Rd_Out_S );
});
912
913
return jsonArray ;
}
914
易文鹏
authored
about a year ago
915
916
public String computeWarehouseType ( List < TaskDetail > taskDetails ) {
易文鹏
authored
about a year ago
917
918
919
920
String str ;
if ( taskDetails . isEmpty ()) {
return "错误:未查询到任务!" ;
}
易文鹏
authored
about a year ago
921
922
923
924
int flatCount = 0 ;
int uprightCount = 0 ;
BigDecimal flatQty = BigDecimal . ZERO ;
BigDecimal uprightQty = BigDecimal . ZERO ;
易文鹏
authored
about a year ago
925
易文鹏
authored
about a year ago
926
927
928
929
for ( TaskDetail taskDetail : taskDetails ) {
if ( taskDetail . getFlat () != null && taskDetail . getFlat () == 1 ) {
flatCount ++;
flatQty = flatQty . add ( taskDetail . getQty ());
易文鹏
authored
about a year ago
930
易文鹏
authored
about a year ago
931
932
933
934
935
936
937
938
939
940
} else {
uprightCount ++;
uprightQty = uprightQty . add ( taskDetail . getQty ());
}
}
if ( flatCount > 0 && uprightCount == 0 ) {
str = "平库" ;
} else if ( uprightCount > 0 && flatCount == 0 ) {
str = "立库" ;
} else if ( flatCount > 0 && uprightCount > 0 ) {
易文鹏
authored
about a year ago
941
942
943
944
// 移除.0或.00后缀
String flatQtyStr = flatQty . stripTrailingZeros (). toPlainString ();
String uprightQtyStr = uprightQty . stripTrailingZeros (). toPlainString ();
str = "平库" + flatQtyStr + "/" + "立库" + uprightQtyStr ;
易文鹏
authored
about a year ago
945
} else {
易文鹏
authored
about a year ago
946
str = "未知错误" ;
易文鹏
authored
about a year ago
947
948
949
950
}
return str ;
}
951
public JSONObject getRd_Out_M ( @RequestBody ShipmentHeader shipmentHeader , String name ) {
952
User user = userService . selectUserByEmail ( shipmentHeader . getLastUpdatedBy ());
953
JSONObject Rd_Out_M = new JSONObject ();
954
Rd_Out_M . put ( "ISMOM" , shipmentHeader . getISMOM ());
955
956
957
958
959
Rd_Out_M . put ( "mno" , shipmentHeader . getCode ());
Rd_Out_M . put ( "MGPK" , shipmentHeader . getMOMID ());
Rd_Out_M . put ( "cBusType" , shipmentHeader . getShipmentType ());
Rd_Out_M . put ( "TAID" , shipmentHeader . getTAID ());
Rd_Out_M . put ( "FAID" , shipmentHeader . getFAID ());
960
961
962
963
964
965
if ( user == null ) {
String UserNo = userService . selectUserByEmail ( name ). getLoginName ();
Rd_Out_M . put ( "UserNo" , UserNo );
} else {
Rd_Out_M . put ( "UserNo" , user . getLoginName ());
}
易文鹏
authored
about a year ago
966
Rd_Out_M . put ( "warehouse" , shipmentHeader . getWarehouse ()); //仓库编码
967
Rd_Out_M . put ( "cDepCode" , "01030101" ); //部门编码
易文鹏
authored
about a year ago
968
//Rd_Out_M.put("cWhCode", shipmentHeader.getWarehouse());//仓库编码
969
return Rd_Out_M ;
970
971
}
972
973
974
975
976
/**
* utf - 8 转 GB2312
*/
public String getGB ( String action ) {
byte [] Rd_Out ; //中间用ISO-8859-1过渡
977
978
979
980
981
982
983
984
985
986
987
String data = null ;
try {
Rd_Out = action . getBytes ( "8859_1" );
data = new String ( Rd_Out , "GB2312" ); //转换成GB2312字符
} catch ( UnsupportedEncodingException e ) {
e . printStackTrace ();
}
return data ;
}
988
/**
989
* @param action MOM 行为
990
991
992
* @param JObject 行为参数
* @return
*/
993
public ReturnInfo postMOM ( String action , JSONObject JObject , String apiName ) {
994
String url = addressService . selectAddress ( QuantityConstant . MOM );
995
return CallaMOM . getMsg ( action , JObject , apiName , url );
996
}
997
998
易文鹏
authored
12 months ago
999
1000
1001
1002
1003
1004
1005
1006
/**
* 蓝牙打印入库物料明细
*/
//@RequiresPermissions("receipt:receiptDetail:printList")
//@Log(title = "入库-入库单明细管理", operating = "查看入库单明细", action = BusinessType.GRANT)
@PostMapping ( "/receipt/printList" )
//@ApiLogger(apiName = "蓝牙打印入库物料明细", from = "PDA")
@ResponseBody
易文鹏
authored
10 months ago
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
public AjaxResult receiptPrintList ( @RequestBody ReceiptPrint receiptPrint ) {
if ( receiptPrint == null ) {
return AjaxResult . error ( "参数为空" );
}
String code = receiptPrint . getCode ();
String sn = receiptPrint . getSn ();
if ( StringUtils . isEmpty ( code ) && StringUtils . isEmpty ( sn )) {
return AjaxResult . error ( "条码和入库单号不能同时为空" );
}
if ( StringUtils . isNotEmpty ( code ) && StringUtils . isNotEmpty ( sn )) {
return AjaxResult . error ( "条码和入库单号不能同时有值" + ",条码:" + sn + ",入库单号:" + code );
}
if ( StringUtils . isNotEmpty ( code )) {
List < ReceiptDetail > receiptDetails = receiptDetailService . list ( new LambdaQueryWrapper < ReceiptDetail >(). eq ( ReceiptDetail: : getReceiptCode , code ));
if (! receiptDetails . isEmpty ()) {
for ( ReceiptDetail receiptDetail : receiptDetails ) {
ReceiptHeader receiptHeader = receiptHeaderService . getById ( receiptDetail . getReceiptId ());
receiptDetail . setWarehouse ( receiptHeader . getWarehouse ());
receiptDetail . setWarehouseName ( receiptHeader . getWarehouseName ());
}
return AjaxResult . success ( receiptDetails );
}
}
if ( StringUtils . isNotEmpty ( sn )) {
ReceiptDetail snReceiptDetail = receiptDetailService . getOne ( new LambdaQueryWrapper < ReceiptDetail >(). eq ( ReceiptDetail: : getSNNO , sn ));
if ( snReceiptDetail != null ) {
List < ReceiptDetail > receiptDetails = receiptDetailService . list ( new LambdaQueryWrapper < ReceiptDetail >(). eq ( ReceiptDetail: : getReceiptCode , snReceiptDetail . getReceiptCode ()));
if (! receiptDetails . isEmpty ()) {
for ( ReceiptDetail receiptDetail : receiptDetails ) {
ReceiptHeader receiptHeader = receiptHeaderService . getById ( receiptDetail . getReceiptId ());
receiptDetail . setWarehouse ( receiptHeader . getWarehouse ());
receiptDetail . setWarehouseName ( receiptHeader . getWarehouseName ());
}
return AjaxResult . success ( receiptDetails );
}
}
易文鹏
authored
12 months ago
1048
}
易文鹏
authored
10 months ago
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
if ( StringUtils . isNotEmpty ( code )) {
List < ReceiptDetailHistory > receiptDetails = receiptDetailHistoryService . list ( new LambdaQueryWrapper < ReceiptDetailHistory >(). eq ( ReceiptDetailHistory: : getReceiptCode , code ));
if (! receiptDetails . isEmpty ()) {
for ( ReceiptDetailHistory receiptDetail : receiptDetails ) {
ReceiptHeaderHistory receiptHeader = receiptHeaderHistoryService . getById ( receiptDetail . getReceiptId ());
receiptDetail . setWarehouse ( receiptHeader . getWarehouse ());
receiptDetail . setWarehouseName ( receiptHeader . getWarehouseName ());
}
return AjaxResult . success ( receiptDetails );
}
易文鹏
authored
10 months ago
1061
}
易文鹏
authored
10 months ago
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
if ( StringUtils . isNotEmpty ( sn )) {
ReceiptDetailHistory snReceiptDetail = receiptDetailHistoryService . getOne ( new LambdaQueryWrapper < ReceiptDetailHistory >(). eq ( ReceiptDetailHistory: : getSNNO , sn ));
if ( snReceiptDetail != null ) {
List < ReceiptDetailHistory > receiptDetails = receiptDetailHistoryService . list ( new LambdaQueryWrapper < ReceiptDetailHistory >(). eq ( ReceiptDetailHistory: : getReceiptCode , snReceiptDetail . getReceiptCode ()));
if (! receiptDetails . isEmpty ()) {
for ( ReceiptDetailHistory receiptDetail : receiptDetails ) {
ReceiptHeader receiptHeader = receiptHeaderService . getById ( receiptDetail . getReceiptId ());
receiptDetail . setWarehouse ( receiptHeader . getWarehouse ());
receiptDetail . setWarehouseName ( receiptHeader . getWarehouseName ());
}
return AjaxResult . success ( receiptDetails );
}
}
易文鹏
authored
12 months ago
1077
}
易文鹏
authored
10 months ago
1078
1079
return AjaxResult . error ( "没有查询到数据" );
易文鹏
authored
12 months ago
1080
1081
1082
1083
1084
1085
1086
1087
1088
}
/**
* 蓝牙打印出库物料明细
*/
@PostMapping ( "/shipment/printList" )
@ResponseBody
public AjaxResult shipmentPrintList ( String code ) {
易文鹏
authored
10 months ago
1089
1090
1091
if ( StringUtils . isEmpty ( code )) {
return AjaxResult . error ( "code为空" );
}
易文鹏
authored
12 months ago
1092
List < ShipmentDetail > list = shipmentDetailService . list ( new LambdaQueryWrapper < ShipmentDetail >(). eq ( ShipmentDetail: : getShipmentCode , code ));
易文鹏
authored
10 months ago
1093
1094
1095
1096
1097
1098
1099
if (! list . isEmpty ()) {
for ( ShipmentDetail shipmentDetail : list ) {
ShipmentHeader shipmentHeader = shipmentHeaderService . getById ( shipmentDetail . getShipmentId ());
shipmentDetail . setWarehouse ( shipmentHeader . getWarehouse ());
shipmentDetail . setWarehouseName ( shipmentHeader . getWarehouseName ());
}
return AjaxResult . success ( list );
易文鹏
authored
12 months ago
1100
}
易文鹏
authored
10 months ago
1101
1102
1103
1104
1105
1106
1107
1108
1109
List < ShipmentDetailHistory > list2 = shipmentDetailHistoryService . list ( new LambdaQueryWrapper < ShipmentDetailHistory >(). eq ( ShipmentDetailHistory: : getShipmentCode , code ));
if (! list2 . isEmpty ()) {
for ( ShipmentDetailHistory shipmentDetail : list2 ) {
ShipmentHeaderHistory shipmentHeader = shipmentHeaderHistoryService . getById ( shipmentDetail . getShipmentId ());
shipmentDetail . setWarehouse ( shipmentHeader . getWarehouse ());
shipmentDetail . setWarehouseName ( shipmentHeader . getWarehouseName ());
}
return AjaxResult . success ( list );
易文鹏
authored
11 months ago
1110
}
易文鹏
authored
10 months ago
1111
return AjaxResult . error ( "没有查询到数据" );
易文鹏
authored
12 months ago
1112
1113
}
1114
}