应用集成平台服务端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

123 lines
4.2 KiB

package modelskpi
import (
"appPlatform/overall"
"strings"
"time"
)
// 岗位考核指标权重
type DepartDimePostWeight struct {
Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"`
Type int64 `json:"type" gorm:"column:type;type:bigint(20) unsigned;default:0;not null;comment:1:定性考核;2:定量考核"`
Orgid int64 `json:"orgid" gorm:"column:orgid;type:bigint(20) unsigned;default:0;not null;comment:行政组织"`
Postid int64 `json:"postid" gorm:"column:postid;type:bigint(20) unsigned;default:0;not null;comment:岗位"`
Dimension int64 `json:"dimension" gorm:"column:dimension;type:bigint(20) unsigned;default:0;not null;comment:考核维度"`
Target int64 `json:"target" gorm:"column:target;type:bigint(20) unsigned;default:0;not null;comment:指标"`
Weight float64 `json:"weight" gorm:"column:weight;type:int(6) unsigned;default:0;not null;comment:权重"`
Addtime int64 `json:"addtime" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:添加时间"`
Hierarchy int64 `json:"hierarchy" gorm:"column:hierarchy;type:bigint(20) unsigned;default:0;not null;comment:维度;2:指标"`
Quote int64 `json:"quote" gorm:"column:is_quote;type:bigint(20) unsigned;default:0;not null;comment:1:不是引用;2:引用部门"`
}
func (DepartDimePostWeight *DepartDimePostWeight) TableName() string {
return "depart_dime_post_weight"
}
// 编辑内容
func (cont *DepartDimePostWeight) EiteCont(whereMap interface{}, saveData interface{}) (err error) {
err = overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Updates(saveData).Error
return
}
// 获取内容
func (cont *DepartDimePostWeight) 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 *DepartDimePostWeight) CountCont(whereMap interface{}) (countId int64) {
overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Count(&countId)
return
}
// 读取全部信息
func (cont *DepartDimePostWeight) ContMap(whereMap interface{}, field ...string) (countAry []DepartDimePostWeight, 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 *DepartDimePostWeight) DelCont(whereMap interface{}) (err error) {
err = overall.CONSTANT_DB_KPI.Where(whereMap).Delete(&cont).Error
return
}
/**
@ 作者: 秦东
@ 时间: 2022-10-25 14:47:00
@ 功能:
@ 参数
#
@ 返回值
#
*/
// 写入岗位考核维度与指标权重
func (cont *DepartDimePostWeight) WriteTargetWeight() (err error) {
where := make(map[string]interface{})
// where := publicmethod.MapOut[string]()
where["`orgid`"] = cont.Orgid
where["`postid`"] = cont.Postid
where["`dimension`"] = cont.Dimension
where["`hierarchy`"] = cont.Hierarchy
where["`is_quote`"] = cont.Quote
if cont.Hierarchy == 1 {
var oldCont DepartDimePostWeight
err = oldCont.GetCont(where)
if err != nil {
err = overall.CONSTANT_DB_KPI.Create(&cont).Error
return
} else {
// editWhe := publicmethod.MapOut[string]()
editWhe := make(map[string]interface{})
editWhe["`id`"] = oldCont.Id
// saveAry := publicmethod.MapOut[string]()
saveAry := make(map[string]interface{})
saveAry["`weight`"] = cont.Weight
saveAry["`time`"] = time.Now().Unix()
err = oldCont.EiteCont(editWhe, saveAry)
return
}
} else {
where["`target`"] = cont.Target
var oldCont DepartDimePostWeight
err = oldCont.GetCont(where)
if err != nil {
err = overall.CONSTANT_DB_KPI.Create(&cont).Error
return
} else {
// editWhe := publicmethod.MapOut[string]()
editWhe := make(map[string]interface{})
editWhe["`id`"] = oldCont.Id
// saveAry := publicmethod.MapOut[string]()
saveAry := make(map[string]interface{})
saveAry["`weight`"] = cont.Weight
saveAry["`time`"] = time.Now().Unix()
err = oldCont.EiteCont(editWhe, saveAry)
return
}
}
return
}