作者 yangfu

fix: 休息时长统计修改

... ... @@ -5,7 +5,7 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils"
)
var Configurator utils.Configurator = utils.EnvConfigurator{}
var Configurator utils.Configurator = utils.EnvConfigurator{} //utils.NewConfig("ini","config/app_test.conf")
var SERVICE_NAME = "allied-creation-manufacture"
var SERVICE_ENV = "dev"
... ...
... ... @@ -181,12 +181,12 @@ func (productAttendanceRecord *ProductAttendanceRecord) AttendanceBreakTime(prod
var (
checkSignIn, checkSignOut time.Time
)
checkSignIn = v.GetCheckBeginTime(signIn)
checkSignOut = v.GetCheckEndTime(signIn)
checkSignIn = v.GetCheckBeginTime(signIn.Local())
checkSignOut = v.GetCheckEndTime(signIn.Local())
if xtime.BeforeEqual(signIn.Local(), checkSignIn) && xtime.AfterEqual(signOut.Local(), checkSignOut) {
bt += v.BreakTime
}
log.Logger.Debug(fmt.Sprintf("range(%v,%v) actual(%v,%v)", checkSignIn, checkSignOut, signIn.Local(), signOut.Local()))
log.Logger.Debug(fmt.Sprintf("range(%v,%v) actual(%v,%v) break_time:%v", checkSignIn, checkSignOut, signIn.Local(), signOut.Local(), bt))
}
if productAttendanceRecord.Ext != nil && productAttendanceRecord.Ext.AttendanceExt != nil {
productAttendanceRecord.Ext.AttendanceExt.BreakTime = bt
... ...
... ... @@ -25,8 +25,8 @@ func TestComputeWorkTimeBefore(t *testing.T) {
[]*ProductAttendanceRecord{
{
SignIn: xtime.MustParse("2022-05-05 09:00:00"),
SignOut: xtime.MustParse("2022-05-05 12:00:00"),
WorkTimeBefore: 2,
SignOut: xtime.MustParse("2022-05-05 13:00:00"),
WorkTimeBefore: 3,
},
{
SignIn: xtime.MustParse("2022-05-05 12:00:00"),
... ...
package utils
import (
"github.com/beego/beego/v2/core/config"
"github.com/beego/beego/v2/server/web"
"os"
"strconv"
... ... @@ -65,7 +66,8 @@ func (c EnvConfigurator) DefaultFloat(key string, defaultVal float64) float64 {
}
// BeegoAppConfigurator read config from beego config file with default value
type BeegoAppConfigurator struct{}
type BeegoAppConfigurator struct {
}
func (c BeegoAppConfigurator) DefaultString(key string, defaultVal string) string {
return web.AppConfig.DefaultString(key, defaultVal)
... ... @@ -82,3 +84,11 @@ func (c BeegoAppConfigurator) DefaultBool(key string, defaultVal bool) bool {
func (c BeegoAppConfigurator) DefaultFloat(key string, defaultVal float64) float64 {
return web.AppConfig.DefaultFloat(key, defaultVal)
}
func NewConfig(adapterName, filename string) Configurator {
config, err := config.NewConfig(adapterName, filename)
if err != nil {
panic(err)
}
return config
}
... ...