You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
152 lines
5.7 KiB
152 lines
5.7 KiB
|
2 years ago
|
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)
|
||
|
|
}
|