15 changed files with 1531 additions and 150 deletions
@ -0,0 +1,589 @@ |
|||
package statistics |
|||
|
|||
import ( |
|||
"encoding/json" |
|||
"fmt" |
|||
"strconv" |
|||
"time" |
|||
|
|||
"github.com/flipped-aurora/gin-vue-admin/server/api/statistics/quantification" |
|||
"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" |
|||
) |
|||
|
|||
// 计算成绩表
|
|||
func (a *ApiGroup) Queryresults(c *gin.Context) { |
|||
isTrue, userCont := commonus.ClientIdentity() |
|||
if isTrue != true { |
|||
response.Result(101, isTrue, "您的身份令牌已经失效!请重新登录获取身份令牌!", c) |
|||
return |
|||
} |
|||
var requestData TranscriptTable |
|||
c.ShouldBindJSON(&requestData) |
|||
//获取当前访问人的公司组织架构
|
|||
var orgList []hrsystem.AdministrativeOrganization |
|||
gromDb := global.GVA_DB_HrDataBase.Model(&hrsystem.AdministrativeOrganization{}).Where("ispower = 1 AND state = 1 AND organization_type > 2") |
|||
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 |
|||
} |
|||
if len(orgList) <= 0 { |
|||
response.Result(103, err, "没有查询到数据", c) |
|||
return |
|||
} |
|||
var orgAry []hrsystem.AdministrativeOrganization |
|||
for _, ov := range orgList { |
|||
sunOrgList, orgSunErr := getSunOrgList(ov.Id) |
|||
if orgSunErr == nil && len(sunOrgList) > 0 { |
|||
for _, sv := range sunOrgList { |
|||
orgAry = append(orgAry, sv) |
|||
} |
|||
} else { |
|||
orgAry = append(orgAry, ov) |
|||
} |
|||
} |
|||
//计算要查询的年份
|
|||
currentYear := commonus.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 := commonus.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 deaprtmenTranscript TranscriptTableData |
|||
for _, v := range orgAry { |
|||
syncProcess.Add(1) |
|||
go deaprtmenTranscript.StaticticsDepartmentResult(userCont.Company, v, currentYear, monthTody) |
|||
} |
|||
syncProcess.Wait() //等待所有协程完毕
|
|||
readStatisticsData := deaprtmenTranscript.readTranscriptData() //读取通道数据
|
|||
fmt.Printf("readStatisticsData----------->%v\n", readStatisticsData) |
|||
|
|||
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 getSunOrgList(orgId int64) (orgList []hrsystem.AdministrativeOrganization, ovErr error) { |
|||
ovErr = global.GVA_DB_HrDataBase.Where("state = 1").Where("ispower = 1 AND superior = ?", orgId).Find(&orgList).Error |
|||
return |
|||
} |
|||
|
|||
/* |
|||
统计部门月度成绩 |
|||
@group 集团 |
|||
@orgCont 行政组织相关信息 |
|||
@year 查询的年份 |
|||
@month 查询月份边界 |
|||
*/ |
|||
func (t *TranscriptTableData) StaticticsDepartmentResult(group string, orgCont hrsystem.AdministrativeOrganization, year int64, month []int64) { |
|||
/* |
|||
锁操作 |
|||
*/ |
|||
t.mutext.Lock() |
|||
defer t.mutext.Unlock() |
|||
|
|||
groupId, _ := strconv.ParseInt(group, 10, 64) |
|||
|
|||
//获取要计算部门当前执行的考核方案表
|
|||
var planVersionInfo assessmentmodel.PlanVersio |
|||
err := global.GVA_DB_Performanceappraisal.Where("state = 1 AND department = ?", orgCont.Id).First(&planVersionInfo).Error |
|||
if err == nil { |
|||
//将考核方案解析
|
|||
var planVersioInfo []AddDutyNewCont |
|||
jsonErr := json.Unmarshal([]byte(planVersionInfo.Content), &planVersioInfo) |
|||
if jsonErr == nil { |
|||
var pingJunFen TranscriptTableDateList |
|||
pingJunFen.DepartmentId = strconv.FormatInt(orgCont.Id, 10) |
|||
pingJunFen.Department = orgCont.Name |
|||
// var i int64
|
|||
var everyMonthScore countEveryDepartmentMonthScore |
|||
// for i = 1; i <= month; i++ {
|
|||
// syncProcessDepartTarget.Add(1)
|
|||
// //按月份计算
|
|||
// go everyMonthScore.everyMonthCalculate(groupId, orgCont.Id, year, i, planVersioInfo)
|
|||
// }
|
|||
|
|||
for _, v := range month { |
|||
syncProcessDepartTarget.Add(1) |
|||
//按月份计算
|
|||
go everyMonthScore.everyMonthCalculate(groupId, orgCont.Id, year, v, planVersioInfo) |
|||
} |
|||
|
|||
syncProcessDepartTarget.Wait() |
|||
everyMonthScoreList := everyMonthScore.readMyDayData() |
|||
for _, emslv := range everyMonthScoreList { |
|||
fmt.Printf("emslv---->%v\n", emslv) |
|||
switch emslv.MonthVal { |
|||
case 1: |
|||
pingJunFen.A = emslv.Score |
|||
case 2: |
|||
pingJunFen.B = emslv.Score |
|||
case 3: |
|||
pingJunFen.C = emslv.Score |
|||
case 4: |
|||
pingJunFen.D = emslv.Score |
|||
case 5: |
|||
pingJunFen.E = emslv.Score |
|||
case 6: |
|||
pingJunFen.F = emslv.Score |
|||
case 7: |
|||
pingJunFen.G = emslv.Score |
|||
case 8: |
|||
pingJunFen.H = emslv.Score |
|||
case 9: |
|||
pingJunFen.I = emslv.Score |
|||
case 10: |
|||
pingJunFen.J = emslv.Score |
|||
case 11: |
|||
pingJunFen.K = emslv.Score |
|||
case 12: |
|||
pingJunFen.L = emslv.Score |
|||
default: |
|||
} |
|||
} |
|||
var monthIsFalse int64 |
|||
for monthIsFalse = 1; monthIsFalse <= 12; monthIsFalse++ { |
|||
if commonus.IsInTrue[int64](monthIsFalse, month) == false { |
|||
switch monthIsFalse { |
|||
case 1: |
|||
pingJunFen.A = -10000 |
|||
case 2: |
|||
pingJunFen.B = -10000 |
|||
case 3: |
|||
pingJunFen.C = -10000 |
|||
case 4: |
|||
pingJunFen.D = -10000 |
|||
case 5: |
|||
pingJunFen.E = -10000 |
|||
case 6: |
|||
pingJunFen.F = -10000 |
|||
case 7: |
|||
pingJunFen.G = -10000 |
|||
case 8: |
|||
pingJunFen.H = -10000 |
|||
case 9: |
|||
pingJunFen.I = -10000 |
|||
case 10: |
|||
pingJunFen.J = -10000 |
|||
case 11: |
|||
pingJunFen.K = -10000 |
|||
case 12: |
|||
pingJunFen.L = -10000 |
|||
default: |
|||
} |
|||
} |
|||
} |
|||
|
|||
// if month < 12 {
|
|||
// beginLostMonth := month + 1
|
|||
// for ; beginLostMonth <= 12; beginLostMonth++ {
|
|||
// switch beginLostMonth {
|
|||
// case 1:
|
|||
// pingJunFen.A = -10000
|
|||
// case 2:
|
|||
// pingJunFen.B = -10000
|
|||
// case 3:
|
|||
// pingJunFen.C = -10000
|
|||
// case 4:
|
|||
// pingJunFen.D = -10000
|
|||
// case 5:
|
|||
// pingJunFen.E = -10000
|
|||
// case 6:
|
|||
// pingJunFen.F = -10000
|
|||
// case 7:
|
|||
// pingJunFen.G = -10000
|
|||
// case 8:
|
|||
// pingJunFen.H = -10000
|
|||
// case 9:
|
|||
// pingJunFen.I = -10000
|
|||
// case 10:
|
|||
// pingJunFen.J = -10000
|
|||
// case 11:
|
|||
// pingJunFen.K = -10000
|
|||
// case 12:
|
|||
// pingJunFen.L = -10000
|
|||
// default:
|
|||
// }
|
|||
// }
|
|||
// }
|
|||
fmt.Printf("month---->%v\n", pingJunFen) |
|||
t.ScoreStatistics = append(t.ScoreStatistics, pingJunFen) |
|||
} |
|||
} |
|||
syncProcess.Done() //结束本协程
|
|||
} |
|||
|
|||
/* |
|||
按月份统计部门总成绩 |
|||
@groupId 集团ID |
|||
@orgId 行政组织ID |
|||
@year 年 |
|||
@month 月 |
|||
@planVersion 部门当前执行的考核版本 |
|||
*/ |
|||
func (c *countEveryDepartmentMonthScore) everyMonthCalculate(groupId, orgId, year, month int64, planVersion []AddDutyNewCont) { |
|||
/* |
|||
锁操作 |
|||
*/ |
|||
c.mutext.Lock() |
|||
defer c.mutext.Unlock() |
|||
var weiDuScore float64 = 0 //维度分值
|
|||
var zhiBiaoScore float64 = 0 //指标标准分值
|
|||
var sumScore float64 = 0 //计算得分
|
|||
|
|||
for _, v := range planVersion { //维度
|
|||
weiDuScore = weiDuScore + float64(v.ZhiFraction) |
|||
for _, sv := range v.Child { //指标
|
|||
zhiBiaoScore = zhiBiaoScore + float64(sv.ReferenceScore) |
|||
if sv.Status == 3 { |
|||
sumScore = sumScore + float64(sv.ReferenceScore) |
|||
} else { |
|||
if sv.Status == 1 && sv.Status != 3 { //判断指标是否启用并且不是观察指标
|
|||
var targetInfo assessmentmodel.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 { //定性考核
|
|||
countScore, _ := quantification.DingXingMonthSum(groupId, orgId, sv.ReferenceScore, year, month, sv.Id, sv.Cycles, sv.Status) |
|||
sumScore = sumScore + countScore |
|||
|
|||
} else { //定量考核
|
|||
countScores, _ := quantification.DingLiangMonthSum(groupId, orgId, sv.ReferenceScore, year, month, sv.Id, sv.Cycles, sv.Status) |
|||
sumScore = sumScore + countScores |
|||
} |
|||
// switch sv.Cycles {
|
|||
// case 5: //季度统计
|
|||
// case 6: //年统计
|
|||
// case 7: //半年统计
|
|||
// default: //月度统计
|
|||
// if targetInfo.Type == 1 { //定性考核
|
|||
// countScore, _ := quantification.DingXingMonthSum(groupId, orgId, sv.ReferenceScore, year, month, sv.Id, sv.Cycles, sv.Status)
|
|||
// sumScore = sumScore + countScore
|
|||
|
|||
// } else { //定量考核
|
|||
// countScores, _ := quantification.DingLiangMonthSum(groupId, orgId, sv.ReferenceScore, year, month, sv.Id, sv.Cycles, sv.Status)
|
|||
// sumScore = sumScore + countScores
|
|||
// }
|
|||
// }
|
|||
} |
|||
} |
|||
} |
|||
} |
|||
var everyMonthScoreInfo everyDepartmentScore |
|||
everyMonthScoreInfo.MonthVal = month |
|||
everyMonthScoreInfo.Score = commonus.Decimal(sumScore) |
|||
c.outData = append(c.outData, everyMonthScoreInfo) |
|||
syncProcessDepartTarget.Done() //结束本协程
|
|||
} |
|||
Loading…
Reference in new issue