作者 13655977079
提交者 yangfu

refactor: 物料管理优化

delete FROM "dictionarys" where dictionary_id in (3812266576427090944);
INSERT INTO "public"."dictionarys"("dictionary_id", "dict_code", "dict_name", "describe", "dict_items") VALUES (3972873532463383552, 'ACM-001', '天联共创-生产制造-物料属性', '', '[{"sort": 1, "isShow": 1, "itemCode": "1", "itemLabel": "", "itemValue": "外购"}, {"sort": 2, "isShow": 1, "itemCode": "2", "itemLabel": "", "itemValue": "自制"}, {"sort": 3, "isShow": 1, "itemCode": "3", "itemLabel": "", "itemValue": "委外"}]');
INSERT INTO "public"."dictionarys"("dictionary_id", "dict_code", "dict_name", "describe", "dict_items") VALUES (3972875981165167616, 'ACM-002', '天联共创-生产制造-物料类别', '', '[{"sort": 1, "isShow": 1, "itemCode": "1", "itemLabel": "", "itemValue": "原材料"}, {"sort": 2, "isShow": 1, "itemCode": "2", "itemLabel": "", "itemValue": "半成品"}, {"sort": 3, "isShow": 1, "itemCode": "3", "itemLabel": "", "itemValue": "成品"}]');
INSERT INTO "public"."dictionarys"("dictionary_id", "dict_code", "dict_name", "describe", "dict_items") VALUES (3972882719129994240, 'ACM-003', '天联共创-生产制造-单位', '', '[{"sort": 1, "isShow": 1, "itemCode": "1", "itemLabel": "", "itemValue": "千克"}, {"sort": 2, "isShow": 1, "itemCode": "2", "itemLabel": "", "itemValue": "个"}, {"sort": 3, "isShow": 1, "itemCode": "3", "itemLabel": "", "itemValue": "包"}, {"sort": 4, "isShow": 1, "itemCode": "4", "itemLabel": "", "itemValue": "箱"}, {"sort": 5, "isShow": 1, "itemCode": "5", "itemLabel": "", "itemValue": "片"}, {"sort": 6, "isShow": 1, "itemCode": "6", "itemLabel": "", "itemValue": "套"}, {"sort": 7, "isShow": 1, "itemCode": "7", "itemLabel": "", "itemValue": "份"}, {"sort": 8, "isShow": 1, "itemCode": "8", "itemLabel": "", "itemValue": "台"}, {"sort": 9, "isShow": 1, "itemCode": "9", "itemLabel": "", "itemValue": "米"}, {"sort": 10, "isShow": 1, "itemCode": "10", "itemLabel": "", "itemValue": "升"}, {"sort": 11, "isShow": 1, "itemCode": "11", "itemLabel": "", "itemValue": "辆"}, {"sort": 12, "isShow": 1, "itemCode": "12", "itemLabel": "", "itemValue": "秒"}, {"sort": 13, "isShow": 1, "itemCode": "13", "itemLabel": "", "itemValue": "栋"}]');
INSERT INTO "public"."dictionarys"("dictionary_id", "dict_code", "dict_name", "describe", "dict_items") VALUES (3972875981165167616, 'ACM-002', '天联共创-生产制造-物料管理-物料类别', '', '[{"sort": 1, "isShow": 1, "itemCode": "1", "itemLabel": "", "itemValue": "原材料"}, {"sort": 2, "isShow": 1, "itemCode": "2", "itemLabel": "", "itemValue": "半成品"}, {"sort": 3, "isShow": 1, "itemCode": "3", "itemLabel": "", "itemValue": "成品"}]');
INSERT INTO "public"."dictionarys"("dictionary_id", "dict_code", "dict_name", "describe", "dict_items") VALUES (3972882719129994240, 'ACM-003', '天联共创-生产制造-单位', '', '[{"sort": 1, "isShow": 1, "itemCode": "1", "itemLabel": "", "itemValue": "千克"}, {"sort": 2, "isShow": 1, "itemCode": "2", "itemLabel": "", "itemValue": "个"}, {"sort": 3, "isShow": 1, "itemCode": "3", "itemLabel": "", "itemValue": "包"}, {"sort": 4, "isShow": 1, "itemCode": "4", "itemLabel": "", "itemValue": "箱"}, {"sort": 5, "isShow": 1, "itemCode": "5", "itemLabel": "", "itemValue": "片"}, {"sort": 6, "isShow": 1, "itemCode": "6", "itemLabel": "", "itemValue": "套"}, {"sort": 7, "isShow": 1, "itemCode": "7", "itemLabel": "", "itemValue": "份"}, {"sort": 8, "isShow": 1, "itemCode": "8", "itemLabel": "", "itemValue": "台"}, {"sort": 9, "isShow": 1, "itemCode": "9", "itemLabel": "", "itemValue": "米"}, {"sort": 10, "isShow": 1, "itemCode": "10", "itemLabel": "", "itemValue": "升"}, {"sort": 11, "isShow": 1, "itemCode": "11", "itemLabel": "", "itemValue": "辆"}, {"sort": 12, "isShow": 1, "itemCode": "12", "itemLabel": "", "itemValue": "秒"}, {"sort": 13, "isShow": 1, "itemCode": "13", "itemLabel": "", "itemValue": "栋"}, {"sort": 14, "isShow": 1, "itemCode": "14", "itemLabel": "", "itemValue": "袋"}, {"sort": 15, "isShow": 1, "itemCode": "15", "itemLabel": "", "itemValue": "kg"}, {"sort": 16, "isShow": 1, "itemCode": "16", "itemLabel": "", "itemValue": "串"}, {"sort": 17, "isShow": 1, "itemCode": "17", "itemLabel": "", "itemValue": "件"}]');
INSERT INTO "public"."dictionarys"("dictionary_id", "dict_code", "dict_name", "describe", "dict_items") VALUES (3978995238135399424, 'ACM-004', '天联共创-生产制造-单位换算-物料类别', '', '[{"sort": 1, "isShow": 1, "itemCode": "1", "itemLabel": "", "itemValue": "南瓜饼串"}, {"sort": 2, "isShow": 1, "itemCode": "2", "itemLabel": "", "itemValue": "包装袋(空)"}, {"sort": 3, "isShow": 1, "itemCode": "3", "itemLabel": "", "itemValue": "包装袋(件数)"}, {"sort": 4, "isShow": 1, "itemCode": "4", "itemLabel": "", "itemValue": "装箱(件数)"}]');
INSERT INTO "public"."dictionarys"("dictionary_id", "dict_code", "dict_name", "describe", "dict_items") VALUES (3812266576427090944, 'XTZD-003', '生产制造-单位', '', '[{"sort": 1, "isShow": 1, "itemCode": "1", "itemLabel": "", "itemValue": "个"}, {"sort": 2, "isShow": 1, "itemCode": "2", "itemLabel": "", "itemValue": "袋"}, {"sort": 3, "isShow": 1, "itemCode": "3", "itemLabel": "", "itemValue": "kg"}, {"sort": 4, "isShow": 1, "itemCode": "4", "itemLabel": "", "itemValue": "串"}, {"sort": 5, "isShow": 1, "itemCode": "5", "itemLabel": "", "itemValue": "箱"}, {"sort": 6, "isShow": 1, "itemCode": "6", "itemLabel": "", "itemValue": "件"}]');
... ...
... ... @@ -63,6 +63,9 @@ func (crontabService *CrontabService) initTask() {
syncMaterialGroup := task.NewTask("定时同步物料分组", "0 0 0/2 * * *", SyncMaterialGroup)
task.AddTask("syncMaterialGroup", syncMaterialGroup)
syncMaterial := task.NewTask("定时同步物料", "0 0 0/2 * * *", SyncMaterial)
task.AddTask("syncMaterial", syncMaterial)
}
func (crontabService *CrontabService) StartCrontabTask() {
... ...
... ... @@ -8,6 +8,7 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/syncdata"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log"
"runtime/debug"
"time"
)
// SyncMaterial 定时同步物料
... ... @@ -30,10 +31,13 @@ func SyncMaterial(ctx context.Context) error {
}
transactionContext.RollbackTransaction()
}()
var pullType string = ""
if val := ctx.Value("pullType"); val != nil {
pullType = val.(string)
}
log.Logger.Debug("【定时同步物料】 启动")
pullK3CloudService := syncdata.PullDataK3CloudService{}
if err := pullK3CloudService.SyncDataMaterialGroup(transactionContext.(*pg.TransactionContext)); err != nil {
if err := pullK3CloudService.SyncDataMaterial(transactionContext.(*pg.TransactionContext), pullType, time.Time{}); err != nil {
log.Logger.Error(err.Error(), map[string]interface{}{"task": "定时同步物料"})
return nil
}
... ...
... ... @@ -14,7 +14,7 @@ type UpdateProductMaterialGroupCommand struct {
// 物料分组名称
MaterialGroupName string `cname:"物料分组名称" json:"materialGroupName" valid:"Required"`
// 物料分组编码
MaterialGroupNumber string `cname:"物料分组编码" json:"materialGroupNumber" valid:"Required"`
MaterialGroupNumber string `cname:"物料分组编码" json:"materialGroupNumber"`
}
func (updateProductMaterialGroupCommand *UpdateProductMaterialGroupCommand) Valid(validation *validation.Validation) {
... ...
... ... @@ -210,6 +210,101 @@ func (srv *PullDataK3CloudService) PullMaterial(timeFilter time.Time) error {
return nil
}
func (srv *PullDataK3CloudService) pullMaterial(timeFilter time.Time) ([]models.MaterialK3cloud, error) {
//拉取数据
var filterString []string
if !timeFilter.IsZero() {
str := timeFilter.Format("2006-01-02T15:04:05")
filterString = append(filterString, "FModifyDate>='"+str+"'")
}
client, err := newK3cloudClient()
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
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", "FCategoryID",
}
var (
startRow int
allResult []map[string]string
queryErr error
)
for {
result, err := client.ExecuteBillQuery(k3cloud.RequestExecuteBillQuery{
FormId: "BD_MATERIAL",
Data: k3cloud.ExecuteBillQueryData{
FormId: "BD_MATERIAL",
FieldKeys: strings.Join(fieldKeys, ","), //查询的字段
StartRow: startRow,
Limit: 1000,
FilterString: strings.Join(filterString, " and "),
},
})
if err != nil {
queryErr = err
break
}
mp := result.ToMapString()
if len(mp) == 0 {
break
}
allResult = append(allResult, mp...)
startRow += 1000
}
if queryErr != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
var (
materialModels []models.MaterialK3cloud
materialTemp models.MaterialK3cloud
)
nowTime := time.Now()
for _, item := range allResult {
materialId, err := strconv.Atoi(item["FMATERIALID"])
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
fErpClsID, _ := strconv.Atoi(item["FErpClsID"])
fBaseUnitId, _ := strconv.Atoi(item["FBaseUnitId"])
materialGroup, _ := strconv.Atoi(item["MaterialGroup"])
fUseOrgId, _ := strconv.Atoi(item["FUseOrgId"])
refStatus, _ := strconv.Atoi(item["RefStatus"])
fCreateDate, _ := time.Parse("2006-01-02T15:04:05.999", item["FCreateDate"])
fModifyDate, _ := time.Parse("2006-01-02T15:04:05.999", item["FModifyDate"])
fForbidDate, _ := time.Parse("2006-01-02T15:04:05.999", item["FForbidDate"])
fApproveDate, _ := time.Parse("2006-01-02T15:04:05.999", item["FApproveDate"])
materialTemp = models.MaterialK3cloud{
MaterialId: materialId,
Name: item["FName"],
Number: item["FNumber"],
Specification: item["FSpecification"],
ForbidStatus: item["FForbidStatus"],
ErpClsId: fErpClsID,
BaseUnitId: fBaseUnitId,
BaseUnitName: item["FBaseUnitId.FName"],
CreateDate: fCreateDate,
ModifyDate: fModifyDate,
ForbidDate: fForbidDate,
ApproveDate: fApproveDate,
MaterialGroup: materialGroup,
MaterialGroupNumber: item["FMaterialGroup.FNumber"],
MaterialGroupName: item["FMaterialGroup.FName"],
RefStatus: refStatus,
UseOrgId: fUseOrgId,
UseOrgName: item["FUseOrgId.FName"],
JoinProductId: 0,
DataVersion: nowTime.Unix(),
FCategoryID: item["FCategoryID"],
}
materialModels = append(materialModels, materialTemp)
}
return materialModels, nil
}
//PullMaterialGroup 拉取物料分组
func (srv *PullDataK3CloudService) PullMaterialGroup() error {
client, err := newK3cloudClient()
... ... @@ -463,6 +558,33 @@ func (srv *PullDataK3CloudService) PullPrdMo(timeFilter time.Time) error {
return nil
}
// PullMaterialCategory 拉取物料分类
func (srv *PullDataK3CloudService) PullMaterialCategory() (map[string]string, error) {
client, err := newK3cloudClient()
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
fieldKeys := []string{
"FName", "FNUMBER", "FMasterId",
}
result, err := client.ExecuteBillQuery(k3cloud.RequestExecuteBillQuery{
FormId: "BD_MATERIALCATEGORY",
Data: k3cloud.ExecuteBillQueryData{
FormId: "BD_MATERIALCATEGORY",
FieldKeys: strings.Join(fieldKeys, ","), //查询的字段
//TopRowCount: 4,
FilterString: "",
},
})
categorys := result.ToMapString()
var categorysById = make(map[string]string)
for _, v := range categorys {
categorysById[v["FMasterId"]] = v["FName"]
}
return categorysById, nil
}
// 同步产品
func (srv *PullDataK3CloudService) SyncDataProduct(ptr *pgTransaction.TransactionContext, fromTime time.Time) error {
prdMoDao, err := dao.NewMaterialK3cloudDao(ptr)
... ... @@ -683,23 +805,15 @@ func (srv *PullDataK3CloudService) SyncDataMaterialGroup(ptr *pgTransaction.Tran
}
// SyncDataMaterial 同步物料数据
func (srv *PullDataK3CloudService) SyncDataMaterial(ptr *pgTransaction.TransactionContext, fromTime time.Time) error {
/*
1.获取更新时间
2.获取prd_mo_k3cloud从更新时间开始的有变化的数据
3.查询是否有重复的批次号
4.有进行更新,其他的插入
*/
// pullType 拉取数据方式 full:全量 其他:增量
func (srv *PullDataK3CloudService) SyncDataMaterial(ptr *pgTransaction.TransactionContext, pullType string, fromTime time.Time) error {
var (
lastTime = utils.GetZeroTime(time.Now()).Add(-time.Hour * 24) //前一天有修改的记录
org *domain.Org
limit = 500
offset = 0
pageIndex = 0
err error
lastTime = utils.GetZeroTime(time.Now()).Add(-time.Hour * 24) //前一天有修改的记录
org *domain.Org
err error
)
if !fromTime.IsZero() {
lastTime = fromTime
if pullType == "full" {
lastTime = time.Time{}
}
var userService = domainService.NewUserService()
... ... @@ -710,9 +824,9 @@ func (srv *PullDataK3CloudService) SyncDataMaterial(ptr *pgTransaction.Transacti
var (
cid = constant.MANUFACTURE_DEFAULT_COMPANYID
oid = constant.MANUFACTURE_DEFAULT_ORGID
productMaterialRepository, _, _ = factory.FastProductMaterial(ptr, 0)
productMaterialGroupRepository, _, _ = factory.FastProductMaterialGroup(ptr, 0)
prdMoK3cloudDao, _ = dao.NewPrdMoK3cloudDao(ptr)
materialGroups domain.ProductMaterialGroups
)
... ... @@ -721,38 +835,63 @@ func (srv *PullDataK3CloudService) SyncDataMaterial(ptr *pgTransaction.Transacti
return err
}
mapMaterialGroup := materialGroups.ToMapByGroupNumber()
for {
offset += pageIndex * limit
pageIndex += 1
records, _, err := prdMoK3cloudDao.GetLatestMaterialData(lastTime, offset, limit)
if err != nil {
return err
records, err := srv.pullMaterial(lastTime)
if err != nil {
return err
}
mapMaterialCategory, err := srv.PullMaterialCategory()
if err != nil {
return err
}
log.Logger.Debug(fmt.Sprintf("【同步物料数据】查询数据条数:%v", len(records)))
for index, item := range records {
var (
material *domain.ProductMaterial
materialGroup *domain.ProductMaterialGroup
ok bool
attribute string //物料属性
category string //物料类别
)
if materialGroup, ok = mapMaterialGroup[item.MaterialGroupNumber]; !ok {
continue
}
material, err = productMaterialRepository.FindOne(map[string]interface{}{"companyId": cid, "materialNumber": item.Number})
if err == nil && material != nil {
continue
}
if err != domain.ErrorNotFound {
continue
}
if v, ok := mapMaterialCategory[item.FCategoryID]; ok {
category = v
}
attribute = domain.MaterialAttributeDescription(item.ErpClsId)
for _, v := range records {
var (
material *domain.ProductMaterial
materialGroup *domain.ProductMaterialGroup
ok bool
)
if materialGroup, ok = mapMaterialGroup[v.MaterialNumber]; !ok {
continue
}
material, err = productMaterialRepository.FindOne(map[string]interface{}{"companyId": cid, "materialNumber": v.MaterialNumber})
if err == nil && material != nil {
continue
}
if err == domain.ErrorNotFound {
material = &domain.ProductMaterial{
ProductMaterialGroupId: materialGroup.ProductMaterialGroupId,
Ext: domain.NewExt(org.OrgName),
}
}
material = &domain.ProductMaterial{
CompanyId: cid,
OrgId: oid,
ProductMaterialGroupId: materialGroup.ProductMaterialGroupId,
MaterialName: item.Name,
MaterialNumber: item.Number,
MaterialAttribute: &domain.MaterialAttribute{Attribute: attribute},
MaterialCategory: &domain.MaterialCategory{Category: category},
ProductMaterialExt: &domain.MaterialExt{
Specification: item.Specification,
Unit: item.BaseUnitName,
ExpiredDay: 0,
Remark: "",
Source: "k3cloud",
},
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
Ext: domain.NewExt(org.OrgName),
}
if len(records) == 0 || len(records) < limit {
break
if material, err = productMaterialRepository.Save(material); err != nil {
return err
}
log.Logger.Debug(fmt.Sprintf("同步 序号:%v 物料数据 id:%v number:%v name:%v", index, material.ProductMaterialId, material.MaterialNumber, material.MaterialName))
}
return nil
}
... ...
... ... @@ -32,4 +32,6 @@ type MaterialExt struct {
ExpiredDay int `json:"expiredDay"`
// 备注
Remark string `json:"remark"`
// 来源 k3cloud
Source string `json:"source"`
}
... ...
... ... @@ -67,3 +67,27 @@ func (productMaterials ProductMaterials) ToMapByNumber() map[string]*ProductMate
}
return mapProductMaterial
}
// 10:资产,9:配置,2:自制,11:费用,12:模型,5:虚拟,7:一次性,13:产品系列 12:模型,3:委外,4:特征,6:服务,1:外购
var mapMaterialCategory = map[int]string{
1: "外购",
2: "自制",
3: "委外",
4: "特征",
5: "虚拟",
6: "服务",
7: "一次性",
8: "",
9: "配置",
10: "资产",
11: "费用",
12: "模型",
13: "产品系列",
}
func MaterialAttributeDescription(code int) string {
if v, ok := mapMaterialCategory[code]; ok {
return v
}
return ""
}
... ...
... ... @@ -172,9 +172,9 @@ func (d *PrdMoK3cloudDao) GetLatestData(fromTime time.Time) ([]*models.PrdMoK3cl
}
// GetLatestMaterialData 增量获取物料数据
func (d *PrdMoK3cloudDao) GetLatestMaterialData(fromTime time.Time, offset, limit int) ([]*models.ProductMaterial, int, error) {
m := new(models.ProductMaterial)
result := make([]*models.ProductMaterial, 0)
func (d *PrdMoK3cloudDao) GetLatestMaterialData(fromTime time.Time, offset, limit int) ([]*models.MaterialK3cloud, int, error) {
m := new(models.MaterialK3cloud)
result := make([]*models.MaterialK3cloud, 0)
query := d.transactionContext.PgTx.Model(m)
if !fromTime.IsZero() {
query.Where("modify_date>=?", fromTime)
... ...
... ... @@ -53,8 +53,7 @@ func (ptr *PGMaterialService) AddMaterial(opt *domain.OperateInfo, item *domain.
UpdatedAt: time.Now(),
Ext: domain.NewExt(org.OrgName).WithOperator(user),
}
aaa, err := productMaterialRepository.Save(newProductMaterial)
return aaa, err
return productMaterialRepository.Save(newProductMaterial)
}
// 物料分组
... ...
... ... @@ -25,6 +25,7 @@ type MaterialK3cloud struct {
UseOrgName string `comment:"使用组织" pg:"use_org_name"`
JoinProductId int64 `comment:"关联的product表id" pg:"join_product_id"`
DataVersion int64 `comment:"数据版本" pg:"data_version"`
FCategoryID string `pg:"-"`
}
//批量处理sql脚本样例
... ...
... ... @@ -137,7 +137,7 @@ func (repository *ProductMaterialRepository) FindOne(queryOptions map[string]int
query.SetWhereByQueryOption("product_material.material_number = ?", "materialNumber")
if err := query.First(); err != nil {
if err.Error() == "pg: no rows in result set" {
return nil, fmt.Errorf("没有此资源")
return nil, domain.ErrorNotFound
} else {
return nil, err
}
... ...
... ... @@ -2,6 +2,7 @@ package k3cloud
import (
"errors"
"fmt"
"io"
"time"
... ... @@ -87,3 +88,20 @@ func (c *Client) ExecuteBillQuery(param RequestExecuteBillQuery) (*BillQueryResu
queryResult := newBillQueryResult(dataByte, param.Data.FieldKeys)
return queryResult, queryResult.Error()
}
// ExecuteMetaDataQuery 元数据查询
func (c *Client) ExecuteMetaDataQuery(param RequestMetaDataQuery) ([]byte, error) {
api := "/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.QueryBusinessInfo.common.kdsvc"
resp, err := c.PostRequest(api, param)
if err != nil {
return nil, err
}
defer resp.Body.Close()
var dataByte []byte
dataByte, err = io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
fmt.Println("data ", string(dataByte))
return dataByte, nil
}
... ...
package k3cloud
import (
"fmt"
"strings"
"testing"
"time"
)
var (
... ... @@ -40,7 +42,7 @@ func TestExecuteBillQuery(t *testing.T) {
"FDocumentStatus", "FForbidStatus", "FErpClsID",
"FBaseUnitId", "FBaseUnitId.FName", "FCreateDate", "FModifyDate",
"FForbidDate", "FApproveDate", "FMaterialGroup", "FMaterialGroup.FName",
"FRefStatus", "FMaterialGroup.FNumber", "FUseOrgId", "FUseOrgId.FName",
"FRefStatus", "FMaterialGroup.FNumber", "FUseOrgId", "FUseOrgId.FName", "FCategoryID",
}
result, err := client.ExecuteBillQuery(RequestExecuteBillQuery{
FormId: "BD_MATERIAL",
... ... @@ -85,3 +87,52 @@ func TestExecuteBillQuery2(t *testing.T) {
return
}
}
func TestMetaDataQuery(t *testing.T) {
client, err := NewClient(hostUrl, acctID, username, password)
if err != nil {
t.Error(err)
return
}
inputs := []struct {
formId string
desc string
}{
{"BD_MATERIALCATEGORY", "货类别没"},
{"BD_MATERIALCATEGORY", "货类别没"},
}
for _, v := range inputs {
result, err := client.ExecuteMetaDataQuery(RequestMetaDataQuery{Data{FormId: v.formId}, v.formId})
if err != nil {
fmt.Println(err.Error())
}
t.Log(v.formId, v.desc, string(result))
}
time.Sleep(time.Second)
}
func TestExecuteMATERIALCATEGORYQuery(t *testing.T) {
client, err := NewClient(hostUrl, acctID, username, password)
if err != nil {
t.Error(err)
return
}
fieldKeys := []string{
"FName", "FNUMBER", "FMasterId",
}
result, err := client.ExecuteBillQuery(RequestExecuteBillQuery{
FormId: "PRD_MO",
Data: ExecuteBillQueryData{
FormId: "BD_MATERIALCATEGORY",
FieldKeys: strings.Join(fieldKeys, ","), //查询的字段
//TopRowCount: 4,
FilterString: "",
},
})
t.Logf("result buf===> %s \n", string(result.Buf))
if err != nil {
t.Error(err)
return
}
}
... ...
... ... @@ -51,3 +51,13 @@ type (
Data ExecuteBillQueryData `json:"data"`
}
)
type (
RequestMetaDataQuery struct {
Data Data `json:"data"`
FormId string `json:"FormId"` //必录,查询表单元数据唯一标识
}
Data struct {
FormId string `json:"FormId"` //必录,查询表单元数据唯一标识
}
)
... ...
... ... @@ -146,6 +146,14 @@ func (controller *StatisticsController) TaskHandler() func(ctx *context.Context)
}
case "11":
crontab.SyncMaterialGroup(nil)
case "12":
bc := c.Background()
bc = c.WithValue(bc, "pullType", "full")
err := crontab.SyncMaterial(bc)
if err != nil {
Response(ctx, nil, err)
return
}
}
Response(ctx, nil, nil)
}
... ...