Browse Source

岗位方案提交人界定

pull/4/head
超级管理员 3 years ago
parent
commit
89c9c2a026
  1. 15
      api/version1/departmentseting/departmentpc/qualitativekpi.go
  2. 8
      api/version1/departmentseting/departmentpc/type.go
  3. 412
      api/version1/postseting/postpc/scheme.go
  4. 27
      api/version1/postseting/postpc/type.go
  5. 67
      models/modelskpi/position_plan_version.go
  6. 2
      models/modelskpi/post_target.go
  7. 77
      models/modelskpi/post_target_details.go
  8. 76
      models/modelskpi/qualitative_evaluation_scheme.go
  9. 97
      overall/publicmethod/technique.go

15
api/version1/departmentseting/departmentpc/qualitativekpi.go

@ -339,7 +339,7 @@ func (a *ApiMethod) GetTargetReport(c *gin.Context) {
}
//上报人信息
var reportManList []modelshr.PersonArchives
rmlErr := overall.CONSTANT_DB_HR.Model(&modelshr.PersonArchives{}).Select("`id`,`number`,`name`,`icon`,`company`,`maindeparment`").Where("`key` IN ?", userKey).Find(&reportManList).Error
rmlErr := overall.CONSTANT_DB_HR.Model(&modelshr.PersonArchives{}).Select("`id`,`key`,`number`,`name`,`icon`,`company`,`maindeparment`").Where("`key` IN ?", userKey).Find(&reportManList).Error
if rmlErr != nil && len(reportManList) < 1 {
publicmethod.Result(107, err, c)
return
@ -348,6 +348,7 @@ func (a *ApiMethod) GetTargetReport(c *gin.Context) {
for _, v := range reportManList {
var reportCont printReportCont
reportCont.Id = strconv.FormatInt(v.Id, 10)
reportCont.Key = strconv.FormatInt(v.Key, 10)
reportCont.Name = v.Name
var groupConb modelshr.AdministrativeOrganization
groupConb.GetCont(map[string]interface{}{"`id`": v.Company}, "`name`")
@ -796,6 +797,10 @@ func (a *ApiMethod) GetDepartmentTragetContList(c *gin.Context) {
standardStr = fmt.Sprintf("%v", publicmethod.DecimalEs(float64(v.MaxScore)/100, 2))
}
outCont.Standard = standardStr
//子栏目信息
var sonTargetInfo modelskpi.QualitativeTarget
sonTargetInfo.GetCont(map[string]interface{}{"`q_id`": v.ParentIdSun}, "q_title")
outCont.SonTargetName = sonTargetInfo.Title
outCont.CensorTypeList = strings.Split(v.CensorType, ",")
outData = append(outData, outCont)
@ -1991,7 +1996,7 @@ func (a *ApiMethod) DeparmentTargetAboutPost(c *gin.Context) {
@class 级别1部门级2岗位级
@nature 1定性考核2定量考核
*/
func departmentAboutPostTarget(dimensionId, targetId, targetSunId, bylawsId int64, departmentId string, postList []loopStruct, class, nature int) {
func departmentAboutPostTarget(dimensionId, targetId, targetSunId, bylawsId int64, departmentId string, postList []LoopStruct, class, nature int) {
defer syncSeting.Done()
fmt.Printf("targetCont-----1---->%v\n", nature)
@ -2082,7 +2087,7 @@ func departmentAboutPostTarget(dimensionId, targetId, targetSunId, bylawsId int6
overall.CONSTANT_DB_KPI.Create(&tarDepartCont)
}
syncSeting.Add(1)
go departAboutPostTargetReport(dimensionId, targetId, targetSunId, bylawsId, departId, postId, v.Child, class, nature)
go DepartAboutPostTargetReport(dimensionId, targetId, targetSunId, bylawsId, departId, postId, v.Child, class, nature)
}
}
@ -2103,10 +2108,12 @@ func departmentAboutPostTarget(dimensionId, targetId, targetSunId, bylawsId int6
@bylawsId 指标细则
@departmentId 接受考核部门
@postId 岗位
@repart 提报人
@class 级别1部门级2岗位级
@nature 1定性考核2定量考核
func departAboutPostTargetReport(dimensionId, targetId, targetSunId, bylawsId, departmentId, postId int64, repart []loopStruct, class, nature int)
*/
func departAboutPostTargetReport(dimensionId, targetId, targetSunId, bylawsId, departmentId, postId int64, repart []loopStruct, class, nature int) {
func DepartAboutPostTargetReport(dimensionId, targetId, targetSunId, bylawsId, departmentId, postId int64, repart []LoopStruct, class, nature int) {
defer syncSeting.Done()
//将不属于该指标细则的部门至禁用
otherSaveData := publicmethod.MapOut[string]()

8
api/version1/departmentseting/departmentpc/type.go

@ -65,6 +65,7 @@ type getAboutReportTarget struct {
// 输出上报人信息
type printReportCont struct {
Id string `json:"id"`
Key string `json:"key"`
Name string `json:"name"`
GroupName string `json:"groupname"`
DepartmentName string `json:"departmentname"`
@ -112,6 +113,7 @@ type printDepartTargetCont struct {
modelskpi.DetailedTarget
Standard string `json:"standard"` //标准
CensorTypeList []string `json:"censortypelist"` //检查方式(1:现场检查;2:资料检查;3:事件触发)
SonTargetName string `json:"sontargetname"` //子栏目名称
}
// 根据指标栏目新增指标细则
@ -188,11 +190,11 @@ type printOneTargetCont struct {
// 部门指标关联岗位
type depTarAboutPost struct {
publicmethod.PublicId
OrgList []loopStruct `json:"orglist"`
OrgList []LoopStruct `json:"orglist"`
}
// 循环体
type loopStruct struct {
type LoopStruct struct {
publicmethod.PublicId
Child []loopStruct `json:"child"`
Child []LoopStruct `json:"child"`
}

412
api/version1/postseting/postpc/scheme.go

@ -9,6 +9,8 @@ import (
"key_performance_indicators/overall/publicmethod"
"sort"
"strconv"
"strings"
"time"
"github.com/gin-gonic/gin"
)
@ -270,6 +272,414 @@ func (a *ApiMethod) SubmitPostScheme(c *gin.Context) {
publicmethod.Result(1, receivedValue, c, "考核项目不能为空!")
return
}
jsonCont, _ := json.Marshal(receivedValue)
orderIdInt, _ := strconv.ParseInt(receivedValue.OrgId, 10, 64)
//根据行政组织Id获取集团信息,及部门信息
groupId, companyId, departmentId, sunDepartId, workShopId := publicmethod.GetOrgStructure(orderIdInt)
//获取公司首字母
var companyCont modelshr.AdministrativeOrganization
companyCont.GetCont(map[string]interface{}{"`id`": companyId}, "`name`", "`abbreviation`")
firstNameWord := companyCont.Abbreviation
if firstNameWord == "" {
firstNameWord = companyCont.Name
}
companyFirstWord := publicmethod.ChineseFirstWordCapitalize(firstNameWord) //公司首字母
//获取部门首字母
var departmentCont modelshr.AdministrativeOrganization
departmentCont.GetCont(map[string]interface{}{"`id`": departmentId}, "`name`", "`abbreviation`")
firstNameWordDepart := departmentCont.Abbreviation
if firstNameWordDepart == "" {
firstNameWordDepart = departmentCont.Name
}
departmentFirstWord := publicmethod.ChineseFirstWordCapitalize(firstNameWordDepart) //部门首字母
judgeState := 1 //方案初始状态
//判断该岗位是否有生成的考核方案
var versionState []int
overall.CONSTANT_DB_KPI.Model(&modelskpi.PositionPlanVersio{}).Select("state").Where("`group` = ? AND `department` = ? AND `orgid` = ? AND `position` = ?", companyId, departmentId, orderIdInt, receivedValue.PostId).Find(&versionState)
fmt.Printf("versionState----------->%v------------>%v\n", len(versionState), versionState)
if len(versionState) > 0 {
for _, s_v := range versionState {
if s_v == 1 {
judgeState = 2
}
}
}
var versioNum string //版本号
//判断年度是否存在版本
var sumVerson int64
judgeVersioNum := overall.CONSTANT_DB_KPI.Model(&modelskpi.PositionPlanVersio{}).Select("`id`").Where("`group` = ? AND `department` = ? AND `years` = ?", companyId, departmentId, receivedValue.Year).Pluck("COALESCE(COUNT(id), 0) as countid", &sumVerson).Error
if judgeVersioNum != nil {
versioNum = "0001"
} else {
if sumVerson == 0 {
versioNum = "0001"
} else {
sumVerson++
sumVersonStr := strconv.FormatInt(sumVerson, 10)
versioNum = publicmethod.ZeroFillByStr(sumVersonStr, 4, true)
}
}
todyTime := time.Now().Unix()
versionNumber := fmt.Sprintf("%v-%v-%v%v", companyFirstWord, departmentFirstWord, publicmethod.UnixTimeToDay(todyTime, 21), versioNum)
postIdInt, _ := strconv.ParseInt(receivedValue.PostId, 10, 64) //岗位id转成整形
yearInt, _ := strconv.ParseInt(receivedValue.Year, 10, 64)
jsonPlanCont, _ := json.Marshal(receivedValue)
//准备写入方案
var postPlanScheme modelskpi.PositionPlanVersio
postPlanScheme.Group = companyId //归属集团"`
postPlanScheme.Department = departmentId //归属部门"`
postPlanScheme.OrgId = orderIdInt //行政组织"`
postPlanScheme.Position = postIdInt //归属岗位"`
postPlanScheme.Key = versionNumber //编码"`
postPlanScheme.Versio = versioNum //版本号"`
postPlanScheme.Year = yearInt //年度"`
postPlanScheme.State = judgeState //状态(1:启用;2:禁用;3:删除)"`
postPlanScheme.AddTime = todyTime //创建时间"`
postPlanScheme.EiteTime = todyTime //修改时间"`
postPlanScheme.Content = string(jsonPlanCont) //版本内容"`
err := overall.CONSTANT_DB_KPI.Create(&postPlanScheme).Error
if err != nil {
publicmethod.Result(104, receivedValue.OrgId, c, "请检查您的数据格式!")
return
}
fmt.Printf("groupId-------->%v---->companyId-------->%v---->departmentId-------->%v---->sunDepartId-------->%v---->workShopId-------->%v---------versionNumber----------->%v---------judgeState----------->%v\n", groupId, companyId, departmentId, sunDepartId, workShopId, versionNumber, judgeState)
//岗位指标处理
if len(receivedValue.PostChild) > 0 {
syncSeting.Add(1)
go postSchemeTarget(versionNumber, 1, judgeState, receivedValue.PostChild, companyId, departmentId, orderIdInt, postIdInt)
}
//引用部门指标处理
if len(receivedValue.DepartmentChild) > 0 {
syncSeting.Add(1)
go postSchemeTarget(versionNumber, 2, judgeState, receivedValue.DepartmentChild, companyId, departmentId, orderIdInt, postIdInt)
}
syncSeting.Wait()
jsonCont, _ := json.Marshal(postPlanScheme)
publicmethod.Result(0, string(jsonCont), c)
}
/*
岗位指标写入
@versionNumber 方案版本号
@source 来源1岗位2部门引用
@judgeState 考核项状态
@scheme 方案结构体
@companyId 公司
@departmentId 部门
@orgid 行政组织
@postid 岗位
*/
func postSchemeTarget(versionNumber string, source, judgeState int, scheme []schemeStructure, companyId, departmentId, orgid, postid int64) {
defer syncSeting.Done()
timeData := time.Now().Unix()
var saveNewData []modelskpi.QualitativeEvaluationScheme
for _, v := range scheme { //解析维度
dimensionIdInt64, _ := strconv.ParseInt(v.Id, 10, 64) //转换维度ID
if len(v.Child) > 0 { //判断是否有指标
for _, cv := range v.Child { //解析指标
targetIdInt64, _ := strconv.ParseInt(cv.Id, 10, 64) //转换指标ID
var saveData modelskpi.QualitativeEvaluationScheme
scoringMethod := 1
//判断计分方式
if source != 1 { //来源于部门引用
var departTargetInfo modelskpi.EvaluationTarget
departTargetInfo.GetCont(map[string]interface{}{"`et_id`": targetIdInt64}, "`et_scoring_method`")
if departTargetInfo.ScoringMethod != 0 {
scoringMethod = departTargetInfo.ScoringMethod
}
} else { //来源于岗位考核
var departPostTargetInfo modelskpi.PostTarget
departPostTargetInfo.GetCont(map[string]interface{}{"`id`": targetIdInt64}, "`scoring_method`")
if departPostTargetInfo.ScoringMethod != 0 {
scoringMethod = departPostTargetInfo.ScoringMethod
}
}
if cv.Type != 1 { //定量考核
//判断该指标是否存在
whereLian := publicmethod.MapOut[string]()
whereLian["`version_number`"] = versionNumber
whereLian["`company_id`"] = companyId
whereLian["`department_id`"] = departmentId
whereLian["`org_id`"] = orgid
whereLian["`post_id`"] = postid
whereLian["`dimension_id`"] = dimensionIdInt64
whereLian["`target_id`"] = targetIdInt64
judgeLianErr := saveData.GetCont(whereLian, "`id`", "`state`")
if judgeLianErr == nil {
eidtTargetCont := publicmethod.MapOut[string]()
eidtTargetCont["`scoring_method`"] = scoringMethod
eidtTargetCont["`state`"] = judgeState
eidtTargetCont["`source`"] = source
eidtTargetCont["`run_state`"] = cv.State
eidtTargetCont["`eitetime`"] = timeData
saveData.EiteCont(map[string]interface{}{"`id`": saveData.Id}, eidtTargetCont)
} else { //不存在需要新增
saveData.VersionNumber = versionNumber //版本编号"`
saveData.CompanyId = companyId //归属公司"`
saveData.DepartmentId = departmentId //归属部门"`
saveData.OrgId = orgid //归属行政组织"`
saveData.PostId = postid //归属岗位"`
saveData.Title = cv.Name //考核项名称"`
saveData.DimensionId = dimensionIdInt64 //维度"`
saveData.TargetId = targetIdInt64 //指标"`
saveData.SonTargetId = 0 //子栏目"`
saveData.DetailsId = 0 //细则"`
saveData.Attribute = cv.Type //属性 1:定性考核;2:定量考核"`
saveData.MinScore = 0 //最小分*100保存"`
saveData.MaxScore = 0 //最大分*100保存"`
saveData.ScoringMethod = scoringMethod //计分方式(1:自动;2:手动)"`
saveData.State = judgeState //状态(1:启用;2:禁用;3:删除)"`
saveData.Addtime = timeData //添加时间"`
saveData.Eitetime = timeData //编辑时间"`
saveData.CensorType = "2" //检查方式(1:现场检查;2:资料检查;3:事件触发)"`
saveData.Source = source //来源(1:岗位;2:部门引用)"`
saveData.RunState = cv.State //运行状态(1:启用;2:禁用;3:观察)
saveNewData = append(saveNewData, saveData)
}
if source != 1 { //来源于部门引用
// fmt.Printf("启用人员管理--1--->%v--->%v--->%v--->%v\n", source, targetIdInt64, len(cv.Operator), cv.Operator)
if len(cv.Operator) > 0 {
// fmt.Printf("启用人员管理--2--->%v\n", targetIdInt64)
syncSetinges.Add(1)
go DepartAboutPostTargetReport(dimensionIdInt64, targetIdInt64, 0, 0, orgid, postid, cv.Operator, 2, cv.Type)
}
}
} else { //定性考核
if len(cv.Child) > 0 { //判断是否有定性考核项目
for _, cvt := range cv.Child {
var sonTargetIdInt64 int64 = 0
var detailsIdInt64 int64 = 0
//获取细则内容
if source != 1 { //来源于部门引用
var depatrDeatCont modelskpi.DetailedTarget
depatrDeatCont.GetCont(map[string]interface{}{"`dt_id`": cvt.Id})
sonTargetIdInt64 = depatrDeatCont.ParentIdSun
detailsIdInt64 = depatrDeatCont.Id
} else { //来源于岗位考核
var depatrDeatCont modelskpi.PostTargetDetails
depatrDeatCont.GetCont(map[string]interface{}{"`id`": cvt.Id})
sonTargetIdInt64 = depatrDeatCont.ParentIdSun
detailsIdInt64 = depatrDeatCont.Id
}
//判断该细则是否存在
whereLian := publicmethod.MapOut[string]()
whereLian["`version_number`"] = versionNumber
whereLian["`company_id`"] = companyId
whereLian["`department_id`"] = departmentId
whereLian["`org_id`"] = orgid
whereLian["`post_id`"] = postid
whereLian["`dimension_id`"] = dimensionIdInt64
whereLian["`target_id`"] = targetIdInt64
whereLian["`son_target_id`"] = sonTargetIdInt64
whereLian["`details_id`"] = detailsIdInt64
judgeLianErr := saveData.GetCont(whereLian, "`id`", "`state`")
if judgeLianErr == nil {
eidtTargetCont := publicmethod.MapOut[string]()
eidtTargetCont["`scoring_method`"] = scoringMethod
eidtTargetCont["`state`"] = judgeState
eidtTargetCont["`source`"] = source
eidtTargetCont["`run_state`"] = cv.State
eidtTargetCont["`eitetime`"] = timeData
saveData.EiteCont(map[string]interface{}{"`id`": saveData.Id}, eidtTargetCont)
} else { //不存在需要新增
var minScoreInt int64 = 0
var maxScoreInt int64 = 0
scoreAry := strings.Split(cvt.ReferenceScore, "-")
scoreLen := len(scoreAry)
if scoreLen > 0 {
if scoreLen == 1 {
maxScore, _ := strconv.ParseFloat(scoreAry[0], 64)
maxScoreInt, _ = strconv.ParseInt(strconv.FormatFloat(maxScore*100, 'f', -1, 64), 10, 64)
minScoreInt = 0
} else {
minScore, _ := strconv.ParseFloat(scoreAry[0], 64)
maxScore, _ := strconv.ParseFloat(scoreAry[scoreLen-1], 64)
minScoreInt, _ = strconv.ParseInt(strconv.FormatFloat(minScore*100, 'f', -1, 64), 10, 64)
maxScoreInt, _ = strconv.ParseInt(strconv.FormatFloat(maxScore*100, 'f', -1, 64), 10, 64)
}
}
saveData.VersionNumber = versionNumber //版本编号"`
saveData.CompanyId = companyId //归属公司"`
saveData.DepartmentId = departmentId //归属部门"`
saveData.OrgId = orgid //归属行政组织"`
saveData.PostId = postid //归属岗位"`
saveData.Title = cv.Name //考核项名称"`
saveData.DimensionId = dimensionIdInt64 //维度"`
saveData.TargetId = targetIdInt64 //指标"`
saveData.SonTargetId = sonTargetIdInt64 //子栏目"`
saveData.DetailsId = detailsIdInt64 //细则"`
saveData.Attribute = cv.Type //属性 1:定性考核;2:定量考核"`
saveData.MinScore = minScoreInt //最小分*100保存"`
saveData.MaxScore = maxScoreInt //最大分*100保存"`
saveData.ScoringMethod = scoringMethod //计分方式(1:自动;2:手动)"`
saveData.State = judgeState //状态(1:启用;2:禁用;3:删除)"`
saveData.Addtime = timeData //添加时间"`
saveData.Eitetime = timeData //编辑时间"`
saveData.CensorType = "2" //检查方式(1:现场检查;2:资料检查;3:事件触发)"`
saveData.Source = source //来源(1:岗位;2:部门引用)"`
saveData.RunState = cv.State //运行状态(1:启用;2:禁用;3:观察)
saveNewData = append(saveNewData, saveData)
}
if source != 1 { //来源于部门引用
// fmt.Printf("启用人员管理--3--->%v--->%v--->%v--->%v\n", source, targetIdInt64, len(cv.Operator), cv.Operator)
if len(cvt.Operator) > 0 {
// fmt.Printf("启用人员管理--4--->%v--->%v\n", targetIdInt64, detailsIdInt64)
syncSetinges.Add(1)
go DepartAboutPostTargetReport(dimensionIdInt64, targetIdInt64, sonTargetIdInt64, detailsIdInt64, orgid, postid, cvt.Operator, 2, cv.Type)
}
}
}
}
}
}
}
}
if len(saveNewData) > 0 {
overall.CONSTANT_DB_KPI.Create(&saveNewData)
}
syncSetinges.Wait()
}
/*
协程处理
部门指标岗位提报人关联通用函数
@dimensionId 维度
@targetId 指标ID
@targetSunId 栏目ID
@bylawsId 指标细则
@departmentId 接受考核部门
@postId 岗位
@repart 提报人
@class 级别1部门级2岗位级
@nature 1定性考核2定量考核
func departAboutPostTargetReport(dimensionId, targetId, targetSunId, bylawsId, departmentId, postId int64, repart []loopStruct, class, nature int)
*/
func DepartAboutPostTargetReport(dimensionId, targetId, targetSunId, bylawsId, departmentId, postId int64, repart []string, class, nature int) {
defer syncSetinges.Done()
// fmt.Printf("启用人员管理----->%v\n", targetId)
//将不属于该指标细则的部门至禁用
otherSaveData := publicmethod.MapOut[string]()
otherSaveData["`state`"] = 2
otherSaveData["`time`"] = time.Now().Unix()
where := publicmethod.MapOut[string]()
where["`type`"] = class
if targetId != 0 {
where["`target_id`"] = targetId
}
if targetSunId != 0 {
where["`target_sun_id`"] = targetSunId
}
if bylawsId != 0 {
where["`target_bylaws`"] = bylawsId
}
if departmentId != 0 {
where["`department_id`"] = departmentId
}
if postId != 0 {
where["`post_id`"] = postId
}
if len(repart) < 1 {
overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetReport{}).Where(where).Updates(&otherSaveData)
} else {
//获取关联的人员
var userKeyAbout []string
for _, v := range repart {
if publicmethod.IsInTrue[string](v, userKeyAbout) == false {
userKeyAbout = append(userKeyAbout, v)
//获取评价人部门
var manCont modelshr.PersonArchives
manCont.GetCont(map[string]interface{}{"`key`": v}, "`maindeparment`")
var tarReportCont modelskpi.TargetReport
trWhere := publicmethod.MapOut[string]()
trWhere["`man_key`"] = v
trWhere["`type`"] = class
if targetId != 0 {
trWhere["`target_id`"] = targetId
}
if targetSunId != 0 {
trWhere["`target_sun_id`"] = targetSunId
}
if bylawsId != 0 {
trWhere["`target_bylaws`"] = bylawsId
}
if departmentId != 0 {
trWhere["`department_id`"] = departmentId
}
if postId != 0 {
trWhere["`post_id`"] = postId
}
saveErr := tarReportCont.GetCont(trWhere, "`id`", "`state`")
if saveErr == nil {
if tarReportCont.State != 1 {
tarReportCont.EiteCont(map[string]interface{}{"`id`": tarReportCont.Id}, map[string]interface{}{"`state`": 1, "`dimension_id`": dimensionId, "`man_department`": manCont.MainDeparment, "`time`": time.Now().Unix()})
}
} else {
xiZe := 3
if targetId != 0 && targetSunId != 0 && bylawsId == 0 {
xiZe = 2
} else if targetId != 0 && targetSunId == 0 && bylawsId == 0 {
xiZe = 1
}
tarReportCont.Dimension = dimensionId
tarReportCont.TargetId = targetId //指标ID"`
tarReportCont.TargetSunId = targetSunId //子目标"`
tarReportCont.TargetBylaws = bylawsId //指标细则"`
tarReportCont.DepartmentId = departmentId //部门ID"`
tarReportCont.PostId = postId //岗位ID"`
tarReportCont.Type = class //类型(1:公司级;2:部门级)"`
tarReportCont.State = 1 //状态(1:启用;2:禁用;3:删除)"`
reportId, _ := strconv.ParseInt(v, 10, 64)
tarReportCont.ReportPerson = reportId //上报人"`
tarReportCont.ManDepartment = manCont.MainDeparment //提报人所在部门"`
tarReportCont.Time = time.Now().Unix() //写入时间"`
tarReportCont.Class = nature //1:定性考核;2:定量考核"`
tarReportCont.Level = xiZe //1:指标;2:子目标;3:细则
overall.CONSTANT_DB_KPI.Create(&tarReportCont)
}
}
}
//清除不需要提报的人员
// if len(userKeyAbout) > 0 {
// overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetReport{}).Where(where).Not(map[string]interface{}{"man_key": userKeyAbout}).Updates(&otherSaveData)
// }
}
}
// 获取岗位方案内容列表
func (a *ApiMethod) GetPostScheme(c *gin.Context) {
var receivedValue publicmethod.PublicId
err := c.ShouldBindJSON(&receivedValue)
if err != nil {
publicmethod.Result(100, err, c)
return
}
if receivedValue.Id == "" {
publicmethod.Result(101, err, c)
return
}
//获取维度
var schemeCont modelskpi.PositionPlanVersio
err = overall.CONSTANT_DB_KPI.Where("`id` = ?", receivedValue.Id).Find(&schemeCont).Error
if err != nil {
publicmethod.Result(107, err, c)
return
}
}

27
api/version1/postseting/postpc/type.go

@ -11,6 +11,7 @@ type ApiMethod struct{}
// 协程设置
var syncSeting = sync.WaitGroup{}
var syncSetinges = sync.WaitGroup{}
// 岗位指标协程操作
type postDimeTarSync struct {
@ -81,17 +82,25 @@ type schemeStructure struct {
type schemeTargetStructure struct {
publicmethod.PublicId //id
publicmethod.PublicName //名称
Content string `json:"content"` //说明
Score float64 `json:"score"` //分数
State int `json:"state"` //状态:1:启用;2:禁用;3:观察
Type int `json:"type"` //1、定性指标;2、定量指标
Child []schemeDetailedStructure `json:"child"` //指标细则列表
Content string `json:"content"` //说明
Score float64 `json:"score"` //分数
State int `json:"state"` //状态:1:启用;2:禁用;3:观察
Type int `json:"type"` //1、定性指标;2、定量指标
Child []schemeDetailedStructure `json:"child"` //指标细则列表
Operator []string `json:"operator"` //考核执行人
}
// 方案中的定性指标细则
type schemeDetailedStructure struct {
publicmethod.PublicId //id
publicmethod.PublicName //名称
ReferenceScore string `json:"referencescore"` //考核标准
State int `json:"state"` //状态:1:启用;2:禁用;3:观察
publicmethod.PublicId //id
publicmethod.PublicName //名称
ReferenceScore string `json:"referencescore"` //考核标准
State int `json:"state"` //状态:1:启用;2:禁用;3:观察
Operator []string `json:"operator"` //考核执行人
}
// 岗位考核方案列表
type postSchemeList struct {
publicmethod.PagesTurn
VersionNumber string `json:"versionnumber"` //版本号
}

67
models/modelskpi/position_plan_version.go

@ -0,0 +1,67 @@
package modelskpi
import (
"key_performance_indicators/overall"
"strings"
)
// 岗位考核方案版本管理
type PositionPlanVersio struct {
Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"`
Group int64 `json:"group" gorm:"column:group;type:bigint(20) unsigned;default:0;not null;comment:归属集团"`
Department int64 `json:"department" gorm:"column:department;type:bigint(20) unsigned;default:0;comment:归属部门"`
OrgId int64 `json:"orgid" gorm:"column:orgid;type:bigint(20) unsigned;default:0;comment:行政组织"`
Position int64 `json:"position" gorm:"column:position;type:bigint(20) unsigned;default:0;comment:归属岗位"`
Key string `json:"key" gorm:"column:key;type:varchar(200) unsigned;default:0;not null;comment:编码"`
Versio string `json:"versio" gorm:"column:version;type:varchar(20) unsigned;default:0;not null;comment:版本号"`
Year int64 `json:"year" gorm:"column:years;type:int(5) unsigned;default:0;not null;comment:年度"`
State int `json:"state" gorm:"column:state;type:int(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"`
AddTime int64 `json:"addtime" gorm:"column:addtime;type:bigint(20) unsigned;default:0;not null;comment:创建时间"`
EiteTime int64 `json:"eitetime" gorm:"column:eitetime;type:bigint(20) unsigned;default:0;not null;comment:修改时间"`
Content string `json:"content" gorm:"column:content;type:longtext;comment:版本内容"`
}
func (PositionPlanVersio *PositionPlanVersio) TableName() string {
return "position_plan_version"
}
// 编辑内容
func (cont *PositionPlanVersio) EiteCont(whereMap interface{}, saveData interface{}) (err error) {
err = overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Updates(saveData).Error
return
}
// 获取内容
func (cont *PositionPlanVersio) GetCont(whereMap interface{}, field ...string) (err error) {
gormDb := overall.CONSTANT_DB_KPI.Model(&cont)
if len(field) > 0 {
fieldStr := strings.Join(field, ",")
gormDb = gormDb.Select(fieldStr)
}
gormDb = gormDb.Where(whereMap)
err = gormDb.First(&cont).Error
return
}
// 根据条件获取总数
func (cont *PositionPlanVersio) CountCont(whereMap interface{}) (countId int64) {
overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Count(&countId)
return
}
// 读取全部信息
func (cont *PositionPlanVersio) ContMap(whereMap interface{}, field ...string) (countAry []PositionPlanVersio, err error) {
gormDb := overall.CONSTANT_DB_KPI.Model(&cont)
if len(field) > 0 {
fieldStr := strings.Join(field, ",")
gormDb = gormDb.Select(fieldStr)
}
err = gormDb.Where(whereMap).Find(&countAry).Error
return
}
// 删除内容
func (cont *PositionPlanVersio) DelCont(whereMap interface{}) (err error) {
err = overall.CONSTANT_DB_KPI.Where(whereMap).Delete(&cont).Error
return
}

2
models/modelskpi/post_target.go

@ -21,7 +21,7 @@ type PostTarget struct {
Unit string `json:"unit" gorm:"column:unit;type:varchar(255) unsigned;default:'';not null;comment:单位"`
Cycle int `json:"cycle" gorm:"column:cycle;type:int(1) unsigned;default:1;not null;comment:1:班;2:天;3:周;4:月;5:季度;6:年"`
Cycleattr int `json:"cycleattr" gorm:"column:cycleattr;type:int(9) unsigned;default:1;not null;comment:辅助计数"`
ScoringMethod int64 `json:"scoringmethod" gorm:"column:scoring_method;type:int(1) unsigned;default:0;not null;comment:计分方式(1:自动;2:手动)"`
ScoringMethod int `json:"scoringmethod" gorm:"column:scoring_method;type:int(1) unsigned;default:0;not null;comment:计分方式(1:自动;2:手动)"`
VisibleRange string `json:"visiblerange" gorm:"column:visible_range;type:text ;default:'';comment:可见范围"`
VisibleGroup string `json:"visiblegroup" gorm:"column:visible_group;type:text ;default:'';comment:可见范围(集团)"`
}

77
models/modelskpi/post_target_details.go

@ -0,0 +1,77 @@
package modelskpi
import (
"key_performance_indicators/overall"
"strings"
)
// 指标细则
type PostTargetDetails struct {
Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"`
Title string `json:"title" gorm:"column:title;type:text;comment:指标细则"`
Content string `json:"content" gorm:"column:content;type:text;comment:指标说明"`
ParentId int64 `json:"parentid" gorm:"column:parentid;type:bigint(20) unsigned;default:0;not null;comment:归属指标栏目"`
ParentIdSun int64 `json:"parentidsun" gorm:"column:parentid_sun;type:bigint(20) unsigned;default:0;not null;comment:归属指标子栏目"`
State int `json:"state" gorm:"column:state;type:tinyint(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"`
AddTime int64 `json:"addtime" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:制定时间"`
MinScore int64 `json:"minscore" gorm:"column:min_score;type:bigint(20) unsigned;default:0;not null;comment:最小分*100保存"`
MaxScore int64 `json:"maxscore" gorm:"column:max_score;type:bigint(20) unsigned;default:0;not null;comment:最大分*100保存"`
Company string `json:"company" gorm:"column:company;type:varchar(20) unsigned;default:0;not null;comment:单位"`
AddReduce int `json:"addreduce" gorm:"column:add_reduce;type:int(1) unsigned;default:1;not null;comment:1:减少;2:增加;3:无属性,现场确认加或减"`
CensorType string `json:"censortype" gorm:"column:censor_type;type:text;comment:检查方式"`
CensorCont string `json:"censorcont" gorm:"column:censor_cont;type:longtext;comment:检查依据"`
CensorRate int `json:"censorrate" gorm:"column:censor_rate;type:int(5) unsigned;default:1;not null;comment:检查频次"`
Cycles int `json:"cycle" gorm:"column:cycle;type:tinyint(1) unsigned;default:1;not null;comment:1:班;2:天;3:周;4:月;5:季度;6:年"`
CycleAttres int `json:"cycleattr" gorm:"column:cycleattr;type:int(9) unsigned;default:1;not null;comment:辅助计数"`
Paretment int64 `json:"paretment" gorm:"column:paretment;type:bigint(20);comment:接受考核的部门"`
ParetmentPost string `json:"paretmentpost" gorm:"column:paretment_post;type:longtext;comment:接受考核的部门岗位"`
Reportary string `json:"reportary" gorm:"column:reportary;type:longtext;comment:提报人"`
Punishmode int `json:"punishmode" gorm:"column:punishmode;type:tinyint(1) unsigned;default:1;not null;comment:处罚方式 1:扣分;2:现金处罚;3:扣分加现金"`
Maxmoney int64 `json:"maxmoney" gorm:"column:maxmoney;type:bigint(20) unsigned;default:0;not null;comment:最高罚款"`
Minmoney int64 `json:"minmoney" gorm:"column:minmoney;type:bigint(20) unsigned;default:0;not null;comment:最低罚款"`
}
func (PostTargetDetails *PostTargetDetails) TableName() string {
return "post_target_details"
}
// 编辑内容
func (cont *PostTargetDetails) EiteCont(whereMap interface{}, saveData interface{}) (err error) {
err = overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Updates(saveData).Error
return
}
// 获取内容
func (cont *PostTargetDetails) GetCont(whereMap interface{}, field ...string) (err error) {
gormDb := overall.CONSTANT_DB_KPI.Model(&cont)
if len(field) > 0 {
fieldStr := strings.Join(field, ",")
gormDb = gormDb.Select(fieldStr)
}
gormDb = gormDb.Where(whereMap)
err = gormDb.First(&cont).Error
return
}
// 根据条件获取总数
func (cont *PostTargetDetails) CountCont(whereMap interface{}) (countId int64) {
overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Count(&countId)
return
}
// 读取全部信息
func (cont *PostTargetDetails) ContMap(whereMap interface{}, field ...string) (countAry []PostTargetDetails, err error) {
gormDb := overall.CONSTANT_DB_KPI.Model(&cont)
if len(field) > 0 {
fieldStr := strings.Join(field, ",")
gormDb = gormDb.Select(fieldStr)
}
err = gormDb.Where(whereMap).Order("sort ASC").Find(&countAry).Error
return
}
// 删除内容
func (cont *PostTargetDetails) DelCont(whereMap interface{}) (err error) {
err = overall.CONSTANT_DB_KPI.Where(whereMap).Delete(&cont).Error
return
}

76
models/modelskpi/qualitative_evaluation_scheme.go

@ -0,0 +1,76 @@
package modelskpi
import (
"key_performance_indicators/overall"
"strings"
)
// 岗位评估方案
type QualitativeEvaluationScheme struct {
Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"`
VersionNumber string `json:"versionnumber" gorm:"column:version_number;type:varchar(255) unsigned;not null;comment:版本编号"`
CompanyId int64 `json:"companyid" gorm:"column:company_id;type:bigint(20) unsigned;default:0;not null;comment:归属公司"`
DepartmentId int64 `json:"departmentid" gorm:"column:department_id;type:bigint(20) unsigned;default:0;not null;comment:归属部门"`
OrgId int64 `json:"orgid" gorm:"column:org_id;type:bigint(20) unsigned;default:0;not null;comment:归属行政组织"`
PostId int64 `json:"postid" gorm:"column:post_id;type:bigint(20) unsigned;default:0;not null;comment:归属岗位"`
Title string `json:"title" gorm:"column:title;type:varchar(255) ;default:'';comment:考核项名称"`
DimensionId int64 `json:"dimensionid" gorm:"column:dimension_id;type:bigint(20) unsigned;default:0;not null;comment:维度"`
TargetId int64 `json:"targetid" gorm:"column:target_id;type:bigint(20) unsigned;default:0;not null;comment:指标"`
SonTargetId int64 `json:"sontargetid" gorm:"column:son_target_id;type:bigint(20) unsigned;default:0;not null;comment:子栏目"`
DetailsId int64 `json:"detailsid" gorm:"column:details_id;type:bigint(20) unsigned;default:0;not null;comment:细则"`
Attribute int `json:"attribute" gorm:"column:attribute;type:tinyint(1) unsigned;default:1;not null;comment:属性 1:定性考核;2:定量考核"`
MinScore int64 `json:"minscore" gorm:"column:min_score;type:bigint(20) unsigned;default:0;not null;comment:最小分*100保存"`
MaxScore int64 `json:"maxscore" gorm:"column:max_score;type:bigint(20) unsigned;default:0;not null;comment:最大分*100保存"`
ScoringMethod int `json:"scoringmethod" gorm:"column:scoring_method;type:tinyint(1) unsigned;default:1;not null;comment:计分方式(1:自动;2:手动)"`
State int `json:"state" gorm:"column:state;type:tinyint(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"`
Addtime int64 `json:"addtime" gorm:"column:addtime;type:bigint(20) unsigned;default:0;not null;comment:添加时间"`
Eitetime int64 `json:"eitetime" gorm:"column:eitetime;type:bigint(20) unsigned;default:0;not null;comment:编辑时间"`
CensorType string `json:"censortype" gorm:"column:censor_type;type:tinytext;comment:检查方式(1:现场检查;2:资料检查;3:事件触发)"`
Source int `json:"source" gorm:"column:source;type:tinyint(1) unsigned;default:1;not null;comment:来源(1:岗位;2:部门引用)"`
RunState int `json:"run_state" gorm:"column:run_state;type:tinyint(1) unsigned;default:1;not null;comment:运行状态(1:启用;2:禁用;3:观察)"`
}
func (QualitativeEvaluationScheme *QualitativeEvaluationScheme) TableName() string {
return "qualitative_evaluation_scheme"
}
// 编辑内容
func (cont *QualitativeEvaluationScheme) EiteCont(whereMap interface{}, saveData interface{}) (err error) {
err = overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Updates(saveData).Error
return
}
// 获取内容
func (cont *QualitativeEvaluationScheme) GetCont(whereMap interface{}, field ...string) (err error) {
gormDb := overall.CONSTANT_DB_KPI.Model(&cont)
if len(field) > 0 {
fieldStr := strings.Join(field, ",")
gormDb = gormDb.Select(fieldStr)
}
gormDb = gormDb.Where(whereMap)
err = gormDb.First(&cont).Error
return
}
// 根据条件获取总数
func (cont *QualitativeEvaluationScheme) CountCont(whereMap interface{}) (countId int64) {
overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Count(&countId)
return
}
// 读取全部信息
func (cont *QualitativeEvaluationScheme) ContMap(whereMap interface{}, field ...string) (countAry []QualitativeEvaluationScheme, err error) {
gormDb := overall.CONSTANT_DB_KPI.Model(&cont)
if len(field) > 0 {
fieldStr := strings.Join(field, ",")
gormDb = gormDb.Select(fieldStr)
}
err = gormDb.Where(whereMap).Find(&countAry).Error
return
}
// 删除内容
func (cont *QualitativeEvaluationScheme) DelCont(whereMap interface{}) (err error) {
err = overall.CONSTANT_DB_KPI.Where(whereMap).Delete(&cont).Error
return
}

97
overall/publicmethod/technique.go

@ -507,3 +507,100 @@ func DecimalEs(value float64, weishu int) float64 {
return value
}
// 递归查找
func RecursionOrgLeve(superior int64, leve int64) (groupId int64) {
if leve == 0 {
leve = 1
}
var orgMap modelshr.OrgContType
err := orgMap.GetCont(map[string]interface{}{"`id`": superior, "`state`": 1}, "`id`", "`superior`", "`level`")
if err != nil {
return
}
if orgMap.Level <= leve {
groupId = orgMap.Id
return
} else {
groupId = RecursionOrgLeve(orgMap.Superior, leve)
}
return
}
// 获取集团、公司、部门、二级部门、工段
func GetOrgStructure(orgId int64) (groupId, companyId, departmentId, sunDepartId, workShopId int64) {
var orgContTypeInfo modelshr.OrgContType
err := orgContTypeInfo.GetCont(map[string]interface{}{"`id`": orgId})
if err != nil {
return
}
switch orgContTypeInfo.Level {
case 1:
groupId = orgContTypeInfo.Id
case 2:
groupId = RecursionOrgLeve(orgContTypeInfo.Superior, 1)
workShopId = orgContTypeInfo.Id
case 3:
groupId = RecursionOrgLeve(orgContTypeInfo.Superior, 2)
companyId = orgContTypeInfo.Id
case 4:
groupId = RecursionOrgLeve(orgContTypeInfo.Superior, 2)
companyId = RecursionOrgLeve(orgContTypeInfo.Superior, 3)
departmentId = orgContTypeInfo.Id
case 5:
groupId = RecursionOrgLeve(orgContTypeInfo.Superior, 2)
companyId = RecursionOrgLeve(orgContTypeInfo.Superior, 3)
departmentId = RecursionOrgLeve(orgContTypeInfo.Superior, 4)
sunDepartId = orgContTypeInfo.Id
case 6:
groupId = RecursionOrgLeve(orgContTypeInfo.Superior, 2)
companyId = RecursionOrgLeve(orgContTypeInfo.Superior, 3)
departmentId = RecursionOrgLeve(orgContTypeInfo.Superior, 4)
sunDepartId = RecursionOrgLeve(orgContTypeInfo.Superior, 5)
workShopId = orgContTypeInfo.Id
default:
groupId = orgContTypeInfo.Id
companyId = orgContTypeInfo.Id
workShopId = orgContTypeInfo.Id
}
return
}
// 获取指定行政组织id,所有子类
func GetDepartmentSun(superior int64, idary []int64) (orgIdAry []int64) {
var orgAry []modelshr.AdministrativeOrganization
err := overall.CONSTANT_DB_HR.Model(&modelshr.AdministrativeOrganization{}).Select("`id`").Where("`state` = 1 AND `superior` = ?", superior).Find(&orgAry).Error
if err != nil {
return
}
for _, v := range orgAry {
if IsInTrue[int64](v.Id, orgIdAry) == false {
orgIdAry = append(orgIdAry, v.Id)
GetDepartmentSun(v.Id, orgIdAry)
} else {
GetDepartmentSun(v.Id, orgIdAry)
}
}
return
}
// 获取集团或第一实权部门
func GetGroupOrDepartPower(parentId int64, departId ...int64) int64 {
var orgCont modelshr.AdministrativeOrganization
err := orgCont.GetCont(map[string]interface{}{"id": parentId}, "id", "organization_type", "superior", "ispower")
if err != nil {
return parentId
}
if len(departId) > 0 {
if orgCont.IsPower == 1 {
return orgCont.Id
}
return GetGroupOrDepartPower(orgCont.Superior, 1)
} else {
if orgCont.OrganizationType <= 2 {
return orgCont.Id
}
return GetGroupOrDepartPower(orgCont.Superior)
}
return orgCont.Id
}

Loading…
Cancel
Save