QisdaApi.java
31.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
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
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
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
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
473
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
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
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
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
package com.myproject.util;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import com.myproject.bean.qisda.AppendInfo;
import com.myproject.bean.qisda.DiffInfo;
import com.myproject.bean.qisda.QisdaApiRequest;
import com.myproject.bean.update.Barcode;
import com.myproject.bean.update.DataLog;
import com.myproject.bean.update.qisda.DNInfo;
import com.myproject.bean.update.qisda.DNItem;
import com.myproject.bean.update.qisda.OutItem;
import com.myproject.exception.ApiException;
import com.myproject.exception.ValidateException;
import com.myproject.webapp.controller.webService.QisdaCache;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* Created by sunke on 2020/4/14.
*/
public class QisdaApi {
protected final static Logger log = LogManager.getLogger(QisdaApi.class);
private static String USER_NAME = "SMD-BOX";
private static ExecutorService threadPool = Executors.newCachedThreadPool();
/**
* CIS收料入库接口
*/
public static void VMIMateriaReceive(final Barcode barcode, final DataLog task){
threadPool.execute(new Runnable() {
@Override
public void run() {
VMIMateriaReceiveThread(barcode, task);
}
});
}
/**
* 纯入库操作完成时通知Qisda
*/
public static void VMILocationIn(final String reelID, final String location, final String fullCodeStr){
threadPool.execute(new Runnable() {
@Override
public void run() {
VMILocationInThread(reelID, location, fullCodeStr);
}
});
}
/**
* 出仓完成时通知(线程)
* @param materialInfoMap
*/
public static void VMILocationOut(final String reelId, final Map<String, Object> materialInfoMap){
threadPool.execute(new Runnable() {
@Override
public void run() {
VMILocationOutThread(reelId, materialInfoMap);
}
});
}
/**
* 物料放上小车时调用(线程)
* @param task 任务信息
* @param barcode 条码信息
* @param latest 本次工单第几盘料(F 第一次,L 最后一次, M 中间)
*/
public static void VMIMateriaRecAss(final DataLog task, final Barcode barcode, final String latest){
threadPool.execute(new Runnable() {
@Override
public void run() {
VMIMateriaRecAssThread(task, barcode, latest);
}
});
}
/**
* 获取库存进行比对
*/
public static Map<String,DiffInfo> getInventory(String area) throws ApiException {
String url = "http://10.85.17.233/ESMTCommonInterface/CommonService.asmx/VMIStcok";
Map<String,Object> paramMap = new HashMap<String,Object>();
paramMap.put("area",area);
Map<String,DiffInfo> diffInfoMap = new HashMap<>();
String result = HttpHelper.postParam(url,paramMap);
log.debug("Qisda获取库存信息进行比对返回:" + result);
Map<String, Object> resultMap = JsonUtil.toMap(result);
String code = resultMap.get("code").toString();
if(code.equals("200")){
List<Map<String,Object>> data = (List<Map<String, Object>>) resultMap.get("data");
for (Map<String, Object> itemMap : data) {
DiffInfo diffInfo = new DiffInfo();
String partno = itemMap.get("partno").toString();
String facility = itemMap.get("facility").toString();
String location = itemMap.get("location").toString();
String reelid = itemMap.get("reelid").toString();
String qty = itemMap.get("qty").toString();
diffInfo.setPn(partno);
diffInfo.setReelId(reelid);
diffInfo.setLocation(location);
diffInfo.setQty(qty);
diffInfo.setFacility(facility);
diffInfoMap.put(reelid,diffInfo);
}
}else{
String errorMsg = " Qisda获取库存信息进行比对转换出错:" + resultMap.get("msg");
log.info(errorMsg);
throw new ApiException(errorMsg);
}
return diffInfoMap;
}
/**
*
* 缺料反馈接口 (出完工单时调用),绑定首盘不管是否缺料都调用,其他类型的只在所有出库完成时调用一次
*
* 只有首盘会反馈多次缺料信息,若首盘反馈第一次缺料后,料自动匹配齐了,第二次反馈时料号传N/A
*
* @param outItemList
* @param lessBind 是否是绑定缺料反馈
*/
public static void VMILocationOutFeedback(List<OutItem> outItemList, boolean lessBind){
String url = "http://10.85.17.233/ESMTCommonInterface/CommonService.asmx/VMILocationOutFeedback";
List<Map<String,Object>> materialInfoList = new ArrayList<>();
for (OutItem outItem : outItemList) {
Map<String,Object> materialInfoMap = new HashMap<String,Object>();
materialInfoMap.put("so",outItem.getSo());//DN单号或者是厂别
materialInfoMap.put("partNum",outItem.getPn());//料号
int lossqty = outItem.outLessQty();
if(lessBind){
//绑定缺料反馈
lossqty = outItem.preBindLessQty();
}
if(lossqty > 0){
materialInfoMap.put("lossqty",lossqty + "");//缺料数量
materialInfoMap.put("slot",outItem.getSlotStr());//料站
materialInfoMap.put("serial",outItem.gethSerial());//需求单号
materialInfoList.add(materialInfoMap);
}
}
if(materialInfoList.isEmpty()){
log.info("需求单不缺料,不进行缺料反馈");
}else{
String lackOfMaterial = JsonUtil.toJsonStr(materialInfoList);
Map<String,Object> paramMap = new HashMap<String,Object>();
paramMap.put("lackOfMaterial",lackOfMaterial);
log.info("缺料反馈接口(VMILocationOutFeedback)参数lackOfMaterial="+lackOfMaterial);
try {
String result = HttpHelper.postParam(url,paramMap);
log.info("收到缺料反馈接口(VMILocationOutFeedback)返回:" + result);
} catch (ApiException e) {
log.error("缺料反馈接口(VMILocationOutFeedback)接口出错",e);
}
}
}
/**
* 获取DN单详情
* @param dnNo
* @param isCheck
* @return
* @throws ApiException
*/
public static List<DNItem> GetDNDetails(String dnNo, boolean isCheck) throws ApiException {
String url = "http://10.85.17.43:8080/WMSWeb.asmx/GetDNDetailsJson";
Map<String,Object> paramMap = new HashMap<String,Object>();
//paramMap.put("DHNO","DNMISW1911197845");
paramMap.put("DHNO",dnNo);
String isCheckStr = "N";
if(isCheck){
isCheckStr = "Y";
}
paramMap.put("ISCheck",isCheckStr);
paramMap.put("isBack","Y");
String errorMsg = "";
Map<String,DNItem> itemMap = new HashMap<>();
try {
String returnResult = HttpHelper.postParam(url,paramMap);
log.info("获取DN单详情结果:" + returnResult);
String resultStr = XmlUtil.getNodeBody("string", returnResult);
if(resultStr.startsWith("[")){
List<Map<String,Object>> items = JsonUtil.toObj(resultStr, List.class);
for (Map<String,Object> map : items) {
DNItem item = new DNItem();
String no = map.get("DLNO").toString();
item.setDnNo(no);
String dnDateStr = map.get("DLCRDTE").toString()+ " " + map.get("DLCRTIME").toString();
item.setDnDateStr(dnDateStr);
int dnQty = Float.valueOf(map.get("WACTQTY").toString()).intValue();
item.setDnQty(dnQty);
String facility = map.get("WPORD").toString();
item.setFacility(facility);
String company = map.get("DSN").toString();
item.setCompany(company);
String pn = map.get("WPROD").toString();
item.setPn(pn);
DNItem dnItem = itemMap.get(pn);
if(dnItem != null){
int totalDNQty = dnItem.getDnQty() + item.getDnQty();
log.info("PN["+pn+"]有重复,合并数量[" + dnItem.getDnQty() +" + " + item.getDnQty() + " = " + totalDNQty);
dnItem.setDnQty(totalDNQty);
}else{
dnItem = item;
}
itemMap.put(pn, dnItem);
}
}else{
//返回错训误了
errorMsg = resultStr;
}
} catch (Exception e) {
errorMsg = e.getMessage();
log.error("获取DN单详情接口出错",e);
}
if(!Strings.isNullOrEmpty(errorMsg)){
throw new ApiException(errorMsg);
}
List<DNItem> dnItems = Lists.newArrayList();
if(!itemMap.isEmpty()){
dnItems.addAll(itemMap.values());
}
return dnItems;
}
/**
* 6. CIS收料判定接口(绑过料串的条码扫码入库时判断)
*/
public static void VMIMateriaReceiveJudge(DNInfo dnInfo, Barcode barcode) throws ValidateException {
String url = "http://10.85.17.233/ESMTCommonInterface/CommonService.asmx/VMIMateriaReceiveJudge";
Map<String,Object> materialInfoMap = new HashMap<String,Object>();
String dnOrFacility = dnInfo.getDnNo();
if(dnInfo.isFacilityIn()){
dnOrFacility = dnInfo.getFacility();
}
materialInfoMap.put("dnOrFacility",dnOrFacility);//DN单号或者是厂别
materialInfoMap.put("reelID",barcode.getBarcode());//料卷ID
materialInfoMap.put("partNum",barcode.getPartNumber());//料号
materialInfoMap.put("qty",barcode.getAmount());//数量
materialInfoMap.put("lifeCycle",barcode.getLifeCycle());//生命周期
String productCode = DateUtil.toDateString(barcode.getProduceDate(),"yyyyMMdd");
materialInfoMap.put("productCode",productCode);//生产日期
materialInfoMap.put("lot", barcode.getBatch());//生产批次(批次号)
materialInfoMap.put("vendor",barcode.getProvider());//供应商
materialInfoMap.put("location","");//location
materialInfoMap.put("qrCodeInfo",barcode.getFullCodeStr());//完整的二维码信息
String materialInfo = JsonUtil.toJsonStr(materialInfoMap);
Map<String,Object> paramMap = new HashMap<String,Object>();
paramMap.put("materialInfo",materialInfo);
log.info("DN单Facility收料判断参数:materialInfo=" + materialInfo);
try {
String result = HttpHelper.postParam(url,paramMap);
log.info("DN单Facility收料("+barcode.getBarcode()+")判定接口返回:" + result);
String resultStr = XmlUtil.getNodeBody("string", result);
//0+提示信息/1/-1 0为NG,1为OK,-1为系统内部异常
if(resultStr.startsWith("1")){
log.info(barcode.getBarcode() + " ["+dnOrFacility+"]收料判定: OK");
}else{
log.info(barcode.getBarcode() + " ["+dnOrFacility+"]收料判定: NG" + resultStr);
if(resultStr.startsWith("0")){
throw new ValidateException(" ["+dnOrFacility+"]收料判定NG:" + resultStr);
}else{
throw new ValidateException(" ["+dnOrFacility+"]收料判定NG:" + resultStr);
}
}
} catch (ApiException e) {
log.error(" ["+dnOrFacility+"]收料判定接口",e);
throw new ValidateException(" ["+dnOrFacility+"]收料接口处理异常:" + e.getMessage());
}
}
/**
* 3. CIS入库判定接口 (没绑过料串的条码调用此接口)
*/
public static Barcode VMILocationInCheck(Barcode barcode) throws ValidateException{
String url = "http://10.85.17.233/ESMTCommonInterface/CommonService.asmx/VMILocationInCheck";
String reelid = barcode.getBarcode();
String partNum = barcode.getPartNumber();
Map<String,Object> paramMap = new HashMap<String,Object>();
paramMap.put("reelid",reelid);
paramMap.put("partNum",partNum);
log.info("纯入库判断参数:reelid=" + reelid + " partNum=" + partNum);
try {
//0+提示信息/1+工单 0:为NG ;1:为OK 工单号码则表示该料卷被绑定在此工单上;-1为内部异常
String result = HttpHelper.postParam(url,paramMap);
//String result = "<?xml version=\"1.0\" encoding=\"utf-8\"?><string xmlns=\"http://tempuri.org/\">{\"state\":\"1\",\"msg\":\"入库判定OK\",\"info\":{\"so\":\"2388518\",\"facility\":\"ST\",\"company\":\"BACHS\",\"qty\":\"1\",\"soseq\":\"2092475\",\"slot\":\"5-4\"}}</string>";
log.info("收到("+reelid+")纯入库判定接口返回:" + result);
String resultStr = XmlUtil.getNodeBody("string", result);
//0+提示信息/1/-1 0为NG,1为OK,-1为系统内部异常
Map<String, Object> resultMap = JsonUtil.toMap(resultStr);
String state = resultMap.get("state").toString();
if(state.equals("1")){
log.info(reelid + " CIS入库判定: OK");
AppendInfo appendInfo = barcode.getAppendInfo();
Object infoObj = resultMap.get("info");
if(infoObj != null){
log.info("写入条码["+reelid+"]工单数量信息,并清空分盘数据");
Map infoMap = (Map)infoObj;
String so = infoMap.get("so").toString();
//有工单信息,需要绑定工单
String soseq = infoMap.get("soseq").toString();
String facility = infoMap.get("facility").toString();
String company = infoMap.get("company").toString();
String qty = infoMap.get("qty").toString();
String slot = infoMap.get("slot").toString();
Object slotlocation = infoMap.get("slotserial");
if(so.equals("0")){
so = null;
soseq = null;
slot = null;
}
appendInfo.setCutMap(null);
appendInfo.setSo(so);
appendInfo.setSoseq(soseq);
appendInfo.setSlotStr(slot);
if(slotlocation == null || slotlocation.equals("0")){
appendInfo.setBindSlot(null);
appendInfo.setPreBindSlot(null);
appendInfo.setSlotIndex(-1);
}else{
String location = slotlocation.toString();
log.info(reelid + "数量:"+ qty + "绑定工单"+ so + "["+location+"]");
appendInfo.setBindSlot(location);
appendInfo.setPreBindSlot(location);
try{
int slotIndex = Integer.valueOf(location);
appendInfo.setSlotIndex(slotIndex);
//TODO:需要重新绑定
}catch (Exception e){
log.error("纯入库判定出错",e);
}
}
appendInfo.setFacility(facility);
appendInfo.setCompany(company);
int amount = Integer.valueOf(qty);
barcode.setAmount(amount);
barcode.setInitialAmount(amount);
//绑定工单
// appendInfo.sethSerial(outItem.gethSerial());
// appendInfo.setRefno(outItem.getRefno());
// appendInfo.setSlotIndex(outItem.getSlotlocation());
// barcode.setAppendInfo(appendInfo);
// int realLockQty = outItem.getRealLockQty() + barcode.getAmount();
// outItem.setRealLockQty(realLockQty);
barcode.setAppendInfo(appendInfo);
}
}else{
log.info(reelid + " 纯入库判定: NG" + resultStr);
String ngMsg = resultMap.get("msg").toString();
throw new ValidateException("纯入库判定NG:["+state+"]" + ngMsg);
}
} catch (Exception e) {
log.error("纯入库判定接口出错"+e.getMessage());
throw new ValidateException("纯入库判定接口处理异常:" + e.getMessage());
}
return barcode;
}
/**
* 纯入库操作完成时通知Qisda
*/
public static void VMILocationInThread(String reelID, String location,String fullCodeStr){
String url = "http://10.85.17.233/ESMTCommonInterface/CommonService.asmx/VMILocationIn";
Map<String,Object> paramMap = new HashMap<String,Object>();
paramMap.put("reelID",reelID);
paramMap.put("location",location);
paramMap.put("userName",USER_NAME);
paramMap.put("code",fullCodeStr);
log.info("纯入库操作完成时通知Qisda接口(VMILocationIn):reelID=" + reelID + "&location="+location +"&code=" + fullCodeStr);
QisdaApiRequest apiRequest = new QisdaApiRequest("纯入库",paramMap,reelID,url);
try {
String result = HttpHelper.postParam(url,paramMap);
log.info(reelID + "纯入库操作完成时通知Qisda接口(VMILocationIn)返回:" + result);
String resultStr = XmlUtil.getNodeBody("string", result);
if(resultStr.startsWith("-1") || resultStr.startsWith("0")){
log.info(reelID + "Qisda接口调用失败,需要进行重发");
}else{
QisdaCache.removeFailedRequest(apiRequest);
return;
}
} catch (Exception e) {
log.error(reelID + "纯入库操作完成时通知Qisda接口(VMILocationIn)出错",e);
}
QisdaCache.addFailedRequest(apiRequest);
}
/**
* CIS收料入库接口
*/
public static void VMIMateriaReceiveThread(Barcode barcode, DataLog task){
String url = "http://10.85.17.233/ESMTCommonInterface/CommonService.asmx/VMIMateriaReceive";
Map<String,Object> materialInfoMap = new HashMap<String,Object>();
materialInfoMap.put("dnOrFacility",barcode.getAppendInfo().getDnOrFacility());//DN单号或者是厂别
materialInfoMap.put("reelID",barcode.getBarcode());//料卷ID
materialInfoMap.put("partNum",barcode.getPartNumber());//料号
materialInfoMap.put("qty",barcode.getInitialAmount() + "");//数量
materialInfoMap.put("lifeCycle",barcode.getLifeCycle());//生命周期
String productCode = DateUtil.toDateString(barcode.getProduceDate(),"yyyyMMdd");
materialInfoMap.put("productCode",productCode);//生产日期
materialInfoMap.put("lot", barcode.getBatch());//生产批次(批次号)
materialInfoMap.put("vendor",barcode.getProvider());//供应商
materialInfoMap.put("location",task.getPosName());//location
materialInfoMap.put("qrCodeInfo",barcode.getFullCodeStr());//完整的二维码信息
materialInfoMap.put("reelType","0");//料卷类型
String materialInfo = JsonUtil.toJsonStr(materialInfoMap);
//materialInfo = "{\"dnOrFacility\":\"DNMIST1901002587\",\"reelID\":\"R000002014042300013\",\"reelType\":\"0\",\"partNum\":\"6H.15010.204\",\"qty\":\"3\",\"lifeCycle\":\"240\",\"productCode\":\"20191102\",\"lot\":\"L00000000IA9617JL1D81\",\"vendor\":\"82012\",\"location\":\"1-1\",\"qrCodeInfo\":\"L00000000IA9617JL1D81;E20190101 0730;B8C.00501.010503562019010103000;R000002014042300013\"}";
Map<String,Object> paramMap = new HashMap<String,Object>();
paramMap.put("materialInfo",materialInfo);
paramMap.put("userName",USER_NAME);
log.info("DN单收料或Facility收料通知Qisda接口(VMIMateriaReceive):" + materialInfo);
QisdaApiRequest apiRequest = new QisdaApiRequest("收料入库",paramMap,barcode.getBarcode(),url);
try {
String result = HttpHelper.postParam(url,paramMap);
log.info("DN单收料或Facility收料["+barcode.getBarcode()+"]接口返回:" + result);
String resultStr = XmlUtil.getNodeBody("string", result);
if(resultStr.startsWith("-1") || resultStr.startsWith("0")){
log.info(barcode.getBarcode() + "Qisda接口调用失败,需要进行重发");
}else{
QisdaCache.removeFailedRequest(apiRequest);
return;
}
} catch (Exception e) {
log.error("DN单收料或Facility收料接口出错",e);
}
QisdaCache.addFailedRequest(apiRequest);
}
/**
* 出仓完成时通知
* @param materialInfoMap
*/
private static void VMILocationOutThread(String reelId, Map<String, Object> materialInfoMap){
String url = "http://10.85.17.233/ESMTCommonInterface/CommonService.asmx/VMILocationOut";
String materialInfo = JsonUtil.toJsonStr(materialInfoMap);
Map<String,Object> paramMap = new HashMap<String,Object>();
paramMap.put("materialInfo",materialInfo);
paramMap.put("userName",USER_NAME);
log.info("出仓完成时通知Qisda:materialInfo=" + materialInfo);
QisdaApiRequest apiRequest = new QisdaApiRequest("出仓",paramMap,reelId,url);
try {
String result = HttpHelper.postParam(url,paramMap);
log.info(reelId + "出仓完成时通知Qisda(VMILocationOut)返回:" + result);
String resultStr = XmlUtil.getNodeBody("string", result);
if(resultStr.startsWith("-1") || resultStr.startsWith("0")){
log.info(reelId + "Qisda接口调用失败,需要进行重发");
}else{
QisdaCache.removeFailedRequest(apiRequest);
return;
}
} catch (Exception e) {
log.error("出仓完成时通知Qisda(VMILocationOut)接口出错",e);
}
QisdaCache.addFailedRequest(apiRequest);
}
/**
* 物料放上小车时调用
* @param task 任务信息
* @param barcode 条码信息
* @param latest 本次工单第几盘料(F 第一次,L 最后一次, M 中间)
*/
private static void VMIMateriaRecAssThread(DataLog task, Barcode barcode, String latest){
String url = "http://10.85.17.233/ESMTCommonInterface/CommonService.asmx/VMIMateriaRecAss";
Map<String,Object> materialInfoMap = new HashMap<String,Object>();
AppendInfo appendInfo = task.getAppendInfo();
materialInfoMap.put("action",appendInfo.getAction());
materialInfoMap.put("facility",appendInfo.getFacility());
materialInfoMap.put("so",appendInfo.getSo());
materialInfoMap.put("partNum",task.getPartNumber());
materialInfoMap.put("reelID",task.getBarcode());
materialInfoMap.put("slot", appendInfo.getSlotStr());
materialInfoMap.put("slotserial", appendInfo.getSlotIndex());
materialInfoMap.put("qty",task.getNum() +"");
materialInfoMap.put("latest",latest);//本次工单第几盘料(F 第一次,L 最后一次, M 中间, E是错误)
materialInfoMap.put("cloudLocation",task.getPosName());//云料仓的库位
materialInfoMap.put("location","");//料架库位
String rfid = appendInfo.getRfid();
if(task.isLessSendReel()){
rfid = "B";
}
if(latest.equals("E")){
//错误状态不发料车编号
rfid = "";
}
materialInfoMap.put("vehicleID",rfid);//料车编号
int rfidLoc = appendInfo.getRfidLoc();
rfidLoc = task.resolveRfidLoc(rfidLoc + "");
materialInfoMap.put("vehicleLocation",rfidLoc);//料车架位号
materialInfoMap.put("lot", barcode.getBatch());//生产批次(批次号)
String productCode = DateUtil.toDateString(barcode.getProduceDate(),"yyyyMMdd");
materialInfoMap.put("productCode",productCode);//生产日期
materialInfoMap.put("vendorCode",barcode.getProvider());//供应商
materialInfoMap.put("hSerial",appendInfo.gethSerial());
materialInfoMap.put("flag", "");//子盘或母盘(L:子盘,M:母盘,其他'')
String idte = DateUtil.toDateString(task.getUpdateDate(), "yyyyMMdd");
String idme = DateUtil.toDateString(task.getUpdateDate(), "HHmmss");
materialInfoMap.put("idte",idte);//发料日期
materialInfoMap.put("itme",idme);//发料时间
materialInfoMap.put("soseq",appendInfo.getSoseq());//工单序号
String materialInfo = JsonUtil.toJsonStr(materialInfoMap);
Map<String,Object> paramMap = new HashMap<String,Object>();
paramMap.put("materialInfo",materialInfo);
paramMap.put("userName",USER_NAME);
log.info("物料放上小车时通知Qisda:materialInfo=" + materialInfo);
QisdaApiRequest apiRequest = new QisdaApiRequest("发料",paramMap,task.getBarcode(),url);
try {
String result = HttpHelper.postParam(url,paramMap);
log.info(task.getBarcode() + "物料放上小车时通知Qisda(VMIMateriaRecAss)返回:" + result);
String resultStr = XmlUtil.getNodeBody("string", result);
if(resultStr.startsWith("-1") || resultStr.startsWith("0")){
log.info(task.getBarcode() + "Qisda接口调用失败,需要进行重发");
}else{
QisdaCache.removeFailedRequest(apiRequest);
return;
}
} catch (Exception e) {
log.error(task.getBarcode() + "物料放上小车时通知Qisda(VMIMateriaRecAss)接口出错",e);
}
QisdaCache.addFailedRequest(apiRequest);
}
/**
* 移远料号转换
*/
public static String PartNoMapping(String vdPartNum) throws ApiException{
String url = "http://10.85.17.233/ESMTCommonInterface/CommonService.asmx/PartNoMapping";
Map<String,Object> paramMap = new HashMap<String,Object>();
paramMap.put("vdPartNum",vdPartNum);
log.info("从Qisda获取料号转换:vdPartNum=" + vdPartNum);
String result = HttpHelper.postParam(url,paramMap);
log.info("从Qisda获取料号转换:(PartNoMapping)返回:" + result);
Map<String, Object> resultMap = JsonUtil.toMap(result);
String msg = resultMap.get("msg").toString();
if(msg.startsWith("0")){
String errorMsg = "从Qisda获取料号["+vdPartNum+"]转换NG:" + msg;
log.info(errorMsg);
throw new ApiException(errorMsg);
}
return msg;
}
/**
* 获取物料尺寸
* @param partNum
* @param vendorCode
* @return
*/
public static PLATE_SIZE PartNoRule(String partNum, String vendorCode){
String url = "http://10.85.17.233/ESMTCommonInterface/CommonService.asmx/PartNoRule";
Map<String,Object> paramMap = new HashMap<String,Object>();
paramMap.put("partNum",partNum);
paramMap.put("vendorCode",vendorCode);
try {
String result = HttpHelper.postParam(url,paramMap);
log.info("从Qisda获取料号"+partNum+"["+vendorCode+"]尺寸(PartNoRule)返回:" + result);
Map<String, Object> resultMap = JsonUtil.toMap(result);
String code = resultMap.get("code").toString();
if(code.equals("200")){
List<Map<String,Object>> data = (List<Map<String, Object>>) resultMap.get("data");
for (Map<String, Object> itemMap : data) {
String w = itemMap.get("specifications").toString();
String h = itemMap.get("widthSize").toString();
return new PLATE_SIZE(Integer.valueOf(w),Integer.valueOf(h));
}
}
} catch (ApiException e) {
log.error("从Qisda获取料号["+partNum+"["+vendorCode+"]尺寸(PartNoRule)接口出错",e);
}
return null;
}
/**
* 清理Qisda库存
*/
public static void ClearStockBy(String posName){
String url = "http://10.85.17.233/ESMTCommonInterface/CommonService.asmx/ClearStockBy";
Map<String,Object> paramMap = new HashMap<String,Object>();
paramMap.put("location",posName);
paramMap.put("userName",USER_NAME);
log.info("清理Qisda库存(ClearStockBy):posName=" + posName);
try {
String result = HttpHelper.postParam(url,paramMap);
log.info("清理Qisda库存["+posName+"](ClearStockBy)返回:" + result);
return;
} catch (Exception e) {
log.error("清理Qisda库存["+posName+"](ClearStockBy)接口出错",e);
}
}
/**
* 检查工单料架是否解绑 [{"data":[{"Serial":"58890","VehicleID":"D15","Status":""},{"Serial":"58890","VehicleID":"D44","Status":""},{"Serial":"58890","VehicleID":"D83","Status":""},{"Serial":"58890","VehicleID":"D90","Status":""},{"Serial":"58890","VehicleID":"D98","Status":""}]}]
*/
public static String GetSerialData(String line, String hserial){
String url = "http://10.85.17.233/ESMTCommonInterface/CommonService.asmx/GetSerialData";
Map<String,Object> paramMap = new HashMap<String,Object>();
paramMap.put("line",line);
paramMap.put("hserial",hserial);
try {
String result = HttpHelper.postParam(url,paramMap);
log.debug("从Qisda检查工单料架是否解绑["+line+"](GetSerialData)返回:" + result);
if(result.contains("VehicleID")){
return result;
}
if(result.toLowerCase().contains("wait")){
return result;
}
return "";
} catch (Exception e) {
log.error("从Qisda检查工单料架是否解绑"+hserial+"["+line+"])接口(GetSerialData)出错",e);
return "检查出错:" + e.getMessage();
}
}
/**
* 将最后一个补料需求单的状态更新为不是最后一个需求单
* @param soseq
* @return
*/
public static String UpdateBatchRefillMark(String soseq){
String url = "http://10.85.17.233/ESMTCommonInterface/CommonService.asmx/UpdateBatchRefillMark";
Map<String,Object> paramMap = new HashMap<String,Object>();
paramMap.put("soseq",soseq);
try {
String result = HttpHelper.postParam(url,paramMap);
log.info("更新Qisda工单序号["+soseq+"]的最后一个需求单状态为非最后一个需求单(UpdateBatchRefillMark)返回:" + result);
return "";
} catch (Exception e) {
log.error("更新Qisda工单序号["+soseq+"]的最后一个需求单状态为非最后一个需求单(UpdateBatchRefillMark)出错",e);
return "工单序号最后一个需求单状态更新出错:" + e.getMessage();
}
}
}