package task

import (
	jitServices "LAPP_ACURA_MOM_BACKEND/services/jit"
	services "LAPP_ACURA_MOM_BACKEND/services/pln"
)

var ParsedStatus int
var ParseToyotaCallOffFileStatus int
var ParseToyotaCallOffStatus int
var WriteDeliveryOrderDataStatus int
var ReadDeliveryOrderDataStatus int

// 解析hongda发运文件
func StartParseCallOff() {
	if ParsedStatus == 1 {
		return
	} else {
		ParsedStatus = 1
		defer func() {
			ParsedStatus = 0
		}()
	}
	svr := services.NewHondaCalloffService()
	svr.AnalysisTask()
}

func ParsedToyotaCallOffFile()  {
	if ParseToyotaCallOffFileStatus == 1 {
		return
	} else {
		ParseToyotaCallOffFileStatus = 1
		defer func() {
			ParseToyotaCallOffFileStatus = 0
		}()
	}
	svr := services.NewToyotaCalloffService()
	svr.ParseToyotaCallOffFile()
}


func ParsedToyotaCallOff() {
	if ParseToyotaCallOffStatus == 1 {
		return
	} else {
		ParseToyotaCallOffStatus = 1
		defer func() {
			ParseToyotaCallOffStatus = 0
		}()
	}
	svr := services.NewToyotaCalloffService()
	svr.ParseToyotaCallOffCache()
}

func WriteDeliveryOrderToPLC()  {
	if WriteDeliveryOrderDataStatus == 1 {
		return
	} else {
		WriteDeliveryOrderDataStatus = 1
		defer func() {
			WriteDeliveryOrderDataStatus = 0
		}()
	}
	svr := services.NewToyotaDeliveryOrderService()
	svr.WriteDeliveryDataToPLCTask()
}

func ReadDeliveryOrderDataFromPLC()  {
	if ReadDeliveryOrderDataStatus == 1 {
		return
	} else {
		ReadDeliveryOrderDataStatus = 1
		defer func() {
			ReadDeliveryOrderDataStatus = 0
		}()
	}
	svr := jitServices.NewPackOrderService()
	svr.ReadPLCBackFlushDataTask()
}