浏览代码

请假时长修改

huangyan 1 周之前
父节点
当前提交
e1ac470706
共有 3 个文件被更改,包括 16 次插入17 次删除
  1. 2 4
      Z_Build.bat
  2. 9 8
      controllers/Leave.go
  3. 5 5
      models/Attendance/Attendance.go

+ 2 - 4
Z_Build.bat

@@ -1,10 +1,8 @@
 cd %~dp0
 set GOARCH=amd64
 set GOOS=linux
-set GOPATH=C:\Users\SIKED\go
+set GOPATH=E:\gopath
 set GO111MODULE=auto
 
-go build main.go
-
-
 
+go build -o ERP_ams6701 main.go

+ 9 - 8
controllers/Leave.go

@@ -388,11 +388,13 @@ func (c *LeaveController) Leave_Duration() {
 		c.ServeJSON()
 		return
 	}
+
+	// 新的工作时间规则:早上8:30上班,下午5:30下班
 	endTime2 := time.Date(endTime.Year(), endTime.Month(), endTime.Day()-1, 17, 30, 0, 0, time.Local)
-	endTime3 := time.Date(endTime.Year(), endTime.Month(), endTime.Day(), 9, 0, 0, 0, time.Local)
+	endTime3 := time.Date(endTime.Year(), endTime.Month(), endTime.Day(), 8, 30, 0, 0, time.Local)
 
 	endTime4 := time.Date(endTime.Year(), endTime.Month(), endTime.Day(), 17, 30, 0, 0, time.Local)
-	endTime5 := time.Date(endTime.Year(), endTime.Month(), endTime.Day()+1, 9, 0, 0, 0, time.Local)
+	endTime5 := time.Date(endTime.Year(), endTime.Month(), endTime.Day()+1, 8, 30, 0, 0, time.Local)
 	if endTime.After(endTime2) && endTime.Before(endTime3) {
 		endTime = endTime2
 	}
@@ -402,10 +404,10 @@ func (c *LeaveController) Leave_Duration() {
 	}
 
 	startTime2 := time.Date(startTime.Year(), startTime.Month(), startTime.Day()-1, 17, 30, 0, 0, time.Local)
-	startTime3 := time.Date(startTime.Year(), startTime.Month(), startTime.Day(), 9, 0, 0, 0, time.Local)
+	startTime3 := time.Date(startTime.Year(), startTime.Month(), startTime.Day(), 8, 30, 0, 0, time.Local)
 
 	startTime4 := time.Date(startTime.Year(), startTime.Month(), startTime.Day(), 17, 30, 0, 0, time.Local)
-	startTime5 := time.Date(startTime.Year(), startTime.Month(), startTime.Day()+1, 9, 0, 0, 0, time.Local)
+	startTime5 := time.Date(startTime.Year(), startTime.Month(), startTime.Day()+1, 8, 30, 0, 0, time.Local)
 	if startTime.After(startTime2) && startTime.Before(startTime3) {
 		startTime = startTime3
 	}
@@ -420,7 +422,7 @@ func (c *LeaveController) Leave_Duration() {
 		return
 	}
 
-	//开始时间的小时和分钟
+	// 开始时间的小时和分钟
 	s_h := startTime.Hour()
 	s_mm := startTime.Minute()
 	e_h := endTime.Hour()
@@ -437,7 +439,7 @@ func (c *LeaveController) Leave_Duration() {
 	diff_minutes = float32(e_mm - s_mm)
 	if diff_day > 1 {
 		// 跨天
-		diff_hours = 17.5 - float32(s_h) + float32(e_h-9)
+		diff_hours = 17.5 - (float32(s_h) - 8.5) + (float32(e_h) - 8.5)
 		// 如果开始时间小于12点 请假小时数-1
 		// 如果结束时间大于13点,请假小时数-1
 		if s_h <= 12 {
@@ -453,12 +455,11 @@ func (c *LeaveController) Leave_Duration() {
 		if s_h <= 12 && e_h >= 13 {
 			diff_hours = float32(e_h - s_h - 1)
 		}
-
 	}
 	if diff_day > 1 {
 		diff_day -= 1
 	}
-	diff_day_hours := float32(diff_day) * 7.5
+	diff_day_hours := float32(diff_day) * 8.0                    // 每天工作时长调整为8小时
 	diff_m := int((diff_day_hours+diff_hours)*60 + diff_minutes) // 分钟数量
 
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: diff_m}

+ 5 - 5
models/Attendance/Attendance.go

@@ -379,7 +379,7 @@ func GetRemainingDaysOff(T_uuid string) int {
 	return duration
 }
 
-// 计算请假时长 返回分钟数
+// GetLeaveDuration 计算请假时长 返回分钟数
 // 规则:早上9:00 下午17:30 午休1小时不计入请假时长
 func GetLeaveDuration(startTime, endTime time.Time) int {
 	//开始时间的小时和分钟
@@ -391,9 +391,9 @@ func GetLeaveDuration(startTime, endTime time.Time) int {
 	var diff_hours float32                               // 间隔小时
 	var diff_minutes float32                             // 间隔分钟
 	if s_h < 9 {
-		// 开始小时早于9点,从9点起算
-		s_h = 9
-		s_mm = 0
+		// 开始小时早于8点30,从9点30起算
+		s_h = 8
+		s_mm = 30
 	}
 	if e_h > 17 && e_mm > 30 {
 		// 结束时间晚于17:30点,到17:30点止
@@ -429,7 +429,7 @@ func GetLeaveDuration(startTime, endTime time.Time) int {
 	if diff_day > 1 {
 		diff_day -= 1
 	}
-	diff_day_hours := float32(diff_day) * 7.5
+	diff_day_hours := float32(diff_day) * 8
 	diff := int((diff_day_hours+diff_hours)*60 + diff_minutes) // 分钟数量
 
 	return diff