client_test.go
2.9 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package k3cloud
import (
"strings"
"testing"
)
var (
acctID = "20211118121754866"
// username = "Administrator"
// password = "stxcs@888"
username = "18559023318"
password = "stx@123456"
hostUrl = "https://tianlian.test.ik3cloud.com/k3cloud"
)
func TestLogin(t *testing.T) {
client := Client{HttpClient{HostUrl: hostUrl}}
result, err := client.Login(acctID, username, password)
if err != nil {
t.Error(err)
}
t.Logf("%+v \n", *result)
}
func TestExecuteBillQuery(t *testing.T) {
client, err := NewClient(hostUrl, acctID, username, password)
if err != nil {
t.Error(err)
return
}
//参见 物料元数据
// _ = [][2]string{{"FMATERIALID", "表主键"}, {"FDocumentStatus", "数据状态"}, {"FForbidStatus", "禁用状态"}, {"FName", "名称"}, {"FNumber", "编码"}, {"FDescription", "描述"},
// {"FCreateDate", "创建日期"}, {"FModifyDate", "修改日期"}, {"FMnemonicCode", "助记码"}, {"FSpecification", "规格型号"}, {"FForbidDate", "禁用日期"},
// {"FApproveDate", "审核日期"}, {"FOldNumber", "旧物料编码"}, {"FMaterialGroup", "物料分组"}, {"FPLMMaterialId", "PLM物料内码"}, {"FMaterialSRC", "物料来源"},
// {"FIsSalseByNet", "是否网销"}, {"FIsAutoAllocate", "自动分配"}, {"FSPUID", "SPU信息"}, {"FPinYin", "拼音"}, {"FDSMatchByLot", "按批号匹配供需"},
// {"FForbidReson", "禁用原因"}, {"FRefStatus", "已使用"}}
fieldKeys := []string{
"FMATERIALID", "FSpecification", "FName", "FNumber",
"FDocumentStatus", "FForbidStatus", "FErpClsID",
"FBaseUnitId", "FBaseUnitId.FName", "FCreateDate", "FModifyDate",
"FForbidDate", "FApproveDate", "FMaterialGroup", "FMaterialGroup.FName",
"FRefStatus", "FMaterialGroup.FNumber", "FUseOrgId", "FUseOrgId.FName",
}
result, err := client.ExecuteBillQuery(RequestExecuteBillQuery{
FormId: "BD_MATERIAL",
Data: ExecuteBillQueryData{
FormId: "BD_MATERIAL",
FieldKeys: strings.Join(fieldKeys, ","), //查询的字段
TopRowCount: 5,
FilterString: "",
},
})
t.Logf("result buf===> %s \n", string(result.Buf))
if err != nil {
t.Error(err)
return
}
}
func TestExecuteBillQuery2(t *testing.T) {
client, err := NewClient(hostUrl, acctID, username, password)
if err != nil {
t.Error(err)
return
}
fieldKeys := []string{
"FBillNo", "FWorkShopID", "FWorkShopID.FName", "FMaterialId", "FMaterialId.FName",
"FMaterialId.FNumber", "FMaterialId.FSpecification", "FPlanStartDate", "FPlanFinishDate", "FDate", "FQty",
"FCreateDate", "FModifyDate", "FPrdOrgId", "FPrdOrgId.FName", "FRowId", "FUnitId", "FUnitId.FName", "FDescription",
}
result, err := client.ExecuteBillQuery(RequestExecuteBillQuery{
FormId: "PRD_MO",
Data: ExecuteBillQueryData{
FormId: "PRD_MO",
FieldKeys: strings.Join(fieldKeys, ","), //查询的字段
TopRowCount: 4,
FilterString: "",
},
})
t.Logf("result buf===> %s \n", string(result.Buf))
if err != nil {
t.Error(err)
return
}
}