Browse Source

考核目标设置

v1_dev_2
超级管理员 3 years ago
parent
commit
cf704d73b0
  1. 148
      api/base/loginVerify/login.go
  2. 19
      api/base/loginVerify/verifyCode.go
  3. 43
      api/version1/departmentseting/departmentpc/qualitativekpi.go
  4. 407
      api/version1/postseting/postpc/serpostconfig.go
  5. 59
      api/version1/postseting/postpc/type.go
  6. 88
      api/version1/postseting/postweb/posttarget.go
  7. 3
      api/version1/postseting/postweb/type.go
  8. 5
      apirouter/v1/postseting/pc.go
  9. 1
      apirouter/v1/postseting/web.go
  10. 2
      apirouter/verifyLogin/route.go
  11. 75
      models/modelskpi/quan_post_config_target.go
  12. 8
      models/modelskpi/sheme_people.go
  13. 209
      overall/publicmethod/technique.go
  14. 50
      overall/publicmethod/type.go

148
api/base/loginVerify/login.go

@ -193,3 +193,151 @@ func (a *ApiMethod) SignOut(c *gin.Context) {
redisClient.DelKey(redisMyContKey)
publicmethod.Result(0, isTrue, c, "退出成功!")
}
// 无验证码登录
func (a *ApiMethod) ScanCodeLoginNotVerify(c *gin.Context) {
var requestData Login
c.ShouldBindJSON(&requestData)
if requestData.Username == "" {
publicmethod.Result(1, requestData, c, "请输入用户名!")
return
}
if requestData.Password == "" {
publicmethod.Result(1, requestData, c, "请输入密码!")
return
}
// if requestData.Captcha == "" {
// publicmethod.Result(1, requestData, c, "请输入验证码!")
// return
// }
// if store.Verify(requestData.CaptchaId, requestData.Captcha, true) != true {
// publicmethod.Result(1, requestData, c, "验证码不正确!")
// return
// }
userAgent := c.Request.Header.Get("User-Agent") // 获取用户代理
// userAgent = "250"
var md5JiaMiPwd publicmethod.Md5Encryption
md5JiaMiPwd.Md5EncryptionInit(requestData.Password)
md5TokenPwd := md5JiaMiPwd.Md5EncryptionAlgorithm()
// var oldAdmin OldSchollAdmin
// oldErr := overall.CONSTANT_DB_Master.Model(&models.SystemUser{}).Select("system_user.*,system_user_attribute.*").Joins("left join system_user_attribute on system_user.u_key = system_user_attribute.ua_id").Where("`u_name` = ? AND `u_password` = ?", requestData.Username, md5TokenPwd).First(&oldAdmin).Error
// if oldErr == nil {
// //原知行学院管理员账号登录
// }
//新的登录认证方式
var userCont modelshr.ManCont
userErr := userCont.GetCont(map[string]interface{}{"number": requestData.Username, "password": md5TokenPwd})
if userErr != nil {
publicmethod.Result(2000, userErr, c)
return
}
if requestData.OpenId != "" {
var userInfo modelshr.PersonArchives
userInfo.EiteCont(map[string]interface{}{"id": userCont.Id}, map[string]interface{}{"work_wechat": requestData.OpenId})
}
if userCont.State == 2 {
publicmethod.Result(1, userErr, c, "登陆失败! 该账号已经被禁用!")
return
}
if userCont.State == 3 {
publicmethod.Result(1, userErr, c, "登陆失败! 该账号不存在!")
return
}
uuIdVal := publicmethod.GetUUid(3)
uuIdValStr := strconv.FormatInt(uuIdVal, 10)
var md5JiaMi publicmethod.Md5Encryption
md5JiaMi.Md5EncryptionInit(userAgent)
md5Token := md5JiaMi.Md5EncryptionAlgorithm()
var md5JiaMiNumber publicmethod.Md5Encryption
md5JiaMiNumber.Md5EncryptionInit(userCont.Number + uuIdValStr)
userKeyCode := md5JiaMiNumber.Md5EncryptionAlgorithm()
sha1Str := userKeyCode + userCont.Number + userCont.Password + md5Token + uuIdValStr
sha1Token := publicmethod.Sha1Encryption(sha1Str)
//返回值
saveData := publicmethod.MapOut[string]()
saveData["key"] = userKeyCode
saveData["token"] = sha1Token
saveData["userinfo"] = userCont
menuoper, jurisdiction := getRoleSeat(userCont.Role)
writeRedisData := map[string]interface{}{
"userkey": userKeyCode,
"key": userCont.Key,
"usernumber": userCont.Number,
"userpwd": userCont.Password,
"usertoken": sha1Token,
"jurisdiction": jurisdiction,
"menuOper": menuoper,
"wand": 118,
}
//API Token数据
redisFileKey := fmt.Sprintf("ScanCode:Authentication:LoginApi_%v_%v", overall.CONSTANT_CONFIG.RedisPrefixStr.Alias, userKeyCode)
redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS5)
redisClient.SetRedisTime(10800)
redisClient.HashMsetAdd(redisFileKey, writeRedisData)
//缓存写入个人信息
redisMyContKey := fmt.Sprintf("ScanCode:Authentication:UserCont_%v_%v", overall.CONSTANT_CONFIG.RedisPrefixStr.Alias, userCont.Number)
myCont := publicmethod.MapOut[string]()
myCont["id"] = userCont.Id
myCont["number"] = userCont.Number //员工工号
myCont["name"] = userCont.Name //姓名
myCont["icon"] = userCont.Icon //头像
myCont["hireclass"] = userCont.HireClass //雇佣类型(1:雇佣入职;2:再入职;)
myCont["emptype"] = userCont.EmpType //用工关系(1:临时工 , 2:编外人员 ;3:实习&实习生;4:试用员工;5:待分配;6:待岗;7:临时调入;8:正式员工;9:长期病假;10:停薪留职;11:退休;12:辞职;13:辞退;14:离职)
myCont["company"] = userCont.Company //入职公司
myCont["maindeparment"] = userCont.MainDeparment //主部门
myCont["sunmaindeparment"] = userCont.SunMainDeparment //二级主部门
myCont["deparment"] = userCont.Deparment //部门
myCont["adminorg"] = userCont.AdminOrg //所属行政组织
myCont["teamid"] = userCont.TeamId //班组
myCont["position"] = userCont.Position //职位
myCont["jobclass"] = userCont.JobClass //职务分类
myCont["jobid"] = userCont.JobId //职务
myCont["jobleve"] = userCont.JobLeve //职务等级
myCont["wechat"] = userCont.Wechat //微信UserId
myCont["workwechat"] = userCont.WorkWechat //企业微信UserId
myCont["state"] = userCont.State //状态(1:启用;2:禁用;3:删除)
myCont["key"] = userCont.Key //key
myCont["isadmin"] = userCont.IsAdmin //是否为管理员(1:不是;2:分公司;3:集团管理员;4:超级管
myCont["password"] = userCont.Password //密码
myCont["role"] = userCont.Role //角色
myCont["idcardno"] = userCont.Idcardno //身份证号
myCont["passportno"] = userCont.Passportno //护照号码
myCont["globalroaming"] = userCont.Globalroaming //国际区号
myCont["mobilephone"] = userCont.Mobilephone //手机号码
myCont["email"] = userCont.Email //电子邮件
myCont["gender"] = userCont.Gender //性别(1:男性;2:女性;3:中性)
myCont["birthday"] = userCont.Birthday //birthday
myCont["myfolk"] = userCont.Myfolk //民族
myCont["nativeplace"] = userCont.Nativeplace //籍贯
myCont["idcardstartdate"] = userCont.Idcardstartdate //身份证有效期开始
myCont["idcardenddate"] = userCont.Idcardenddate //身份证有效期结束
myCont["idcardaddress"] = userCont.Idcardaddress //身份证地址
myCont["idcardIssued"] = userCont.IdcardIssued //身份证签发机关
myCont["health"] = userCont.Health //健康状况(1:良好;2:一般;3:较弱,4:有生理缺陷;5:残废)
myCont["maritalstatus"] = userCont.Maritalstatus //婚姻状况(1:未婚;2:已婚;3:丧偶;4:离异)
myCont["internaltelephone"] = userCont.Internaltelephone //内线电话
myCont["currentresidence"] = userCont.Currentresidence //现居住地址
myCont["constellationing"] = userCont.Constellation //星座(1:白羊座;2:金牛座;3:双子座;4:巨蟹座;5:狮子座;6:处女座;7:天枰座;8:天蝎座;9:射手座;10:摩羯座;11:水瓶座;12:双鱼座)
myCont["isdoubleworker"] = userCont.Isdoubleworker //是否双职工(1:是;2:否)
myCont["isveterans"] = userCont.Isveterans //是否为退役军人(1:是;2:否)
myCont["veteransnumber"] = userCont.Veteransnumber //退役证编号
myCont["jobstartdate"] = userCont.Jobstartdate //参加工作日期
myCont["entrydate"] = userCont.Entrydate //入职日期
myCont["probationperiod"] = userCont.Probationperiod //试用期
myCont["planformaldate"] = userCont.Planformaldate //预计转正日期
myCont["political_outlook"] = userCont.PoliticalOutlook //政治面貌(1:群众;2:无党派;3:台盟会员;4:九三社员;5:致公党员;6:农工党员;7:民进会员;8:民建会员;9:民盟盟员;10:民革会员,11:共青团员;12:预备党员;13:中共党员)
redisClient.HashMsetAdd(redisMyContKey, myCont)
// fmt.Printf("redisMyContKey------Login----->%v\n", redisMyContKey)
publicmethod.Result(0, saveData, c)
}

19
api/base/loginVerify/verifyCode.go

@ -1,6 +1,8 @@
package loginVerify
import (
"fmt"
"key_performance_indicators/middleware/grocerystore"
"key_performance_indicators/overall"
"key_performance_indicators/overall/publicmethod"
@ -25,3 +27,20 @@ func (a *ApiMethod) Captcha(c *gin.Context) {
}, c)
}
}
// 验证授权是否还有效
func (a *ApiMethod) VerifyEmpower(c *gin.Context) {
userKey := c.Request.Header.Get("user-key")
if userKey == "" {
publicmethod.Result(9001, userKey, c, "未获得授权信息!")
return
}
redisFileKey := fmt.Sprintf("ScanCode:Authentication:LoginApi_%v_%v", overall.CONSTANT_CONFIG.RedisPrefixStr.Alias, userKey)
redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS5)
userRedisToken, isTrue := redisClient.HashGetAll(redisFileKey)
if isTrue == false {
publicmethod.Result(9002, userKey, c, "授权超时!")
return
}
publicmethod.Result(0, userRedisToken, c)
}

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

@ -110,13 +110,15 @@ func (a *ApiMethod) Shiyan(c *gin.Context) {
// // fmt.Printf("gormDb----->%v----->%v\n", gormDb, evalCont)
// err := overall.CONSTANT_DB_KPI.Raw("SELECT e.*,(SELECT id FROM target_department td WHERE td.department_id = ? AND td.post_id = ? AND td.target_id = e.et_id) as tdm FROM evaluationtarget e HAVING tdm IS NOT NULL", receivedValue.DepartmentId, receivedValue.DimensionId).Scan(&evalCont).Error
// fmt.Printf("gormDb----->%v----->%v\n", err, evalCont)
//校正部门级考核
var dimeTargetList []modelskpi.DetailedTarget
err := overall.CONSTANT_DB_KPI.Where("dt_state = 1").Find(&dimeTargetList).Error
if err != nil || len(dimeTargetList) < 1 {
publicmethod.Result(107, err, c)
return
}
// //校正部门级考核
// var dimeTargetList []modelskpi.DetailedTarget
// err := overall.CONSTANT_DB_KPI.Where("dt_state = 1").Find(&dimeTargetList).Error
// if err != nil || len(dimeTargetList) < 1 {
// publicmethod.Result(107, err, c)
// return
// }
// fmt.Printf("总数---->%v\n", len(dimeTargetList))
// var xieChengChuli []modelskpi.DetailedTarget
// for i, v := range dimeTargetList {
@ -129,14 +131,33 @@ func (a *ApiMethod) Shiyan(c *gin.Context) {
// }
// }
for _, v := range dimeTargetList {
xiaoZhengBuMen(v)
}
// for _, v := range dimeTargetList {
// xiaoZhengBuMen(v)
// }
fmt.Printf("jieshu---->%v\n", len(dimeTargetList))
// fmt.Printf("jieshu---->%v\n", len(dimeTargetList))
//校正维度
// xiaoZehgnWeiDu()
var receivedValue publicmethod.PublicId
c.ShouldBindJSON(&receivedValue)
//获取被考核人基本信息
var userCont modelshr.PersonArchives
err := userCont.GetCont(map[string]interface{}{"`number`": receivedValue.Id}, "`key`", "`company`", "`maindeparment`", "`admin_org`", "`position`")
// err := userCont.GetCont(map[string]interface{}{"`number`": 300595}, "`company`", "`maindeparment`", "`admin_org`", "`position`")
if err != nil {
publicmethod.Result(107, err, c)
return
}
// publicmethod.GetDepartmentLeader(userCont)
var kjskd []publicmethod.PositionDigui
kjskd = publicmethod.GetPositionList(userCont.Key, userCont.AdminOrg, userCont.Position, 1, kjskd)
jsonStr, _ := json.Marshal(kjskd)
fmt.Printf("kjskd---------------->%v\n", string(jsonStr))
// var ksd []int64
// ksd = publicmethod.GetDepartmentSun(userCont.Company, ksd)
// fmt.Printf("ksd----------->%v\n", ksd)
publicmethod.Result(0, kjskd, c)
}
// 校正关联维度

407
api/version1/postseting/postpc/serpostconfig.go

@ -0,0 +1,407 @@
package postpc
import (
"key_performance_indicators/models/modelshr"
"key_performance_indicators/models/modelskpi"
"key_performance_indicators/overall"
"key_performance_indicators/overall/publicmethod"
"strconv"
"time"
"github.com/gin-gonic/gin"
)
// 提交岗位定量目标设定
func (a *ApiMethod) SetEvaluationObjectives(c *gin.Context) {
var requestData SetEvaluationObjectives
err := c.ShouldBindJSON(&requestData)
if err != nil {
publicmethod.Result(1, err, c, "数据获取失败!")
return
}
if requestData.Year == 0 {
publicmethod.Result(1, err, c, "请填写年度")
return
}
if requestData.Group == "" {
publicmethod.Result(1, err, c, "请选择归属集团")
return
}
if requestData.DepartMent == "" {
publicmethod.Result(1, err, c, "请选择归属行政组织")
return
}
if requestData.PostId == "" {
publicmethod.Result(1, err, c, "请选择归属岗位")
return
}
if requestData.Dimension == "" {
publicmethod.Result(1, err, c, "请选择归属维度")
return
}
if requestData.Target == "" {
publicmethod.Result(1, err, c, "请选择归属指标")
return
}
switch requestData.Cycle {
case 1:
if len(requestData.CycleAdded) != 1 {
publicmethod.Result(1, err, c, "年度只可填写一条!")
return
}
case 2:
if len(requestData.CycleAdded) > 4 {
publicmethod.Result(1, err, c, "季度最多只可填写四条!")
return
}
if len(requestData.CycleAdded) < 1 {
publicmethod.Result(1, err, c, "季度至少填写一条!")
return
}
case 3:
if len(requestData.CycleAdded) > 12 {
publicmethod.Result(1, err, c, "月度最多只可填写十二条!")
return
}
if len(requestData.CycleAdded) < 1 {
publicmethod.Result(1, err, c, "月度至少填写一条!")
return
}
default:
publicmethod.Result(1, err, c, "请选择周期")
return
}
var timecopy []int64
gromDb := overall.CONSTANT_DB_KPI.Model(&modelskpi.QuanPostConfig{}).Select("Timecopy").Where("`group` = ? AND `org_id` = ? AND `post_id` = ? AND `dimension` = ? AND `target` = ? AND `year` = ? ", requestData.Group, requestData.DepartMent, requestData.PostId, requestData.Dimension, requestData.Target, requestData.Year)
judgeErr := gromDb.Find(&timecopy).Error
if judgeErr == nil {
if len(timecopy) > 0 {
publicmethod.Result(1, judgeErr, c, "已经存在!不要重复添加!")
return
}
}
var saveData []modelskpi.QuanPostConfig
var eiteAddData []int64
for _, v := range requestData.CycleAdded {
if judgeErr != nil {
var saveDataCont modelskpi.QuanPostConfig
orgId, _ := strconv.ParseInt(requestData.DepartMent, 10, 64)
_, saveDataCont.CompanyId, saveDataCont.DepartmentId, _, _ = publicmethod.GetOrgStructure(orgId) //公司部门
saveDataCont.OrgId = orgId //行政组织
postIdInt, _ := strconv.ParseInt(requestData.PostId, 10, 64)
saveDataCont.PostId = postIdInt //岗位
dimensionId, _ := strconv.ParseInt(requestData.Dimension, 10, 64)
saveDataCont.Dimension = dimensionId //维度
targetId, _ := strconv.ParseInt(requestData.Target, 10, 64)
saveDataCont.Target = targetId //指标
saveDataCont.Type = int64(requestData.Cycle)
saveDataCont.Year = requestData.Year
saveDataCont.Timecopy = v.Id
if v.Zeroprize < 0 {
saveDataCont.Zeroprize = 0
} else {
saveDataCont.Zeroprize = v.Zeroprize * 100
}
if v.Allprize < 0 {
saveDataCont.Allprize = 0
} else {
saveDataCont.Allprize = v.Allprize * 100
}
if v.Capping > 0 {
saveDataCont.Capping = 1
saveDataCont.CappingVal = v.Capping * 100
} else {
saveDataCont.Capping = 2
saveDataCont.CappingVal = 0
}
saveDataCont.Time = time.Now().Unix()
saveDataCont.State = 1
saveData = append(saveData, saveDataCont)
} else {
if len(timecopy) <= 0 {
var saveDataCont modelskpi.QuanPostConfig
orgId, _ := strconv.ParseInt(requestData.DepartMent, 10, 64)
_, saveDataCont.CompanyId, saveDataCont.DepartmentId, _, _ = publicmethod.GetOrgStructure(orgId) //公司部门
saveDataCont.OrgId = orgId //行政组织
postIdInt, _ := strconv.ParseInt(requestData.PostId, 10, 64)
saveDataCont.PostId = postIdInt //岗位
dimensionId, _ := strconv.ParseInt(requestData.Dimension, 10, 64)
saveDataCont.Dimension = dimensionId //维度
targetId, _ := strconv.ParseInt(requestData.Target, 10, 64)
saveDataCont.Target = targetId //指标
saveDataCont.Type = int64(requestData.Cycle)
saveDataCont.Year = requestData.Year
saveDataCont.Timecopy = v.Id
if v.Zeroprize < 0 {
saveDataCont.Zeroprize = 0
} else {
saveDataCont.Zeroprize = v.Zeroprize * 100
}
if v.Allprize < 0 {
saveDataCont.Allprize = 0
} else {
saveDataCont.Allprize = v.Allprize * 100
}
if v.Capping > 0 {
saveDataCont.Capping = 1
saveDataCont.CappingVal = v.Capping * 100
} else {
saveDataCont.Capping = 2
saveDataCont.CappingVal = 0
}
saveDataCont.Time = time.Now().Unix()
saveDataCont.State = 1
saveData = append(saveData, saveDataCont)
} else {
for _, s_v := range timecopy {
if s_v != v.Id {
var saveDataCont modelskpi.QuanPostConfig
orgId, _ := strconv.ParseInt(requestData.DepartMent, 10, 64)
_, saveDataCont.CompanyId, saveDataCont.DepartmentId, _, _ = publicmethod.GetOrgStructure(orgId) //公司部门
saveDataCont.OrgId = orgId //行政组织
postIdInt, _ := strconv.ParseInt(requestData.PostId, 10, 64)
saveDataCont.PostId = postIdInt //岗位
dimensionId, _ := strconv.ParseInt(requestData.Dimension, 10, 64)
saveDataCont.Dimension = dimensionId //维度
targetId, _ := strconv.ParseInt(requestData.Target, 10, 64)
saveDataCont.Target = targetId //指标
saveDataCont.Type = int64(requestData.Cycle)
saveDataCont.Year = requestData.Year
saveDataCont.Timecopy = v.Id
if v.Zeroprize < 0 {
saveDataCont.Zeroprize = 0
} else {
saveDataCont.Zeroprize = v.Zeroprize * 100
}
if v.Allprize < 0 {
saveDataCont.Allprize = 0
} else {
saveDataCont.Allprize = v.Allprize * 100
}
if v.Capping > 0 {
saveDataCont.Capping = 1
saveDataCont.CappingVal = v.Capping * 100
} else {
saveDataCont.Capping = 2
saveDataCont.CappingVal = 0
}
saveDataCont.Time = time.Now().Unix()
saveDataCont.State = 1
saveData = append(saveData, saveDataCont)
} else {
eiteDataMap := publicmethod.MapOut[string]()
eiteDataMap["type"] = requestData.Cycle
eiteDataMap["timecopy"] = v.Id
if v.Zeroprize < 0 {
eiteDataMap["zeroprize"] = 0
} else {
eiteDataMap["zeroprize"] = v.Zeroprize * 100
}
if v.Allprize < 0 {
eiteDataMap["allprize"] = 0
} else {
eiteDataMap["allprize"] = v.Allprize * 100
}
if v.Capping > 0 {
eiteDataMap["capping"] = 1
eiteDataMap["capping_val"] = v.Capping * 100
} else {
eiteDataMap["capping"] = 2
eiteDataMap["capping_val"] = 0
}
eiteDataMap["time"] = time.Now().Unix()
gromDb := overall.CONSTANT_DB_KPI.Model(&modelskpi.QuanPostConfig{}).Select("Timecopy").Where("`company_id` = ? AND `org_id` = ? AND `post_id` = ? AND `dimension` = ? AND `target` = ? AND `year` = ? AND `type` = ?", requestData.Group, requestData.DepartMent, requestData.PostId, requestData.Dimension, requestData.Target, requestData.Year, requestData.Cycle)
gromDb.Updates(eiteDataMap)
eiteAddData = append(eiteAddData, 1)
}
}
}
}
}
if len(saveData) <= 0 && len(eiteAddData) <= 0 {
publicmethod.Result(1, err, c, "没有要添加的数据!")
return
}
if len(saveData) > 0 {
saveErr := overall.CONSTANT_DB_KPI.Create(&saveData).Error
if saveErr != nil {
publicmethod.Result(1, err, c, "数据添加失败!")
return
}
}
publicmethod.Result(0, err, c)
}
// 岗位定量考核目标列表
func (a *ApiMethod) PostConfigList(c *gin.Context) {
var requestData SelectQuantitativeConfig
c.ShouldBindJSON(&requestData)
// if err != nil {
// publicmethod.Result(1, err, c, "数据获取失败!")
// return
// }
// var qualConfigList []assessmentmodel.QuantitativeConfig
var qualConfigList []modelskpi.QuanPostConfigTarget
gormDb := overall.CONSTANT_DB_KPI
if requestData.GroupId != "" {
gormDb = gormDb.Where("`company_id` = ?", requestData.GroupId)
}
if requestData.DepartmentID != "" {
gormDb = gormDb.Where("`org_id` = ?", requestData.DepartmentID)
}
if requestData.PostId != "" {
gormDb = gormDb.Where("`post_id` = ?", requestData.PostId)
}
if requestData.Dimension != "" {
gormDb = gormDb.Where("`dimension` = ?", requestData.Dimension)
}
if requestData.Target != "" {
gormDb = gormDb.Where("`target` = ?", requestData.Target)
}
switch requestData.Type {
case 1:
gormDb = gormDb.Where("`type` = ?", requestData.Type)
case 2:
gormDb = gormDb.Where("`type` = ?", requestData.Type)
if requestData.Class != 0 {
gormDb = gormDb.Where("`timecopy` = ?", requestData.Class)
}
case 3:
gormDb = gormDb.Where("`type` = ?", requestData.Type)
if requestData.Class != 0 {
gormDb = gormDb.Where("`timecopy` = ?", requestData.Class)
}
default:
}
if requestData.Year != 0 {
gormDb = gormDb.Where("`year` = ?", requestData.Year)
}
if requestData.State != 0 {
gormDb = gormDb.Where("`state` = ?", requestData.State)
}
if requestData.Title != "" {
gormDb = gormDb.Where("`title` LIKE ?", "%"+requestData.Title+"%")
}
// gormDb = gormDb.Order("group ASC,departmentid ASC,dimension ASC,target ASC,targetconfig ASC").Order("year DESC").Order("timecopy ASC,id ASC")
gormDb = gormDb.Order("`company_id` ASC").Order("`department_id` ASC").Order("`org_id` ASC").Order("`post_id` ASC").Order("`dimension` ASC").Order("`target` ASC").Order("`year` DESC").Order("`timecopy` ASC").Order("`id` ASC")
contErr := gormDb.Find(&qualConfigList).Error
if contErr != nil {
publicmethod.Result(1, contErr, c, "没有数据!")
return
}
var outList []OutQuantitativeConfig
for _, v := range qualConfigList {
var outCont OutQuantitativeConfig
outCont.Id = v.Id
outCont.Title = v.Title
outCont.CompanyId = v.CompanyId
outCont.DepartmentId = v.DepartmentId
outCont.OrgId = v.OrgId
outCont.PostId = v.PostId
outCont.Dimension = v.Dimension
outCont.Target = v.Target
outCont.Type = v.Type
outCont.Year = v.Year
outCont.Timecopy = v.Timecopy
outCont.Zeroprize = v.Zeroprize / 100
outCont.Allprize = v.Allprize / 100
outCont.Capping = v.Capping
outCont.CappingVal = v.CappingVal / 100
outCont.Time = v.Time
outCont.State = v.State
outCont.DimensionId = strconv.FormatInt(v.Dimension, 10)
var companyCont modelshr.AdministrativeOrganization
companyCont.GetCont(map[string]interface{}{"`id`": v.CompanyId}, "id", "name")
outCont.GroupTitle = companyCont.Name
var departmenCont modelshr.AdministrativeOrganization
departmenCont.GetCont(map[string]interface{}{"`id`": v.DepartmentId}, "id", "name")
outCont.DepartmentTitle = departmenCont.Name
var postCont modelshr.Position
postCont.GetCont(map[string]interface{}{"`id`": v.PostId}, "id", "name")
outCont.PostTitle = postCont.Name
var dimensionCont modelskpi.DutyClass
dimensionCont.GetCont(map[string]interface{}{"`id`": v.Dimension}, "id", "title")
outCont.DimensionTitle = dimensionCont.Title
outCont.TargetTitle = v.Title
// dErr, departmentInfo := commonus.GetBranchFactory(v.DepartmentId)
// if dErr == true {
// outCont.DimensionTitle = departmentInfo.Name
// }
// targetInfo, tErr := commonus.GetTargetInfo(v.Target)
// if tErr == true {
// outCont.TargetTitle = targetInfo.Title
// }
outList = append(outList, outCont)
}
publicmethod.Result(0, outList, c)
}
// 修改考核目标设置
func (a *ApiMethod) EiteQuantitativeConfig(c *gin.Context) {
var requestData []EiteQuantConfig
err := c.ShouldBindJSON(&requestData)
if err != nil {
publicmethod.Result(1, err, c, "数据获取失败!")
return
}
if len(requestData) < 1 {
publicmethod.Result(1, err, c, "数据获取失败!")
return
}
for _, v := range requestData {
eiteCont := publicmethod.MapOut[string]()
eiteCont["allprize"] = v.Allprize * 100
eiteCont["zeroprize"] = v.Zeroprize * 100
eiteCont["capping_val"] = v.Capping * 100
err = overall.CONSTANT_DB_KPI.Model(&modelskpi.QuanPostConfig{}).Where("`id` = ?", v.Id).Updates(eiteCont).Error
}
if err != nil {
publicmethod.Result(104, err, c)
} else {
publicmethod.Result(0, err, c)
}
}
// 删除考核目标设置
func (a *ApiMethod) DelQuantitativeConfig(c *gin.Context) {
var requestData []string
err := c.ShouldBindJSON(&requestData)
if err != nil {
publicmethod.Result(1, err, c, "数据获取失败!")
return
}
if len(requestData) < 1 {
publicmethod.Result(1, err, c, "数据获取失败!")
return
}
err = overall.CONSTANT_DB_KPI.Where("`id` IN ?", requestData).Delete(&modelskpi.QuanPostConfig{}).Error
if err != nil {
publicmethod.Result(108, err, c)
} else {
publicmethod.Result(0, err, c)
}
}

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

@ -281,3 +281,62 @@ type sonTargetAddDieastion struct {
publicmethod.PublicId
postContList
}
// 设定指标结算周期
type SetEvaluationObjectives struct {
Year int64 `json:"year"` //年度
Group string `json:"group"` //集团
DepartMent string `json:"department"` //部门
PostId string `postid`
Dimension string `json:"dimension"` //维度
Target string `json:"target"` //指标
Cycle int `json:"cycle"` //周期
CycleAdded []CycleAddedType `json:"cycleadded"`
}
// 周期列表
type CycleAddedType struct {
Id int64 `json:"id"`
Zeroprize float64 `json:"zeroprize"` //零奖值"`
Allprize float64 `json:"allprize"` //全奖值"`
Capping float64 `json:"capping"` //封顶值"`
}
// 定量考核目标设定查询
type SelectQuantitativeConfig struct {
Title string `json:"title"` //指标标题
GroupId string `json:"groupid"`
DepartmentID string `json:"departmentid"`
PostId string `postid`
Dimension string `json:"dimension"` //维度
Target string `json:"target"` //指标
Type int `json:"type"` //1、年度;2、季度;3、月度
Year int `json:"year"` //年度
Class int `json:"class"` //季度与月度辅助值
State int `json:"state"` //状态(1、启用;2、禁用;3、删除)
}
// 输出
type OutQuantitativeConfig struct {
modelskpi.QuanPostConfigTarget
GroupTitle string `json:"grouptitle"` //公司
DepartmentTitle string `json:"departmenttitle"` //部门
PostTitle string `json:"posttitle"` //岗位
DimensionTitle string `json:"dimensiontitle"` //维度
DimensionId string `json:"dimensionid"` //维度
TargetTitle string `json:"targettitle"` //指标
DetailedTargetTitle string `json:"detailedtargenttitle"` //指标明细
}
// 修改考核目标设定
type EiteQuantConfig struct {
Id string `json:"id"`
Zeroprize float64 `json:"zeroprize"` //零奖值"`
Allprize float64 `json:"allprize"` //全奖值"`
Capping float64 `json:"capping"` //封顶值"`
}
// 删除考核目标设定
type DelQuantConfig struct {
Id string `json:"id"`
}

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

@ -114,8 +114,8 @@ func (a *ApiMethod) GetPostNature(c *gin.Context) {
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
postTarDeta.GetCont(map[string]interface{}{"`id`": v.DetailsId}, "`add_reduce`")
outCont.AddReduce = postTarDeta.AddReduce
} else { //部门
var departTarDeta modelskpi.DetailedTarget
departTarDeta.GetCont(map[string]interface{}{"`dt_id`": v.DetailsId}, "`dt_add_reduce`")
@ -195,7 +195,8 @@ func (a *ApiMethod) GetPostRation(c *gin.Context) {
if publicmethod.IsInTrue[int64](v.TargetId, targetId) == false {
var outCont outPostRation
outCont.Id = strconv.FormatInt(v.TargetId, 10)
outCont.Name = v.Title
outCont.ShemeId = strconv.FormatInt(v.Id, 10)
outCont.Title = v.Title
outCont.UserKey = receivedValue.Id
outCont.DimensionId = strconv.FormatInt(v.DimensionId, 10)
outDataAry = append(outDataAry, outCont)
@ -224,6 +225,9 @@ func (a *ApiMethod) GetPostDeimensoInfo(c *gin.Context) {
publicmethod.Result(101, receivedValue, c)
return
}
if receivedValue.PageSize < 1 {
receivedValue.PageSize = 20
}
//获取被考核人基本信息
var userCont modelshr.PersonArchives
err = userCont.GetCont(map[string]interface{}{"`key`": receivedValue.UserKey}, "`company`", "`maindeparment`", "`admin_org`", "`position`")
@ -236,18 +240,61 @@ func (a *ApiMethod) GetPostDeimensoInfo(c *gin.Context) {
//获取被考核人本岗位的考核项目
var itemList []modelskpi.ShemePeople
gormDb := overall.CONSTANT_DB_KPI.Where("`state` = 1 AND `tr_type` = 2 AND `attribute` = 1 AND `run_state` <> 2 AND `dimension_id` = ? AND `target_id` = ? AND `org_id` = ? AND `post_id` = ? AND `man_key` = ?", receivedValue.DimensionId, receivedValue.TargetId, userCont.AdminOrg, userCont.Position, context.Key)
//SELECT * FROM `sheme_people` WHERE `state` = 1 AND `tr_type` = 2 AND `attribute` = 1 AND `run_state` <> 2 AND `dimension_id` = '16468024054665111' AND `target_id` = '3' AND `org_id` = 272 AND `post_id` = 794 AND `man_key` = 15993815826844528 AND `son_target_id` = '2' ORDER BY `son_target_id` DESC LIMIT 20 OFFSET 20
sqlStrList := "SELECT * FROM `sheme_people`"
sqlListCount := "SELECT count(*) FROM `sheme_people`"
sqlStr := "WHERE `state` = 1 AND `tr_type` = 2 AND `attribute` = 1 AND `run_state` <> 2"
if receivedValue.DimensionId != "" {
sqlStr = fmt.Sprintf("%v AND `dimension_id` = %v", sqlStr, receivedValue.DimensionId)
}
if receivedValue.TargetId != "" {
sqlStr = fmt.Sprintf("%v AND `target_id` = %v", sqlStr, receivedValue.TargetId)
}
if receivedValue.Sontargetid != "" {
gormDb = gormDb.Where("`son_target_id` = ?", receivedValue.Sontargetid)
sqlStr = fmt.Sprintf("%v AND `son_target_id` = %v", sqlStr, receivedValue.Sontargetid)
}
gormDb = publicmethod.PageTurningSettings(gormDb, receivedValue.Page, receivedValue.PageSize)
errGorm := gormDb.Order("`son_target_id` DESC").Find(&itemList).Error
var total int64
totalErr := gormDb.Count(&total).Error
if totalErr != nil {
total = 0
if userCont.AdminOrg != 0 {
sqlStr = fmt.Sprintf("%v AND `org_id` = %v", sqlStr, userCont.AdminOrg)
}
if userCont.Position != 0 {
sqlStr = fmt.Sprintf("%v AND `post_id` = %v", sqlStr, userCont.Position)
}
if errGorm != nil || len(itemList) < 1 {
if context.Key != 0 {
sqlStr = fmt.Sprintf("%v AND `man_key` = %v", sqlStr, context.Key)
}
sqlStr = fmt.Sprintf("%v ORDER BY `son_target_id` DESC", sqlStr)
if receivedValue.Page <= 1 {
sqlStr = fmt.Sprintf("%v LIMIT %v", sqlStr, receivedValue.PageSize)
} else {
sqlStr = fmt.Sprintf("%v LIMIT %v OFFSET %v", sqlStr, receivedValue.PageSize, publicmethod.LimitPage(receivedValue.Page, receivedValue.PageSize))
}
var total int64
selectSqlStr := fmt.Sprintf("%v %v", sqlStrList, sqlStr)
selectSqlStrCount := fmt.Sprintf("%v %v", sqlListCount, sqlStr)
//原生查询
errGormEaw := overall.CONSTANT_DB_KPI.Raw(selectSqlStr).Scan(&itemList).Error
overall.CONSTANT_DB_KPI.Raw(selectSqlStrCount).Scan(&total)
// fmt.Printf("errGormEaw------------------->%v----------->%v----------->%v\n", itemList, errGormEaw, total)
// gormDb := overall.CONSTANT_DB_KPI.Model(&modelskpi.ShemePeople{})
// // gormDb = gormDb.Where("`state` = 1 AND `tr_type` = 2 AND `attribute` = 1")
// // gormDb = gormDb.Where("`dimension_id` = ? AND `target_id` = ? ", receivedValue.DimensionId, receivedValue.TargetId)
// // gormDb = gormDb.Where("`org_id` = ? AND `post_id` = ? AND `man_key` = ?", userCont.AdminOrg, userCont.Position, context.Key)
// gormDb = gormDb.Where("`state` = 1 AND `tr_type` = 2 AND `attribute` = 1 AND `run_state` <> 2 AND `dimension_id` = ? AND `target_id` = ? AND `org_id` = ? AND `post_id` = ? AND `man_key` = ?", receivedValue.DimensionId, receivedValue.TargetId, userCont.AdminOrg, userCont.Position, context.Key)
// if receivedValue.Sontargetid != "" {
// gormDb = gormDb.Where("`son_target_id` = ?", receivedValue.Sontargetid)
// }
// gormDb = publicmethod.PageTurningSettings(gormDb, receivedValue.Page, receivedValue.PageSize)
// errGorm := gormDb.Order("`son_target_id` DESC").Find(&itemList).Error
// totalErr := gormDb.Count(&total).Error
// if totalErr != nil {
// total = 0
// }
// fmt.Printf("outList------------------->%v----------->%v\n", itemList, total)
if errGormEaw != nil || total < 1 {
publicmethod.Result(107, err, c)
return
}
@ -266,8 +313,8 @@ func (a *ApiMethod) GetPostDeimensoInfo(c *gin.Context) {
outCont.SonTargetId = v.SonTargetId //子栏目"`
outCont.DetailsId = v.DetailsId //细则"`
outCont.Attribute = v.Attribute // 属性 1:定性考核;2:定量考核"`
outCont.MinScore = v.MinScore // 最小分*100保存"`
outCont.MaxScore = v.MaxScore //最大分*100保存"`
outCont.MinScore = publicmethod.DecimalEs(v.MinScore/100, 2) // 最小分*100保存"`
outCont.MaxScore = publicmethod.DecimalEs(v.MaxScore/100, 2) //最大分*100保存"`
outCont.ScoringMethod = v.ScoringMethod //计分方式(1:自动;2:手动)"`
outCont.State = v.State //状态(1:启用;2:禁用;3:删除)"`
outCont.Addtime = v.Addtime //添加时间"`
@ -282,8 +329,8 @@ func (a *ApiMethod) GetPostDeimensoInfo(c *gin.Context) {
outCont.Class = v.Class //1:定性考核;2:定量考核"`
outCont.Level = v.Level //类型(1:指标;2:子目标;3:细则)"`
outCont.Punishmode = v.Punishmode //处罚方式 1:扣分;2:现金处罚;3:扣分加现金
outCont.Maxmoney = v.Maxmoney //最高罚款
outCont.Minmoney = v.Minmoney //最低罚款
outCont.Maxmoney = publicmethod.DecimalEs(v.Maxmoney/100, 2) //最高罚款
outCont.Minmoney = publicmethod.DecimalEs(v.Minmoney/100, 2) //最低罚款
if v.CensorType != "" {
outCont.CensorTypeAry = strings.Split(v.CensorType, ",")
}
@ -306,18 +353,19 @@ func (a *ApiMethod) GetPostDeimensoInfo(c *gin.Context) {
}
}
if v.MinScore != 0 {
outCont.ScoreStr = fmt.Sprintf("%v-%v", v.MinScore, v.MaxScore)
outCont.ScoreStr = fmt.Sprintf("%v-%v", publicmethod.DecimalEs(v.MinScore/100, 2), publicmethod.DecimalEs(v.MaxScore/100, 2))
} else {
outCont.ScoreStr = fmt.Sprintf("%v", v.MaxScore)
outCont.ScoreStr = fmt.Sprintf("%v", publicmethod.DecimalEs(v.MaxScore/100, 2))
}
if v.Minmoney != 0 {
outCont.MoneyStr = fmt.Sprintf("%v-%v", v.Minmoney, v.Maxmoney)
outCont.MoneyStr = fmt.Sprintf("%v-%v", publicmethod.DecimalEs(v.Minmoney/100, 2), publicmethod.DecimalEs(v.Maxmoney/100, 2))
} else {
outCont.MoneyStr = fmt.Sprintf("%v", v.Maxmoney)
outCont.MoneyStr = fmt.Sprintf("%v", publicmethod.DecimalEs(v.Maxmoney/100, 2))
}
outCont.UserKey = receivedValue.UserKey
outList = append(outList, outCont)
}
// fmt.Printf("outList------------------->%v\n", outList)
publicmethod.ResultList(0, receivedValue.Page, receivedValue.PageSize, total, int64(len(outList)), outList, c)
}

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

@ -34,7 +34,8 @@ type outPostManTargetList struct {
// 输出定量考核项目
type outPostRation struct {
publicmethod.PublicId
publicmethod.PublicName
ShemeId string `json:"shemeid"`
Title string `json:"title"`
UserKey string `json:"userkey"`
DimensionId string `json:"dimensionid"` //维度
}

5
apirouter/v1/postseting/pc.go

@ -19,6 +19,11 @@ func (a *ApiRouter) RouterGroupPc(router *gin.RouterGroup) {
apiRouter.POST("submit_post_scheme", methodBinding.SubmitPostScheme) //提交岗位考核方案
apiRouter.POST("get_post_scheme", methodBinding.GetPostScheme) //获取岗位方案内容列表
apiRouter.POST("get_copy_sheme_infor", methodBinding.GetCopyShemeInfor) //获取复制岗位考核方案
apiRouter.POST("set_evaluation_objectives", methodBinding.SetEvaluationObjectives) //提交岗位定量目标设定
apiRouter.POST("post_config_list", methodBinding.PostConfigList) //岗位定量考核目标列表
apiRouter.POST("eite_quantitative_config", methodBinding.EiteQuantitativeConfig) //修改考核目标设置
apiRouter.POST("del_quantitative_config", methodBinding.DelQuantitativeConfig) //删除考核目标设置
/*
岗位定性指标
*/

1
apirouter/v1/postseting/web.go

@ -24,5 +24,6 @@ func (a *ApiRouter) RouterGroupWeb(router *gin.RouterGroup) {
apiRouter.POST("send_us_nature_evaluation", methodBinding.SendUsNatureEvaluation) //提交个人岗位定性考核数据
apiRouter.POST("get_ration_target_cont", methodBinding.GetRationTargetCont) //获取定量考核详细内容
apiRouter.POST("submit_ration_post_cont", methodBinding.SubmitRationPostCont) //提交定量考核数据
}
}

2
apirouter/verifyLogin/route.go

@ -17,5 +17,7 @@ func (a *ApiRouter) RouterGroup(router *gin.RouterGroup) {
apiRouter.POST("captcha", methodBinding.Captcha) //获取验证码
apiRouter.POST("login", methodBinding.ScanCodeLogin) //登录
apiRouter.POST("signout", methodBinding.SignOut) //退出登录
apiRouter.POST("verify_empower", methodBinding.VerifyEmpower) //验证授权是否还有效
apiRouter.POST("login_not_verify", methodBinding.ScanCodeLoginNotVerify) //登录(无验证码)
}
}

75
models/modelskpi/quan_post_config_target.go

@ -0,0 +1,75 @@
package modelskpi
//
import (
"key_performance_indicators/overall"
"strings"
)
// 岗位定量考核目标设定
type QuanPostConfigTarget 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:标题"`
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:部门ID"`
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:岗位"`
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:指标"`
Detailed int64 `json:"detailed" gorm:"column:detailed;type:bigint(20) unsigned;default:0;not null;comment:指标细则"`
Type int64 `json:"type" gorm:"column:type;type:tinyint(1) unsigned;default:0;not null;comment:1、年度;2、季度;3、月度"`
Year int64 `json:"year" gorm:"column:year;type:bigint(20) unsigned;default:0;not null;comment:年度"`
Timecopy int64 `json:"timecopy" gorm:"column:timecopy;type:int(3) unsigned;default:0;not null;comment:季度与月度辅助值"`
Zeroprize float64 `json:"zeroprize" gorm:"column:zeroprize;type:int(7) unsigned;default:0;not null;comment:零奖值"`
Allprize float64 `json:"allprize" gorm:"column:allprize;type:int(7) unsigned;default:0;not null;comment:全奖值"`
Capping int `json:"capping" gorm:"column:capping;type:int(1) unsigned;default:2;not null;comment:是否封顶(1、是;2:否)"`
CappingVal float64 `json:"cappingval" gorm:"column:capping_val;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:删除)"`
Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"`
}
func (QuanPostConfigTarget *QuanPostConfigTarget) TableName() string {
return "quan_post_config_target"
}
// 编辑内容
func (cont *QuanPostConfigTarget) EiteCont(whereMap interface{}, saveData interface{}) (err error) {
err = overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Updates(saveData).Error
return
}
// 获取内容
func (cont *QuanPostConfigTarget) 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 *QuanPostConfigTarget) CountCont(whereMap interface{}) (countId int64) {
overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Count(&countId)
return
}
// 读取全部信息
func (cont *QuanPostConfigTarget) ContMap(whereMap interface{}, field ...string) (countAry []QuanPostConfigTarget, 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 *QuanPostConfigTarget) DelCont(whereMap interface{}) (err error) {
err = overall.CONSTANT_DB_KPI.Where(whereMap).Delete(&cont).Error
return
}

8
models/modelskpi/sheme_people.go

@ -20,8 +20,8 @@ type ShemePeople struct {
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保存"`
MinScore float64 `json:"minscore" gorm:"column:min_score;type:bigint(20) unsigned;default:0;not null;comment:最小分*100保存"`
MaxScore float64 `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:添加时间"`
@ -37,8 +37,8 @@ type ShemePeople struct {
Level int `json:"level" gorm:"column:tr_level;type:tinyint(1) unsigned;default:1;not null;comment:类型(1:指标;2:子目标;3:细则)"`
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:最低罚款"`
Maxmoney float64 `json:"maxmoney" gorm:"column:maxmoney;type:bigint(20) unsigned;default:0;not null;comment:最高罚款"`
Minmoney float64 `json:"minmoney" gorm:"column:minmoney;type:bigint(20) unsigned;default:0;not null;comment:最低罚款"`
}
func (ShemePeople *ShemePeople) TableName() string {

209
overall/publicmethod/technique.go

@ -6,6 +6,7 @@ import (
"crypto/rand"
"crypto/sha1"
"encoding/hex"
"encoding/json"
"errors"
"fmt"
"key_performance_indicators/middleware/grocerystore"
@ -18,6 +19,7 @@ import (
"math"
"math/big"
"reflect"
"sort"
"strconv"
"strings"
"time"
@ -878,3 +880,210 @@ func GetMenuThrees(jurisd int, parentId string, threeData []MenuContList) []Powe
}
return treeList
}
// 获取责任人
func GetDepartmentLeader(userCont modelshr.PersonArchives) {
var orgContList []DepartmentIsPower
orgContList = GetAllFatherDeparment(userCont.AdminOrg, 1, orgContList)
//根据序号排序
sort.Slice(orgContList, func(i, j int) bool {
return orgContList[i].Sort < orgContList[j].Sort
})
jsonStr, _ := json.Marshal(orgContList)
fmt.Printf("orgList---------------->%v\n", string(jsonStr))
}
// 获取行政组织的所有上级实权部门
func GetAllFatherDeparment(orgId int64, sort int, oldCont []DepartmentIsPower) (orgContList []DepartmentIsPower) {
var orgCont modelshr.AdministrativeOrganization
err := orgCont.GetCont(map[string]interface{}{"id": orgId}, "id", "name", "organization_type", "superior", "ispower")
if err != nil {
return
}
if orgCont.OrganizationType <= 2 {
orgContList = oldCont
// jsonStr, _ := json.Marshal(oldCont)
// fmt.Printf("oldCont---------------->%v\n", string(jsonStr))
return
} else {
// jsonStr, _ := json.Marshal(oldCont)
// fmt.Printf("oldCont---------------->%v\n", string(jsonStr))
if orgCont.IsPower == 1 {
var orgListCont DepartmentIsPower
orgListCont.Id = strconv.FormatInt(orgCont.Id, 10)
orgListCont.Name = orgCont.Name
orgListCont.Superior = orgCont.Superior
orgListCont.OrganizationType = orgCont.OrganizationType
orgListCont.IsPower = orgCont.IsPower
orgListCont.Sort = sort
orgListCont.PowerPeople = GetDutyOrgAbourLeader(orgCont.Id)
oldCont = append(oldCont, orgListCont)
orgContList = oldCont
sort = sort + 1
}
return GetAllFatherDeparment(orgCont.Superior, sort, oldCont)
}
return orgContList
}
/*
获取主权行政组织责任岗位及相关人员
@ordId 行政组织ID
*/
func GetDutyOrgAbourLeader(ordId int64) (postAboutPeople []DepartSoverePostMan) {
//获取负责人岗位
var leaderPostList []modelshr.Position
err := overall.CONSTANT_DB_HR.Model(&modelshr.Position{}).Select("`id`,`name`").Where("`state` = 1 AND `person_in_charge` = 1 AND `administrative_organization` = ?", ordId).Find(&leaderPostList).Error
if err != nil || len(leaderPostList) < 1 {
return
}
var isIn []int64
for _, v := range leaderPostList {
if IsInTrue[int64](v.Id, isIn) == false { //岗位
var postAboutManCont DepartSoverePostMan
postAboutManCont.Id = strconv.FormatInt(v.Id, 10)
postAboutManCont.Name = v.Name
postAboutManCont.People = GetManInPostList(ordId, v.Id)
postAboutPeople = append(postAboutPeople, postAboutManCont)
}
}
return postAboutPeople
}
/*
获取岗位中的人及其职务
@ordId 行政组织ID
@postId 岗位ID
*/
func GetManInPostList(ordId, postId int64) (peopleList []PeopleSoverePostMan) {
//获取相关行政组织岗位的人员列表
var usList []modelshr.PersonArchives
err := overall.CONSTANT_DB_HR.Model(&modelshr.PersonArchives{}).Select("`id`,`number`,`name`,`job_id`").Where("`state` = 1 AND `admin_org` = ? AND `position` = ? AND `emp_type` IN ?", ordId, postId, overall.EmployeeStatusIng).Find(&usList).Error
if err != nil || len(usList) < 1 {
return
}
for _, v := range usList {
var peopleCont PeopleSoverePostMan
peopleCont.Id = strconv.FormatInt(v.Id, 10)
peopleCont.Number = v.Number
peopleCont.Name = v.Name
var duitesCont modelshr.Duties
duitesCont.GetCont(map[string]interface{}{"`id`": v.JobId}, "`id`", "`name`")
peopleCont.PostId = strconv.FormatInt(duitesCont.Id, 10)
peopleCont.PostName = duitesCont.Name
peopleList = append(peopleList, peopleCont)
}
return
}
/*
获取上级审批
@userKey 用户KEy
@ordId 行政组织ID
@postId 岗位ID
@sort 排序
@contList 审批人列表
*/
func GetPositionList(userKey, ordId, postId int64, sort int, contList []PositionDigui) (listCont []PositionDigui) {
var positionCont modelshr.PostDutiesJob
err := positionCont.GetCont(map[string]interface{}{"`id`": postId})
if err != nil {
return
}
jsonStr, _ := json.Marshal(positionCont)
fmt.Printf("positionCont---------------->%v\n", string(jsonStr))
if positionCont.JobType < 2 {
listCont = contList
return
} else {
if positionCont.PersonInCharge == 1 {
peopelAry := GetPeopleInPostList(userKey, positionCont.AdministrativeOrganization, positionCont.Id)
if len(peopelAry) > 0 {
var cont PositionDigui
cont.Id = strconv.FormatInt(positionCont.Id, 10)
cont.Name = positionCont.Name
cont.OrgId = strconv.FormatInt(positionCont.AdministrativeOrganization, 10)
cont.Superior = strconv.FormatInt(positionCont.Superior, 10)
cont.Sort = sort
cont.People = peopelAry
contList = append(contList, cont)
}
listCont = contList
return GetPositionList(userKey, positionCont.AdministrativeOrganization, positionCont.Superior, sort+1, contList)
} else {
return GetPositionList(userKey, positionCont.AdministrativeOrganization, positionCont.Superior, sort+1, contList)
}
}
return
}
/*
获取岗位下人员列表
@userKey 用户KEy
@ordId 行政组织ID
@postId 岗位ID
*/
func GetPeopleInPostList(userKey, ordId, postId int64) (peopleList []PostPeople) {
isTrue := false
//获取相关行政组织岗位的人员列表
var usList []modelshr.PersonArchives
err := overall.CONSTANT_DB_HR.Model(&modelshr.PersonArchives{}).Select("`id`,`key`,`number`,`name`,`job_id`,`wechat`,`work_wechat`,`company`,`maindeparment`,`admin_org`,`job_id`").Where("`state` = 1 AND `admin_org` = ? AND `position` = ? AND `emp_type` IN ?", ordId, postId, overall.EmployeeStatusIng).Find(&usList).Error
if err != nil || len(usList) < 1 {
return
}
for _, v := range usList {
if v.Key == userKey {
isTrue = true
}
wechatStr := v.Wechat
if v.WorkWechat != "" {
wechatStr = v.WorkWechat
}
if wechatStr != "" {
var peopleCont PostPeople
peopleCont.Id = strconv.FormatInt(v.Id, 10)
peopleCont.Number = v.Number
peopleCont.Name = v.Name
peopleCont.Company = strconv.FormatInt(v.Company, 10)
if v.Company != 0 {
var companyCont modelshr.AdministrativeOrganization
companyCont.GetCont(map[string]interface{}{"`id`": v.Company}, "`name`")
peopleCont.CompanyName = companyCont.Name
}
if v.MainDeparment != 0 {
departmentId := GetGroupOrDepartPower(v.AdminOrg, 1)
peopleCont.Department = strconv.FormatInt(departmentId, 10)
var departCont modelshr.AdministrativeOrganization
departCont.GetCont(map[string]interface{}{"`id`": departmentId}, "`name`")
peopleCont.DepartmentName = departCont.Name
}
peopleCont.OrgId = strconv.FormatInt(v.AdminOrg, 10)
if v.AdminOrg != 0 {
var orgCont modelshr.AdministrativeOrganization
orgCont.GetCont(map[string]interface{}{"`id`": v.AdminOrg}, "`name`")
peopleCont.OrgName = orgCont.Name
}
var duitesCont modelshr.Duties
duitesCont.GetCont(map[string]interface{}{"`id`": v.JobId}, "`id`", "`name`")
peopleCont.DutiesId = strconv.FormatInt(duitesCont.Id, 10)
peopleCont.DutiesName = duitesCont.Name
peopleCont.Wechat = wechatStr
peopleList = append(peopleList, peopleCont)
}
}
fmt.Printf("%v\n", isTrue)
// if isTrue == true {
// var emptyAry []PostPeople
// peopleList = emptyAry
// }
return
}

50
overall/publicmethod/type.go

@ -77,3 +77,53 @@ type PowerThree struct {
Child []PowerThree `json:"child"`
MenuOperation []MenuContList `json:"menuOperation"`
}
//部门判断列表
type DepartmentIsPower struct {
PublicId
PublicName
Superior int64 `json:"superior"`
OrganizationType int64 `json:"organizationtype"`
IsPower int `json:"ispower"`
Sort int `json:"sort"`
PowerPeople []DepartSoverePostMan `json:"powerpeople"`
}
//获取主权部门的负责人
type DepartSoverePostMan struct {
PublicId
PublicName
People []PeopleSoverePostMan `json:"people"`
}
type PeopleSoverePostMan struct {
PublicId
Number string `json:"number"`
PublicName
PostId string `json:"postid"`
PostName string `json:"postname"`
}
//岗位递归
type PositionDigui struct {
PublicId
PublicName
OrgId string `json:"orgId"`
Superior string `json:"superior"`
Sort int `json:"sort"`
People []PostPeople `json:"people"`
}
type PostPeople struct {
PublicId
Number string `json:"number"`
PublicName
Company string `json:"company"`
CompanyName string `json:"companyname"`
Department string `json:"department"`
DepartmentName string `json:"departmentname"`
OrgId string `json:"orgId"`
OrgName string `json:"orgname"`
DutiesId string `json:"dutiesid"`
DutiesName string `json:"dutiesname"`
Wechat string `json:"wechat"`
}

Loading…
Cancel
Save