京西平台和其他平台商品的对比
This commit is contained in:
@@ -2,6 +2,7 @@ package cms
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
"fmt"
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||||
@@ -11,6 +12,7 @@ import (
|
|||||||
"git.rosy.net.cn/baseapi"
|
"git.rosy.net.cn/baseapi"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/excel"
|
"git.rosy.net.cn/jx-callback/business/jxutils/excel"
|
||||||
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -198,16 +200,14 @@ func CompareJxAndVendor(vendorID int, storeIDStr, vendorStoreID, storeName strin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func CheckSkuDiffBetweenJxAndVendor(vendorIDList []string, storeIDList []string) {
|
func CheckSkuDiffBetweenJxAndVendor(vendorIDList []int, storeIDList []int) {
|
||||||
startProcessTime := time.Now().Unix()
|
startProcessTime := time.Now().Unix()
|
||||||
vendorMap := make(map[int]bool)
|
vendorMap := make(map[int]bool)
|
||||||
for _, value := range vendorIDList {
|
for _, vendorID := range vendorIDList {
|
||||||
vendorID := int(utils.Str2Int64(value))
|
|
||||||
vendorMap[vendorID] = true
|
vendorMap[vendorID] = true
|
||||||
}
|
}
|
||||||
storeIDMap := make(map[int]bool)
|
storeIDMap := make(map[int]bool)
|
||||||
for _, value := range storeIDList {
|
for _, storeID := range storeIDList {
|
||||||
storeID := int(utils.Str2Int64(value))
|
|
||||||
storeIDMap[storeID] = true
|
storeIDMap[storeID] = true
|
||||||
}
|
}
|
||||||
baseapi.SugarLogger.Debugf("CheckSkuDiffBetweenJxAndVendor start time: %v", time.Now())
|
baseapi.SugarLogger.Debugf("CheckSkuDiffBetweenJxAndVendor start time: %v", time.Now())
|
||||||
@@ -218,6 +218,9 @@ func CheckSkuDiffBetweenJxAndVendor(vendorIDList []string, storeIDList []string)
|
|||||||
} else {
|
} else {
|
||||||
GetJdAllSkuInfo()
|
GetJdAllSkuInfo()
|
||||||
diffData = make(map[int][]DiffData)
|
diffData = make(map[int][]DiffData)
|
||||||
|
taskSeqFunc := func(task *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) {
|
||||||
|
switch step {
|
||||||
|
case 0:
|
||||||
taskFunc := func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
taskFunc := func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||||
jxStoreInfoListValue := batchItemList[0].(*StoreExt)
|
jxStoreInfoListValue := batchItemList[0].(*StoreExt)
|
||||||
storeID := jxStoreInfoListValue.ID
|
storeID := jxStoreInfoListValue.ID
|
||||||
@@ -272,21 +275,27 @@ func CheckSkuDiffBetweenJxAndVendor(vendorIDList []string, storeIDList []string)
|
|||||||
}
|
}
|
||||||
return retVal, err
|
return retVal, err
|
||||||
}
|
}
|
||||||
task := tasksch.NewParallelTask("CheckSkuDiffBetweenJxAndVendor", tasksch.NewParallelConfig().SetParallelCount(parallelCount), ctx, taskFunc, jxStoreInfoList.Stores)
|
taskParallel := tasksch.NewParallelTask("CheckSkuDiffBetweenJxAndVendor", tasksch.NewParallelConfig().SetParallelCount(parallelCount), ctx, taskFunc, jxStoreInfoList.Stores)
|
||||||
tasksch.HandleTask(task, nil, false).Run()
|
tasksch.HandleTask(taskParallel, task, false).Run()
|
||||||
_, err = task.GetResult(0)
|
_, err = taskParallel.GetResult(0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
baseapi.SugarLogger.Debugf("CheckSkuDiffBetweenJxAndVendor tasksch error:%v", err)
|
baseapi.SugarLogger.Debugf("CheckSkuDiffBetweenJxAndVendor taskParallel error:%v", err)
|
||||||
}
|
}
|
||||||
WriteToExcel(diffData)
|
case 1:
|
||||||
|
WriteToExcel(task, diffData)
|
||||||
endProcessTime := time.Now().Unix()
|
endProcessTime := time.Now().Unix()
|
||||||
diff := endProcessTime - startProcessTime
|
diff := endProcessTime - startProcessTime
|
||||||
baseapi.SugarLogger.Debugf("CheckSkuDiffBetweenJxAndVendor end time: %v", time.Now())
|
baseapi.SugarLogger.Debugf("CheckSkuDiffBetweenJxAndVendor end time: %v", time.Now())
|
||||||
baseapi.SugarLogger.Debugf("CheckSkuDiffBetweenJxAndVendor cost time: %d sec", diff)
|
baseapi.SugarLogger.Debugf("CheckSkuDiffBetweenJxAndVendor cost time: %d sec", diff)
|
||||||
}
|
}
|
||||||
|
return result, err
|
||||||
|
}
|
||||||
|
taskSeq := tasksch.NewSeqTask("CheckSkuDiffBetweenJxAndVendor SeqTask", ctx, taskSeqFunc, 2)
|
||||||
|
tasksch.HandleTask(taskSeq, nil, false).Run()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func WriteToExcel(data map[int][]DiffData) {
|
func WriteToExcel(task *tasksch.SeqTask, data map[int][]DiffData) {
|
||||||
var sheetList []*excel.Obj2ExcelSheetConfig
|
var sheetList []*excel.Obj2ExcelSheetConfig
|
||||||
for key, value := range data {
|
for key, value := range data {
|
||||||
sheetName := vendorNameList[key]
|
sheetName := vendorNameList[key]
|
||||||
@@ -310,6 +319,8 @@ func WriteToExcel(data map[int][]DiffData) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
baseapi.SugarLogger.Errorf("WriteToExcel:upload %s failed error:%v", diffFullFileName, err)
|
baseapi.SugarLogger.Errorf("WriteToExcel:upload %s failed error:%v", diffFullFileName, err)
|
||||||
} else {
|
} else {
|
||||||
|
noticeMsg := fmt.Sprintf("[详情点我](%s/billshow/?normal=true&path=%s) \n", globals.BackstageHost, downloadURL)
|
||||||
|
task.SetNoticeMsg(noticeMsg)
|
||||||
baseapi.SugarLogger.Debugf("WriteToExcel:upload %s success, downloadURL:%s", diffFullFileName, downloadURL)
|
baseapi.SugarLogger.Debugf("WriteToExcel:upload %s success, downloadURL:%s", diffFullFileName, downloadURL)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package controllers
|
package controllers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
|
||||||
"git.rosy.net.cn/baseapi/platformapi/ebaiapi"
|
"git.rosy.net.cn/baseapi/platformapi/ebaiapi"
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxstore/tempop"
|
"git.rosy.net.cn/jx-callback/business/jxstore/tempop"
|
||||||
@@ -296,22 +295,19 @@ func (c *TempOpController) TestStartOrEndOpStore() {
|
|||||||
// @Title 京西平台和其他平台商品的对比
|
// @Title 京西平台和其他平台商品的对比
|
||||||
// @Description 京西平台和其他平台商品的对比
|
// @Description 京西平台和其他平台商品的对比
|
||||||
// @Param token header string true "认证token"
|
// @Param token header string true "认证token"
|
||||||
// @Param vendorIDList query string false "运营商ID列表(京东0 美团1 饿百3)"
|
// @Param vendorIDs formData string false "运营商ID列表(京东0 美团1 饿百3)"
|
||||||
// @Param storeIDList query string false "京西门店ID列表"
|
// @Param storeIDs formData string false "京西门店ID列表"
|
||||||
// @Success 200 {object} controllers.CallResult
|
// @Success 200 {object} controllers.CallResult
|
||||||
// @Failure 200 {object} controllers.CallResult
|
// @Failure 200 {object} controllers.CallResult
|
||||||
// @router /CheckSkuDiffBetweenJxAndVendor [get]
|
// @router /CheckSkuDiffBetweenJxAndVendor [post]
|
||||||
func (c *TempOpController) CheckSkuDiffBetweenJxAndVendor() {
|
func (c *TempOpController) CheckSkuDiffBetweenJxAndVendor() {
|
||||||
c.callCheckSkuDiffBetweenJxAndVendor(func(params *tTempopCheckSkuDiffBetweenJxAndVendorParams) (retVal interface{}, errCode string, err error) {
|
c.callCheckSkuDiffBetweenJxAndVendor(func(params *tTempopCheckSkuDiffBetweenJxAndVendorParams) (retVal interface{}, errCode string, err error) {
|
||||||
var vendorIDList []string
|
var vendorIDList []int
|
||||||
if params.VendorIDList != "" {
|
var storeIDList []int
|
||||||
vendorIDList = strings.Split(params.VendorIDList, ",")
|
if err = jxutils.Strings2Objs(params.VendorIDs, &vendorIDList, params.StoreIDs, &storeIDList); err == nil {
|
||||||
}
|
|
||||||
var storeIDList []string
|
|
||||||
if params.StoreIDList != "" {
|
|
||||||
storeIDList = strings.Split(params.StoreIDList, ",")
|
|
||||||
}
|
|
||||||
cms.CheckSkuDiffBetweenJxAndVendor(vendorIDList, storeIDList)
|
cms.CheckSkuDiffBetweenJxAndVendor(vendorIDList, storeIDList)
|
||||||
|
}
|
||||||
|
|
||||||
return retVal, "", err
|
return retVal, "", err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1658,7 +1658,7 @@ func init() {
|
|||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "CheckSkuDiffBetweenJxAndVendor",
|
Method: "CheckSkuDiffBetweenJxAndVendor",
|
||||||
Router: `/CheckSkuDiffBetweenJxAndVendor`,
|
Router: `/CheckSkuDiffBetweenJxAndVendor`,
|
||||||
AllowHTTPMethods: []string{"get"},
|
AllowHTTPMethods: []string{"post"},
|
||||||
MethodParams: param.Make(),
|
MethodParams: param.Make(),
|
||||||
Filters: nil,
|
Filters: nil,
|
||||||
Params: nil})
|
Params: nil})
|
||||||
|
|||||||
Reference in New Issue
Block a user