Browse Source

添加岗位考核指标添加

master
超级管理员 3 years ago
parent
commit
967c066de9
  1. 6
      api/version1/postseting/postpc/scheme.go
  2. 183
      api/version1/postseting/postpc/targetpost.go
  3. 15
      api/version1/postseting/postpc/type.go
  4. 85
      api/version1/postseting/postweb/posttarget.go
  5. 1
      api/version1/postseting/postweb/type.go
  6. 1
      apirouter/v1/postseting/pc.go
  7. 8
      models/modelskpi/post_nature_flow.go
  8. 65
      overall/publicmethod/technique.go

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

@ -840,9 +840,9 @@ func DepartAboutPostTargetReport(dimensionId, targetId, targetSunId, bylawsId, d
}
}
//清除不需要提报的人员
// if len(userKeyAbout) > 0 {
// overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetReport{}).Where(where).Not(map[string]interface{}{"man_key": userKeyAbout}).Updates(&otherSaveData)
// }
if len(userKeyAbout) > 0 {
overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetReport{}).Where(where).Not(map[string]interface{}{"man_key": userKeyAbout}).Updates(&otherSaveData)
}
}
}

183
api/version1/postseting/postpc/targetpost.go

@ -5,6 +5,8 @@ import (
"key_performance_indicators/overall"
"key_performance_indicators/overall/publicmethod"
"strconv"
"strings"
"time"
"github.com/gin-gonic/gin"
)
@ -86,3 +88,184 @@ func getTargetAboutPostMan(departmentId, postid, dimensionId, targetId int64) (p
}
return
}
// 添加岗位指标
func (a *ApiMethod) AddPostTarget(c *gin.Context) {
var receivedValue addPostTarget
if receivedValue.Title == "" {
publicmethod.Result(1, receivedValue, c, "请输入指标名称!")
return
}
if receivedValue.Type == 0 {
receivedValue.Type = 2
}
if receivedValue.ScoringMethod == 0 {
receivedValue.ScoringMethod = 1
}
if receivedValue.RelevantDepartments == "" {
publicmethod.Result(1, receivedValue, c, "请选择该指标归属部门!")
return
}
if len(receivedValue.RelevantPostsMan) < 1 {
publicmethod.Result(1, receivedValue, c, "请选择该指标归属岗位!")
return
}
if receivedValue.Dimension == "" {
publicmethod.Result(1, receivedValue, c, "请选择指标归属维度!")
return
}
if receivedValue.Unit == "" {
publicmethod.Result(1, receivedValue, c, "请输入该指标计算单位!")
return
}
if receivedValue.Cycle == 0 {
receivedValue.Cycle = 1
}
if receivedValue.CycleAttr == 0 {
receivedValue.CycleAttr = 1
}
var saveData modelskpi.PostTarget
saveData.Title = receivedValue.Title //标题"`
saveData.Type = receivedValue.Type //1:定性考核;2:定量考核"`
saveData.State = 1 //状态(1:启用;2:禁用;3:删除)"`
saveData.Time = time.Now().Unix() //创建时间"`
saveData.Share = 2 //1:共用;2:私用"`
departmentId, _ := strconv.ParseInt(receivedValue.RelevantDepartments, 10, 64)
saveData.ReleDepart = departmentId //相关部门"`
// saveData.DepartmentsPost = strings.Join(receivedValue.DepartmentsPost, ",") //相关岗位"`
dimensionId, _ := strconv.ParseInt(receivedValue.Dimension, 10, 64)
saveData.Dimension = dimensionId //维度"`
saveData.Key = publicmethod.GetUUid(1) //UUID"`
// saveData.Report = strings.Join(receivedValue.Report, ",") //上报人"`
saveData.Unit = receivedValue.Unit //单位"`
saveData.Cycle = receivedValue.Cycle //1:班;2:天;3:周;4:月;5:季度;6:年"`
saveData.Cycleattr = receivedValue.CycleAttr //辅助计数"`
saveData.ScoringMethod = receivedValue.ScoringMethod //计分方式(1:自动;2:手动)"`
saveData.VisibleRange = strings.Join(receivedValue.VisibleRange, ",") //可见范围"`
saveData.VisibleGroup = strings.Join(receivedValue.VisibleGroup, ",") //可见范围(集团)"`
//获取岗位与提报人
var departAny []string
var peopletAny []string
for _, v := range receivedValue.RelevantPostsMan {
if publicmethod.IsInTrue[string](v.Id, departAny) == false {
departAny = append(departAny, v.Id)
}
if len(v.Operator) > 0 {
for _, ov := range v.Operator {
if publicmethod.IsInTrue[string](ov, peopletAny) == false {
peopletAny = append(peopletAny, ov)
}
}
}
}
saveData.DepartmentsPost = strings.Join(departAny, ",") //相关岗位"`
saveData.Report = strings.Join(peopletAny, ",") //上报人"`
err := overall.CONSTANT_DB_KPI.Create(&saveData).Error
if err != nil {
publicmethod.Result(104, err, c)
return
}
//关联部门岗位
if len(departAny) > 0 {
syncSetinges.Add(1)
go EditTargetTableDimenAboutPostOfDepart(dimensionId, saveData.Id, 0, 0, departmentId, departAny, 2, receivedValue.Type)
}
//关联考核岗位和提报人
for _, dv := range receivedValue.RelevantPostsMan {
postid, _ := strconv.ParseInt(dv.Id, 10, 64)
syncSetinges.Add(1)
go DepartAboutPostTargetReport(dimensionId, saveData.Id, 0, 0, departmentId, postid, dv.Operator, 2, receivedValue.Type)
}
syncSetinges.Wait()
publicmethod.Result(0, err, c)
}
/*
编辑指标栏目细则关联部门
协程处理
部门指标岗位提报人关联通用函数
@dimensionId 维度
@targetId 指标ID
@targetSunId 栏目ID
@bylawsId 指标细则
@departmentId 接受考核部门
@postId 岗位
@class 级别1部门级2岗位级
@nature 1定性考核2定量考核
EditTargetTableDimenAboutPostOfDepart(dimensionId, targetId, targetSunId, bylawsId, departmentId int64, postId []string, class, nature int)
*/
func EditTargetTableDimenAboutPostOfDepart(dimensionId, targetId, targetSunId, bylawsId, departmentId int64, postId []string, class, nature int) {
defer syncSetinges.Done()
//将不属于的信息禁用
otherSaveData := publicmethod.MapOut[string]()
otherSaveData["`state`"] = 2
otherSaveData["`time`"] = time.Now().Unix()
//判断岗位是否存在
where := publicmethod.MapOut[string]()
where["`type`"] = class
if targetId != 0 {
where["`dimension_id`"] = dimensionId
}
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 len(postId) < 1 {
overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetReport{}).Where(where).Updates(&otherSaveData)
} else {
//获取关联部门
var aboutDepartment []string
for _, v := range postId {
if publicmethod.IsInTrue[string](v, aboutDepartment) == false {
aboutDepartment = append(aboutDepartment, v)
//判断该岗位是否已经关联
var tarDeparCont modelskpi.TargetDepartment
judgeAboutErr := overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetDepartment{}).Select("`id`,`state`").Where(where).Where("`post_id` = ?", v).First(&tarDeparCont).Error
if judgeAboutErr == nil {
tarDeparCont.EiteCont(map[string]interface{}{"`id`": tarDeparCont.Id}, map[string]interface{}{"`state`": 1, "`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
}
tarDeparCont.Dimension = dimensionId //维度"`
tarDeparCont.TargetId = targetId //指标ID"`
tarDeparCont.TargetSunId = targetSunId //子目标"`
tarDeparCont.TargetBylaws = bylawsId //指标细则"`
tarDeparCont.Type = xiZe //类型(1:指标;2:子目标;3:细则)"`
tarDeparCont.DepartmentId = departmentId //部门ID"`
postIdInt64, _ := strconv.ParseInt(v, 10, 64)
tarDeparCont.PostId = postIdInt64 //岗位ID"`
tarDeparCont.State = 1 //状态(1:启用;2:禁用;3:删除)"`
tarDeparCont.Time = time.Now().Unix() //写入时间"`
tarDeparCont.Class = nature //1:定性考核;2:定量考核"`
tarDeparCont.Level = class //级别(1:部门级;2:岗位级)"`
overall.CONSTANT_DB_KPI.Create(&tarDeparCont)
}
}
}
//清除不需要关联的部门
if len(aboutDepartment) > 0 {
overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetDepartment{}).Where(where).Not(map[string]interface{}{"`post_id`": aboutDepartment}).Updates(&otherSaveData)
}
}
}

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

@ -151,3 +151,18 @@ type postPeople struct {
publicmethod.PublicId
Operator []string `json:"operator"` //考核执行人
}
// 添加岗位指标
type addPostTarget struct {
Title string `json:"title"` //名称
Type int `json:"type"` //1:定性考核;2:定量考核
ScoringMethod int `json:"scoringMethod"` //计分方式(1:自动;2:手动)
RelevantDepartments string `json:"relevantDepartments"` //相关部门
Dimension string `json:"dimension"` //维度
Unit string `json:"unit"` //单位
Cycle int `json:"cycle"` //1:班;2:天;3:周;4:月;5:季度;6:年
CycleAttr int `json:"cycleattr"` //辅助计数
VisibleRange []string `json:"visibleRange"` //可见范围
VisibleGroup []string `json:"visibleGroup"` //可见范围(集团)
RelevantPostsMan []postPeople `json:"relevantpostsman"` //相关岗位与提报人
}

85
api/version1/postseting/postweb/posttarget.go

@ -1,6 +1,7 @@
package postweb
import (
"encoding/json"
"fmt"
"key_performance_indicators/models/modelshr"
"key_performance_indicators/models/modelskpi"
@ -443,11 +444,93 @@ func (a *ApiMethod) SendUsNatureEvaluation(c *gin.Context) {
if receivedValue.Rectification == 0 {
receivedValue.Rectification = 2
}
var correctionTime int64 = 0
if receivedValue.Rectification == 1 {
if receivedValue.CorrectionPeriod == "" {
publicmethod.Result(1, isTrue, c, "请选择什么时间前整改完成!")
return
}
var corrTimeErr bool = false
correctionTime, corrTimeErr = publicmethod.DateToTimeStamp(receivedValue.CorrectionPeriod)
if corrTimeErr == false {
publicmethod.Result(1, corrTimeErr, c, "请输入整改期限时间格式不对,谢谢!")
return
}
}
//获取登录人信息
context, _ := publicmethod.LoginMyCont(c)
uuId := publicmethod.GetUUid(1)
//流程列表
var flowCont modelskpi.PostWorkflowOrders
flowCont.OrderId = uuId //审批单ID"`
flowCont.Step = 1 //当前执行到第几步"`
flowCont.NextStep = 2 //下一步执行哪个步骤"`
flowCont.WorkFlow = "" //工作流(审批json字符串)"`
flowCont.CompanyId = userCont.Company //公司"`
flowCont.DepartmentId = userCont.MainDeparment //部门"`
flowCont.OrgId = userCont.AdminOrg //行政组织"`
flowCont.PostId = userCont.Position //岗位"`
flowCont.Class = postShemeCont.Attribute //属性1、定性;2、定量"`
flowCont.Dimension = postShemeCont.DimensionId //维度"`
flowCont.Target = postShemeCont.TargetId //指标"`
flowCont.SonTarget = postShemeCont.SonTargetId //指标子栏目"`
flowCont.Detailed = postShemeCont.DetailsId //指标细则"`
flowCont.Executor = context.Key //执行人"`
flowCont.ExecutorDepartment = context.MainDeparment //执行人部门"`
flowCont.State = 3 //流程状态 1:草稿;2:驳回;3:审批中;4:归档;5:废弃;6:删除"`
flowCont.StartTime = time.Now().Unix() //流程开始时间"`
flowCont.Time = time.Now().Unix() //时间"`
if len(receivedValue.Enclosure) > 0 {
jsonFileList, _ := json.Marshal(receivedValue.Enclosure)
flowCont.EnclosureFormat = string(jsonFileList) //附件"`
}
//定性考核流水
var postNatureFlowCont modelskpi.PostNatureFlow
postNatureFlowCont.OrderId = uuId //审批单ID"`
postNatureFlowCont.AddOrDecrease = receivedValue.AddOrDecrease //增加或减少(1:增加;2:减少)"`
postNatureFlowCont.Score = scoreVal //分值(*100保存)"`
postNatureFlowCont.Money = moneyVal //钱(扣款或奖励)*100保存"`
postNatureFlowCont.Reason = receivedValue.Reason //这样操作的原因"`
postNatureFlowCont.ShemeId = postShemeCont.Id //方案ID"`
postNatureFlowCont.ShemeVersion = postShemeCont.VersionNumber //方案版本编号"`
postNatureFlowCont.Dimension = postShemeCont.DimensionId //维度"`
postNatureFlowCont.Target = postShemeCont.TargetId //指标"`
postNatureFlowCont.SonTarget = postShemeCont.SonTargetId //指标子栏目"`
postNatureFlowCont.Detailed = postShemeCont.DetailsId //指标细则"`
postNatureFlowCont.Year = publicmethod.ComputingTime(currentTime, 1) //年"`
postNatureFlowCont.Quarter = publicmethod.ComputingTime(currentTime, 2) //季度"`
postNatureFlowCont.Month = publicmethod.ComputingTime(currentTime, 3) //月"`
postNatureFlowCont.Week = publicmethod.ComputingTime(currentTime, 4) //周"`
postNatureFlowCont.PersonLiable = userCont.Key //责任人"`
postNatureFlowCont.CompanyId = userCont.Company //公司"`
postNatureFlowCont.DepartmentId = userCont.MainDeparment //部门"`
postNatureFlowCont.OrgId = userCont.AdminOrg //行政组织"`
postNatureFlowCont.PostId = userCont.Position //岗位"`
postNatureFlowCont.Executor = context.Key //执行人"`
postNatureFlowCont.ExecutorDepartment = context.MainDeparment //执行人部门"`
postNatureFlowCont.Rectification = receivedValue.Rectification //是否需要整改 1、需要整改;2:无需整改"`
postNatureFlowCont.CorrectionTime = correctionTime //整改期限"`
postNatureFlowCont.HappenTime = currentTime //发生时间"`
postNatureFlowCont.HappenCount = receivedValue.Count //发生次数"`
postNatureFlowCont.Time = time.Now().Unix() //时间"`
//开启事务提交
gormDbAffair := overall.CONSTANT_DB_KPI
passorErr := gormDbAffair.Create(&flowCont).Error
flowErr := gormDbAffair.Create(&postNatureFlowCont).Error
if passorErr == nil && flowErr == nil {
addErr := gormDbAffair.Commit().Error
publicmethod.Result(0, addErr, c)
} else {
addErr := gormDbAffair.Rollback().Error
publicmethod.Result(104, addErr, c)
}
fmt.Printf("%v---%v---%v---%v---%v\n", currentTime, uuId, flowCont, scoreVal, moneyVal)
// fmt.Printf("%v---%v---%v---%v---%v\n", currentTime, uuId, flowCont, scoreVal, moneyVal)
}
/*

1
api/version1/postseting/postweb/type.go

@ -85,6 +85,7 @@ type sendMyEvaluationData struct {
HappenTime string `json:"happentime"` //发生时间.
Reason string `json:"reason"` //操作原因
Rectification int `json:"rectification"` //是否需要整改 1、需要整改;2:无需整改
CorrectionPeriod string `json:"correctionperiod"` //整改期限
AddOrDecrease int `json:"addordecrease"` //加或减 1:增加;2:减少
Punishmode int `json:"punishmode" ` //处罚方式 1:扣分;2:现金处罚;3:扣分加现金
Score string `json:"score"` //分数*100保存

1
apirouter/v1/postseting/pc.go

@ -20,5 +20,6 @@ func (a *ApiRouter) RouterGroupPc(router *gin.RouterGroup) {
apiRouter.POST("get_post_scheme", methodBinding.GetPostScheme) //获取岗位方案内容列表
apiRouter.POST("get_copy_sheme_infor", methodBinding.GetCopyShemeInfor) //获取复制岗位考核方案
apiRouter.POST("get_post_target", methodBinding.GetPostTarget) //获取岗位指标详情
apiRouter.POST("add_post_target", methodBinding.AddPostTarget) //添加岗位指标
}
}

8
models/modelskpi/post_nature_flow.go

@ -19,10 +19,10 @@ type PostNatureFlow struct {
Target int64 `json:"target" gorm:"column:target;type:bigint(20) unsigned;default:0;not null;comment:指标"`
SonTarget int64 `json:"sontarget" gorm:"column:son_target;type:bigint(20) unsigned;default:0;not null;comment:指标子栏目"`
Detailed int64 `json:"detailed" gorm:"column:detailed;type:bigint(20) unsigned;default:0;not null;comment:指标细则"`
Year int `json:"year" gorm:"column:year;type:int(7) unsigned;default:0;not null;comment:年"`
Quarter int `json:"quarter" gorm:"column:quarter;type:int(3) unsigned;default:0;not null;comment:季度"`
Month int `json:"month" gorm:"column:month;type:int(3) unsigned;default:0;not null;comment:月"`
Week int `json:"week" gorm:"column:week;type:int(3) unsigned;default:0;not null;comment:周"`
Year int64 `json:"year" gorm:"column:year;type:int(7) unsigned;default:0;not null;comment:年"`
Quarter int64 `json:"quarter" gorm:"column:quarter;type:int(3) unsigned;default:0;not null;comment:季度"`
Month int64 `json:"month" gorm:"column:month;type:int(3) unsigned;default:0;not null;comment:月"`
Week int64 `json:"week" gorm:"column:week;type:int(3) unsigned;default:0;not null;comment:周"`
PersonLiable int64 `json:"personliable" gorm:"column:person_liable;type:bigint(20) unsigned;default:0;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:部门"`

65
overall/publicmethod/technique.go

@ -129,6 +129,12 @@ func DateToTimeStamp(dataStr string) (timeStamp int64, isTrue bool) {
}
return
}
func DateToTimeStampOld(dataStr string) (timeStamp int64) {
tmp := "2006-01-02 15:04:05"
res, _ := time.ParseInLocation(tmp, dataStr, time.Local)
timeStamp = res.Unix()
return
}
// 数据库查询翻页
func LimitPage(page, pageSize int) (offSet int) {
@ -616,3 +622,62 @@ func GetGroupOrDepartPower(parentId int64, departId ...int64) int64 {
}
return orgCont.Id
}
// 时间计算(年、季、月、周、日、时、分、秒)
func ComputingTime(timeStamp int64, timeType int) (timeDataInt int64) {
var timeData string = "1"
switch timeType {
case 1:
timeData = time.Unix(timeStamp, 0).Format("2006") //年
case 2:
dayMonth := time.Unix(timeStamp, 0).Format("01") //季度
datMonthFloat, datMonthFloatErr := strconv.ParseFloat(dayMonth, 10)
if datMonthFloatErr == nil {
timeData = strconv.FormatFloat(math.Ceil(datMonthFloat/3), 'f', -1, 64)
} else {
timeData = "1"
}
case 3:
timeData = time.Unix(timeStamp, 0).Format("01") //月份
case 4: //当前日期为本月第几周
monthFirstDayStr := DateToTimeStampOld(UnixTimeToDay(timeStamp, 15) + "-01 00:00:00") //获取指定月第一天时间戳
dayTime := time.Unix(monthFirstDayStr, 0)
dayOfWeek := int(dayTime.Weekday()) //获取本月第一天是周几
if dayOfWeek == 0 {
dayOfWeek = 7
}
dayNumber, dayNumberErr := strconv.ParseInt(UnixTimeToDay(timeStamp, 18), 10, 64) //获取今天是几号
if dayNumberErr != nil {
dayNumber = 1
}
daysAndWeeksDiff := dayNumber - (8 - int64(dayOfWeek))
if daysAndWeeksDiff <= 0 {
timeData = "1"
} else {
daysAndWeeksDiffFlot, daysAndWeeksDiffFloatErr := strconv.ParseFloat(strconv.FormatInt(daysAndWeeksDiff, 10), 10)
if daysAndWeeksDiffFloatErr == nil {
daysWeeksDiffVal := math.Ceil(daysAndWeeksDiffFlot/7) + 1
timeData = strconv.FormatFloat(daysWeeksDiffVal, 'f', -1, 64)
} else {
timeData = "1"
}
}
case 5:
timeData = time.Unix(timeStamp, 0).Format("02") //天
case 7:
timeData = time.Unix(timeStamp, 0).Format("15") //时
case 8:
timeData = time.Unix(timeStamp, 0).Format("04") //分
case 9:
timeData = time.Unix(timeStamp, 0).Format("05") //秒
default:
timeData = "0"
}
timeDataInt, timeDataIntErr := strconv.ParseInt(timeData, 10, 64)
if timeDataIntErr != nil {
timeDataInt = 0
return
}
return
}

Loading…
Cancel
Save