|
|
- package int
-
- import (
- "fmt"
- "leit.com/leit_seat_aps/common"
- "leit.com/leit_seat_aps/db"
- "testing"
- "time"
- )
-
- // 测试TOD解析创建生产订单
- func TestParseTodCustorderNew(t *testing.T) {
- var (
- connstring string
- err error
- wotab db.Pln_workorder
- intwotab db.Int_aps_out_prord
- i int
- vdatalst []db.VWorkorderCustorder
- )
-
- // 连接APS数据库
- connstring = fmt.Sprintf("server=%s;user id=%s;password=%s;database=%s;port=%d;encrypt=disable",
- `DESKTOP-S4G95G5\\MLINK`, "lapp", "123fis", "LAPP_JITS", 1433)
- if err = db.InitMssqlDb(connstring); err != nil {
- t.Errorf("Failed to connect db due to: %v", err)
- return
- }
- // 读数据
- wotab = db.Pln_workorder{}
- if vdatalst, err = wotab.GetReleasedWorkorder("G38"); err != nil {
- t.Errorf("Failed to get released workorder due to: %v", err)
- return
- }
-
- db.G_DbEngine.Close()
-
- // 连接接口数据库
- /**connstring = fmt.Sprintf("server=%s;user id=%s;password=%s;database=%s;port=%d;encrypt=disable",
- `10.114.64.19`, "sa", "SJJsql2012", "APS_MES_INT", 1433)**/
- connstring = fmt.Sprintf("server=%s;user id=%s;password=%s;database=%s;port=%d;encrypt=disable",
- `DESKTOP-S4G95G5\\MLINK`, "lapp", "123fis", "LAPP_APS_MES_INT", 1433)
-
- if err = db.InitMssqlDb(connstring); err != nil {
- t.Errorf("Failed to connect db due to: %v", err)
- return
- }
-
- // 写数据
- fmt.Println("准备写数据.......",len(vdatalst))
- for i = 0; i < len(vdatalst); i++ {
- fmt.Println(i,vdatalst[i].Pln_workorder)
- intwotab = db.Int_aps_out_prord{}
- intwotab.Plant = vdatalst[i].Pln_workorder.Finr
- intwotab.Projnr = vdatalst[i].Pln_workorder.Projnr
- intwotab.Ordernr = vdatalst[i].Pln_workorder.Workordernr
- intwotab.Ordertype = vdatalst[i].Pln_workorder.Ordertype
- intwotab.Schedresource = vdatalst[i].Pln_workorder.Worklineid
- intwotab.Partfamily = vdatalst[i].Pln_workorder.Partfamilyid
- intwotab.Supplygroup = vdatalst[i].Pln_workorder.Supplygroupid
- intwotab.Planqty = vdatalst[i].Pln_workorder.Planqty
- intwotab.Bba_seq = vdatalst[i].Pln_workorder.Oemseq
- intwotab.Aps_seq = vdatalst[i].Pln_workorder.Schedseq
- if intwotab.Swet, err = common.DateParse(vdatalst[i].Pln_workorder.Swet, "YmdHis"); err != nil {
- t.Errorf("转换时间%s失败因为: %v", vdatalst[i].Pln_workorder.Swet,err)
- return
- }
- intwotab.Custordnr = vdatalst[i].Pln_custorder.Oemordernr
- intwotab.Vin = vdatalst[i].Pln_custorder.Vin
- intwotab.Creationtime = time.Now()
- intwotab.Responsetime = time.Now()
- if err = intwotab.Add(); err != nil {
- t.Errorf("插入生产订单%s失败因为: %v", vdatalst[i].Pln_workorder.Workordernr,err)
- return
- }
- }
- fmt.Println("完成写数据......")
- db.G_DbEngine.Close()
- }
|