allied-creation-byte-bank.go
1.8 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
package domainService
import (
"github.com/linmadan/egglib-go/core/application"
"github.com/tidwall/gjson"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/constant"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/allied-lib/gateway/byte_bank"
)
type ByteBankService struct {
internalService *byte_bank.HttpLibByteBankServiceGateway
}
func NewByteBankService() *ByteBankService {
return &ByteBankService{
internalService: byte_bank.NewHttpLibByteBankServiceGateway(constant.MMM_BYTE_BANK_HOST),
}
}
//GetFormulasId 获取公式id
func (svr *ByteBankService) GetFormulasId(formulaName string) string {
//获取公式id
formulaId := ""
listLoop:
for i := 0; ; i++ {
data, err := svr.internalService.ListFormulas(1000, int64(i))
if err != nil {
return ""
}
if len(data.Formulas) == 0 {
break listLoop
}
for _, item := range data.Formulas {
if item.FormulaDescription == formulaName {
formulaId = item.FormulaId
break listLoop
}
}
}
return formulaId
}
// SectionProductive 时段产能
func (svr *ByteBankService) SectionProductive() (interface{}, error) {
//获取公式id时段产能
formulaId := svr.GetFormulasId("type_salesman_id")
//获取解析数据
byteResult, err := svr.internalService.AnalysisFormulaByte(formulaId)
if err != nil {
return struct{}{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
code := gjson.GetBytes(byteResult, "code").String()
if code != "0" {
msg := gjson.GetBytes(byteResult, "msg").String()
return struct{}{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, msg)
}
//待解析的
queryResult := gjson.GetBytes(byteResult, "data.queryResult").Array()
for _, item := range queryResult {
if item.Get("type_salesman_id").String() != "" {
continue
}
}
return nil, nil
}