Merge branch 'oa' into dev

main
jhc 1 year ago
commit 520b11b369

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

@ -185,6 +185,29 @@ func ExistPayApproval(in *approval.CreateRequest) bool {
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) {
var entity *Approval
@ -549,7 +572,7 @@ func MyAllWorkApprovals(in *approval.ListRequest) ([]*Approval, int64) {
modelObj = modelObj.Where(&Approval{Type: in.Type}).Where(
DB.Where(&Approval{NowUserId: in.UserID, Status: StatusDoing}). // 我需要审批的
Or(DB.Where("status = ?", StatusOk).Where("id in (?)", s1))) // 已完成,抄送给我的
Or(DB.Where("status = ?", StatusOk).Where("id in (?)", s1))) // 已完成,抄送给我的
modelObj.Count(&count)
if len(ids) > 0 { //根据具体id排序
@ -596,8 +619,8 @@ func MyApprovalWorkApprovals(in *approval.ListRequest) ([]*Approval, int64) {
if in.UserID != 0 {
modelObj = modelObj.Where(
DB.Where("JSON_CONTAINS(approval_users,JSON_OBJECT('ID', ?))", in.UserID).
Where("status != ?", StatusDoing). //完成,我参与审批
Or(DB.Where("now_user_id", in.UserID).Where("status = ?", StatusDoing)). //进行中,当前审批人是我,
Where("status != ?", StatusDoing). //完成,我参与审批
Or(DB.Where("now_user_id", in.UserID).Where("status = ?", StatusDoing)). //进行中,当前审批人是我,
Or(DB.Where("JSON_CONTAINS(copy_users,JSON_OBJECT('ID', ?))", in.UserID).Where("status = ?", StatusOk))) //抄送人(完成抄送)
}
@ -655,8 +678,8 @@ func MyWorkApprovals(in *approval.ListRequest) ([]*Approval, int64) {
if in.UserID != 0 {
modelObj = modelObj.Where(
DB.Where("JSON_CONTAINS(approval_users,JSON_OBJECT('ID', ?))", in.UserID).
Where("status != ?", StatusDoing). //完成,我参与审批
Or(DB.Where("now_user_id", in.UserID).Where("status = ?", StatusDoing)). //进行中,当前审批人是我,
Where("status != ?", StatusDoing). //完成,我参与审批
Or(DB.Where("now_user_id", in.UserID).Where("status = ?", StatusDoing)). //进行中,当前审批人是我,
Or(DB.Where("JSON_CONTAINS(copy_users,JSON_OBJECT('ID', ?))", in.UserID).Where("status = ?", StatusOk))) //抄送人(完成抄送)
}

@ -39,7 +39,7 @@ type LeaveApply struct {
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"`
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:状态(目前和审批系统状态同步)"`
VerifyFile VerifyFiles `json:"verifyFile" gorm:"column:verify_file;type:json;comment:证明文件(图片|pdf)"`
ApprovalUsers ApprovalUsers `json:"approvalUsers" gorm:"column:approval_users;type:json;comment:审批人"`
@ -264,6 +264,23 @@ var sonMap = map[string]string{
"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 {
return sonMap[k]
}

@ -64,6 +64,7 @@ var TypeMap = map[string]string{
"paternityLeaveApply": "oa", // 陪产假申请
"parentalLeaveApply": "oa", // 育儿假申请
"nursingLeaveApply": "oa", // 独生子女护理假申请
"funeralLeaveApply": "oa", // 丧假
"financialFormApply": "", // 财务表单审批
@ -102,6 +103,7 @@ var keyWordMap = map[string]string{
"陪产假申请": "paternityLeaveApply", // 陪产假申请
"育儿假申请": "parentalLeaveApply", // 育儿假申请
"独生子女护理假申请": "nursingLeaveApply", // 独生子女护理假申请
"丧假申请": "funeralLeaveApply", // 独生子女护理假申请
"财务表单审批": "financialFormApply", // 财务表单审批
@ -197,6 +199,7 @@ var OaTypeMap = map[string]string{
"paternityLeaveApply": "leaveApply", // 陪产假申请
"parentalLeaveApply": "leaveApply", // 育儿假申请
"nursingLeaveApply": "leaveApply", // 独生子女护理假申请
"funeralLeaveApply": "leaveApply", // 丧假申请
}
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)
if err != nil {
return response, err

Loading…
Cancel
Save