Browse Source

自定义表单

v1_dev_2
超级管理员 2 years ago
parent
commit
4f73a36a6b
  1. 1
      api/version1/departmentseting/departmentpc/dingliang.go
  2. 16
      api/version1/departmentseting/departmentpc/programme.go
  3. 1
      api/version1/departmentseting/departmentpc/rulesmatrix.go
  4. 16
      api/version1/departmentseting/departmentweb/department.go
  5. 147
      api/version1/departmentseting/departmentweb/web.go
  6. 2
      api/version1/entry.go
  7. 2
      api/version1/jurisdiction/jurisdictionpc/people.go
  8. 564
      api/version1/statistics/newpc.go
  9. 140
      api/version1/statistics/orgstatistics.go
  10. 1591
      api/version1/statistics/pc.go
  11. 151
      api/version1/statistics/pcplant.go
  12. 229
      api/version1/statistics/type.go
  13. 2
      apirouter/entry.go
  14. 41
      apirouter/v1/statisticsrouter/pc.go
  15. 14
      apirouter/v1/statisticsrouter/type.go
  16. 22
      config/configDatabase/database.yaml
  17. 1
      go.mod
  18. 2
      go.sum
  19. 3
      initialization/route/initRoute.go
  20. 1
      models/modelskpi/flow_data_log.go
  21. 2
      overall/publicmethod/formatOutput.go
  22. 188
      overall/publicmethod/technique.go
  23. 15
      overall/publicmethod/type.go

1
api/version1/departmentseting/departmentpc/dingliang.go

@ -138,6 +138,7 @@ func (a *ApiMethod) GetQuantitativeTasks(c *gin.Context) {
sendCont.UserListAry = append(sendCont.UserListAry, userCont)
}
}
fmt.Printf("版本号吗!--->%v\n", v.QualEvalId)
sendCont.DimensionWeight, sendCont.TargetWeight = getPlanVersionWeghit(v.QualEvalId, strconv.FormatInt(v.Dimension, 10), strconv.FormatInt(v.Target, 10))
//获取目标设定
quanTitWhere := publicmethod.MapOut[string]()

16
api/version1/departmentseting/departmentpc/programme.go

@ -131,14 +131,14 @@ func (a *ApiMethod) EditDepartPrograState(c *gin.Context) {
return
}
//判断是否可执行操作
if editDepartStateIsTrue(planVersionCont, receivedValue.State) {
msg := "要操作的方案还有未走完的审批流程!请不要进行此操作!"
if receivedValue.State == 1 {
msg = "当前激活的方案中还有未走完的审批流程!请不要进行此操作!"
}
publicmethod.Result(1, receivedValue, c, msg)
return
}
// if editDepartStateIsTrue(planVersionCont, receivedValue.State) {
// msg := "要操作的方案还有未走完的审批流程!请不要进行此操作!"
// if receivedValue.State == 1 {
// msg = "当前激活的方案中还有未走完的审批流程!请不要进行此操作!"
// }
// publicmethod.Result(1, receivedValue, c, msg)
// return
// }
//根据操作不同执行相应函数
editState := publicmethod.MapOut[string]()
editState["`state`"] = 2

1
api/version1/departmentseting/departmentpc/rulesmatrix.go

@ -186,6 +186,7 @@ func (a *ApiMethod) GetTargetDetailsList(c *gin.Context) {
publicmethod.Result(107, err, c)
return
}
// return
var listCont []modelskpi.DetailedTarget
err = overall.CONSTANT_DB_KPI.Where("`dt_id` IN ?", idList).Order("dt_parentid desc, dt_parentid_sun").Find(&listCont).Error
if err != nil || len(listCont) < 1 {

16
api/version1/departmentseting/departmentweb/department.go

@ -238,15 +238,15 @@ func (a *ApiMethod) BasisDepartTargetTimeStatistics(c *gin.Context) {
yAxisOne.Name = "目标值 / 实际值 / 单位"
// yAxisOne.Name = fmt.Sprintf("目标值(%v)/实际值(%v)/单位(%v)", targetCont.Uniteing, targetCont.Uniteing, "%")
yAxisOne.Type = "value" //图像类型
yAxisOne.Min = yMinValLeft //最小值
yAxisOne.Max = yMaxValLeft //最大值
yAxisOne.Min = publicmethod.DecimalEs(yMinValLeft, 3) //最小值
yAxisOne.Max = publicmethod.DecimalEs(yMaxValLeft, 3) //最大值
yAxisOne.FormAtter = targetCont.Uniteing
sendCont.YAxis = append(sendCont.YAxis, yAxisOne)
var yAxisTwo YaxisStruct
yAxisTwo.Name = "达成率"
yAxisTwo.Type = "value" //图像类型
yAxisTwo.Min = yMinValRight //最小值
yAxisTwo.Max = yMaxValRight //最大值
yAxisTwo.Min = publicmethod.DecimalEs(yMinValRight, 3) //最小值
yAxisTwo.Max = publicmethod.DecimalEs(yMaxValRight, 3) //最大值
yAxisTwo.FormAtter = "%"
sendCont.YAxis = append(sendCont.YAxis, yAxisTwo)
fmt.Printf("%v---------->%v------------->%v------------->%v------------->%v------------->%v------------->%v\n", axisLeftMax, axisLeftMin, axisRightMax, axisRightMin, yAxisOne, yAxisTwo, yMaxValLeft)
@ -720,7 +720,8 @@ func (a *ApiMethod) TotalScoreOFOrgComesFromTimeSearch(c *gin.Context) {
// if v.Id == 354 {
sendData.XAxisVal = append(sendData.XAxisVal, v.Name)
SyncSeting.Add(1)
go syncOrgTimeScore.OrgCalculateScore(v, currentYears, currentMonths)
// go syncOrgTimeScore.OrgCalculateScore(v, currentYears, currentMonths)
go syncOrgTimeScore.TallyUpOrgCalculateScore(v, currentYears, currentMonths)
// }
}
@ -1156,6 +1157,8 @@ func GetOrgHingeTarget(targetId int64, attribute int, ysers, months string, orgI
orgScore := GetAryValue(ov.Id, orgScore)
dataList = append(dataList, orgScore)
}
maxVal = publicmethod.DecimalEs(maxVal, 2)
minVal = publicmethod.DecimalEs(minVal, 2)
fmt.Printf("orgScore------->%v------->%v------->%v\n", orgScore, maxVal, minVal)
return
}
@ -1595,7 +1598,8 @@ func (g *GeteveryYearDttsb) GetOrgMoreTimeScore(orgCont modelshr.AdministrativeO
for i := 1; i <= months; i++ {
monthStr := strconv.Itoa(i)
SyncSeting.Add(1)
go syncOrgTimeScore.OrgCalculateScore(orgCont, yearsStr, monthStr)
// go syncOrgTimeScore.OrgCalculateScore(orgCont, yearsStr, monthStr)
go syncOrgTimeScore.TallyUpOrgCalculateScore(orgCont, yearsStr, monthStr)
}
SyncSeting.Wait()
scoreList, maxScore, minSchor := syncOrgTimeScore.readPlanTaskData()

147
api/version1/departmentseting/departmentweb/web.go

@ -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 (){}

2
api/version1/entry.go

@ -10,6 +10,7 @@ import (
"key_performance_indicators/api/version1/jurisdiction/jurisdictionpc"
"key_performance_indicators/api/version1/postseting/postpc"
"key_performance_indicators/api/version1/postseting/postweb"
"key_performance_indicators/api/version1/statistics"
"key_performance_indicators/api/version1/systemapproval"
)
@ -24,6 +25,7 @@ type ApiEntry struct {
EmpowerApi empower.ApiMethod //系统授权
WorkFlowChat flowchart.ApiMethod //工作流
SystemAppExamine systemapproval.ApiMethod //系统审批处理
StatisticsApi statistics.ApiMethod //指标统计
}
var AppApiEntry = new(ApiEntry)

2
api/version1/jurisdiction/jurisdictionpc/people.go

@ -46,7 +46,7 @@ func (a *ApiMethod) SearchPeople(c *gin.Context) {
var listCont []modelshr.PersonArchives
gormDb := overall.CONSTANT_DB_HR.Model(&modelshr.PersonArchives{}).Where("`emp_type` BETWEEN ? AND ?", 1, 10)
if receivedValue.Name != "" {
gormDb = gormDb.Where("`name` LIKE ?", "%"+receivedValue.Name+"%")
gormDb = gormDb.Where("`name` LIKE ? OR `number` LIKE ?", "%"+receivedValue.Name+"%", "%"+receivedValue.Name+"%")
}
var total int64
gormDbTotal := gormDb

564
api/version1/statistics/newpc.go

@ -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)
}

140
api/version1/statistics/orgstatistics.go

@ -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() //结束本协程
}

1591
api/version1/statistics/pc.go

File diff suppressed because it is too large

151
api/version1/statistics/pcplant.go

@ -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)
}

229
api/version1/statistics/type.go

@ -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:观察
}

2
apirouter/entry.go

@ -9,6 +9,7 @@ import (
"key_performance_indicators/apirouter/v1/empowerrouter"
honorsRoute "key_performance_indicators/apirouter/v1/honorsRoute"
"key_performance_indicators/apirouter/v1/postseting"
"key_performance_indicators/apirouter/v1/statisticsrouter"
"key_performance_indicators/apirouter/v1/systempower"
"key_performance_indicators/apirouter/verifyLogin"
"key_performance_indicators/apirouter/wechaturl"
@ -31,6 +32,7 @@ type RouterGroup struct {
WorkFlowRouter workflowchart.ApiRouter
ExamineSystemApp approvalsystem.ApiRouter
MyWorkFlowRouter workflowrouter.ApiRouter
StatisticsApiRouter statisticsrouter.ApiRouter
}
var RouterGroupEntry = new(RouterGroup)

41
apirouter/v1/statisticsrouter/pc.go

@ -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) //行政组织成绩单(新版)
}
}

14
apirouter/v1/statisticsrouter/type.go

@ -0,0 +1,14 @@
package statisticsrouter
/**
@ 作者: 秦东
@ 时间: 2023-07-27 10:16:28
@ 功能: 数据统计路由
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
type ApiRouter struct{}

22
config/configDatabase/database.yaml

@ -28,17 +28,17 @@ wechat:
gorm_log: false #是否开启gorm日志
#HR数据库
hrdatabase:
url_path: '127.0.0.1' #数据库地址
port: 3306 #数据库端口
# url_path: '127.0.0.1' #数据库地址
# port: 3306 #数据库端口
# name: 'hr_new' #数据库名称
# username: 'root' #数据库用户民
# password: 'root' #数据库密码
url_path: '172.20.5.33' #数据库地址
port: 4000 #数据库端口
name: 'hr_new' #数据库名称
username: 'root' #数据库用户民
password: 'root' #数据库密码
# url_path: '120.224.6.6' #数据库地址
# port: 6666 #数据库端口
# name: 'hr_new' #数据库名称
# username: 'hr_new' #数据库用户民
# password: 'AnknKiXiXaxNrw78' #数据库密码
password: '9z_Bu28r1*DZ3K6@+a' #数据库密码
charset: 'utf8mb4' #数据库编码方式
parseTime: 'True' #是否自动转换时间
@ -160,12 +160,16 @@ healthReportDate:
kpiDate:
url_path: '127.0.0.1' #数据库地址
port: 3306 #数据库端口
# url_path: '172.20.5.33' #数据库地址
# port: 4000 #数据库端口
charset: 'utf8mb4' #数据库编码方式
parseTime: 'True' #是否自动转换时间
loc: 'Local' #时区
name: 'perform' #数据库名称
# name: 'performing' #数据库名称
username: 'root' #数据库用户民
password: 'root' #数据库密码
# password: '9z_Bu28r1*DZ3K6@+a' #数据库密码
max_idle_conns: 100 #最大空闲数量
max_open_conns: 1500 #最大打开数量
gorm_log: true #是否开启gorm日志

1
go.mod

@ -36,6 +36,7 @@ require (
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.1 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/spf13/afero v1.8.2 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect

2
go.sum

@ -490,6 +490,8 @@ github.com/shirou/gopsutil v3.20.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMT
github.com/shirou/gopsutil/v3 v3.22.5/go.mod h1:so9G9VzeHt/hsd0YwqprnjHnfARAUktauykSbr+y2gA=
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4=
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8=
github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=

3
initialization/route/initRoute.go

@ -74,6 +74,9 @@ func InitialRouter() *gin.Engine {
// 图文信息
bookimgRouterApi := apirouter.RouterGroupEntry.BookImg
bookimgRouterApi.RouterGroup(VerifyIdentity)
//统计
statisticsApiRouter := apirouter.RouterGroupEntry.StatisticsApiRouter
statisticsApiRouter.RouterGroup(VerifyIdentity)
}
//验证身份接口 无需鉴权Url(主要web端使用)

1
models/modelskpi/flow_data_log.go

@ -19,6 +19,7 @@ type FlowDataLogType struct {
TargetId int64 `json:"targetid" gorm:"column:targetid;type:bigint(20) unsigned;default:0;not null;comment:指标ID"`
Edition string `json:"edition" gorm:"column:edition;type:longtext;comment:版本号 "`
Content string `json:"content" gorm:"column:content;type:longtext;comment:评测内容 "`
Reply int `json:"reply" gorm:"column:fl_reply;type:int(2) unsigned;default:1;not null;comment:状态(0:删除;1:起草;2:审批;3:通过)"`
}
func (FlowDataLogType *FlowDataLogType) TableName() string {

2
overall/publicmethod/formatOutput.go

@ -179,7 +179,7 @@ func DetermineUserIdentity(userKey int64) (identity outShenFen) {
//角色权限范围判定
roleList := strings.Split(userCont.Role, ",")
var roleVerify modelssystempermission.RoleEmpower
overall.CONSTANT_DB_System_Permission.Where("`state` = 1 AND `system` = ? AND `id` IN ? ", "kpi", roleList).Find(&roleVerify)
overall.CONSTANT_DB_System_Permission.Where("`state` = 1 AND `system` = ? AND `role_id` IN ? ", "kpi", roleList).Find(&roleVerify)
//岗位权限范围判定
var postVerify modelssystempermission.Empower
postVerify.GetCont(map[string]interface{}{"`post_id`": userCont.Position, "`state`": 1, "`system`": "kpi"})

188
overall/publicmethod/technique.go

@ -12,6 +12,7 @@ import (
"key_performance_indicators/middleware/grocerystore"
"key_performance_indicators/middleware/snowflake"
"key_performance_indicators/models/modelshr"
"key_performance_indicators/models/modelskpi"
"key_performance_indicators/models/modelsschool"
"key_performance_indicators/models/modelsstorage"
"key_performance_indicators/models/modelssystempermission"
@ -25,6 +26,7 @@ import (
"time"
"github.com/mozillazg/go-pinyin"
"github.com/shopspring/decimal"
"gorm.io/gorm"
)
@ -81,6 +83,10 @@ func MapOut[T GenericityVariable]() (data map[T]interface{}) {
data = make(map[T]interface{}) //必可不少,分配内存
return data
}
func MapOutAny[T GenericityVariable, S GenericityVariable]() (data map[T]S) {
data = make(map[T]S) //必可不少,分配内存
return data
}
//时间搓转换成日期
/*
@ -599,20 +605,26 @@ func PageTurningSettings(gormDb *gorm.DB, page, pageSize int) *gorm.DB {
@weishu 要保留的小数位数
*/
func DecimalEs(value float64, weishu int) float64 {
switch weishu {
case 3:
value, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", value), 64)
case 4:
value, _ = strconv.ParseFloat(fmt.Sprintf("%.4f", value), 64)
case 5:
value, _ = strconv.ParseFloat(fmt.Sprintf("%.5f", value), 64)
case 6:
value, _ = strconv.ParseFloat(fmt.Sprintf("%.6f", value), 64)
default:
value, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", value), 64)
// switch weishu {
// case 3:
// value, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", value), 64)
// case 4:
// value, _ = strconv.ParseFloat(fmt.Sprintf("%.4f", value), 64)
// case 5:
// value, _ = strconv.ParseFloat(fmt.Sprintf("%.5f", value), 64)
// case 6:
// value, _ = strconv.ParseFloat(fmt.Sprintf("%.6f", value), 64)
// default:
// value, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", value), 64)
// }
value, _ = DecimalNew(value, int32(weishu))
return value
}
return value
func DecimalNew(value float64, weishu int32) (val float64, isTrue bool) {
// decimal.NewFromFloatWithExponent(value,weishu).Float64()
val, isTrue = decimal.NewFromFloat(value).Round(weishu).Float64()
return
}
// 递归查找
@ -648,6 +660,7 @@ func GetOrgStructurees(orgId int64) (groupId, companyId, departmentId, sunDepart
if err != nil {
return
}
switch orgContTypeInfo.Level {
case 1:
groupId = orgContTypeInfo.Id
@ -1963,6 +1976,8 @@ func JudjeMaxOfMinVal(maxVal, minVal float64) (maxVals, minVals float64) {
}
}
maxVals = DecimalEs(maxVals, 2)
minVals = DecimalEs(minVals, 2)
// fmt.Printf("ge---1-->%v----->%v\n", maxVals, minVals)
return
}
@ -2223,3 +2238,152 @@ func KpiMenuOperaTree(parentId string, treeCont []MenuContList) (treeList []Powe
}
return
}
/*
*
@ 作者: 秦东
@ 时间: 2023-07-27 11:35:16
@ 功能: 获取考核方案版本
@ 参数
#orgId 行政组织
#years
#months
@ 返回值
#
@ 方法原型
#
*/
func GetPlanVresion(orgId, years, months int64) (planVersionInfo modelskpi.PlanVersio, err error) {
if years == 0 || months == 0 {
planVersionInfo, err = PublicPlanVersion(orgId, years, months)
} else {
var flowPlanKey []string
overall.CONSTANT_DB_KPI.Model(&modelskpi.DutyFlowData{}).Select("fld_planversion").Where("fl_duty_department = ? AND fld_year = ? AND fld_month = ? AND fl_reply IN ?", orgId, years, months, []int{2, 3}).Find(&flowPlanKey)
var scoreFlowPlanKey []string
overall.CONSTANT_DB_KPI.Model(&modelskpi.ScoreFlow{}).Select("sf_planversion").Where("sf_duty_department = ? AND sf_year = ? AND sf_month = ? AND sf_reply IN ?", orgId, years, months, []int{2, 3}).Find(&scoreFlowPlanKey)
planKeyList := MapOutAny[string, int64]()
for _, v := range flowPlanKey {
if _, isOk := planKeyList[v]; isOk {
planKeyList[v] = planKeyList[v] + 1
} else {
planKeyList[v] = 1
}
}
for _, v := range scoreFlowPlanKey {
if _, isOk := planKeyList[v]; isOk {
planKeyList[v] = planKeyList[v] + 1
} else {
planKeyList[v] = 1
}
}
var maxKey MaxValStruct[string, int64]
if len(planKeyList) > 0 {
fmt.Printf("planKeyList:%v\n", planKeyList)
for mk, mv := range planKeyList {
if mv > maxKey.Val {
maxKey.Key = mk
maxKey.Val = mv
}
}
}
if maxKey.Key != "" {
err = overall.CONSTANT_DB_KPI.Where("`key` = ?", maxKey.Key).Find(&planVersionInfo).Error
if err != nil {
planVersionInfo, err = PublicPlanVersion(orgId, years, months)
}
} else {
planVersionInfo, err = PublicPlanVersion(orgId, years, months)
}
// fmt.Printf("years:%v\nmonths:%v\nplanKeyList:%v\nmaxKeyt:%v\nplanVersionInfo:%v\n", planKeyList, years, months, maxKey, planVersionInfo)
}
return
}
// 通用
func PublicPlanVersion(orgId, years, months int64) (planVersionInfo modelskpi.PlanVersio, err error) {
err = overall.CONSTANT_DB_KPI.Where("state = 1 AND department = ?", orgId).Order("addtime desc").First(&planVersionInfo).Error
if err != nil {
err = overall.CONSTANT_DB_KPI.Where("state = 2 AND department = ? AND yeares = ?", orgId, years).Order("addtime desc").First(&planVersionInfo).Error
if err != nil {
err = overall.CONSTANT_DB_KPI.Where("state = 3 AND department = ? AND yeares = ?", orgId, years).Order("addtime desc").First(&planVersionInfo).Error
if err != nil {
err = overall.CONSTANT_DB_KPI.Where("state = 2 AND department = ?", orgId).Order("addtime desc").First(&planVersionInfo).Error
if err != nil {
err = overall.CONSTANT_DB_KPI.Where("state = 3 AND department = ?", orgId).Order("addtime desc").First(&planVersionInfo).Error
}
}
}
}
return
}
/*
*
@ 作者: 秦东
@ 时间: 2023-08-04 15:08:41
@ 功能: 获取指标全奖值零奖值封顶值
@ 参数
#targetId 指标
#rewardCont 上报时的全奖值零奖值封顶值设置
#orgId 行政组织
#years 发生年
#quarter 发生季
#month 发生月
#cycles 12345季度67半年
@ 返回值
#zeroPrize 零奖值
#allPrize 全奖值
#cappingPrize 封顶值
@ 方法原型
#func GetTargetConfig(targetId, rewardCont string, orgId, years, quarter, month int64, cycles int) (zeroPrize, allPrize, cappingPrize float64)
*/
func GetTargetConfig(targetId, rewardCont string, orgId, years, quarter, month int64, cycles int) (zeroPrize, allPrize, cappingPrize float64) {
setIsTrue := true
var rewardAry []FlowLogAllZreo
jsonErr := json.Unmarshal([]byte(rewardCont), &rewardAry)
if jsonErr == nil {
//获取当前指标的全奖零奖值
for _, v := range rewardAry {
if v.TargetId == targetId {
zeroPrize = v.Zeroprize //零奖值"`
allPrize = v.Allprize //全奖值"`
cappingPrize = v.Capping //封顶值"`
setIsTrue = false
}
}
}
if setIsTrue {
var setCont modelskpi.QuantitativeConfig
gormdb := overall.CONSTANT_DB_KPI.Where("`departmentid` = ? AND `target` = ? AND `year` = ?", orgId, targetId, years)
switch cycles {
case 5: //季度
gormdb = gormdb.Where("`timecopy` = ?", quarter)
case 6: //年
case 7: //半年
banNian := 1
if !IsInTrue[int64](month, []int64{1, 2, 3, 4, 5, 6}) {
banNian = 2
}
gormdb = gormdb.Where("`timecopy` = ?", banNian)
default:
gormdb = gormdb.Where("`timecopy` = ?", month)
}
err := gormdb.Find(setCont).Error
if err == nil {
zeroPrize = setCont.Zeroprize //零奖值"`
allPrize = setCont.Allprize //全奖值"`
cappingPrize = setCont.CappingVal //封顶值"`
}
}
return
}

15
overall/publicmethod/type.go

@ -300,3 +300,18 @@ type WechatCallBack struct {
type GetOrgAllSun struct {
Id []int64
}
// 最大值
type MaxValStruct[T GenericityVariable, S GenericityVariable] struct {
Key T
Val S
}
// 定量流水全奖值、零奖值、封顶值
type FlowLogAllZreo struct {
Id string `json:"id"`
TargetId string `json:"targetid"` //指标ID`
Zeroprize float64 `json:"zeroprize"` //零奖值"`
Allprize float64 `json:"allprize"` //全奖值"`
Capping float64 `json:"capping"` //封顶值"`
}

Loading…
Cancel
Save