23 changed files with 3130 additions and 53 deletions
@ -0,0 +1,147 @@ |
|||||
|
package departmentweb |
||||
|
|
||||
|
import ( |
||||
|
"encoding/json" |
||||
|
"key_performance_indicators/api/version1/statistics" |
||||
|
"key_performance_indicators/models/modelshr" |
||||
|
"key_performance_indicators/models/modelskpi" |
||||
|
"key_performance_indicators/overall/publicmethod" |
||||
|
"strconv" |
||||
|
"time" |
||||
|
) |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2023-07-29 16:50:53 |
||||
|
@ 功能: 按时间计算行政组织成绩 |
||||
|
@ 参数 |
||||
|
|
||||
|
# |
||||
|
|
||||
|
@ 返回值 |
||||
|
|
||||
|
# |
||||
|
|
||||
|
@ 方法原型 |
||||
|
|
||||
|
# |
||||
|
*/ |
||||
|
func (s *SyncOrgTimeAllScore) TallyUpOrgCalculateScore(orgCont modelshr.AdministrativeOrganization, year, month string) { |
||||
|
//锁操作
|
||||
|
s.mutext.Lock() |
||||
|
defer s.mutext.Unlock() |
||||
|
yearInt, _ := strconv.ParseInt(year, 10, 64) |
||||
|
monthInt, _ := strconv.ParseInt(month, 10, 64) |
||||
|
//获取版本信息
|
||||
|
planCont, err := publicmethod.GetPlanVresion(orgCont.Id, yearInt, monthInt) |
||||
|
var getPoints float64 //行政组织总分
|
||||
|
if err == nil { |
||||
|
var planVersioInfo []SchemeInfo |
||||
|
jsonErr := json.Unmarshal([]byte(planCont.Content), &planVersioInfo) |
||||
|
if jsonErr == nil { |
||||
|
for _, v := range planVersioInfo { //维度
|
||||
|
for _, sv := range v.Child { //指标
|
||||
|
if sv.Status == 3 { //为观察指标
|
||||
|
getPoints = getPoints + float64(sv.ReferenceScore) |
||||
|
} else { |
||||
|
var targetInfo modelskpi.EvaluationTarget |
||||
|
targetInfo.GetCont(map[string]interface{}{"et_id": sv.Id}, "et_type,et_cycle") |
||||
|
if sv.Cycles == 0 { //判断统计方式
|
||||
|
sv.Cycles = targetInfo.Cycles |
||||
|
} |
||||
|
if targetInfo.Type == 1 { //定性考核
|
||||
|
dingXingScore, _ := statistics.DingXingScoreCalculation(orgCont.Id, yearInt, sv.ReferenceScore, []int64{monthInt}, sv.Id) |
||||
|
getPoints = getPoints + dingXingScore |
||||
|
} else { //定量考核
|
||||
|
var dingLiangScore float64 |
||||
|
switch sv.Cycles { |
||||
|
case 5: //季度指标
|
||||
|
quarterList := []int64{3, 6, 9, 12} |
||||
|
if !publicmethod.IsInTrue[int64](monthInt, quarterList) { |
||||
|
dingLiangScore = float64(sv.ReferenceScore) |
||||
|
// fmt.Printf("季度指标--->%v--->%v--->%v\n", sv.Name, sv.Id, dingLiangScore)
|
||||
|
} else { |
||||
|
switch monthInt { |
||||
|
case 3: |
||||
|
dingLiangScore, _ = statistics.DingLiangScoreCalculation(orgCont.Id, yearInt, sv.ReferenceScore, []int64{1, 2, 3}, sv.Id, sv.Cycles) |
||||
|
case 6: |
||||
|
dingLiangScore, _ = statistics.DingLiangScoreCalculation(orgCont.Id, yearInt, sv.ReferenceScore, []int64{4, 5, 6}, sv.Id, sv.Cycles) |
||||
|
case 9: |
||||
|
dingLiangScore, _ = statistics.DingLiangScoreCalculation(orgCont.Id, yearInt, sv.ReferenceScore, []int64{7, 8, 9}, sv.Id, sv.Cycles) |
||||
|
case 12: |
||||
|
dingLiangScore, _ = statistics.DingLiangScoreCalculation(orgCont.Id, yearInt, sv.ReferenceScore, []int64{10, 11, 12}, sv.Id, sv.Cycles) |
||||
|
default: |
||||
|
} |
||||
|
} |
||||
|
case 6: //年度指标
|
||||
|
if monthInt == 12 { |
||||
|
dingLiangScore, _ = statistics.DingLiangScoreCalculation(orgCont.Id, yearInt, sv.ReferenceScore, []int64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}, sv.Id, sv.Cycles) |
||||
|
} else { |
||||
|
dingLiangScore = float64(sv.ReferenceScore) |
||||
|
// fmt.Printf("年度指标--->%v--->%v--->%v\n", sv.Name, sv.Id, dingLiangScore)
|
||||
|
} |
||||
|
|
||||
|
case 7: //半年指标
|
||||
|
switch monthInt { |
||||
|
case 6: |
||||
|
dingLiangScore, _ = statistics.DingLiangScoreCalculation(orgCont.Id, yearInt, sv.ReferenceScore, []int64{1, 2, 3, 4, 5, 6}, sv.Id, sv.Cycles) |
||||
|
case 12: |
||||
|
dingLiangScore, _ = statistics.DingLiangScoreCalculation(orgCont.Id, yearInt, sv.ReferenceScore, []int64{7, 8, 9, 10, 11, 12}, sv.Id, sv.Cycles) |
||||
|
default: |
||||
|
dingLiangScore = float64(sv.ReferenceScore) |
||||
|
// fmt.Printf("半年指标--->%v--->%v--->%v\n", sv.Name, sv.Id, dingLiangScore)
|
||||
|
} |
||||
|
default: //月度指标
|
||||
|
dingLiangScore, _ = statistics.DingLiangScoreCalculation(orgCont.Id, yearInt, sv.ReferenceScore, []int64{monthInt}, sv.Id, sv.Cycles) |
||||
|
} |
||||
|
dingLiangScoreGd, _ := publicmethod.DecimalNew(dingLiangScore, 2) |
||||
|
getPoints = getPoints + dingLiangScoreGd |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
tayTime := time.Now().Unix() |
||||
|
currentYears := publicmethod.UnixTimeToDay(tayTime, 16) |
||||
|
currentMonth := publicmethod.UnixTimeToDay(tayTime, 17) |
||||
|
|
||||
|
currentYearsInt, _ := strconv.Atoi(currentYears) |
||||
|
currentMonthInt, _ := strconv.Atoi(currentMonth) |
||||
|
yearsInt, _ := strconv.Atoi(year) |
||||
|
monthsInt, _ := strconv.Atoi(month) |
||||
|
if currentYearsInt == yearsInt && monthsInt > currentMonthInt { |
||||
|
getPoints = 0 |
||||
|
} |
||||
|
if s.AxisMax < getPoints { |
||||
|
s.AxisMax = getPoints |
||||
|
} |
||||
|
if s.AxisMin == 0 { |
||||
|
s.AxisMin = getPoints |
||||
|
} else { |
||||
|
if s.AxisMin > getPoints { |
||||
|
s.AxisMin = getPoints |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
var orgScore SyncOTASVal |
||||
|
orgScore.OrgId = orgCont.Id |
||||
|
orgScore.Score = publicmethod.DecimalEs(getPoints, 2) |
||||
|
orgScore.Months, _ = strconv.Atoi(month) |
||||
|
s.OrgScore = append(s.OrgScore, orgScore) |
||||
|
SyncSeting.Done() |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2023-07-29 17:03:39 |
||||
|
@ 功能: 计算行政组织月份得分 |
||||
|
@ 参数 |
||||
|
# |
||||
|
@ 返回值 |
||||
|
# |
||||
|
@ 方法原型 |
||||
|
# |
||||
|
*/ |
||||
|
// func (){}
|
||||
@ -0,0 +1,564 @@ |
|||||
|
package statistics |
||||
|
|
||||
|
import ( |
||||
|
"encoding/json" |
||||
|
"fmt" |
||||
|
"key_performance_indicators/models/modelshr" |
||||
|
"key_performance_indicators/models/modelskpi" |
||||
|
"key_performance_indicators/overall/publicmethod" |
||||
|
"strconv" |
||||
|
"time" |
||||
|
|
||||
|
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response" |
||||
|
"github.com/gin-gonic/gin" |
||||
|
) |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2023-08-04 09:18:31 |
||||
|
@ 功能: 汇总方案定量指标详情历史记录(新版) |
||||
|
@ 参数 |
||||
|
|
||||
|
# |
||||
|
|
||||
|
@ 返回值 |
||||
|
|
||||
|
# |
||||
|
|
||||
|
@ 方法原型 |
||||
|
|
||||
|
# |
||||
|
*/ |
||||
|
func (a *ApiMethod) SummaryPlanRecord(c *gin.Context) { |
||||
|
var requestData detailedResultsLog |
||||
|
err := c.ShouldBindJSON(&requestData) |
||||
|
if err != nil { |
||||
|
response.Result(101, err, "数据获取失败!", c) |
||||
|
return |
||||
|
} |
||||
|
if requestData.TargetId == "" { |
||||
|
response.Result(102, err, "参数错误!请属入指标", c) |
||||
|
return |
||||
|
} |
||||
|
if requestData.Department == "" { |
||||
|
response.Result(103, err, "参数错误!请属入部门", c) |
||||
|
return |
||||
|
} |
||||
|
if requestData.Year == 0 { |
||||
|
requestData.Year = publicmethod.ComputingTime(time.Now().Unix(), 1) |
||||
|
} |
||||
|
if requestData.Months < 1 { |
||||
|
requestData.Months = 1 |
||||
|
} |
||||
|
if requestData.Months > 12 { |
||||
|
requestData.Months = 12 |
||||
|
} |
||||
|
orgId, _ := strconv.ParseInt(requestData.Department, 10, 64) |
||||
|
monthInt := int64(requestData.Months) |
||||
|
//获取当前时间考核方案
|
||||
|
targetScore, attribute, cycles := GetTargetPlanScore("", requestData.TargetId, orgId, requestData.Year, monthInt) |
||||
|
// fmt.Printf("targetScore:%v\nattribute:%v\ncycles:%v\n", targetScore, attribute, cycles)
|
||||
|
var sendList []dingLiangKaoHe |
||||
|
if err != nil { |
||||
|
response.Result(101, err, "数据获取失败!", c) |
||||
|
return |
||||
|
} |
||||
|
switch cycles { |
||||
|
case 5: //季度度指标
|
||||
|
|
||||
|
if publicmethod.IsInTrue[int64](monthInt, []int64{3, 6, 9, 12}) { |
||||
|
var fengDingZhi float64 = 0 |
||||
|
var lingJiang float64 = 0 |
||||
|
var quanJiang float64 = 0 |
||||
|
isTrue := true |
||||
|
var dingLiangScore float64 = 0 |
||||
|
switch monthInt { |
||||
|
case 3: |
||||
|
for i := 1; i <= 3; i++ { |
||||
|
sendListIng, _ := GetDingLiangLog(orgId, requestData.Year, int64(i), requestData.TargetId, fmt.Sprintf("%v月份实际分值", i)) |
||||
|
sendList = append(sendList, sendListIng...) |
||||
|
if i == 3 { |
||||
|
for _, v := range sendListIng { |
||||
|
fengDingZhi = v.Capping |
||||
|
lingJiang = v.Zeroprize |
||||
|
quanJiang = v.Allprize |
||||
|
if v.MtOrAt == 2 { |
||||
|
dingLiangScore = v.Score |
||||
|
isTrue = false |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
case 6: |
||||
|
for i := 4; i <= 6; i++ { |
||||
|
sendListIng, _ := GetDingLiangLog(orgId, requestData.Year, int64(i), requestData.TargetId, fmt.Sprintf("%v月份实际分值", i)) |
||||
|
sendList = append(sendList, sendListIng...) |
||||
|
if i == 6 { |
||||
|
for _, v := range sendListIng { |
||||
|
fengDingZhi = v.Capping |
||||
|
lingJiang = v.Zeroprize |
||||
|
quanJiang = v.Allprize |
||||
|
if v.MtOrAt == 2 { |
||||
|
dingLiangScore = v.Score |
||||
|
isTrue = false |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
case 9: |
||||
|
for i := 7; i <= 9; i++ { |
||||
|
sendListIng, _ := GetDingLiangLog(orgId, requestData.Year, int64(i), requestData.TargetId, fmt.Sprintf("%v月份实际分值", i)) |
||||
|
sendList = append(sendList, sendListIng...) |
||||
|
if i == 9 { |
||||
|
for _, v := range sendListIng { |
||||
|
fengDingZhi = v.Capping |
||||
|
lingJiang = v.Zeroprize |
||||
|
quanJiang = v.Allprize |
||||
|
if v.MtOrAt == 2 { |
||||
|
dingLiangScore = v.Score |
||||
|
isTrue = false |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
case 12: |
||||
|
for i := 10; i <= 12; i++ { |
||||
|
sendListIng, _ := GetDingLiangLog(orgId, requestData.Year, int64(i), requestData.TargetId, fmt.Sprintf("%v月份实际分值", i)) |
||||
|
sendList = append(sendList, sendListIng...) |
||||
|
if i == 12 { |
||||
|
for _, v := range sendListIng { |
||||
|
fengDingZhi = v.Capping |
||||
|
lingJiang = v.Zeroprize |
||||
|
quanJiang = v.Allprize |
||||
|
if v.MtOrAt == 2 { |
||||
|
dingLiangScore = v.Score |
||||
|
isTrue = false |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
default: |
||||
|
} |
||||
|
var secondCont dingLiangKaoHe |
||||
|
secondCont.MtOrAt = 1 //手动还是自动
|
||||
|
secondCont.Cont = "平均分" //说明
|
||||
|
secondCont.Nature = 1 |
||||
|
secondCont.Zeroprize = lingJiang |
||||
|
secondCont.Allprize = quanJiang |
||||
|
secondCont.Capping = fengDingZhi |
||||
|
|
||||
|
if attribute == 3 { |
||||
|
secondCont.Score = targetScore |
||||
|
} else { |
||||
|
|
||||
|
var daChengLv float64 = 0 |
||||
|
var pingJunXiShu float64 = 0 |
||||
|
for _, j := range sendList { |
||||
|
daChengLv = daChengLv + j.CompletionRateAll |
||||
|
pingJunXiShu++ |
||||
|
} |
||||
|
if pingJunXiShu > 0 { |
||||
|
pingJunZhi := daChengLv / pingJunXiShu |
||||
|
secondCont.Score = publicmethod.DecimalEs(GetQuantifyScore(targetScore, pingJunZhi, fengDingZhi), 2) |
||||
|
secondCont.CompletionRate = publicmethod.DecimalEs(pingJunZhi, 2) |
||||
|
} else { |
||||
|
secondCont.Score = targetScore |
||||
|
} |
||||
|
if !isTrue { |
||||
|
secondCont.Score = dingLiangScore |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
sendList = append(sendList, secondCont) |
||||
|
} else { |
||||
|
sendList, _ = GetDingLiangLog(orgId, requestData.Year, monthInt, requestData.TargetId, "") |
||||
|
} |
||||
|
case 6: //年度指标
|
||||
|
isTrue := true |
||||
|
var dingLiangScore float64 = 0 |
||||
|
var fengDingZhi float64 = 0 |
||||
|
var lingJiang float64 = 0 |
||||
|
var quanJiang float64 = 0 |
||||
|
for i := 1; i <= 12; i++ { |
||||
|
sendListIng, _ := GetDingLiangLog(orgId, requestData.Year, int64(i), requestData.TargetId, fmt.Sprintf("%v月份实际分值", i)) |
||||
|
sendList = append(sendList, sendListIng...) |
||||
|
if i == 12 { |
||||
|
for _, v := range sendListIng { |
||||
|
fengDingZhi = v.Capping |
||||
|
lingJiang = v.Zeroprize |
||||
|
quanJiang = v.Allprize |
||||
|
if v.MtOrAt == 2 { |
||||
|
dingLiangScore = v.Score |
||||
|
isTrue = false |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
var secondCont dingLiangKaoHe |
||||
|
secondCont.MtOrAt = 1 //手动还是自动
|
||||
|
secondCont.Cont = "平均分" //说明
|
||||
|
secondCont.Nature = 1 |
||||
|
secondCont.Zeroprize = lingJiang |
||||
|
secondCont.Allprize = quanJiang |
||||
|
secondCont.Capping = fengDingZhi |
||||
|
|
||||
|
if attribute == 3 { |
||||
|
secondCont.Score = targetScore |
||||
|
} else { |
||||
|
|
||||
|
var daChengLv float64 = 0 |
||||
|
var pingJunXiShu float64 = 0 |
||||
|
for _, j := range sendList { |
||||
|
daChengLv = daChengLv + j.CompletionRateAll |
||||
|
pingJunXiShu++ |
||||
|
} |
||||
|
if pingJunXiShu > 0 { |
||||
|
pingJunZhi := daChengLv / pingJunXiShu |
||||
|
secondCont.Score = publicmethod.DecimalEs(GetQuantifyScore(targetScore, pingJunZhi, fengDingZhi), 2) |
||||
|
secondCont.CompletionRate = publicmethod.DecimalEs(pingJunZhi, 2) |
||||
|
} else { |
||||
|
secondCont.Score = targetScore |
||||
|
} |
||||
|
if !isTrue { |
||||
|
secondCont.Score = dingLiangScore |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
sendList = append(sendList, secondCont) |
||||
|
case 7: //半年指标
|
||||
|
isTrue := true |
||||
|
var dingLiangScore float64 = 0 |
||||
|
var fengDingZhi float64 = 0 |
||||
|
var lingJiang float64 = 0 |
||||
|
var quanJiang float64 = 0 |
||||
|
if publicmethod.IsInTrue[int64](monthInt, []int64{1, 2, 3, 4, 5, 6}) { |
||||
|
for i := 1; i <= 6; i++ { |
||||
|
sendListIng, _ := GetDingLiangLog(orgId, requestData.Year, int64(i), requestData.TargetId, fmt.Sprintf("%v月份实际分值", i)) |
||||
|
sendList = append(sendList, sendListIng...) |
||||
|
if i == 6 { |
||||
|
for _, v := range sendListIng { |
||||
|
fengDingZhi = v.Capping |
||||
|
lingJiang = v.Zeroprize |
||||
|
quanJiang = v.Allprize |
||||
|
if v.MtOrAt == 2 { |
||||
|
dingLiangScore = v.Score |
||||
|
isTrue = false |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} else { |
||||
|
for i := 7; i <= 12; i++ { |
||||
|
sendListIng, _ := GetDingLiangLog(orgId, requestData.Year, int64(i), requestData.TargetId, fmt.Sprintf("%v月份实际分值", i)) |
||||
|
sendList = append(sendList, sendListIng...) |
||||
|
if i == 12 { |
||||
|
for _, v := range sendListIng { |
||||
|
fengDingZhi = v.Capping |
||||
|
lingJiang = v.Zeroprize |
||||
|
quanJiang = v.Allprize |
||||
|
if v.MtOrAt == 2 { |
||||
|
dingLiangScore = v.Score |
||||
|
isTrue = false |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
var secondCont dingLiangKaoHe |
||||
|
secondCont.MtOrAt = 1 //手动还是自动
|
||||
|
secondCont.Cont = "平均分" //说明
|
||||
|
secondCont.Nature = 1 |
||||
|
secondCont.Zeroprize = lingJiang |
||||
|
secondCont.Allprize = quanJiang |
||||
|
secondCont.Capping = fengDingZhi |
||||
|
if attribute == 3 { |
||||
|
secondCont.Score = targetScore |
||||
|
} else { |
||||
|
|
||||
|
var daChengLv float64 = 0 |
||||
|
var pingJunXiShu float64 = 0 |
||||
|
for _, j := range sendList { |
||||
|
daChengLv = daChengLv + j.CompletionRateAll |
||||
|
pingJunXiShu++ |
||||
|
} |
||||
|
if pingJunXiShu > 0 { |
||||
|
pingJunZhi := daChengLv / pingJunXiShu |
||||
|
secondCont.Score = publicmethod.DecimalEs(GetQuantifyScore(targetScore, pingJunZhi, fengDingZhi), 2) |
||||
|
secondCont.CompletionRate = publicmethod.DecimalEs(pingJunZhi, 2) |
||||
|
} else { |
||||
|
secondCont.Score = targetScore |
||||
|
} |
||||
|
if !isTrue { |
||||
|
secondCont.Score = dingLiangScore |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
sendList = append(sendList, secondCont) |
||||
|
default: |
||||
|
sendList, _ = GetDingLiangLog(orgId, requestData.Year, monthInt, requestData.TargetId, "") |
||||
|
// chushu := len(sendList)
|
||||
|
// var dingLiangScore float64 = 0
|
||||
|
// if chushu > 0 {
|
||||
|
// isTrue := true
|
||||
|
// for _, v := range sendList {
|
||||
|
// dingLiangScore = dingLiangScore + v.Score
|
||||
|
// if v.MtOrAt == 2 {
|
||||
|
// dingLiangScore = v.Score
|
||||
|
// isTrue = false
|
||||
|
// }
|
||||
|
// }
|
||||
|
// if isTrue {
|
||||
|
// dingLiangScore, _ = publicmethod.DecimalNew(dingLiangScore/float64(chushu), 2)
|
||||
|
// statisCont.Score = dingLiangScore
|
||||
|
// } else {
|
||||
|
// statisCont.Score = dingLiangScore
|
||||
|
// }
|
||||
|
|
||||
|
// } else {
|
||||
|
// targetScore, _, _ := GetTargetPlanScore("", cv.Id, orgId, requestData.Year, monthInt)
|
||||
|
// statisCont.Score = targetScore
|
||||
|
// }
|
||||
|
} |
||||
|
response.Result(0, sendList, "查询完成!", c) |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2023-08-05 08:47:01 |
||||
|
@ 功能: 计算定量指标分值 |
||||
|
@ 参数 |
||||
|
|
||||
|
#targetScore 指标分 |
||||
|
#completionRate 达成率 |
||||
|
#capping 封顶值 |
||||
|
|
||||
|
@ 返回值 |
||||
|
|
||||
|
# |
||||
|
|
||||
|
@ 方法原型 |
||||
|
|
||||
|
# |
||||
|
*/ |
||||
|
func GetQuantifyScore(targetScore, completionRate, capping float64) (score float64) { |
||||
|
// fmt.Printf("targetScore:---》%v\ncompletionRate:---》%v\ncapping:---》%v\n", targetScore, completionRate, capping)
|
||||
|
if capping != 0 { |
||||
|
if completionRate >= capping { |
||||
|
score = targetScore * (capping / 100) |
||||
|
} else { |
||||
|
score = targetScore * (completionRate / 100) |
||||
|
} |
||||
|
} else { |
||||
|
score = targetScore * (completionRate / 100) |
||||
|
} |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2023-08-07 10:42:04 |
||||
|
@ 功能: 方案得分明细(new) |
||||
|
@ 参数 |
||||
|
|
||||
|
# |
||||
|
|
||||
|
@ 返回值 |
||||
|
|
||||
|
# |
||||
|
|
||||
|
@ 方法原型 |
||||
|
|
||||
|
# |
||||
|
*/ |
||||
|
func (a *ApiMethod) NewSummaryDetails(c *gin.Context) { |
||||
|
var requestData detailedResults |
||||
|
err := c.ShouldBindJSON(&requestData) |
||||
|
if err != nil { |
||||
|
response.Result(101, err, "数据获取失败!", c) |
||||
|
return |
||||
|
} |
||||
|
if requestData.Department == "" { |
||||
|
response.Result(102, err, "参数错误!请属入部门", c) |
||||
|
return |
||||
|
} |
||||
|
if requestData.Year == 0 { |
||||
|
requestData.Year = publicmethod.ComputingTime(time.Now().Unix(), 1) |
||||
|
} |
||||
|
if requestData.Months < 1 { |
||||
|
requestData.Months = 1 |
||||
|
} |
||||
|
if requestData.Months > 12 { |
||||
|
requestData.Months = 12 |
||||
|
} |
||||
|
orgId, _ := strconv.ParseInt(requestData.Department, 10, 64) |
||||
|
planVersion, _ := publicmethod.GetPlanVresion(orgId, requestData.Year, int64(requestData.Months)) |
||||
|
var planVersioInfo []AddDutyNewCont |
||||
|
json.Unmarshal([]byte(planVersion.Content), &planVersioInfo) |
||||
|
var lookStatistics []detailedResultsList |
||||
|
for _, v := range planVersioInfo { //维度
|
||||
|
for _, cv := range v.Child { //指标
|
||||
|
if cv.Id == "43" { |
||||
|
|
||||
|
var statisCont detailedResultsList |
||||
|
statisCont.DimensionId = v.Id //维度Id
|
||||
|
statisCont.DimensionName = v.Name //维度名称
|
||||
|
statisCont.DimensionWeight = int64(v.ZhiFraction) //维度权重
|
||||
|
statisCont.TargetId = cv.Id //指标ID
|
||||
|
statisCont.TargetName = cv.Name //指标名称
|
||||
|
statisCont.TargetCont = cv.Content //指标名称
|
||||
|
statisCont.Targetweight = cv.ReferenceScore //指标权重
|
||||
|
statisCont.GroupId = strconv.FormatInt(planVersion.Group, 10) //集团Id
|
||||
|
statisCont.Versio = planVersion.Key |
||||
|
var groupCont modelshr.AdministrativeOrganization |
||||
|
groupCont.GetCont(map[string]interface{}{"`id`": planVersion.Group}, "name") |
||||
|
statisCont.GroupName = groupCont.Name //集团名称
|
||||
|
statisCont.DepartmentId = strconv.FormatInt(planVersion.Department, 10) //部门ID
|
||||
|
var departCont modelshr.AdministrativeOrganization |
||||
|
departCont.GetCont(map[string]interface{}{"`id`": planVersion.Department}, "name") |
||||
|
statisCont.DepartmentName = departCont.Name //部门名称
|
||||
|
|
||||
|
var evalTargetCont modelskpi.EvaluationTarget //指标信息
|
||||
|
if cv.Id != "" && cv.Id != "0" { |
||||
|
targetErr := evalTargetCont.GetCont(map[string]interface{}{"`et_id`": cv.Id}, "et_type") |
||||
|
if targetErr == nil { |
||||
|
monthInt := int64(requestData.Months) |
||||
|
if evalTargetCont.Type == 1 { //定性指标
|
||||
|
statisCont.Score, statisCont.ExecutiveDepartment = DingXingScoreCalculation(orgId, requestData.Year, cv.ReferenceScore, []int64{monthInt}, cv.Id) |
||||
|
} else { //定量指标
|
||||
|
var sendList []dingLiangKaoHe |
||||
|
var dingLiangScore float64 = 0 |
||||
|
switch cv.Cycles { |
||||
|
case 5: //季度指标
|
||||
|
var fengDingZhi float64 = 0 |
||||
|
isTrue := true |
||||
|
switch monthInt { |
||||
|
case 3: |
||||
|
for i := 1; i <= 3; i++ { |
||||
|
sendListIng, orgNameList := GetDingLiangLog(orgId, requestData.Year, int64(i), cv.Id, fmt.Sprintf("%v月份实际分值", i)) |
||||
|
sendList = append(sendList, sendListIng...) |
||||
|
statisCont.ExecutiveDepartment = append(statisCont.ExecutiveDepartment, orgNameList...) |
||||
|
if i == 3 { |
||||
|
for _, v := range sendListIng { |
||||
|
fengDingZhi = v.Capping |
||||
|
if v.MtOrAt == 2 { |
||||
|
dingLiangScore = v.Score |
||||
|
isTrue = false |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
case 6: |
||||
|
for i := 4; i <= 6; i++ { |
||||
|
sendListIng, orgNameList := GetDingLiangLog(orgId, requestData.Year, int64(i), cv.Id, fmt.Sprintf("%v月份实际分值", i)) |
||||
|
sendList = append(sendList, sendListIng...) |
||||
|
statisCont.ExecutiveDepartment = append(statisCont.ExecutiveDepartment, orgNameList...) |
||||
|
if i == 6 { |
||||
|
for _, v := range sendListIng { |
||||
|
fengDingZhi = v.Capping |
||||
|
if v.MtOrAt == 2 { |
||||
|
dingLiangScore = v.Score |
||||
|
isTrue = false |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
case 9: |
||||
|
for i := 7; i <= 9; i++ { |
||||
|
sendListIng, orgNameList := GetDingLiangLog(orgId, requestData.Year, int64(i), cv.Id, fmt.Sprintf("%v月份实际分值", i)) |
||||
|
sendList = append(sendList, sendListIng...) |
||||
|
statisCont.ExecutiveDepartment = append(statisCont.ExecutiveDepartment, orgNameList...) |
||||
|
if i == 9 { |
||||
|
for _, v := range sendListIng { |
||||
|
fengDingZhi = v.Capping |
||||
|
if v.MtOrAt == 2 { |
||||
|
dingLiangScore = v.Score |
||||
|
isTrue = false |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
case 12: |
||||
|
for i := 10; i <= 12; i++ { |
||||
|
sendListIng, orgNameList := GetDingLiangLog(orgId, requestData.Year, int64(i), cv.Id, fmt.Sprintf("%v月份实际分值", i)) |
||||
|
sendList = append(sendList, sendListIng...) |
||||
|
statisCont.ExecutiveDepartment = append(statisCont.ExecutiveDepartment, orgNameList...) |
||||
|
if i == 12 { |
||||
|
for _, v := range sendListIng { |
||||
|
fengDingZhi = v.Capping |
||||
|
if v.MtOrAt == 2 { |
||||
|
dingLiangScore = v.Score |
||||
|
isTrue = false |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
default: |
||||
|
isTrue = true |
||||
|
} |
||||
|
if isTrue { |
||||
|
targetScore, attribute, _ := GetTargetPlanScore("", cv.Id, orgId, requestData.Year, monthInt) |
||||
|
if attribute == 3 { |
||||
|
statisCont.Score = targetScore |
||||
|
} else { |
||||
|
var daChengLv float64 = 0 |
||||
|
var pingJunXiShu float64 = 0 |
||||
|
for _, j := range sendList { |
||||
|
daChengLv = daChengLv + j.CompletionRateAll |
||||
|
pingJunXiShu++ |
||||
|
} |
||||
|
if pingJunXiShu > 0 { |
||||
|
pingJunZhi := daChengLv / pingJunXiShu |
||||
|
statisCont.Score = publicmethod.DecimalEs(GetQuantifyScore(targetScore, pingJunZhi, fengDingZhi), 2) |
||||
|
} else { |
||||
|
statisCont.Score = targetScore |
||||
|
} |
||||
|
} |
||||
|
} else { |
||||
|
statisCont.Score = dingLiangScore |
||||
|
} |
||||
|
|
||||
|
default: |
||||
|
sendList, statisCont.ExecutiveDepartment = GetDingLiangLog(orgId, requestData.Year, monthInt, cv.Id, "") |
||||
|
chushu := len(sendList) |
||||
|
if chushu > 0 { |
||||
|
isTrue := true |
||||
|
for _, v := range sendList { |
||||
|
dingLiangScore = dingLiangScore + v.Score |
||||
|
if v.MtOrAt == 2 { |
||||
|
dingLiangScore = v.Score |
||||
|
isTrue = false |
||||
|
} |
||||
|
} |
||||
|
if isTrue { |
||||
|
dingLiangScore, _ = publicmethod.DecimalNew(dingLiangScore/float64(chushu), 2) |
||||
|
statisCont.Score = dingLiangScore |
||||
|
} else { |
||||
|
statisCont.Score = dingLiangScore |
||||
|
} |
||||
|
|
||||
|
} else { |
||||
|
targetScore, _, _ := GetTargetPlanScore("", cv.Id, orgId, requestData.Year, monthInt) |
||||
|
statisCont.Score = targetScore |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
statisCont.Type = evalTargetCont.Type //1:定性;2:定量
|
||||
|
statisCont.Unit = cv.Unit //单位
|
||||
|
statisCont.Cycle = cv.Cycles //周期
|
||||
|
statisCont.Cycleattr = cv.CycleAttres //辅助参数
|
||||
|
lookStatistics = append(lookStatistics, statisCont) |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
response.Result(0, lookStatistics, "查询完成", c) |
||||
|
} |
||||
@ -0,0 +1,140 @@ |
|||||
|
package statistics |
||||
|
|
||||
|
import ( |
||||
|
"key_performance_indicators/models/modelshr" |
||||
|
"key_performance_indicators/overall" |
||||
|
"key_performance_indicators/overall/publicmethod" |
||||
|
"strconv" |
||||
|
"time" |
||||
|
|
||||
|
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response" |
||||
|
"github.com/gin-gonic/gin" |
||||
|
) |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2023-08-17 16:44:24 |
||||
|
@ 功能: 行政组织成绩单(新版) |
||||
|
@ 参数 |
||||
|
|
||||
|
# |
||||
|
|
||||
|
@ 返回值 |
||||
|
|
||||
|
# |
||||
|
|
||||
|
@ 方法原型 |
||||
|
|
||||
|
# |
||||
|
*/ |
||||
|
func (a *ApiMethod) OrgTranscriptNew(c *gin.Context) { |
||||
|
//获取登录人信息
|
||||
|
context, err := publicmethod.LoginMyCont(c) |
||||
|
if err != nil { |
||||
|
publicmethod.Result(1, err, c, "您无权进行此操作!") |
||||
|
return |
||||
|
} |
||||
|
var requestData TranscriptTable |
||||
|
c.ShouldBindJSON(&requestData) |
||||
|
//获取当前访问人的公司组织架构
|
||||
|
var orgList []modelshr.AdministrativeOrganization |
||||
|
gromDb := overall.CONSTANT_DB_HR.Model(&modelshr.AdministrativeOrganization{}).Select("`id`,`name`,`sort`").Where("ispower = 1 AND state = 1 AND organization_type > 2") |
||||
|
if requestData.Group != "" { |
||||
|
gromDb = gromDb.Where("superior = ?", requestData.Group) |
||||
|
} else { |
||||
|
gromDb = gromDb.Where("superior = ?", context.Company) |
||||
|
} |
||||
|
if requestData.Department != "" { |
||||
|
gromDb = gromDb.Where("`id` = ?", requestData.Department) |
||||
|
} |
||||
|
err = gromDb.Find(&orgList).Error |
||||
|
if err != nil { |
||||
|
response.Result(102, err, "没有查询到数据", c) |
||||
|
return |
||||
|
} |
||||
|
if len(orgList) <= 0 { |
||||
|
response.Result(103, err, "没有查询到数据", c) |
||||
|
return |
||||
|
} |
||||
|
var orgAry []modelshr.AdministrativeOrganization //行政组织列表
|
||||
|
for _, ov := range orgList { |
||||
|
if ov.Id != 163 && ov.Id != 281 { |
||||
|
sunOrgList, orgSunErr := getSunOrgList(ov.Id, "`id`", "`name`", "`sort`") |
||||
|
if orgSunErr == nil && len(sunOrgList) > 0 { |
||||
|
orgAry = append(orgAry, sunOrgList...) |
||||
|
} else { |
||||
|
orgAry = append(orgAry, ov) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
//计算要查询的年份
|
||||
|
currentYear := publicmethod.ComputingTime(time.Now().Unix(), 1) //当前年
|
||||
|
todayYear := currentYear //今年
|
||||
|
if requestData.Year != "" { |
||||
|
yearInt64, _ := strconv.ParseInt(requestData.Year, 10, 64) |
||||
|
currentYear = yearInt64 |
||||
|
} |
||||
|
//计算月
|
||||
|
var monthTody []int64 |
||||
|
if len(requestData.Month) < 1 { |
||||
|
if currentYear == todayYear { |
||||
|
monthTodyIng := publicmethod.ComputingTime(time.Now().Unix(), 3) |
||||
|
var montInt64 int64 |
||||
|
for montInt64 = 1; montInt64 <= monthTodyIng; montInt64++ { |
||||
|
monthTody = append(monthTody, montInt64) |
||||
|
} |
||||
|
} else { |
||||
|
var montInt64All int64 |
||||
|
for montInt64All = 1; montInt64All <= 12; montInt64All++ { |
||||
|
monthTody = append(monthTody, montInt64All) |
||||
|
} |
||||
|
} |
||||
|
} else { |
||||
|
for _, mmv := range requestData.Month { |
||||
|
monthTody = append(monthTody, int64(mmv)) |
||||
|
} |
||||
|
} |
||||
|
//保证月份不为负数
|
||||
|
if len(monthTody) < 1 { |
||||
|
monthTody = append(monthTody, 1) |
||||
|
} |
||||
|
/* |
||||
|
设定协程 |
||||
|
遍历行政组织,并发计算 |
||||
|
*/ |
||||
|
var orgTranscript TranscriptTableData |
||||
|
for _, v := range orgAry { |
||||
|
// if v.Id == 362 {
|
||||
|
syncProcess.Add(1) |
||||
|
go orgTranscript.StaticticsOrgTimeResult(v, currentYear, monthTody) |
||||
|
// }
|
||||
|
} |
||||
|
syncProcess.Wait() |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2023-08-18 08:16:52 |
||||
|
@ 功能: 计算每个行政组织得分 |
||||
|
@ 参数 |
||||
|
|
||||
|
# |
||||
|
|
||||
|
@ 返回值 |
||||
|
|
||||
|
# |
||||
|
|
||||
|
@ 方法原型 |
||||
|
|
||||
|
# |
||||
|
*/ |
||||
|
func (t *TranscriptTableData) EveryOrgCensusResult(orgCont modelshr.AdministrativeOrganization, year int64, month []int64) { |
||||
|
//锁操作
|
||||
|
t.mutext.Lock() |
||||
|
defer t.mutext.Unlock() |
||||
|
|
||||
|
syncProcess.Done() //结束本协程
|
||||
|
} |
||||
File diff suppressed because it is too large
@ -0,0 +1,151 @@ |
|||||
|
package statistics |
||||
|
|
||||
|
import ( |
||||
|
"encoding/json" |
||||
|
"fmt" |
||||
|
"key_performance_indicators/models/modelshr" |
||||
|
"key_performance_indicators/models/modelskpi" |
||||
|
"key_performance_indicators/overall/publicmethod" |
||||
|
"strconv" |
||||
|
"time" |
||||
|
|
||||
|
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response" |
||||
|
"github.com/gin-gonic/gin" |
||||
|
) |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2023-07-29 15:21:47 |
||||
|
@ 功能: 方案得分明细 |
||||
|
@ 参数 |
||||
|
|
||||
|
# |
||||
|
|
||||
|
@ 返回值 |
||||
|
|
||||
|
# |
||||
|
|
||||
|
@ 方法原型 |
||||
|
|
||||
|
# |
||||
|
*/ |
||||
|
func (a *ApiMethod) SummaryDetails(c *gin.Context) { |
||||
|
var requestData detailedResults |
||||
|
err := c.ShouldBindJSON(&requestData) |
||||
|
if err != nil { |
||||
|
response.Result(101, err, "数据获取失败!", c) |
||||
|
return |
||||
|
} |
||||
|
if requestData.Department == "" { |
||||
|
response.Result(102, err, "参数错误!请属入部门", c) |
||||
|
return |
||||
|
} |
||||
|
if requestData.Year == 0 { |
||||
|
requestData.Year = publicmethod.ComputingTime(time.Now().Unix(), 1) |
||||
|
} |
||||
|
if requestData.Months < 1 { |
||||
|
requestData.Months = 1 |
||||
|
} |
||||
|
if requestData.Months > 12 { |
||||
|
requestData.Months = 12 |
||||
|
} |
||||
|
orgId, _ := strconv.ParseInt(requestData.Department, 10, 64) |
||||
|
planVersion, _ := publicmethod.GetPlanVresion(orgId, requestData.Year, int64(requestData.Months)) |
||||
|
var planVersioInfo []AddDutyNewCont |
||||
|
json.Unmarshal([]byte(planVersion.Content), &planVersioInfo) |
||||
|
var lookStatistics []detailedResultsList |
||||
|
for _, v := range planVersioInfo { //维度
|
||||
|
for _, cv := range v.Child { //指标
|
||||
|
// if cv.Id == "12" {
|
||||
|
var statisCont detailedResultsList |
||||
|
statisCont.GroupId = strconv.FormatInt(planVersion.Group, 10) //集团Id
|
||||
|
statisCont.Versio = planVersion.Key |
||||
|
var groupCont modelshr.AdministrativeOrganization |
||||
|
groupCont.GetCont(map[string]interface{}{"`id`": planVersion.Group}, "name") |
||||
|
statisCont.GroupName = groupCont.Name //集团名称
|
||||
|
statisCont.DepartmentId = strconv.FormatInt(planVersion.Department, 10) //部门ID
|
||||
|
var departCont modelshr.AdministrativeOrganization |
||||
|
departCont.GetCont(map[string]interface{}{"`id`": planVersion.Department}, "name") |
||||
|
statisCont.DepartmentName = departCont.Name //部门名称
|
||||
|
statisCont.DimensionId = v.Id //维度Id
|
||||
|
statisCont.DimensionName = v.Name //维度名称
|
||||
|
statisCont.DimensionWeight = int64(v.ZhiFraction) //维度权重
|
||||
|
statisCont.TargetId = cv.Id //指标ID
|
||||
|
statisCont.TargetName = cv.Name //指标名称
|
||||
|
statisCont.TargetCont = cv.Content //指标名称
|
||||
|
statisCont.Targetweight = cv.ReferenceScore //指标权重
|
||||
|
|
||||
|
var evalTargetCont modelskpi.EvaluationTarget //指标信息
|
||||
|
if cv.Id != "" && cv.Id != "0" { |
||||
|
targetErr := evalTargetCont.GetCont(map[string]interface{}{"`et_id`": cv.Id}, "et_type") |
||||
|
monthInt := int64(requestData.Months) |
||||
|
if targetErr == nil { |
||||
|
if evalTargetCont.Type == 1 { |
||||
|
//定性指标
|
||||
|
statisCont.Score, statisCont.ExecutiveDepartment = DingXingScoreCalculation(orgId, requestData.Year, cv.ReferenceScore, []int64{monthInt}, cv.Id) |
||||
|
|
||||
|
} else { |
||||
|
//定量指标
|
||||
|
var dingLiangScore float64 |
||||
|
var orgList []string |
||||
|
//定量考核
|
||||
|
switch cv.Cycles { |
||||
|
case 5: //季度指标
|
||||
|
quarterList := []int64{3, 6, 9, 12} |
||||
|
if !publicmethod.IsInTrue[int64](monthInt, quarterList) { |
||||
|
dingLiangScore = float64(cv.ReferenceScore) |
||||
|
// fmt.Printf("季度指标--->%v--->%v--->%v\n", cv.Name, cv.Id, dingLiangScore)
|
||||
|
} else { |
||||
|
switch monthInt { |
||||
|
case 3: |
||||
|
dingLiangScore, orgList = DingLiangScoreCalculation(orgId, requestData.Year, cv.ReferenceScore, []int64{1, 2, 3}, cv.Id, cv.Cycles) |
||||
|
case 6: |
||||
|
dingLiangScore, orgList = DingLiangScoreCalculation(orgId, requestData.Year, cv.ReferenceScore, []int64{4, 5, 6}, cv.Id, cv.Cycles) |
||||
|
case 9: |
||||
|
dingLiangScore, orgList = DingLiangScoreCalculation(orgId, requestData.Year, cv.ReferenceScore, []int64{7, 8, 9}, cv.Id, cv.Cycles) |
||||
|
case 12: |
||||
|
dingLiangScore, orgList = DingLiangScoreCalculation(orgId, requestData.Year, cv.ReferenceScore, []int64{10, 11, 12}, cv.Id, cv.Cycles) |
||||
|
default: |
||||
|
} |
||||
|
} |
||||
|
case 6: //年度指标
|
||||
|
if monthInt == 12 { |
||||
|
dingLiangScore, orgList = DingLiangScoreCalculation(orgId, requestData.Year, cv.ReferenceScore, []int64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}, cv.Id, cv.Cycles) |
||||
|
} else { |
||||
|
dingLiangScore = float64(cv.ReferenceScore) |
||||
|
// fmt.Printf("年度指标--->%v--->%v--->%v\n", cv.Name, cv.Id, dingLiangScore)
|
||||
|
} |
||||
|
|
||||
|
case 7: //半年指标
|
||||
|
switch monthInt { |
||||
|
case 6: |
||||
|
dingLiangScore, orgList = DingLiangScoreCalculation(orgId, requestData.Year, cv.ReferenceScore, []int64{1, 2, 3, 4, 5, 6}, cv.Id, cv.Cycles) |
||||
|
case 12: |
||||
|
dingLiangScore, orgList = DingLiangScoreCalculation(orgId, requestData.Year, cv.ReferenceScore, []int64{7, 8, 9, 10, 11, 12}, cv.Id, cv.Cycles) |
||||
|
default: |
||||
|
dingLiangScore = float64(cv.ReferenceScore) |
||||
|
// fmt.Printf("半年指标--->%v--->%v--->%v\n", cv.Name, cv.Id, dingLiangScore)
|
||||
|
} |
||||
|
default: //月度指标
|
||||
|
dingLiangScore, orgList = DingLiangScoreCalculation(orgId, requestData.Year, cv.ReferenceScore, []int64{monthInt}, cv.Id, cv.Cycles) |
||||
|
} |
||||
|
dingLiangScoreGd, _ := publicmethod.DecimalNew(dingLiangScore, 2) |
||||
|
statisCont.Score = dingLiangScoreGd |
||||
|
statisCont.ExecutiveDepartment = orgList |
||||
|
fmt.Printf("定量指标---->%v\n---->%v\n", dingLiangScoreGd, orgList) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
statisCont.Type = evalTargetCont.Type //1:定性;2:定量
|
||||
|
statisCont.Unit = cv.Unit //单位
|
||||
|
statisCont.Cycle = cv.Cycles //周期
|
||||
|
statisCont.Cycleattr = cv.CycleAttres //辅助参数
|
||||
|
|
||||
|
lookStatistics = append(lookStatistics, statisCont) |
||||
|
// }
|
||||
|
|
||||
|
} |
||||
|
} |
||||
|
response.Result(0, lookStatistics, "查询完成", c) |
||||
|
} |
||||
@ -0,0 +1,229 @@ |
|||||
|
package statistics |
||||
|
|
||||
|
import ( |
||||
|
"key_performance_indicators/overall/publicmethod" |
||||
|
"sync" |
||||
|
|
||||
|
"github.com/gin-gonic/gin" |
||||
|
) |
||||
|
|
||||
|
type ApiMethod struct{} |
||||
|
|
||||
|
// 携程设置
|
||||
|
// var syncSeting = sync.WaitGroup{}
|
||||
|
var syncProcess = sync.WaitGroup{} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2023-07-27 10:11:58 |
||||
|
@ 功能: 统计入口 |
||||
|
@ 参数 |
||||
|
|
||||
|
# |
||||
|
|
||||
|
@ 返回值 |
||||
|
|
||||
|
# |
||||
|
|
||||
|
@ 方法原型 |
||||
|
|
||||
|
# |
||||
|
*/ |
||||
|
func (a *ApiMethod) Index(c *gin.Context) { |
||||
|
outputCont := publicmethod.MapOut[string]() |
||||
|
outputCont["index"] = "统计入口" |
||||
|
publicmethod.Result(0, outputCont, c) |
||||
|
} |
||||
|
|
||||
|
// 绩效考核成绩表
|
||||
|
type TranscriptTable struct { |
||||
|
Group string `json:"group"` |
||||
|
Department string `json:"department"` |
||||
|
Year string `year` |
||||
|
Month []int `json:"month"` |
||||
|
} |
||||
|
|
||||
|
// 绩效考核成绩表结果
|
||||
|
type TranscriptTableDateList struct { |
||||
|
DepartmentId string `json:"departmentid"` |
||||
|
Department string `json:"department"` |
||||
|
Sort int `json:"sort"` |
||||
|
A float64 `json:"a"` |
||||
|
B float64 `json:"b"` |
||||
|
C float64 `json:"C"` |
||||
|
D float64 `json:"d"` |
||||
|
E float64 `json:"e"` |
||||
|
F float64 `json:"f"` |
||||
|
G float64 `json:"g"` |
||||
|
H float64 `json:"h"` |
||||
|
I float64 `json:"i"` |
||||
|
J float64 `json:"J"` |
||||
|
K float64 `json:"K"` |
||||
|
L float64 `json:"L"` |
||||
|
} |
||||
|
|
||||
|
// 计算得分性质
|
||||
|
type defenfenxi struct { |
||||
|
Title string `json:"title"` |
||||
|
TimeClass string `json:"timeclass"` |
||||
|
Month int64 `json:"month"` |
||||
|
Stroce float64 `json:"stroce"` |
||||
|
State int `json:"state"` |
||||
|
} |
||||
|
|
||||
|
// 成绩表
|
||||
|
type TranscriptTableData struct { |
||||
|
ScoreStatistics []TranscriptTableDateList |
||||
|
Defen []defenfenxi |
||||
|
mutext sync.RWMutex |
||||
|
} |
||||
|
|
||||
|
// 读取成绩表锁数据
|
||||
|
func (t *TranscriptTableData) readTranscriptData() []TranscriptTableDateList { |
||||
|
t.mutext.RLock() |
||||
|
defer t.mutext.RUnlock() |
||||
|
return t.ScoreStatistics |
||||
|
} |
||||
|
|
||||
|
type countEveryDepartmentMonthScore struct { |
||||
|
outData []everyDepartmentScore |
||||
|
mutext sync.RWMutex |
||||
|
} |
||||
|
|
||||
|
// 部门月分数
|
||||
|
type everyDepartmentScore struct { |
||||
|
MonthVal int64 `json:"monthval"` |
||||
|
Score float64 `json:"score"` |
||||
|
} |
||||
|
|
||||
|
// 读取锁数据
|
||||
|
func (c *countEveryDepartmentMonthScore) readMyDayData() []everyDepartmentScore { |
||||
|
c.mutext.RLock() |
||||
|
defer c.mutext.RUnlock() |
||||
|
return c.outData |
||||
|
} |
||||
|
|
||||
|
var syncProcessDepartTarget = sync.WaitGroup{} //获取指标相关参数
|
||||
|
// 方案回显
|
||||
|
type AddDutyNewCont struct { |
||||
|
Id string `json:"id"` //维度ID
|
||||
|
Name string `json:"name"` |
||||
|
// Order int64 `json:"ordering"`
|
||||
|
ZhiFraction int `json:"zhiFraction"` |
||||
|
Child []EvaluPross `json:"child"` //考核细则
|
||||
|
} |
||||
|
|
||||
|
// 指标
|
||||
|
type EvaluPross struct { |
||||
|
Id string `json:"id"` //维度ID
|
||||
|
Name string `json:"name"` |
||||
|
Content string `json:"content"` //指标说明
|
||||
|
Unit string `json:"unit"` //单位"`
|
||||
|
ReferenceScore int64 `json:"referencescore"` //标准分值"`
|
||||
|
Cycles int `json:"cycle"` //1:班;2:天;3:周;4:月;5:季度;6:年"`
|
||||
|
CycleAttres int `json:"cycleattr"` //辅助计数"`
|
||||
|
State int `json:"state"` |
||||
|
Score int64 `json:"score"` //分数
|
||||
|
QualEvalId string `json:"qeid"` |
||||
|
Status int `json:"status"` |
||||
|
} |
||||
|
|
||||
|
// 定量流水全奖值、零奖值、封顶值
|
||||
|
type FlowLogAllZreo struct { |
||||
|
Id string `json:"id"` |
||||
|
TargetId string `json:"targetid"` //指标ID`
|
||||
|
Zeroprize float64 `json:"zeroprize"` //零奖值"`
|
||||
|
Allprize float64 `json:"allprize"` //全奖值"`
|
||||
|
Capping float64 `json:"capping"` //封顶值"`
|
||||
|
} |
||||
|
|
||||
|
// 图标维度输出
|
||||
|
type TranscriptTableDateListChars struct { |
||||
|
XLine []string `json:"xline"` |
||||
|
Cylindrical []string `json:"cylindrical"` |
||||
|
YLine []YlineData `json:"cylindricaldata"` |
||||
|
} |
||||
|
|
||||
|
type YlineData struct { |
||||
|
Name string `json:"name"` |
||||
|
Data []float64 `json:"data"` |
||||
|
} |
||||
|
|
||||
|
// 行政组织级统计
|
||||
|
type orgShierTongji struct { |
||||
|
A []float64 `json:"a"` |
||||
|
B []float64 `json:"b"` |
||||
|
C []float64 `json:"C"` |
||||
|
D []float64 `json:"d"` |
||||
|
E []float64 `json:"e"` |
||||
|
F []float64 `json:"f"` |
||||
|
G []float64 `json:"g"` |
||||
|
H []float64 `json:"h"` |
||||
|
I []float64 `json:"i"` |
||||
|
J []float64 `json:"J"` |
||||
|
K []float64 `json:"K"` |
||||
|
L []float64 `json:"L"` |
||||
|
} |
||||
|
|
||||
|
// 查询成绩表月份明细
|
||||
|
type detailedResults struct { |
||||
|
Department string `json:"department"` //部门
|
||||
|
Year int64 `json:"year"` //年
|
||||
|
Months int `json:"month"` //月份
|
||||
|
} |
||||
|
|
||||
|
// 查询成绩表月份明细历史
|
||||
|
type detailedResultsLog struct { |
||||
|
TargetId string `json:"targetid"` //指标ID
|
||||
|
detailedResults |
||||
|
} |
||||
|
|
||||
|
// 定量考核基础参数
|
||||
|
type dingLiangKaoHe struct { |
||||
|
Zeroprize float64 `json:"zeroprize"` //零奖值"`
|
||||
|
Allprize float64 `json:"allprize"` //全奖值"`
|
||||
|
Capping float64 `json:"capping"` //封顶值"`
|
||||
|
Actual float64 `json:"actual"` //实际值
|
||||
|
CompletionRate float64 `json:"completionrate"` //达成率
|
||||
|
CompletionRateAll float64 `json:"completionrateall"` //达成率
|
||||
|
Score float64 `json:"score"` //得分
|
||||
|
MtOrAt int `json:"mtorat"` //手动还是自动
|
||||
|
Cont string `json:"count"` //说明
|
||||
|
Nature int `json:"nature"` //性质
|
||||
|
} |
||||
|
|
||||
|
// 输出考核方案月份详情表
|
||||
|
type detailedResultsList struct { |
||||
|
GroupId string `json:"group"` //集团Id
|
||||
|
GroupName string `json:"groupname"` //集团名称
|
||||
|
DepartmentId string `json:"departmentid"` //部门ID
|
||||
|
DepartmentName string `json:"departmentname"` //部门名称
|
||||
|
DimensionId string `json:"dimensionid"` //维度Id
|
||||
|
DimensionName string `json:"dimensionname"` //维度名称
|
||||
|
DimensionWeight int64 `json:"dimensionweight"` //维度权重
|
||||
|
TargetId string `json:"targetid"` //指标ID
|
||||
|
TargetName string `json:"targetname"` //指标名称
|
||||
|
TargetCont string `json:"targetCont"` //指标说明
|
||||
|
Targetweight int64 `json:"targetweight"` //指标权重
|
||||
|
Type int `json:"type"` //1:定性;2:定量
|
||||
|
Unit string `json:"unit"` //单位
|
||||
|
Cycle int `json:"cycle"` //周期
|
||||
|
Cycleattr int `json:"cycleattr"` //辅助参数
|
||||
|
ExecutiveDepartment []string `json:"executivedepartment"` //执行部门
|
||||
|
Score float64 `json:"score"` //得分
|
||||
|
Versio string `json:"versio"` //版本号码
|
||||
|
} |
||||
|
|
||||
|
// 定量考核基础参数(新版)
|
||||
|
type dingLiangKaoHeNew struct { |
||||
|
Zeroprize float64 `json:"zeroprize"` //零奖值"`
|
||||
|
Allprize float64 `json:"allprize"` //全奖值"`
|
||||
|
Capping float64 `json:"capping"` //封顶值"`
|
||||
|
Actual float64 `json:"actual"` //实际值
|
||||
|
Score float64 `json:"score"` //手动得分
|
||||
|
CompletionRate float64 `json:"completionrate"` //达成率
|
||||
|
TargetScore float64 `json:"target_score"` //指标分
|
||||
|
MtOrAt int `json:"mtorat"` //手动还是自动
|
||||
|
Nature int `json:"nature"` //1、使用;2:禁用;3:观察
|
||||
|
} |
||||
@ -0,0 +1,41 @@ |
|||||
|
package statisticsrouter |
||||
|
|
||||
|
import ( |
||||
|
"key_performance_indicators/api/version1" |
||||
|
|
||||
|
"github.com/gin-gonic/gin" |
||||
|
) |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2023-07-27 10:17:05 |
||||
|
@ 功能: 统计路由 |
||||
|
@ 参数 |
||||
|
|
||||
|
# |
||||
|
|
||||
|
@ 返回值 |
||||
|
|
||||
|
# |
||||
|
|
||||
|
@ 方法原型 |
||||
|
|
||||
|
# |
||||
|
*/ |
||||
|
func (a *ApiRouter) RouterGroup(router *gin.RouterGroup) { |
||||
|
apiRouter := router.Group("strtistics") |
||||
|
var statisRouter = version1.AppApiEntry.StatisticsApi |
||||
|
{ |
||||
|
apiRouter.GET("", statisRouter.Index) //入口
|
||||
|
apiRouter.POST("", statisRouter.Index) //入口
|
||||
|
|
||||
|
apiRouter.POST("orgtranscript", statisRouter.OrgTranscript) //行政组织成绩单
|
||||
|
apiRouter.POST("summarydetailslianglog", statisRouter.SummaryDetailsLiangLog) //汇总详情定量历史记录
|
||||
|
apiRouter.POST("summarydetails", statisRouter.SummaryDetails) //方案得分明细
|
||||
|
|
||||
|
apiRouter.POST("summaryplanrecord", statisRouter.SummaryPlanRecord) //汇总方案定量指标详情历史记录(新版)
|
||||
|
apiRouter.POST("newsummarydetails", statisRouter.NewSummaryDetails) //方案得分明细(新版)
|
||||
|
apiRouter.POST("neworgtranscript", statisRouter.OrgTranscriptNew) //行政组织成绩单(新版)
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,14 @@ |
|||||
|
package statisticsrouter |
||||
|
|
||||
|
/** |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2023-07-27 10:16:28 |
||||
|
@ 功能: 数据统计路由 |
||||
|
@ 参数 |
||||
|
# |
||||
|
@ 返回值 |
||||
|
# |
||||
|
@ 方法原型 |
||||
|
# |
||||
|
*/ |
||||
|
type ApiRouter struct{} |
||||
Loading…
Reference in new issue