package schedule

import (
	"time"
)

type WorkLoadSrv struct {
	LoadType         string
	StartTime        time.Time
	EndTime          time.Time
	AvailCapacity    time.Duration
	RestCapacity     time.Duration
	AvailCapacityStr string
	WorkLoadPercent  float64
}

func (wloadsrv *WorkLoadSrv) Init() {
	if wloadsrv.AvailCapacity <= 0 {
		wloadsrv.WorkLoadPercent = 0.0
		return
	}
	//fmt.Println()
	//fmt.Println(wloadsrv.AvailCapacity)
	//fmt.Println(wloadsrv.RestCapacity)
	//fmt.Println()
	//判断
	if wloadsrv.AvailCapacity < wloadsrv.RestCapacity{
		wloadsrv.RestCapacity = wloadsrv.AvailCapacity
	}
	// 时段负荷 = （可用能力 - 剩余能力）/可用能力
	wloadsrv.WorkLoadPercent = (wloadsrv.AvailCapacity.Seconds() - wloadsrv.RestCapacity.Seconds()) / wloadsrv.AvailCapacity.Seconds()
	return
}
