package departmentpc
import (
"encoding/json"
"fmt"
"key_performance_indicators/middleware/snowflake"
"key_performance_indicators/models/modelshr"
"key_performance_indicators/models/modelskpi"
"key_performance_indicators/overall"
"key_performance_indicators/overall/publicmethod"
"strconv"
"strings"
"time"
"github.com/gin-gonic/gin"
)
// 部门指标列表
func ( a * ApiMethod ) DepartmentTargetList ( c * gin . Context ) {
var receivedValue departListQuery
c . ShouldBindJSON ( & receivedValue )
if receivedValue . Page == 0 {
receivedValue . Page = 1
}
if receivedValue . PageSize == 0 {
receivedValue . PageSize = 20
}
gormDb := overall . CONSTANT_DB_KPI . Model ( & modelskpi . EvaluationTarget { } )
if receivedValue . State != 0 { //状态(1:启用;2:禁用;3:删除)
gormDb = gormDb . Where ( "et_state = ?" , receivedValue . State )
} else {
gormDb = gormDb . Where ( "et_state BETWEEN ? AND ?" , 1 , 2 )
}
if receivedValue . Title != "" { //指标名称
gormDb = gormDb . Where ( "et_state LIKE ?" , "%" + receivedValue . Title + "%" )
}
if receivedValue . Class != 0 { //1:定性考核;2:定量考核
gormDb = gormDb . Where ( "et_type = ?" , receivedValue . Class )
}
if receivedValue . DepartmentId != "" { //部门ID
gormDb = gormDb . Where ( "FIND_IN_SET(?,`et_relevant_departments`)" , receivedValue . DepartmentId )
}
if receivedValue . DimensionId != "" { //维度ID
gormDb = gormDb . Where ( "et_dimension = ?" , receivedValue . DimensionId )
}
if receivedValue . ReportPerson != "" { //上报人
gormDb = gormDb . Where ( "FIND_IN_SET(?,`et_report`)" , receivedValue . ReportPerson )
}
if receivedValue . ScoringMethod != 0 { //计分方式(1:自动;2:手动)
gormDb = gormDb . Where ( "et_scoring_method = ?" , receivedValue . ScoringMethod )
}
if receivedValue . Cycle != 0 { //1:班;2:天;3:周;4:月;5:季度;6:年
gormDb = gormDb . Where ( "et_cycle = ?" , receivedValue . Cycle )
}
var total int64
totalErr := gormDb . Count ( & total ) . Error
if totalErr != nil {
total = 0
}
var departmentTargetList [ ] modelskpi . EvaluationTarget
gormDb = publicmethod . PageTurningSettings ( gormDb , receivedValue . Page , receivedValue . PageSize )
err := gormDb . Order ( "`et_id` DESC" ) . Find ( & departmentTargetList ) . Error
if err != nil {
publicmethod . Result ( 105 , err , c )
return
}
var targetList [ ] printDepartmentTarget
for _ , v := range departmentTargetList {
var targetCont printDepartmentTarget
targetCont . Id = v . Id
targetCont . Title = v . Title //指标名称"`
targetCont . Type = v . Type //1:定性考核;2:定量考核"`
targetCont . State = v . State //状态(1:启用;2:禁用;3:删除)"`
targetCont . AddTime = v . AddTime //制定时间"`
targetCont . Share = v . Share //1:共用;2:私用"`
targetCont . RelevantDepartments = v . RelevantDepartments //相关部门"`
targetCont . Dimension = v . Dimension //维度"`
targetCont . Key = v . Key //UUID"`
targetCont . Report = v . Report //上报人"`
targetCont . Uniteing = v . Uniteing //计量单位"`
targetCont . Cycles = v . Cycles //1:班;2:天;3:周;4:月;5:季度;6:年"`
targetCont . CycleAttres = v . CycleAttres //辅助计数"`
targetCont . VisibleRange = v . VisibleRange //可见范围"`
targetCont . VisibleRangeGroup = v . VisibleRangeGroup //可见范围(集团)"`
targetCont . ScoringMethod = v . ScoringMethod //计分方式(1:自动;2:手动)"`
var dutyClassCont modelskpi . DutyClass
dutyClassCont . GetCont ( map [ string ] interface { } { "`id`" : v . Dimension } , "`title`" )
targetCont . DimensionTitle = dutyClassCont . Title
targetList = append ( targetList , targetCont )
}
publicmethod . ResultList ( 0 , receivedValue . Page , receivedValue . PageSize , total , int64 ( len ( targetList ) ) , targetList , c )
}
// 实验查询
func ( a * ApiMethod ) Shiyan ( c * gin . Context ) {
// var receivedValue departListQuery
// c.ShouldBindJSON(&receivedValue)
// if receivedValue.DepartmentId == "" {
// receivedValue.DepartmentId = "316"
// }
// if receivedValue.DimensionId == "" {
// receivedValue.DimensionId = "1"
// }
// var evalCont []modelskpi.EvaluationTarget
// // gormDb := overall.CONSTANT_DB_KPI.Model(&modelskpi.EvaluationTarget{}).Select("evaluationtarget.*,(?) AS tdm", overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetDepartment{}).Select("id").Where("department_id = ? AND target_id = et_id ", receivedValue.DepartmentId).Find(&modelskpi.TargetDepartment{})).Having("tdm IS NOT NULL").Find(&evalCont).Error
// // 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
}
fmt . Printf ( "总数---->%v\n" , len ( dimeTargetList ) )
// var xieChengChuli []modelskpi.DetailedTarget
// for i, v := range dimeTargetList {
// if (i+1)%100 == 0 {
// xieChengChuli = append(xieChengChuli, v)
// fmt.Printf("循环--%v-->%v\n", i, len(xieChengChuli))
// xieChengChuli = []modelskpi.DetailedTarget{}
// } else {
// xieChengChuli = append(xieChengChuli, v)
// }
// }
for _ , v := range dimeTargetList {
xiaoZhengBuMen ( v )
}
// 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)
//发送消息
// var sendTextMsgCont wechatsendmsg.TextMsgCont
// sendTextMsgCont.Content = "你的快递已到,请携带工卡前往邮件中心领取。\n出发前可查看<a href=\"http://work.weixin.qq.com\">邮件中心视频实况</a>,聪明避开排队。"
// var sendTextMsg wechatsendmsg.SendTextMsg
// sendTextMsg.Touser = "KaiXinGuo" //指定接收消息的成员,成员ID列表;特殊情况:指定为"@all",则向该企业应用的全部成员发送;最多支持1000个
// sendTextMsg.Toparty = "" //指定接收消息的部门,部门ID列表,多个接收者用‘|’分隔,最多支持100个。当touser为"@all"时忽略本参数
// sendTextMsg.Totag = "" //指定接收消息的标签,标签ID列表,多个接收者用‘|’分隔,最多支持100个。当touser为"@all"时忽略本参数
// sendTextMsg.Msgtype = "text" //消息类型
// agentIdInt, _ := strconv.ParseInt(overall.CONSTANT_CONFIG.WechatKpi.Agentid, 10, 64)
// sendTextMsg.Agentid = agentIdInt //企业应用的id,整型。企业内部开发,可在应用的设置页面查看;第三方服务商,可通过接口 获取企业授权信息 获取该参数值
// sendTextMsg.EnableDuplicateCheck = 0 //表示是否开启重复消息检查,0表示否,1表示是,默认0
// sendTextMsg.DuplicateCheckInterval = 1800 //表示是否重复消息检查的时间间隔,默认1800s,最大不超过4小时
// sendTextMsg.Text = sendTextMsgCont
// sendTextMsg.Safe = 0 //表示是否是保密消息,0表示可对外分享,1表示不能分享且内容显示水印,默认为0
// sendTextMsg.EnableIdTrans = 0 //表示是否开启id转译,0表示否,1表示是,默认0。仅第三方应用需要用到,企业自建应用可以忽略。
// callData, err := sendTextMsg.SendMsg("kpi")
// fmt.Printf("callData------>%v--------err--------->%v\n", callData, err)
// publicmethod.Result(0, callData, c)
// var cehui wechatstatice.RevokeMsgSend
// cehui.Msgid = "mrVtVXE39it1tWVvd57npMpx5AjKZ1VvM-pj7nMCULC0FrlcENid7lRqMZbLvltWcOzLOrKSbGUqV0ngefx2xQ"
// callData, err := cehui.RevokeMsgSendCont("kpi")
// fmt.Printf("callData------>%v--------err--------->%v\n", callData, err)
// publicmethod.Result(0, callData, c)
//发送文本卡片
// var cardCont wechatsendmsg.TextMsgCont
// cardCont.Content = "您的会议室已经预定,稍后会同步到`邮箱` "
// cardCont.Content = fmt.Sprintf("%v \n>**事项详情** ", cardCont.Content)
// cardCont.Content = fmt.Sprintf("%v \n>事 项:<font color=\"info\">开会</font> ", cardCont.Content)
// cardCont.Content = fmt.Sprintf("%v \n>组织者:@miglioguan ", cardCont.Content)
// cardCont.Content = fmt.Sprintf("%v \n>参与者:@miglioguan、@kunliu、@jamdeezhou、@kanexiong、@kisonwang ", cardCont.Content)
// cardCont.Content = fmt.Sprintf("%v \n>", cardCont.Content)
// cardCont.Content = fmt.Sprintf("%v \n>会议室:<font color=\"info\">广州TIT 1楼 301</font>", cardCont.Content)
// cardCont.Content = fmt.Sprintf("%v \n>日 期:<font color=\"warning\">2018年5月18日</font> ", cardCont.Content)
// cardCont.Content = fmt.Sprintf("%v \n>时 间:<font color=\"comment\">上午9:00-11:00</font> ", cardCont.Content)
// cardCont.Content = fmt.Sprintf("%v \n>", cardCont.Content)
// cardCont.Content = fmt.Sprintf("%v \n>请准时参加会议。 ", cardCont.Content)
// cardCont.Content = fmt.Sprintf("%v \n>", cardCont.Content)
// cardCont.Content = fmt.Sprintf("%v \n>如需修改会议信息,请点击:[修改会议信息](https://work.weixin.qq.com)", cardCont.Content)
// var sendTextMsg wechatsendmsg.SendMarkDown
// sendTextMsg.Touser = "KaiXinGuo" //指定接收消息的成员,成员ID列表;特殊情况:指定为"@all",则向该企业应用的全部成员发送;最多支持1000个
// sendTextMsg.Toparty = "" //指定接收消息的部门,部门ID列表,多个接收者用‘|’分隔,最多支持100个。当touser为"@all"时忽略本参数
// sendTextMsg.Totag = "" //指定接收消息的标签,标签ID列表,多个接收者用‘|’分隔,最多支持100个。当touser为"@all"时忽略本参数
// sendTextMsg.Msgtype = "markdown" //消息类型
// agentIdInt, _ := strconv.ParseInt(overall.CONSTANT_CONFIG.WechatKpi.Agentid, 10, 64)
// sendTextMsg.Agentid = agentIdInt //企业应用的id,整型。企业内部开发,可在应用的设置页面查看;第三方服务商,可通过接口 获取企业授权信息 获取该参数值
// sendTextMsg.EnableDuplicateCheck = 0 //表示是否开启重复消息检查,0表示否,1表示是,默认0
// sendTextMsg.DuplicateCheckInterval = 1800 //表示是否重复消息检查的时间间隔,默认1800s,最大不超过4小时
// sendTextMsg.MsgBody = cardCont
// callData, err := sendTextMsg.SendMsg("kpi")
// jsonstr, _ := json.Marshal(sendTextMsg)
// fmt.Printf("callData------>%v--------err--------->%v--------->%v\n", callData, err, string(jsonstr))
// publicmethod.Result(0, callData, c)
//发送模板卡片
//文本通知
// var sourceText wechatsendmsg.SourceText
// sourceText.IconUrl = "https://docu.hxgk.group/images/2022_01/3f7a1120a559e9bee3991b85eb34d103.png"
// sourceText.Desc = "恒信高科"
// sourceText.DescColor = 1
// var actionListCont []wechatsendmsg.ActionListCont
// var actionListContOne wechatsendmsg.ActionListCont
// actionListContOne.Key = "A"
// actionListContOne.Text = "接受推送"
// actionListCont = append(actionListCont, actionListContOne)
// var actionListContTwo wechatsendmsg.ActionListCont
// actionListContTwo.Key = "B"
// actionListContTwo.Text = "不再推送"
// actionListCont = append(actionListCont, actionListContTwo)
// var ActionMenuCont wechatsendmsg.ActionMenuCont
// ActionMenuCont.Desc = "卡片副交互辅助文本说明"
// ActionMenuCont.ActionList = actionListCont
// var mainTitleCont wechatsendmsg.MainTitleCont
// mainTitleCont.Title = "一级标题一级标题一级标题\n一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题一级标题"
// mainTitleCont.Desc = "一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明一级说明"
// var quoteAreaCont wechatsendmsg.QuoteAreaCont
// quoteAreaCont.Type = 1
// quoteAreaCont.Url = "http://admin.hxgk.group"
// quoteAreaCont.Title = "引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题引用文献标题"
// quoteAreaCont.QuoteText = "引用文献描述引用文献描述\n引用文献描\n述引用文献描述引用文献描述\n引用文献描述引用\n文献描述引用文献描\n述引用文献描述\n引用文献描述引用文献描述引用文献描述引用文献描\n述引用文献描述引用文献描\n述引用文献描述引用文\n献描述引用文献描述引\n用文献描述引用文献描述引用\n文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述\n引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引\n用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述引用文献描述"
// var emphasisContentInfo wechatsendmsg.EmphasisContentInfo
// emphasisContentInfo.Title = "关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题"
// emphasisContentInfo.Desc = "关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述关键数据描述"
// var horizontalContentListInfoAry []wechatsendmsg.HorizontalContentListInfo
// var horizontalContentListInfo wechatsendmsg.HorizontalContentListInfo
// horizontalContentListInfo.KeyName = "邀请人"
// horizontalContentListInfo.Value = "张三"
// horizontalContentListInfoAry = append(horizontalContentListInfoAry, horizontalContentListInfo)
// var horizontalContentLis1 wechatsendmsg.HorizontalContentListInfo
// horizontalContentLis1.KeyName = "企业微信官网"
// horizontalContentLis1.Value = "点击访问"
// horizontalContentLis1.Type = 1
// horizontalContentLis1.Url = "https://work.weixin.qq.com"
// horizontalContentListInfoAry = append(horizontalContentListInfoAry, horizontalContentLis1)
// // var horizontalContentLis2 wechatsendmsg.HorizontalContentListInfo
// // horizontalContentLis2.KeyName = "企业微信下载"
// // horizontalContentLis2.Value = "企业微信.apk"
// // horizontalContentLis2.Type = 2
// // horizontalContentLis2.MediaId = "https://work.weixin.qq.com"
// // horizontalContentListInfoAry = append(horizontalContentListInfoAry, horizontalContentLis2)
// var horizontalContentLis3 wechatsendmsg.HorizontalContentListInfo
// horizontalContentLis3.KeyName = "员工信息"
// horizontalContentLis3.Value = "点击查看"
// horizontalContentLis3.Type = 3
// horizontalContentLis3.Userid = "KaiXinGuo"
// horizontalContentListInfoAry = append(horizontalContentListInfoAry, horizontalContentLis3)
// var jumpListContList []wechatsendmsg.JumpListCont
// var jumpList1 wechatsendmsg.JumpListCont
// jumpList1.Type = 1
// jumpList1.Title = "企业微信官网===>"
// jumpList1.Url = "https://work.weixin.qq.com"
// jumpListContList = append(jumpListContList, jumpList1)
// // var jumpList2 wechatsendmsg.JumpListCont
// // jumpList2.Type = 2
// // jumpList2.Title = "跳转小程序"
// // jumpList2.Appid = "小程序的appid"
// // jumpList2.PagePath = "/index.html"
// // jumpListContList = append(jumpListContList, jumpList2)
// var cardActionContStr wechatsendmsg.CardActionCont
// cardActionContStr.Type = 1
// cardActionContStr.Url = "http://www.baidu.com"
// uuId := publicmethod.GetUUid(5)
// var tempCardContText wechatsendmsg.TemplateCardContText
// tempCardContText.CardType = "text_notice"
// tempCardContText.Source = sourceText
// tempCardContText.ActionMenu = ActionMenuCont
// uuIdsStr := strconv.FormatInt(uuId, 10)
// tempCardContText.TaskId = fmt.Sprintf("KPI_%v", uuIdsStr)
// tempCardContText.MainTitle = mainTitleCont
// tempCardContText.QuoteArea = quoteAreaCont
// tempCardContText.EmphasisContent = emphasisContentInfo
// tempCardContText.SubTitleText = "二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段二级文本单一字段"
// tempCardContText.HorizontalContentList = horizontalContentListInfoAry
// tempCardContText.JumpList = jumpListContList
// tempCardContText.CardAction = cardActionContStr
// var sendTextTempl wechatsendmsg.SendTextNoticeAll
// sendTextTempl.Touser = "KaiXinGuo" //指定接收消息的成员,成员ID列表;特殊情况:指定为"@all",则向该企业应用的全部成员发送;最多支持1000个
// sendTextTempl.Toparty = "" //指定接收消息的部门,部门ID列表,多个接收者用‘|’分隔,最多支持100个。当touser为"@all"时忽略本参数
// sendTextTempl.Totag = "" //指定接收消息的标签,标签ID列表,多个接收者用‘|’分隔,最多支持100个。当touser为"@all"时忽略本参数
// sendTextTempl.Msgtype = "template_card" //消息类型
// agentIdInt, _ := strconv.ParseInt(overall.CONSTANT_CONFIG.WechatKpi.Agentid, 10, 64)
// sendTextTempl.Agentid = agentIdInt
// sendTextTempl.EnableDuplicateCheck = 0
// sendTextTempl.DuplicateCheckInterval = 1800
// sendTextTempl.TemplateCard = tempCardContText
// sendTextTempl.EnableIdTrans = 0
// callData, err := sendTextTempl.SendMsg("kpi")
// jsonstr, _ := json.Marshal(sendTextTempl)
// fmt.Printf("callData------>%v--------err--------->%v--------->%v\n", callData, err, string(jsonstr))
// publicmethod.Result(0, callData, c)
// var mainTitleCont wechatsendmsg.MainTitleCont
// mainTitleCont.Title = "关键数据标\n题关键数据标题关键数据\n标题关键数据标题关\n键数据标题关键数据标题关\n键数据标题\n关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据\n标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题关键数据标题"
// var imageTextAreaCont wechatsendmsg.ImageTextAreaCont
// imageTextAreaCont.Type = 1
// imageTextAreaCont.Url = "https://work.weixin.qq.com"
// imageTextAreaCont.Title = "企业微信的左图右文样式"
// imageTextAreaCont.Desc = "企业微信真好用呀真好用"
// imageTextAreaCont.ImageUrl = "https://img.iplaysoft.com/wp-content/uploads/2019/free-images/free_stock_photo_2x.jpg"
// var cardImageCont wechatsendmsg.CardImageCont
// cardImageCont.Url = "https://docu.hxgk.group/images/2022_01/3f7a1120a559e9bee3991b85eb34d103.png"
// cardImageCont.AspectRatio = 2.2
// var verticalContentListCont wechatsendmsg.VerticalContentListCont
// verticalContentListCont.Title = "惊喜红包等你来拿"
// verticalContentListCont.Desc = "下载企业微信还能抢红包!"
// var optionListContList []wechatsendmsg.OptionListCont
// var optionListCont1 wechatsendmsg.OptionListCont
// optionListCont1.Id = "btn_selection_id1"
// optionListCont1.Text = "100分"
// optionListContList = append(optionListContList, optionListCont1)
// var optionListCont2 wechatsendmsg.OptionListCont
// optionListCont2.Id = "btn_selection_id2"
// optionListCont2.Text = "101分"
// optionListContList = append(optionListContList, optionListCont2)
// var buttonSelectionCont wechatsendmsg.ButtonSelectionCont
// buttonSelectionCont.QuestionKey = "btn_question_key1"
// buttonSelectionCont.Title = "企业微信评分"
// buttonSelectionCont.SelectedId = "btn_selection_id1"
// buttonSelectionCont.OptionList = optionListContList
// var optionListContList1 []wechatsendmsg.OptionListCont
// var optionListCont11 wechatsendmsg.OptionListCont
// optionListCont11.Id = "btn_selection_id12"
// optionListCont11.Text = "100"
// optionListContList1 = append(optionListContList1, optionListCont11)
// var optionListCont12 wechatsendmsg.OptionListCont
// optionListCont12.Id = "btn_selection_id22"
// optionListCont12.Text = "101"
// optionListContList1 = append(optionListContList1, optionListCont12)
// var buttonSelectionCont1 wechatsendmsg.ButtonSelectionCont
// buttonSelectionCont1.QuestionKey = "btn_question_key12"
// buttonSelectionCont1.Title = "评分"
// buttonSelectionCont1.SelectedId = "btn_selection_id12"
// buttonSelectionCont1.OptionList = optionListContList1
// var buttonSelectionContList []wechatsendmsg.ButtonSelectionCont
// buttonSelectionContList = append(buttonSelectionContList, buttonSelectionCont)
// buttonSelectionContList = append(buttonSelectionContList, buttonSelectionCont1)
// var buttonList []wechatsendmsg.ButtonListCont
// var buttonList1 wechatsendmsg.ButtonListCont
// buttonList1.Text = "按钮1"
// buttonList1.Style = 1
// buttonList1.Key = "button_key_1"
// buttonList = append(buttonList, buttonList1)
// var buttonList2 wechatsendmsg.ButtonListCont
// buttonList2.Text = "按钮2"
// buttonList2.Style = 2
// buttonList2.Key = "button_key_2"
// buttonList = append(buttonList, buttonList2)
// var OptionListContCheckBoxList []wechatsendmsg.OptionListContCheckBox
// var OptionListContCheckBox1 wechatsendmsg.OptionListContCheckBox
// OptionListContCheckBox1.Id = "option_id1"
// OptionListContCheckBox1.Text = "选择题选项1"
// OptionListContCheckBox1.IsChecked = true
// OptionListContCheckBoxList = append(OptionListContCheckBoxList, OptionListContCheckBox1)
// var OptionListContCheckBox2 wechatsendmsg.OptionListContCheckBox
// OptionListContCheckBox2.Id = "option_id2"
// OptionListContCheckBox2.Text = "选择题选项2"
// OptionListContCheckBox2.IsChecked = false
// OptionListContCheckBoxList = append(OptionListContCheckBoxList, OptionListContCheckBox2)
// var checkBoxCont wechatsendmsg.CheckBoxCont
// checkBoxCont.QuestionKey = "question_key1"
// checkBoxCont.Mode = 1
// checkBoxCont.OptionList = OptionListContCheckBoxList
// var submitButton wechatsendmsg.ActionListCont
// submitButton.Text = "提交"
// submitButton.Key = "key"
// uuId := publicmethod.GetUUid(5)
// var sendCont wechatsendmsg.TemMultipleInteraction
// sendCont.CardType = "multiple_interaction"
// sendCont.Source = sourceText
// // sendCont.ActionMenu = ActionMenuCont
// sendCont.TaskId = fmt.Sprintf("KPI_%v", uuId)
// sendCont.MainTitle = mainTitleCont
// sendCont.QuoteArea = quoteAreaCont
// sendCont.SubTitleText = quoteAreaCont.QuoteText
// sendCont.ButtonSelection = buttonSelectionCont
// sendCont.ButtonList = buttonList
// sendCont.ImageTextArea = imageTextAreaCont
// sendCont.CardImage = cardImageCont
// sendCont.VerticalContentList = verticalContentListCont
// sendCont.CardAction = cardActionContStr
// sendCont.HorizontalContentList = horizontalContentListInfoAry
// sendCont.JumpList = jumpListContList
// sendCont.SelectList = buttonSelectionContList
// sendCont.SubmitButton = submitButton
// var sendTextTempl wechatsendmsg.SendMultipleInteraction
// sendTextTempl.Touser = "KaiXinGuo" //指定接收消息的成员,成员ID列表;特殊情况:指定为"@all",则向该企业应用的全部成员发送;最多支持1000个
// sendTextTempl.Toparty = "" //指定接收消息的部门,部门ID列表,多个接收者用‘|’分隔,最多支持100个。当touser为"@all"时忽略本参数
// sendTextTempl.Totag = "" //指定接收消息的标签,标签ID列表,多个接收者用‘|’分隔,最多支持100个。当touser为"@all"时忽略本参数
// sendTextTempl.Msgtype = "template_card" //消息类型
// agentIdInt, _ := strconv.ParseInt(overall.CONSTANT_CONFIG.WechatKpi.Agentid, 10, 64)
// sendTextTempl.Agentid = agentIdInt
// sendTextTempl.EnableDuplicateCheck = 0
// sendTextTempl.DuplicateCheckInterval = 1800
// sendTextTempl.TemplateCard = sendCont
// sendTextTempl.EnableIdTrans = 0
// callData, err := sendTextTempl.SendMsg("kpi")
// jsonstr, _ := json.Marshal(sendTextTempl)
// fmt.Printf("callData------>%v--------err--------->%v--------->%v\n", callData, err, string(jsonstr))
// publicmethod.Result(0, callData, c)
}
// 校正关联维度
func xiaoZehgnWeiDu ( ) {
//校正部门维度
var zhiBiaoId [ ] int64
overall . CONSTANT_DB_KPI . Model ( & modelskpi . TargetDepartment { } ) . Distinct ( "`target_id`" ) . Find ( & zhiBiaoId )
if len ( zhiBiaoId ) > 0 {
for _ , dv := range zhiBiaoId {
var zhiBiaoCont modelskpi . EvaluationTarget
zhiBiaoCont . GetCont ( map [ string ] interface { } { "`et_id`" : dv } , "`et_dimension`" )
var tarDepCont modelskpi . TargetDepartment
tarDepCont . EiteCont ( map [ string ] interface { } { "`target_id`" : dv } , map [ string ] interface { } { "`dimension_id`" : zhiBiaoCont . Dimension } )
}
}
//校正提交人维度
var zhiBiaoReportId [ ] int64
overall . CONSTANT_DB_KPI . Model ( & modelskpi . TargetReport { } ) . Distinct ( "`target_id`" ) . Find ( & zhiBiaoReportId )
if len ( zhiBiaoReportId ) > 0 {
for _ , rv := range zhiBiaoReportId {
var zhiBiaoRenCont modelskpi . EvaluationTarget
zhiBiaoRenCont . GetCont ( map [ string ] interface { } { "`et_id`" : rv } , "`et_dimension`" )
var tarDepRenCont modelskpi . TargetReport
tarDepRenCont . EiteCont ( map [ string ] interface { } { "`target_id`" : rv } , map [ string ] interface { } { "`dimension_id`" : zhiBiaoRenCont . Dimension } )
}
}
}
// 校正部门定性考核关联关系
func xiaoZhengBuMen ( detaTar modelskpi . DetailedTarget ) {
if detaTar . Paretment != "" {
bumenAry := strings . Split ( detaTar . Paretment , "," )
if len ( bumenAry ) > 0 {
for _ , v := range bumenAry {
zbLmXzBm ( detaTar . ParentId , detaTar . ParentIdSun , detaTar . Id , 3 , v )
}
}
}
var assTar modelskpi . Assesstarget
assErr := overall . CONSTANT_DB_KPI . Where ( "`targetid` = ? AND `suntargetid` = ?" , detaTar . ParentId , detaTar . ParentIdSun ) . First ( & assTar ) . Error
if assErr == nil {
var reportAry [ ] zhuanHuanMan
jsonErr := json . Unmarshal ( [ ] byte ( assTar . Content ) , & reportAry )
if jsonErr == nil {
for _ , mv := range reportAry {
if mv . Id == detaTar . Id {
if len ( mv . Operator ) > 0 {
for _ , ov := range mv . Operator {
juadgeReport ( detaTar . ParentId , detaTar . ParentIdSun , detaTar . Id , 1 , ov )
}
}
}
}
}
}
}
// 判断该指标细则是否已经存在上报人
/ *
@ tarId 指标
@ sunId 栏目
@ lawsId 细则
@ class 类型 ( 1 : 指标 ; 2 : 子目标 ; 3 : 细则 )
@ manKey 上报人
* /
func juadgeReport ( tarId , sunId , lawsId int64 , class int , manKey string ) {
if class == 0 {
class = 1
}
var trCont modelskpi . TargetReport
err := trCont . GetCont ( map [ string ] interface { } { ` type ` : class , ` target_id ` : tarId , ` target_sun_id ` : sunId , ` target_bylaws ` : lawsId , ` man_key ` : manKey } )
if err == nil {
if trCont . State != 1 {
saveErr := trCont . EiteCont ( map [ string ] interface { } { "`id`" : trCont . Id } , map [ string ] interface { } { "`state`" : 1 , "`time`" : time . Now ( ) . Unix ( ) } )
fmt . Printf ( "编辑---->tarId----%v---->sunId----%v---->lawsId----%v---->class----%v---->bumenId----%v------>saveErr----->%v\n" , tarId , sunId , lawsId , class , manKey , saveErr )
}
} else {
trCont . TargetId = tarId //指标ID"`
trCont . TargetSunId = sunId //子目标"`
trCont . TargetBylaws = lawsId //指标细则"`
trCont . DepartmentId = 0 //部门ID"`
trCont . PostId = 0 //岗位ID"`
trCont . Type = class //类型(1:公司级;2:部门级)"`
trCont . State = 1 //状态(1:启用;2:禁用;3:删除)"`
manKeyInt , _ := strconv . ParseInt ( manKey , 10 , 64 )
trCont . ReportPerson = manKeyInt //上报人"`
trCont . Time = time . Now ( ) . Unix ( )
trCont . Class = 1
addErr := overall . CONSTANT_DB_KPI . Create ( & trCont ) . Error
fmt . Printf ( "编辑---->tarId----%v---->sunId----%v---->lawsId----%v---->class----%v---->bumenId----%v------>saveErr----->%v\n" , tarId , sunId , lawsId , class , manKey , addErr )
}
}
//编辑指标、栏目、细则关联部门
/ *
@ tarId 指标
@ sunId 栏目
@ lawsId 细则
@ class 类型 ( 1 : 指标 ; 2 : 子目标 ; 3 : 细则 )
@ bumenId 部门
* /
func zbLmXzBm ( tarId , sunId , lawsId int64 , class int , bumenId string ) {
var tarDepCont modelskpi . TargetDepartment
where := publicmethod . MapOut [ string ] ( )
where [ "`target_id`" ] = tarId
where [ "`target_sun_id`" ] = sunId
where [ "`target_bylaws`" ] = lawsId
where [ "`department_id`" ] = bumenId
err := tarDepCont . GetCont ( where , "`id`" , "`state`" )
if err == nil {
//存在,判断状态
if tarDepCont . State != 1 { //不是启用状态,改为启用
eidtWher := publicmethod . MapOut [ string ] ( )
eidtWher [ "``id``" ] = tarDepCont . Id
saveErr := tarDepCont . EiteCont ( eidtWher , map [ string ] interface { } { "`state`" : 1 , "`time`" : time . Now ( ) . Unix ( ) } )
fmt . Printf ( "编辑---->tarId----%v---->sunId----%v---->lawsId----%v---->class----%v---->bumenId----%v------>saveErr----->%v\n" , tarId , sunId , lawsId , class , bumenId , saveErr )
}
} else {
tarDepCont . TargetId = tarId //指标ID"`
tarDepCont . TargetSunId = sunId //子目标"`
tarDepCont . TargetBylaws = lawsId //指标细则"`
tarDepCont . Type = class //类型(1:指标;2:子目标;3:细则)"`
bumenIdInt , _ := strconv . ParseInt ( bumenId , 10 , 64 )
tarDepCont . DepartmentId = bumenIdInt //部门ID"`
tarDepCont . PostId = 0 //岗位ID"`
tarDepCont . State = 1 //状态(1:启用;2:禁用;3:删除)"`
tarDepCont . Time = time . Now ( ) . Unix ( ) //写入时间"`
tarDepCont . Class = 1
addErr := overall . CONSTANT_DB_KPI . Create ( & tarDepCont ) . Error
fmt . Printf ( "编辑---->tarId----%v---->sunId----%v---->lawsId----%v---->class----%v---->bumenId----%v------>saveErr----->%v\n" , tarId , sunId , lawsId , class , bumenId , addErr )
}
}
// 获取部门定性考核部门关联列表
func ( a * ApiMethod ) GetDepartAboutTarget ( c * gin . Context ) {
var receivedValue publicmethod . PublicId
err := c . ShouldBindJSON ( & receivedValue )
if err != nil {
publicmethod . Result ( 100 , err , c )
return
}
var targetDepartmentID [ ] int64
disrErr := overall . CONSTANT_DB_KPI . Model ( & modelskpi . TargetDepartment { } ) . Distinct ( "`department_id`" ) . Where ( "`state` = 1 AND `level` = 1 AND `target_id` = ?" , receivedValue . Id ) . Find ( & targetDepartmentID ) . Error
if disrErr != nil {
publicmethod . Result ( 107 , err , c )
return
}
var departmentList [ ] modelshr . AdministrativeOrganization
departErr := overall . CONSTANT_DB_HR . Model ( & modelshr . AdministrativeOrganization { } ) . Select ( "`id`,`name`,`superior`,`ispower`" ) . Where ( "`id` IN ?" , targetDepartmentID ) . Find ( & departmentList ) . Error
if departErr != nil || len ( departmentList ) < 1 {
publicmethod . Result ( 107 , err , c )
return
}
var outList [ ] departOutcome
for _ , v := range departmentList {
var outCont departOutcome
outCont . Id = strconv . FormatInt ( v . Id , 10 )
outCont . Name = v . Name
outCont . Superior = strconv . FormatInt ( v . Superior , 10 )
outCont . Ispower = v . IsPower
outList = append ( outList , outCont )
}
publicmethod . Result ( 0 , outList , c )
}
// 获取部门指标相关执行人
func ( a * ApiMethod ) GetTargetReport ( c * gin . Context ) {
var receivedValue getAboutReportTarget
c . ShouldBindJSON ( & receivedValue )
if receivedValue . TargetId == "" {
publicmethod . Result ( 1 , receivedValue , c , "指标不能为空!" )
return
}
var userKey [ ] int64
typeClass := 1
if receivedValue . DepartmentId != "" || receivedValue . PostId != "" {
typeClass = 2
}
gormDb := overall . CONSTANT_DB_KPI . Model ( & modelskpi . TargetReport { } ) . Distinct ( "`man_key`" ) . Where ( "`state` = ? AND `type` = ? AND `target_id` = ?" , 1 , typeClass , receivedValue . TargetId )
if receivedValue . TargetSunId != "" {
gormDb = gormDb . Where ( "`target_sun_id` = ?" , receivedValue . TargetSunId )
}
if receivedValue . TargetBylaws != "" {
gormDb = gormDb . Where ( "`target_bylaws` = ?" , receivedValue . TargetBylaws )
}
if receivedValue . DepartmentId != "" {
gormDb = gormDb . Where ( "`department_id` = ?" , receivedValue . DepartmentId )
}
if receivedValue . PostId != "" {
gormDb = gormDb . Where ( "`post_id` = ?" , receivedValue . PostId )
}
err := gormDb . Find ( & userKey ) . Error
if err != nil || len ( userKey ) < 1 {
publicmethod . Result ( 107 , err , c )
return
}
//上报人信息
var reportManList [ ] modelshr . PersonArchives
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
}
var reportListCont [ ] printReportCont
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`" )
reportCont . GroupName = groupConb . Name
var departmentConb modelshr . AdministrativeOrganization
departmentConb . GetCont ( map [ string ] interface { } { "`id`" : v . MainDeparment } , "`name`" )
reportCont . DepartmentName = departmentConb . Name
reportCont . Icon = v . Icon
reportCont . Number = v . Number
reportListCont = append ( reportListCont , reportCont )
}
outData := publicmethod . MapOut [ string ] ( )
outData [ "userlist" ] = userKey
outData [ "userlistary" ] = reportListCont
publicmethod . Result ( 0 , outData , c )
}
// 添加定性考核子栏目及细则
func ( a * ApiMethod ) AddSunTargetDetailed ( c * gin . Context ) {
var receivedValue AddQualEval
c . ShouldBindJSON ( & receivedValue )
if len ( receivedValue . AcceptDepartmentId ) <= 0 {
publicmethod . Result ( 1 , receivedValue , c , "请选择接受考核的部门!" )
return
}
if receivedValue . Target == "" {
publicmethod . Result ( 1 , receivedValue , c , "请选择考核指标" )
return
}
if receivedValue . TargetSunTitle == "" {
publicmethod . Result ( 1 , receivedValue , c , "请输入栏目名称!" )
return
}
if len ( receivedValue . EvaluationList ) <= 0 {
publicmethod . Result ( 1 , receivedValue , c , "请添加测评详情!" )
return
} else {
isWrite := true
for _ , jv := range receivedValue . EvaluationList {
if jv . Title == "" || jv . Unit == "" || jv . ReferenceScore == "" {
isWrite = false
}
}
if isWrite == false {
publicmethod . Result ( 1 , receivedValue , c , "指标细则有未填写的内容!请检查!" )
return
}
}
tragetId , _ := strconv . ParseInt ( receivedValue . Target , 10 , 64 )
//判断子目标是否存在
var judgeSunTarget modelskpi . QualitativeTarget
saveSunTarget := modelskpi . QualitativeTarget {
Title : receivedValue . TargetSunTitle , // 指标子栏目名称
ParentId : tragetId , //归属指标
State : 1 , //状态(1:启用;2:禁用;3:删除)
AddTime : time . Now ( ) . Unix ( ) , //制定时间"`
Depart : strings . Join ( receivedValue . AcceptDepartmentId , "," ) , //关联部门"`
}
var whistleblower zhuanHuanMan
// judgeSunTarErr := judgeSunTarget.JudgeIsTrue(map[string]interface{}{"q_title": receivedValue.TargetSunTitle, "q_parent_id": receivedValue.Target}, saveSunTarget)
judgeSunTarErr := JudgeSunTargetAbout ( receivedValue . Target , receivedValue . TargetSunTitle , saveSunTarget , whistleblower )
/ *
*
@ 作者 : 秦东
@ 时间 : 2023 - 01 - 03 16 : 13 : 46
@ 功能 : 判断指标得子栏目是否存在
@ 参数
# targetId 指标ID
# sunTargetTitle 子栏目名称
# saveData 子栏目数据表
# whistleblower 提报人
@ 返回值
# err 返回值
@ 方法原型
# JudgeSunTargetAbout ( targetId , sunTargetTitle string , saveData modelskpi . QualitativeTarget , whistleblower zhuanHuanMan ) ( err error )
* /
if judgeSunTarErr != nil {
publicmethod . Result ( 106 , judgeSunTarErr , c )
return
}
//子表细则处理
for _ , v := range receivedValue . EvaluationList {
//判断指标细则是否已经存在
var judgeDetaCont modelskpi . DetailedTarget
judgeDetaErr := judgeDetaCont . GetCont ( map [ string ] interface { } { "`dt_parentid`" : receivedValue . Target , "`dt_parentid_sun`" : judgeSunTarget . Id , "`dt_title`" : v . Title } )
if judgeDetaErr == nil {
editDetaAdd ( judgeDetaCont . ParentId , judgeDetaCont . ParentIdSun , v , judgeDetaCont , receivedValue . AcceptDepartmentId )
} else {
addDetaInfo ( tragetId , judgeSunTarget . Id , v , receivedValue . AcceptDepartmentId )
}
}
publicmethod . Result ( 0 , receivedValue , c )
}
/ *
添加指标细则
@ targetId 指标ID
@ sunTargetId 栏目ID
@ qualEvalCont 提交的参数
@ departmentAry 接受考核部门
* /
func addDetaInfo ( targetId , sunTargetId int64 , qualEvalCont QualEvalSunList , departmentAry [ ] string ) ( err error ) {
var minScoreInt int64 = 0
var maxScoreInt int64 = 0
scoreAry := strings . Split ( qualEvalCont . 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 )
}
}
var targetCont modelskpi . EvaluationTarget
targetCont . GetCont ( map [ string ] interface { } { "et_id" : targetId } , "et_unit" , "et_cycle" )
//单位
unitName := qualEvalCont . Unit
if unitName == "" {
unitName = targetCont . Uniteing
}
//计分属性
addOrReduce := qualEvalCont . AddOrReduce
if qualEvalCont . AddOrReduce == 0 {
addOrReduce = 1
}
//统计周期
cyclesInt := qualEvalCont . Cycles
if cyclesInt == 0 {
cyclesInt = 4
}
cycleAttresInt := qualEvalCont . CycleAttres
if cycleAttresInt == 0 {
cycleAttresInt = 1
}
//接受考核部门
if len ( departmentAry ) < 1 {
//获取指标所有关联部门
var aboutTarDepList [ ] int64
aboutTDErr := overall . CONSTANT_DB_KPI . Model ( & modelskpi . TargetDepartment { } ) . Distinct ( "`department_id`" ) . Where ( "`state` = 1 AND `level` = 1 AND `target_id` = ?" , targetId ) . Find ( & aboutTarDepList ) . Error
if aboutTDErr == nil {
for _ , atdv := range aboutTarDepList {
departmentAry = append ( departmentAry , strconv . FormatInt ( atdv , 10 ) )
}
}
}
operatorList := qualEvalCont . Operator
//提报人
if len ( operatorList ) < 1 {
//获取指标所有关联部门
var aboutTarReportList [ ] int64
aboutTDErr := overall . CONSTANT_DB_KPI . Model ( & modelskpi . TargetReport { } ) . Distinct ( "`man_key`" ) . Where ( "`state` = 1 AND `type` = 1 AND `target_id` = ?" , targetId ) . Find ( & aboutTarReportList ) . Error
if aboutTDErr == nil {
for _ , atrv := range aboutTarReportList {
operatorList = append ( operatorList , strconv . FormatInt ( atrv , 10 ) )
}
}
}
var detaildeTarInfo modelskpi . DetailedTarget
detaildeTarInfo . Title = qualEvalCont . Title //指标细则"`
detaildeTarInfo . Content = qualEvalCont . Content //指标说明"`
detaildeTarInfo . ParentId = targetId //归属指标栏目"`
detaildeTarInfo . ParentIdSun = sunTargetId //归属指标子栏目"`
detaildeTarInfo . State = 1 //状态(1:启用;2:禁用;3:删除)"`
detaildeTarInfo . AddTime = time . Now ( ) . Unix ( ) //制定时间"`
detaildeTarInfo . MinScore = minScoreInt //最小分*100保存"`
detaildeTarInfo . MaxScore = maxScoreInt //最大分*100保存"`
detaildeTarInfo . Company = unitName //单位"`
detaildeTarInfo . AddReduce = addOrReduce //1:减少;2:增加;3:无属性,现场确认加或减"`
detaildeTarInfo . CensorType = strings . Join ( qualEvalCont . CensorType , "," ) //检查方式"`
detaildeTarInfo . CensorCont = qualEvalCont . CensorCont //检查依据"`
detaildeTarInfo . CensorRate = qualEvalCont . CensorRate //检查频次"`
detaildeTarInfo . Cycles = cyclesInt //1:班;2:天;3:周;4:月;5:季度;6:年"`
detaildeTarInfo . CycleAttres = cycleAttresInt //辅助计数"`
detaildeTarInfo . Paretment = strings . Join ( departmentAry , "," ) //接受考核的部门"`
detaildeTarInfo . Reportary = strings . Join ( operatorList , "," ) //提报人"`
err = overall . CONSTANT_DB_KPI . Create ( & detaildeTarInfo ) . Error
if err == nil {
syncSeting . Add ( 1 )
go handleDetarildTargetDepart ( targetId , sunTargetId , detaildeTarInfo . Id , departmentAry , 1 , 1 )
syncSeting . Add ( 1 )
go handleDetarildTargetRepart ( targetId , sunTargetId , detaildeTarInfo . Id , operatorList , 1 , 1 )
syncSeting . Wait ( )
}
return nil
}
/ *
编辑已经存在的指标细则
@ targetId 指标ID
@ sunTargetId 栏目ID
@ qualEvalCont 提交的参数
@ detailInfof 查询到的参数
@ departmentAry 接受考核部门
* /
func editDetaAdd ( targetId , sunTargetId int64 , qualEvalCont QualEvalSunList , detailInfof modelskpi . DetailedTarget , departmentAry [ ] string ) ( err error ) {
saveData := publicmethod . MapOut [ string ] ( )
if targetId != detailInfof . ParentId {
saveData [ "dt_parentid" ] = targetId
}
if sunTargetId != detailInfof . ParentIdSun {
saveData [ "dt_parentid_sun" ] = sunTargetId
}
if qualEvalCont . Title != "" && qualEvalCont . Title != detailInfof . Title {
saveData [ "dt_title" ] = qualEvalCont . Title
}
if qualEvalCont . Content != "" && qualEvalCont . Content != detailInfof . Content {
saveData [ "dt_content" ] = qualEvalCont . Content
}
if qualEvalCont . Unit != "" && qualEvalCont . Unit != detailInfof . Company {
saveData [ "dt_company" ] = qualEvalCont . Unit
}
if qualEvalCont . Cycles != 0 && qualEvalCont . Cycles != detailInfof . Cycles {
saveData [ "dt_cycle" ] = qualEvalCont . Cycles
}
if qualEvalCont . CycleAttres != 0 && qualEvalCont . CycleAttres != detailInfof . CycleAttres {
saveData [ "dt_cycleattr" ] = qualEvalCont . CycleAttres
}
if qualEvalCont . AddOrReduce != 0 && qualEvalCont . AddOrReduce != detailInfof . AddReduce {
saveData [ "dt_add_reduce" ] = qualEvalCont . AddOrReduce
}
censStr := strings . Join ( qualEvalCont . CensorType , "," )
if len ( qualEvalCont . CensorType ) > 0 {
if censStr != detailInfof . CensorType {
saveData [ "dt_censor_type" ] = censStr
}
}
if qualEvalCont . CensorCont != "" && qualEvalCont . CensorCont != detailInfof . CensorCont {
saveData [ "dt_censor_cont" ] = qualEvalCont . CensorCont
}
if qualEvalCont . CensorRate != 0 && qualEvalCont . CensorRate != detailInfof . CensorRate {
saveData [ "dt_censor_rate" ] = qualEvalCont . CensorRate
}
var minScoreInt int64 = 0
var maxScoreInt int64 = 0
scoreAry := strings . Split ( qualEvalCont . 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 )
}
}
if minScoreInt != detailInfof . MinScore {
saveData [ "dt_min_score" ] = minScoreInt
}
if maxScoreInt != detailInfof . MaxScore {
saveData [ "dt_max_score" ] = maxScoreInt
}
departStr := strings . Join ( departmentAry , "," )
if departStr != detailInfof . Paretment {
saveData [ "dt_paretment" ] = departStr
}
reportStr := strings . Join ( qualEvalCont . Operator , "," )
if reportStr != detailInfof . Reportary {
saveData [ "reportary" ] = reportStr
}
if detailInfof . State != 1 {
saveData [ "dt_state" ] = 1
}
if len ( saveData ) > 0 {
saveData [ "dt_time" ] = time . Now ( ) . Unix ( )
var editCont modelskpi . DetailedTarget
err = editCont . EiteCont ( map [ string ] interface { } { "`dt_id`" : detailInfof . Id } , saveData )
}
syncSeting . Add ( 1 )
go handleDetarildTargetDepart ( targetId , sunTargetId , detailInfof . Id , departmentAry , 1 , 1 )
syncSeting . Add ( 1 )
go handleDetarildTargetRepart ( targetId , sunTargetId , detailInfof . Id , qualEvalCont . Operator , 1 , 1 )
syncSeting . Wait ( )
return nil
}
/ *
处理指标细则关联部门
@ targetId 指标ID
@ targetSunId 栏目ID
@ bylawsId 指标细则
@ department 接受考核部门
@ class 级别 ( 1 : 部门级 ; 2 : 岗位级 )
@ nature 1 : 定性考核 ; 2 : 定量考核
* /
func handleDetarildTargetDepart ( targetId , targetSunId , bylawsId int64 , department [ ] string , class , nature int ) {
defer syncSeting . Done ( )
if nature == 0 {
nature = 1
}
//将不属于该指标细则的部门至禁用
otherSaveData := publicmethod . MapOut [ string ] ( )
otherSaveData [ "`state`" ] = 2
otherSaveData [ "`time`" ] = time . Now ( ) . Unix ( )
overall . CONSTANT_DB_KPI . Model ( & modelskpi . TargetDepartment { } ) . Where ( "`level` = ? AND `target_id` = ? AND `target_sun_id` = ? AND `target_bylaws` = ?" , class , targetId , targetSunId , bylawsId ) . Not ( map [ string ] interface { } { "department_id" : department } ) . Updates ( & otherSaveData )
for _ , v := range department {
var tarDepartCont modelskpi . TargetDepartment
saveErr := tarDepartCont . GetCont ( map [ string ] interface { } { "`level`" : class , "`target_id`" : targetId , "`target_sun_id`" : targetSunId , "`target_bylaws`" : bylawsId , "`department_id`" : v } , "`id`" , "`state`" )
if saveErr == nil {
if tarDepartCont . State != 1 {
tarDepartCont . EiteCont ( map [ string ] interface { } { "`id`" : tarDepartCont . 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
}
tarDepartCont . TargetId = targetId //指标ID"`
tarDepartCont . TargetSunId = targetSunId //子目标"`
tarDepartCont . TargetBylaws = bylawsId //指标细则"`
tarDepartCont . Type = xiZe //类型(1:指标;2:子目标;3:细则)"`
departId , _ := strconv . ParseInt ( v , 10 , 64 )
tarDepartCont . DepartmentId = departId //部门ID"`
tarDepartCont . PostId = 0 //岗位ID"`
tarDepartCont . State = 1 //状态(1:启用;2:禁用;3:删除)"`
tarDepartCont . Time = time . Now ( ) . Unix ( ) //写入时间"`
tarDepartCont . Class = nature //1:定性考核;2:定量考核"`
tarDepartCont . Level = class //级别(1:部门级;2:岗位级)"`
overall . CONSTANT_DB_KPI . Create ( & tarDepartCont )
}
}
}
/ *
处理指标细则关联考核提交人
@ targetId 指标ID
@ targetSunId 栏目ID
@ bylawsId 指标细则
@ repart 考核提交人
@ class 级别 ( 1 : 部门级 ; 2 : 岗位级 )
@ nature 1 : 定性考核 ; 2 : 定量考核
* /
func handleDetarildTargetRepart ( targetId , targetSunId , bylawsId int64 , repart [ ] string , class , nature int ) {
defer syncSeting . Done ( )
if nature == 0 {
nature = 1
}
//将不属于该指标细则的部门至禁用
otherSaveData := publicmethod . MapOut [ string ] ( )
otherSaveData [ "`state`" ] = 2
otherSaveData [ "`time`" ] = time . Now ( ) . Unix ( )
overall . CONSTANT_DB_KPI . Model ( & modelskpi . TargetReport { } ) . Where ( "`type` = ? AND `target_id` = ? AND `target_sun_id` = ? AND `target_bylaws` = ?" , class , targetId , targetSunId , bylawsId ) . Not ( map [ string ] interface { } { "man_key" : repart } ) . Updates ( & otherSaveData )
for _ , v := range repart {
//获取评价人部门
var manCont modelshr . PersonArchives
manCont . GetCont ( map [ string ] interface { } { "`key`" : v } , "`maindeparment`" )
var tarReportCont modelskpi . TargetReport
saveErr := tarReportCont . GetCont ( map [ string ] interface { } { "`type`" : class , "`target_id`" : targetId , "`target_sun_id`" : targetSunId , "`target_bylaws`" : bylawsId , "`man_key`" : v } , "`id`" , "`state`" )
if saveErr == nil {
if tarReportCont . State != 1 {
tarReportCont . EiteCont ( map [ string ] interface { } { "`id`" : tarReportCont . Id } , map [ string ] interface { } { "`state`" : 1 , "`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 . TargetId = targetId //指标ID"`
tarReportCont . TargetSunId = targetSunId //子目标"`
tarReportCont . TargetBylaws = bylawsId //指标细则"`
tarReportCont . DepartmentId = 0 //部门ID"`
tarReportCont . PostId = 0 //岗位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 )
}
}
var targetInfo modelskpi . QualitativeTarget
saveSunTarget := modelskpi . QualitativeTarget {
Title : targetInfo . Title , // 指标子栏目名称
ParentId : targetId , //归属指标
State : 1 , //状态(1:启用;2:禁用;3:删除)
AddTime : time . Now ( ) . Unix ( ) , //制定时间"`
Depart : targetInfo . Depart , //关联部门"`
}
var whistleblower zhuanHuanMan
whistleblower . Id = bylawsId
whistleblower . Operator = repart
targetIdStr := strconv . FormatInt ( targetId , 10 )
targetSunIdStr := strconv . FormatInt ( targetSunId , 10 )
JudgeSunTargetAbout ( targetIdStr , targetSunIdStr , saveSunTarget , whistleblower )
}
// 获取定性考核指标列表内容
func ( a * ApiMethod ) GetDepartmentTragetContList ( c * gin . Context ) {
var receivedValue getDepartTargetContType
c . ShouldBindJSON ( & receivedValue )
if receivedValue . TargetId == "" {
publicmethod . Result ( 1 , receivedValue , c , "未知指标ID!" )
return
}
if receivedValue . Page == 0 {
receivedValue . Page = 1
}
if receivedValue . PageSize == 0 {
receivedValue . PageSize = 20
}
var detaildeList [ ] modelskpi . DetailedTarget
var detCont modelskpi . DetailedTarget
gormDb := overall . CONSTANT_DB_KPI . Table ( fmt . Sprintf ( "%s dt" , detCont . TableName ( ) ) ) . Select ( "dt.*" ) . Where ( "dt.dt_state = 1 AND dt.dt_parentid = ?" , receivedValue . TargetId )
//接受考核的部门
if receivedValue . DepartmentId != "" {
gormDb = gormDb . Joins ( "LEFT JOIN `target_department` `td` on td.target_id = dt.dt_parentid AND td.target_sun_id = dt.dt_parentid_sun AND td.target_bylaws = dt.dt_id" ) . Where ( "td.department_id = ?" , receivedValue . DepartmentId )
}
//提报人
if receivedValue . ReportPerson != "" {
gormDb = gormDb . Joins ( "LEFT JOIN `target_report` `tr` on tr.target_id = dt.dt_parentid AND tr.target_sun_id = dt.dt_parentid_sun AND tr.target_bylaws = dt.dt_id" ) . Where ( "tr.man_key = ?" , receivedValue . ReportPerson )
}
if receivedValue . Cycle != 0 {
gormDb = gormDb . Where ( "dt.dt_cycle = ?" , receivedValue . Cycle )
}
if receivedValue . TargetSunId != "" {
gormDb = gormDb . Where ( "dt.dt_parentid_sun = ?" , receivedValue . TargetSunId )
}
err := gormDb . Order ( "dt.dt_parentid desc, dt.dt_parentid_sun" ) . Find ( & detaildeList ) . Error
if err != nil || len ( detaildeList ) < 1 {
publicmethod . Result ( 107 , receivedValue , c )
return
}
var total int64
totalErr := gormDb . Select ( "dt_id" ) . Count ( & total ) . Error
if totalErr != nil {
total = 0
}
var outData [ ] printDepartTargetCont
for _ , v := range detaildeList {
var outCont printDepartTargetCont
outCont . Id = v . Id
outCont . Title = v . Title //指标细则"`
outCont . Content = v . Content //指标说明"`
outCont . ParentId = v . ParentId //归属指标栏目"`
outCont . ParentIdSun = v . ParentIdSun //归属指标子栏目"`
outCont . State = v . State //状态(1:启用;2:禁用;3:删除)"`
outCont . AddTime = v . AddTime //制定时间"`
outCont . MinScore = v . MinScore //最小分*100保存"`
outCont . MaxScore = v . MaxScore //100保存"`
outCont . Company = v . Company //单位"`
outCont . AddReduce = v . AddReduce //1:减少;2:增加;3:无属性,现场确认加或减"`
outCont . CensorType = v . CensorType //检查方式"`
outCont . CensorCont = v . CensorCont //检查依据"`
outCont . CensorRate = v . CensorRate //检查频次"`
outCont . Cycles = v . Cycles //1:班;2:天;3:周;4:月;5:季度;6:年"`
outCont . CycleAttres = v . CycleAttres //辅助计数"`
outCont . Paretment = v . Paretment //接受考核的部门"`
outCont . Reportary = v . Reportary //提报人"`
standardStr := ""
if v . MinScore != 0 {
standardStr = fmt . Sprintf ( "%v-%v" , publicmethod . DecimalEs ( float64 ( v . MinScore ) / 100 , 2 ) , publicmethod . DecimalEs ( float64 ( v . MaxScore ) / 100 , 2 ) )
} else {
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 )
}
publicmethod . ResultList ( 0 , receivedValue . Page , receivedValue . PageSize , total , int64 ( len ( outData ) ) , outData , c )
}
// 根据指标栏目新增指标细则
func ( a * ApiMethod ) BasisSonTargetAddDetailed ( c * gin . Context ) {
var receivedValue basisSonTargetAddDet
c . ShouldBindJSON ( & receivedValue )
// var minScoreInt int64 = 0 //最低分
// var maxScoreInt int64 = 0 //最高分
if receivedValue . Id == "" {
publicmethod . Result ( 1 , receivedValue , c , "未知指标子栏目ID!" )
return
}
var sonTargetFatherInfo modelskpi . SonTargetFather
err := sonTargetFatherInfo . GetCont ( map [ string ] interface { } { "q_id" : receivedValue . Id } )
if err != nil {
publicmethod . Result ( 1 , err , c , "该子栏目不存在!" )
return
}
if receivedValue . Title == "" {
publicmethod . Result ( 1 , receivedValue , c , "请输入考核细则名称!" )
return
}
//判断指标细则是否符合规则
if receivedValue . ReferenceScore == "" {
publicmethod . Result ( 1 , receivedValue , c , "请输入考核细则相关考核标准!" )
return
} else {
scoreAry := strings . Split ( receivedValue . ReferenceScore , "-" )
scoreLen := len ( scoreAry )
if scoreLen < 1 {
publicmethod . Result ( 1 , receivedValue , c , "考核标准不符合要求!请仔细填写!" )
return
}
if scoreLen == 1 {
maxScore , maxErr := strconv . ParseFloat ( scoreAry [ 0 ] , 64 )
if maxErr != nil {
publicmethod . Result ( 1 , maxErr , c , "考核标准不符合要求!请仔细填写!" )
return
}
var maxIntErr error
_ , maxIntErr = strconv . ParseInt ( strconv . FormatFloat ( maxScore * 100 , 'f' , - 1 , 64 ) , 10 , 64 )
if maxIntErr != nil {
publicmethod . Result ( 1 , maxIntErr , c , "考核标准不符合要求!请仔细填写!" )
return
}
} else {
minScore , minErr := strconv . ParseFloat ( scoreAry [ 0 ] , 64 )
if minErr != nil {
publicmethod . Result ( 1 , minErr , c , "考核标准不符合要求!请仔细填写!" )
return
}
maxScore , maxErr := strconv . ParseFloat ( scoreAry [ scoreLen - 1 ] , 64 )
if maxErr != nil {
publicmethod . Result ( 1 , maxErr , c , "考核标准不符合要求!请仔细填写!" )
return
}
var minIntErr error
_ , minIntErr = strconv . ParseInt ( strconv . FormatFloat ( minScore * 100 , 'f' , - 1 , 64 ) , 10 , 64 )
if minIntErr != nil {
publicmethod . Result ( 1 , minIntErr , c , "考核标准不符合要求!请仔细填写!" )
return
}
var maxIntErr error
_ , maxIntErr = strconv . ParseInt ( strconv . FormatFloat ( maxScore * 100 , 'f' , - 1 , 64 ) , 10 , 64 )
if maxIntErr != nil {
publicmethod . Result ( 1 , maxIntErr , c , "考核标准不符合要求!请仔细填写!" )
return
}
}
}
//获取子栏目接受考核部门
var sonAboutDeparment [ ] string
var aboutTarDepList [ ] int64
aboutTDErr := overall . CONSTANT_DB_KPI . Model ( & modelskpi . TargetDepartment { } ) . Distinct ( "`department_id`" ) . Where ( "`state` = 1 AND `level` = 1 AND `target_id` = ? AND `target_sun_id` = ?" , sonTargetFatherInfo . ParentId , sonTargetFatherInfo . Id ) . Find ( & aboutTarDepList ) . Error
if aboutTDErr == nil {
for _ , atdv := range aboutTarDepList {
sonAboutDeparment = append ( sonAboutDeparment , strconv . FormatInt ( atdv , 10 ) )
}
}
var qualEvalCont QualEvalSunList
qualEvalCont . Title = receivedValue . Title //考核内容
qualEvalCont . Content = receivedValue . Content //备注说明
qualEvalCont . Unit = receivedValue . Unit //单位
qualEvalCont . ReferenceScore = receivedValue . ReferenceScore //考核标准
qualEvalCont . Cycles = receivedValue . Cycles //1:班;2:天;3:周;4:月;5:季度;6:年
qualEvalCont . CycleAttres = receivedValue . CycleAttres //辅助计数
qualEvalCont . Operator = receivedValue . Operator //考核执行人
qualEvalCont . AddOrReduce = receivedValue . AddOrReduce //操作类型 1:减少;2:增加;3:用户自定义
qualEvalCont . CensorType = receivedValue . CensorType //检查方式(1:现场检查;2:资料检查;3:事件触发)
qualEvalCont . CensorCont = receivedValue . CensorCont //客观证据
qualEvalCont . CensorRate = receivedValue . CensorRate //检查频次
//判断指标细则是否已经存在
var judgeDetaCont modelskpi . DetailedTarget
judgeDetaErr := judgeDetaCont . GetCont ( map [ string ] interface { } { "`dt_parentid`" : sonTargetFatherInfo . ParentId , "`dt_parentid_sun`" : sonTargetFatherInfo . Id , "`dt_title`" : receivedValue . Title } )
if judgeDetaErr == nil {
judgeDetaErr = editDetaAdd ( sonTargetFatherInfo . ParentId , sonTargetFatherInfo . Id , qualEvalCont , judgeDetaCont , sonAboutDeparment )
} else {
judgeDetaErr = addDetaInfo ( sonTargetFatherInfo . ParentId , sonTargetFatherInfo . Id , qualEvalCont , sonAboutDeparment )
}
if judgeDetaErr != nil {
publicmethod . Result ( 106 , judgeDetaErr , c )
return
}
publicmethod . Result ( 0 , judgeDetaErr , c )
}
// 根据指标和部门获取相关岗位
func ( a * ApiMethod ) BasisTargetDearpetmentGetPost ( c * gin . Context ) {
var receivedValue bgdgp
c . ShouldBindJSON ( & receivedValue )
if receivedValue . TargetId == "" {
publicmethod . Result ( 101 , receivedValue , c )
return
}
if receivedValue . DepartmentId == "" {
publicmethod . Result ( 101 , receivedValue , c )
return
}
if receivedValue . Level == 0 {
receivedValue . Level = 2
}
var postId [ ] int64
gormDb := overall . CONSTANT_DB_KPI . Model ( & modelskpi . TargetDepartment { } ) . Distinct ( "post_id" ) . Where ( "`state` = 1 AND `level` = ? AND `target_id` = ? AND `department_id` = ?" , receivedValue . Level , receivedValue . TargetId , receivedValue . DepartmentId )
if receivedValue . TargetSunId != "" {
gormDb = gormDb . Where ( "`target_sun_id` = ?" , receivedValue . TargetSunId )
}
if receivedValue . TargetBylaws != "" {
gormDb = gormDb . Where ( "`target_bylaws` = ?" , receivedValue . TargetBylaws )
}
err := gormDb . Find ( & postId ) . Error
if err != nil || len ( postId ) < 1 {
publicmethod . Result ( 107 , err , c )
return
}
var postList [ ] modelshr . Position
hrErr := overall . CONSTANT_DB_HR . Model ( & modelshr . Position { } ) . Select ( "`id`,`name`" ) . Where ( "`id` IN ?" , postId ) . Find ( & postList ) . Error
if hrErr != nil || len ( postList ) < 1 {
publicmethod . Result ( 107 , hrErr , c )
return
}
outdata := publicmethod . MapOut [ string ] ( )
outdata [ "postid" ] = postId
outdata [ "postlist" ] = postList
publicmethod . Result ( 0 , outdata , c )
}
// 获取部门指标岗位提交人
func ( a * ApiMethod ) BasisTaegetDeparmentReport ( c * gin . Context ) {
var receivedValue btdgr
c . ShouldBindJSON ( & receivedValue )
if receivedValue . TargetId == "" {
publicmethod . Result ( 101 , receivedValue , c )
return
}
// if receivedValue.DepartmentId == "" {
// publicmethod.Result(101, receivedValue, c)
// return
// }
if receivedValue . Level == 0 {
receivedValue . Level = 2
}
var userKey [ ] int64
gormDb := overall . CONSTANT_DB_KPI . Model ( & modelskpi . TargetReport { } ) . Distinct ( "man_key" ) . Where ( "`state` = 1 AND `type` = ? AND `target_id` = ?" , receivedValue . Level , receivedValue . TargetId )
if receivedValue . DepartmentId != "" {
gormDb = gormDb . Where ( "`department_id` = ?" , receivedValue . DepartmentId )
}
if receivedValue . TargetSunId != "" {
gormDb = gormDb . Where ( "`target_sun_id` = ?" , receivedValue . TargetSunId )
}
if receivedValue . TargetBylaws != "" {
gormDb = gormDb . Where ( "`target_bylaws` = ?" , receivedValue . TargetBylaws )
}
if receivedValue . PostId != "" {
gormDb = gormDb . Where ( "`post_id` = ?" , receivedValue . PostId )
}
err := gormDb . Find ( & userKey ) . Error
if err != nil || len ( userKey ) < 1 {
publicmethod . Result ( 107 , err , c )
return
}
var peopleList [ ] modelshr . UserPostDuties
hrErr := overall . CONSTANT_DB_HR . Model ( & modelshr . UserPostDuties { } ) . Where ( "`key` IN ?" , userKey ) . Find ( & peopleList ) . Error
if hrErr != nil || len ( peopleList ) < 1 {
publicmethod . Result ( 107 , hrErr , c )
return
}
outdata := publicmethod . MapOut [ string ] ( )
outdata [ "postid" ] = userKey
outdata [ "peoplelist" ] = peopleList
publicmethod . Result ( 0 , outdata , c )
}
// 修改子栏目标题名称级考核关联部门及提报人
func ( a * ApiMethod ) EditSonTargetDepartmentReport ( c * gin . Context ) {
var receivedValue editTarDepartReport
c . ShouldBindJSON ( & receivedValue )
if receivedValue . TargetSunId == "" {
publicmethod . Result ( 101 , receivedValue , c )
return
}
var sonTargetCont modelskpi . QualitativeTarget
err := sonTargetCont . GetCont ( map [ string ] interface { } { "q_id" : receivedValue . TargetSunId } )
if err != nil {
publicmethod . Result ( 107 , receivedValue , c )
return
}
if receivedValue . Title != "" && receivedValue . Title != sonTargetCont . Title {
var judgeIsFalse modelskpi . QualitativeTarget
judgeErr := judgeIsFalse . GetCont ( map [ string ] interface { } { "q_title" : sonTargetCont . Id , "q_parent_id" : sonTargetCont . ParentId } , "q_id" )
if judgeErr == nil {
publicmethod . Result ( 103 , receivedValue , c )
return
}
saveData := publicmethod . MapOut [ string ] ( )
saveData [ "q_title" ] = receivedValue . Title
saveData [ "q_time" ] = time . Now ( ) . Unix ( )
err = sonTargetCont . EiteCont ( map [ string ] interface { } { "q_id" : receivedValue . TargetSunId } , saveData )
}
if err != nil {
publicmethod . Result ( 106 , receivedValue , c )
return
}
departmentAry := receivedValue . AcceptDepartmentId
operatorList := receivedValue . Operator
if len ( departmentAry ) < 1 {
var sonDepartmentAbouttargetId [ ] int64
deparErr := overall . CONSTANT_DB_KPI . Model ( & modelskpi . TargetDepartment { } ) . Distinct ( "department_id" ) . Where ( "`state` = 1 AND `level` = 1 AND `target_id` = ? " , sonTargetCont . ParentId ) . Find ( & sonDepartmentAbouttargetId ) . Error
if deparErr == nil && len ( sonDepartmentAbouttargetId ) > 0 {
for _ , sdv := range sonDepartmentAbouttargetId {
departmentAry = append ( departmentAry , strconv . FormatInt ( sdv , 10 ) )
}
}
}
if len ( operatorList ) < 1 {
var sonReportAbouttargetId [ ] int64
deparErr := overall . CONSTANT_DB_KPI . Model ( & modelskpi . TargetReport { } ) . Distinct ( "man_key" ) . Where ( "`state` = 1 AND `type` = 1 AND `target_id` = ? " , sonTargetCont . ParentId ) . Find ( & sonReportAbouttargetId ) . Error
if deparErr == nil && len ( sonReportAbouttargetId ) > 0 {
for _ , srv := range sonReportAbouttargetId {
operatorList = append ( operatorList , strconv . FormatInt ( srv , 10 ) )
}
}
}
//获取该指标下所有细则
var detaildId [ ] int64
err = overall . CONSTANT_DB_KPI . Model ( & modelskpi . DetailedTarget { } ) . Select ( "dt_id" ) . Where ( "`dt_state` = 1 AND `dt_parentid` = ? AND `dt_parentid_sun` = ?" , sonTargetCont . ParentId , sonTargetCont . Id ) . Find ( & detaildId ) . Error
if err == nil && len ( detaildId ) > 0 {
for _ , v := range detaildId {
if len ( departmentAry ) > 0 {
syncSeting . Add ( 1 )
go handleDetarildTargetDepart ( sonTargetCont . ParentId , sonTargetCont . Id , v , departmentAry , 1 , 1 )
}
if len ( operatorList ) > 0 {
syncSeting . Add ( 1 )
go handleDetarildTargetRepart ( sonTargetCont . ParentId , sonTargetCont . Id , v , operatorList , 1 , 1 )
}
syncSeting . Wait ( )
}
}
//获取该子栏目所有的接受考核部门
saveData := publicmethod . MapOut [ string ] ( )
saveData [ "q_depart" ] = strings . Join ( departmentAry , "," )
saveData [ "q_time" ] = time . Now ( ) . Unix ( )
err = sonTargetCont . EiteCont ( map [ string ] interface { } { "q_id" : receivedValue . TargetSunId } , saveData )
//修改指标的关联部门和关联人
var targetAboutDepartnebt [ ] int64
overall . CONSTANT_DB_KPI . Model ( & modelskpi . TargetDepartment { } ) . Distinct ( "department_id" ) . Where ( "`state` = 1 AND `level` = 1 AND `target_id` = ? " , sonTargetCont . ParentId ) . Find ( & targetAboutDepartnebt )
var targetAboutReport [ ] int64
overall . CONSTANT_DB_KPI . Model ( & modelskpi . TargetReport { } ) . Distinct ( "man_key" ) . Where ( "`state` = 1 AND `type` = 1 AND `target_id` = ? " , sonTargetCont . ParentId ) . Find ( & targetAboutReport )
if len ( targetAboutDepartnebt ) > 0 || len ( targetAboutReport ) > 0 {
tarSaveData := publicmethod . MapOut [ string ] ( )
if len ( targetAboutDepartnebt ) > 0 {
var departStr [ ] string
for _ , dsv := range targetAboutDepartnebt {
departStr = append ( departStr , strconv . FormatInt ( dsv , 10 ) )
}
tarSaveData [ "et_relevant_departments" ] = strings . Join ( departStr , "," )
}
if len ( targetAboutReport ) > 0 {
var reportStr [ ] string
for _ , dsvr := range targetAboutReport {
reportStr = append ( reportStr , strconv . FormatInt ( dsvr , 10 ) )
}
tarSaveData [ "et_report" ] = strings . Join ( reportStr , "," )
}
if len ( tarSaveData ) > 0 {
tarSaveData [ "et_time" ] = time . Now ( ) . Unix ( )
var evalTarCont modelskpi . EvaluationTarget
evalTarCont . EiteCont ( map [ string ] interface { } { "`et_id`" : sonTargetCont . ParentId } , tarSaveData )
}
}
publicmethod . Result ( 0 , err , c )
}
// 获取子栏目基础信息
func ( a * ApiMethod ) GetSonTargetCont ( c * gin . Context ) {
var receivedValue publicmethod . PublicId
err := c . ShouldBindJSON ( & receivedValue )
if err != nil {
publicmethod . Result ( 100 , receivedValue , c )
return
}
if receivedValue . Id == "" {
publicmethod . Result ( 101 , receivedValue , c )
return
}
where := publicmethod . MapOut [ string ] ( )
where [ "q_id" ] = receivedValue . Id
var sonTargetCont modelskpi . QualitativeTarget
err = sonTargetCont . GetCont ( where , "q_title" , "q_parent_id" )
if err != nil {
publicmethod . Result ( 107 , receivedValue , c )
return
}
//获取关联部门
var targetAboutDepartnebt [ ] int64
overall . CONSTANT_DB_KPI . Model ( & modelskpi . TargetDepartment { } ) . Distinct ( "department_id" ) . Where ( "`state` = 1 AND `level` = 1 AND `target_id` = ? AND `target_sun_id` = ?" , sonTargetCont . ParentId , receivedValue . Id ) . Find ( & targetAboutDepartnebt )
//获取关联提报人
var targetAboutReport [ ] int64
overall . CONSTANT_DB_KPI . Model ( & modelskpi . TargetReport { } ) . Distinct ( "man_key" ) . Where ( "`state` = 1 AND `type` = 1 AND `target_id` = ? AND `target_sun_id` = ?" , sonTargetCont . ParentId , receivedValue . Id ) . Find ( & targetAboutReport )
//部门列表
var departContList [ ] modelshr . AdministrativeOrganization
overall . CONSTANT_DB_HR . Model ( & modelshr . AdministrativeOrganization { } ) . Select ( "`id`,`name`" ) . Where ( "`id` IN ?" , targetAboutDepartnebt ) . Find ( & departContList )
//人员列表
var reportContList [ ] modelshr . PersonArchives
overall . CONSTANT_DB_HR . Model ( & modelshr . PersonArchives { } ) . Select ( "`key`,`name`" ) . Where ( "`key` IN ?" , targetAboutReport ) . Find ( & reportContList )
var departArt [ ] outCont
for _ , darv := range departContList {
var departContArt outCont
departContArt . Id = strconv . FormatInt ( darv . Id , 10 )
departContArt . Name = darv . Name
departArt = append ( departArt , departContArt )
}
var reportArt [ ] outCont
for _ , rclv := range reportContList {
var reportContArt outCont
reportContArt . Id = strconv . FormatInt ( rclv . Key , 10 )
reportContArt . Name = rclv . Name
reportArt = append ( reportArt , reportContArt )
}
outData := publicmethod . MapOut [ string ] ( )
outData [ "title" ] = sonTargetCont . Title
outData [ "departmentid" ] = targetAboutDepartnebt
outData [ "userkey" ] = targetAboutReport
outData [ "departmentcont" ] = departArt
outData [ "usercont" ] = reportArt
publicmethod . Result ( 0 , outData , c )
}
// 删除子栏目
func ( a * ApiMethod ) DelSonTarget ( c * gin . Context ) {
var receivedValue publicmethod . PublicId
err := c . ShouldBindJSON ( & receivedValue )
if err != nil {
publicmethod . Result ( 100 , receivedValue , c )
return
}
if receivedValue . Id == "" {
publicmethod . Result ( 101 , receivedValue , c )
return
}
where := publicmethod . MapOut [ string ] ( )
where [ "q_id" ] = receivedValue . Id
var sonTargetCont modelskpi . QualitativeTarget
err = sonTargetCont . GetCont ( where , "q_id" , "q_parent_id" )
if err != nil {
publicmethod . Result ( 107 , err , c )
return
}
//预留判断该指标是否在使用中
delTime := time . Now ( ) . Unix ( )
//软删除所有此子栏目下的指标细则
syncSeting . Add ( 1 )
go softDetaildeCont ( sonTargetCont . ParentId , sonTargetCont . Id , delTime )
//软删除所有此子栏目相关的联部门
syncSeting . Add ( 1 )
go softDelTargetDepartment ( map [ string ] interface { } { "target_id" : sonTargetCont . ParentId , "target_sun_id" : sonTargetCont . Id , "`state`" : 1 } , delTime )
//软删除所有此子栏目相关联的提报人
syncSeting . Add ( 1 )
go softDelTargetReport ( map [ string ] interface { } { "`target_id`" : sonTargetCont . ParentId , "`target_sun_id`" : sonTargetCont . Id , "`state`" : 1 } , delTime )
//软删除此栏目
var delTargetSon modelskpi . QualitativeTarget
err = delTargetSon . EiteCont ( map [ string ] interface { } { "`q_id`" : sonTargetCont . Id } , map [ string ] interface { } { "`q_state`" : 3 , "`q_time`" : delTime } )
syncSeting . Wait ( )
if err != nil {
publicmethod . Result ( 106 , err , c )
return
}
publicmethod . Result ( 0 , err , c )
}
// 软删除所有此子栏目下的指标细则
func softDetaildeCont ( targetId , sonTargetId , delTime int64 ) {
defer syncSeting . Done ( )
var detaildeCont modelskpi . DetailedTarget
detaildeCont . EiteCont ( map [ string ] interface { } { "dt_parentid" : targetId , "dt_parentid_sun" : sonTargetId , "dt_state" : 1 } , map [ string ] interface { } { "dt_state" : 3 , "dt_time" : delTime } )
}
// 软删除所有此子栏目相关联的提报人
func softDelTargetReport ( where interface { } , delTime int64 ) {
defer syncSeting . Done ( )
var delTargetReport modelskpi . TargetReport
delTargetReport . EiteCont ( where , map [ string ] interface { } { "`state`" : 3 , "`time`" : delTime } )
}
// 软删除所有此子栏目相关的联部门
func softDelTargetDepartment ( where interface { } , delTime int64 ) {
defer syncSeting . Done ( )
var delTargetDepartment modelskpi . TargetDepartment
delTargetDepartment . EiteCont ( where , map [ string ] interface { } { "`state`" : 3 , "`time`" : delTime } )
}
// 获取单一指标细则内容
func ( a * ApiMethod ) GetOneDetailedTarget ( c * gin . Context ) {
var receivedValue publicmethod . PublicId
err := c . ShouldBindJSON ( & receivedValue )
if err != nil {
publicmethod . Result ( 100 , receivedValue , c )
return
}
if receivedValue . Id == "" {
publicmethod . Result ( 101 , receivedValue , c )
return
}
where := publicmethod . MapOut [ string ] ( )
where [ "dt_id" ] = receivedValue . Id
var detailedTargetCont modelskpi . DetailedTarget
err = detailedTargetCont . GetCont ( where )
if err != nil {
publicmethod . Result ( 107 , err , c )
return
}
var outDataCont NewOutPutDetailedTarget
outDataCont . Id = strconv . FormatInt ( detailedTargetCont . Id , 10 )
outDataCont . Title = detailedTargetCont . Title //考核内容
outDataCont . Content = detailedTargetCont . Content //备注说明
outDataCont . Unit = detailedTargetCont . Company //单位
biaoZhun := ""
if detailedTargetCont . MinScore != 0 {
biaoZhun = fmt . Sprintf ( "%v-%v" , detailedTargetCont . MinScore , detailedTargetCont . MaxScore )
} else {
biaoZhun = fmt . Sprintf ( "%v" , detailedTargetCont . MaxScore )
}
outDataCont . ReferenceScore = biaoZhun //考核标准
outDataCont . Cycles = detailedTargetCont . Cycles //1:班;2:天;3:周;4:月;5:季度;6:年
outDataCont . CycleAttres = detailedTargetCont . CycleAttres //辅助计数
outDataCont . Operator , outDataCont . ReportManList , _ = getDetailedReport ( detailedTargetCont . ParentId , detailedTargetCont . ParentIdSun , detailedTargetCont . Id , 1 ) //考核执行人
outDataCont . AddOrReduce = detailedTargetCont . AddReduce //操作类型 1:减少;2:增加;3:用户自定义
outDataCont . CensorType = strings . Split ( detailedTargetCont . CensorType , "," ) //检查方式(1:现场检查;2:资料检查;3:事件触发)
outDataCont . CensorCont = detailedTargetCont . CensorCont //客观证据
outDataCont . CensorRate = detailedTargetCont . CensorRate //检查频次
outDataCont . DepartmentList , _ , _ = getDetailedDepartment ( detailedTargetCont . ParentId , detailedTargetCont . ParentIdSun , detailedTargetCont . Id , 1 ) //接受考核的部门
publicmethod . Result ( 0 , outDataCont , c )
}
// 获取指标细则接受考核部门
func getDetailedDepartment ( targetId , targetSunId , bylawsId int64 , class int ) ( departmentStr [ ] string , departmentInfo [ ] departOutcome , err error ) {
if class == 0 {
class = 1
}
var departmentId [ ] int64
err = overall . CONSTANT_DB_KPI . Model ( & modelskpi . TargetDepartment { } ) . Distinct ( "`department_id`" ) . Where ( "`state` = 1 AND `level` = ? AND `target_id` = ? AND `target_sun_id` = ? AND `target_bylaws` = ?" , class , targetId , targetSunId , bylawsId ) . Find ( & departmentId ) . Error
if err != nil || len ( departmentId ) < 1 {
return
}
var orgList [ ] modelshr . AdministrativeOrganization
gormDb := overall . CONSTANT_DB_HR . Model ( & modelshr . AdministrativeOrganization { } ) . Select ( "`id`,`name`,`superior`,`ispower`" )
if len ( departmentId ) > 1 {
gormDb = gormDb . Where ( "`id` IN ?" , departmentId )
} else {
gormDb = gormDb . Where ( "`id` = ?" , departmentId )
}
err = gormDb . Find ( & orgList ) . Error
if err != nil || len ( orgList ) < 1 {
return
}
for _ , v := range orgList {
departIdStr := strconv . FormatInt ( v . Id , 10 )
if publicmethod . IsInTrue [ string ] ( departIdStr , departmentStr ) == false {
var departCont departOutcome
departCont . Id = departIdStr
departCont . Name = v . Name
departCont . Superior = strconv . FormatInt ( v . Superior , 10 ) //上级
departCont . Ispower = v . IsPower //是否为主部门
departmentStr = append ( departmentStr , departIdStr )
departmentInfo = append ( departmentInfo , departCont )
}
}
return
}
// 获取指标细则执行人
func getDetailedReport ( targetId , targetSunId , bylawsId int64 , class int ) ( userKey [ ] string , userCont [ ] printReportCont , err error ) {
if class == 0 {
class = 1
}
var userKeyInt [ ] int64
err = overall . CONSTANT_DB_KPI . Model ( & modelskpi . TargetReport { } ) . Distinct ( "`man_key`" ) . Where ( "`state` = 1 AND `type` = ? AND `target_id` = ? AND `target_sun_id` = ? AND `target_bylaws` = ?" , class , targetId , targetSunId , bylawsId ) . Find ( & userKeyInt ) . Error
if err != nil || len ( userKeyInt ) < 1 {
return
}
var userContList [ ] modelshr . PersonArchives
gormDb := overall . CONSTANT_DB_HR . Model ( & modelshr . PersonArchives { } ) . Select ( "`id`,`number`,`name`,`icon`,`company`,`maindeparment`" )
if len ( userKeyInt ) > 1 {
gormDb = gormDb . Where ( "`key` IN ?" , userKeyInt )
} else {
gormDb = gormDb . Where ( "`key` = ?" , userKeyInt )
}
err = gormDb . Find ( & userContList ) . Error
if err != nil || len ( userContList ) < 1 {
return
}
for _ , v := range userContList {
userKeyStr := strconv . FormatInt ( v . Id , 10 )
if publicmethod . IsInTrue [ string ] ( userKeyStr , userKey ) == false {
var userInfo printReportCont
userInfo . Id = userKeyStr
userInfo . Name = v . Name
var groupCont modelshr . AdministrativeOrganization
groupCont . GetCont ( map [ string ] interface { } { "`id`" : v . Company } , "`name`" )
userInfo . GroupName = groupCont . Name
var deparHrCont modelshr . AdministrativeOrganization
deparHrCont . GetCont ( map [ string ] interface { } { "`id`" : v . Company } , "`name`" )
userInfo . DepartmentName = deparHrCont . Name
userInfo . Icon = v . Icon
userInfo . Number = v . Number
userKey = append ( userKey , userKeyStr )
userCont = append ( userCont , userInfo )
}
}
return
}
// 编辑单一指标细则内容
func ( a * ApiMethod ) EditOneDetailedTarget ( c * gin . Context ) {
var receivedValue editOneDetailedTargetInfo
c . ShouldBindJSON ( & receivedValue )
var judgeDetaCont modelskpi . DetailedTarget
judgeDetaErr := judgeDetaCont . GetCont ( map [ string ] interface { } { "`dt_id`" : receivedValue . Id } )
if judgeDetaErr != nil {
publicmethod . Result ( 107 , receivedValue , c )
return
}
if receivedValue . Title == "" {
publicmethod . Result ( 1 , receivedValue , c , "请输入考核细则名称!" )
return
}
//判断指标细则是否符合规则
if receivedValue . ReferenceScore == "" {
publicmethod . Result ( 1 , receivedValue , c , "请输入考核细则相关考核标准!" )
return
} else {
scoreAry := strings . Split ( receivedValue . ReferenceScore , "-" )
scoreLen := len ( scoreAry )
if scoreLen < 1 {
publicmethod . Result ( 1 , receivedValue , c , "考核标准不符合要求!请仔细填写!" )
return
}
if scoreLen == 1 {
maxScore , maxErr := strconv . ParseFloat ( scoreAry [ 0 ] , 64 )
if maxErr != nil {
publicmethod . Result ( 1 , maxErr , c , "考核标准不符合要求!请仔细填写!" )
return
}
var maxIntErr error
_ , maxIntErr = strconv . ParseInt ( strconv . FormatFloat ( maxScore * 100 , 'f' , - 1 , 64 ) , 10 , 64 )
if maxIntErr != nil {
publicmethod . Result ( 1 , maxIntErr , c , "考核标准不符合要求!请仔细填写!" )
return
}
} else {
minScore , minErr := strconv . ParseFloat ( scoreAry [ 0 ] , 64 )
if minErr != nil {
publicmethod . Result ( 1 , minErr , c , "考核标准不符合要求!请仔细填写!" )
return
}
maxScore , maxErr := strconv . ParseFloat ( scoreAry [ scoreLen - 1 ] , 64 )
if maxErr != nil {
publicmethod . Result ( 1 , maxErr , c , "考核标准不符合要求!请仔细填写!" )
return
}
var minIntErr error
_ , minIntErr = strconv . ParseInt ( strconv . FormatFloat ( minScore * 100 , 'f' , - 1 , 64 ) , 10 , 64 )
if minIntErr != nil {
publicmethod . Result ( 1 , minIntErr , c , "考核标准不符合要求!请仔细填写!" )
return
}
var maxIntErr error
_ , maxIntErr = strconv . ParseInt ( strconv . FormatFloat ( maxScore * 100 , 'f' , - 1 , 64 ) , 10 , 64 )
if maxIntErr != nil {
publicmethod . Result ( 1 , maxIntErr , c , "考核标准不符合要求!请仔细填写!" )
return
}
}
}
if len ( receivedValue . DepartmentList ) < 1 {
//获取子栏目接受考核部门
var aboutTarDepList [ ] int64
aboutTDErr := overall . CONSTANT_DB_KPI . Model ( & modelskpi . TargetDepartment { } ) . Distinct ( "`department_id`" ) . Where ( "`state` = 1 AND `level` = 1 AND `target_id` = ? AND `target_sun_id` = ?" , judgeDetaCont . ParentId , judgeDetaCont . ParentIdSun ) . Find ( & aboutTarDepList ) . Error
if aboutTDErr == nil {
for _ , atdv := range aboutTarDepList {
receivedValue . DepartmentList = append ( receivedValue . DepartmentList , strconv . FormatInt ( atdv , 10 ) )
}
}
}
if len ( receivedValue . QualEvalSunList . Operator ) < 1 {
var aboutTarDepRepList [ ] int64
aboutReTDErr := overall . CONSTANT_DB_KPI . Model ( & modelskpi . TargetReport { } ) . Distinct ( "`man_key`" ) . Where ( "`state` = 1 AND `type` = 1 AND `target_id` = ? AND `target_sun_id` = ?" , judgeDetaCont . ParentId , judgeDetaCont . ParentIdSun ) . Find ( & aboutTarDepRepList ) . Error
if aboutReTDErr == nil {
for _ , atdv := range aboutTarDepRepList {
receivedValue . QualEvalSunList . Operator = append ( receivedValue . QualEvalSunList . Operator , strconv . FormatInt ( atdv , 10 ) )
}
}
}
err := editDetaAdd ( judgeDetaCont . ParentId , judgeDetaCont . ParentIdSun , receivedValue . QualEvalSunList , judgeDetaCont , receivedValue . DepartmentList )
if err != nil {
publicmethod . Result ( 106 , receivedValue , c )
return
}
publicmethod . Result ( 0 , err , c )
}
// 删除单一指标细则
func ( a * ApiMethod ) DelOneDetailedTarget ( c * gin . Context ) {
var receivedValue publicmethod . PublicId
err := c . ShouldBindJSON ( & receivedValue )
if err != nil {
publicmethod . Result ( 100 , receivedValue , c )
return
}
if receivedValue . Id == "" {
publicmethod . Result ( 101 , receivedValue , c )
return
}
where := publicmethod . MapOut [ string ] ( )
where [ "dt_id" ] = receivedValue . Id
var detailedTargetCont modelskpi . DetailedTarget
err = detailedTargetCont . GetCont ( where )
if err != nil {
publicmethod . Result ( 107 , err , c )
return
}
delTime := time . Now ( ) . Unix ( )
err = detailedTargetCont . EiteCont ( where , map [ string ] interface { } { "dt_state" : 3 , "dt_time" : delTime } )
if err != nil {
publicmethod . Result ( 106 , err , c )
return
}
//软删除所有此子栏目相关的联部门
syncSeting . Add ( 1 )
go softDelTargetDepartment ( map [ string ] interface { } { "target_id" : detailedTargetCont . ParentId , "`target_sun_id`" : detailedTargetCont . ParentIdSun , "target_bylaws" : detailedTargetCont . Id , "`state`" : 1 } , delTime )
//软删除所有此子栏目相关联的提报人
syncSeting . Add ( 1 )
go softDelTargetReport ( map [ string ] interface { } { "`target_id`" : detailedTargetCont . ParentId , "`target_sun_id`" : detailedTargetCont . ParentIdSun , "target_bylaws" : detailedTargetCont . Id , "`state`" : 1 } , delTime )
syncSeting . Wait ( )
publicmethod . Result ( 0 , err , c )
}
// 添加部门指标
func ( a * ApiMethod ) AddDepartmentTarget ( c * gin . Context ) {
var receivedValue addTargetContDepart
err := c . ShouldBindJSON ( & receivedValue )
if err != nil {
publicmethod . Result ( 100 , err , c )
return
}
if receivedValue . Name == "" {
publicmethod . Result ( 101 , err , c , "请输入指标名称!!" )
return
}
if receivedValue . Nature == 0 {
receivedValue . Nature = 1
}
if receivedValue . Share == 0 {
receivedValue . Share = 1
} else {
if receivedValue . Share > 1 {
if len ( receivedValue . AcceptDepartmentId ) < 1 {
publicmethod . Result ( 101 , err , c , "您选择了此指标为指定部门使用!但您未指定具体使用部门!请指定相关使用部门!" )
return
}
}
}
if receivedValue . Unit == "" {
publicmethod . Result ( 101 , err , c , "请输入计量单位!" )
return
}
if receivedValue . Cycles == 0 {
receivedValue . Cycles = 4
}
if receivedValue . CycleAttres == 0 {
receivedValue . CycleAttres = 1
}
if receivedValue . ScoringMethod == 0 {
receivedValue . ScoringMethod = 1
}
JudgeIsTrue := publicmethod . MapOut [ string ] ( )
err = overall . CONSTANT_DB_KPI . Model ( & modelskpi . EvaluationTarget { } ) . Select ( "et_title" ) . Where ( "`et_title` = ? AND `et_type` = ? AND `et_dimension` = ?" , receivedValue . Name , receivedValue . Nature , receivedValue . Dimension ) . First ( & JudgeIsTrue ) . Error
if err == nil {
publicmethod . Result ( 101 , err , c , "此考核指标已经存在!请不要重复添加!" )
return
}
var uuId int64 = 0
snowflakeId , snowflakeErr := snowflake . NewWorker ( 1 )
if snowflakeErr != nil {
uuId = publicmethod . TableNumber ( )
} else {
uuId = snowflakeId . GetId ( )
}
var saveData modelskpi . EvaluationTarget
saveData . Title = receivedValue . Name //指标名称"`
saveData . Type = receivedValue . Nature //1:定性考核;2:定量考核"`
saveData . State = 1 //状态(1:启用;2:禁用;3:删除)"`
saveData . AddTime = time . Now ( ) . Unix ( ) //制定时间"`
saveData . Share = 1 //1:共用;2:私用"`
saveData . RelevantDepartments = strings . Join ( receivedValue . AcceptDepartmentId , "," ) //相关部门"`
dimensionId , _ := strconv . ParseInt ( receivedValue . Dimension , 10 , 64 )
saveData . Dimension = dimensionId //维度"`
saveData . Key = uuId //UUID"`
saveData . Report = strings . Join ( receivedValue . Operator , "," ) //上报人"`
saveData . Uniteing = receivedValue . Unit //计量单位"`
saveData . Cycles = receivedValue . Cycles //1:班;2:天;3:周;4:月;5:季度;6:年"`
saveData . CycleAttres = receivedValue . CycleAttres //辅助计数"`
saveData . VisibleRange = strings . Join ( receivedValue . VisibleRangeDepart , "," ) //可见范围"`
saveData . VisibleRangeGroup = strings . Join ( receivedValue . VisibleRangeGroup , "," ) //可见范围(集团)"`
saveData . ScoringMethod = receivedValue . ScoringMethod //计分方式(1:自动;2:手动)"`
err = overall . CONSTANT_DB_KPI . Create ( & saveData ) . Error
if err != nil {
publicmethod . Result ( 104 , err , c )
return
}
if len ( receivedValue . AcceptDepartmentId ) > 0 {
syncSeting . Add ( 1 )
go handleDetarildTargetDepart ( saveData . Id , 0 , 0 , receivedValue . AcceptDepartmentId , 1 , receivedValue . Nature )
}
if len ( receivedValue . Operator ) > 0 {
syncSeting . Add ( 1 )
go handleDetarildTargetRepart ( saveData . Id , 0 , 0 , receivedValue . Operator , 1 , receivedValue . Nature )
}
syncSeting . Wait ( )
publicmethod . Result ( 0 , err , c )
}
/ *
获取关联部门
@ where 查询条件
@ level 1 : 部门级 ; 2 : 岗位级
* /
func GetAboutDepartment ( where interface { } , level int ) ( departmentId [ ] int64 , departmentIdStr [ ] string , err error ) {
err = overall . CONSTANT_DB_KPI . Model ( & modelskpi . TargetDepartment { } ) . Distinct ( "`department_id`" ) . Where ( where ) . Where ( "`level` = ?" , level ) . Find ( & departmentId ) . Error
if err == nil {
for _ , v := range departmentId {
departmentIdStr = append ( departmentIdStr , strconv . FormatInt ( v , 10 ) )
}
}
return
}
/ *
获取关联提报人
@ where 查询条件
@ level 1 : 公司级 ; 2 : 部门级
* /
func GetAboutReport ( where interface { } , level int ) ( userKey [ ] int64 , userKeyStr [ ] string , err error ) {
err = overall . CONSTANT_DB_KPI . Model ( & modelskpi . TargetReport { } ) . Distinct ( "`man_key`" ) . Where ( where ) . Where ( "`type` = ?" , level ) . Find ( & userKey ) . Error
if err == nil {
for _ , v := range userKey {
userKeyStr = append ( userKeyStr , strconv . FormatInt ( v , 10 ) )
}
}
return
}
// 获取单一指标详细内容
func ( a * ApiMethod ) GetOneTergetInfo ( c * gin . Context ) {
var receivedValue publicmethod . PublicId
err := c . ShouldBindJSON ( & receivedValue )
if err != nil {
publicmethod . Result ( 100 , receivedValue , c )
return
}
if receivedValue . Id == "" {
publicmethod . Result ( 101 , receivedValue , c )
return
}
where := publicmethod . MapOut [ string ] ( )
where [ "et_id" ] = receivedValue . Id
var targetCont modelskpi . EvaluationTarget
err = targetCont . GetCont ( where )
if err != nil {
publicmethod . Result ( 107 , err , c )
return
}
var outCont printOneTargetCont
outCont . Id = strconv . FormatInt ( targetCont . Id , 10 )
outCont . Name = targetCont . Title
outCont . Share = targetCont . Share //1:共用;2:私用
outCont . AcceptDepartmentId = strings . Split ( targetCont . RelevantDepartments , "," ) //接受考核部门
outCont . Operator = strings . Split ( targetCont . Report , "," ) //考核执行人
outCont . Dimension = strconv . FormatInt ( targetCont . Dimension , 10 ) //维度
outCont . Nature = targetCont . Type //性质 1:定性考核;2:定量考核
outCont . Unit = targetCont . Uniteing //单位
outCont . Cycles = targetCont . Cycles //1:班;2:天;3:周;4:月;5:季度;6:年
outCont . CycleAttres = targetCont . CycleAttres //辅助计数
outCont . ScoringMethod = targetCont . ScoringMethod //计分方式(1:自动;2:手动)'
outCont . VisibleRangeGroup = strings . Split ( targetCont . VisibleRangeGroup , "," ) //可见范围(集团)
outCont . VisibleRangeDepart = strings . Split ( targetCont . VisibleRange , "," ) //可见范围(分厂)
publicmethod . Result ( 0 , outCont , c )
}
// 编辑单一部门指标
func ( a * ApiMethod ) EditOneTarget ( c * gin . Context ) {
var receivedValue printOneTargetCont
err := c . ShouldBindJSON ( & receivedValue )
if err != nil {
publicmethod . Result ( 100 , err , c )
return
}
if receivedValue . Id == "" {
publicmethod . Result ( 101 , err , c , "请输入指标ID!!" )
return
}
where := publicmethod . MapOut [ string ] ( )
where [ "et_id" ] = receivedValue . Id
var targetCont modelskpi . EvaluationTarget
err = targetCont . GetCont ( where )
if err != nil {
publicmethod . Result ( 107 , err , c )
return
}
if receivedValue . Name == "" {
publicmethod . Result ( 101 , err , c , "请输入指标名称!!" )
return
}
if receivedValue . Nature == 0 {
receivedValue . Nature = 1
}
if receivedValue . Share == 0 {
receivedValue . Share = 1
} else {
if receivedValue . Share > 1 {
if len ( receivedValue . AcceptDepartmentId ) < 1 {
publicmethod . Result ( 101 , err , c , "您选择了此指标为指定部门使用!但您未指定具体使用部门!请指定相关使用部门!" )
return
}
}
}
if receivedValue . Unit == "" {
publicmethod . Result ( 101 , err , c , "请输入计量单位!" )
return
}
if receivedValue . Cycles == 0 {
receivedValue . Cycles = 4
}
if receivedValue . CycleAttres == 0 {
receivedValue . CycleAttres = 1
}
if receivedValue . ScoringMethod == 0 {
receivedValue . ScoringMethod = 1
}
saveData := publicmethod . MapOut [ string ] ( )
if receivedValue . Name != targetCont . Title {
JudgeIsTrue := publicmethod . MapOut [ string ] ( )
err = overall . CONSTANT_DB_KPI . Model ( & modelskpi . EvaluationTarget { } ) . Select ( "et_title" ) . Where ( "`et_title` = ? AND `et_type` = ? AND `et_dimension` = ?" , receivedValue . Name , receivedValue . Nature , receivedValue . Dimension ) . First ( & JudgeIsTrue ) . Error
if err == nil {
publicmethod . Result ( 101 , err , c , "此考核指标已经存在!请不要重复添加!" )
return
} else {
saveData [ "et_title" ] = receivedValue . Name
}
}
if receivedValue . Share != targetCont . Share {
saveData [ "et_share" ] = receivedValue . Share
}
if receivedValue . Dimension != "" {
dimensionStr , _ := strconv . ParseInt ( receivedValue . Dimension , 10 , 64 )
if dimensionStr != targetCont . Dimension {
saveData [ "et_dimension" ] = dimensionStr
}
}
if receivedValue . Nature != targetCont . Type {
saveData [ "et_type" ] = receivedValue . Nature
}
if receivedValue . Unit != targetCont . Uniteing {
saveData [ "et_unit" ] = receivedValue . Nature
}
if receivedValue . Cycles != targetCont . Cycles {
saveData [ "et_cycle" ] = receivedValue . Cycles
}
if receivedValue . CycleAttres != targetCont . CycleAttres {
saveData [ "et_cycleattr" ] = receivedValue . CycleAttres
}
if receivedValue . ScoringMethod != targetCont . ScoringMethod {
saveData [ "et_scoring_method" ] = receivedValue . ScoringMethod
}
visiblerangegroup := strings . Join ( receivedValue . VisibleRangeGroup , "," )
if visiblerangegroup != targetCont . VisibleRangeGroup {
saveData [ "et_visible_group" ] = visiblerangegroup
}
visiblerange := strings . Join ( receivedValue . VisibleRangeDepart , "," )
if visiblerange != targetCont . VisibleRange {
saveData [ "et_visible_range" ] = visiblerange
}
departIsTreu := false
if len ( receivedValue . AcceptDepartmentId ) > 0 {
departWhere := publicmethod . MapOut [ string ] ( )
departWhere [ "`target_id`" ] = receivedValue . Id
departWhere [ "`state`" ] = 1
_ , departAry , _ := GetAboutDepartment ( departWhere , 1 )
departAryStr := strings . Join ( departAry , "," )
accDepart := strings . Join ( receivedValue . AcceptDepartmentId , "," )
if departAryStr != accDepart {
departIsTreu = true
saveData [ "et_relevant_departments" ] = accDepart
syncSeting . Add ( 1 )
go handleTargetDepart ( targetCont . Id , 0 , 0 , receivedValue . AcceptDepartmentId , 1 , targetCont . Type )
}
}
reportIsTrue := false
if len ( receivedValue . Operator ) > 0 {
reportWhere := publicmethod . MapOut [ string ] ( )
reportWhere [ "`target_id`" ] = receivedValue . Id
reportWhere [ "`state`" ] = 1
_ , report , _ := GetAboutReport ( reportWhere , 1 )
reportStr := strings . Join ( report , "," )
accDepart := strings . Join ( receivedValue . Operator , "," )
if reportStr != accDepart {
reportIsTrue = true
saveData [ "et_report" ] = accDepart
syncSeting . Add ( 1 )
go handleTargetRepart ( targetCont . Id , 0 , 0 , receivedValue . Operator , 1 , targetCont . Type )
}
}
/ *
获取关联部门
@ where 查询条件
@ level 1 : 部门级 ; 2 : 岗位级
func GetAboutDepartment ( where interface { } , level int ) ( departmentId [ ] int64 , departmentIdStr [ ] string , err error ) {
* /
if len ( saveData ) > 0 {
saveData [ "et_time" ] = time . Now ( ) . Unix ( )
err = targetCont . EiteCont ( where , saveData )
}
if err != nil {
publicmethod . Result ( 106 , err , c )
return
}
if reportIsTrue == true || departIsTreu == true {
syncSeting . Wait ( )
}
publicmethod . Result ( 0 , err , c )
}
/ *
处理指标细则关联部门
@ targetId 指标ID
@ targetSunId 栏目ID
@ bylawsId 指标细则
@ department 接受考核部门
@ class 级别 ( 1 : 部门级 ; 2 : 岗位级 )
@ nature 1 : 定性考核 ; 2 : 定量考核
* /
func handleTargetDepart ( targetId , targetSunId , bylawsId int64 , department [ ] string , class , nature int ) {
defer syncSeting . Done ( )
if nature == 0 {
nature = 1
}
//将不属于该指标细则的部门至禁用
otherSaveData := publicmethod . MapOut [ string ] ( )
otherSaveData [ "`state`" ] = 2
otherSaveData [ "`time`" ] = time . Now ( ) . Unix ( )
where := publicmethod . MapOut [ string ] ( )
where [ "`level`" ] = class
if targetId != 0 {
where [ "`target_id`" ] = targetId
}
if targetSunId != 0 {
where [ "`target_sun_id`" ] = targetSunId
}
if bylawsId != 0 {
where [ "`target_bylaws`" ] = bylawsId
}
if len ( department ) < 1 {
overall . CONSTANT_DB_KPI . Model ( & modelskpi . TargetDepartment { } ) . Where ( where ) . Updates ( & otherSaveData )
} else {
overall . CONSTANT_DB_KPI . Model ( & modelskpi . TargetDepartment { } ) . Where ( where ) . Not ( map [ string ] interface { } { "department_id" : department } ) . Updates ( & otherSaveData )
for _ , v := range department {
var tarDepartCont modelskpi . TargetDepartment
trWhere := publicmethod . MapOut [ string ] ( )
trWhere [ "`department_id`" ] = v
trWhere [ "`level`" ] = class
if targetId != 0 {
trWhere [ "`target_id`" ] = targetId
}
if targetSunId != 0 {
trWhere [ "`target_sun_id`" ] = targetSunId
}
if bylawsId != 0 {
trWhere [ "`target_bylaws`" ] = bylawsId
}
saveErr := tarDepartCont . GetCont ( trWhere , "`id`" , "`state`" )
if saveErr == nil {
if tarDepartCont . State != 1 {
tarDepartCont . EiteCont ( map [ string ] interface { } { "`id`" : tarDepartCont . 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
}
tarDepartCont . TargetId = targetId //指标ID"`
tarDepartCont . TargetSunId = targetSunId //子目标"`
tarDepartCont . TargetBylaws = bylawsId //指标细则"`
tarDepartCont . Type = xiZe //类型(1:指标;2:子目标;3:细则)"`
departId , _ := strconv . ParseInt ( v , 10 , 64 )
tarDepartCont . DepartmentId = departId //部门ID"`
tarDepartCont . PostId = 0 //岗位ID"`
tarDepartCont . State = 1 //状态(1:启用;2:禁用;3:删除)"`
tarDepartCont . Time = time . Now ( ) . Unix ( ) //写入时间"`
tarDepartCont . Class = nature //1:定性考核;2:定量考核"`
tarDepartCont . Level = class //级别(1:部门级;2:岗位级)"`
overall . CONSTANT_DB_KPI . Create ( & tarDepartCont )
}
}
}
}
/ *
处理指标细则关联考核提交人
@ targetId 指标ID
@ targetSunId 栏目ID
@ bylawsId 指标细则
@ repart 考核提交人
@ class 级别 ( 1 : 部门级 ; 2 : 岗位级 )
@ nature 1 : 定性考核 ; 2 : 定量考核
* /
func handleTargetRepart ( targetId , targetSunId , bylawsId int64 , repart [ ] string , class , nature int ) {
defer syncSeting . Done ( )
if nature == 0 {
nature = 1
}
//将不属于该指标细则的部门至禁用
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 len ( repart ) < 1 {
overall . CONSTANT_DB_KPI . Model ( & modelskpi . TargetReport { } ) . Where ( where ) . Updates ( & otherSaveData )
} else {
overall . CONSTANT_DB_KPI . Model ( & modelskpi . TargetReport { } ) . Where ( where ) . Not ( map [ string ] interface { } { "man_key" : repart } ) . Updates ( & otherSaveData )
for _ , v := range repart {
//获取评价人部门
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
}
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 , "`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 . TargetId = targetId //指标ID"`
tarReportCont . TargetSunId = targetSunId //子目标"`
tarReportCont . TargetBylaws = bylawsId //指标细则"`
tarReportCont . DepartmentId = 0 //部门ID"`
tarReportCont . PostId = 0 //岗位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 )
}
}
}
}
// 指标关联岗位
func ( a * ApiMethod ) DeparmentTargetAboutPost ( c * gin . Context ) {
var receivedValue depTarAboutPost
c . ShouldBindJSON ( & receivedValue )
if receivedValue . Id == "" {
publicmethod . Result ( 101 , receivedValue , c , "请输入指标ID!!" )
return
}
where := publicmethod . MapOut [ string ] ( )
where [ "et_id" ] = receivedValue . Id
var targetCont modelskpi . EvaluationTarget
err := targetCont . GetCont ( where )
jsonCont , _ := json . Marshal ( targetCont )
fmt . Printf ( "targetCont--------->%v\n" , string ( jsonCont ) )
if err != nil {
publicmethod . Result ( 107 , err , c )
return
}
if len ( receivedValue . OrgList ) < 1 {
publicmethod . Result ( 101 , receivedValue , c , "请指定部岗位与指标关联关系!" )
return
}
for _ , ov := range receivedValue . OrgList {
if len ( ov . Child ) < 1 {
publicmethod . Result ( 101 , ov , c , "请指定部的对照岗位!" )
return
}
syncSeting . Add ( 1 )
go departmentAboutPostTarget ( targetCont . Dimension , targetCont . Id , 0 , 0 , ov . Id , ov . Child , 2 , targetCont . Type )
}
syncSeting . Wait ( )
publicmethod . Result ( 0 , err , c )
}
/ *
协程处理
部门指标岗位关联通用函数
@ dimensionId 维度
@ targetId 指标ID
@ targetSunId 栏目ID
@ bylawsId 指标细则
@ department 接受考核部门
@ class 级别 ( 1 : 部门级 ; 2 : 岗位级 )
@ nature 1 : 定性考核 ; 2 : 定量考核
* /
func departmentAboutPostTarget ( dimensionId , targetId , targetSunId , bylawsId int64 , departmentId string , postList [ ] LoopStruct , class , nature int ) {
defer syncSeting . Done ( )
fmt . Printf ( "targetCont-----1---->%v\n" , nature )
if nature == 0 {
nature = 1
}
fmt . Printf ( "targetCont----2----->%v\n" , nature )
//将不属于该指标细则的部门至禁用
otherSaveData := publicmethod . MapOut [ string ] ( )
otherSaveData [ "`state`" ] = 2
otherSaveData [ "`time`" ] = time . Now ( ) . Unix ( )
where := publicmethod . MapOut [ string ] ( )
where [ "`level`" ] = 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 != "" {
where [ "`department_id`" ] = departmentId
}
if len ( postList ) < 1 {
overall . CONSTANT_DB_KPI . Model ( & modelskpi . TargetDepartment { } ) . Where ( where ) . Updates ( & otherSaveData )
} else {
//获取提交的岗位
var postIdAry [ ] string
// overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetDepartment{}).Where(where).Not(map[string]interface{}{"post_id": postList}).Updates(&otherSaveData)
for _ , v := range postList {
if publicmethod . IsInTrue [ string ] ( v . Id , postIdAry ) == false {
postIdAry = append ( postIdAry , v . Id )
//判断该岗位是否已经存在对照
trWhere := publicmethod . MapOut [ string ] ( )
trWhere [ "`post_id`" ] = v . Id
trWhere [ "`level`" ] = 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 != "" {
trWhere [ "`department_id`" ] = departmentId
}
departId , _ := strconv . ParseInt ( departmentId , 10 , 64 )
postId , _ := strconv . ParseInt ( v . Id , 10 , 64 )
var tarDepartCont modelskpi . TargetDepartment
saveErr := tarDepartCont . GetCont ( trWhere , "`id`" , "`state`" )
if saveErr == nil { //已经存在
if tarDepartCont . State != 1 { //不是启用状态,更改启用状态
tarDepartCont . EiteCont ( map [ string ] interface { } { "`id`" : tarDepartCont . Id } , map [ string ] interface { } { "`state`" : 1 , "`dimension_id`" : dimensionId , "`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
}
tarDepartCont . Dimension = dimensionId
tarDepartCont . TargetId = targetId //指标ID"`
tarDepartCont . TargetSunId = targetSunId //子目标"`
tarDepartCont . TargetBylaws = bylawsId //指标细则"`
tarDepartCont . Type = xiZe //类型(1:指标;2:子目标;3:细则)"`
tarDepartCont . DepartmentId = departId //部门ID"`
tarDepartCont . PostId = postId //岗位ID"`
tarDepartCont . State = 1 //状态(1:启用;2:禁用;3:删除)"`
tarDepartCont . Time = time . Now ( ) . Unix ( ) //写入时间"`
tarDepartCont . Class = nature //1:定性考核;2:定量考核"`
tarDepartCont . Level = class //级别(1:部门级;2:岗位级)"`
jsonCont , _ := json . Marshal ( tarDepartCont )
fmt . Printf ( "targetCont----3----->%v\n" , string ( jsonCont ) )
overall . CONSTANT_DB_KPI . Create ( & tarDepartCont )
}
syncSeting . Add ( 1 )
go DepartAboutPostTargetReport ( dimensionId , targetId , targetSunId , bylawsId , departId , postId , v . Child , class , nature )
}
}
//把不在进行关联的取消
if len ( postIdAry ) > 0 {
overall . CONSTANT_DB_KPI . Model ( & modelskpi . TargetDepartment { } ) . Where ( where ) . Not ( map [ string ] interface { } { "post_id" : postIdAry } ) . Updates ( & otherSaveData )
}
}
}
/ *
协程处理
部门指标岗位提报人关联通用函数
@ 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 [ ] LoopStruct , class , nature int ) {
defer syncSeting . Done ( )
//将不属于该指标细则的部门至禁用
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 . Id , userKeyAbout ) == false {
userKeyAbout = append ( userKeyAbout , v . Id )
//获取评价人部门
var manCont modelshr . PersonArchives
manCont . GetCont ( map [ string ] interface { } { "`key`" : v . Id } , "`maindeparment`" )
var tarReportCont modelskpi . TargetReport
trWhere := publicmethod . MapOut [ string ] ( )
trWhere [ "`man_key`" ] = v . Id
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 . Id , 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 ) DeparSonTargetAboutPost ( c * gin . Context ) {
var receivedValue depTarAboutPost
c . ShouldBindJSON ( & receivedValue )
if receivedValue . Id == "" {
publicmethod . Result ( 101 , receivedValue , c , "请输入指标ID!!" )
return
}
where := publicmethod . MapOut [ string ] ( )
where [ "q_id" ] = receivedValue . Id
var targetCont modelskpi . QualitativeTarget
err := targetCont . GetCont ( where )
if err != nil {
publicmethod . Result ( 107 , err , c )
return
}
if len ( receivedValue . OrgList ) < 1 {
publicmethod . Result ( 101 , receivedValue , c , "请指定部岗位与指标关联关系!" )
return
}
var fashTar modelskpi . EvaluationTarget
fashTar . GetCont ( map [ string ] interface { } { "et_id" : targetCont . ParentId } , "et_dimension" , "et_type" )
for _ , ov := range receivedValue . OrgList {
if len ( ov . Child ) < 1 {
publicmethod . Result ( 101 , ov , c , "请指定部的对照岗位!" )
return
}
syncSeting . Add ( 1 )
go departmentAboutPostTarget ( fashTar . Dimension , targetCont . ParentId , targetCont . Id , 0 , ov . Id , ov . Child , 2 , fashTar . Type )
}
syncSeting . Wait ( )
publicmethod . Result ( 0 , err , c )
}
// 指标细则关联部门岗位
func ( a * ApiMethod ) DeparDetaileAboutPost ( c * gin . Context ) {
var receivedValue depTarAboutPost
c . ShouldBindJSON ( & receivedValue )
if receivedValue . Id == "" {
publicmethod . Result ( 101 , receivedValue , c , "请输入指标ID!!" )
return
}
where := publicmethod . MapOut [ string ] ( )
where [ "dt_id" ] = receivedValue . Id
var targetCont modelskpi . DetailedTarget
err := targetCont . GetCont ( where )
if err != nil {
publicmethod . Result ( 107 , err , c )
return
}
if len ( receivedValue . OrgList ) < 1 {
publicmethod . Result ( 101 , receivedValue , c , "请指定部岗位与指标关联关系!" )
return
}
var fashTar modelskpi . EvaluationTarget
fashTar . GetCont ( map [ string ] interface { } { "et_id" : targetCont . ParentId } , "et_dimension" , "et_type" )
for _ , ov := range receivedValue . OrgList {
if len ( ov . Child ) < 1 {
publicmethod . Result ( 101 , ov , c , "请指定部的对照岗位!" )
return
}
syncSeting . Add ( 1 )
go departmentAboutPostTarget ( fashTar . Dimension , targetCont . ParentId , targetCont . ParentIdSun , targetCont . Id , ov . Id , ov . Child , 2 , fashTar . Type )
}
syncSeting . Wait ( )
publicmethod . Result ( 0 , err , c )
}
// 删除子栏目
func ( a * ApiMethod ) DelTarget ( c * gin . Context ) {
var receivedValue publicmethod . PublicId
err := c . ShouldBindJSON ( & receivedValue )
if err != nil {
publicmethod . Result ( 100 , receivedValue , c )
return
}
if receivedValue . Id == "" {
publicmethod . Result ( 101 , receivedValue , c )
return
}
where := publicmethod . MapOut [ string ] ( )
where [ "et_id" ] = receivedValue . Id
var sonTargetCont modelskpi . EvaluationTarget
err = sonTargetCont . GetCont ( where , "q_id" )
if err != nil {
publicmethod . Result ( 107 , err , c )
return
}
//预留判断该指标是否在使用中
delTime := time . Now ( ) . Unix ( )
//获取该指标下的所有子栏目
var sonTargetList [ ] int64
overall . CONSTANT_DB_KPI . Model ( & modelskpi . QualitativeTarget { } ) . Select ( "`q_id`" ) . Where ( "`q_state` = 1 AND `q_parent_id` = ?" , sonTargetCont . Id ) . Find ( & sonTargetList )
if len ( sonTargetList ) > 0 {
for _ , v := range sonTargetList {
//软删除所有此子栏目下的指标细则
syncSeting . Add ( 1 )
go softDetaildeCont ( sonTargetCont . Id , v , delTime )
//软删除所有此子栏目相关的联部门
syncSeting . Add ( 1 )
go softDelTargetDepartment ( map [ string ] interface { } { "target_id" : sonTargetCont . Id , "target_sun_id" : v , "`state`" : 1 } , delTime )
//软删除所有此子栏目相关联的提报人
syncSeting . Add ( 1 )
go softDelTargetReport ( map [ string ] interface { } { "`target_id`" : sonTargetCont . Id , "`target_sun_id`" : v , "`state`" : 1 } , delTime )
}
}
//软删除此指标
var delTargetSon modelskpi . EvaluationTarget
err = delTargetSon . EiteCont ( map [ string ] interface { } { "`et_id`" : sonTargetCont . Id } , map [ string ] interface { } { "`et_state`" : 3 , "`et_time`" : delTime } )
syncSeting . Wait ( )
if err != nil {
publicmethod . Result ( 106 , err , c )
return
}
publicmethod . Result ( 0 , err , c )
}
/ *
*
@ 作者 : 秦东
@ 时间 : 2023 - 01 - 03 16 : 13 : 46
@ 功能 : 判断指标得子栏目是否存在
@ 参数
# targetId 指标ID
# sunTargetTitle 子栏目名称
# saveData 子栏目数据表
# whistleblower 提报人
@ 返回值
# err 返回值
@ 方法原型
# JudgeSunTargetAbout ( targetId , sunTargetTitle string , saveData modelskpi . QualitativeTarget , whistleblower zhuanHuanMan ) ( err error )
* /
func JudgeSunTargetAbout ( targetId , sunTargetTitle string , saveData modelskpi . QualitativeTarget , whistleblower zhuanHuanMan ) ( err error ) {
var sunTargetCont modelskpi . QualitativeTarget
err = sunTargetCont . GetCont ( map [ string ] interface { } { "q_title" : sunTargetTitle , "q_parent_id" : targetId } )
if err != nil {
err = overall . CONSTANT_DB_KPI . Create ( & saveData ) . Error
} else {
if sunTargetCont . State != 1 {
err = sunTargetCont . EiteCont ( map [ string ] interface { } { "`q_id`" : sunTargetCont . Id } , map [ string ] interface { } { "`q_state`" : 1 , "`q_time`" : time . Now ( ) . Unix ( ) } )
}
}
if err == nil {
var dimCont modelskpi . EvaluationTarget
dimCont . GetCont ( map [ string ] interface { } { "`et_id`" : targetId } , "`et_dimension`" )
var groupId int64
groupId = 309
departAry := strings . Split ( sunTargetCont . Depart , "," )
if len ( departAry ) > 0 {
orgId , _ := strconv . ParseInt ( departAry [ 0 ] , 10 , 64 )
_ , groupId , _ , _ , _ = publicmethod . GetOrgStructure ( orgId )
}
//判断关联数据是否是否编写
var assEssCont modelskpi . Assesstarget
errEs := assEssCont . GetCont ( map [ string ] interface { } { "`targetid`" : targetId , "`suntargetid`" : sunTargetCont . Id , "`dimension`" : dimCont . Id } )
if errEs != nil {
//数据不存在,则新增
assEssCont . Group = groupId //集团ID"`
assEssCont . Departmentmap = sunTargetCont . Depart //部门ID"`
assEssCont . TargetId = sunTargetCont . ParentId //指标"`
assEssCont . SunTargetId = sunTargetCont . Id //子栏目ID"`
var whistleblowerAry [ ] zhuanHuanMan
whistleblowerAry = append ( whistleblowerAry , whistleblower )
whistleblowerStr , _ := json . Marshal ( whistleblowerAry )
assEssCont . Content = string ( whistleblowerStr ) //描述"`
assEssCont . Time = time . Now ( ) . Unix ( ) //创建时间"`
assEssCont . State = 1 //状态(1:启用;2:禁用;3:删除)"`
assEssCont . Dimension = dimCont . Id //维度"`
overall . CONSTANT_DB_KPI . Create ( & assEssCont )
} else {
oldDepart := strings . Split ( assEssCont . Departmentmap , "," )
//数据存在,则修改
metgrAry := publicmethod . MergeStruct [ string ] ( departAry , oldDepart )
metgrAryStr := strings . Join ( metgrAry , "," )
editSaveDate := publicmethod . MapOut [ string ] ( )
if metgrAryStr != assEssCont . Departmentmap {
editSaveDate [ "`departmentmap`" ] = metgrAryStr
}
if whistleblower . Id != 0 && len ( whistleblower . Operator ) > 0 {
var oldWhistle [ ] zhuanHuanMan
errjson := json . Unmarshal ( [ ] byte ( assEssCont . Content ) , oldWhistle )
if errjson != nil {
var newPeopleList [ ] zhuanHuanMan
for _ , v := range oldWhistle {
if whistleblower . Id == v . Id {
var newPeopleCont zhuanHuanMan
newPeopleCont . Id = whistleblower . Id
metgrPeoleAry := publicmethod . MergeStruct [ string ] ( v . Operator , whistleblower . Operator )
newPeopleCont . Operator = metgrPeoleAry
newPeopleList = append ( newPeopleList , newPeopleCont )
} else {
newPeopleList = append ( newPeopleList , v )
}
}
whistleblowerStr , _ := json . Marshal ( newPeopleList )
editSaveDate [ "`departmentmap`" ] = whistleblowerStr
} else {
var whistleblowerAry [ ] zhuanHuanMan
whistleblowerAry = append ( whistleblowerAry , whistleblower )
whistleblowerStr , _ := json . Marshal ( whistleblowerAry )
editSaveDate [ "`departmentmap`" ] = whistleblowerStr
}
}
if len ( editSaveDate ) > 0 {
editSaveDate [ "`state`" ] = 1
editSaveDate [ "`time`" ] = time . Now ( ) . Unix ( )
var editAssEssCont modelskpi . Assesstarget
editAssEssCont . EiteCont ( map [ string ] interface { } { "`at_id`" : assEssCont . Id } , editSaveDate )
}
}
}
return
}