14 changed files with 714 additions and 39 deletions
@ -0,0 +1,167 @@ |
|||
package postweb |
|||
|
|||
import ( |
|||
"key_performance_indicators/models/modelshr" |
|||
"key_performance_indicators/models/modelskpi" |
|||
"key_performance_indicators/overall" |
|||
"key_performance_indicators/overall/publicmethod" |
|||
"strconv" |
|||
|
|||
"github.com/gin-gonic/gin" |
|||
) |
|||
|
|||
//岗位指标相关操作
|
|||
|
|||
// 获取指定人要考核的项目列表
|
|||
func (a *ApiMethod) GetPostTarget(c *gin.Context) { |
|||
var receivedValue getPostManTargetList |
|||
err := c.ShouldBindJSON(&receivedValue) |
|||
if err != nil { |
|||
publicmethod.Result(100, err, c) |
|||
return |
|||
} |
|||
if receivedValue.Id == "" { |
|||
publicmethod.Result(101, receivedValue, c) |
|||
return |
|||
} |
|||
if receivedValue.Class == 0 { |
|||
receivedValue.Class = 1 |
|||
} |
|||
//获取被考核人基本西悉尼
|
|||
var userCont modelshr.PersonArchives |
|||
err = userCont.GetCont(map[string]interface{}{"`key`": receivedValue.Id}, "`company`", "`maindeparment`", "`admin_org`", "`position`") |
|||
if err != nil { |
|||
publicmethod.Result(107, err, c) |
|||
return |
|||
} |
|||
//获取登录人信息
|
|||
context, _ := publicmethod.LoginMyCont(c) |
|||
|
|||
var qualitSchemeList []modelskpi.QualitativeEvaluationScheme |
|||
err = overall.CONSTANT_DB_KPI.Raw("SELECT q.* FROM qualitative_evaluation_scheme q Where q.state = 1 AND `attribute` = ? AND q.target_id = some (SELECT target_id FROM target_report tr WHERE tr.type = 2 AND tr.department_id = ? AND tr.post_id = ? AND tr.man_key = ?)", receivedValue.Class, userCont.MainDeparment, userCont.Position, context.Key).Scan(&qualitSchemeList).Error |
|||
if err != nil || len(qualitSchemeList) < 1 { |
|||
publicmethod.Result(107, err, c) |
|||
return |
|||
} |
|||
var outDataAry []outPostManTargetList |
|||
for _, v := range qualitSchemeList { |
|||
// jsonStr, _ := json.Marshal(v)
|
|||
// fmt.Printf("v----------->%v\n", string(jsonStr))
|
|||
var outCont outPostManTargetList |
|||
outCont.Id = strconv.FormatInt(v.Id, 10) |
|||
outCont.Class = v.Attribute |
|||
outCont.Title = v.Title |
|||
if v.Attribute == 1 { |
|||
if v.Source == 1 { //岗位
|
|||
var postTarDeta modelskpi.PostTargetDetails |
|||
postTarDeta.GetCont(map[string]interface{}{"`id`": v.DetailsId}, "`punishmode`") |
|||
outCont.AddReduce = postTarDeta.Punishmode |
|||
} else { //部门
|
|||
var departTarDeta modelskpi.DetailedTarget |
|||
departTarDeta.GetCont(map[string]interface{}{"`dt_id`": v.DetailsId}, "`dt_add_reduce`") |
|||
outCont.AddReduce = departTarDeta.AddReduce |
|||
} |
|||
|
|||
} |
|||
outDataAry = append(outDataAry, outCont) |
|||
} |
|||
publicmethod.Result(0, outDataAry, c) |
|||
} |
|||
|
|||
// 定性指标列表
|
|||
func (a *ApiMethod) GetPostNature(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, receivedValue, c) |
|||
return |
|||
} |
|||
//获取被考核人基本信息
|
|||
var userCont modelshr.PersonArchives |
|||
err = userCont.GetCont(map[string]interface{}{"`key`": receivedValue.Id}, "`company`", "`maindeparment`", "`admin_org`", "`position`") |
|||
if err != nil { |
|||
publicmethod.Result(107, err, c) |
|||
return |
|||
} |
|||
//获取登录人信息
|
|||
context, _ := publicmethod.LoginMyCont(c) |
|||
//获取被考核人本岗位的考核项目
|
|||
var itemList []modelskpi.ShemePeople |
|||
|
|||
err = overall.CONSTANT_DB_KPI.Where("`state` = 1 AND `attribute` = 1 AND `run_state` <> 2 AND `org_id` = ? AND `post_id` = ? AND `man_key` = ?", userCont.MainDeparment, userCont.Position, context.Key).Find(&itemList).Error |
|||
if err != nil || len(itemList) < 1 { |
|||
publicmethod.Result(107, err, c) |
|||
return |
|||
} |
|||
var targetId []int64 |
|||
//获取指标内容
|
|||
var outDataAry []outPostManTargetList |
|||
for _, v := range itemList { |
|||
if publicmethod.IsInTrue[int64](v.TargetId, targetId) == false { |
|||
var outCont outPostManTargetList |
|||
outCont.Id = strconv.FormatInt(v.TargetId, 10) |
|||
outCont.Title = v.Title |
|||
outCont.Class = v.Attribute |
|||
if v.Source == 1 { //岗位
|
|||
var postTarDeta modelskpi.PostTargetDetails |
|||
postTarDeta.GetCont(map[string]interface{}{"`id`": v.DetailsId}, "`punishmode`") |
|||
outCont.AddReduce = postTarDeta.Punishmode |
|||
} else { //部门
|
|||
var departTarDeta modelskpi.DetailedTarget |
|||
departTarDeta.GetCont(map[string]interface{}{"`dt_id`": v.DetailsId}, "`dt_add_reduce`") |
|||
outCont.AddReduce = departTarDeta.AddReduce |
|||
} |
|||
|
|||
outDataAry = append(outDataAry, outCont) |
|||
} |
|||
} |
|||
publicmethod.Result(0, outDataAry, c) |
|||
} |
|||
|
|||
// 获取定量指标
|
|||
func (a *ApiMethod) GetPostRation(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, receivedValue, c) |
|||
return |
|||
} |
|||
//获取被考核人基本信息
|
|||
var userCont modelshr.PersonArchives |
|||
err = userCont.GetCont(map[string]interface{}{"`key`": receivedValue.Id}, "`company`", "`maindeparment`", "`admin_org`", "`position`") |
|||
if err != nil { |
|||
publicmethod.Result(107, err, c) |
|||
return |
|||
} |
|||
//获取登录人信息
|
|||
context, _ := publicmethod.LoginMyCont(c) |
|||
//获取被考核人本岗位的考核项目
|
|||
var itemList []modelskpi.ShemePeople |
|||
|
|||
err = overall.CONSTANT_DB_KPI.Where("`state` = 1 AND `attribute` = 2 AND `run_state` <> 2 AND `org_id` = ? AND `post_id` = ? AND `man_key` = ?", userCont.MainDeparment, userCont.Position, context.Key).Find(&itemList).Error |
|||
if err != nil || len(itemList) < 1 { |
|||
publicmethod.Result(107, err, c) |
|||
return |
|||
} |
|||
|
|||
var targetId []int64 |
|||
//获取指标内容
|
|||
var outDataAry []outPostRation |
|||
for _, v := range itemList { |
|||
if publicmethod.IsInTrue[int64](v.TargetId, targetId) == false { |
|||
var outCont outPostRation |
|||
outCont.Id = strconv.FormatInt(v.TargetId, 10) |
|||
outCont.Name = v.Title |
|||
outDataAry = append(outDataAry, outCont) |
|||
} |
|||
} |
|||
publicmethod.Result(0, outDataAry, c) |
|||
} |
|||
@ -0,0 +1,62 @@ |
|||
package modelskpi |
|||
|
|||
import ( |
|||
"key_performance_indicators/overall" |
|||
"strings" |
|||
) |
|||
|
|||
// 岗位定性指标子栏目
|
|||
type PostSonTarget 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:varchar(255) unsigned;default:'';not null;comment:标题"` |
|||
ParentId int64 `json:"parentid" gorm:"column:parent_id;type:bigint(20) unsigned;default:0;not null;comment:归属指标"` |
|||
Time int64 `json:"time" gorm:"column:time;type:bigint(20) 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:删除)"` |
|||
Depart int64 `json:"depart" gorm:"column:depart;type:bigint(20) ;default:0;comment:关联部门"` |
|||
DepartPost string `json:"departpost" gorm:"column:depart_post;type:mediumtext ;default:'';comment:关联部门岗位"` |
|||
} |
|||
|
|||
func (PostSonTarget *PostSonTarget) TableName() string { |
|||
return "post_sun_target" |
|||
} |
|||
|
|||
// 编辑内容
|
|||
func (cont *PostSonTarget) EiteCont(whereMap interface{}, saveData interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Updates(saveData).Error |
|||
return |
|||
} |
|||
|
|||
// 获取内容
|
|||
func (cont *PostSonTarget) 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 *PostSonTarget) CountCont(whereMap interface{}) (countId int64) { |
|||
overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Count(&countId) |
|||
return |
|||
} |
|||
|
|||
// 读取全部信息
|
|||
func (cont *PostSonTarget) ContMap(whereMap interface{}, field ...string) (countAry []PostSonTarget, 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 *PostSonTarget) DelCont(whereMap interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_KPI.Where(whereMap).Delete(&cont).Error |
|||
return |
|||
} |
|||
@ -0,0 +1,83 @@ |
|||
package modelskpi |
|||
|
|||
//岗位考核项目与提报人关联视图
|
|||
import ( |
|||
"key_performance_indicators/overall" |
|||
"strings" |
|||
) |
|||
|
|||
// 岗位评估方案
|
|||
type ShemePeople 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:观察)"` |
|||
|
|||
Type int `json:"type" gorm:"column:tr_type;type:tinyint(1) unsigned;default:1;not null;comment:类型(1:公司级;2:部门级)"` |
|||
ReportPerson int64 `json:"reportperson" gorm:"column:man_key;type:bigint(20) unsigned;default:0;not null;comment:上报人"` |
|||
ManDepartment int64 `json:"mandepartment" gorm:"column:man_department;type:bigint(20) unsigned;default:0;not null;comment:提报人所在部门"` |
|||
Class int `json:"class" gorm:"column:tr_class;type:tinyint(1) unsigned;default:1;not null;comment:1:定性考核;2:定量考核"` |
|||
Level int `json:"level" gorm:"column:tr_level;type:tinyint(1) unsigned;default:1;not null;comment:类型(1:指标;2:子目标;3:细则)"` |
|||
} |
|||
|
|||
func (ShemePeople *ShemePeople) TableName() string { |
|||
return "sheme_people" |
|||
} |
|||
|
|||
// 编辑内容
|
|||
func (cont *ShemePeople) EiteCont(whereMap interface{}, saveData interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Updates(saveData).Error |
|||
return |
|||
} |
|||
|
|||
// 获取内容
|
|||
func (cont *ShemePeople) 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 *ShemePeople) CountCont(whereMap interface{}) (countId int64) { |
|||
overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Count(&countId) |
|||
return |
|||
} |
|||
|
|||
// 读取全部信息
|
|||
func (cont *ShemePeople) ContMap(whereMap interface{}, field ...string) (countAry []ShemePeople, 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 *ShemePeople) DelCont(whereMap interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_KPI.Where(whereMap).Delete(&cont).Error |
|||
return |
|||
} |
|||
Loading…
Reference in new issue