KPI绩效考核系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1580 lines
66 KiB

package postweb
import (
"encoding/json"
"fmt"
"key_performance_indicators/api/version1/flowchart"
"key_performance_indicators/middleware/wechatapp/wechatcallback"
"key_performance_indicators/middleware/wechatapp/wechatsendmsg"
"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) GetPostTarget(c *gin.Context) {
var receivedValue getPostManTargetList
err := c.ShouldBindJSON(&receivedValue)
if err != nil {
publicmethod.Result(100, err, c)
return
}
if receivedValue.Id == "" {
publicmethod.Result(101, receivedValue, c)
return
}
if receivedValue.Class == 0 {
receivedValue.Class = 1
}
//获取被考核人基本西悉尼
var userCont modelshr.PersonArchives
err = userCont.GetCont(map[string]interface{}{"`key`": receivedValue.Id}, "`company`", "`maindeparment`", "`admin_org`", "`position`")
if err != nil {
publicmethod.Result(107, err, c)
return
}
//获取登录人信息
context, _ := publicmethod.LoginMyCont(c)
var qualitSchemeList []modelskpi.QualitativeEvaluationScheme
err = overall.CONSTANT_DB_KPI.Raw("SELECT q.* FROM qualitative_evaluation_scheme q Where q.state = 1 AND `attribute` = ? AND q.target_id = some (SELECT target_id FROM target_report tr WHERE tr.type = 2 AND tr.department_id = ? AND tr.post_id = ? AND tr.man_key = ?)", receivedValue.Class, userCont.MainDeparment, userCont.Position, context.Key).Scan(&qualitSchemeList).Error
if err != nil || len(qualitSchemeList) < 1 {
publicmethod.Result(107, err, c)
return
}
var outDataAry []outPostManTargetList
for _, v := range qualitSchemeList {
// jsonStr, _ := json.Marshal(v)
// fmt.Printf("v----------->%v\n", string(jsonStr))
var outCont outPostManTargetList
outCont.Id = strconv.FormatInt(v.Id, 10)
outCont.Class = v.Attribute
outCont.Title = v.Title
if v.Attribute == 1 {
if v.Source == 1 { //岗位
var postTarDeta modelskpi.PostTargetDetails
postTarDeta.GetCont(map[string]interface{}{"`id`": v.DetailsId}, "`punishmode`")
outCont.AddReduce = postTarDeta.Punishmode
} else { //部门
var departTarDeta modelskpi.DetailedTarget
departTarDeta.GetCont(map[string]interface{}{"`dt_id`": v.DetailsId}, "`dt_add_reduce`")
outCont.AddReduce = departTarDeta.AddReduce
}
}
outDataAry = append(outDataAry, outCont)
}
publicmethod.Result(0, outDataAry, c)
}
// 定性指标列表
func (a *ApiMethod) GetPostNature(c *gin.Context) {
var receivedValue publicmethod.PublicId
err := c.ShouldBindJSON(&receivedValue)
if err != nil {
publicmethod.Result(100, err, c)
return
}
if receivedValue.Id == "" {
publicmethod.Result(101, receivedValue, c)
return
}
//获取被考核人基本信息
var userCont modelshr.PersonArchives
err = userCont.GetCont(map[string]interface{}{"`key`": receivedValue.Id}, "`company`", "`maindeparment`", "`admin_org`", "`position`")
if err != nil {
publicmethod.Result(107, err, c)
return
}
//获取登录人信息
context, _ := publicmethod.LoginMyCont(c)
//获取被考核人本岗位的考核项目
var itemList []modelskpi.ShemePeople
err = overall.CONSTANT_DB_KPI.Where("`state` = 1 AND `tr_type` = 2 AND `attribute` = 1 AND `run_state` <> 2 AND `org_id` = ? AND `post_id` = ? AND `man_key` = ?", userCont.AdminOrg, userCont.Position, context.Key).Find(&itemList).Error
if err != nil || len(itemList) < 1 {
publicmethod.Result(107, err, c)
return
}
var targetId []int64
//获取指标内容
var outDataAry []outPostManTargetList
for _, v := range itemList {
if publicmethod.IsInTrue[int64](v.TargetId, targetId) == false {
var tarCont modelskpi.PostTarget
tarCont.GetCont(map[string]interface{}{"`id`": v.TargetId}, "`title`")
var outCont outPostManTargetList
outCont.Id = strconv.FormatInt(v.TargetId, 10)
outCont.Title = tarCont.Title
outCont.Class = v.Attribute
if v.Source == 1 { //岗位
var postTarDeta modelskpi.PostTargetDetails
postTarDeta.GetCont(map[string]interface{}{"`id`": v.DetailsId}, "`add_reduce`")
outCont.AddReduce = postTarDeta.AddReduce
} else { //部门
var departTarDeta modelskpi.DetailedTarget
departTarDeta.GetCont(map[string]interface{}{"`dt_id`": v.DetailsId}, "`dt_add_reduce`")
outCont.AddReduce = departTarDeta.AddReduce
}
3 years ago
outCont.UserKey = receivedValue.Id
outCont.DimensionId = strconv.FormatInt(v.DimensionId, 10)
outDataAry = append(outDataAry, outCont)
targetId = append(targetId, v.TargetId)
}
}
publicmethod.Result(0, outDataAry, c)
}
// 获取定性指标子栏目列表
func (a *ApiMethod) GetPostNatureSonTarget(c *gin.Context) {
var receivedValue getSonTarList
err := c.ShouldBindJSON(&receivedValue)
if err != nil {
publicmethod.Result(100, err, c)
return
}
if receivedValue.Id == "" {
publicmethod.Result(101, receivedValue, c)
return
}
var sonTargetList []modelskpi.PostSonTarget
gormDb := overall.CONSTANT_DB_KPI.Model(&modelskpi.PostSonTarget{}).Where("`parent_id` = ?", receivedValue.Id)
if receivedValue.OrgId != "" {
gormDb = gormDb.Where("`depart` = ?", receivedValue.OrgId)
}
if receivedValue.PostId != "" {
gormDb = gormDb.Where("`depart_post` = ?", receivedValue.PostId)
}
err = gormDb.Find(&sonTargetList).Error
if err != nil || len(sonTargetList) < 1 {
publicmethod.Result(104, err, c)
return
}
publicmethod.Result(0, sonTargetList, c)
}
3 years ago
// 获取定量指标列表
func (a *ApiMethod) GetPostRation(c *gin.Context) {
var receivedValue publicmethod.PublicId
err := c.ShouldBindJSON(&receivedValue)
if err != nil {
publicmethod.Result(100, err, c)
return
}
if receivedValue.Id == "" {
publicmethod.Result(101, receivedValue, c)
return
}
//获取被考核人基本信息
var userCont modelshr.PersonArchives
err = userCont.GetCont(map[string]interface{}{"`key`": receivedValue.Id}, "`company`", "`maindeparment`", "`admin_org`", "`position`")
if err != nil {
publicmethod.Result(107, err, c)
return
}
//获取登录人信息
context, _ := publicmethod.LoginMyCont(c)
//获取被考核人本岗位的考核项目
var itemList []modelskpi.ShemePeople
err = overall.CONSTANT_DB_KPI.Where("`state` = 1 AND `tr_type` = 2 AND `attribute` = 2 AND `run_state` <> 2 AND `org_id` = ? AND `post_id` = ? AND `man_key` = ?", userCont.AdminOrg, userCont.Position, context.Key).Find(&itemList).Error
if err != nil || len(itemList) < 1 {
publicmethod.Result(107, err, c)
return
}
var targetId []int64
//获取指标内容
var outDataAry []outPostRation
for _, v := range itemList {
if publicmethod.IsInTrue[int64](v.TargetId, targetId) == false {
var outCont outPostRation
outCont.Id = strconv.FormatInt(v.TargetId, 10)
outCont.ShemeId = strconv.FormatInt(v.Id, 10)
outCont.Title = v.Title
3 years ago
outCont.UserKey = receivedValue.Id
outCont.DimensionId = strconv.FormatInt(v.DimensionId, 10)
outDataAry = append(outDataAry, outCont)
}
}
publicmethod.Result(0, outDataAry, c)
}
3 years ago
// 获取岗位定性考核指标细则列表
func (a *ApiMethod) GetPostDeimensoInfo(c *gin.Context) {
var receivedValue getNatureDimeList
err := c.ShouldBindJSON(&receivedValue)
if err != nil {
publicmethod.Result(100, err, c)
return
}
if receivedValue.UserKey == "" {
publicmethod.Result(101, receivedValue, c)
return
}
if receivedValue.DimensionId == "" {
publicmethod.Result(101, receivedValue, c)
return
}
3 years ago
if receivedValue.TargetId == "" {
publicmethod.Result(101, receivedValue, c)
return
}
if receivedValue.PageSize < 1 {
receivedValue.PageSize = 20
}
3 years ago
//获取被考核人基本信息
var userCont modelshr.PersonArchives
err = userCont.GetCont(map[string]interface{}{"`key`": receivedValue.UserKey}, "`company`", "`maindeparment`", "`admin_org`", "`position`")
if err != nil {
publicmethod.Result(107, err, c)
return
}
//获取登录人信息
context, _ := publicmethod.LoginMyCont(c)
//获取被考核人本岗位的考核项目
var itemList []modelskpi.ShemePeople
//SELECT * FROM `sheme_people` WHERE `state` = 1 AND `tr_type` = 2 AND `attribute` = 1 AND `run_state` <> 2 AND `dimension_id` = '16468024054665111' AND `target_id` = '3' AND `org_id` = 272 AND `post_id` = 794 AND `man_key` = 15993815826844528 AND `son_target_id` = '2' ORDER BY `son_target_id` DESC LIMIT 20 OFFSET 20
sqlStrList := "SELECT * FROM `sheme_people`"
sqlListCount := "SELECT count(*) FROM `sheme_people`"
sqlStr := "WHERE `state` = 1 AND `tr_type` = 2 AND `attribute` = 1 AND `run_state` <> 2"
if receivedValue.DimensionId != "" {
sqlStr = fmt.Sprintf("%v AND `dimension_id` = %v", sqlStr, receivedValue.DimensionId)
}
if receivedValue.TargetId != "" {
sqlStr = fmt.Sprintf("%v AND `target_id` = %v", sqlStr, receivedValue.TargetId)
}
if receivedValue.Sontargetid != "" {
sqlStr = fmt.Sprintf("%v AND `son_target_id` = %v", sqlStr, receivedValue.Sontargetid)
}
if userCont.AdminOrg != 0 {
sqlStr = fmt.Sprintf("%v AND `org_id` = %v", sqlStr, userCont.AdminOrg)
}
if userCont.Position != 0 {
sqlStr = fmt.Sprintf("%v AND `post_id` = %v", sqlStr, userCont.Position)
}
if context.Key != 0 {
sqlStr = fmt.Sprintf("%v AND `man_key` = %v", sqlStr, context.Key)
}
sqlStr = fmt.Sprintf("%v ORDER BY `son_target_id` DESC", sqlStr)
if receivedValue.Page <= 1 {
sqlStr = fmt.Sprintf("%v LIMIT %v", sqlStr, receivedValue.PageSize)
} else {
sqlStr = fmt.Sprintf("%v LIMIT %v OFFSET %v", sqlStr, receivedValue.PageSize, publicmethod.LimitPage(receivedValue.Page, receivedValue.PageSize))
}
var total int64
selectSqlStr := fmt.Sprintf("%v %v", sqlStrList, sqlStr)
selectSqlStrCount := fmt.Sprintf("%v %v", sqlListCount, sqlStr)
//原生查询
errGormEaw := overall.CONSTANT_DB_KPI.Raw(selectSqlStr).Scan(&itemList).Error
overall.CONSTANT_DB_KPI.Raw(selectSqlStrCount).Scan(&total)
// fmt.Printf("errGormEaw------------------->%v----------->%v----------->%v\n", itemList, errGormEaw, total)
// gormDb := overall.CONSTANT_DB_KPI.Model(&modelskpi.ShemePeople{})
// // gormDb = gormDb.Where("`state` = 1 AND `tr_type` = 2 AND `attribute` = 1")
// // gormDb = gormDb.Where("`dimension_id` = ? AND `target_id` = ? ", receivedValue.DimensionId, receivedValue.TargetId)
// // gormDb = gormDb.Where("`org_id` = ? AND `post_id` = ? AND `man_key` = ?", userCont.AdminOrg, userCont.Position, context.Key)
// gormDb = gormDb.Where("`state` = 1 AND `tr_type` = 2 AND `attribute` = 1 AND `run_state` <> 2 AND `dimension_id` = ? AND `target_id` = ? AND `org_id` = ? AND `post_id` = ? AND `man_key` = ?", receivedValue.DimensionId, receivedValue.TargetId, userCont.AdminOrg, userCont.Position, context.Key)
// if receivedValue.Sontargetid != "" {
// gormDb = gormDb.Where("`son_target_id` = ?", receivedValue.Sontargetid)
// }
// gormDb = publicmethod.PageTurningSettings(gormDb, receivedValue.Page, receivedValue.PageSize)
// errGorm := gormDb.Order("`son_target_id` DESC").Find(&itemList).Error
// totalErr := gormDb.Count(&total).Error
// if totalErr != nil {
// total = 0
// }
// fmt.Printf("outList------------------->%v----------->%v\n", itemList, total)
if errGormEaw != nil || total < 1 {
3 years ago
publicmethod.Result(107, err, c)
return
}
var outList []outNatureDimeCont
for _, v := range itemList {
var outCont outNatureDimeCont
outCont.Id = v.Id
outCont.VersionNumber = v.VersionNumber // 版本编号"`
outCont.CompanyId = v.CompanyId // 归属公司"`
outCont.DepartmentId = v.DepartmentId // 归属部门"`
outCont.OrgId = v.OrgId // 归属行政组织"`
outCont.PostId = v.PostId // 归属岗位"`
outCont.Title = v.Title //考核项名称"`
outCont.DimensionId = v.DimensionId //维度"`
outCont.TargetId = v.TargetId // 指标"`
outCont.SonTargetId = v.SonTargetId //子栏目"`
outCont.DetailsId = v.DetailsId //细则"`
outCont.Attribute = v.Attribute // 属性 1:定性考核;2:定量考核"`
outCont.MinScore = publicmethod.DecimalEs(v.MinScore/100, 2) // 最小分*100保存"`
outCont.MaxScore = publicmethod.DecimalEs(v.MaxScore/100, 2) //最大分*100保存"`
outCont.ScoringMethod = v.ScoringMethod //计分方式(1:自动;2:手动)"`
outCont.State = v.State //状态(1:启用;2:禁用;3:删除)"`
outCont.Addtime = v.Addtime //添加时间"`
outCont.Eitetime = v.Eitetime // 编辑时间"`
outCont.CensorType = v.CensorType //检查方式(1:现场检查;2:资料检查;3:事件触发)"`
outCont.Source = v.Source //来源(1:岗位;2:部门引用)"`
outCont.RunState = v.RunState //运行状态(1:启用;2:禁用;3:观察)"`
outCont.Type = v.Type //类型(1:公司级;2:部门级)"`
outCont.ReportPerson = v.ReportPerson //上报人"`
outCont.ManDepartment = v.ManDepartment //提报人所在部门"`
outCont.Class = v.Class //1:定性考核;2:定量考核"`
outCont.Level = v.Level //类型(1:指标;2:子目标;3:细则)"`
outCont.Punishmode = v.Punishmode //处罚方式 1:扣分;2:现金处罚;3:扣分加现金
outCont.Maxmoney = publicmethod.DecimalEs(v.Maxmoney/100, 2) //最高罚款
outCont.Minmoney = publicmethod.DecimalEs(v.Minmoney/100, 2) //最低罚款
if v.CensorType != "" {
outCont.CensorTypeAry = strings.Split(v.CensorType, ",")
}
if v.DetailsId != 0 {
//获取指标信息
if v.Source == 1 { //岗位
var targetCont modelskpi.PostTargetDetails
targetCont.GetCont(map[string]interface{}{"`id`": v.DetailsId}, "`content`", "`add_reduce`", "`censor_cont`", "`company`")
outCont.Context = targetCont.Content //指标说明"`
outCont.AddReduce = targetCont.AddReduce //1:减少;2:增加;3:无属性,现场确认加或减"`
outCont.CensorCont = targetCont.CensorCont //检查依据"`
outCont.Unity = targetCont.Company
} else { //部门
var departTarDeta modelskpi.DetailedTarget
departTarDeta.GetCont(map[string]interface{}{"`dt_id`": v.DetailsId}, "`dt_add_reduce`", "`dt_company`")
outCont.Context = departTarDeta.Content //指标说明"`
outCont.AddReduce = departTarDeta.AddReduce //1:减少;2:增加;3:无属性,现场确认加或减"`
outCont.CensorCont = departTarDeta.CensorCont //检查依据"`
outCont.Unity = departTarDeta.Company
}
}
if v.MinScore != 0 {
outCont.ScoreStr = fmt.Sprintf("%v-%v", publicmethod.DecimalEs(v.MinScore/100, 2), publicmethod.DecimalEs(v.MaxScore/100, 2))
} else {
outCont.ScoreStr = fmt.Sprintf("%v", publicmethod.DecimalEs(v.MaxScore/100, 2))
}
if v.Minmoney != 0 {
outCont.MoneyStr = fmt.Sprintf("%v-%v", publicmethod.DecimalEs(v.Minmoney/100, 2), publicmethod.DecimalEs(v.Maxmoney/100, 2))
} else {
outCont.MoneyStr = fmt.Sprintf("%v", publicmethod.DecimalEs(v.Maxmoney/100, 2))
}
outCont.UserKey = receivedValue.UserKey
outList = append(outList, outCont)
}
// fmt.Printf("outList------------------->%v\n", outList)
publicmethod.ResultList(0, receivedValue.Page, receivedValue.PageSize, total, int64(len(outList)), outList, c)
3 years ago
}
// 获取被考核人定性指标细则详细内容
func (a *ApiMethod) GetNaturePostDimerons(c *gin.Context) {
var receivedValue postNaturcInfo
err := c.ShouldBindJSON(&receivedValue)
if err != nil {
publicmethod.Result(100, err, c)
return
}
if receivedValue.UserKey == "" {
publicmethod.Result(101, receivedValue, c)
return
}
if receivedValue.Id == "" {
publicmethod.Result(101, receivedValue, c)
return
}
var shemeCont modelskpi.QualitativeEvaluationScheme
errSheme := shemeCont.GetCont(map[string]interface{}{"`id`": receivedValue.Id})
if errSheme != nil {
publicmethod.Result(107, receivedValue, c)
return
}
var outCont outNatureDimePostCont
outCont.Id = shemeCont.Id
outCont.VersionNumber = shemeCont.VersionNumber // 版本编号"`
outCont.CompanyId = shemeCont.CompanyId // 归属公司"`
outCont.DepartmentId = shemeCont.DepartmentId // 归属部门"`
outCont.OrgId = shemeCont.OrgId // 归属行政组织"`
outCont.PostId = shemeCont.PostId // 归属岗位"`
outCont.Title = shemeCont.Title //考核项名称"`
outCont.DimensionId = shemeCont.DimensionId //维度"`
outCont.TargetId = shemeCont.TargetId // 指标"`
outCont.SonTargetId = shemeCont.SonTargetId //子栏目"`
outCont.DetailsId = shemeCont.DetailsId //细则"`
outCont.Attribute = shemeCont.Attribute // 属性 1:定性考核;2:定量考核"`
outCont.MinScore = shemeCont.MinScore // 最小分*100保存"`
outCont.MaxScore = shemeCont.MaxScore //最大分*100保存"`
outCont.ScoringMethod = shemeCont.ScoringMethod //计分方式(1:自动;2:手动)"`
outCont.State = shemeCont.State //状态(1:启用;2:禁用;3:删除)"`
outCont.Addtime = shemeCont.Addtime //添加时间"`
outCont.Eitetime = shemeCont.Eitetime // 编辑时间"`
outCont.CensorType = shemeCont.CensorType //检查方式(1:现场检查;2:资料检查;3:事件触发)"`
outCont.Source = shemeCont.Source //来源(1:岗位;2:部门引用)"`
outCont.RunState = shemeCont.RunState //运行状态(1:启用;2:禁用;3:观察)"`
outCont.Punishmode = shemeCont.Punishmode //处罚方式 1:扣分;2:现金处罚;3:扣分加现金
outCont.Maxmoney = shemeCont.Maxmoney //最高罚款
outCont.Minmoney = shemeCont.Minmoney //最低罚款
if shemeCont.CensorType != "" {
outCont.CensorTypeAry = strings.Split(shemeCont.CensorType, ",")
}
if shemeCont.DetailsId != 0 {
//获取指标信息
if shemeCont.Source == 1 { //岗位
var targetCont modelskpi.PostTargetDetails
targetCont.GetCont(map[string]interface{}{"`id`": shemeCont.DetailsId}, "content", "add_reduce", "censor_cont")
outCont.Context = targetCont.Content //指标说明"`
outCont.AddReduce = targetCont.AddReduce //1:减少;2:增加;3:无属性,现场确认加或减"`
outCont.CensorCont = targetCont.CensorCont //检查依据"`
} else { //部门
var departTarDeta modelskpi.DetailedTarget
departTarDeta.GetCont(map[string]interface{}{"`dt_id`": shemeCont.DetailsId}, "`dt_add_reduce`")
outCont.Context = departTarDeta.Content //指标说明"`
outCont.AddReduce = departTarDeta.AddReduce //1:减少;2:增加;3:无属性,现场确认加或减"`
outCont.CensorCont = departTarDeta.CensorCont //检查依据"`
}
}
if shemeCont.MinScore != 0 {
outCont.ScoreStr = fmt.Sprintf("%v-%v", shemeCont.MinScore, shemeCont.MaxScore)
outCont.ScoreState = 2
} else if shemeCont.MinScore > 0 && shemeCont.MaxScore <= 0 {
outCont.ScoreStr = fmt.Sprintf("%v", float64(shemeCont.MinScore)/100)
outCont.ScoreState = 1
} else if shemeCont.MinScore <= 0 && shemeCont.MaxScore > 0 {
outCont.ScoreStr = fmt.Sprintf("%v", float64(shemeCont.MaxScore)/100)
outCont.ScoreState = 1
} else {
outCont.ScoreStr = "0"
outCont.ScoreState = 3
}
if shemeCont.Minmoney != 0 {
outCont.MoneyStr = fmt.Sprintf("%v-%v", shemeCont.Minmoney, shemeCont.Maxmoney)
outCont.MoneyState = 2
} else if shemeCont.Minmoney > 0 && shemeCont.Maxmoney <= 0 {
outCont.MoneyStr = fmt.Sprintf("%v", float64(shemeCont.Minmoney)/100)
outCont.MoneyState = 1
} else if shemeCont.Minmoney <= 0 && shemeCont.Maxmoney > 0 {
outCont.MoneyStr = fmt.Sprintf("%v", float64(shemeCont.Maxmoney)/100)
outCont.MoneyState = 1
} else {
outCont.MoneyStr = "0"
outCont.MoneyState = 3
}
// if shemeCont.Minmoney != 0 {
// outCont.MoneyStr = fmt.Sprintf("%v-%v", shemeCont.Minmoney, shemeCont.Maxmoney)
// } else {
// outCont.MoneyStr = fmt.Sprintf("%v", shemeCont.Maxmoney)
// }
outCont.UserKey = receivedValue.UserKey
publicmethod.Result(0, outCont, c)
}
// 提交个人岗位定性考核数据
func (a *ApiMethod) SendUsNatureEvaluation(c *gin.Context) {
var receivedValue sendMyEvaluationData
err := c.ShouldBindJSON(&receivedValue)
if err != nil {
publicmethod.Result(100, err, c)
return
}
if receivedValue.Id == "" {
publicmethod.Result(101, receivedValue, c)
return
}
var postShemeCont modelskpi.QualitativeEvaluationScheme
err = postShemeCont.GetCont(map[string]interface{}{"`id`": receivedValue.Id})
if err != nil {
publicmethod.Result(107, err, c)
return
}
//获取指标单位
var unitTitle string
var postTargetDetailInfo modelskpi.PostTargetDetails
overall.CONSTANT_DB_KPI.Where(map[string]interface{}{"`id`": postShemeCont.DetailsId}).First(&postTargetDetailInfo)
unitTitle = postTargetDetailInfo.Company
var targetUnit modelskpi.PostTarget
overall.CONSTANT_DB_KPI.Model(&modelskpi.PostTarget{}).Select("`unit`,`title`").Where(map[string]interface{}{"`id`": postShemeCont.TargetId}).First(&targetUnit)
if unitTitle == "" {
unitTitle = targetUnit.Unit
}
if receivedValue.UserKey == "" {
publicmethod.Result(101, receivedValue, c)
return
}
//获取被考核人基本信息
var userCont modelshr.PersonArchives
err = userCont.GetCont(map[string]interface{}{"`key`": receivedValue.UserKey}, "`company`", "`maindeparment`", "`admin_org`", "`position`", "`wechat`", "`work_wechat`", "`key`")
if err != nil {
publicmethod.Result(107, err, c)
return
}
if receivedValue.AddOrDecrease == 0 {
receivedValue.AddOrDecrease = 2
}
if receivedValue.Punishmode == 0 {
receivedValue.Punishmode = 1
}
var scoreVal float64 = 0
var moneyVal float64 = 0
isTrue := false
var msg string
switch receivedValue.Punishmode {
case 1:
scoreVal, isTrue, msg = judgeScoreOrMoneyIsTrue(receivedValue.ScoreState, receivedValue.Score, float64(postShemeCont.MaxScore), float64(postShemeCont.MinScore))
if isTrue != true {
publicmethod.Result(1, isTrue, c, msg)
return
}
case 2:
moneyVal, isTrue, msg = judgeScoreOrMoneyIsTrue(receivedValue.MoneyState, receivedValue.Money, float64(postShemeCont.Maxmoney), float64(postShemeCont.Minmoney))
if isTrue != true {
publicmethod.Result(1, isTrue, c, msg)
return
}
case 3:
scoreVal, isTrue, msg = judgeScoreOrMoneyIsTrue(receivedValue.ScoreState, receivedValue.Score, float64(postShemeCont.MaxScore), float64(postShemeCont.MinScore))
if isTrue != true {
publicmethod.Result(1, isTrue, c, msg)
return
}
moneyVal, isTrue, msg = judgeScoreOrMoneyIsTrue(receivedValue.MoneyState, receivedValue.Money, float64(postShemeCont.Maxmoney), float64(postShemeCont.Minmoney))
if isTrue != true {
publicmethod.Result(1, isTrue, c, msg)
return
}
}
if receivedValue.Count == 0 {
receivedValue.Count = 1
}
currentTime := time.Now().Unix()
if receivedValue.HappenTime != "" {
happTime, timeErr := publicmethod.DateToTimeStamp(receivedValue.HappenTime)
if timeErr == true {
currentTime = happTime
}
}
if receivedValue.Rectification == 0 {
receivedValue.Rectification = 2
}
var correctionTime int64 = 0
if receivedValue.Rectification == 1 {
if receivedValue.CorrectionPeriod == "" {
publicmethod.Result(1, isTrue, c, "请选择什么时间前整改完成!")
return
}
var corrTimeErr bool = false
correctionTime, corrTimeErr = publicmethod.DateToTimeStamp(receivedValue.CorrectionPeriod)
if corrTimeErr == false {
publicmethod.Result(1, corrTimeErr, c, "请输入整改期限时间格式不对,谢谢!")
return
}
}
//获取登录人信息
context, _ := publicmethod.LoginMyCont(c)
uuId := publicmethod.GetUUid(1)
addTime := time.Now().Unix()
//生成工作流
wechatOpenId := context.Wechat
if context.WorkWechat != "" {
wechatOpenId = context.WorkWechat
}
var reviewFlowCont flowchart.ReviewFlow
reviewFlowCont.Id = receivedValue.Id
reviewFlowCont.IsCorrection = receivedValue.Rectification
reviewFlowCont.PlusReduction = receivedValue.AddOrDecrease
reviewFlowCont.PeopleList = append(reviewFlowCont.PeopleList, receivedValue.UserKey)
flowMap, _ := flowchart.SetUpWorkFlow(wechatOpenId, context.MainDeparment, reviewFlowCont, 1)
var sendUserList []string //审批人列表
var sendTitle string //标题
//获取下一个节点审批人
for _, v := range flowMap {
if v.Step == 2 {
sendTitle = v.NodeName
for _, vu := range v.UserList {
// fmt.Printf("vu------------>%v\n", vu)
if publicmethod.IsInTrue[string](vu.Wechat, sendUserList) == false {
sendUserList = append(sendUserList, vu.Wechat)
}
}
}
}
//流程列表
var flowCont modelskpi.PostWorkflowOrders
flowCont.OrderId = uuId //审批单ID"`
flowCont.Step = 1 //当前执行到第几步"`
flowCont.NextStep = 2 //下一步执行哪个步骤"`
sumStep := len(flowMap)
if sumStep-1 > 0 {
sumStep = sumStep - 1
} else {
sumStep = 1
}
flowCont.CountStep = sumStep
flowMapJson, _ := json.Marshal(flowMap)
flowCont.WorkFlow = string(flowMapJson) //工作流(审批json字符串)"`
flowCont.CompanyId = userCont.Company //公司"`
flowCont.DepartmentId = userCont.MainDeparment //部门"`
flowCont.OrgId = userCont.AdminOrg //行政组织"`
flowCont.PostId = userCont.Position //岗位"`
flowCont.Class = postShemeCont.Attribute //属性1、定性;2、定量"`
flowCont.Dimension = postShemeCont.DimensionId //维度"`
flowCont.Target = postShemeCont.TargetId //指标"`
flowCont.SonTarget = postShemeCont.SonTargetId //指标子栏目"`
flowCont.Detailed = postShemeCont.DetailsId //指标细则"`
flowCont.Executor = context.Key //执行人"`
flowCont.ExecutorDepartment = context.MainDeparment //执行人部门"`
flowCont.State = 3 //流程状态 1:草稿;2:驳回;3:审批中;4:归档;5:废弃;6:删除"`
flowCont.StartTime = time.Now().Unix() //流程开始时间"`
flowCont.Time = time.Now().Unix() //时间"`
if len(receivedValue.Enclosure) > 0 {
jsonFileList, _ := json.Marshal(receivedValue.Enclosure)
flowCont.EnclosureFormat = string(jsonFileList) //附件"`
}
//定性考核流水
var postNatureFlowCont modelskpi.PostNatureFlow
postNatureFlowCont.OrderId = uuId //审批单ID"`
postNatureFlowCont.AddOrDecrease = receivedValue.AddOrDecrease //增加或减少(1:增加;2:减少)"`
postNatureFlowCont.Score = scoreVal //分值(*100保存)"`
postNatureFlowCont.Money = moneyVal //钱(扣款或奖励)*100保存"`
postNatureFlowCont.Reason = receivedValue.Reason //这样操作的原因"`
postNatureFlowCont.ShemeId = postShemeCont.Id //方案ID"`
postNatureFlowCont.ShemeVersion = postShemeCont.VersionNumber //方案版本编号"`
postNatureFlowCont.Dimension = postShemeCont.DimensionId //维度"`
postNatureFlowCont.Target = postShemeCont.TargetId //指标"`
postNatureFlowCont.SonTarget = postShemeCont.SonTargetId //指标子栏目"`
postNatureFlowCont.Detailed = postShemeCont.DetailsId //指标细则"`
postNatureFlowCont.Year = publicmethod.ComputingTime(currentTime, 1) //年"`
postNatureFlowCont.Quarter = publicmethod.ComputingTime(currentTime, 2) //季度"`
postNatureFlowCont.Month = publicmethod.ComputingTime(currentTime, 3) //月"`
postNatureFlowCont.Week = publicmethod.ComputingTime(currentTime, 4) //周"`
postNatureFlowCont.PersonLiable = userCont.Key //责任人"`
postNatureFlowCont.CompanyId = userCont.Company //公司"`
postNatureFlowCont.DepartmentId = userCont.MainDeparment //部门"`
postNatureFlowCont.OrgId = userCont.AdminOrg //行政组织"`
postNatureFlowCont.PostId = userCont.Position //岗位"`
postNatureFlowCont.Executor = context.Key //执行人"`
postNatureFlowCont.ExecutorDepartment = context.MainDeparment //执行人部门"`
postNatureFlowCont.Rectification = receivedValue.Rectification //是否需要整改 1、需要整改;2:无需整改"`
postNatureFlowCont.CorrectionTime = correctionTime //整改期限"`
postNatureFlowCont.HappenTime = currentTime //发生时间"`
postNatureFlowCont.HappenCount = receivedValue.Count //发生次数"`
postNatureFlowCont.Time = time.Now().Unix() //时间"`
// publicmethod.Result(1, postNatureFlowCont, c, msg)
// return
//开启事务提交
gormDbAffair := overall.CONSTANT_DB_KPI.Begin()
passorErr := gormDbAffair.Create(&flowCont).Error
flowErr := gormDbAffair.Create(&postNatureFlowCont).Error
// openAppChangeErr := gormDbAffair.Create(&openAppChangeLog).Error
if passorErr == nil && flowErr == nil {
addErr := gormDbAffair.Commit().Error
publicmethod.Result(0, addErr, c)
if len(sendUserList) > 0 {
//项下一个审批节点发送审批通知
//头部信息
var sourceText wechatsendmsg.SourceText
sourceText.IconUrl = "https://docu.hxgk.group/images/2022_01/3f7a1120a559e9bee3991b85eb34d103.png"
sourceText.Desc = fmt.Sprintf("恒信高科-%v", sendTitle)
sourceText.DescColor = 1
//考核标准
var sunTextCont string
var quoteTextCont string
switch postTargetDetailInfo.Punishmode {
case 2:
var moneyTitle string
if receivedValue.AddOrDecrease == 1 {
moneyTitle = "现金奖励标准"
quoteTextCont = fmt.Sprintf("奖励现金:%v元", receivedValue.Money)
} else {
moneyTitle = "现金罚款标准"
quoteTextCont = fmt.Sprintf("罚款现金:%v元", receivedValue.Money)
}
var scoreStr string
if postTargetDetailInfo.Minmoney != 0 {
scoreStr = fmt.Sprintf("%v元-%v元", publicmethod.DecimalEs(float64(postTargetDetailInfo.Minmoney)/100, 2), publicmethod.DecimalEs(float64(postTargetDetailInfo.Maxmoney)/100, 2))
} else {
scoreStr = fmt.Sprintf("%v元", publicmethod.DecimalEs(float64(postTargetDetailInfo.Maxmoney)/100, 2))
}
sunTextCont = fmt.Sprintf("%v:%v", moneyTitle, scoreStr)
if receivedValue.Reason != "" {
quoteTextCont = fmt.Sprintf("%v\n备注:%v", quoteTextCont, receivedValue.Reason)
}
case 3:
var moneyTitle string
var scoreTitle string
if receivedValue.AddOrDecrease == 1 {
moneyTitle = "现金奖励标准"
scoreTitle = "考核扣分标准"
quoteTextCont = fmt.Sprintf("考核加:%v%v\n奖励现金:%v元", receivedValue.Score, unitTitle, receivedValue.Money)
} else {
moneyTitle = "现金罚款标准"
scoreTitle = "考核加分标准"
quoteTextCont = fmt.Sprintf("考核扣:%v%v\n罚款现金:%v元", receivedValue.Score, unitTitle, receivedValue.Money)
}
var scoreStr string
if postTargetDetailInfo.MinScore != 0 {
scoreStr = fmt.Sprintf("%v%v-%v%v", publicmethod.DecimalEs(float64(postTargetDetailInfo.MinScore)/100, 2), unitTitle, publicmethod.DecimalEs(float64(postTargetDetailInfo.MaxScore)/100, 2), unitTitle)
} else {
scoreStr = fmt.Sprintf("%v%v", publicmethod.DecimalEs(float64(postTargetDetailInfo.MaxScore)/100, 2), unitTitle)
}
sunTextCont = fmt.Sprintf("%v:%v", scoreTitle, scoreStr)
if postTargetDetailInfo.Minmoney != 0 {
sunTextCont = fmt.Sprintf("%v\n%v:%v元-%v元", sunTextCont, moneyTitle, publicmethod.DecimalEs(float64(postTargetDetailInfo.Minmoney)/100, 2), publicmethod.DecimalEs(float64(postTargetDetailInfo.Maxmoney)/100, 2))
} else {
sunTextCont = fmt.Sprintf("%v\n%v:%v元", sunTextCont, moneyTitle, publicmethod.DecimalEs(float64(postTargetDetailInfo.Maxmoney)/100, 2))
}
if receivedValue.Reason != "" {
quoteTextCont = fmt.Sprintf("%v\n备注:%v", quoteTextCont, receivedValue.Reason)
}
default:
var scoreTitle string
if receivedValue.AddOrDecrease == 1 {
scoreTitle = "考核加分标准"
quoteTextCont = fmt.Sprintf("考核加:%v%v", receivedValue.Score, unitTitle)
} else {
scoreTitle = "考核扣分标准"
quoteTextCont = fmt.Sprintf("考核扣:%v%v", receivedValue.Score, unitTitle)
}
var scoreStr string
if postTargetDetailInfo.MinScore != 0 {
scoreStr = fmt.Sprintf("%v%v-%v%v", publicmethod.DecimalEs(float64(postTargetDetailInfo.MinScore)/100, 2), unitTitle, publicmethod.DecimalEs(float64(postTargetDetailInfo.MaxScore)/100, 2), unitTitle)
} else {
scoreStr = fmt.Sprintf("%v%v", publicmethod.DecimalEs(float64(postTargetDetailInfo.MaxScore)/100, 2), unitTitle)
}
sunTextCont = fmt.Sprintf("%v:%v", scoreTitle, scoreStr)
if receivedValue.Reason != "" {
quoteTextCont = fmt.Sprintf("%v\n备注:%v", quoteTextCont, receivedValue.Reason)
}
}
//引用文献
var quoteAreaInfo wechatsendmsg.QuoteAreaCont
quoteAreaInfo.Type = 0
quoteAreaInfo.Title = "考核明细"
quoteAreaInfo.QuoteText = quoteTextCont
//按钮
var buttonList []wechatsendmsg.ButtonListCont
var buttonList1 wechatsendmsg.ButtonListCont
buttonList1.Text = "批准"
buttonList1.Style = 1
buttonList1.Key = fmt.Sprintf("KPI_post_%v_%v_%v", uuId, 1, 2)
buttonList = append(buttonList, buttonList1)
var buttonList2 wechatsendmsg.ButtonListCont
buttonList2.Text = "驳回"
buttonList2.Style = 3
buttonList2.Key = fmt.Sprintf("KPI_post_%v_%v_%v", uuId, 2, 2)
buttonList = append(buttonList, buttonList2)
//二级标题+文本列表
var twoTitleTextList []wechatsendmsg.HorizontalContentListInfo
//发送人
var horizontalContentLis3 wechatsendmsg.HorizontalContentListInfo
horizontalContentLis3.KeyName = "申请人:"
horizontalContentLis3.Value = "点击查看"
horizontalContentLis3.Type = 3
horizontalContentLis3.Userid = wechatOpenId
twoTitleTextList = append(twoTitleTextList, horizontalContentLis3)
//被考核人
if userCont.Wechat != "" || userCont.WorkWechat != "" {
weChatStrs := userCont.Wechat
if userCont.WorkWechat != "" {
weChatStrs = userCont.WorkWechat
}
var twoTitleTextCont wechatsendmsg.HorizontalContentListInfo
twoTitleTextCont.KeyName = "被考核人:"
twoTitleTextCont.Value = "点击查看"
twoTitleTextCont.Type = 3
twoTitleTextCont.Userid = weChatStrs
twoTitleTextList = append(twoTitleTextList, twoTitleTextCont)
}
//卡片跳转地址
var cardActionContStr wechatsendmsg.CardActionCont
cardActionContStr.Type = 1
cardActionContStr.Url = fmt.Sprintf("http://new.hxgk.group/#/quantitativeList?id=%v", uuId)
var sendButtionMsg wechatsendmsg.SendButtonInteractionSimplify
sendButtionMsg.Touser = strings.Join(sendUserList, "|")
// sendButtionMsg.Touser = "KaiXinGuo" //指定接收消息的成员,成员ID列表;特殊情况:指定为
sendButtionMsg.Msgtype = "template_card"
agentIdInt, _ := strconv.ParseInt(overall.CONSTANT_CONFIG.WechatKpi.Agentid, 10, 64)
sendButtionMsg.Agentid = agentIdInt
sendButtionMsg.EnableDuplicateCheck = 0
sendButtionMsg.DuplicateCheckInterval = 1800
sendButtionMsg.EnableIdTrans = 0
sendButtionMsg.TemplateCard.CardType = "button_interaction"
sendButtionMsg.TemplateCard.Source = sourceText
sendButtionMsg.TemplateCard.TaskId = fmt.Sprintf("KPI_%v", uuId)
sendButtionMsg.TemplateCard.MainTitle.Title = targetUnit.Title
descInfo := postTargetDetailInfo.Title
// if postTargetDetailInfo.CensorCont != "" {
// descInfo = fmt.Sprintf("%v\n检查依据:%v", descInfo, postTargetDetailInfo.CensorCont)
// }
// if postTargetDetailInfo.Content != "" {
// if descInfo != "" {
// descInfo = fmt.Sprintf("%v\n备注:%v", descInfo, postTargetDetailInfo.Content)
// } else {
// descInfo = fmt.Sprintf("备注:%v", postTargetDetailInfo.Content)
// }
// }
sendButtionMsg.TemplateCard.MainTitle.Desc = descInfo
sendButtionMsg.TemplateCard.QuoteArea = quoteAreaInfo
sendButtionMsg.TemplateCard.SubTitleText = sunTextCont
sendButtionMsg.TemplateCard.ButtonList = buttonList
sendButtionMsg.TemplateCard.HorizontalContentList = twoTitleTextList
sendButtionMsg.TemplateCard.CardAction = cardActionContStr
callData, err := sendButtionMsg.SendMsg("kpi")
if err == nil {
if callData.Errcode == 0 {
// var operatorIsTrueCont modelskpi.OperatorIsTrue
// operatorIsTrueCont.OrderId = uuId //订单ID"`
// operatorIsTrueCont.Step = 1 //审批到第几步"`
// operatorIsTrueCont.State = 1 //:状态:1:可操作;2:不可操作"`
// operatorIsTrueCont.Time = addTime //操作时间"`
// operatorIsTrueCont.Msgid = callData.Msgid //:消息id,用于撤回应用消息"`
// operatorIsTrueCont.ResponseCode = callData.ResponseCode //仅消息类型为“按钮交互型”,“投票选择型”和“多项选择型”的模板卡片消息返回,应用可使用response_code调用更新模版卡片消息接口,24小时内有效,且只能使用一次"`
// operatorIsTrueCont.Stepper = 1
// overall.CONSTANT_DB_KPI.Create(&operatorIsTrueCont)
var openAppChangeLog modelskpi.OpenApprovalChangeLog
openAppChangeLog.Type = 2
openAppChangeLog.Title = "创建申请"
openAppChangeLog.Operator = context.Key
openAppChangeLog.OrderId = uuId // 审批单ID"`
openAppChangeLog.OperatorTime = addTime
openAppChangeLog.Step = 1
openAppChangeLog.OperatorType = 2
openAppChangeLog.Msgid = callData.Msgid //:消息id,用于撤回应用消息"`
openAppChangeLog.ResponseCode = callData.ResponseCode //仅消息类型为“按钮交互型”,“投票选择型”和“多项选择型”的模板卡片消息返回,应用可使用response_code调用更新模版卡片消息接口,24小时内有效,且只能使用一次"`
openAppChangeLog.Stepper = 1
openAppChangeLog.ChangeIsTrue = 1 //是否可变更(1:可变更;2:不可变更)"`
openAppChangeLog.Eiteyime = addTime
openAppChangeLog.YesOrNo = 1
overall.CONSTANT_DB_KPI.Create(&openAppChangeLog)
}
}
// jsonstr, _ := json.Marshal(callData)
// fmt.Printf("callData------>%v--------err--------->%v--------->%v\n", callData, err, string(jsonstr))
}
} else {
addErr := gormDbAffair.Rollback().Error
publicmethod.Result(104, addErr, c)
}
// fmt.Printf("%v---%v---%v---%v---%v\n", currentTime, uuId, flowCont, scoreVal, moneyVal)
}
/*
判断分数是否符合要求
@scoreState 1定分2区间分3不定性分值
@score 要操作的数值
@MaxScore 最大值
@minScore 最小值
*/
func judgeScoreOrMoneyIsTrue(scoreState int, score string, maxScore, minScore float64) (scoreInt64 float64, isTrue bool, msg string) {
isTrue = false
// fmt.Printf("\n\nscoreState:%v\n\nscore:%v\n\nmaxScore:%v\n\nminScore:%v\n\n", scoreState, score, maxScore, minScore)
switch scoreState {
case 2, 3:
if score == "" {
return
}
scoreInt64, _ = strconv.ParseFloat(score, 64)
scoreInt64 = scoreInt64 * 100
if scoreInt64 > maxScore {
msg = fmt.Sprintf("您提交的数值超过允许提交的最大值(最大值:%v)!", float64(maxScore)/100)
return
}
if scoreInt64 < minScore {
msg = fmt.Sprintf("您提交的数值低于允许提交的最小值(最小值:%v)!", float64(minScore)/100)
return
}
isTrue = true
case 1:
scoreInt64, _ = strconv.ParseFloat(score, 64)
scoreInt64 = scoreInt64 * 100
isTrue = true
default:
msg = "请您输入要操作的数据,谢谢!"
return
}
// fmt.Printf("\nscoreInt64:%v\n\nisTrue:%v\n\nmsg:%v\n\n", scoreInt64, isTrue, msg)
return
}
// 整改措施
func (a *ApiMethod) PostRectificationMeasures(c *gin.Context) {
var receivedValue publicmethod.CorrectiveMeasuresType
c.ShouldBindJSON(&receivedValue)
if receivedValue.OrderId == "" || receivedValue.Register == "" || receivedValue.Content == "" {
publicmethod.Result(101, receivedValue, c)
return
}
//判断此号码是否可以使用
var setUpRegister modelskpi.Register
err := setUpRegister.GetCont(map[string]interface{}{"`number`": receivedValue.Register}, "`state`", "`id`")
if err != nil {
publicmethod.Result(1, err, c, "你们不是此考核项整改的责任人!您无权进行此项操作!")
return
}
if setUpRegister.State != 1 {
publicmethod.Result(1, err, c, "此考核项已经提交过整改方案!")
return
}
syncSeting.Add(1)
go UpdateRegister(setUpRegister.Id, 2)
//获取登录人信息
context, _ := publicmethod.LoginMyCont(c)
//获取审批流
var pwoCont modelskpi.PostWorkflowOrders
err = pwoCont.GetCont(map[string]interface{}{"`order_id`": receivedValue.OrderId})
if err != nil {
publicmethod.Result(1, err, c, "不存在的审批整改项目!")
return
}
if pwoCont.State != 3 {
publicmethod.Result(1, err, c, "此考核项目已经审批结束!请不要重复提交整改措施!")
return
}
if pwoCont.Class == 1 { //定性
var pnfCont modelskpi.PostNatureFlow
err = pnfCont.GetCont(map[string]interface{}{"`order_id`": receivedValue.OrderId})
if err != nil {
publicmethod.Result(1, err, c, "不存在的审批整改项目!")
return
}
if pnfCont.PersonLiable != context.Key {
publicmethod.Result(1, err, c, "你们不是此考核项整改的责任人!您无权进行此项操作!")
return
}
} else { //定量
var pnfCont modelskpi.PostMeteringFlow
err = pnfCont.GetCont(map[string]interface{}{"`order_id`": receivedValue.OrderId})
if err != nil {
publicmethod.Result(1, err, c, "不存在的审批整改项目!")
return
}
if pnfCont.PersonLiable != context.Key {
publicmethod.Result(1, err, c, "你们不是此考核项整改的责任人!您无权进行此项操作!")
return
}
}
//提交整改内容
var addRecMeas modelskpi.RectificationMeasures
addRecMeas.UserKey = context.Key
addRecMeas.Department = context.MainDeparment
addRecMeas.Group = context.Company
addRecMeas.OrderKey = pwoCont.OrderId
addRecMeas.State = 1
addRecMeas.Time = time.Now().Unix()
addRecMeas.EiteTime = time.Now().Unix()
addRecMeas.Content = receivedValue.Content
if len(receivedValue.Enclosure) > 0 {
enclosure, enclosureErr := json.Marshal(receivedValue.Enclosure)
if enclosureErr == nil {
addRecMeas.Enclosure = string(enclosure) //附件
}
}
err = overall.CONSTANT_DB_KPI.Create(&addRecMeas).Error
if err != nil {
publicmethod.Result(104, err, c)
return
}
//发送下一步审批信息
stepIng := pwoCont.NextStep
if stepIng == 0 {
if pwoCont.CountStep-1 > 0 {
stepIng = pwoCont.CountStep - 1
} else {
stepIng = 1
}
}
flowMap, flowOneCont, _ := wechatcallback.GetOneNodeCont(pwoCont.WorkFlow, stepIng) //获取流程图
nextStep := 0 //下一步执行哪个步骤
flowState := 3 //判断流程状态
switch flowOneCont.RunType {
case 1:
flowState = 3
case 2:
flowState = 3
case 3:
flowState = 4
case 4:
flowState = 4
default:
flowState = 1
}
//判断下一个当前节点是否为最后一个节点
if flowState == 4 {
nextStep = 0
} else {
nextStep = flowOneCont.Step + 1
}
//更新审批流状态
syncSeting.Add(1)
go UpdateStateFlow(pwoCont.Id, nextStep, flowState)
//更新审批工作流json内容
wechatName := context.Wechat
if context.WorkWechat != "" {
wechatName = context.WorkWechat
}
syncSeting.Add(1)
go EidtPostFlowLog(pwoCont.Id, flowMap, flowOneCont, wechatName, 2, stepIng)
//获取下一个执行点位
var nextClickStep int
overall.CONSTANT_DB_KPI.Model(&modelskpi.OpenApprovalChangeLog{}).Select("stepper").Where("`orderid` = ?", pwoCont.OrderId).Order("stepper DESC").First(&nextClickStep)
//执行下一步审批
nextClickStep = nextClickStep + 1
syncSeting.Add(1)
go ApproveFlow("kpi", flowMap, flowOneCont, nextClickStep, pwoCont)
var operatorIsTreu modelskpi.OpenApprovalChangeLog
operatorIsTreu.Type = 2
operatorIsTreu.Title = flowOneCont.NodeName
operatorIsTreu.Operator = context.Key
operatorIsTreu.OrderId = pwoCont.OrderId
operatorIsTreu.OperatorTime = time.Now().Unix()
operatorIsTreu.Step = flowOneCont.Step
operatorIsTreu.OperatorType = 2
operatorIsTreu.Msgid = ""
operatorIsTreu.ResponseCode = ""
operatorIsTreu.Stepper = nextClickStep
operatorIsTreu.ChangeIsTrue = 2
operatorIsTreu.YesOrNo = 1
operatorIsTreu.Eiteyime = time.Now().Unix()
overall.CONSTANT_DB_KPI.Create(&operatorIsTreu)
syncSeting.Wait()
sendMap := publicmethod.MapOut[string]()
sendMap["flowMap"] = flowMap
sendMap["flowOneCont"] = flowOneCont
publicmethod.Result(0, sendMap, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2022-10-09 16:48:09
@ 功能: 更新挂号单
@ 参数
#
@ 返回值
#
*/
func UpdateRegister(id int64, state int) {
defer syncSeting.Done()
var setUpRegister modelskpi.Register
setUpRegister.EiteCont(map[string]interface{}{"`id`": id}, map[string]interface{}{"`state`": state, "`time`": time.Now().Unix()})
}
/*
*
@ 作者: 秦东
@ 时间: 2022-10-08 11:20:38
@ 功能: 同意
@ 参数
#systemApp 系统
#pwoCont 岗位审批工作流
#flowMap 流程结构体
#flowOneCont 当前节点构体
#step 记录值
#liangOrXing 属性1定性2定量
ApproveFlow(systemApp string, flowMap []publicmethod.FlowChartList, flowOneCont publicmethod.FlowChartList, step int, pwoContOld modelskpi.PostWorkflowOrders)
@ 返回值
#
*/
func ApproveFlow(systemApp string, flowMap []publicmethod.FlowChartList, flowOneCont publicmethod.FlowChartList, step int, pwoContOld modelskpi.PostWorkflowOrders) {
defer syncSeting.Done()
nextStep := 0
flowState := 3 //判断流程状态
switch flowOneCont.RunType {
case 1:
flowState = 3
case 2:
flowState = 3
case 3:
flowState = 4
case 4:
flowState = 4
default:
flowState = 1
}
//判断下一个当前节点是否为最后一个节点
if flowState == 4 {
nextStep = 0
} else {
nextStep = flowOneCont.Step + 1
}
//更新审批流状态
var pwoCont modelskpi.PostWorkflowOrders
pwoCont.EiteCont(map[string]interface{}{"`order_id`": pwoContOld.OrderId}, map[string]interface{}{"`next_step`": nextStep, "`state`": flowState, "`time`": time.Now().Unix()}) //改变审批流状态
//获取下一部操作
for _, fv := range flowMap {
if fv.Step == flowOneCont.Step+1 {
var sendToUserList []string //获取发送人
for _, fvu := range fv.UserList {
if publicmethod.IsInTrue[string](fvu.Wechat, sendToUserList) == false {
sendToUserList = append(sendToUserList, fvu.Wechat)
}
}
if len(sendToUserList) > 0 { //存在接收人执行以下操作
var postTarDeta modelskpi.PostTarget
postTarDeta.GetCont(map[string]interface{}{"`id`": pwoContOld.Target}, "`title`")
if fv.Class < 3 {
sendNextStep := step + 1
//发送按钮信息
if pwoContOld.Class == 1 { //定性操作
var postTarDetailsDeta modelskpi.PostTargetDetails
postTarDetailsDeta.GetCont(map[string]interface{}{"`id`": pwoContOld.Detailed}, "`title`", "`punishmode`", "`company`")
unitTitle := postTarDetailsDeta.Company
if unitTitle == "" {
unitTitle = postTarDeta.Unit
}
var postNatuerFlowCont modelskpi.PostNatureFlow
postNatuerFlowCont.GetCont(map[string]interface{}{"`order_id`": pwoContOld.OrderId})
if fv.Class == 2 { //需要填写信息,发送相关信息
//挂号
registerNum := publicmethod.GetUUid(2)
var setUpRegister modelskpi.Register
setUpRegister.Number = registerNum
setUpRegister.State = 1
setUpRegister.Time = time.Now().Unix()
setUpRegister.AddCont()
//抄送信息
markDowmStr := "整改通知"
markDowmStr = fmt.Sprintf("%v\n>**事项详情** ", markDowmStr)
markDowmStr = fmt.Sprintf("%v\n>指标: %v", markDowmStr, postTarDeta.Title)
markDowmStr = fmt.Sprintf("%v\n>指标详情: %v", markDowmStr, postTarDetailsDeta.Title)
markDowmStr = fmt.Sprintf("%v\n><font color=\"info\">发生时间: %v</font> ", markDowmStr, publicmethod.UnixTimeToDay(postNatuerFlowCont.HappenTime, 1))
switch postTarDetailsDeta.Punishmode {
case 1:
if postNatuerFlowCont.Score != 0 {
scoreFloat := (float64(postNatuerFlowCont.Score) * float64(postNatuerFlowCont.HappenCount)) / 100
if postNatuerFlowCont.AddOrDecrease == 1 {
//增加
markDowmStr = fmt.Sprintf("%v\n>奖励: %v%v", markDowmStr, publicmethod.DecimalEs(scoreFloat, 2), postTarDetailsDeta.Company)
} else {
//减少
markDowmStr = fmt.Sprintf("%v\n>减少: %v%v", markDowmStr, publicmethod.DecimalEs(scoreFloat, 2), postTarDetailsDeta.Company)
}
}
case 2:
if postNatuerFlowCont.Money != 0 {
moneyFloat := float64(postNatuerFlowCont.Money) / 100
if postNatuerFlowCont.AddOrDecrease == 1 {
//增加
markDowmStr = fmt.Sprintf("%v\n>奖励: %v元", markDowmStr, publicmethod.DecimalEs(moneyFloat, 2))
} else {
//减少
markDowmStr = fmt.Sprintf("%v\n>减少: %v元", markDowmStr, publicmethod.DecimalEs(moneyFloat, 2))
}
}
default:
if postNatuerFlowCont.Score != 0 {
scoreFloat := (float64(postNatuerFlowCont.Score) * float64(postNatuerFlowCont.HappenCount)) / 100
if postNatuerFlowCont.AddOrDecrease == 1 {
//增加
markDowmStr = fmt.Sprintf("%v\n>增奖励: %v%v", markDowmStr, publicmethod.DecimalEs(scoreFloat, 2), postTarDetailsDeta.Company)
} else {
//减少
markDowmStr = fmt.Sprintf("%v\n>减少: %v%v", markDowmStr, publicmethod.DecimalEs(scoreFloat, 2), postTarDetailsDeta.Company)
}
}
if postNatuerFlowCont.Money != 0 {
moneyFloat := float64(postNatuerFlowCont.Money) / 100
if postNatuerFlowCont.AddOrDecrease == 1 {
//增加
markDowmStr = fmt.Sprintf("%v\n>奖励: %v元", markDowmStr, publicmethod.DecimalEs(moneyFloat, 2))
} else {
//减少
markDowmStr = fmt.Sprintf("%v\n>减少: %v元", markDowmStr, publicmethod.DecimalEs(moneyFloat, 2))
}
}
}
//获取提报人信息
var zeRenRenCont modelshr.PersonArchives
zeRenRenCont.GetCont(map[string]interface{}{"`key`": postNatuerFlowCont.Executor}, "`name`", "`number`")
markDowmStr = fmt.Sprintf("%v\n> \n><font color=\"warning\">提报人: %v(%v)</font>", markDowmStr, zeRenRenCont.Name, zeRenRenCont.Number)
markDowmStr = fmt.Sprintf("%v\n>\n>[填写整改措施](http://new.hxgk.group/#/rectification?id=%v&num=%v)", markDowmStr, pwoContOld.OrderId, registerNum)
//发送同通信息
wechatcallback.SendNoticeMsg(sendToUserList, markDowmStr, systemApp)
} else { //无需填写信息。继续发送
//考核标准
var sunTextCont string
var quoteTextCont string
switch postTarDetailsDeta.Punishmode {
case 2:
var moneyTitle string
if postNatuerFlowCont.AddOrDecrease == 1 {
moneyTitle = "现金奖励标准"
quoteTextCont = fmt.Sprintf("奖励现金:%v元", postNatuerFlowCont.Money)
} else {
moneyTitle = "现金罚款标准"
quoteTextCont = fmt.Sprintf("罚款现金:%v元", postNatuerFlowCont.Money)
}
var scoreStr string
if postTarDetailsDeta.Minmoney != 0 {
scoreStr = fmt.Sprintf("%v元-%v元", publicmethod.DecimalEs(float64(postTarDetailsDeta.Minmoney)/100, 2), publicmethod.DecimalEs(float64(postTarDetailsDeta.Maxmoney)/100, 2))
} else {
scoreStr = fmt.Sprintf("%v元", publicmethod.DecimalEs(float64(postTarDetailsDeta.Maxmoney)/100, 2))
}
sunTextCont = fmt.Sprintf("%v:%v", moneyTitle, scoreStr)
if postNatuerFlowCont.Reason != "" {
quoteTextCont = fmt.Sprintf("%v\n备注:%v", quoteTextCont, postNatuerFlowCont.Reason)
}
case 3:
var moneyTitle string
var scoreTitle string
if postNatuerFlowCont.AddOrDecrease == 1 {
moneyTitle = "现金奖励标准"
scoreTitle = "考核扣分标准"
quoteTextCont = fmt.Sprintf("考核加:%v%v\n奖励现金:%v元", postNatuerFlowCont.Score, unitTitle, postNatuerFlowCont.Money)
} else {
moneyTitle = "现金罚款标准"
scoreTitle = "考核加分标准"
quoteTextCont = fmt.Sprintf("考核扣:%v%v\n罚款现金:%v元", postNatuerFlowCont.Score, unitTitle, postNatuerFlowCont.Money)
}
var scoreStr string
if postTarDetailsDeta.MinScore != 0 {
scoreStr = fmt.Sprintf("%v%v-%v%v", publicmethod.DecimalEs(float64(postTarDetailsDeta.MinScore)/100, 2), unitTitle, publicmethod.DecimalEs(float64(postTarDetailsDeta.MaxScore)/100, 2), unitTitle)
} else {
scoreStr = fmt.Sprintf("%v%v", publicmethod.DecimalEs(float64(postTarDetailsDeta.MaxScore)/100, 2), unitTitle)
}
sunTextCont = fmt.Sprintf("%v:%v", scoreTitle, scoreStr)
if postTarDetailsDeta.Minmoney != 0 {
sunTextCont = fmt.Sprintf("%v\n%v:%v元-%v元", sunTextCont, moneyTitle, publicmethod.DecimalEs(float64(postTarDetailsDeta.Minmoney)/100, 2), publicmethod.DecimalEs(float64(postTarDetailsDeta.Maxmoney)/100, 2))
} else {
sunTextCont = fmt.Sprintf("%v\n%v:%v元", sunTextCont, moneyTitle, publicmethod.DecimalEs(float64(postTarDetailsDeta.Maxmoney)/100, 2))
}
if postNatuerFlowCont.Reason != "" {
quoteTextCont = fmt.Sprintf("%v\n备注:%v", quoteTextCont, postNatuerFlowCont.Reason)
}
default:
var scoreTitle string
if postNatuerFlowCont.AddOrDecrease == 1 {
scoreTitle = "考核加分标准"
quoteTextCont = fmt.Sprintf("考核加:%v%v", postNatuerFlowCont.Score, unitTitle)
} else {
scoreTitle = "考核扣分标准"
quoteTextCont = fmt.Sprintf("考核扣:%v%v", postNatuerFlowCont.Score, unitTitle)
}
var scoreStr string
if postTarDetailsDeta.MinScore != 0 {
scoreStr = fmt.Sprintf("%v%v-%v%v", publicmethod.DecimalEs(float64(postTarDetailsDeta.MinScore)/100, 2), unitTitle, publicmethod.DecimalEs(float64(postTarDetailsDeta.MaxScore)/100, 2), unitTitle)
} else {
scoreStr = fmt.Sprintf("%v%v", publicmethod.DecimalEs(float64(postTarDetailsDeta.MaxScore)/100, 2), unitTitle)
}
sunTextCont = fmt.Sprintf("%v:%v", scoreTitle, scoreStr)
if postNatuerFlowCont.Reason != "" {
quoteTextCont = fmt.Sprintf("%v\n备注:%v", quoteTextCont, postNatuerFlowCont.Reason)
}
}
var quoteAreaInfo wechatsendmsg.QuoteAreaCont
quoteAreaInfo.Type = 0
quoteAreaInfo.Title = "考核明细"
quoteAreaInfo.QuoteText = quoteTextCont
//二级标题+文本列表
var twoTitleTextList []wechatsendmsg.HorizontalContentListInfo
var shenQingRen modelshr.PersonArchives
shenQingRen.GetCont(map[string]interface{}{"`key`": postNatuerFlowCont.Executor}, "`wechat`", "`work_wechat`")
if shenQingRen.Wechat != "" || shenQingRen.WorkWechat != "" {
wechatOpenId := shenQingRen.Wechat
if shenQingRen.WorkWechat != "" {
wechatOpenId = shenQingRen.WorkWechat
}
//发送人
var horizontalContentLis3 wechatsendmsg.HorizontalContentListInfo
horizontalContentLis3.KeyName = "申请人:"
horizontalContentLis3.Value = "点击查看"
horizontalContentLis3.Type = 3
horizontalContentLis3.Userid = wechatOpenId
twoTitleTextList = append(twoTitleTextList, horizontalContentLis3)
}
var beiKaoHeRen modelshr.PersonArchives
beiKaoHeRen.GetCont(map[string]interface{}{"`key`": postNatuerFlowCont.Executor}, "`wechat`", "`work_wechat`")
//被考核人
if beiKaoHeRen.Wechat != "" || beiKaoHeRen.WorkWechat != "" {
weChatStrs := beiKaoHeRen.Wechat
if beiKaoHeRen.WorkWechat != "" {
weChatStrs = beiKaoHeRen.WorkWechat
}
var twoTitleTextCont wechatsendmsg.HorizontalContentListInfo
twoTitleTextCont.KeyName = "被考核人:"
twoTitleTextCont.Value = "点击查看"
twoTitleTextCont.Type = 3
twoTitleTextCont.Userid = weChatStrs
twoTitleTextList = append(twoTitleTextList, twoTitleTextCont)
}
wechatcallback.SendButtonCard(systemApp, postTarDeta.Title, postTarDetailsDeta.Title, sunTextCont, fv.NodeName, pwoContOld.OrderId, sendNextStep, sendToUserList, quoteAreaInfo, twoTitleTextList)
}
} else { //定量操作
//定量操作
var postMeterFlowCont modelskpi.PostMeteringFlow
postMeterFlowCont.GetCont(map[string]interface{}{"`order_id`": pwoContOld.OrderId})
//获取考核项目信息
var postShemeCont modelskpi.QualitativeEvaluationScheme
postShemeCont.GetCont(map[string]interface{}{"`id`": postMeterFlowCont.ShemeId})
//引用文献
var quoteAreaInfo wechatsendmsg.QuoteAreaCont
quoteAreaInfo.Type = 0
quoteAreaInfo.Title = "数据详细"
quoteAreaInfo.QuoteText = fmt.Sprintf("数值:%v%v\n备注:%v", publicmethod.DecimalEs(postMeterFlowCont.Score, 2), postTarDeta.Unit, postMeterFlowCont.Reason)
//二级标题+文本列表
var twoTitleTextList []wechatsendmsg.HorizontalContentListInfo
var shenQingRen modelshr.PersonArchives
shenQingRen.GetCont(map[string]interface{}{"`key`": postMeterFlowCont.Executor}, "`wechat`", "`work_wechat`")
if shenQingRen.Wechat != "" || shenQingRen.WorkWechat != "" {
wechatOpenId := shenQingRen.Wechat
if shenQingRen.WorkWechat != "" {
wechatOpenId = shenQingRen.WorkWechat
}
//发送人
var horizontalContentLis3 wechatsendmsg.HorizontalContentListInfo
horizontalContentLis3.KeyName = "申请人:"
horizontalContentLis3.Value = "点击查看"
horizontalContentLis3.Type = 3
horizontalContentLis3.Userid = wechatOpenId
twoTitleTextList = append(twoTitleTextList, horizontalContentLis3)
}
var beiKaoHeRen modelshr.PersonArchives
beiKaoHeRen.GetCont(map[string]interface{}{"`key`": postMeterFlowCont.Executor}, "`wechat`", "`work_wechat`")
//被考核人
if beiKaoHeRen.Wechat != "" || beiKaoHeRen.WorkWechat != "" {
weChatStrs := beiKaoHeRen.Wechat
if beiKaoHeRen.WorkWechat != "" {
weChatStrs = beiKaoHeRen.WorkWechat
}
var twoTitleTextCont wechatsendmsg.HorizontalContentListInfo
twoTitleTextCont.KeyName = "被考核人:"
twoTitleTextCont.Value = "点击查看"
twoTitleTextCont.Type = 3
twoTitleTextCont.Userid = weChatStrs
twoTitleTextList = append(twoTitleTextList, twoTitleTextCont)
}
wechatcallback.SendButtonCard(systemApp, postShemeCont.Title, postShemeCont.Content, "", fv.NodeName, pwoContOld.OrderId, sendNextStep, sendToUserList, quoteAreaInfo, twoTitleTextList)
}
} else {
//抄送信息
markDowmStr := "审批通过-抄送"
markDowmStr = fmt.Sprintf("%v\n>**事项详情** ", markDowmStr)
markDowmStr = fmt.Sprintf("%v\n>指标: %v", markDowmStr, postTarDeta.Title)
if pwoContOld.Class == 1 {
//定性操作
var postTarDetailsDeta modelskpi.PostTargetDetails
postTarDetailsDeta.GetCont(map[string]interface{}{"`id`": pwoContOld.Detailed}, "`title`", "`punishmode`", "`company`")
markDowmStr = fmt.Sprintf("%v\n>指标详情: %v", markDowmStr, postTarDetailsDeta.Title)
var postNatuerFlowCont modelskpi.PostNatureFlow
postNatuerFlowCont.GetCont(map[string]interface{}{"`order_id`": pwoContOld.OrderId})
switch postTarDetailsDeta.Punishmode {
case 1:
if postNatuerFlowCont.Score != 0 {
scoreFloat := (float64(postNatuerFlowCont.Score) * float64(postNatuerFlowCont.HappenCount)) / 100
if postNatuerFlowCont.AddOrDecrease == 1 {
//增加
markDowmStr = fmt.Sprintf("%v\n>奖励: %v%v", markDowmStr, publicmethod.DecimalEs(scoreFloat, 2), postTarDetailsDeta.Company)
} else {
//减少
markDowmStr = fmt.Sprintf("%v\n>减少: %v%v", markDowmStr, publicmethod.DecimalEs(scoreFloat, 2), postTarDetailsDeta.Company)
}
}
case 2:
if postNatuerFlowCont.Money != 0 {
moneyFloat := float64(postNatuerFlowCont.Money) / 100
if postNatuerFlowCont.AddOrDecrease == 1 {
//增加
markDowmStr = fmt.Sprintf("%v\n>奖励: %v元", markDowmStr, publicmethod.DecimalEs(moneyFloat, 2))
} else {
//减少
markDowmStr = fmt.Sprintf("%v\n>减少: %v元", markDowmStr, publicmethod.DecimalEs(moneyFloat, 2))
}
}
default:
if postNatuerFlowCont.Score != 0 {
scoreFloat := (float64(postNatuerFlowCont.Score) * float64(postNatuerFlowCont.HappenCount)) / 100
if postNatuerFlowCont.AddOrDecrease == 1 {
//增加
markDowmStr = fmt.Sprintf("%v\n>增奖励: %v%v", markDowmStr, publicmethod.DecimalEs(scoreFloat, 2), postTarDetailsDeta.Company)
} else {
//减少
markDowmStr = fmt.Sprintf("%v\n>减少: %v%v", markDowmStr, publicmethod.DecimalEs(scoreFloat, 2), postTarDetailsDeta.Company)
}
}
if postNatuerFlowCont.Money != 0 {
moneyFloat := float64(postNatuerFlowCont.Money) / 100
if postNatuerFlowCont.AddOrDecrease == 1 {
//增加
markDowmStr = fmt.Sprintf("%v\n>奖励: %v元", markDowmStr, publicmethod.DecimalEs(moneyFloat, 2))
} else {
//减少
markDowmStr = fmt.Sprintf("%v\n>减少: %v元", markDowmStr, publicmethod.DecimalEs(moneyFloat, 2))
}
}
}
//获取责任信息
var zeRenRenCont modelshr.PersonArchives
zeRenRenCont.GetCont(map[string]interface{}{"`key`": postNatuerFlowCont.PersonLiable}, "`name`", "`number`")
markDowmStr = fmt.Sprintf("%v\n> \n><font color=\"warning\">被考核人: %v(%v)</font>", markDowmStr, zeRenRenCont.Name, zeRenRenCont.Number)
markDowmStr = fmt.Sprintf("%v\n><font color=\"info\">发生时间: %v</font> ", markDowmStr, publicmethod.UnixTimeToDay(postNatuerFlowCont.HappenTime, 1))
markDowmStr = fmt.Sprintf("%v\n>\n>[查看审批详情](http://new.hxgk.group/#/quantitativeList?id=%v)", markDowmStr, pwoContOld.OrderId)
} else {
//定量操作
var postMeterFlowCont modelskpi.PostMeteringFlow
postMeterFlowCont.GetCont(map[string]interface{}{"`order_id`": pwoContOld.OrderId})
markDowmStr = fmt.Sprintf("%v\n>%v年", markDowmStr, postMeterFlowCont.Year)
switch postTarDeta.Cycle {
case 5:
markDowmStr = fmt.Sprintf("%v\n>%v季度上报数值%v%v", markDowmStr, postMeterFlowCont.Quarter, publicmethod.DecimalEs(postMeterFlowCont.Score, 2), postTarDeta.Unit)
case 6:
markDowmStr = fmt.Sprintf("%v\n>上报数值%v%v", markDowmStr, publicmethod.DecimalEs(postMeterFlowCont.Score, 2), postTarDeta.Unit)
default:
markDowmStr = fmt.Sprintf("%v\n>%v月上报数值%v%v", markDowmStr, postMeterFlowCont.Month, publicmethod.DecimalEs(postMeterFlowCont.Score, 2), postTarDeta.Unit)
}
//获取责任信息
var zeRenRenCont modelshr.PersonArchives
zeRenRenCont.GetCont(map[string]interface{}{"`key`": postMeterFlowCont.PersonLiable}, "`name`", "`number`")
markDowmStr = fmt.Sprintf("%v\n> \n><font color=\"warning\">被考核人: %v(%v)</font>", markDowmStr, zeRenRenCont.Name, zeRenRenCont.Number)
markDowmStr = fmt.Sprintf("%v\n>\n>[查看审批详情](http://new.hxgk.group/#/quantitativeList?id=%v)", markDowmStr, pwoContOld.OrderId)
}
//发送抄送信息
wechatcallback.SendNoticeMsg(sendToUserList, markDowmStr, systemApp)
}
}
}
}
}
/*
*
@ 作者: 秦东
@ 时间: 2022-10-09 16:15:56
@ 功能: 更新审批流
@ 参数
#pwoId 岗位审批工作流ID
#flowMap 流程结构体
#operatorWechat 操作人
#clickEnter 操作
#step 执行的哪一步
@ 返回值
#
*/
func EidtPostFlowLog(pwoId int64, flowMap []publicmethod.FlowChartList, oneFlowCont publicmethod.FlowChartList, operatorWechat string, clickEnter, step int) {
defer syncSeting.Done()
var newFlowMap []publicmethod.FlowChartList
for _, v := range flowMap {
var newFlowMapCont publicmethod.FlowChartList
newFlowMapCont.Step = v.Step //步伐
newFlowMapCont.NodeName = v.NodeName //节点名称
newFlowMapCont.Class = v.Class //节点类型 1、普通节点;2、运行中指定节点
newFlowMapCont.RunType = v.RunType //运行状态(1:开始;2:操作点;3:结束)
newFlowMapCont.NodeRelationship = v.NodeRelationship
if v.Step == oneFlowCont.Step { //获取到当前执行的节点
newFlowMapCont.State = 2 //状态 1、不点亮;2、点亮
for _, uv := range v.UserList { //遍历审批人列表
if uv.Wechat == operatorWechat { //当前操作人
var logCont publicmethod.LogList
switch clickEnter {
case 1:
logCont.State = 2
case 2:
logCont.State = 3
default:
logCont.State = 1
}
logCont.TimeVal = publicmethod.UnixTimeToDay(time.Now().Unix(), 1)
uv.LogList = append(uv.LogList, logCont)
}
newFlowMapCont.UserList = append(newFlowMapCont.UserList, uv)
}
} else {
newFlowMapCont.State = v.Class //状态 1、不点亮;2、点亮
newFlowMapCont.UserList = v.UserList
}
newFlowMap = append(newFlowMap, newFlowMapCont)
}
jsonStr, _ := json.Marshal(newFlowMap)
var pwoCont modelskpi.PostWorkflowOrders
pwoCont.EiteCont(map[string]interface{}{"`id`": pwoId}, map[string]interface{}{"`work_flow`": string(jsonStr), "`time`": time.Now().Unix()})
}
/*
*
@ 作者: 秦东
@ 时间: 2022-10-09 16:09:35
@ 功能: 更新审批状态
@ 参数
#pwoId 审批流ID
#nextStep 下一步
#flowState 流程状态
@ 返回值
#
*/
func UpdateStateFlow(pwoId int64, nextStep, flowState int) {
defer syncSeting.Done()
var pwoCont modelskpi.PostWorkflowOrders
pwoCont.EiteCont(map[string]interface{}{"`id`": pwoId}, map[string]interface{}{"`next_step`": nextStep, "`state`": flowState, "`time`": time.Now().Unix()}) //改变审批流状态
}