EDI报文及相对的java对象
时间: 2023-12-06 13:44:32 浏览: 68
EDI(Electronic Data Interchange)报文是一种基于ASCII字符集的电子数据交换标准格式。在Java中,我们可以使用EDI解析器库来处理EDI报文。常见的EDI解析器库包括Smooks和jPOS。
在解析EDI报文时,我们可以将其转换成Java对象来方便地进行后续处理。这里给出一个示例:
假设我们有以下EDI报文:
```EDI
ISA*00* *00* *12*3456789012 *08*9876543210 *200101*1200*U*00401*000000001*0*T*:~
GS*PO*4405197800*9876543210*20010101*1319*1*X*004010~
ST*850*0001~
BEG*00*SA*08292233294**20010101~
N1*BY*ABC COMPANY~
N1*SE*DEF COMPANY~
PO1*1*10*EA*19.95*UK*1234567890*VP*ABC123~
CTT*1~
SE*7*0001~
GE*1*1~
IEA*1*000000001~
```
我们可以定义以下Java对象来表示这些数据:
```
public class EDI {
private ISA isa;
private GS gs;
private List<ST> sts;
// getters and setters
}
public class ISA {
private String authorizationInformationQualifier;
private String authorizationInformation;
private String securityInformationQualifier;
private String securityInformation;
private String senderIDQualifier;
private String senderID;
private String receiverIDQualifier;
private String receiverID;
private String date;
private String time;
private String interchangeControlStandardsIdentifier;
private String interchangeControlVersionNumber;
private String interchangeControlNumber;
private String acknowledgementRequested;
private String usageIndicator;
private String componentElementSeparator;
// getters and setters
}
public class GS {
private String functionalIdentifierCode;
private String senderID;
private String receiverID;
private String date;
private String time;
private String groupControlNumber;
private String transactionTypeCode;
private String versionNumber;
// getters and setters
}
public class ST {
private String transactionSetIdentifierCode;
private String transactionSetControlNumber;
private String implementationConventionReference;
// getters and setters
}
public class BEG {
private String transactionSetPurposeCode;
private String purchaseOrderTypeCode;
private String purchaseOrderNumber;
private String releaseNumber;
private String date;
private String contractNumber;
// getters and setters
}
public class N1 {
private String entityIdentifierCode;
private String name;
// getters and setters
}
public class PO1 {
private String lineNumber;
private String quantityOrdered;
private String unitOfMeasure;
private String unitPrice;
private String basisOfUnitPrice;
private String productIDQualifier;
private String productID;
private String vendorPartNumber;
// getters and setters
}
public class CTT {
private String numberOfLineItems;
// getters and setters
}
```
然后我们可以使用Smooks或jPOS等EDI解析器库将EDI报文解析成这些Java对象。
阅读全文