@ -1,8 +1,11 @@
package calloff
import (
"encoding/json"
"encoding/xml"
"fmt"
"github.com/go-xorm/xorm"
"io"
"io/ioutil"
"leit.com/leit_seat_aps/common"
"leit.com/leit_seat_aps/db"
@ -11,6 +14,8 @@ import (
"leit.com/leit_seat_aps/service"
"os"
"regexp"
"strconv"
"strings"
"time"
)
@ -554,6 +559,7 @@ func ParseCalloffOrder() {
session . Close ( )
etcd . G_jobLock . UnLock ( )
time . Sleep ( 10 * time . Millisecond )
}
}
@ -699,12 +705,127 @@ func GenerateDeliveryCar() {
}
}
fmt . Println ( "---------------------生成xmL_msg1" )
//APS向WMS传递发运包装信息
var o = PlnCalloffdataLandingXml { }
o . Packorderid = pkotablst [ j ] . Packorderid
o . Packtemplateid = pkotablst [ j ] . Packtemplateid
o . Projnr = pkotablst [ j ] . Projnr
o . Status = strconv . Itoa ( pkotablst [ j ] . Status )
o . Shortpack = strconv . Itoa ( pkotablst [ j ] . Shortpack )
o . Orderinfo = pkotablst [ j ] . Orderinfo
o . Boxsn = pkotablst [ j ] . Boxsn
o . Packtypeid = pkotablst [ j ] . Packtypeid
o . Printerid = pkotablst [ j ] . Printerid
o . Templatefile = pkotablst [ j ] . Templatefile
o . Planqty = strconv . Itoa ( pkotablst [ j ] . Planqty )
o . Actqty = strconv . Itoa ( pkotablst [ j ] . Actqty )
for _ , info := range pkotablst [ j ] . Itemlst {
o . Details = append ( o . Details , Pln_calloffdata_landing_Xml {
Packorderid : info . Packorderid ,
Pos : common . ValueToString ( info . Pos , "" ) ,
Poscode : info . Poscode ,
Oemseq : common . ValueToString ( info . Oemseq , "" ) ,
Checkseq : common . ValueToString ( info . Seq , "" ) ,
Supplygroupid : info . Supplygroupid ,
Workordernr : info . Workordernr ,
Status : common . ValueToString ( info . Status , "" ) ,
Planqty : common . ValueToString ( info . Planqty , "" ) ,
Actqty : common . ValueToString ( info . Actqty , "" ) ,
} )
}
jsonBytes , err := json . Marshal ( o )
if err != nil {
fmt . Println ( err )
}
bl_xmlmsg := service . BL_Xmlmsg { MsgType : common . MSG_TYPE_SHIP , Msg : string ( jsonBytes ) }
fmt . Println ( "---------------------生成xmL_msg2" )
if err = bl_xmlmsg . Create ( session ) ; err != nil {
fmt . Println ( err )
}
err = session . Commit ( )
if err != nil {
fmt . Println ( err )
return
}
}
}
time . Sleep ( 10 * time . Second )
}
}
func CallOffXmlTick ( ) {
timer := time . NewTicker ( 60 * time . Second )
for {
select {
case <- timer . C :
Xml_msg := db . Xml_msg { }
if xmllst , err := Xml_msg . GetUnXmlMessages ( ) ; err != nil {
glog . InfoExtln ( "Calloff包装单" , "解析发运单消息失败: " , err )
} else {
for _ , xmlInfo := range xmllst {
var xmlStruct PlnCalloffdataLandingXml
json . Unmarshal ( [ ] byte ( xmlInfo . Msg ) , & xmlStruct )
resXML , err := xml . MarshalIndent ( xmlStruct , " " , " " )
if err != nil {
glog . InfoExtln ( "Calloff包装单" , "Failed to create xml due to :" , err )
}
timeS := time . Now ( ) . Format ( "20060102150405.999" )
fileName := strings . Trim ( timeS , "." )
f , err := os . Create ( "./OutData/" + fileName + ".xml" )
if err != nil {
glog . InfoExtln ( "Calloff包装单" , "Failed to create xml due to :" , err )
}
io . WriteString ( f , xml . Header )
io . WriteString ( f , string ( resXML ) )
Xml_msg . Msgid = xmlInfo . Msgid
Xml_msg . Status = common . MSG_STATUS_FINISHED
Xml_msg . Lastmodif = common . Date ( time . Now ( ) . Unix ( ) , "YYYYMMDDHHmmss" )
Xml_msg . Lastuser = "service"
if err = Xml_msg . UpdateFieldsWithoutSession ( "status,lastmodif,lastuser" ) ; err != nil {
glog . InfoExtln ( "Calloff包装单" , "Failed to create xml due to :" , err )
}
}
}
}
}
}
type PlnCalloffdataLandingXml struct {
XMLName xml . Name ` xml:"Content" `
Packorderid string ` xml:"packorderid,attr" `
Packtemplateid string ` xml:"packtemplateid,attr" `
Projnr string ` xml:"projnr,attr" `
Status string ` xml:"status,attr" `
Shortpack string ` xml:"shortpack,attr" `
Orderinfo string ` xml:"orderinfo,attr" `
Boxsn string ` xml:"boxsn,attr" `
Packtypeid string ` xml:"packtypeid,attr" `
Printerid string ` xml:"printerid,attr" `
Templatefile string ` xml:"templatefile,attr" `
Planqty string ` xml:"planqty,attr" `
Actqty string ` xml:"actqty,attr" `
Details [ ] Pln_calloffdata_landing_Xml ` xml:"Details" `
Description string ` xml:",innerxml" `
}
type Pln_calloffdata_landing_Xml struct {
XMLName xml . Name ` xml:"Details" `
Packorderid string ` xml:"packorderid,attr" `
Pos string ` xml:"pos,attr" `
Poscode string ` xml:"poscode,attr" `
Oemseq string ` xml:"oemseq,attr" `
Checkseq string ` xml:"checkseq,attr" `
Supplygroupid string ` xml:"supplygroupid,attr" `
Workordernr string ` xml:"workordernr,attr" `
Status string ` xml:"status,attr" `
Planqty string ` xml:"planqty,attr" `
Actqty string ` xml:"actqty,attr" `
}