ErpGenerateBill.java
1.73 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
package com.huaheng.api.general.domain;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import com.huaheng.pc.receipt.receiptDetail.domain.ReceiptDetail;
import com.huaheng.pc.receipt.receiptHeader.domain.ReceiptHeader;
import lombok.Data;
import org.apache.commons.lang.StringEscapeUtils;
import java.util.ArrayList;
import java.util.List;
@Data
public class ErpGenerateBill {
/**ERP单据类型**/
@JSONField(name = "ErpBillType")
String ErpBillType;
/**仓库编号**/
@JSONField(name = "StockCode")
String StockCode;
/**单据单别**/
@JSONField(name = "BillType")
String BillType;
@JSONField(name = "GenBillDetails")
List<ErpGenBillDetail> GenBillDetails;
public static ErpGenerateBill transformate(ReceiptHeader header, List<ReceiptDetail> list){
ErpGenerateBill bill = new ErpGenerateBill();
bill.setErpBillType(header.getReceiptType());
bill.setBillType(header.getBillType());
bill.setStockCode(header.getWarehouseCode());
List<ErpGenBillDetail> bills = new ArrayList<>();
for(ReceiptDetail d: list){
ErpGenBillDetail b = new ErpGenBillDetail();
b.setBarcode(d.getBarCode());
b.setQuantity(d.getQty());
bills.add(b);
}
bill.setGenBillDetails(bills);
return bill;
}
public static ErpGenerateBill parse(String msg){
String json = StringEscapeUtils.unescapeJava(msg);
ErpGenerateBill obj = JSON.parseObject(json, ErpGenerateBill.class);
return obj;
}
public String toRawJsonStr(){
String s = JSON.toJSONString(this);
// System.out.println(StringEscapeUtils.escapeJava(s));
return s;
}
}