package msg
|
|
|
|
import (
|
|
"leit.com/leit_seat_aps/common"
|
|
"leit.com/leit_seat_aps/db"
|
|
"strconv"
|
|
"strings"
|
|
"time"
|
|
)
|
|
|
|
// 按发运车的不同PartFamily生成独立的ASN
|
|
type ASN_ARD_PF struct {
|
|
Pfid string
|
|
DataList []db.VCustorderPackorder
|
|
}
|
|
|
|
type ASN_UNB struct {
|
|
Field1 string
|
|
Field2 string
|
|
Field3 string
|
|
Field4 string
|
|
Field5 string
|
|
}
|
|
|
|
type ASN_UNH struct {
|
|
Field1 string
|
|
Field2 string
|
|
}
|
|
|
|
type ASN_MID struct {
|
|
Field1 string // ASN号
|
|
Field2 string // 日期 YYMMDD:hhmm
|
|
}
|
|
|
|
type ASN_CDT struct {
|
|
Field1 string // Supplier Code
|
|
}
|
|
|
|
type ASN_CSG struct {
|
|
Field1 string // Consignee (BBA delivery address code)
|
|
}
|
|
|
|
type ASN_DTR struct {
|
|
Field1 string // Vehicle registration
|
|
Field2 string // 不是必须
|
|
Field3 string // Carrier Code = ZZZ
|
|
Field4 string // 开票号 Invoice number
|
|
Field5 string // 不是必须
|
|
Field6 string // 预计到达时间 YYMMDDhhmm
|
|
Field7 string // 不是必须
|
|
Field8 string // 不是必须
|
|
Field9 string // Despatch date and time
|
|
}
|
|
|
|
// 示例 ARD+::MIKKBR4:MIKFLG4 :4076174:6707067+0+00000000000000000'
|
|
type ASN_ARD struct {
|
|
Field1 string // :: Parts Family : Supply Group (optional) : Call Off Number : EINSTEIN Order Number
|
|
Field2 string // 0 for order related deliveries
|
|
Field3 string // Package number 00000000000000000'
|
|
}
|
|
|
|
// Type of package + Type of package + number of package + Quantity of articles in package
|
|
// TCO+REUSABLE +9 +272 '
|
|
type ASN_TCO struct {
|
|
Field1 string // Type of package
|
|
Field2 string // number of package
|
|
Field3 string // Quantity of articles in package
|
|
}
|
|
|
|
type ASN_UNT struct {
|
|
Field1 string
|
|
Field2 string
|
|
}
|
|
|
|
type ASN_UNZ struct {
|
|
Field1 string
|
|
Field2 string
|
|
}
|
|
|
|
type ASN_EDI struct {
|
|
unb ASN_UNB
|
|
unh ASN_UNH
|
|
mid ASN_MID
|
|
cdt ASN_CDT
|
|
csg ASN_CSG
|
|
ardlst []ASN_ARD
|
|
unt ASN_UNT
|
|
unz ASN_UNZ
|
|
}
|
|
|
|
func (au *ASN_UNB) Tostring() string {
|
|
return "UNB+" + au.Field1 + "+" + au.Field2 + "+" + au.Field3 + "+" + au.Field4 + "+" + au.Field5
|
|
}
|
|
|
|
func (au *ASN_UNH) Tostring() string {
|
|
return "UNH+" + au.Field1 + "+" + au.Field2
|
|
}
|
|
|
|
// Message Identification
|
|
func (am *ASN_MID) Tostring() string {
|
|
return "MID+" + am.Field1 + "+" + am.Field2
|
|
}
|
|
|
|
// Consignor Details
|
|
func (ac *ASN_CDT) Tostring() string {
|
|
return "CDT+" + ac.Field1
|
|
}
|
|
|
|
// Consignor Details
|
|
func (ac *ASN_CSG) Tostring() string {
|
|
return "CSG+" + ac.Field1
|
|
}
|
|
|
|
// Transport Details
|
|
func (ad *ASN_DTR) Tostring() string {
|
|
return "DTR+" + ad.Field1 + "+" + ad.Field2 + "+" + ad.Field3 + "+" + ad.Field4 + "+" + ad.Field5 + "+" + ad.Field6 + "+" + ad.Field7 + "+" + ad.Field8 + "+" + ad.Field9
|
|
}
|
|
|
|
// Article Details
|
|
func (aa *ASN_ARD) Tostring() string {
|
|
return "ARD+" + aa.Field1 + "+" + aa.Field2 + "+" + aa.Field3
|
|
}
|
|
|
|
// Type of Package
|
|
func (at *ASN_TCO) Tostring() string {
|
|
return "TCO+" + at.Field1 + "+" + at.Field2 + "+" + at.Field3
|
|
}
|
|
|
|
func (au *ASN_UNT) Tostring() string {
|
|
return "UNT+" + au.Field1 + "+" + au.Field2
|
|
}
|
|
|
|
func (au *ASN_UNZ) Tostring() string {
|
|
return "UNZ+" + au.Field1 + "+" + au.Field2
|
|
}
|
|
|
|
/****/
|
|
func (au *ASN_UNB) Read(asnnr string) (err error) {
|
|
var (
|
|
stdeftab db.Stdeftab
|
|
stdeftablst []db.Stdeftab
|
|
i int
|
|
)
|
|
|
|
stdeftab = db.Stdeftab{}
|
|
if stdeftablst, err = stdeftab.GetStandardList("BBAASN_UNB"); err != nil {
|
|
return
|
|
}
|
|
stdeftablst = stdeftablst
|
|
|
|
for i = 0; i < len(stdeftablst); i++ {
|
|
//fmt.Println(i, ">",stdeftablst[i].Statid,"<", stdeftablst[i].Bez)
|
|
switch stdeftablst[i].Statid {
|
|
case "Field1":
|
|
au.Field1 = stdeftablst[i].Bez
|
|
case "Field2":
|
|
au.Field2 = stdeftablst[i].Bez
|
|
case "Field3":
|
|
au.Field3 = stdeftablst[i].Bez
|
|
case "Field4":
|
|
au.Field4 = common.Date(time.Now().Unix(), stdeftablst[i].Bez)
|
|
case "Field5":
|
|
au.Field5 = asnnr
|
|
default:
|
|
|
|
}
|
|
}
|
|
|
|
return
|
|
}
|
|
func (au *ASN_UNH) Read(asnnr string) (err error) {
|
|
var (
|
|
stdeftab db.Stdeftab
|
|
stdeftablst []db.Stdeftab
|
|
i int
|
|
)
|
|
|
|
stdeftab = db.Stdeftab{}
|
|
if stdeftablst, err = stdeftab.GetStandardList("BBAASN_UNH"); err != nil {
|
|
return
|
|
}
|
|
stdeftablst = stdeftablst
|
|
|
|
for i = 0; i < len(stdeftablst); i++ {
|
|
//fmt.Println(i, ">",stdeftablst[i].Statid,"<", stdeftablst[i].Bez)
|
|
switch stdeftablst[i].Statid {
|
|
case "Field1":
|
|
au.Field1 = asnnr
|
|
case "Field2":
|
|
au.Field2 = stdeftablst[i].Bez
|
|
default:
|
|
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
// Message Identification
|
|
func (am *ASN_MID) Read(asnnr string) (err error) {
|
|
var (
|
|
stdeftab db.Stdeftab
|
|
stdeftablst []db.Stdeftab
|
|
i int
|
|
astr []string
|
|
)
|
|
|
|
stdeftab = db.Stdeftab{}
|
|
if stdeftablst, err = stdeftab.GetStandardList("BBAASN_MID"); err != nil {
|
|
return
|
|
}
|
|
|
|
for i = 0; i < len(stdeftablst); i++ {
|
|
//fmt.Println(i, ">",stdeftablst[i].Statid,"<", stdeftablst[i].Bez)
|
|
switch stdeftablst[i].Statid {
|
|
case "Field1":
|
|
astr = strings.Split(stdeftablst[i].Bez, "+")
|
|
if len(astr) > 1 {
|
|
am.Field1 = astr[0] + asnnr
|
|
} else {
|
|
am.Field1 = asnnr
|
|
}
|
|
|
|
case "Field2":
|
|
am.Field2 = common.Date(time.Now().Unix(), stdeftablst[i].Bez)
|
|
default:
|
|
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
// Consignor Details
|
|
func (ac *ASN_CDT) Read() (err error) {
|
|
var (
|
|
stdeftab db.Stdeftab
|
|
stdeftablst []db.Stdeftab
|
|
i int
|
|
)
|
|
|
|
stdeftab = db.Stdeftab{}
|
|
if stdeftablst, err = stdeftab.GetStandardList("BBAASN_CDT"); err != nil {
|
|
return
|
|
}
|
|
stdeftablst = stdeftablst
|
|
|
|
for i = 0; i < len(stdeftablst); i++ {
|
|
//fmt.Println(i, ">",stdeftablst[i].Statid,"<", stdeftablst[i].Bez)
|
|
switch stdeftablst[i].Statid {
|
|
case "Field1":
|
|
ac.Field1 = stdeftablst[i].Bez
|
|
default:
|
|
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
// Consignor Details
|
|
func (ac *ASN_CSG) Read() (err error) {
|
|
var (
|
|
stdeftab db.Stdeftab
|
|
stdeftablst []db.Stdeftab
|
|
i int
|
|
)
|
|
|
|
stdeftab = db.Stdeftab{}
|
|
if stdeftablst, err = stdeftab.GetStandardList("BBAASN_CSG"); err != nil {
|
|
return
|
|
}
|
|
stdeftablst = stdeftablst
|
|
|
|
for i = 0; i < len(stdeftablst); i++ {
|
|
//fmt.Println(i, ">",stdeftablst[i].Statid,"<", stdeftablst[i].Bez)
|
|
switch stdeftablst[i].Statid {
|
|
case "Field1":
|
|
ac.Field1 = stdeftablst[i].Bez
|
|
default:
|
|
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
// Transport Details
|
|
func (ad *ASN_DTR) Read() {
|
|
|
|
}
|
|
|
|
// Article Details
|
|
func (aa *ASN_ARD) Read(pf, sg, calloffnr, oemordnr string) {
|
|
aa.Field1 = "::" + pf + ":" + sg + ":" + calloffnr + ":" + oemordnr[:len(oemordnr)-1]
|
|
aa.Field2 = "0"
|
|
aa.Field3 = "00000000000000000"
|
|
}
|
|
|
|
// Type of Package
|
|
func (at *ASN_TCO) Read() {
|
|
|
|
}
|
|
func (au *ASN_UNT) Read(iRows int, asnnr string) {
|
|
au.Field1 = strconv.Itoa(iRows)
|
|
au.Field2 = asnnr
|
|
}
|
|
func (au *ASN_UNZ) Read(asnnr string) {
|
|
au.Field1 = "1"
|
|
au.Field2 = asnnr
|
|
}
|
|
|
|
func (ae *ASN_EDI) Tostring() (result string) {
|
|
var i int
|
|
|
|
result = ae.unb.Tostring() + "'"
|
|
result = result + ae.unh.Tostring() + "'"
|
|
result = result + ae.mid.Tostring() + "'"
|
|
result = result + ae.cdt.Tostring() + "'"
|
|
result = result + ae.csg.Tostring() + "'"
|
|
for i = 0; i < len(ae.ardlst); i++ {
|
|
result = result + ae.ardlst[i].Tostring() + "'"
|
|
}
|
|
result = result + ae.unt.Tostring() + "'"
|
|
result = result + ae.unz.Tostring() + "'"
|
|
|
|
return
|
|
}
|
|
|
|
|