|
@@ -5,12 +5,12 @@ import (
|
|
"ERP_ams/conf"
|
|
"ERP_ams/conf"
|
|
"ERP_ams/models/Account"
|
|
"ERP_ams/models/Account"
|
|
"ERP_ams/models/Attendance"
|
|
"ERP_ams/models/Attendance"
|
|
|
|
+ "fmt"
|
|
userlibs "git.baozhida.cn/ERP_libs/User"
|
|
userlibs "git.baozhida.cn/ERP_libs/User"
|
|
"git.baozhida.cn/ERP_libs/lib"
|
|
"git.baozhida.cn/ERP_libs/lib"
|
|
beego "github.com/beego/beego/v2/server/web"
|
|
beego "github.com/beego/beego/v2/server/web"
|
|
"math"
|
|
"math"
|
|
"strconv"
|
|
"strconv"
|
|
- "time"
|
|
|
|
)
|
|
)
|
|
|
|
|
|
type OvertimeController struct {
|
|
type OvertimeController struct {
|
|
@@ -34,21 +34,10 @@ func (c *OvertimeController) Overtime_List() {
|
|
if page_z < 1 {
|
|
if page_z < 1 {
|
|
page_z = conf.Page_size
|
|
page_z = conf.Page_size
|
|
}
|
|
}
|
|
- // 年月 2023-01
|
|
|
|
- T_month := c.GetString("T_month")
|
|
|
|
-
|
|
|
|
- if len(T_month) > 0 {
|
|
|
|
- _, err := time.Parse("2006-01", T_month)
|
|
|
|
- if err != nil {
|
|
|
|
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "日期格式错误!"}
|
|
|
|
- c.ServeJSON()
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
|
|
userList, _ := NatsServer.Read_User_List_All()
|
|
userList, _ := NatsServer.Read_User_List_All()
|
|
Account.Read_User_All_Map(userList)
|
|
Account.Read_User_All_Map(userList)
|
|
- r_jsons.Data, r_jsons.Num = Attendance.Read_Attendance_List("", c.User.T_uuid, T_month, 1, Attendance.AttendanceWaitAudit, page, page_z)
|
|
|
|
|
|
+ r_jsons.Data, r_jsons.Num = Attendance.Read_Attendance_List("", c.User.T_uuid, 1, Attendance.AttendanceWaitAudit, page, page_z)
|
|
r_jsons.Page = page
|
|
r_jsons.Page = page
|
|
r_jsons.Page_size = int(math.Ceil(float64(r_jsons.Num) / float64(page_z)))
|
|
r_jsons.Page_size = int(math.Ceil(float64(r_jsons.Num) / float64(page_z)))
|
|
|
|
|
|
@@ -74,17 +63,9 @@ func (c *OvertimeController) Overtime_User_List() {
|
|
if len(T_uuid) == 0 {
|
|
if len(T_uuid) == 0 {
|
|
T_uuid = c.User.T_uuid
|
|
T_uuid = c.User.T_uuid
|
|
}
|
|
}
|
|
- // 年月 2023-01
|
|
|
|
- T_month := c.GetString("T_month")
|
|
|
|
- if len(T_month) > 0 {
|
|
|
|
- _, err := time.Parse("2006-01", T_month)
|
|
|
|
- if err != nil {
|
|
|
|
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "日期格式错误!"}
|
|
|
|
- c.ServeJSON()
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- r_jsons.Data, r_jsons.Num = Attendance.Read_Attendance_List(T_uuid, "", T_month, 1, 0, page, page_z)
|
|
|
|
|
|
+ userList, _ := NatsServer.Read_User_List_All()
|
|
|
|
+ Account.Read_User_All_Map(userList)
|
|
|
|
+ r_jsons.Data, r_jsons.Num = Attendance.Read_Attendance_List(T_uuid, "", 1, 0, page, page_z)
|
|
r_jsons.Page = page
|
|
r_jsons.Page = page
|
|
r_jsons.Page_size = int(math.Ceil(float64(r_jsons.Num) / float64(page_z)))
|
|
r_jsons.Page_size = int(math.Ceil(float64(r_jsons.Num) / float64(page_z)))
|
|
|
|
|
|
@@ -95,9 +76,8 @@ func (c *OvertimeController) Overtime_User_List() {
|
|
|
|
|
|
func (c *OvertimeController) Overtime_Add() {
|
|
func (c *OvertimeController) Overtime_Add() {
|
|
T_start_time := c.GetString("T_start_time")
|
|
T_start_time := c.GetString("T_start_time")
|
|
- T_start_prove := c.GetString("T_start_prove")
|
|
|
|
|
|
+ T_prove_img := c.GetString("T_prove_img")
|
|
T_end_time := c.GetString("T_end_time")
|
|
T_end_time := c.GetString("T_end_time")
|
|
- T_end_prove := c.GetString("T_end_prove")
|
|
|
|
T_duration, _ := c.GetInt("T_duration")
|
|
T_duration, _ := c.GetInt("T_duration")
|
|
T_text := c.GetString("T_text")
|
|
T_text := c.GetString("T_text")
|
|
T_approver := c.GetString("T_approver")
|
|
T_approver := c.GetString("T_approver")
|
|
@@ -114,16 +94,15 @@ func (c *OvertimeController) Overtime_Add() {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
var_ := Attendance.Attendance{
|
|
var_ := Attendance.Attendance{
|
|
- T_uid: c.User.T_uuid,
|
|
|
|
- T_type: Attendance.AttendanceOvertime,
|
|
|
|
- T_start_time: startTime,
|
|
|
|
- T_start_prove: T_start_prove,
|
|
|
|
- T_end_time: endTime,
|
|
|
|
- T_end_prove: T_end_prove,
|
|
|
|
- T_duration: T_duration,
|
|
|
|
- T_text: T_text,
|
|
|
|
- T_approver: T_approver,
|
|
|
|
- T_State: Attendance.AttendanceWaitAudit,
|
|
|
|
|
|
+ T_uid: c.User.T_uuid,
|
|
|
|
+ T_type: Attendance.AttendanceOvertime,
|
|
|
|
+ T_start_time: startTime,
|
|
|
|
+ T_prove_img: T_prove_img,
|
|
|
|
+ T_end_time: endTime,
|
|
|
|
+ T_duration: T_duration,
|
|
|
|
+ T_text: T_text,
|
|
|
|
+ T_approver: T_approver,
|
|
|
|
+ T_State: Attendance.AttendanceWaitAudit,
|
|
}
|
|
}
|
|
|
|
|
|
_, err := Attendance.Add_Attendance(var_)
|
|
_, err := Attendance.Add_Attendance(var_)
|
|
@@ -134,6 +113,7 @@ func (c *OvertimeController) Overtime_Add() {
|
|
}
|
|
}
|
|
|
|
|
|
NatsServer.AddUserLogs(c.User.T_uuid, "我的加班", "添加", var_)
|
|
NatsServer.AddUserLogs(c.User.T_uuid, "我的加班", "添加", var_)
|
|
|
|
+ NatsServer.AddNews(T_approver, fmt.Sprintf("您有一条【%s】的加班审批待处理", c.User.T_name), "/overtime")
|
|
|
|
|
|
c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: var_.Id}
|
|
c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: var_.Id}
|
|
c.ServeJSON()
|
|
c.ServeJSON()
|
|
@@ -144,9 +124,8 @@ func (c *OvertimeController) Overtime_Update() {
|
|
T_id, _ := c.GetInt("T_id")
|
|
T_id, _ := c.GetInt("T_id")
|
|
T_type, _ := c.GetInt("T_type")
|
|
T_type, _ := c.GetInt("T_type")
|
|
T_start_time := c.GetString("T_start_time")
|
|
T_start_time := c.GetString("T_start_time")
|
|
- T_start_prove := c.GetString("T_start_prove")
|
|
|
|
|
|
+ T_prove_img := c.GetString("T_prove_img")
|
|
T_end_time := c.GetString("T_end_time")
|
|
T_end_time := c.GetString("T_end_time")
|
|
- T_end_prove := c.GetString("T_end_prove")
|
|
|
|
T_duration, _ := c.GetInt("T_duration")
|
|
T_duration, _ := c.GetInt("T_duration")
|
|
T_text := c.GetString("T_text")
|
|
T_text := c.GetString("T_text")
|
|
T_approver := c.GetString("T_approver")
|
|
T_approver := c.GetString("T_approver")
|
|
@@ -159,7 +138,7 @@ func (c *OvertimeController) Overtime_Update() {
|
|
}
|
|
}
|
|
|
|
|
|
if leave.T_State == Attendance.AttendancePass {
|
|
if leave.T_State == Attendance.AttendancePass {
|
|
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "无权修改!"}
|
|
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "加班审批已通过,禁止修改!"}
|
|
c.ServeJSON()
|
|
c.ServeJSON()
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -178,9 +157,7 @@ func (c *OvertimeController) Overtime_Update() {
|
|
leave.T_start_time = startTime
|
|
leave.T_start_time = startTime
|
|
|
|
|
|
}
|
|
}
|
|
- if len(T_start_prove) > 0 {
|
|
|
|
- leave.T_start_prove = T_start_prove
|
|
|
|
- }
|
|
|
|
|
|
+ leave.T_prove_img = T_prove_img
|
|
|
|
|
|
if len(T_end_time) > 0 {
|
|
if len(T_end_time) > 0 {
|
|
endTime, is := lib.TimeStrToTime(T_end_time)
|
|
endTime, is := lib.TimeStrToTime(T_end_time)
|
|
@@ -191,9 +168,6 @@ func (c *OvertimeController) Overtime_Update() {
|
|
}
|
|
}
|
|
leave.T_end_time = endTime
|
|
leave.T_end_time = endTime
|
|
}
|
|
}
|
|
- if len(T_end_prove) > 0 {
|
|
|
|
- leave.T_end_prove = T_end_prove
|
|
|
|
- }
|
|
|
|
|
|
|
|
if T_duration > 0 {
|
|
if T_duration > 0 {
|
|
leave.T_duration = T_duration
|
|
leave.T_duration = T_duration
|
|
@@ -207,7 +181,7 @@ func (c *OvertimeController) Overtime_Update() {
|
|
}
|
|
}
|
|
leave.T_State = Attendance.AttendanceWaitAudit
|
|
leave.T_State = Attendance.AttendanceWaitAudit
|
|
|
|
|
|
- _, err = Attendance.Update_Attendance(leave, "T_type", "T_start_time", "T_start_prove", "T_end_time", "T_end_prove", "T_duration", "T_text", "T_approver", "T_State")
|
|
|
|
|
|
+ _, err = Attendance.Update_Attendance(leave, "T_type", "T_start_time", "T_prove_img", "T_end_time", "T_duration", "T_text", "T_approver", "T_State")
|
|
if err != nil {
|
|
if err != nil {
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: "添加失败"}
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: "添加失败"}
|
|
c.ServeJSON()
|
|
c.ServeJSON()
|
|
@@ -254,6 +228,7 @@ func (c *OvertimeController) Overtime_Approval() {
|
|
}
|
|
}
|
|
|
|
|
|
NatsServer.AddUserLogs(c.User.T_uuid, "加班审批", "审批", leave)
|
|
NatsServer.AddUserLogs(c.User.T_uuid, "加班审批", "审批", leave)
|
|
|
|
+ NatsServer.AddNews(leave.T_uid, "您的加班申请已通过", "/myOvertime")
|
|
|
|
|
|
c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: id}
|
|
c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: id}
|
|
c.ServeJSON()
|
|
c.ServeJSON()
|
|
@@ -272,7 +247,7 @@ func (c *OvertimeController) Overtime_Del() {
|
|
}
|
|
}
|
|
|
|
|
|
if leave.T_State == Attendance.AttendancePass {
|
|
if leave.T_State == Attendance.AttendancePass {
|
|
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "无权删除!"}
|
|
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "加班审批已通过,禁止删除!"}
|
|
c.ServeJSON()
|
|
c.ServeJSON()
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -302,23 +277,20 @@ func (c *OvertimeController) Overtime_Stat() {
|
|
if page_z < 1 {
|
|
if page_z < 1 {
|
|
page_z = conf.Page_size
|
|
page_z = conf.Page_size
|
|
}
|
|
}
|
|
- // 年月 2023-01
|
|
|
|
- T_month := c.GetString("T_month")
|
|
|
|
- if len(T_month) > 0 {
|
|
|
|
- _, err := time.Parse("2006-01", T_month)
|
|
|
|
- if err != nil {
|
|
|
|
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "日期格式错误!"}
|
|
|
|
- c.ServeJSON()
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
|
|
+ T_uuid := c.GetString("T_uuid")
|
|
|
|
+ if len(T_uuid) == 0 {
|
|
|
|
+ T_uuid = c.User.T_uuid
|
|
}
|
|
}
|
|
|
|
|
|
- attendance, cnt := Attendance.Read_Attendance_List_For_Stat(c.User.T_uuid, T_month, page, page_z)
|
|
|
|
|
|
+ attendance, cnt := Attendance.Read_Attendance_List_For_Stat(T_uuid, page, page_z)
|
|
|
|
|
|
|
|
+ userList, _ := NatsServer.Read_User_List_All()
|
|
|
|
+ Account.Read_User_All_Map(userList)
|
|
var duration int
|
|
var duration int
|
|
for i := 0; i < len(attendance); i++ {
|
|
for i := 0; i < len(attendance); i++ {
|
|
if attendance[i].T_type == Attendance.AttendanceDaysOff || attendance[i].T_type == Attendance.AttendanceShiftPerf {
|
|
if attendance[i].T_type == Attendance.AttendanceDaysOff || attendance[i].T_type == Attendance.AttendanceShiftPerf {
|
|
duration -= attendance[i].T_duration
|
|
duration -= attendance[i].T_duration
|
|
|
|
+ attendance[i].T_duration = -attendance[i].T_duration
|
|
} else {
|
|
} else {
|
|
duration += attendance[i].T_duration
|
|
duration += attendance[i].T_duration
|
|
}
|
|
}
|
|
@@ -329,7 +301,7 @@ func (c *OvertimeController) Overtime_Stat() {
|
|
type R_JSONS struct {
|
|
type R_JSONS struct {
|
|
//必须的大写开头
|
|
//必须的大写开头
|
|
Data interface{}
|
|
Data interface{}
|
|
- RemainingTime int
|
|
|
|
|
|
+ RemainingTime int // 剩余时长
|
|
Num int64
|
|
Num int64
|
|
Page int
|
|
Page int
|
|
Page_size int
|
|
Page_size int
|
|
@@ -337,7 +309,7 @@ func (c *OvertimeController) Overtime_Stat() {
|
|
|
|
|
|
var r_jsons R_JSONS
|
|
var r_jsons R_JSONS
|
|
r_jsons.Num = cnt
|
|
r_jsons.Num = cnt
|
|
- r_jsons.RemainingTime = duration
|
|
|
|
|
|
+ r_jsons.RemainingTime = Attendance.GetRemainingDaysOff(T_uuid)
|
|
r_jsons.Data = attendance
|
|
r_jsons.Data = attendance
|
|
r_jsons.Page = page
|
|
r_jsons.Page = page
|
|
r_jsons.Page_size = int(math.Ceil(float64(r_jsons.Num) / float64(page_z)))
|
|
r_jsons.Page_size = int(math.Ceil(float64(r_jsons.Num) / float64(page_z)))
|