|
@@ -66,7 +66,7 @@ func getKplerDataByApi(params models.KplerSearchEdbReq, serverUrl string, isRefr
|
|
|
libreq.WithIntraRegion = "true"
|
|
|
libreq.WithForecast = "true"
|
|
|
libreq.OnlyRealized = "false"
|
|
|
- libreq.StartDate = "2025-01-01"
|
|
|
+ libreq.StartDate = "2013-01-01"
|
|
|
libreq.EndDate = time.Now().Format(utils.FormatDate)
|
|
|
// 请求接口
|
|
|
apiResp, err := getKplerFlowDataLib(serverUrl, libreq)
|
|
@@ -416,9 +416,13 @@ func getKplerFlowDataLib(libUrl string, dataMap *models.KplerFlowDataLibReq) (re
|
|
|
return resp, nil
|
|
|
}
|
|
|
|
|
|
-func getKplerProductLib(libUrl string) (resp *models.KplerProductLibResp, err error) {
|
|
|
+func getKplerProductLib(libUrl string, req *models.KplerProductLibReq) (resp *models.KplerProductLibResp, err error) {
|
|
|
postUrl := fmt.Sprintf("%s%s", libUrl, "/v1/kpler/getProductData")
|
|
|
- result, err := HttpPost(postUrl, "", "application/json")
|
|
|
+ postData, err := json.Marshal(req)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ result, err := HttpPost(postUrl, string(postData), "application/json")
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
@@ -798,7 +802,18 @@ func GetKplerGranularity(frequency string) (granularity string) {
|
|
|
|
|
|
func InitKplerProduct ()(err error) {
|
|
|
libUrl := "http://127.0.0.1:8915"
|
|
|
- libResp, err := getKplerProductLib(libUrl)
|
|
|
+ libResp, err := getKplerProductLib(libUrl, &models.KplerProductLibReq{
|
|
|
+ AncestorFamilyIds: "",
|
|
|
+ AncestorFamilyNames: "",
|
|
|
+ AncestorGroupIds: "",
|
|
|
+ AncestorGroupNames: "",
|
|
|
+ AncestorProductIds: "",
|
|
|
+ AncestorProductNames: "",
|
|
|
+ AncestorGradeIds: "",
|
|
|
+ AncestorGradeNames: "",
|
|
|
+ Products: "",
|
|
|
+ ProductIds: "",
|
|
|
+ })
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
@@ -872,6 +887,77 @@ func InitKplerProduct ()(err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+func InitKplerProductGrade ()(err error) {
|
|
|
+ libUrl := "http://127.0.0.1:8915"
|
|
|
+
|
|
|
+ classifyList, err := models.GetAllBaseFromKplerClassifyByClassifyType("subgrade4")
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, c := range classifyList {
|
|
|
+ c.ModifyTime = time.Now()
|
|
|
+ err = c.Update([]string{"ModifyTime"})
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("更新开普勒产品库失败", err)
|
|
|
+ utils.FileLog.Info("更新开普勒产品库失败", err)
|
|
|
+ }
|
|
|
+ // 每个分类都发起分组请求
|
|
|
+ libResp, er := getKplerProductLib(libUrl, &models.KplerProductLibReq{
|
|
|
+ // AncestorFamilyIds: familyIds,
|
|
|
+ // AncestorFamilyNames: familyNames,
|
|
|
+ // AncestorGroupIds: groupIds,
|
|
|
+ // AncestorGroupNames: groupNames,
|
|
|
+ // AncestorProductIds: productIds,
|
|
|
+ // AncestorProductNames: productNames,
|
|
|
+ AncestorGradeIds: strconv.Itoa(c.ProductId),
|
|
|
+ AncestorGradeNames: c.ProductName,
|
|
|
+ })
|
|
|
+ if er != nil {
|
|
|
+ fmt.Println("获取开普勒产品库失败", er)
|
|
|
+ utils.FileLog.Info("获取开普勒产品库失败", er)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ if libResp.Ret != 200 {
|
|
|
+ fmt.Println("获取开普勒产品库失败", libResp.ErrMsg)
|
|
|
+ utils.FileLog.Info("获取开普勒产品库失败", libResp.ErrMsg)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ classifyObj := new(models.BaseFromKplerClassify)
|
|
|
+ for _, v := range libResp.Data {
|
|
|
+ id, _ := strconv.Atoi(v.Id)
|
|
|
+ if id == 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ if id == c.ProductId {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ // 更新对应的分类等级和父级
|
|
|
+ // 查找所有子分类
|
|
|
+
|
|
|
+ classifyItem, er := classifyObj.GetByProductId(id)
|
|
|
+ if er != nil {
|
|
|
+ err = fmt.Errorf("子分类不存在 Err:%s", er)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ classifyItem.Level = c.Level + 1
|
|
|
+ classifyItem.ParentId = c.ClassifyId
|
|
|
+ classifyItem.ClassifyType = "subgrade5"
|
|
|
+ classifyItem.ModifyTime = time.Now()
|
|
|
+ err = classifyItem.Update([]string{"Level", "ParentId", "ClassifyType", "ModifyTime"})
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("更新开普勒产品库失败", err)
|
|
|
+ utils.FileLog.Info("更新开普勒产品库失败", err)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ fmt.Println("classifyList:", classifyList)
|
|
|
+
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
func InitKplerZone() (err error) {
|
|
|
libUrl := "http://127.0.0.1:8915"
|