oa 审批 类型筛选

main
jhc 1 year ago
parent 9fc156be43
commit b58c70825f

@ -28,3 +28,9 @@ const (
const ( const (
ErrorOperate = "操作顺序错误" ErrorOperate = "操作顺序错误"
) )
// oa
const (
ErrorOnceAYear = "此审批类型已存在,请在下一年申请"
ErrorOnce = "此审批类型已存在,无法再次申请"
)

@ -185,6 +185,29 @@ func ExistPayApproval(in *approval.CreateRequest) bool {
return false return false
} }
// 余额申请 校验
func ExistLeaveApplyApproval(in *approval.CreateRequest) bool {
var count int64
// 校验 规则
// 一年一次 多次 一次
subQuery1 := DB.Model(&Approval{}).Where(&Approval{SubmitterID: in.SubmitterID, Type: in.Type}).
Where("status in (?)", []uint64{StatusDoing, StatusOk})
if LeaveBalanceUsefulTime[in.Type] == OnceAYear {
subQuery1.Where("DATE_FORMAT(created_at,%Y) = ?", time.Now().Format("2006"))
}
subQuery1.Select("id")
DB.Model(&ApprovalOA{}).Where("approval_id in (?)", subQuery1).Count(&count)
if count >= 1 {
return true
}
return false
}
func StoreApproval(in *approval.CreateRequest) (*Approval, error) { func StoreApproval(in *approval.CreateRequest) (*Approval, error) {
var entity *Approval var entity *Approval

@ -39,7 +39,7 @@ type LeaveApply struct {
ActionTime string `json:"actionTime" gorm:"column:action_time;type:varchar(255);comment:操作|申请时间"` ActionTime string `json:"actionTime" gorm:"column:action_time;type:varchar(255);comment:操作|申请时间"`
ApprovalID string `json:"approvalID" gorm:"column:approval_id;type:varchar(255);comment:审批系统中的approvalID"` ApprovalID string `json:"approvalID" gorm:"column:approval_id;type:varchar(255);comment:审批系统中的approvalID"`
Reason string `json:"reason" gorm:"column:reason;type:varchar(255);comment:理由"` Reason string `json:"reason" gorm:"column:reason;type:varchar(255);comment:理由"`
LeaveBalance int32 `json:"leaveBalance" gorm:"column:leave_balance;type:int;comment:假期余额"` LeaveBalance float32 `json:"leaveBalance" gorm:"column:leave_balance;type:int;comment:假期余额"`
Status int32 `json:"status" gorm:"column:status;type:int;comment:状态(目前和审批系统状态同步)"` Status int32 `json:"status" gorm:"column:status;type:int;comment:状态(目前和审批系统状态同步)"`
VerifyFile VerifyFiles `json:"verifyFile" gorm:"column:verify_file;type:json;comment:证明文件(图片|pdf)"` VerifyFile VerifyFiles `json:"verifyFile" gorm:"column:verify_file;type:json;comment:证明文件(图片|pdf)"`
ApprovalUsers ApprovalUsers `json:"approvalUsers" gorm:"column:approval_users;type:json;comment:审批人"` ApprovalUsers ApprovalUsers `json:"approvalUsers" gorm:"column:approval_users;type:json;comment:审批人"`
@ -264,6 +264,23 @@ var sonMap = map[string]string{
"nursingLeaveApply": "leaveApply", // 独生子女护理假申请 "nursingLeaveApply": "leaveApply", // 独生子女护理假申请
} }
var OnceAYear = "onceAYear"
var Once = "once"
var More = "more"
var LeaveBalanceUsefulTime = map[string]string{
"annualLeaveApply": "onceAYear", // 年假申请
"parentalLeaveApply": "onceAYear", // 育儿假申请
"nursingLeaveApply": "onceAYear", // 独生子女护理假申请
"matingCheckLeaveApply": "more", // 孕检假申请
"maternityLeaveApply": "more", // 产假申请
"paternityLeaveApply": "more", // 陪产假申请
"funeralLeaveApply": "more", // 丧假申请
"maritalLeaveApply": "once", // 婚假申请
}
func GetSonMapValue(k string) string { func GetSonMapValue(k string) string {
return sonMap[k] return sonMap[k]
} }

@ -64,6 +64,7 @@ var TypeMap = map[string]string{
"paternityLeaveApply": "oa", // 陪产假申请 "paternityLeaveApply": "oa", // 陪产假申请
"parentalLeaveApply": "oa", // 育儿假申请 "parentalLeaveApply": "oa", // 育儿假申请
"nursingLeaveApply": "oa", // 独生子女护理假申请 "nursingLeaveApply": "oa", // 独生子女护理假申请
"funeralLeaveApply": "oa", // 丧假
"financialFormApply": "", // 财务表单审批 "financialFormApply": "", // 财务表单审批
@ -102,6 +103,7 @@ var keyWordMap = map[string]string{
"陪产假申请": "paternityLeaveApply", // 陪产假申请 "陪产假申请": "paternityLeaveApply", // 陪产假申请
"育儿假申请": "parentalLeaveApply", // 育儿假申请 "育儿假申请": "parentalLeaveApply", // 育儿假申请
"独生子女护理假申请": "nursingLeaveApply", // 独生子女护理假申请 "独生子女护理假申请": "nursingLeaveApply", // 独生子女护理假申请
"丧假申请": "funeralLeaveApply", // 独生子女护理假申请
"财务表单审批": "financialFormApply", // 财务表单审批 "财务表单审批": "financialFormApply", // 财务表单审批
@ -197,6 +199,7 @@ var OaTypeMap = map[string]string{
"paternityLeaveApply": "leaveApply", // 陪产假申请 "paternityLeaveApply": "leaveApply", // 陪产假申请
"parentalLeaveApply": "leaveApply", // 育儿假申请 "parentalLeaveApply": "leaveApply", // 育儿假申请
"nursingLeaveApply": "leaveApply", // 独生子女护理假申请 "nursingLeaveApply": "leaveApply", // 独生子女护理假申请
"funeralLeaveApply": "leaveApply", // 丧假申请
} }
func GetOaType(k string) string { func GetOaType(k string) string {

@ -26,6 +26,16 @@ func (a *ApprovalProvider) Create(ctx context.Context, in *approval.CreateReques
} }
} }
if model.LeaveBalanceUsefulTime[in.Type] == model.OnceAYear || model.LeaveBalanceUsefulTime[in.Type] == model.Once {
if model.ExistLeaveApplyApproval(in) == true {
if model.LeaveBalanceUsefulTime[in.Type] == model.OnceAYear {
return response, errors.New(m.ErrorOnceAYear)
} else if model.LeaveBalanceUsefulTime[in.Type] == model.Once {
return response, errors.New(m.ErrorOnce)
}
}
}
entity, err := model.StoreApproval(in) entity, err := model.StoreApproval(in)
if err != nil { if err != nil {
return response, err return response, err

Loading…
Cancel
Save