diff --git a/gin_server_admin/api/index/statistics/enter.go b/gin_server_admin/api/index/statistics/enter.go index 56d0cb8..f7ac79c 100644 --- a/gin_server_admin/api/index/statistics/enter.go +++ b/gin_server_admin/api/index/statistics/enter.go @@ -27,6 +27,20 @@ func (t *tablePlanVersionStic) readMyDayData() []TableScoreList { return t.TableScore } +//成绩表 +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 dataLockStatistics struct { outData []TargetContOutCont @@ -231,4 +245,60 @@ 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"` + 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 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 defenfenxi struct { + Title string `json:"title"` + TimeClass string `json:"timeclass"` + Month int64 `json:"month"` + Stroce float64 `json:"stroce"` + State int `json:"state"` +} + +//行政组织级统计 +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"` } diff --git a/gin_server_admin/api/index/statistics/newstatistics.go b/gin_server_admin/api/index/statistics/newstatistics.go index 232d181..7e51362 100644 --- a/gin_server_admin/api/index/statistics/newstatistics.go +++ b/gin_server_admin/api/index/statistics/newstatistics.go @@ -4,12 +4,15 @@ import ( "encoding/json" "fmt" "strconv" + "time" "github.com/flipped-aurora/gin-vue-admin/server/commonus" "github.com/flipped-aurora/gin-vue-admin/server/global" "github.com/flipped-aurora/gin-vue-admin/server/model/assessmentmodel" "github.com/flipped-aurora/gin-vue-admin/server/model/common/response" + "github.com/flipped-aurora/gin-vue-admin/server/model/hrsystem" "github.com/gin-gonic/gin" + "gorm.io/gorm" ) //计算定量考核 @@ -136,6 +139,15 @@ func GetAllZreoCapp(flKey, group, depart, dimen, targetId, year, timecopy, deaTa } //获取达成率配置 +/*GetPassRate(group, depart, dimen, target, year, timecopy, deaTarget int64) +@group 集团 +@depart 部门 +@dimen 维度 +@target 指标 +@year 年 +@timecopy 辅助技术 +@deaTarget 指标细则 +*/ func GetPassRate(group, depart, dimen, target, year, timecopy, deaTarget int64) (zeroPrize, allPrize, cappingPrize float64) { var qualConfig assessmentmodel.QuantitativeConfig gormDb := global.GVA_DB_Performanceappraisal.Where("`group` = ? AND `departmentid` = ? AND `dimension` = ? AND `target` = ? AND `year` = ?", group, depart, dimen, target, year) @@ -153,23 +165,695 @@ func GetPassRate(group, depart, dimen, target, year, timecopy, deaTarget int64) return } -//定性 -/*SubjectiveAuxiliaryCalculationSumMethod(wherStr string, i, status, class int, referenceScore int64) -统计分数 -@wherStr 统计条件 -@i 步进器 -@status 是否为观察数据 -@class 指标类型 1、定性;2:定量 -@referenceScore 指标权重 -*/ +//成绩表查询 +/* + */ func (a *ApiGroup) DepartmentTranscript(c *gin.Context) { isTrue, userCont := commonus.ClientIdentity() if isTrue != true { - response.Result(1001, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c) + response.Result(101, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c) return } var requestData TranscriptTable c.ShouldBindJSON(&requestData) - var orgList assessmentmodel + var orgList []hrsystem.AdministrativeOrganization + gromDb := global.GVA_DB_HrDataBase.Model(&hrsystem.AdministrativeOrganization{}).Where("state = 1") + if requestData.Group != "" { + gromDb = gromDb.Where("superior = ?", requestData.Group) + } else { + gromDb = gromDb.Where("superior = ?", userCont.Company) + } + if requestData.Department != "" { + gromDb = gromDb.Where("`id` = ?", requestData.Department) + } + err := gromDb.Find(&orgList).Error + + if err != nil { + response.Result(102, err, "没有查询到数据", c) + return + } + countDeparNum := len(orgList) + if countDeparNum <= 0 { + response.Result(103, err, "没有查询到数据", c) + return + } + + currentYear := commonus.ComputingTime(time.Now().Unix(), 1) + if requestData.Year != "" { + yearInt64, _ := strconv.ParseInt(requestData.Year, 10, 64) + currentYear = yearInt64 + } + var deaprtmenTranscript TranscriptTableData + for _, v := range orgList { + syncProcess.Add(1) + go deaprtmenTranscript.StatisticalResults(userCont.Company, v, currentYear) + // break + } + syncProcess.Wait() + readStatisticsData := deaprtmenTranscript.readTranscriptData() + var AScore float64 = 0 + var BScore float64 = 0 + var CScore float64 = 0 + var DScore float64 = 0 + var EScore float64 = 0 + var FScore float64 = 0 + var GScore float64 = 0 + var HScore float64 = 0 + var IScore float64 = 0 + var JScore float64 = 0 + var KScore float64 = 0 + var LScore float64 = 0 + jiBuQi := 0 + var echarsList TranscriptTableDateListChars + + var echarsListOrg TranscriptTableDateListChars + + if len(requestData.Month) > 0 { + var monthAry []int + for i := 1; i <= 12; i++ { + if commonus.IsInTrue[int](i, requestData.Month) == true && commonus.IsInTrue[string](fmt.Sprintf("%v月", i), echarsList.XLine) == false { + echarsList.XLine = append(echarsList.XLine, fmt.Sprintf("%v月", i)) + monthAry = append(monthAry, i) + echarsListOrg.Cylindrical = append(echarsListOrg.Cylindrical, fmt.Sprintf("%v月", i)) + } + } + } else { + echarsList.XLine = append(echarsList.XLine, "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月") + } + var orgFen orgShierTongji + // var dfgfd []YlineData + for _, readv := range readStatisticsData { + AScore = AScore + readv.A + BScore = BScore + readv.B + CScore = CScore + readv.C + DScore = DScore + readv.D + EScore = EScore + readv.E + FScore = FScore + readv.F + GScore = GScore + readv.G + HScore = HScore + readv.H + IScore = IScore + readv.I + JScore = JScore + readv.J + KScore = KScore + readv.K + LScore = LScore + readv.L + jiBuQi++ + echarsList.Cylindrical = append(echarsList.Cylindrical, readv.Department) + echarsListOrg.XLine = append(echarsListOrg.XLine, readv.Department) + + var cyLineAry_1 YlineData + cyLineAry_1.Name = readv.Department + + // var yZhoue YlineData + + if readv.A == -10000 { + readv.A = 0 + } + if readv.B == -10000 { + readv.B = 0 + } + if readv.C == -10000 { + readv.C = 0 + } + if readv.D == -10000 { + readv.D = 0 + } + if readv.E == -10000 { + readv.E = 0 + } + if readv.F == -10000 { + readv.F = 0 + } + if readv.G == -10000 { + readv.G = 0 + } + if readv.H == -10000 { + readv.H = 0 + } + if readv.I == -10000 { + readv.I = 0 + } + if readv.J == -10000 { + readv.J = 0 + } + if readv.K == -10000 { + readv.K = 0 + } + if readv.L == -10000 { + readv.L = 0 + } + if len(requestData.Month) > 0 { + if commonus.IsInTrue[int](1, requestData.Month) == true { + // echarsList.XLine = append(echarsList.XLine, fmt.Sprintf("%v月", 1)) + cyLineAry_1.Data = append(cyLineAry_1.Data, readv.A) + + } + if commonus.IsInTrue[int](2, requestData.Month) == true { + // echarsList.XLine = append(echarsList.XLine, fmt.Sprintf("%v月", 2)) + cyLineAry_1.Data = append(cyLineAry_1.Data, readv.B) + + } + if commonus.IsInTrue[int](3, requestData.Month) == true { + // echarsList.XLine = append(echarsList.XLine, fmt.Sprintf("%v月", 3)) + cyLineAry_1.Data = append(cyLineAry_1.Data, readv.C) + + } + if commonus.IsInTrue[int](4, requestData.Month) == true { + // echarsList.XLine = append(echarsList.XLine, fmt.Sprintf("%v月", 4)) + cyLineAry_1.Data = append(cyLineAry_1.Data, readv.D) + + } + if commonus.IsInTrue[int](5, requestData.Month) == true { + // echarsList.XLine = append(echarsList.XLine, fmt.Sprintf("%v月", 5)) + cyLineAry_1.Data = append(cyLineAry_1.Data, readv.E) + + } + if commonus.IsInTrue[int](6, requestData.Month) == true { + // echarsList.XLine = append(echarsList.XLine, fmt.Sprintf("%v月", 6)) + cyLineAry_1.Data = append(cyLineAry_1.Data, readv.F) + + } + if commonus.IsInTrue[int](7, requestData.Month) == true { + // echarsList.XLine = append(echarsList.XLine, fmt.Sprintf("%v月", 7)) + cyLineAry_1.Data = append(cyLineAry_1.Data, readv.G) + + } + if commonus.IsInTrue[int](8, requestData.Month) == true { + // echarsList.XLine = append(echarsList.XLine, fmt.Sprintf("%v月", 8)) + cyLineAry_1.Data = append(cyLineAry_1.Data, readv.H) + + } + if commonus.IsInTrue[int](9, requestData.Month) == true { + // echarsList.XLine = append(echarsList.XLine, fmt.Sprintf("%v月", 9)) + cyLineAry_1.Data = append(cyLineAry_1.Data, readv.I) + + } + if commonus.IsInTrue[int](10, requestData.Month) == true { + // echarsList.XLine = append(echarsList.XLine, fmt.Sprintf("%v月", 10)) + cyLineAry_1.Data = append(cyLineAry_1.Data, readv.J) + + } + if commonus.IsInTrue[int](11, requestData.Month) == true { + // echarsList.XLine = append(echarsList.XLine, fmt.Sprintf("%v月", 11)) + cyLineAry_1.Data = append(cyLineAry_1.Data, readv.K) + + } + if commonus.IsInTrue[int](12, requestData.Month) == true { + // echarsList.XLine = append(echarsList.XLine, fmt.Sprintf("%v月", 12)) + cyLineAry_1.Data = append(cyLineAry_1.Data, readv.L) + + } + + } else { + cyLineAry_1.Data = append(cyLineAry_1.Data, readv.A, readv.B, readv.C, readv.D, readv.E, readv.F, readv.G, readv.H, readv.I, readv.J, readv.K, readv.L) + // cyLineAry_2.Data = append(cyLineAry_1.Data, readv.A, readv.B, readv.C, readv.D, readv.E, readv.F, readv.G, readv.H, readv.I, readv.J, readv.K, readv.L) + } + orgFen.A = append(orgFen.A, readv.A) + orgFen.B = append(orgFen.B, readv.B) + orgFen.C = append(orgFen.C, readv.C) + orgFen.D = append(orgFen.D, readv.D) + orgFen.E = append(orgFen.E, readv.E) + orgFen.F = append(orgFen.F, readv.F) + orgFen.G = append(orgFen.G, readv.G) + orgFen.H = append(orgFen.H, readv.H) + orgFen.I = append(orgFen.I, readv.I) + orgFen.J = append(orgFen.J, readv.J) + orgFen.K = append(orgFen.K, readv.K) + orgFen.L = append(orgFen.L, readv.L) + + echarsList.YLine = append(echarsList.YLine, cyLineAry_1) + // echarsListOrg.YLine = append(echarsListOrg.YLine, cyLineAry_2) + + } + + if jiBuQi > 0 { + var pingJunFen TranscriptTableDateList + pingJunFen.DepartmentId = "0" + pingJunFen.Department = "平均分" + pingJunFen.A = commonus.Decimal(AScore / float64(jiBuQi)) + pingJunFen.B = commonus.Decimal(BScore / float64(jiBuQi)) + pingJunFen.C = commonus.Decimal(CScore / float64(jiBuQi)) + pingJunFen.D = commonus.Decimal(DScore / float64(jiBuQi)) + pingJunFen.E = commonus.Decimal(EScore / float64(jiBuQi)) + pingJunFen.F = commonus.Decimal(FScore / float64(jiBuQi)) + pingJunFen.G = commonus.Decimal(GScore / float64(jiBuQi)) + pingJunFen.H = commonus.Decimal(HScore / float64(jiBuQi)) + pingJunFen.I = commonus.Decimal(IScore / float64(jiBuQi)) + pingJunFen.J = commonus.Decimal(JScore / float64(jiBuQi)) + pingJunFen.K = commonus.Decimal(KScore / float64(jiBuQi)) + pingJunFen.L = commonus.Decimal(LScore / float64(jiBuQi)) + + readStatisticsData = append(readStatisticsData, pingJunFen) + } + var monthInt []int + if len(requestData.Month) <= 0 { + for dkj := 1; dkj <= 12; dkj++ { + monthInt = append(monthInt, dkj) + } + } else { + monthInt = requestData.Month + } + for _, mvv := range monthInt { + switch mvv { + case 1: + var cyLineAry_2 YlineData + cyLineAry_2.Name = "1月" + cyLineAry_2.Data = orgFen.A + echarsListOrg.YLine = append(echarsListOrg.YLine, cyLineAry_2) + case 2: + var cyLineAry_2 YlineData + cyLineAry_2.Name = "2月" + cyLineAry_2.Data = orgFen.B + echarsListOrg.YLine = append(echarsListOrg.YLine, cyLineAry_2) + case 3: + var cyLineAry_2 YlineData + cyLineAry_2.Name = "3月" + cyLineAry_2.Data = orgFen.C + echarsListOrg.YLine = append(echarsListOrg.YLine, cyLineAry_2) + case 4: + var cyLineAry_2 YlineData + cyLineAry_2.Name = "4月" + cyLineAry_2.Data = orgFen.D + echarsListOrg.YLine = append(echarsListOrg.YLine, cyLineAry_2) + case 5: + var cyLineAry_2 YlineData + cyLineAry_2.Name = "5月" + cyLineAry_2.Data = orgFen.E + echarsListOrg.YLine = append(echarsListOrg.YLine, cyLineAry_2) + case 6: + var cyLineAry_2 YlineData + cyLineAry_2.Name = "6月" + cyLineAry_2.Data = orgFen.F + echarsListOrg.YLine = append(echarsListOrg.YLine, cyLineAry_2) + case 7: + var cyLineAry_2 YlineData + cyLineAry_2.Name = "7月" + cyLineAry_2.Data = orgFen.G + echarsListOrg.YLine = append(echarsListOrg.YLine, cyLineAry_2) + case 8: + var cyLineAry_2 YlineData + cyLineAry_2.Name = "8月" + cyLineAry_2.Data = orgFen.H + echarsListOrg.YLine = append(echarsListOrg.YLine, cyLineAry_2) + case 9: + var cyLineAry_2 YlineData + cyLineAry_2.Name = "9月" + cyLineAry_2.Data = orgFen.I + echarsListOrg.YLine = append(echarsListOrg.YLine, cyLineAry_2) + case 10: + var cyLineAry_2 YlineData + cyLineAry_2.Name = "10月" + cyLineAry_2.Data = orgFen.G + echarsListOrg.YLine = append(echarsListOrg.YLine, cyLineAry_2) + case 11: + var cyLineAry_2 YlineData + cyLineAry_2.Name = "11月" + cyLineAry_2.Data = orgFen.K + echarsListOrg.YLine = append(echarsListOrg.YLine, cyLineAry_2) + case 12: + var cyLineAry_2 YlineData + cyLineAry_2.Name = "12月" + cyLineAry_2.Data = orgFen.L + echarsListOrg.YLine = append(echarsListOrg.YLine, cyLineAry_2) + } + } + + outData := commonus.MapOut() + outData["readStatisticsData"] = readStatisticsData + outData["echarsList"] = echarsList + outData["echarsListOrg"] = echarsListOrg + + response.Result(0, outData, "查询完成", c) +} + +func kjsd(name string, yZhoue []YlineData) bool { + for _, v := range yZhoue { + if v.Name == name { + return true + } + } + return false +} + +//统计月度成绩 +func (t *TranscriptTableData) StatisticalResults(group string, orgCont hrsystem.AdministrativeOrganization, year int64) { + t.mutext.Lock() + defer t.mutext.Unlock() + //获取本本部门发行版考核方案 + currentYear := commonus.ComputingTime(time.Now().Unix(), 1) + var monthTody int64 = 12 + + if currentYear == year { + monthTody = commonus.ComputingTime(time.Now().Unix(), 3) + } + + var planVersion assessmentmodel.PlanVersio + err := global.GVA_DB_Performanceappraisal.Where("state = 1 AND department = ?", orgCont.Id).First(&planVersion).Error + if err == nil { + var planVersioInfo []AddDutyNewCont + jsonErr := json.Unmarshal([]byte(planVersion.Content), &planVersioInfo) + if jsonErr == nil { + var pingJunFen TranscriptTableDateList + pingJunFen.DepartmentId = strconv.FormatInt(orgCont.Id, 10) + pingJunFen.Department = orgCont.Name + if currentYear >= year { + if monthTody >= 1 { + pingJunFen.A = StatisVersionTable(group, planVersioInfo, orgCont.Id, year, 1) + } else { + pingJunFen.A = -10000 + } + if monthTody >= 2 { + pingJunFen.B = StatisVersionTable(group, planVersioInfo, orgCont.Id, year, 2) + } else { + pingJunFen.B = -10000 + } + if monthTody >= 3 { + pingJunFen.C = StatisVersionTable(group, planVersioInfo, orgCont.Id, year, 3) + } else { + pingJunFen.C = -10000 + } + if monthTody >= 4 { + pingJunFen.D = StatisVersionTable(group, planVersioInfo, orgCont.Id, year, 4) + } else { + pingJunFen.D = -10000 + } + if monthTody >= 5 { + pingJunFen.E = StatisVersionTable(group, planVersioInfo, orgCont.Id, year, 5) + } else { + pingJunFen.E = -10000 + } + if monthTody >= 6 { + pingJunFen.F = StatisVersionTable(group, planVersioInfo, orgCont.Id, year, 6) + } else { + pingJunFen.F = -10000 + } + if monthTody >= 7 { + pingJunFen.G = StatisVersionTable(group, planVersioInfo, orgCont.Id, year, 7) + } else { + pingJunFen.G = -10000 + } + if monthTody >= 8 { + pingJunFen.H = StatisVersionTable(group, planVersioInfo, orgCont.Id, year, 8) + } else { + pingJunFen.H = -10000 + } + if monthTody >= 9 { + pingJunFen.I = StatisVersionTable(group, planVersioInfo, orgCont.Id, year, 9) + } else { + pingJunFen.I = -10000 + } + if monthTody >= 10 { + pingJunFen.J = StatisVersionTable(group, planVersioInfo, orgCont.Id, year, 10) + } else { + pingJunFen.J = -10000 + } + if monthTody >= 11 { + pingJunFen.K = StatisVersionTable(group, planVersioInfo, orgCont.Id, year, 11) + } else { + pingJunFen.K = -10000 + } + if monthTody >= 12 { + pingJunFen.L = StatisVersionTable(group, planVersioInfo, orgCont.Id, year, 12) + } else { + pingJunFen.L = -10000 + } + } + t.ScoreStatistics = append(t.ScoreStatistics, pingJunFen) + } + } + + syncProcess.Done() +} + +//根据版本统计得分 +/* +@planVersionCont 部门方案版本内容 +@orgId 部门ID +@year 年 +@month 月 +*/ +func StatisVersionTable(group string, planVersionCont []AddDutyNewCont, orgId, year int64, month int) float64 { + var sumScore float64 = 0 + var sumScoreKS float64 = 0 + var deScore float64 = 0 + var listgg []defenfenxi + for _, v := range planVersionCont { + sumScore = sumScore + float64(v.ZhiFraction) + for _, vc := range v.Child { + var listggCont defenfenxi + sumScoreKS = sumScoreKS + float64(vc.ReferenceScore) + if vc.Status == 3 { + deScore = deScore + float64(vc.ReferenceScore) + listggCont.Stroce = float64(vc.ReferenceScore) + + // fmt.Printf("Score---观察---ID--%v--->%v---->deScore---->%v\n", vc.Name, float64(vc.ReferenceScore), deScore) + } + if vc.Status == 1 && vc.Status != 3 { + var targetInfo assessmentmodel.EvaluationTarget + targetInfo.GetCont(map[string]interface{}{"et_id": vc.Id}, "et_type,et_cycle,et_title") + + listggCont.Title = targetInfo.Title + // if targetInfo.Type == 1 { + // //定性考核 + // gormDb := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.ScoreFlow{}).Where("`sf_target_id` = ? AND `sf_duty_department` = ? AND `sf_year` = ? AND `sf_month` = ?", vc.Id, orgId, year, month) + // deScore = deScore + calculationDingXingScore(gormDb, float64(vc.ReferenceScore)) + // } else { + // //定量考核 + // gormDb := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.FlowDataLogType{}).Where("`month` = ?", month) + // deScore = deScore + calculationDingLiangScore(group, strconv.FormatInt(orgId, 10), v.Id, vc.Id, gormDb, vc.ReferenceScore, year, int64(month)) + + // } + switch targetInfo.Cycles { + case 5: + //季度 + jidu := 1 + isWerint := false + // var monthAry []int + switch month { + case 3: + //monthAry = []int{1, 2, 3} + isWerint = true + jidu = 1 + case 6: + //monthAry = []int{4, 5, 6} + isWerint = true + jidu = 2 + case 9: + //monthAry = []int{7, 8, 9} + isWerint = true + jidu = 3 + case 12: + //monthAry = []int{10, 11, 12} + isWerint = true + jidu = 4 + default: + // deScore = deScore + float64(vc.ReferenceScore) + isWerint = false + jidu = 1 + } + + if isWerint == true { + if targetInfo.Type == 1 { + //定性考核 + gormDb := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.ScoreFlow{}).Where("`sf_target_id` = ? AND `sf_duty_department` = ? AND `sf_year` = ? AND `sf_quarter` = ?", vc.Id, orgId, year, jidu) + fffff := calculationDingXingScore(gormDb, float64(vc.ReferenceScore)) + deScore = deScore + fffff + listggCont.Stroce = fffff + listggCont.TimeClass = "1" + + // fmt.Printf("Score---季度---x----->%v\n", fffff) + } else { + //定量考核 + gormDb := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.FlowDataLogType{}).Where("`quarte` = ?", jidu) + fffG := calculationDingLiangScore(group, strconv.FormatInt(orgId, 10), v.Id, vc.Id, gormDb, vc.ReferenceScore, year, int64(jidu)) + deScore = deScore + fffG + listggCont.Stroce = fffG + listggCont.TimeClass = "2" + // fmt.Printf("Score---季度---l----->%v\n", fffG) + } + } else { + deScore = deScore + float64(vc.ReferenceScore) + // fmt.Printf("Score---季度---z----->%v\n", float64(vc.ReferenceScore)) + } + + case 6: + //年 + if month == 12 { + if targetInfo.Type == 1 { + //定性考核 + gormDb := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.ScoreFlow{}).Where("`sf_target_id` = ? AND `sf_duty_department` = ? AND `sf_year` = ?", vc.Id, orgId, year) + fffff := calculationDingXingScore(gormDb, float64(vc.ReferenceScore)) + deScore = deScore + fffff + listggCont.Stroce = fffff + listggCont.TimeClass = "1" + // fmt.Printf("Score---年---x----->%v\n", fffff) + } else { + //定量考核 + gormDb := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.FlowDataLogType{}) + fffG := calculationDingLiangScore(group, strconv.FormatInt(orgId, 10), v.Id, vc.Id, gormDb, vc.ReferenceScore, year, 1) + deScore = deScore + fffG + listggCont.Stroce = fffG + listggCont.TimeClass = "2" + // fmt.Printf("Score---年---l----->%v\n", fffG) + } + } else { + deScore = deScore + float64(vc.ReferenceScore) + // fmt.Printf("Score---年---z----->%v\n", float64(vc.ReferenceScore)) + } + + case 7: + //半年 + bannian := 1 + isWerint := false + var monthAry []int + switch month { + case 6: + for i := 1; i <= 6; i++ { + monthAry = append(monthAry, i) + } + isWerint = true + bannian = 1 + case 7: + for i := 7; i <= 12; i++ { + monthAry = append(monthAry, i) + } + isWerint = true + bannian = 2 + default: + // deScore = deScore + float64(vc.ReferenceScore) + isWerint = false + bannian = 1 + } + if isWerint == true { + if targetInfo.Type == 1 { + //定性考核 + gormDb := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.ScoreFlow{}).Where("`sf_target_id` = ? AND `sf_duty_department` = ? AND `sf_year` = ? AND `sf_month` IN ?", vc.Id, orgId, year, monthAry) + fffff := calculationDingXingScore(gormDb, float64(vc.ReferenceScore)) + + deScore = deScore + fffff + listggCont.Stroce = fffff + listggCont.TimeClass = "1" + // fmt.Printf("Score---半年---x----->%v\n", fffff) + } else { + //定量考核 + gormDb := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.FlowDataLogType{}).Where("`month` IN ?", monthAry) + fffG := calculationDingLiangScore(group, strconv.FormatInt(orgId, 10), v.Id, vc.Id, gormDb, vc.ReferenceScore, year, int64(bannian)) + deScore = deScore + fffG + listggCont.Stroce = fffG + listggCont.TimeClass = "2" + // fmt.Printf("Score---半年---l----->%v\n", fffG) + } + } else { + deScore = deScore + float64(vc.ReferenceScore) + // fmt.Printf("Score---半年---z----->%v\n", float64(vc.ReferenceScore)) + } + default: + //月 + if targetInfo.Type == 1 { + //定性考核 + gormDb := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.ScoreFlow{}).Where("`sf_target_id` = ? AND `sf_duty_department` = ? AND `sf_year` = ? AND `sf_month` = ?", vc.Id, orgId, year, month) + fffff := calculationDingXingScore(gormDb, float64(vc.ReferenceScore)) + deScore = deScore + fffff + listggCont.Stroce = fffff + listggCont.TimeClass = "1" + // fmt.Printf("Score---月---x----->%v\n", fffff) + } else { + //定量考核 + gormDb := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.FlowDataLogType{}).Where("`month` = ?", month) + fffG := calculationDingLiangScore(group, strconv.FormatInt(orgId, 10), v.Id, vc.Id, gormDb, vc.ReferenceScore, year, int64(month)) + deScore = deScore + fffG + listggCont.Stroce = fffG + listggCont.TimeClass = "2" + // fmt.Printf("Score---月---l----->%v\n", fffG) + } + } + } + // fmt.Printf("deScore--name:%v--->%v\n", vc.Name, deScore) + listgg = append(listgg, listggCont) + } + } + // jskd, _ := json.Marshal(listgg) + // fmt.Printf("listgg----->%v\n", string(jskd)) + + // fmt.Printf("sumScore----->%v-----sumScoreKS---->%v---->deScore---->%v\n", sumScore, sumScoreKS, deScore) + return commonus.Decimal(deScore) +} + +//计算定性得分 +/*MMI021201 +mm8888 +@gormDb 要查询得语句 +@referenceScore 指标权重 +*/ +func calculationDingXingScore(gormDb *gorm.DB, referenceScore float64) float64 { + // return 0 + var jiaFenAry []TongjiFenShu + gormDb.Select("sf_score,sf_count").Where("sf_plus_reduce_score = 1").Where("sf_reply IN (2,3)").Find(&jiaFenAry) + //加分 + var addSumScore float64 = 0 + for _, jiav := range jiaFenAry { + addSumScore = addSumScore + (jiav.Score * jiav.Count) + } + //减分 + var scoreReduction float64 = 0 + var jianFenAry []TongjiFenShu + gormDb.Select("sf_score,sf_count").Where("sf_plus_reduce_score = 2").Where("sf_reply IN (2,3)").Find(&jianFenAry) + for _, jianv := range jianFenAry { + scoreReduction = scoreReduction + (jianv.Score * jianv.Count) + } + sumScore := scoreReduction - addSumScore + return referenceScore - commonus.Decimal(sumScore/100) +} + +//计算定量得分 +/*func calculationDingLiangScore(group, department, dimensionId, targetId string, gormDb *gorm.DB, referenceScore, year int64, monthType int64) +@group 集团 +@department 部门 +@dimensionId 维度 +@targetId 指标 +@gormDb 要查询得语句 +@referenceScore 指标权重 +@year 年 +@monthType 辅助 +*/ +func calculationDingLiangScore(group, department, dimensionId, targetId string, gormDb *gorm.DB, referenceScore, year int64, monthType int64) float64 { + + var fldList []assessmentmodel.FlowDataLogType + gormDb = gormDb.Where("`targetid` = ? AND `group` = ? AND `department` = ? AND `year` = ?", targetId, group, department, year) + err := gormDb.Find(&fldList).Error + if err != nil { + return float64(referenceScore) + } + var actualScore float64 = 0 + targetIdInt, _ := strconv.ParseInt(targetId, 10, 64) + groupId, _ := strconv.ParseInt(group, 10, 64) + departmentId, _ := strconv.ParseInt(department, 10, 64) + dimensionIdInt, _ := strconv.ParseInt(dimensionId, 10, 64) + if len(fldList) > 0 { + for _, v := range fldList { + var zeroprize float64 = 0 + var allprize float64 = 0 + var capping float64 = 0 + var baseLineAry []FlowLogAllZreo + jsonErr := json.Unmarshal([]byte(v.Baseline), &baseLineAry) + if jsonErr == nil { + for _, tbsv := range baseLineAry { + if tbsv.TargetId == targetId { + zeroprize = tbsv.Zeroprize + allprize = tbsv.Allprize + capping = tbsv.Capping + } + } + } else { + zeroprize, allprize, capping = GetPassRate(groupId, departmentId, dimensionIdInt, targetIdInt, year, monthType, 0) + } + actualScoreVal, _, _, _, _ := commonus.CalculateScore(referenceScore, float64(v.Score), allprize, zeroprize, capping, 2) + actualScore = actualScore + actualScoreVal + + } + } + + // zeroPrize, allPrize, cappingPrize := GetAllZreoCapp(lastEvalId, groupId, departmentId, dimensionIdInt, targetIdInt, year, monthType, 0) + // actualScore, _, _, _, _ := commonus.CalculateScore(referenceScore, scoreSum, allPrize, zeroPrize, cappingPrize, 2) + return actualScore + // return 0 } diff --git a/gin_server_admin/api/statistics/quantification/jisuanshuzhi.go b/gin_server_admin/api/statistics/quantification/jisuanshuzhi.go index a770fd4..dfe5da6 100644 --- a/gin_server_admin/api/statistics/quantification/jisuanshuzhi.go +++ b/gin_server_admin/api/statistics/quantification/jisuanshuzhi.go @@ -29,12 +29,14 @@ func AuxiliaryCalculationSumNature(where interface{}) (sumScore float64) { for _, jianv := range jianFenAry { scoreReduction = scoreReduction + (jianv.Score * jianv.Count) } - if addSumScore > scoreReduction { - sumScore = addSumScore - scoreReduction - } else { - sumScore = scoreReduction - addSumScore - } + // if addSumScore > scoreReduction { + // sumScore = addSumScore - scoreReduction + // } else { + // sumScore = scoreReduction - addSumScore + // } + sumScore = addSumScore - scoreReduction return + // return sumScore * -1 } //获取定性总数 diff --git a/gin_server_admin/router/index/statisticsroute/programme.go b/gin_server_admin/router/index/statisticsroute/programme.go index fda126e..1abad17 100644 --- a/gin_server_admin/router/index/statisticsroute/programme.go +++ b/gin_server_admin/router/index/statisticsroute/programme.go @@ -18,5 +18,7 @@ func (s *StatisticsRoute) InitRouter(Router *gin.RouterGroup) { shiyanCodeRouter.POST("planversiostatistics", authorityApi.PlanVersioStatistics) //方案数据表格统计 shiyanCodeRouter.POST("departperappdatastatistics", authorityApi.DepartPerAppDataStatistics) //绩效考核数据统计 shiyanCodeRouter.POST("getplanversionvalid", authorityApi.GetPlanVersionValid) //绩效考核数据统计(改版) + + shiyanCodeRouter.POST("departmenttranscript", authorityApi.DepartmentTranscript) //成绩表查询 } }