From cac80aaa449cb1ea65ab49364840114ed24a041f Mon Sep 17 00:00:00 2001 From: herenshan112 Date: Wed, 1 Mar 2023 11:17:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AE=A1=E6=89=B9=E8=AE=B0?= =?UTF-8?q?=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../departmentpc/dingliang.go | 116 +++++++-- .../departmentpc/programme.go | 240 ++++++++++++------ .../departmentseting/departmentpc/type.go | 3 +- api/version1/postseting/postpc/teshuxuqiu.go | 8 +- models/modelskpi/flow_data_log.go | 26 ++ overall/publicmethod/technique.go | 62 +++++ 6 files changed, 351 insertions(+), 104 deletions(-) create mode 100644 models/modelskpi/flow_data_log.go diff --git a/api/version1/departmentseting/departmentpc/dingliang.go b/api/version1/departmentseting/departmentpc/dingliang.go index 139ac8a..a591293 100644 --- a/api/version1/departmentseting/departmentpc/dingliang.go +++ b/api/version1/departmentseting/departmentpc/dingliang.go @@ -149,40 +149,44 @@ func (a *ApiMethod) GetQuantitativeTasks(c *gin.Context) { } } } + years := publicmethod.ComputingTime(operationTime, 1) + quarter := publicmethod.ComputingTime(operationTime, 2) + months := publicmethod.ComputingTime(operationTime, 3) switch v.Cycles { case 1: - shiJiZhi["fl_year"] = publicmethod.ComputingTime(operationTime, 1) - shiJiZhi["fl_quarter"] = publicmethod.ComputingTime(operationTime, 2) - shiJiZhi["fl_month"] = publicmethod.ComputingTime(operationTime, 3) + shiJiZhi["fl_year"] = years + shiJiZhi["fl_quarter"] = quarter + shiJiZhi["fl_month"] = months shiJiZhi["fl_week"] = publicmethod.ComputingTime(operationTime, 4) shiJiZhi["fl_day"] = publicmethod.ComputingTime(operationTime, 5) case 2: - shiJiZhi["fl_year"] = publicmethod.ComputingTime(operationTime, 1) - shiJiZhi["fl_quarter"] = publicmethod.ComputingTime(operationTime, 2) - shiJiZhi["fl_month"] = publicmethod.ComputingTime(operationTime, 3) + shiJiZhi["fl_year"] = years + shiJiZhi["fl_quarter"] = quarter + shiJiZhi["fl_month"] = months shiJiZhi["fl_week"] = publicmethod.ComputingTime(operationTime, 4) shiJiZhi["fl_day"] = publicmethod.ComputingTime(operationTime, 5) case 3: - shiJiZhi["fl_year"] = publicmethod.ComputingTime(operationTime, 1) - shiJiZhi["fl_quarter"] = publicmethod.ComputingTime(operationTime, 2) - shiJiZhi["fl_month"] = publicmethod.ComputingTime(operationTime, 3) + shiJiZhi["fl_year"] = years + shiJiZhi["fl_quarter"] = quarter + shiJiZhi["fl_month"] = months shiJiZhi["fl_week"] = publicmethod.ComputingTime(operationTime, 4) case 4: - shiJiZhi["fl_year"] = publicmethod.ComputingTime(operationTime, 1) - shiJiZhi["fl_quarter"] = publicmethod.ComputingTime(operationTime, 2) - shiJiZhi["fl_month"] = publicmethod.ComputingTime(operationTime, 3) + shiJiZhi["fl_year"] = years + shiJiZhi["fl_quarter"] = quarter + shiJiZhi["fl_month"] = months case 5: - shiJiZhi["fl_year"] = publicmethod.ComputingTime(operationTime, 1) - shiJiZhi["fl_quarter"] = publicmethod.ComputingTime(operationTime, 2) + shiJiZhi["fl_year"] = years + shiJiZhi["fl_quarter"] = quarter case 6: - shiJiZhi["fl_year"] = publicmethod.ComputingTime(operationTime, 1) + shiJiZhi["fl_year"] = years default: - shiJiZhi["fl_year"] = publicmethod.ComputingTime(operationTime, 1) - shiJiZhi["fl_quarter"] = publicmethod.ComputingTime(operationTime, 2) - shiJiZhi["fl_month"] = publicmethod.ComputingTime(operationTime, 3) + shiJiZhi["fl_year"] = years + shiJiZhi["fl_quarter"] = quarter + shiJiZhi["fl_month"] = months shiJiZhi["fl_week"] = publicmethod.ComputingTime(operationTime, 4) shiJiZhi["fl_day"] = publicmethod.ComputingTime(operationTime, 5) } + sendCont.ReferTo = JudgeDingLiangIsTrue(v.Target, v.AcceptEvaluation, years, quarter, months, v.Cycles) actualValue := GetTimeIntervalDuty(shiJiZhi, v.Id) //实际值 sendCont.Actual = strconv.FormatFloat(actualValue/100, 'f', -1, 64) // chuShuVal := actualValue - quanTitCont.Zeroprize @@ -233,6 +237,31 @@ func (a *ApiMethod) GetQuantitativeTasks(c *gin.Context) { publicmethod.Result(0, sendListCont, c) } +// 判断定量指标是否已经提交 +func JudgeDingLiangIsTrue(targetId, department int64, year, quarter, monthsss int64, types int) bool { + var idList []int64 + gormDb := overall.CONSTANT_DB_KPI.Model(&modelskpi.FlowDataLogType{}).Select("`id`").Where("`targetid` = ? AND `department` = ?", targetId, department) + switch types { + case 5: + gormDb = gormDb.Where("`year` = ? AND `quarte` = ?", year, quarter) + case 6: + gormDb = gormDb.Where("`year` = ?", year) + case 7: + banNian := []int{1, 2, 3, 4, 5, 6} + if monthsss > 6 { + banNian = []int{7, 8, 9, 10, 11, 12} + } + gormDb = gormDb.Where("`year` = ? AND `month` IN ?", year, banNian) + default: + gormDb = gormDb.Where("`year` = ? AND `month` = ?", year, monthsss) + } + err := gormDb.Find(&idList).Error + if err == nil && len(idList) > 0 { + return true + } + return false +} + /* * @ 作者: 秦东 @@ -324,3 +353,54 @@ func GetSchemeFlowData(flowKwy, schemeID int64) (weightSum float64) { overall.CONSTANT_DB_KPI.Model(&modelskpi.FlowLogData{}).Where("`fld_evaluation_id` = ? AND `fld_flow_log` = ?", schemeID, flowKwy).Pluck("COALESCE(SUM(fld_score), 0) as qe_reference_score", &weightSum) return } + +/* +* +@ 作者: 秦东 +@ 时间: 2023-02-23 16:35:22 +@ 功能: 获取关联指标细则 +@ 参数 + + #targetid 指标ID + #tableid 栏目Id + #bylaws 细则Id + #orgid 行政组织 + #post 岗位 + #types 类型(1:指标;2:子目标;3:细则) + #level 级别(1:部门级;2:岗位级) + +@ 返回值 + + #bylawsId 相关ID + #err 信息 + +@ 方法原型 + + #GetTargetDetailsInfoList(targetid, tableid, bylaws, orgid, post int64, types, level int) (bylawsId []int64, err error) +*/ +func GetTargetDetailsInfoList(targetid, tableid, bylaws, orgid, post int64, types, level int) (bylawsId []int64, err error) { + if types == 0 { + types = 3 + } + gormDb := overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetDepartment{}) + switch types { + case 1: + gormDb = gormDb.Distinct(`target_id`) + case 2: + gormDb = gormDb.Distinct(`target_sun_id`) + default: + gormDb = gormDb.Distinct(`target_bylaws`) + } + gormDb = gormDb.Where("`state` = 1 AND `type` = ? AND `level` = ?", types, level) + if targetid != 0 { + gormDb = gormDb.Where("`target_id` = ?", targetid) + } + if tableid != 0 { + gormDb = gormDb.Where("`target_sun_id` = ?", tableid) + } + if bylaws != 0 { + gormDb = gormDb.Where("`target_bylaws` = ?", bylaws) + } + err = gormDb.Find(&bylawsId).Error + return +} diff --git a/api/version1/departmentseting/departmentpc/programme.go b/api/version1/departmentseting/departmentpc/programme.go index 22e3a6b..cde217b 100644 --- a/api/version1/departmentseting/departmentpc/programme.go +++ b/api/version1/departmentseting/departmentpc/programme.go @@ -472,6 +472,7 @@ func (a *ApiMethod) CreateSchemeForDeparment(c *gin.Context) { var qualEvalList []modelskpi.QualitativeEvaluation //解析方案结构体 for _, v := range receivedValue.Child { + // dimensionIdInt, _ := strconv.ParseInt(v.Id, 10, 64) //维度操作 AddWeight(receivedValue.Group, v.Id, receivedValue.DepartmentId, "", int64(v.ZhiFraction), 1) //添加维度权重 for _, cv := range v.Child { @@ -520,94 +521,171 @@ func (a *ApiMethod) CreateSchemeForDeparment(c *gin.Context) { } else { //定性指标 AddWeight(receivedValue.Group, v.Id, receivedValue.DepartmentId, cv.Id, cv.ReferenceScore, 1) - //获取定性指标得关联关系 - var assessList []modelskpi.Assesstarget - err = overall.CONSTANT_DB_KPI.Model(&modelskpi.Assesstarget{}).Where("`state` = 1 AND `group` = ? AND `dimension` = ? AND `targetid` = ? AND FIND_IN_SET(?,`departmentmap`)", groupId, v.Id, cv.Id, departId).Find(&assessList).Error + + //获取关联的细则Id + tarIdIntSet, _ := strconv.ParseInt(cv.Id, 10, 64) + targetIdAry, err := GetTargetDetailsInfoList(tarIdIntSet, 0, 0, departId, 0, 3, 1) + var targetDetailsList []modelskpi.DetailedTarget + err = overall.CONSTANT_DB_KPI.Model(&modelskpi.DetailedTarget{}).Where("`dt_state` = 1 AND `dt_id` IN ? ", targetIdAry).Find(&targetDetailsList).Error + var detailedList []DutyAssEssTarget + //写入指标细则 if err == nil { - var sunTarget []int64 - for _, sv := range assessList { //遍历与此部门相关得子栏目 - if publicmethod.IsInTrue[int64](sv.Id, sunTarget) == false { //次子栏目未操作过 - //拆解指标详情 - var detailedList []DutyAssEssTarget - json.Unmarshal([]byte(sv.Content), &detailedList) - - sunTarget = append(sunTarget, sv.Id) - //获取指标细则列表 - var targetDetailsList []modelskpi.DetailedTarget - err = overall.CONSTANT_DB_KPI.Model(&modelskpi.DetailedTarget{}).Where("`dt_state` = 1 AND `dt_parentid` = ? AND `dt_parentid_sun` = ? AND (FIND_IN_SET(?,`dt_paretment`) OR `dt_paretment` = '')", cv.Id, sv.SunTargetId, departId).Find(&targetDetailsList).Error - fmt.Printf("获取指标细则列表-------->%v-------->%v-------->%v-------->%v\n", cv.Id, sv.Id, departId, len(targetDetailsList)) - if err == nil { - for _, tv := range targetDetailsList { //指标细则 - - //写入新的定性考核细则 - var saveData modelskpi.QualitativeEvaluation - saveData.Dimension = sv.Dimension //纬度 - saveData.Target = targetInfo.Id //指标 - saveData.Type = 1 //类型 - saveData.TargetSun = sv.SunTargetId //子栏目 - saveData.DetailedTarget = tv.Id //指标细则 - if tv.Company != "" { - saveData.Unit = tv.Company - } else { - saveData.Unit = targetInfo.Uniteing - } - saveData.ReferenceScore = 0 //分值 - saveData.MinScore = tv.MinScore //最低分 - saveData.MaxScore = tv.MaxScore //最高分 - - saveData.CensorType = tv.CensorType //检查方式 - saveData.CensorCont = tv.CensorCont //检查依据 - saveData.CensorRate = tv.CensorRate //检查频次 - saveData.State = judgeState //状态 - saveData.Addtime = time.Now().Unix() - saveData.Eitetime = time.Now().Unix() - saveData.Group = groupId //集团 - - if tv.Cycles > 0 { - saveData.Cycles = tv.Cycles //1:班;2:天;3:周;4:月;5:季度;6:年 - saveData.CycleAttres = tv.CycleAttres //辅助计数 - } else { - saveData.Cycles = targetInfo.Cycles //1:班;2:天;3:周;4:月;5:季度;6:年 - saveData.CycleAttres = targetInfo.CycleAttres //辅助计数 - } - saveData.AcceptEvaluation = departId //接受考核部门 - saveData.Content = tv.Content //描述 - reportStr := tv.Reportary - if tv.Reportary != "" { - saveData.Operator = tv.Reportary //执行考核人 - } else { - if len(detailedList) > 0 { - for _, dev := range detailedList { - if dev.Id == tv.Id { - saveData.Operator = strings.Join(dev.Operator, ",") //执行考核人 //执行考核人 - reportStr = strings.Join(dev.Operator, ",") - saveData.DepartmentId = strings.Join(dev.Department, ",") - } - } - } - } - var departAry []string - userKeyAry := strings.Split(reportStr, ",") - if len(userKeyAry) > 0 { - for _, u_v := range userKeyAry { - var userCont modelshr.PersonArchives - err = userCont.GetCont(map[string]interface{}{"`key`": u_v}, "`maindeparment`") - mainDepartStr := strconv.FormatInt(userCont.MainDeparment, 10) - if publicmethod.IsInTrue[string](mainDepartStr, departAry) == false { - departAry = append(departAry, mainDepartStr) - } - } + for _, tv := range targetDetailsList { //指标细则 + + //写入新的定性考核细则 + var saveData modelskpi.QualitativeEvaluation + saveData.Dimension = targetInfo.Dimension //纬度 + saveData.Target = targetInfo.Id //指标 + saveData.Type = 1 //类型 + saveData.TargetSun = tv.ParentIdSun //子栏目 + saveData.DetailedTarget = tv.Id //指标细则 + if tv.Company != "" { + saveData.Unit = tv.Company + } else { + saveData.Unit = targetInfo.Uniteing + } + saveData.ReferenceScore = 0 //分值 + saveData.MinScore = tv.MinScore //最低分 + saveData.MaxScore = tv.MaxScore //最高分 + + saveData.CensorType = tv.CensorType //检查方式 + saveData.CensorCont = tv.CensorCont //检查依据 + saveData.CensorRate = tv.CensorRate //检查频次 + saveData.State = judgeState //状态 + saveData.Addtime = time.Now().Unix() + saveData.Eitetime = time.Now().Unix() + saveData.Group = groupId //集团 + + if tv.Cycles > 0 { + saveData.Cycles = tv.Cycles //1:班;2:天;3:周;4:月;5:季度;6:年 + saveData.CycleAttres = tv.CycleAttres //辅助计数 + } else { + saveData.Cycles = targetInfo.Cycles //1:班;2:天;3:周;4:月;5:季度;6:年 + saveData.CycleAttres = targetInfo.CycleAttres //辅助计数 + } + saveData.AcceptEvaluation = departId //接受考核部门 + saveData.Content = tv.Content //描述 + reportStr := tv.Reportary + if tv.Reportary != "" { + saveData.Operator = tv.Reportary //执行考核人 + } else { + if len(detailedList) > 0 { + for _, dev := range detailedList { + if dev.Id == tv.Id { + saveData.Operator = strings.Join(dev.Operator, ",") //执行考核人 //执行考核人 + reportStr = strings.Join(dev.Operator, ",") + saveData.DepartmentId = strings.Join(dev.Department, ",") } - saveData.DepartmentId = strings.Join(departAry, ",") //处理关联部门 - saveData.QualEvalId = keyStr - saveData.Observer = cv.Status - qualEvalList = append(qualEvalList, saveData) } } } + var departAry []string + userKeyAry := strings.Split(reportStr, ",") + if len(userKeyAry) > 0 { + for _, u_v := range userKeyAry { + var userCont modelshr.PersonArchives + err = userCont.GetCont(map[string]interface{}{"`key`": u_v}, "`maindeparment`") + mainDepartStr := strconv.FormatInt(userCont.MainDeparment, 10) + if publicmethod.IsInTrue[string](mainDepartStr, departAry) == false { + departAry = append(departAry, mainDepartStr) + } + } + } + saveData.DepartmentId = strings.Join(departAry, ",") //处理关联部门 + saveData.QualEvalId = keyStr + saveData.Observer = cv.Status + qualEvalList = append(qualEvalList, saveData) } - } + + //获取定性指标得关联关系 + // var assessList []modelskpi.Assesstarget + // err = overall.CONSTANT_DB_KPI.Model(&modelskpi.Assesstarget{}).Where("`state` = 1 AND `group` = ? AND `dimension` = ? AND `targetid` = ? AND FIND_IN_SET(?,`departmentmap`)", groupId, v.Id, cv.Id, departId).Find(&assessList).Error + // if err == nil { + // var sunTarget []int64 + // for _, sv := range assessList { //遍历与此部门相关得子栏目 + // if publicmethod.IsInTrue[int64](sv.Id, sunTarget) == false { //次子栏目未操作过 + // //拆解指标详情 + // var detailedList []DutyAssEssTarget + // json.Unmarshal([]byte(sv.Content), &detailedList) + + // sunTarget = append(sunTarget, sv.Id) + // //获取指标细则列表 + // var targetDetailsList []modelskpi.DetailedTarget + // err = overall.CONSTANT_DB_KPI.Model(&modelskpi.DetailedTarget{}).Where("`dt_state` = 1 AND `dt_parentid` = ? AND `dt_parentid_sun` = ? AND (FIND_IN_SET(?,`dt_paretment`) OR `dt_paretment` = '')", cv.Id, sv.SunTargetId, departId).Find(&targetDetailsList).Error + // fmt.Printf("获取指标细则列表-------->%v-------->%v-------->%v-------->%v\n", cv.Id, sv.Id, departId, len(targetDetailsList)) + // if err == nil { + // for _, tv := range targetDetailsList { //指标细则 + + // //写入新的定性考核细则 + // var saveData modelskpi.QualitativeEvaluation + // saveData.Dimension = sv.Dimension //纬度 + // saveData.Target = targetInfo.Id //指标 + // saveData.Type = 1 //类型 + // saveData.TargetSun = sv.SunTargetId //子栏目 + // saveData.DetailedTarget = tv.Id //指标细则 + // if tv.Company != "" { + // saveData.Unit = tv.Company + // } else { + // saveData.Unit = targetInfo.Uniteing + // } + // saveData.ReferenceScore = 0 //分值 + // saveData.MinScore = tv.MinScore //最低分 + // saveData.MaxScore = tv.MaxScore //最高分 + + // saveData.CensorType = tv.CensorType //检查方式 + // saveData.CensorCont = tv.CensorCont //检查依据 + // saveData.CensorRate = tv.CensorRate //检查频次 + // saveData.State = judgeState //状态 + // saveData.Addtime = time.Now().Unix() + // saveData.Eitetime = time.Now().Unix() + // saveData.Group = groupId //集团 + + // if tv.Cycles > 0 { + // saveData.Cycles = tv.Cycles //1:班;2:天;3:周;4:月;5:季度;6:年 + // saveData.CycleAttres = tv.CycleAttres //辅助计数 + // } else { + // saveData.Cycles = targetInfo.Cycles //1:班;2:天;3:周;4:月;5:季度;6:年 + // saveData.CycleAttres = targetInfo.CycleAttres //辅助计数 + // } + // saveData.AcceptEvaluation = departId //接受考核部门 + // saveData.Content = tv.Content //描述 + // reportStr := tv.Reportary + // if tv.Reportary != "" { + // saveData.Operator = tv.Reportary //执行考核人 + // } else { + // if len(detailedList) > 0 { + // for _, dev := range detailedList { + // if dev.Id == tv.Id { + // saveData.Operator = strings.Join(dev.Operator, ",") //执行考核人 //执行考核人 + // reportStr = strings.Join(dev.Operator, ",") + // saveData.DepartmentId = strings.Join(dev.Department, ",") + // } + // } + // } + // } + // var departAry []string + // userKeyAry := strings.Split(reportStr, ",") + // if len(userKeyAry) > 0 { + // for _, u_v := range userKeyAry { + // var userCont modelshr.PersonArchives + // err = userCont.GetCont(map[string]interface{}{"`key`": u_v}, "`maindeparment`") + // mainDepartStr := strconv.FormatInt(userCont.MainDeparment, 10) + // if publicmethod.IsInTrue[string](mainDepartStr, departAry) == false { + // departAry = append(departAry, mainDepartStr) + // } + // } + // } + // saveData.DepartmentId = strings.Join(departAry, ",") //处理关联部门 + // saveData.QualEvalId = keyStr + // saveData.Observer = cv.Status + // qualEvalList = append(qualEvalList, saveData) + // } + // } + // } + // } + + // } } } } diff --git a/api/version1/departmentseting/departmentpc/type.go b/api/version1/departmentseting/departmentpc/type.go index ec539af..cf75c55 100644 --- a/api/version1/departmentseting/departmentpc/type.go +++ b/api/version1/departmentseting/departmentpc/type.go @@ -351,7 +351,7 @@ type TargetContOutCont struct { ZeroPrize string `json:"zeroprize"` //零奖值 AllPrize string `json:"allprize"` //全奖奖值 Reach string `json:"reach"` //达成率公式 - ReachScore float64 `json:"reachscore"` //达成率 + ReachScore float64 `json:"reachscore"` //手动分 CappingVal float64 `json:"cappingcal"` //封顶值 Reason string `json:"reason"` //说明 @@ -359,6 +359,7 @@ type TargetContOutCont struct { DimensionWeight int64 `json:"dimensionweight"` //权重 TargetWeight int64 `json:"targetweight"` //权重 PlanVersionNumber string `json:"planversionnumber"` //版本号 + ReferTo bool `json:"referto"` //是否提交 } // 执行人列表输出 diff --git a/api/version1/postseting/postpc/teshuxuqiu.go b/api/version1/postseting/postpc/teshuxuqiu.go index 479c4c3..668a1f4 100644 --- a/api/version1/postseting/postpc/teshuxuqiu.go +++ b/api/version1/postseting/postpc/teshuxuqiu.go @@ -202,16 +202,16 @@ func (a *ApiMethod) GetOrgAndPostAry(c *gin.Context) { idInt, _ := strconv.ParseInt(receivedValue.Id, 10, 64) _, _, minDer, sunDer, workId := publicmethod.GetOrgStructure(idInt) var orgAry []int64 - if minDer != 0 && publicmethod.IsInTrue[int64](minDer, orgAry) == false { + if minDer != 0 && minDer != 309 && publicmethod.IsInTrue[int64](minDer, orgAry) == false { orgAry = append(orgAry, minDer) } - if sunDer != 0 && publicmethod.IsInTrue[int64](sunDer, orgAry) == false { + if sunDer != 0 && sunDer != 309 && publicmethod.IsInTrue[int64](sunDer, orgAry) == false { orgAry = append(orgAry, sunDer) } - if workId != 0 && publicmethod.IsInTrue[int64](workId, orgAry) == false { + if workId != 0 && workId != 309 && publicmethod.IsInTrue[int64](workId, orgAry) == false { orgAry = append(orgAry, workId) } - if idInt != 0 && publicmethod.IsInTrue[int64](idInt, orgAry) == false { + if idInt != 0 && idInt != 309 && publicmethod.IsInTrue[int64](idInt, orgAry) == false { orgAry = append(orgAry, idInt) } //获取相关岗位 diff --git a/models/modelskpi/flow_data_log.go b/models/modelskpi/flow_data_log.go new file mode 100644 index 0000000..af6dce2 --- /dev/null +++ b/models/modelskpi/flow_data_log.go @@ -0,0 +1,26 @@ +package modelskpi + +// 定量柳树视图 +type FlowDataLogType struct { + Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` + Key int64 `json:"key" gorm:"column:key;type:bigint(20) unsigned;default:0;not null;comment:识别标志"` + Score int64 `json:"score" gorm:"column:score;type:bigint(20) unsigned;default:0;not null;comment:数据"` + ScoringMethod int `json:"scoringmethod" gorm:"column:method;type:int(1) unsigned;default:1;not null;comment:计分方式(1:自动;2:手动)"` + ScoringScore float64 `json:"scoringscore" gorm:"column:scoring_score;type:bigint(20) unsigned;default:0;not null;comment:手动分"` + EvaluationDepartment int64 `json:"evaluationdepartment" gorm:"column:eval_department;type:bigint(20) unsigned;default:0;not null;comment:测评部门"` + DutyGroup int64 `json:"dutygroup" gorm:"column:group;type:bigint(20) unsigned;default:0;not null;comment:职责集团"` + DutyDepartment int64 `json:"dutydepartment" gorm:"column:department;type:bigint(20) unsigned;default:0;not null;comment:职责部门"` + Baseline string `json:"baseline" gorm:"column:baseline;type:longtext;comment:基准线 "` + Year int64 `json:"year" gorm:"column:year;type:int(7) unsigned;default:0;not null;comment:年分"` + Quarter int64 `json:"quarter" gorm:"column:quarte;type:int(2) unsigned;default:0;not null;comment:季度"` + Month int64 `json:"month" gorm:"column:month;type:int(2) unsigned;default:0;not null;comment:月"` + Week int64 `json:"week" gorm:"column:week;type:int(5) unsigned;default:0;not null;comment:周"` + ToDay int64 `json:"today" gorm:"column:today;type:int(5) unsigned;default:0;not null;comment:天"` + TargetId int64 `json:"targetid" gorm:"column:targetid;type:bigint(20) unsigned;default:0;not null;comment:指标ID"` + Edition string `json:"edition" gorm:"column:edition;type:longtext;comment:版本号 "` + Content string `json:"content" gorm:"column:content;type:longtext;comment:评测内容 "` +} + +func (FlowDataLogType *FlowDataLogType) TableName() string { + return "flow_data_log" +} diff --git a/overall/publicmethod/technique.go b/overall/publicmethod/technique.go index 14a0b27..48c95a1 100644 --- a/overall/publicmethod/technique.go +++ b/overall/publicmethod/technique.go @@ -588,6 +588,68 @@ func RecursionOrgLeve(superior int64, leve int64) (groupId int64) { return } +// 获取集团、公司、部门、二级部门、工段 +func GetOrgStructurees(orgId int64) (groupId, companyId, departmentId, sunDepartId, workShopId int64) { + var orgContTypeInfo modelshr.OrgContType + err := orgContTypeInfo.GetCont(map[string]interface{}{"`id`": orgId}) + if err != nil { + return + } + switch orgContTypeInfo.Level { + case 1: + groupId = orgContTypeInfo.Id + case 2: + groupId = RecursionOrgLevees(orgId, orgContTypeInfo.Superior, 1) + workShopId = orgContTypeInfo.Id + case 3: + groupId = RecursionOrgLevees(orgId, orgContTypeInfo.Superior, 2) + companyId = orgContTypeInfo.Id + case 4: + groupId = RecursionOrgLevees(orgId, orgContTypeInfo.Superior, 2) + companyId = RecursionOrgLevees(orgId, orgContTypeInfo.Superior, 3) + departmentId = orgContTypeInfo.Id + case 5: + groupId = RecursionOrgLevees(orgId, orgContTypeInfo.Superior, 2) + companyId = RecursionOrgLevees(orgId, orgContTypeInfo.Superior, 3) + departmentId = RecursionOrgLevees(orgId, orgContTypeInfo.Superior, 4) + sunDepartId = orgContTypeInfo.Id + case 6: + groupId = RecursionOrgLevees(orgId, orgContTypeInfo.Superior, 2) + companyId = RecursionOrgLevees(orgId, orgContTypeInfo.Superior, 3) + departmentId = RecursionOrgLevees(orgId, orgContTypeInfo.Superior, 4) + sunDepartId = RecursionOrgLevees(orgId, orgContTypeInfo.Superior, 5) + workShopId = orgContTypeInfo.Id + default: + groupId = orgContTypeInfo.Id + companyId = orgContTypeInfo.Id + workShopId = orgContTypeInfo.Id + } + return +} + +func RecursionOrgLevees(oldId, superior int64, leve int64) (groupId int64) { + if leve == 0 { + leve = 1 + } + var orgMap modelshr.OrgContType + err := orgMap.GetCont(map[string]interface{}{"`id`": superior, "`state`": 1}, "`id`", "`superior`", "`level`") + if err != nil { + return + } + if orgMap.Level <= leve { + if orgMap.Level == leve { + groupId = oldId + } else { + groupId = orgMap.Id + } + + return + } else { + groupId = RecursionOrgLevees(orgMap.Id, orgMap.Superior, leve) + } + return +} + // 获取集团、公司、部门、二级部门、工段 func GetOrgStructure(orgId int64) (groupId, companyId, departmentId, sunDepartId, workShopId int64) { var orgContTypeInfo modelshr.OrgContType