package task

import (
	"LAPP_LF_MOM_BACKEND/conf"
	services "LAPP_LF_MOM_BACKEND/services/log"
	"strconv"
)


var transferToPortalTaskStatus int
var transferCacheDataToPortalTaskStatus int

/******************************************************************************
 *
 * @Struct Name              : TransferArtDemandToPortal
 *-----------------------------------------------------------------------------
 *
 * @Description              : 传输供应商数据到portal与服务器
 *
 * @Author                   : zhangxin
 *
 * @Date                     : 2021-05-12
 *
 ******************************************************************************/
func TransferArtDemandToPortal()  {
	if transferToPortalTaskStatus == 0 {
		transferToPortalTaskStatus = 1
		defer func() {
			transferToPortalTaskStatus = 0
		}()
	} else {
		return
	}
	plantNr := 100
	getTimeUrl := conf.DbConfig.PortalGetTimeUrl + "?plantNr=" + strconv.Itoa(plantNr)
	postFileUrl := conf.DbConfig.PortalPostFileUrl + "?plantNr=" + strconv.Itoa(plantNr)
	artDemandHeadService := services.NewArtDemandHeadService()
	artDemandHeadService.TransferDataToOrigin(getTimeUrl, postFileUrl, plantNr)
}


/******************************************************************************
 *
 * @Struct Name              : TransferArtDemandToPortal
 *-----------------------------------------------------------------------------
 *
 * @Description              : 传输供应商数据到portal与服务器
 *
 * @Author                   : zhangxin
 *
 * @Date                     : 2021-05-12
 *
 ******************************************************************************/
func TransferArtDemandCacheToPortal()  {
	if transferCacheDataToPortalTaskStatus == 0 {
		transferCacheDataToPortalTaskStatus = 1
		defer func() {
			transferCacheDataToPortalTaskStatus = 0
		}()
	} else {
		return
	}
	plantNr := 100
	postFileUrl := conf.DbConfig.PortalCachePostFileUrl + "?plantNr=" + strconv.Itoa(plantNr)
	artDemandHeadService := services.NewArtDemandHeadCacheService()
	artDemandHeadService.TransferCacheDataToOrigin(plantNr, postFileUrl)
}