作者 yangfu

fix: 休息时长统计修改

@@ -5,7 +5,7 @@ import ( @@ -5,7 +5,7 @@ import (
5 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils" 5 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils"
6 ) 6 )
7 7
8 -var Configurator utils.Configurator = utils.EnvConfigurator{} 8 +var Configurator utils.Configurator = utils.EnvConfigurator{} //utils.NewConfig("ini","config/app_test.conf")
9 9
10 var SERVICE_NAME = "allied-creation-manufacture" 10 var SERVICE_NAME = "allied-creation-manufacture"
11 var SERVICE_ENV = "dev" 11 var SERVICE_ENV = "dev"
@@ -181,12 +181,12 @@ func (productAttendanceRecord *ProductAttendanceRecord) AttendanceBreakTime(prod @@ -181,12 +181,12 @@ func (productAttendanceRecord *ProductAttendanceRecord) AttendanceBreakTime(prod
181 var ( 181 var (
182 checkSignIn, checkSignOut time.Time 182 checkSignIn, checkSignOut time.Time
183 ) 183 )
184 - checkSignIn = v.GetCheckBeginTime(signIn)  
185 - checkSignOut = v.GetCheckEndTime(signIn) 184 + checkSignIn = v.GetCheckBeginTime(signIn.Local())
  185 + checkSignOut = v.GetCheckEndTime(signIn.Local())
186 if xtime.BeforeEqual(signIn.Local(), checkSignIn) && xtime.AfterEqual(signOut.Local(), checkSignOut) { 186 if xtime.BeforeEqual(signIn.Local(), checkSignIn) && xtime.AfterEqual(signOut.Local(), checkSignOut) {
187 bt += v.BreakTime 187 bt += v.BreakTime
188 } 188 }
189 - log.Logger.Debug(fmt.Sprintf("range(%v,%v) actual(%v,%v)", checkSignIn, checkSignOut, signIn.Local(), signOut.Local())) 189 + log.Logger.Debug(fmt.Sprintf("range(%v,%v) actual(%v,%v) break_time:%v", checkSignIn, checkSignOut, signIn.Local(), signOut.Local(), bt))
190 } 190 }
191 if productAttendanceRecord.Ext != nil && productAttendanceRecord.Ext.AttendanceExt != nil { 191 if productAttendanceRecord.Ext != nil && productAttendanceRecord.Ext.AttendanceExt != nil {
192 productAttendanceRecord.Ext.AttendanceExt.BreakTime = bt 192 productAttendanceRecord.Ext.AttendanceExt.BreakTime = bt
@@ -25,8 +25,8 @@ func TestComputeWorkTimeBefore(t *testing.T) { @@ -25,8 +25,8 @@ func TestComputeWorkTimeBefore(t *testing.T) {
25 []*ProductAttendanceRecord{ 25 []*ProductAttendanceRecord{
26 { 26 {
27 SignIn: xtime.MustParse("2022-05-05 09:00:00"), 27 SignIn: xtime.MustParse("2022-05-05 09:00:00"),
28 - SignOut: xtime.MustParse("2022-05-05 12:00:00"),  
29 - WorkTimeBefore: 2, 28 + SignOut: xtime.MustParse("2022-05-05 13:00:00"),
  29 + WorkTimeBefore: 3,
30 }, 30 },
31 { 31 {
32 SignIn: xtime.MustParse("2022-05-05 12:00:00"), 32 SignIn: xtime.MustParse("2022-05-05 12:00:00"),
1 package utils 1 package utils
2 2
3 import ( 3 import (
  4 + "github.com/beego/beego/v2/core/config"
4 "github.com/beego/beego/v2/server/web" 5 "github.com/beego/beego/v2/server/web"
5 "os" 6 "os"
6 "strconv" 7 "strconv"
@@ -65,7 +66,8 @@ func (c EnvConfigurator) DefaultFloat(key string, defaultVal float64) float64 { @@ -65,7 +66,8 @@ func (c EnvConfigurator) DefaultFloat(key string, defaultVal float64) float64 {
65 } 66 }
66 67
67 // BeegoAppConfigurator read config from beego config file with default value 68 // BeegoAppConfigurator read config from beego config file with default value
68 -type BeegoAppConfigurator struct{} 69 +type BeegoAppConfigurator struct {
  70 +}
69 71
70 func (c BeegoAppConfigurator) DefaultString(key string, defaultVal string) string { 72 func (c BeegoAppConfigurator) DefaultString(key string, defaultVal string) string {
71 return web.AppConfig.DefaultString(key, defaultVal) 73 return web.AppConfig.DefaultString(key, defaultVal)
@@ -82,3 +84,11 @@ func (c BeegoAppConfigurator) DefaultBool(key string, defaultVal bool) bool { @@ -82,3 +84,11 @@ func (c BeegoAppConfigurator) DefaultBool(key string, defaultVal bool) bool {
82 func (c BeegoAppConfigurator) DefaultFloat(key string, defaultVal float64) float64 { 84 func (c BeegoAppConfigurator) DefaultFloat(key string, defaultVal float64) float64 {
83 return web.AppConfig.DefaultFloat(key, defaultVal) 85 return web.AppConfig.DefaultFloat(key, defaultVal)
84 } 86 }
  87 +
  88 +func NewConfig(adapterName, filename string) Configurator {
  89 + config, err := config.NewConfig(adapterName, filename)
  90 + if err != nil {
  91 + panic(err)
  92 + }
  93 + return config
  94 +}