|
@@ -227,8 +227,8 @@ func GetLzProductDetail() (err error) {
|
|
|
}
|
|
|
}()
|
|
|
|
|
|
- startDate := "2020-09-01" //time.Now().AddDate(0, 0, 0).Format(utils.FormatDate)
|
|
|
- endDate := "2020-09-04" //time.Now().AddDate(0, 0, 0).Format(utils.FormatDate)
|
|
|
+ startDate := time.Now().AddDate(0, 0, 0).Format(utils.FormatDate)
|
|
|
+ endDate := time.Now().AddDate(0, 0, 0).Format(utils.FormatDate)
|
|
|
time.Sleep(5 * time.Second)
|
|
|
pageSize := 30
|
|
|
|
|
@@ -711,20 +711,16 @@ func GetLzProductPriceData() (err error) {
|
|
|
}
|
|
|
}()
|
|
|
|
|
|
- //chuchang, guonei, guoji, oil ,lingshou,guojioil,base,国内出厂,国内市场,国际市场,国内成品油批发价,国内成品油零售价,国际原油,基准价
|
|
|
- typeMap := make(map[string]string)
|
|
|
- //typeMap["chuchang"] = "国内出厂"
|
|
|
- typeMap["guonei"] = "国内市场"
|
|
|
- //typeMap["guoji"] = "国际市场"
|
|
|
- //typeMap["oil"] = "国内成品油批发价"
|
|
|
- //typeMap["lingshou"] = "国内成品油零售价"
|
|
|
- //typeMap["guojioil"] = "国际原油"
|
|
|
- //typeMap["base"] = "基准价"
|
|
|
+ priceInfoList,err:=models.GetLongzhongpriceinfo()
|
|
|
+ if err!=nil {
|
|
|
+ msg="获取价格指标失败,Err:"+err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
username := "hzmd"
|
|
|
password := "HZMD2020"
|
|
|
- for k, v := range typeMap {
|
|
|
+ for k, v := range priceInfoList {
|
|
|
fmt.Println(k, v)
|
|
|
- getUrl := `https://openapi.oilchem.net/price/getPrice?password=` + password + `&type=` + k + `&username=` + username + `&inStartDate=2020-08-01&inEndDate=2020-08-07`
|
|
|
+ getUrl := `https://openapi.oilchem.net/price/getPrice?password=` + password + `&type=` + v.PriceId + `&username=` + username + `&inStartDate=2020-08-01&inEndDate=2020-08-07`
|
|
|
body, err := http.Get(getUrl)
|
|
|
if err != nil {
|
|
|
msg = "获取隆众价格数据失败:Err" + err.Error()
|
|
@@ -743,23 +739,6 @@ func GetLzProductPriceData() (err error) {
|
|
|
return nil
|
|
|
}
|
|
|
for _, n := range infoList.Data {
|
|
|
- infoItem, err := models.GetLongzhongpriceinfoByPriceId(n.Id)
|
|
|
- if err != nil {
|
|
|
- if err.Error() == utils.ErrNoRow() {
|
|
|
- fmt.Println("指标不存在:id:" + n.Id)
|
|
|
- msg = "指标不存在:id:" + n.Id
|
|
|
- return err
|
|
|
- } else {
|
|
|
- fmt.Println("获取指标失败:id:" + n.Id)
|
|
|
- msg = "获取指标失败:id:" + n.Id
|
|
|
- return err
|
|
|
- }
|
|
|
- }
|
|
|
- if infoItem == nil {
|
|
|
- fmt.Println("指标不存在:id:" + n.Id)
|
|
|
- msg = "指标不存在:id:" + n.Id
|
|
|
- return nil
|
|
|
- }
|
|
|
count, err := models.GetLongzhongpricedataCount(n.Id, n.PriceDate)
|
|
|
if err != nil {
|
|
|
msg = "获取隆众价格数据失败:err " + err.Error()
|
|
@@ -769,7 +748,7 @@ func GetLzProductPriceData() (err error) {
|
|
|
fmt.Println("存在", n.PriceDate, n.Id)
|
|
|
} else {
|
|
|
item := new(models.Longzhongpricedata)
|
|
|
- item.LongzhongpriceinfoId=infoItem.LongzhongpriceinfoId
|
|
|
+ item.LongzhongpriceinfoId=v.LongzhongpriceinfoId
|
|
|
item.PriceDate=n.PriceDate
|
|
|
item.Memo=n.Memo
|
|
|
item.Price=n.Price
|
|
@@ -789,7 +768,6 @@ func GetLzProductPriceData() (err error) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
return
|
|
|
-}
|
|
|
+}
|