feat: 添加角色处理人。
This commit is contained in:
parent
2e8eb41434
commit
5d7ca470a1
@ -93,7 +93,6 @@ func Paging(p *Param, result interface{}, args ...interface{}) (*Paginator, erro
|
|||||||
} else {
|
} else {
|
||||||
offset = (param.Page - 1) * param.PerPage
|
offset = (param.Page - 1) * param.PerPage
|
||||||
}
|
}
|
||||||
|
|
||||||
err := db.Limit(param.PerPage).Offset(offset).Scan(result).Error
|
err := db.Limit(param.PerPage).Offset(offset).Scan(result).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Errorf("数据查询失败,错误:%v", err)
|
logger.Errorf("数据查询失败,错误:%v", err)
|
||||||
|
@ -29,6 +29,13 @@ func GetPrincipal(processor []int, processMethod string) (principals string, err
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
case "role":
|
||||||
|
err = orm.Eloquent.Model(&system.SysRole{}).
|
||||||
|
Where("role_id in (?)", processor).
|
||||||
|
Pluck("role_name", &principalList).Error
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
//case "department":
|
//case "department":
|
||||||
// err = orm.Eloquent.Model(&user.Dept{}).Where("id in (?)", processor).Pluck("nickname", &principalList).Error
|
// err = orm.Eloquent.Model(&user.Dept{}).Where("id in (?)", processor).Pluck("nickname", &principalList).Error
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
|
@ -65,10 +65,12 @@ func fmtDuration(d time.Duration) string {
|
|||||||
// 会签
|
// 会签
|
||||||
func (h *Handle) Countersign(c *gin.Context) (err error) {
|
func (h *Handle) Countersign(c *gin.Context) (err error) {
|
||||||
var (
|
var (
|
||||||
stateList []map[string]interface{}
|
stateList []map[string]interface{}
|
||||||
stateIdMap map[string]interface{}
|
stateIdMap map[string]interface{}
|
||||||
currentState map[string]interface{}
|
currentState map[string]interface{}
|
||||||
cirHistoryCount int
|
cirHistoryCount int
|
||||||
|
roleUserInfo []system.SysUser
|
||||||
|
circulationStatus bool
|
||||||
)
|
)
|
||||||
|
|
||||||
err = json.Unmarshal(h.workOrderDetails.State, &stateList)
|
err = json.Unmarshal(h.workOrderDetails.State, &stateList)
|
||||||
@ -83,19 +85,82 @@ func (h *Handle) Countersign(c *gin.Context) (err error) {
|
|||||||
currentState = v
|
currentState = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
roleStatusCount := 0
|
||||||
|
circulationStatus = false
|
||||||
for _, cirHistoryValue := range h.cirHistoryList {
|
for _, cirHistoryValue := range h.cirHistoryList {
|
||||||
if _, ok := stateIdMap[cirHistoryValue.Source]; !ok {
|
if len(currentState["processor"].([]interface{})) > 1 {
|
||||||
break
|
if _, ok := stateIdMap[cirHistoryValue.Source]; !ok {
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for _, processor := range currentState["processor"].([]interface{}) {
|
|
||||||
if cirHistoryValue.ProcessorId != tools.GetUserId(c) &&
|
if currentState["process_method"].(string) == "person" {
|
||||||
cirHistoryValue.Source == currentState["id"].(string) &&
|
// 用户会签
|
||||||
cirHistoryValue.ProcessorId == int(processor.(float64)) {
|
for _, processor := range currentState["processor"].([]interface{}) {
|
||||||
cirHistoryCount += 1
|
if cirHistoryValue.ProcessorId != tools.GetUserId(c) &&
|
||||||
|
cirHistoryValue.Source == currentState["id"].(string) &&
|
||||||
|
cirHistoryValue.ProcessorId == int(processor.(float64)) {
|
||||||
|
cirHistoryCount += 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if cirHistoryCount == len(currentState["processor"].([]interface{}))-1 {
|
||||||
|
circulationStatus = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
} else if currentState["process_method"].(string) == "role" {
|
||||||
|
// 全员处理
|
||||||
|
var tmpUserList []system.SysUser
|
||||||
|
if h.stateValue["fullHandle"].(bool) {
|
||||||
|
err = orm.Eloquent.Model(&system.SysUser{}).
|
||||||
|
Where("role_id in (?)", currentState["processor"].([]interface{})).
|
||||||
|
Find(&roleUserInfo).Error
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
temp := map[string]struct{}{}
|
||||||
|
for _, user := range roleUserInfo {
|
||||||
|
if _, ok := temp[user.Username]; !ok {
|
||||||
|
temp[user.Username] = struct{}{}
|
||||||
|
tmpUserList = append(tmpUserList, user)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, user := range tmpUserList {
|
||||||
|
if cirHistoryValue.Source == currentState["id"].(string) &&
|
||||||
|
cirHistoryValue.ProcessorId != tools.GetUserId(c) &&
|
||||||
|
cirHistoryValue.ProcessorId == user.UserId {
|
||||||
|
roleStatusCount += 1
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 普通会签
|
||||||
|
for _, processor := range currentState["processor"].([]interface{}) {
|
||||||
|
err = orm.Eloquent.Model(&system.SysUser{}).Where("role_id = ?", processor).Find(&roleUserInfo).Error
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for _, user := range roleUserInfo {
|
||||||
|
if user.UserId != tools.GetUserId(c) &&
|
||||||
|
cirHistoryValue.Source == currentState["id"].(string) &&
|
||||||
|
cirHistoryValue.ProcessorId == user.UserId {
|
||||||
|
roleStatusCount += 1
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if h.stateValue["fullHandle"].(bool) {
|
||||||
|
if roleStatusCount == len(tmpUserList)-1 {
|
||||||
|
circulationStatus = true
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if roleStatusCount == len(currentState["processor"].([]interface{}))-1 {
|
||||||
|
circulationStatus = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if cirHistoryCount == len(currentState["processor"].([]interface{}))-1 {
|
if circulationStatus {
|
||||||
h.endHistory = true
|
h.endHistory = true
|
||||||
err = h.circulation()
|
err = h.circulation()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -298,7 +363,7 @@ func (h *Handle) commonProcessing(c *gin.Context) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 会签
|
// 会签
|
||||||
if h.stateValue["assignValue"] != nil && len(h.stateValue["assignValue"].([]interface{})) > 1 {
|
if h.stateValue["assignValue"] != nil && len(h.stateValue["assignValue"].([]interface{})) > 0 {
|
||||||
if isCounterSign, ok := h.stateValue["isCounterSign"]; ok {
|
if isCounterSign, ok := h.stateValue["isCounterSign"]; ok {
|
||||||
if isCounterSign.(bool) {
|
if isCounterSign.(bool) {
|
||||||
h.endHistory = false
|
h.endHistory = false
|
||||||
|
@ -69,7 +69,7 @@ func JudgeUserAuthority(c *gin.Context, workOrderId int, currentState string) (s
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 会签
|
// 会签
|
||||||
if currentStateValue["processor"] != nil && len(currentStateValue["processor"].([]interface{})) > 1 {
|
if currentStateValue["processor"] != nil && len(currentStateValue["processor"].([]interface{})) >= 1 {
|
||||||
if isCounterSign, ok := stateValue["isCounterSign"]; ok {
|
if isCounterSign, ok := stateValue["isCounterSign"]; ok {
|
||||||
if isCounterSign.(bool) {
|
if isCounterSign.(bool) {
|
||||||
err = orm.Eloquent.Model(&process.CirculationHistory{}).
|
err = orm.Eloquent.Model(&process.CirculationHistory{}).
|
||||||
@ -82,9 +82,32 @@ func JudgeUserAuthority(c *gin.Context, workOrderId int, currentState string) (s
|
|||||||
for _, cirHistoryValue := range cirHistoryList {
|
for _, cirHistoryValue := range cirHistoryList {
|
||||||
if cirHistoryValue.Source != stateValue["id"] {
|
if cirHistoryValue.Source != stateValue["id"] {
|
||||||
break
|
break
|
||||||
}
|
} else if cirHistoryValue.Source == stateValue["id"] {
|
||||||
if cirHistoryValue.Source == stateValue["id"] && cirHistoryValue.ProcessorId == tools.GetUserId(c) {
|
if currentStateValue["process_method"].(string) == "person" {
|
||||||
return
|
// 验证个人会签
|
||||||
|
if cirHistoryValue.ProcessorId == tools.GetUserId(c) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} else if currentStateValue["process_method"].(string) == "role" {
|
||||||
|
// 验证角色会签
|
||||||
|
if stateValue["fullHandle"].(bool) {
|
||||||
|
if cirHistoryValue.ProcessorId == tools.GetUserId(c) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
var roleUserInfo system.SysUser
|
||||||
|
err = orm.Eloquent.Model(&roleUserInfo).
|
||||||
|
Where("user_id = ?", cirHistoryValue.ProcessorId).
|
||||||
|
Find(&roleUserInfo).
|
||||||
|
Error
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if roleUserInfo.RoleId == tools.GetRoleId(c) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -98,6 +121,12 @@ func JudgeUserAuthority(c *gin.Context, workOrderId int, currentState string) (s
|
|||||||
status = true
|
status = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case "role":
|
||||||
|
for _, processorValue := range currentStateValue["processor"].([]interface{}) {
|
||||||
|
if int(processorValue.(float64)) == tools.GetRoleId(c) {
|
||||||
|
status = true
|
||||||
|
}
|
||||||
|
}
|
||||||
//case "persongroup":
|
//case "persongroup":
|
||||||
// var persongroupCount int
|
// var persongroupCount int
|
||||||
// err = orm.Eloquent.Model(&user.UserGroup{}).
|
// err = orm.Eloquent.Model(&user.UserGroup{}).
|
||||||
|
@ -43,36 +43,15 @@ func (w *WorkOrder) PureWorkOrderList() (result interface{}, err error) {
|
|||||||
// 1. 个人
|
// 1. 个人
|
||||||
personSelect := fmt.Sprintf("(JSON_CONTAINS(state, JSON_OBJECT('processor', %v)) and JSON_CONTAINS(state, JSON_OBJECT('process_method', 'person')))", tools.GetUserId(w.GinObj))
|
personSelect := fmt.Sprintf("(JSON_CONTAINS(state, JSON_OBJECT('processor', %v)) and JSON_CONTAINS(state, JSON_OBJECT('process_method', 'person')))", tools.GetUserId(w.GinObj))
|
||||||
|
|
||||||
// 2. 小组
|
// 2. 角色
|
||||||
//groupList := make([]int, 0)
|
roleSelect := fmt.Sprintf("(JSON_CONTAINS(state, JSON_OBJECT('processor', %v)) and JSON_CONTAINS(state, JSON_OBJECT('process_method', 'role')))", tools.GetRoleId(w.GinObj))
|
||||||
//err = orm.Eloquent.Model(&user.UserGroup{}).
|
|
||||||
// Where("user = ?", tools.GetUserId(c)).
|
|
||||||
// Pluck("`group`", &groupList).Error
|
|
||||||
//if err != nil {
|
|
||||||
// return
|
|
||||||
//}
|
|
||||||
//groupSqlList := make([]string, 0)
|
|
||||||
//if len(groupList) > 0 {
|
|
||||||
// for _, group := range groupList {
|
|
||||||
// groupSqlList = append(groupSqlList, fmt.Sprintf("JSON_CONTAINS(state, JSON_OBJECT('processor', %v))", group))
|
|
||||||
// }
|
|
||||||
//} else {
|
|
||||||
// groupSqlList = append(groupSqlList, fmt.Sprintf("JSON_CONTAINS(state, JSON_OBJECT('processor', 0))"))
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//personGroupSelect := fmt.Sprintf(
|
|
||||||
// "((%v) and %v)",
|
|
||||||
// strings.Join(groupSqlList, " or "),
|
|
||||||
// "JSON_CONTAINS(state, JSON_OBJECT('process_method', 'persongroup'))",
|
|
||||||
//)
|
|
||||||
|
|
||||||
// 3. 部门
|
// 3. 部门
|
||||||
//departmentSelect := fmt.Sprintf("(JSON_CONTAINS(state, JSON_OBJECT('processor', %v)) and JSON_CONTAINS(state, JSON_OBJECT('process_method', 'department')))", userInfo.Dept)
|
//departmentSelect := fmt.Sprintf("(JSON_CONTAINS(state, JSON_OBJECT('processor', %v)) and JSON_CONTAINS(state, JSON_OBJECT('process_method', 'department')))", userInfo.Dept)
|
||||||
|
|
||||||
// 4. 变量会转成个人数据
|
// 4. 变量会转成个人数据
|
||||||
|
|
||||||
//db = db.Where(fmt.Sprintf("(%v or %v or %v or %v) and is_end = 0", personSelect, personGroupSelect, departmentSelect, variableSelect))
|
//db = db.Where(fmt.Sprintf("(%v or %v or %v or %v) and is_end = 0", personSelect, personGroupSelect, departmentSelect, variableSelect))
|
||||||
db = db.Where(fmt.Sprintf("(%v) and is_end = 0", personSelect))
|
db = db.Where(fmt.Sprintf("(%v or %v) and is_end = 0", personSelect, roleSelect))
|
||||||
case 2:
|
case 2:
|
||||||
// 我创建的
|
// 我创建的
|
||||||
db = db.Where("creator = ?", tools.GetUserId(w.GinObj))
|
db = db.Where("creator = ?", tools.GetUserId(w.GinObj))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user