package postweb import ( "key_performance_indicators/middleware/wechatapp/wechatcallback" "key_performance_indicators/models/modelskpi" "key_performance_indicators/overall" "key_performance_indicators/overall/publicmethod" "strconv" "github.com/gin-gonic/gin" ) // 岗位审批记录 func (a *ApiMethod) GetPostFlowLog(c *gin.Context) { var receivedValue postFlowLog c.ShouldBindJSON(&receivedValue) if receivedValue.Page == 0 { receivedValue.Page = 1 } if receivedValue.PageSize == 0 { receivedValue.PageSize = 20 } //获取登录人信息 context, _ := publicmethod.LoginMyCont(c) gormDb := overall.CONSTANT_DB_KPI.Model(&modelskpi.AppNewFlowLog{}) switch context.IsAdmin { case 2: case 3: case 4: default: gormDb = gormDb.Where("FIND_IN_SET(?,`participants`)", context.Key) gormDb = gormDb.Where("`department_id` = ?", context.MainDeparment) } var flowLogList []modelskpi.AppNewFlowLog if receivedValue.Title != "" { gormDb = gormDb.Where("`pt_title` LIKE ? OR `pst_title` LIKE ? OR `ptd_title` LIKE ?", "%"+receivedValue.Title+"%", "%"+receivedValue.Title+"%", "%"+receivedValue.Title+"%") } if receivedValue.OrgId != "" { gormDb = gormDb.Where("`org_id` = ?", receivedValue.OrgId) } if receivedValue.PostId != "" { gormDb = gormDb.Where("`post_id` = ?", receivedValue.PostId) } if receivedValue.DayTime != "" { startTime, endTime := publicmethod.GetAppointMonthStarAndEndTime(receivedValue.DayTime) gormDb = gormDb.Where("`start_time` BETWEEN ? AND ?", startTime, endTime) } if receivedValue.State != 0 { gormDb = gormDb.Where("`state` = ?", receivedValue.State) } else { gormDb = gormDb.Where("`state` BETWEEN ? AND ?", 1, 5) } if receivedValue.ApprovalState == 1 { gormDb = gormDb.Where("NOT FIND_IN_SET(?,`next_executor`)", context.Key) } if receivedValue.ApprovalState == 2 { gormDb = gormDb.Where("FIND_IN_SET(?,`next_executor`)", context.Key) } err := gormDb.Order("`id` DESC").Find(&flowLogList).Error var total int64 totalErr := gormDb.Count(&total).Error if totalErr != nil { total = 0 } if err != nil || len(flowLogList) < 1 { publicmethod.Result(107, err, c) return } var sendData []SendPostFlowLog for _, v := range flowLogList { var sendCont SendPostFlowLog sendCont.OrderId = strconv.FormatInt(v.OrderId, 10) //订单Key titleStr := v.PtTitle if v.PstTitle != "" { titleStr = v.PstTitle } if v.PtdTitle != "" { titleStr = v.PtdTitle } sendCont.Title = titleStr //标题 switch v.State { case 1: sendCont.Result = "起草" //审批结果 sendCont.Statetype = 1 //审批状态 case 2: sendCont.Result = "驳回" sendCont.Statetype = 4 case 3: sendCont.Result = "审批中" sendCont.Statetype = 0 case 4: sendCont.Result = "归档" sendCont.Statetype = 1 case 5: sendCont.Result = "废弃" sendCont.Statetype = 1 case 6: sendCont.Result = "删除" sendCont.Statetype = 1 default: sendCont.Result = "审批中" sendCont.Statetype = 0 } cyclesVal := v.PtCycle cycleAttresVal := v.PtCycleattr if v.PtdCycles != 0 { cyclesVal = v.PtdCycles } if v.PtdCycleAttres != 0 { cycleAttresVal = v.PtdCycleAttres } sendCont.Cycles = cyclesVal //1:班;2:天;3:周;4:月;5:季度;6:年"` sendCont.CycleAttres = cycleAttresVal //辅助计数"` sendCont.Year = v.Year //年分"` sendCont.Quarter = v.Quarter //季度"` sendCont.Month = v.Month //月"` sendCont.Week = v.Week //周"` if v.NextStep == 0 { sendCont.Node = "归档" } else { //获取流程节点 _, flowCont, _ := wechatcallback.GetOneNodeCont(v.WorkFlow, v.Step) sendCont.Node = flowCont.NodeName //当前节点 } sendCont.MonthDays = publicmethod.UnixTimeToDay(v.StartTime, 22) //提报日期 sendData = append(sendData, sendCont) } publicmethod.ResultList(0, receivedValue.Page, receivedValue.PageSize, total, int64(len(sendData)), sendData, c) }