Browse Source

审批流同意与驳回

v1_dev_2
超级管理员 3 years ago
parent
commit
095bf14e02
  1. 53
      api/shiyan/maptostruct/cang_chu.go
  2. 4
      api/shiyan/maptostruct/department.go
  3. 542
      api/version1/departmentseting/departmentpc/ding_xing.go
  4. 68
      api/version1/departmentseting/departmentpc/type.go
  5. 161
      api/version1/flowchart/entry.go
  6. 716
      api/version1/flowchart/myworkflow.go
  7. 38
      api/version1/jurisdiction/jurisdictionpc/people.go
  8. 19
      api/version1/jurisdiction/jurisdictionpc/type.go
  9. 2
      api/version1/postseting/postweb/posttarget.go
  10. 2
      api/version1/systemapproval/post_nature.go
  11. 45
      api/workflow/currency_recipe/general_method.go
  12. 26
      api/workflow/currency_recipe/structural_analysis.go
  13. 21
      api/workflow/currency_recipe/type.go
  14. 57
      api/workflow/workflowengine/type.go
  15. 17
      api/workflow/workflowengine/workflow.go
  16. 206
      api/workflow/workflowengine/workflowapi.go
  17. 2
      apirouter/apishiyan/maptostruct.go
  18. 3
      apirouter/v1/departmentseting/pc.go
  19. 5
      apirouter/workflowchart/flowes.go
  20. 2
      apirouter/workflowrouter/flowrouter.go
  21. 2
      middleware/wechatapp/wechatcallback/event_processing.go
  22. 97
      models/modelskpi/approval_record.go
  23. 7
      models/modelskpi/evaluation_process.go
  24. 6
      models/modelskpi/open_approval_change_log.go
  25. 6
      models/modelskpi/qualitative_evaluation.go
  26. 95
      models/modelskpi/qualitative_evaluation_view.go
  27. 12
      models/modelskpi/register.go
  28. 11
      models/modelskpi/work_flow.go
  29. 1
      models/modelskpi/work_flow_cont.go
  30. 17
      models/modelssystempermission/role_empower.go
  31. 64
      overall/publicmethod/formatOutput.go
  32. 230
      overall/publicmethod/technique.go
  33. 9
      overall/publicmethod/type.go

53
api/shiyan/maptostruct/cang_chu.go

@ -2,6 +2,7 @@ package maptostruct
import ( import (
"fmt" "fmt"
"key_performance_indicators/models/modelskpi"
"key_performance_indicators/models/modelsstorage" "key_performance_indicators/models/modelsstorage"
"key_performance_indicators/overall" "key_performance_indicators/overall"
"key_performance_indicators/overall/publicmethod" "key_performance_indicators/overall/publicmethod"
@ -169,3 +170,55 @@ func GetMenuThreePeiQuan(parentId int64, threeData []MaterialCont) []CaiDanShu {
} }
return treeList return treeList
} }
/*
*
@ 作者: 秦东
@ 时间: 2023-04-08 15:25:49
@ 功能: 校正原审批流信息
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) CheckOldWorkflow(c *gin.Context) {
var oldFlowList []modelskpi.EvaluationProcess
err := overall.CONSTANT_DB_KPI.Model(&modelskpi.EvaluationProcess{}).Find(&oldFlowList).Error
if err == nil {
for _, v := range oldFlowList {
if v.TypeClass == 1 {
//定性
var scoreFlowCont modelskpi.ScoreFlow
errSore := scoreFlowCont.GetCont(map[string]interface{}{"`sf_key`": v.OrderKey})
if errSore == nil {
scoreEdit := publicmethod.MapOut[string]()
scoreEdit["ep_setup_department"] = scoreFlowCont.EvaluationDepartment
scoreEdit["ep_target"] = scoreFlowCont.TargetId
scoreEdit["ep_detailedtarget"] = scoreFlowCont.DetailedId
scoreEdit["ep_creater"] = scoreFlowCont.EvaluationUser
var editDingXingEvalPros modelskpi.EvaluationProcess
editDingXingEvalPros.EiteCont(map[string]interface{}{"`ep_id`": v.Id}, scoreEdit)
}
} else {
//定量
var dingLiangCont modelskpi.FlowLog
errSore := dingLiangCont.GetCont(map[string]interface{}{"`fl_key`": v.OrderKey})
if errSore == nil {
scoreEditLiang := publicmethod.MapOut[string]()
scoreEditLiang["ep_setup_department"] = dingLiangCont.EvaluationDepartment
scoreEditLiang["ep_creater"] = dingLiangCont.EvaluationUser
var editDingLiangEvalPros modelskpi.EvaluationProcess
editDingLiangEvalPros.EiteCont(map[string]interface{}{"`ep_id`": v.Id}, scoreEditLiang)
}
}
}
}
}

4
api/shiyan/maptostruct/department.go

@ -364,12 +364,12 @@ func (a *ApiMethod) TestAndVerifyWorkflow(c *gin.Context) {
//自定义判断 //自定义判断
var zdyPd []currency_recipe.CustomFields var zdyPd []currency_recipe.CustomFields
var zdyPdOne currency_recipe.CustomFields var zdyPdOne currency_recipe.CustomFields
zdyPdOne.WordField = "istrue" zdyPdOne.WordField = "attribute"
zdyPdOne.LeftVal = "1" zdyPdOne.LeftVal = "1"
zdyPd = append(zdyPd, zdyPdOne) zdyPd = append(zdyPd, zdyPdOne)
var zdyPdTwo currency_recipe.CustomFields var zdyPdTwo currency_recipe.CustomFields
zdyPdTwo.WordField = "isok" zdyPdTwo.WordField = "correct"
zdyPdTwo.LeftVal = "1" zdyPdTwo.LeftVal = "1"
zdyPd = append(zdyPd, zdyPdTwo) zdyPd = append(zdyPd, zdyPdTwo)
//条件设定 //条件设定

542
api/version1/departmentseting/departmentpc/ding_xing.go

@ -0,0 +1,542 @@
package departmentpc
import (
"encoding/json"
"fmt"
"key_performance_indicators/api/workflow/workflowengine"
"key_performance_indicators/models/modelshonory"
"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"
)
/*
*
@ 作者: 秦东
@ 时间: 2023-04-01 08:16:22
@ 功能: 获取定性考核任务列表
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) GetQualityTasks(c *gin.Context) {
//获取登录人信息
myLoginCont, _ := publicmethod.LoginMyCont(c)
var receivedValue GetQuanTasks
c.ShouldBindJSON(&receivedValue)
if receivedValue.Page == 0 {
receivedValue.Page = 1
}
if receivedValue.PageSize == 0 {
receivedValue.PageSize = 15
}
var qualEvaCont modelskpi.QualitativeEvaluationView
gormDb := overall.CONSTANT_DB_KPI.Table(fmt.Sprintf("%s qe", qualEvaCont.TableName())).Distinct("qe.`qe_accept_evaluation`,qe.`qe_target`,qe.`et_title`").Where("qe.`qe_type` = 1 AND qe.`qe_state` = 1 ")
gormDb = gormDb.Joins("JOIN target_report td ON qe.qe_target = td.target_id AND qe.qe_accept_evaluation = td.`department_id` AND td.target_bylaws = qe.`qe_detailed_target` AND td.`type` = 1 AND td.`post_id` = 0 AND td.state = 1 AND td.type_level = 3 AND td.`man_key` = ?", myLoginCont.Key)
if receivedValue.OrgId != "" {
gormDb = gormDb.Where("`qe_accept_evaluation` = ?", receivedValue.OrgId)
}
if receivedValue.Title != "" {
gormDb = gormDb.Where("et_title LIKE ?", "%"+receivedValue.Title+"%")
}
var total int
var qualEvaListCount []modelskpi.QualitativeEvaluationView
totalErr := gormDb.Find(&qualEvaListCount).Error
if totalErr != nil {
total = 0
} else {
total = len(qualEvaListCount)
}
var qualEvaList []modelskpi.QualitativeEvaluationView
gormDb = publicmethod.PageTurningSettings(gormDb, receivedValue.Page, receivedValue.PageSize)
err := gormDb.Order("qe_accept_evaluation ASC,qe_target ASC").Find(&qualEvaList).Error
if err != nil {
publicmethod.Result(105, err, c)
return
}
todayVal := time.Now().Unix()
yearVal := publicmethod.UnixTimeToDay(todayVal, 16)
monthVal := publicmethod.UnixTimeToDay(todayVal, 17)
if receivedValue.Time != "" {
var dayTime publicmethod.DateTimeTotimes
dayTime.BaisStrToTime(receivedValue.Time)
yearVal = dayTime.Years
monthVal = dayTime.Months
}
var sendContList []OutPutDingXingCont
for _, v := range qualEvaList {
var sendCont OutPutDingXingCont
sendCont.OrgId = strconv.FormatInt(v.AcceptEvaluation, 10) //行政组织Id
var orgCont modelshr.AdministrativeOrganization
orgCont.GetCont(map[string]interface{}{"`id`": v.AcceptEvaluation}, "`name`")
sendCont.OrgName = orgCont.Name
sendCont.TargetId = strconv.FormatInt(v.Target, 10) //指标ID
sendCont.Title = v.EtTitle //指标名称
sendCont.MinusScore, sendCont.BonusPoints = CalculatePlusOrMinusPoints(v.AcceptEvaluation, v.Target, yearVal, monthVal) //总减分,总加分
sendContList = append(sendContList, sendCont)
}
publicmethod.ResultList(0, receivedValue.Page, receivedValue.PageSize, int64(total), int64(len(sendContList)), sendContList, c)
}
/**
@ 作者: 秦东
@ 时间: 2023-04-01 10:06:37
@ 功能: 计算加减分
@ 参数
#orgId 行政组织
#targetId 指标
#years
#months
@ 返回值
#minusScore 减去的分数
#bonusPoints 加上的分数
@ 方法原型
#func CalculatePlusOrMinusPoints(orgId, targetId int64, years, months string) (minusScore, bonusPoints float64)
*/
func CalculatePlusOrMinusPoints(orgId, targetId int64, years, months string) (minusScore, bonusPoints float64) {
var examineListCont []modelskpi.ScoreFlow
err := overall.CONSTANT_DB_KPI.Model(&modelskpi.ScoreFlow{}).Select("sf_score,sf_plus_reduce_score,sf_count").Where("sf_reply IN ? AND sf_duty_department = ? AND sf_year = ? AND sf_month = ? AND sf_target_id = ?", []int{2, 3}, orgId, years, months, targetId).Find(&examineListCont).Error
if err == nil && len(examineListCont) > 0 {
for _, v := range examineListCont {
if v.PlusReduceScore == 1 {
//加分操作
bonusPoints = bonusPoints + (float64(v.Score) * float64(v.Count)) //分值=原分值+(评分乘以发生次数)
} else {
//减分操作
minusScore = minusScore + (float64(v.Score) * float64(v.Count)) //分值=原分值+(评分乘以发生次数)
}
}
}
bonusPoints = publicmethod.DecimalEs(bonusPoints/100, 2)
minusScore = publicmethod.DecimalEs(minusScore/100, 2)
return
}
/*
*
@ 作者: 秦东
@ 时间: 2023-04-01 14:09:42
@ 功能: 相关提报人定性考核细则列表
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) GetQualityBylawsTasks(c *gin.Context) {
var receivedValue BylawsAboutPeople
c.ShouldBindJSON(&receivedValue)
if receivedValue.OrgId == "" || receivedValue.TargetId == "" {
publicmethod.Result(101, receivedValue, c)
return
}
if receivedValue.Page == 0 {
receivedValue.Page = 1
}
if receivedValue.PageSize == 0 {
receivedValue.PageSize = 15
}
//获取登录人信息
myLoginCont, _ := publicmethod.LoginMyCont(c)
var qualEvaCont modelskpi.QualitativeEvaluationView
gormDb := overall.CONSTANT_DB_KPI.Table(fmt.Sprintf("%s qe", qualEvaCont.TableName())).Select("qe.qe_id,qe.qe_target_sun,qe.qe_detailed_target,qe.qe_content,qe.qe_censor_cont,qe.qe_min_score,qe.qe_max_score,qe.qe_unit").Where("qe.`qe_type` = 1 AND qe.`qe_state` = 1 AND qe.`qe_accept_evaluation` = ? AND qe.`qe_target` = ?", receivedValue.OrgId, receivedValue.TargetId)
gormDb = gormDb.Joins("JOIN target_report td ON qe.qe_target = td.target_id AND qe.qe_accept_evaluation = td.`department_id` AND td.target_bylaws = qe.`qe_detailed_target` AND td.`type` = 1 AND td.`post_id` = 0 AND td.state = 1 AND td.type_level = 3 AND td.`man_key` = ?", myLoginCont.Key)
if receivedValue.OrgId != "" {
gormDb = gormDb.Where("`qe_accept_evaluation` = ?", receivedValue.OrgId)
}
if receivedValue.Title != "" {
gormDb = gormDb.Where("et_title LIKE ?", "%"+receivedValue.Title+"%")
}
var total int
var qualEvaListCount []modelskpi.QualitativeEvaluationView
totalErr := gormDb.Find(&qualEvaListCount).Error
if totalErr != nil {
total = 0
} else {
total = len(qualEvaListCount)
}
var qualEvaList []modelskpi.QualitativeEvaluationView
gormDb = publicmethod.PageTurningSettings(gormDb, receivedValue.Page, receivedValue.PageSize)
err := gormDb.Order("qe_accept_evaluation ASC,qe_target ASC").Find(&qualEvaList).Error
if err != nil {
publicmethod.Result(105, err, c)
return
}
var sendContList []OutPutBylawsCont
for _, v := range qualEvaList {
var sendCont OutPutBylawsCont
sendCont.Id = strconv.FormatInt(v.Id, 10)
var bylawsCont modelskpi.DetailedTarget
bylawsCont.GetCont(map[string]interface{}{"`dt_id`": v.DetailedTarget}, "`dt_title`", "`dt_content`", `dt_add_reduce`)
var columnCont modelskpi.QualitativeTarget
columnCont.GetCont(map[string]interface{}{"`q_id`": v.TargetSun}, "`q_title`")
sendCont.ColumnTitle = columnCont.Title
sendCont.Title = bylawsCont.Title //考核项目
sendCont.Content = bylawsCont.Content //考核内容
if v.Content != "" {
sendCont.Content = v.Content
}
if v.CensorCont != "" {
sendCont.Content = v.CensorCont
}
sendCont.MaxScore = publicmethod.DecimalEs(float64(v.MaxScore)/100, 2)
sendCont.MinScore = publicmethod.DecimalEs(float64(v.MinScore)/100, 2)
if sendCont.MinScore > 0 && sendCont.MaxScore > 0 {
sendCont.Standard = fmt.Sprintf("%v-%v", sendCont.MinScore, sendCont.MaxScore) //标准
sendCont.ScoreType = 2
} else if sendCont.MinScore > 0 && sendCont.MaxScore <= 0 {
sendCont.Standard = fmt.Sprintf("%v", sendCont.MinScore)
sendCont.ScoreType = 1
} else if sendCont.MinScore <= 0 && sendCont.MaxScore > 0 {
sendCont.Standard = fmt.Sprintf("%v", sendCont.MaxScore)
sendCont.ScoreType = 1
} else {
sendCont.Standard = "0"
sendCont.ScoreType = 3
}
sendCont.Unit = v.Unit //单位
sendCont.PlusMinusScore = bylawsCont.AddReduce //加减分
sendContList = append(sendContList, sendCont)
}
publicmethod.ResultList(0, receivedValue.Page, receivedValue.PageSize, int64(total), int64(len(sendContList)), sendContList, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2023-04-06 16:16:42
@ 功能: 提交定性考核
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) SubmitQualityAssess(c *gin.Context) {
var receivedValue HaveQualityAssessData
c.ShouldBindJSON(&receivedValue)
if receivedValue.ScoreFlowCont.ItemId == "" {
publicmethod.Result(1, receivedValue, c, "未知考核项目!不可进行提交")
return
}
if len(receivedValue.WorkFlowView) < 1 {
publicmethod.Result(1, receivedValue, c, "未知工作流!不可进行提交")
return
} else {
if !workflowengine.JudgeWorkflowIsTrue(receivedValue.WorkFlowView) {
publicmethod.Result(1, receivedValue, c, "未知工作流!不可进行提交")
return
}
}
if receivedValue.Orgid == "" {
publicmethod.Result(1, receivedValue, c, "未知接受考核部门!不可进行提交")
return
}
var qualEvalCont modelskpi.QualitativeEvaluation
err := qualEvalCont.GetCont(map[string]interface{}{"`qe_id`": receivedValue.ScoreFlowCont.ItemId})
if err != nil {
publicmethod.Result(1, receivedValue, c, "未知考核项目!不可进行提交")
return
}
if receivedValue.ScoreFlowCont.Type == 0 {
receivedValue.ScoreFlowCont.Type = 2
}
scoreType := 1
var dingFen float64
if qualEvalCont.MinScore > 0 && qualEvalCont.MaxScore > 0 {
dingFen = receivedValue.ScoreFlowCont.Score * 100
scoreType = 2
} else if qualEvalCont.MinScore > 0 && qualEvalCont.MaxScore <= 0 {
dingFen = float64(qualEvalCont.MinScore)
scoreType = 1
} else if qualEvalCont.MinScore <= 0 && qualEvalCont.MaxScore > 0 {
dingFen = float64(qualEvalCont.MaxScore)
scoreType = 1
} else {
dingFen = 0
scoreType = 3
}
if scoreType == 2 {
if receivedValue.ScoreFlowCont.Score == 0 {
publicmethod.Result(1, receivedValue, c, "请输入分值!")
return
}
judgeScore := receivedValue.ScoreFlowCont.Score * 100
if judgeScore > float64(qualEvalCont.MaxScore) {
publicmethod.Result(1, receivedValue, c, fmt.Sprintf("您提交的分数超过允许提交的最大值(最大值:%v)!", float64(qualEvalCont.MaxScore)/100))
return
}
if judgeScore < float64(qualEvalCont.MinScore) {
publicmethod.Result(1, receivedValue, c, fmt.Sprintf("您提交的分数超过允许提交的最小值(最小值:%v)!", float64(qualEvalCont.MinScore)/100))
return
}
} else {
if receivedValue.ScoreFlowCont.Frequency == 0 {
receivedValue.ScoreFlowCont.Frequency = 1
}
}
if receivedValue.ScoreFlowCont.Reason == "" {
publicmethod.Result(1, receivedValue, c, "请输入这样操作得原因!")
return
}
operationTime := time.Now().Unix() //统一操作时间
occurrenceTime := operationTime
//计算发生时间
currentYears := publicmethod.UnixTimeToDay(operationTime, 16)
currentQuarter := publicmethod.UnixTimeToDay(operationTime, 19)
currentMonths := publicmethod.UnixTimeToDay(operationTime, 17)
currentWeek := publicmethod.UnixTimeToDay(operationTime, 23)
if receivedValue.ScoreFlowCont.Time == "" {
publicmethod.Result(1, receivedValue, c, "请确认发生时间!")
return
} else {
var dayTime publicmethod.DateTimeTotimes
dayTime.BaisStrToTime(receivedValue.ScoreFlowCont.Time)
if dayTime.Years != "" {
currentYears = dayTime.Years
}
if dayTime.Quarter != "" {
currentQuarter = dayTime.Quarter
}
if dayTime.Months != "" {
currentMonths = dayTime.Months
}
if dayTime.Week != "" {
currentWeek = dayTime.Week
}
occurrenceTime = dayTime.AllTime
}
currentYearsInt, _ := strconv.ParseInt(currentYears, 10, 64) //年
currentQuarterInt, _ := strconv.ParseInt(currentQuarter, 10, 64) //季度
currentMonthsInt, _ := strconv.ParseInt(currentMonths, 10, 64) //月
currentWeekInt, _ := strconv.ParseInt(currentWeek, 10, 64) //周
var correctionTime int64
if receivedValue.ScoreFlowCont.Correct == 0 || receivedValue.ScoreFlowCont.Correct == 1 {
receivedValue.ScoreFlowCont.Correct = 1
if receivedValue.ScoreFlowCont.DueTime == "" {
publicmethod.Result(1, receivedValue, c, "请指定整改最晚完成期限!")
return
} else {
var dayCorreTime publicmethod.DateTimeTotimes
dayCorreTime.BaisStrToTime(receivedValue.ScoreFlowCont.DueTime)
correctionTime = dayCorreTime.AllTime
}
}
uuid := publicmethod.GetUUid(7) //上报数据唯一识别码
//获取登录人信息
myLoginCont, _ := publicmethod.LoginMyCont(c)
var addScoreFlow modelskpi.ScoreFlow
addScoreFlow.EvaluationPlan = qualEvalCont.Id //考核方案项目ID"`
addScoreFlow.PlusReduceScore = receivedValue.ScoreFlowCont.Type //1:加分;2:减分"`
dingFenStr := strconv.FormatFloat(dingFen, 'f', -1, 64)
dingFenInt, _ := strconv.ParseInt(dingFenStr, 10, 64)
addScoreFlow.Score = dingFenInt //分值(乘100录入)"`
addScoreFlow.Key = uuid //识别标志"`
addScoreFlow.Reason = receivedValue.ScoreFlowCont.Reason //操作原因"`
addScoreFlow.Time = operationTime //创建时间"`
addScoreFlow.EiteTime = operationTime //修改时间"`
addScoreFlow.EvaluationDepartment = myLoginCont.MainDeparment //测评部门"`
addScoreFlow.EvaluationUser = myLoginCont.Key //测评人"`
addScoreFlow.EvaluationGroup = myLoginCont.Company //测评集团"`
addScoreFlow.Year = currentYearsInt //年分"`
addScoreFlow.Quarter = currentQuarterInt //季度"`
addScoreFlow.Month = currentMonthsInt //月"`
addScoreFlow.Week = currentWeekInt //周"`
if len(receivedValue.UploadFiles) > 0 {
fileJson, jsonErr := json.Marshal(receivedValue.UploadFiles)
if jsonErr == nil {
addScoreFlow.Enclosure = string(fileJson) //附件"`
}
}
addScoreFlow.DutyGroup = qualEvalCont.Group //职责集团"`
addScoreFlow.DutyDepartment = qualEvalCont.AcceptEvaluation //职责部门"`
addScoreFlow.Reply = 2 //状态(0:删除;1:起草;2:审批;3:通过)"`
addScoreFlow.Rectification = receivedValue.ScoreFlowCont.Correct //1、需要整改;2:无需整改"`
addScoreFlow.HappenTime = occurrenceTime //发生时间"`
addScoreFlow.Count = receivedValue.ScoreFlowCont.Frequency //发生次数"`
addScoreFlow.CorrectionTime = correctionTime //整改期限"`
addScoreFlow.PlanVersion = qualEvalCont.QualEvalId //版本号"`
addScoreFlow.TargetId = qualEvalCont.Target //指标ID"`
addScoreFlow.DetailedId = qualEvalCont.DetailedTarget //指标细则"`
//获取工作流
var haveWorkflow workflowengine.OperateWorkflow
haveWorkflow.Step = 1 //操作哪一步
// haveWorkflow.OrderId = uuid //发起表单ID
// haveWorkflow.Attribute = qualEvalCont.Type //属性 1、定性;2、定量
haveWorkflow.OperationStatus = 2 //操作状态
var caoZuoRen workflowengine.ManipulatePeopleInfo
caoZuoRen.Key = strconv.FormatInt(myLoginCont.Key, 10) //操作人
caoZuoRen.OrgId = strconv.FormatInt(myLoginCont.AdminOrg, 10) //操作人行政组织
haveWorkflow.ManipulatePeople = caoZuoRen //操作人相关
haveWorkflow.WorkFlowList = receivedValue.WorkFlowView //流程步进图
flowView := haveWorkflow.ManipulateWorkflow()
//审批主体信息
var evalProFlowView modelskpi.EvaluationProcess
evalProFlowView.OrderKey = uuid //发起表单key"`
evalProFlowView.Step = haveWorkflow.Step //当前执行到第几部"`
flowAllJson, _ := json.Marshal(flowView)
evalProFlowView.Content = string(flowAllJson) //流程步进值"`
nextNodeJson, _ := json.Marshal(haveWorkflow.NextNodeCont)
evalProFlowView.NextContent = string(nextNodeJson) //下一步内容"`
evalProFlowView.Time = operationTime //创建时间"`
evalProFlowView.State = 2 //1:起草,2:审批中;3:通过;4:驳回"`
evalProFlowView.RoleGroup = 0 //角色组"`
evalProFlowView.TypeClass = qualEvalCont.Type //1、定性;2、定量"`
evalProFlowView.Participants = strings.Join(haveWorkflow.Participant, ",") //参与人"`
evalProFlowView.StartTime = operationTime //流程开始时间"`
evalProFlowView.NextStep = haveWorkflow.NextStep //下一步"`
evalProFlowView.NextExecutor = strings.Join(haveWorkflow.NextNodeContExecutor, ",") //下一步执行人"`
evalProFlowView.SetupDepartment = myLoginCont.MainDeparment //发起部门"`
evalProFlowView.Dimension = strconv.FormatInt(qualEvalCont.Dimension, 10) //维度"`
evalProFlowView.Target = strconv.FormatInt(qualEvalCont.Target, 10) //指标"`
evalProFlowView.DetailedTarget = strconv.FormatInt(qualEvalCont.DetailedTarget, 10) //指标细则"`
evalProFlowView.AcceptDepartment = qualEvalCont.AcceptEvaluation //接受考核部门"`
evalProFlowView.HappenTime = occurrenceTime
flowKyeInt, _ := strconv.ParseInt(receivedValue.FlowKey, 10, 64)
evalProFlowView.FlowKey = flowKyeInt //流程图唯一识别符
flowVersionInt, _ := strconv.ParseInt(receivedValue.FlowVersion, 10, 64)
evalProFlowView.FlowVid = flowVersionInt //流程版本"`
evalProFlowView.EpOld = 2
evalProFlowView.Creater = myLoginCont.Key //发起人
evalProFlowView.Clique = myLoginCont.Company //流程归属公司
//审批记录
var stepsTotal int64
overall.CONSTANT_DB_KPI.Model(&modelskpi.OpenApprovalChangeLog{}).Where("`orderid` = ?", uuid).Count(&stepsTotal)
var flowLogCont modelskpi.OpenApprovalChangeLog
flowLogCont.Type = 1 //类型(1:部门;2:岗位)"`
flowLogCont.Title = haveWorkflow.CurrentNode.NodeName //节点名称"`
flowLogCont.Operator = myLoginCont.Key //操作人"`
flowLogCont.OrderId = uuid //订单ID"`
flowLogCont.OperatorTime = operationTime //操作时间"`
flowLogCont.Step = stepsTotal + 1 //操作第几步"`
flowLogCont.OperatorType = haveWorkflow.CurrentNode.State //操作状态(1:位操作;2:已操作)"`
flowLogCont.Msgid = "" //消息id,用于撤回应用消息"`
flowLogCont.ResponseCode = "" //仅消息类型为“按钮交互型”,“投票选择型”和“多项选择型”的模板卡片消息返回,应用可使用response_code调用更新模版卡片消息接口,24小时内有效,且只能使用一次"`
flowLogCont.Stepper = haveWorkflow.CurrentNode.Step //步进器"`
flowLogCont.ChangeIsTrue = 1 //是否可变更(1:可变更;2:不可变更)"`
flowLogCont.Eiteyime = operationTime //变动时间"`
flowLogCont.YesOrNo = haveWorkflow.CurrentNode.State //未操作;1:同意;2:驳回;3:撤回"`
gormDb := overall.CONSTANT_DB_KPI.Begin()
scoreFlowErr := gormDb.Create(&addScoreFlow).Error
evalProFlowErr := gormDb.Create(&evalProFlowView).Error
flowLogContErr := gormDb.Create(&flowLogCont).Error
if scoreFlowErr == nil && evalProFlowErr == nil && flowLogContErr == nil {
addErr := gormDb.Commit().Error
if addErr == nil {
publicmethod.Result(0, addErr, c)
} else {
addErr := gormDb.Rollback().Error
publicmethod.Result(104, addErr, c)
}
} else {
outErr := publicmethod.MapOut[string]()
addErr := gormDb.Rollback().Error
outErr["scoreFlowErr"] = scoreFlowErr
outErr["evalProFlowErr"] = evalProFlowErr
outErr["flowLogContErr"] = flowLogContErr
outErr["addErr"] = addErr
publicmethod.Result(1014, outErr, c)
}
// outPut := publicmethod.MapOut[string]()
// outPut["evalProFlowView"] = evalProFlowView
// outPut["flowkk"] = flowView
// outPut["addScoreFlow"] = addScoreFlow
// outPut["flowLogCont"] = flowLogCont
// publicmethod.Result(0, outPut, c, "限!")
}
/**
@ 作者: 秦东
@ 时间: 2023-04-07 10:07:07
@ 功能: 写入附件
@ 参数
#ascriptionId 识别码
#ascriptionDataSheet 归属表单
#fileList 文件列表
@ 返回值
#
@ 方法原型
#
*/
func EditFileHandel(ascriptionId int64, ascriptionDataSheet string, fileList []UploadFilesCont) {
defer SyncSetFiles.Done()
if len(fileList) > 0 {
operationTime := time.Now().Unix() //统一操作时间
for _, v := range fileList {
var phpGalCont modelshonory.PhotosGallery
err := phpGalCont.GetCont(map[string]interface{}{"`ascription_data_sheet`": ascriptionDataSheet, "`ascription_id`": ascriptionId, "`img_path`": v.PhysicsPath})
if err != nil {
var addCont modelshonory.PhotosGallery
addCont.Url = v.FileUrl //图片地址"`
addCont.ImgPath = v.PhysicsPath //物理地址"`
addCont.Name = v.Name //文档名称"`
addCont.FileSize = v.Size //文档大小"`
addCont.Time = operationTime //创建时间"`
addCont.AscriptionId = ascriptionId //归属"`
addCont.AscriptionDataSheet = ascriptionDataSheet //归属拿个数据表"`
addCont.State = 1 //状态(1:启用;2:禁用;3:删除)"`
overall.CONSTANT_DB_MANAGE_ARCHIVES.Create(&addCont)
} else {
editCont := publicmethod.MapOut[string]()
if v.FileUrl != phpGalCont.Url {
editCont["`url`"] = v.FileUrl
}
if v.PhysicsPath != phpGalCont.ImgPath {
editCont["`img_path`"] = v.PhysicsPath
}
if v.Name != phpGalCont.Name {
editCont["`name`"] = v.Name
}
if v.Size != phpGalCont.FileSize {
editCont["`file_size`"] = v.Size
}
if len(editCont) > 0 {
editCont["`state`"] = 1
editCont["`file_size`"] = operationTime
}
var editContInfo modelshonory.PhotosGallery
editContInfo.EiteCont(map[string]interface{}{"`id`": phpGalCont.Id}, editCont)
}
}
}
}

68
api/version1/departmentseting/departmentpc/type.go

@ -1,6 +1,7 @@
package departmentpc package departmentpc
import ( import (
"key_performance_indicators/api/workflow/currency_recipe"
"key_performance_indicators/models/modelskpi" "key_performance_indicators/models/modelskpi"
"key_performance_indicators/overall/publicmethod" "key_performance_indicators/overall/publicmethod"
"sync" "sync"
@ -12,6 +13,7 @@ type ApiMethod struct{}
// 协程设置 // 协程设置
var SyncSeting = sync.WaitGroup{} var SyncSeting = sync.WaitGroup{}
var SyncSetFiles = sync.WaitGroup{}
// 部门考核WEB端入口 // 部门考核WEB端入口
func (a *ApiMethod) Index(c *gin.Context) { func (a *ApiMethod) Index(c *gin.Context) {
@ -320,6 +322,7 @@ type GetQuanTasks struct {
OrgId string `json:"orgid"` //行政组织Id OrgId string `json:"orgid"` //行政组织Id
Title string `json:"title"` Title string `json:"title"`
Time string `json:"time"` //时间 Time string `json:"time"` //时间
publicmethod.PagesTurn
} }
// 考核方案细则列表输出 // 考核方案细则列表输出
@ -470,3 +473,68 @@ type EditTableInfo struct {
Departmentint []string `json:"departmentint"` //关联部门 Departmentint []string `json:"departmentint"` //关联部门
UserList []string `json:"userlist"` //执行人 UserList []string `json:"userlist"` //执行人
} }
// 输出定性考核列表
type OutPutDingXingCont struct {
OrgId string `json:"orgid"` //行政组织Id
OrgName string `json:"orgname"` //行政组织名称
TargetId string `json:"targetid"` //指标ID
Title string `json:"title"`
MinusScore float64 `json:"minusscore"` //总减分
BonusPoints float64 `json:"bonuspoints"` //总加分
}
// 相关提报人定性考核细则
type BylawsAboutPeople struct {
OrgId string `json:"orgid"` //行政组织Id
TargetId string `json:"targetid"` //行政组织Id
Title string `json:"title"`
publicmethod.PagesTurn
}
// 输出相关考核项目
type OutPutBylawsCont struct {
publicmethod.PublicId //项目ID
ColumnTitle string `json:"columntitle"` //栏目名称
Title string `json:"title"` //考核项目
Content string `json:"content"` //考核内容
Standard string `json:"standard"` //标准
Unit string `json:"unit"` //单位
PlusMinusScore int `json:"plusminusscore"` //加减分
ScoreType int `json:"scoretype"` //1、定分;2、区间分;3、不定性分值
MaxScore float64 `json:"maxscore"` //最大分
MinScore float64 `json:"minscore"` //最小分
}
// 获取定性考核提交数据
type HaveQualityAssessData struct {
Orgid string `json:"orgid"` //接受考核的行政组织
ScoreFlowCont ScoreFlowInfo `json:"scoreflowcont"` //定性考核数据
FlowKey string `json:"flowkey"` //工作流识别符
FlowVersion string `json:"flowversion"` //使用的版本
UploadFiles []UploadFilesCont `json:"uploadfiles"` //附件文件
WorkFlowView []currency_recipe.NodeCont `json:"workflowview"` //工作流
}
// 定性考核提交参数
type ScoreFlowInfo struct {
ItemId string `json:"id"` //考核项目ID
Score float64 `json:"score"` //区间分数
Frequency int `json:"frequency"` //定分发生次数 frequency:1,
Time string `json:"time"` //发生时间
Correct int `json:"correct"` //是否需要整改 1:整改;2:不需要
DueTime string `json:"duetime"` //整改期限
Reason string `json:"reason"` //操作原因
Type int `json:"type"` //1:加分;2:减分
}
// 附件文件
type UploadFilesCont struct {
publicmethod.PublicName //文件名称
FileUrl string `json:"fileUrl"` //文件访问地址
PhysicsPath string `json:"physicspath"` //文件物理地址
Type int `json:"type"` //类型 1:图片;2:视频;3:office文档;4:压缩文件;5:其他文件
FileSize int64 `json:"fileSize"` //文件大小(单位:B)
Size string `json:"size"` //文件大小文字描述
Tag string `json:"tag"` //文件后缀
}

161
api/version1/flowchart/entry.go

@ -1,6 +1,7 @@
package flowchart package flowchart
import ( import (
"key_performance_indicators/api/workflow/currency_recipe"
"key_performance_indicators/overall/publicmethod" "key_performance_indicators/overall/publicmethod"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
@ -23,3 +24,163 @@ type ReviewFlow struct {
PlusReduction int `json:"plusreduction"` //加减分 1:减少;2:增加; PlusReduction int `json:"plusreduction"` //加减分 1:减少;2:增加;
PeopleList []string `json:"peopleList"` //被测评的人userKey PeopleList []string `json:"peopleList"` //被测评的人userKey
} }
// 获取审批记录
type HaveApprovalRecord struct {
publicmethod.PagesTurn
State int `json:"state"` // 0:全部;1:审批中;2:驳回;3:归档;4:删除
NameorNumber string `json:"nameornumber"` //申请人姓名或工号
Title string `json:"title"` //标题
}
// 输出审批记录值
type OutPutFlowLog struct {
Id string `json:"id"` //
OrderKey string `json:"orderkey"` //发起表单key"`
Step int `json:"step"` //当前执行到第几部"`
Content string `json:"content"` //流程步进值"`
NextContent string `json:"nextcontent"` //下一步内容"`
Time int64 `json:"time"` //创建时间"`
State int `json:"state"` //1:草稿,2:审批中;3:驳回;4:归档;5:删除"`
RoleGroup string `json:"rolegroup"` //角色组"`
TypeClass int `json:"type"` //1、定性;2、定量"`
Participants string `json:"participants"` //参与人"`
StartTime int64 `json:"starttime"` //u流程开始时间"`
NextStep int `json:"nextstep"` //下一步"`
NextExecutor string `json:"nextexecutor"` //下一步执行人"`
SetupDepartment string `json:"setupdepartment"` //发起部门"`
Dimension string `json:"dimension"` //维度"`
Target string `json:"target"` //指标"`
DetailedTarget string `json:"detailedtarget"` //指标细则"`
AcceptDepartment string `json:"acceptdepartment"` //接受考核部门"`
HappenTime int64 `json:"happentime"` //发生时间"`
FlowKey string `json:"flowkey"` //工作流识别符"`
FlowVid string `json:"flowvid"` //当前工作流版本号"`
EpOld int `json:"epold"` //1:旧流程;2:新流程"`
Creater string `json:"creater"` //流程创始人"`
TargetTitle string `json:"targettitle"` //指标名称"`
BylawsTitle string `json:"bylawstitle"` //细则名称"`
Clique string `json:"clique"` //公司"`
DepartmentName string `json:"departmentname"` //接受考核部门名称
CreaterName string `json:"creatername"` //流程创始人"`
CurrentNode string `json:"currentnode"` //当前节点"`
CurrentNodeMan string `json:"currentnodeman"` //当前节点操作人"`
CreationDate string `json:"creationdate"` //创建日期"`
}
// 输出工作流内容
type OutPutWorkflowCont struct {
publicmethod.PublicId //id
FlowNumber string `json:"flownumber"` //编号
IsOld int `json:"isold"` //1:旧流程;2:新流程
Attribute int `json:"attribute"` //属性:1:定性;2:定量
CreaterName string `json:"creatername"` //流程创始人"`
DepartmentName string `json:"departmentname"` //接受考核部门名称
CreationDate string `json:"creationdate"` //发生日期"`
ReportingDate string `json:"reportingdate"` //提报日期"`
Actionable int `json:"actionable"` //本节点是否可操作(1:可操作;非1:不可操作)
OperateOtherNodes currency_recipe.NodeCont `json:"operateothernodes"` //允许操作的节点
SetExecutor int `json:"setexecutor"` //设置执行人 (1:可操作;非1:不可操作)
NodeStep int `json:"nodestep"` //当前步骤
//定性部分
DingXingList []DingxingCont `json:"dingxinglist"` //定性指标
//定量部分
DingLiangList []DingLiangCont `json:"dinglianglist"` //定量指标
//流程
WorkFlowList []currency_recipe.NodeCont `json:"workflowlist"` //流程步进树
WorkFlowListOld []OldWoekflow `json:"workflowlistold"` //流程步进树
}
// 允许操作的节点
type OperateOtherNodes struct {
}
type DingxingCont struct {
Dimension string `json:"dimension"` //维度"`
Target string `json:"target"` //指标"`
TableName string `json:"tablename"` //栏目"`
DetailedTarget string `json:"detailedtarget"` //指标细则"`
Standard string `json:"standard"` //考核标准
PlusMinusScore float64 `json:"plusminusscore"` //加减分
Cause string `json:"cause"` //原因
PlusReduction int `json:"plusreduction"` //加减分 1:减少;2:增加;
}
type DingLiangCont struct {
Dimension string `json:"dimension"` //维度"`
Target string `json:"target"` //指标"`
Zeroprize float64 `json:"zeroprize"` //零奖值"`
Allprize float64 `json:"allprize"` //全奖值"`
Capping float64 `json:"capping"` //封顶值"`
Weight float64 `json:"weight"` //权重
ActualValue float64 `json:"actualvalue"` //实际值
CompletionRate float64 `json:"completionrate"` //完成率
TargetScore float64 `json:"targetscore"` //指标得分
CalculationMethod int `json:"calculationmethod"` //计算方式
Cause string `json:"cause"` //原因
}
// 定量考核基准线
type DingLiangJizhuxian struct {
publicmethod.PublicId
TargetId string `json:"targetid"` //指标ID
Zeroprize float64 `json:"zeroprize"` //零奖值"`
Allprize float64 `json:"allprize"` //全奖值"`
Capping float64 `json:"capping"` //封顶值"`
}
// 旧流程
type OldWoekflow struct {
Step int `json:"step"` //步骤
NodeName string `json:"nodename"` //
State int `json:"state"` //
Class int `json:"class"` //
Userlist []OldUserlist `json:"userlist"` //
}
// 就流程审批人
type OldUserlist struct {
publicmethod.PublicId
publicmethod.PublicName
Icon string `json:"icon"`
Wechat string `json:"wechat"`
Group int `json:"group"` //
GroupName string `json:"groupname"` //
DepartMentid int `json:"departmentid"` //
DepartmentName string `json:"departmentname"` //
Workshopid int `json:"workshopid"` //
WorkshopName string `json:"workshopname"` //
Postid int `json:"postid"` //
PostName string `json:"postname"` //
Tema int `json:"tema"` //
TemaName string `json:"temaname"` //
Log []OldLog `json:"log"` //
}
type OldLog struct {
State int `json:"state"` //
Time string `json:"time"` //
Enclosure string `json:"enclosure"` //
}
// 审批参数
type ExamAndApp struct {
publicmethod.PublicId //流程ID
YesOrNo int `json:"yesorno"` //1:未操作,2:同意;3:驳回
Cause string `json:"cause"` //意见
Enclosure []currency_recipe.EnclosureFormat `json:"enclosure"` //附件
}
// 审批执行
type WorkFlowRuning struct {
OrderKey int64
List []currency_recipe.NodeCont //流程全图
Participant []string //参与人
Step int //下一步步进值
Executor publicmethod.AuthenticationPower `json:"sxecutor"` //当前执行人
YesOrNo int `json:"yesorno"` //1:未操作,2:同意;3:驳回
Cause string `json:"cause"` //意见
Enclosure []currency_recipe.EnclosureFormat `json:"enclosure"` //附件
NextStep int //下一步
NextNodeCont currency_recipe.NodeCont //下一节点
NextExecutor []string //下一步执行人
RunNode currency_recipe.NodeCont
}

716
api/version1/flowchart/myworkflow.go

@ -0,0 +1,716 @@
package flowchart
import (
"encoding/json"
"fmt"
"key_performance_indicators/api/workflow/currency_recipe"
"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"
)
/*
*
@ 作者: 秦东
@ 时间: 2023-04-08 10:09:31
@ 功能: 获取审批记录
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) GetApprovalRecord(c *gin.Context) {
var receivedValue HaveApprovalRecord
c.ShouldBindJSON(&receivedValue)
if receivedValue.Page == 0 {
receivedValue.Page = 1
}
if receivedValue.PageSize == 0 {
receivedValue.Page = 20
}
//获取登录人信息
myLoginCont, _ := publicmethod.LoginMyCont(c)
var flowList []modelskpi.ApprovalRecord
gormDb := overall.CONSTANT_DB_KPI.Model(&modelskpi.ApprovalRecord{})
switch receivedValue.State {
case 1:
gormDb = gormDb.Where("ep_state = ? ", 1)
case 2:
gormDb = gormDb.Where("ep_state = ? ", 2)
case 3:
gormDb = gormDb.Where("ep_state = ? ", 3)
case 4:
gormDb = gormDb.Where("ep_state = ? ", 4)
default:
gormDb = gormDb.Where("ep_state BETWEEN ? AND ?", 1, 4)
}
if receivedValue.Title != "" {
gormDb = gormDb.Where("target_title LIKE ? OR bylaws_title LIKE ?", "%"+receivedValue.Title+"%", "%"+receivedValue.Title+"%")
}
userIdentity := publicmethod.DetermineUserIdentity(myLoginCont.Key)
switch userIdentity.Level {
// case 1:
// gormDb = gormDb.Where("FIND_IN_SET(?,`ep_participants`)", myLoginCont.Key)
// case 2:
// gormDb = gormDb.Where("`ep_setup_department` IN ? OR `ep_accept_department` IN ?", userIdentity.OrgList)
// case 3:
// gormDb = gormDb.Where("`ep_clique` = ? ", userIdentity.Group)
// case 4:
// gormDb = gormDb.Where("`ep_setup_department` IN ? OR `ep_accept_department` IN ?", userIdentity.OrgList)
default:
}
var total int64
totalErr := gormDb.Count(&total).Error
if totalErr != nil {
total = 0
}
gormDb = publicmethod.PageTurningSettings(gormDb, receivedValue.Page, receivedValue.PageSize)
err := gormDb.Order("ep_id DESC").Find(&flowList).Error
if err != nil {
publicmethod.Result(105, err, c)
return
}
var sendListCont []OutPutFlowLog
for _, v := range flowList {
var sendCont OutPutFlowLog
sendCont.Id = strconv.FormatInt(v.Id, 10) //
sendCont.OrderKey = strconv.FormatInt(v.OrderKey, 10) //发起表单key"`
sendCont.Step = v.Step //当前执行到第几部"`
sendCont.Content = v.Content //流程步进值"`
sendCont.NextContent = v.NextContent //下一步内容"`
sendCont.Time = v.Time //创建时间"`
sendCont.CreationDate = publicmethod.UnixTimeToDay(v.StartTime, 11)
sendCont.State = v.State //1:草稿,2:审批中;3:驳回;4:归档;5:删除"`
sendCont.RoleGroup = strconv.FormatInt(v.RoleGroup, 10) //角色组"`
sendCont.TypeClass = v.TypeClass //1、定性;2、定量"`
sendCont.Participants = v.Participants //参与人"`
sendCont.StartTime = v.StartTime //u流程开始时间"`
sendCont.NextStep = v.NextStep //下一步"`
sendCont.NextExecutor = v.NextExecutor //下一步执行人"`
sendCont.SetupDepartment = strconv.FormatInt(v.SetupDepartment, 10) //发起部门"`
sendCont.Dimension = v.Dimension //维度"`
sendCont.Target = v.Target //指标"`
sendCont.DetailedTarget = v.DetailedTarget //指标细则"`
sendCont.AcceptDepartment = strconv.FormatInt(v.AcceptDepartment, 10) //接受考核部门"`
sendCont.HappenTime = v.HappenTime //发生时间"`
sendCont.FlowKey = strconv.FormatInt(v.FlowKey, 10) //工作流识别符"`
sendCont.FlowVid = strconv.FormatInt(v.FlowVid, 10) //当前工作流版本号"`
sendCont.EpOld = v.EpOld //1:旧流程;2:新流程"`
sendCont.Creater = strconv.FormatInt(v.Creater, 10) //流程创始人"`
sendCont.TargetTitle = v.TargetTitle //指标名称"`
sendCont.BylawsTitle = v.BylawsTitle //细则名称"`
sendCont.Clique = strconv.FormatInt(v.Clique, 10) //公司"`
var accOrgCont modelshr.AdministrativeOrganization
accOrgCont.GetCont(map[string]interface{}{"`id`": v.AcceptDepartment}, "`name`")
sendCont.DepartmentName = accOrgCont.Name
if v.Creater != 0 {
var creaCont modelshr.PersonArchives
creaCont.GetCont(map[string]interface{}{"`key`": v.Creater}, "`name`")
sendCont.CreaterName = creaCont.Name
}
if v.EpOld == 2 {
if v.NextContent != "" {
var nextNode currency_recipe.NodeCont
jsonErr := json.Unmarshal([]byte(v.NextContent), &nextNode)
if jsonErr == nil {
sendCont.CurrentNode = nextNode.NodeName
if len(nextNode.UserList) > 0 {
var userNameCree []string
for _, uv := range nextNode.UserList {
if !publicmethod.IsInTrue[string](uv.Name, userNameCree) {
userNameCree = append(userNameCree, uv.Name)
}
}
sendCont.CurrentNodeMan = strings.Join(userNameCree, ",")
}
}
}
} else {
var flowLog []currency_recipe.NodeCont
jsonFlowErr := json.Unmarshal([]byte(v.NextContent), &flowLog)
// fmt.Printf("流程------>%v\n", flowLog)
if jsonFlowErr == nil {
for _, fv := range flowLog {
if fv.Step == v.NextStep {
sendCont.CurrentNode = fv.NodeName
if len(fv.UserList) > 0 {
var userNameCreeOld []string
for _, uvo := range fv.UserList {
if !publicmethod.IsInTrue[string](uvo.Name, userNameCreeOld) {
userNameCreeOld = append(userNameCreeOld, uvo.Name)
}
}
sendCont.CurrentNodeMan = strings.Join(userNameCreeOld, ",")
}
}
}
}
}
sendListCont = append(sendListCont, sendCont)
}
publicmethod.ResultList(0, receivedValue.Page, receivedValue.PageSize, int64(total), int64(len(sendListCont)), sendListCont, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2023-04-08 16:47:22
@ 功能: 查看审批记录详情
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) LookWorkFlowCont(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, err, c)
return
}
//获取流程信息
var evalProCont modelskpi.EvaluationProcess
err = evalProCont.GetCont(map[string]interface{}{"ep_id": receivedValue.Id})
if err != nil {
publicmethod.Result(107, err, c)
return
}
var sendCont OutPutWorkflowCont
sendCont.Id = strconv.FormatInt(evalProCont.Id, 10)
sendCont.FlowNumber = strconv.FormatInt(evalProCont.OrderKey, 10)
sendCont.Attribute = evalProCont.TypeClass //1、定性;2、定量"`
if evalProCont.Creater != 0 {
var creaCont modelshr.PersonArchives
creaCont.GetCont(map[string]interface{}{"`key`": evalProCont.Creater}, "`name`")
sendCont.CreaterName = creaCont.Name
}
var accOrgCont modelshr.AdministrativeOrganization
accOrgCont.GetCont(map[string]interface{}{"`id`": evalProCont.AcceptDepartment}, "`name`")
sendCont.DepartmentName = accOrgCont.Name
sendCont.CreationDate = publicmethod.UnixTimeToDay(evalProCont.HappenTime, 11)
sendCont.ReportingDate = publicmethod.UnixTimeToDay(evalProCont.Time, 11)
sendCont.IsOld = evalProCont.EpOld
if evalProCont.EpOld == 2 {
json.Unmarshal([]byte(evalProCont.Content), &sendCont.WorkFlowList)
if evalProCont.NextStep != 0 && evalProCont.NextStep <= len(sendCont.WorkFlowList) {
sendCont.NodeStep = evalProCont.Step
} else {
sendCont.NodeStep = len(sendCont.WorkFlowList)
}
if evalProCont.State < 4 && evalProCont.NextContent != "" {
var nextNodeCont currency_recipe.NodeCont
json.Unmarshal([]byte(evalProCont.NextContent), &nextNodeCont)
//获取登录人信息
myLoginCont, _ := publicmethod.LoginMyCont(c)
if len(nextNodeCont.UserList) > 0 {
for _, uv := range nextNodeCont.UserList {
myKeyStr := strconv.FormatInt(myLoginCont.Key, 10)
if uv.Id == myKeyStr {
sendCont.Actionable = 1
}
}
}
if len(sendCont.WorkFlowList) > 0 {
for _, av := range sendCont.WorkFlowList {
if av.CustomNode == nextNodeCont.NodeNumber {
sendCont.OperateOtherNodes = av
sendCont.SetExecutor = 1
}
}
}
}
} else {
json.Unmarshal([]byte(evalProCont.NextContent), &sendCont.WorkFlowListOld)
if evalProCont.NextStep != 0 && evalProCont.NextStep <= len(sendCont.WorkFlowListOld) {
sendCont.NodeStep = evalProCont.Step
} else {
sendCont.NodeStep = len(sendCont.WorkFlowListOld)
}
}
//定性部分
if evalProCont.TypeClass == 1 {
var scoreFlowList []modelskpi.ScoreFlow
overall.CONSTANT_DB_KPI.Model(&modelskpi.ScoreFlow{}).Select("sf_evaluation_plan,sf_plus_reduce_score,sf_score,sf_reason,sf_count,sf_target_id,sf_detailed_id").Where("sf_key = ?", evalProCont.OrderKey).Find(&scoreFlowList)
if len(scoreFlowList) > 0 {
for _, v := range scoreFlowList {
var dingXingCong DingxingCont
//获取指标信息
var targetCont modelskpi.EvaluationTarget
targetCont.GetCont(map[string]interface{}{"`et_id`": v.TargetId}, "`et_title`", "`et_dimension`")
dingXingCong.Target = targetCont.Title
//获取维度细信息
var dimeCont modelskpi.DutyClass
dimeCont.GetCont(map[string]interface{}{"`id`": targetCont.Dimension}, "`title`")
dingXingCong.Dimension = dimeCont.Title
//获取细则信息
var detailedTargetCont modelskpi.DetailedTarget
detailedTargetCont.GetCont(map[string]interface{}{"`dt_id`": v.DetailedId}, "`dt_title`", "`dt_parentid_sun`")
dingXingCong.DetailedTarget = detailedTargetCont.Title
//获取栏目信息
var tableCont modelskpi.QualitativeTarget
tableCont.GetCont(map[string]interface{}{"`q_id`": detailedTargetCont.ParentIdSun}, "`q_title`")
dingXingCong.TableName = tableCont.Title
//获取定性指标数据
var qualEvalView modelskpi.QualitativeEvaluationView
qualEvalView.GetCont(map[string]interface{}{"`qe_id`": v.EvaluationPlan}, "`qe_min_score`", "`qe_max_score`", "`qe_reference_score`")
if qualEvalView.MinScore > 0 && qualEvalView.MaxScore > 0 {
dingXingCong.Standard = fmt.Sprintf("%v-%v", qualEvalView.MinScore/100, qualEvalView.MaxScore/100) //标准
defen := float64(v.Score) / 100
dingXingCong.PlusMinusScore = publicmethod.DecimalEs(defen, 2)
} else if qualEvalView.MinScore > 0 && qualEvalView.MaxScore <= 0 {
dingXingCong.Standard = fmt.Sprintf("%v", qualEvalView.MinScore/100)
defen := (float64(v.Score) * float64(v.Count)) / 100
dingXingCong.PlusMinusScore = publicmethod.DecimalEs(defen, 2)
} else if qualEvalView.MinScore <= 0 && qualEvalView.MaxScore > 0 {
dingXingCong.Standard = fmt.Sprintf("%v", qualEvalView.MaxScore/100)
defen := (float64(v.Score) * float64(v.Count)) / 100
dingXingCong.PlusMinusScore = publicmethod.DecimalEs(defen, 2)
} else {
dingXingCong.Standard = "0"
defen := float64(v.Score) / 100
dingXingCong.PlusMinusScore = publicmethod.DecimalEs(defen, 2)
}
dingXingCong.Cause = v.Reason
dingXingCong.PlusReduction = v.PlusReduceScore
sendCont.DingXingList = append(sendCont.DingXingList, dingXingCong)
}
}
} else {
//定量
var flowLogCont modelskpi.FlowLog
flcErr := flowLogCont.GetCont(map[string]interface{}{"`fl_key`": evalProCont.OrderKey}, "`fl_enclosure`", "`fl_planversion`", "`fl_baseline`")
if flcErr == nil {
var jiZhunZhi []DingLiangJizhuxian
json.Unmarshal([]byte(flowLogCont.Baseline), &jiZhunZhi)
var dingLiangLog []modelskpi.FlowLogData
overall.CONSTANT_DB_KPI.Model(&modelskpi.FlowLogData{}).Select("fld_evaluation_id,fld_score,fld_cont,fld_scoring_method,fld_scoring_score,fld_target_id").Where("fld_flow_log = ?", evalProCont.OrderKey).Find(&dingLiangLog)
if len(dingLiangLog) > 0 {
for _, v := range dingLiangLog {
var dingLiangInfo DingLiangCont
//获取指标信息
var targetCont modelskpi.EvaluationTarget
targetCont.GetCont(map[string]interface{}{"`et_id`": v.TargetId}, "`et_title`", "`et_dimension`")
dingLiangInfo.Target = targetCont.Title
//获取维度细信息
var dimeCont modelskpi.DutyClass
dimeCont.GetCont(map[string]interface{}{"`id`": targetCont.Dimension}, "`title`")
dingLiangInfo.Dimension = dimeCont.Title
var zeroprize float64
var allprize float64
var capping float64
if len(jiZhunZhi) > 0 {
for _, jzzv := range jiZhunZhi {
epId := strconv.FormatInt(v.EvaluationPlan, 10)
fmt.Printf("限定值---》%v\n", v.EvaluationPlan)
if jzzv.Id == epId {
dingLiangInfo.Zeroprize = publicmethod.DecimalEs(float64(jzzv.Zeroprize)/100, 2) //零奖值"`
dingLiangInfo.Allprize = publicmethod.DecimalEs(float64(jzzv.Allprize)/100, 2) //零奖值"`
dingLiangInfo.Capping = publicmethod.DecimalEs(float64(jzzv.Capping)/100, 2) //零奖值"`
zeroprize = float64(jzzv.Zeroprize)
allprize = float64(jzzv.Allprize)
capping = float64(jzzv.Capping)
}
}
}
var qualEvalView modelskpi.QualitativeEvaluationView
qualEvalView.GetCont(map[string]interface{}{"`qe_id`": v.EvaluationPlan}, "`qe_reference_score`")
dingLiangInfo.Weight = float64(qualEvalView.ReferenceScore) //权重
dingLiangInfo.ActualValue = publicmethod.DecimalEs(float64(v.Score)/100, 2) //实际值
// dingLiangInfo.CompletionRate = v.Score //完成率
if v.ScoringMethod == 1 {
dingLiangInfo.TargetScore, _, _, _, dingLiangInfo.CompletionRate = publicmethod.CalculateScore(qualEvalView.ReferenceScore, float64(v.Score), allprize, zeroprize, capping, 2)
} else {
dingLiangInfo.TargetScore = publicmethod.DecimalEs(float64(v.ScoringScore)/100, 2) //指标得分
}
//
dingLiangInfo.CalculationMethod = v.ScoringMethod
dingLiangInfo.Cause = v.Content
sendCont.DingLiangList = append(sendCont.DingLiangList, dingLiangInfo)
}
}
}
}
publicmethod.Result(0, sendCont, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2023-04-10 15:22:38
@ 功能: 审批操作
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) ExamineAndApprove(c *gin.Context) {
var receivedValue ExamAndApp
c.ShouldBindJSON(&receivedValue)
if receivedValue.Id == "" {
publicmethod.Result(101, receivedValue, c)
return
}
if receivedValue.YesOrNo == 0 {
receivedValue.YesOrNo = 3
}
//获取登录人信息
myLoginCont, err := publicmethod.LoginMyCont(c)
if err != nil {
publicmethod.Result(1, err, c, "你没有权限进行此操作!或您的身份令牌已超时!")
return
}
//获取流程信息
var evalProCont modelskpi.EvaluationProcess
err = evalProCont.GetCont(map[string]interface{}{"ep_id": receivedValue.Id})
if err != nil {
publicmethod.Result(107, err, c)
return
}
if evalProCont.State == 4 {
publicmethod.Result(1, err, c, "流程已归档!不可进行审批!")
return
}
if evalProCont.State == 5 {
publicmethod.Result(1, err, c, "流程已锁定!不可进行任何操作!")
return
}
if evalProCont.NextStep == 0 {
publicmethod.Result(1, err, c, "流程已归档!不可进行审批!")
return
}
if evalProCont.NextContent != "" {
var nextNodeInfo currency_recipe.NodeCont
jsonErr := json.Unmarshal([]byte(evalProCont.NextContent), &nextNodeInfo)
if jsonErr == nil {
isOk := false
for _, v := range nextNodeInfo.UserList {
myKeyStr := strconv.FormatInt(myLoginCont.Key, 10)
if myKeyStr == v.Id {
isOk = true
}
}
if !isOk {
publicmethod.Result(1, err, c, "你没有权限进行此操作!或您的身份令牌已超时!")
return
}
}
}
var workFlowList []currency_recipe.NodeCont
json.Unmarshal([]byte(evalProCont.Content), &workFlowList)
var runWorkflow WorkFlowRuning
runWorkflow.OrderKey = evalProCont.OrderKey
runWorkflow.List = workFlowList
runWorkflow.Step = evalProCont.NextStep
runWorkflow.Executor = myLoginCont
runWorkflow.YesOrNo = receivedValue.YesOrNo
runWorkflow.Cause = receivedValue.Cause
runWorkflow.Enclosure = receivedValue.Enclosure
runWorkflow.ProcessOperation()
editWorkflow := publicmethod.MapOut[string]()
workflowAll, _ := json.Marshal(runWorkflow.List)
editWorkflow["ep_cont"] = string(workflowAll)
if len(runWorkflow.NextExecutor) > 0 {
editWorkflow["ep_next_executor"] = strings.Join(runWorkflow.NextExecutor, ",")
} else {
editWorkflow["ep_next_executor"] = ""
}
if runWorkflow.NextNodeCont.Step != 0 {
workflowNext, _ := json.Marshal(runWorkflow.NextNodeCont)
editWorkflow["ep_next_cont"] = string(workflowNext)
} else {
editWorkflow["ep_next_cont"] = ""
}
editWorkflow["ep_next_step"] = runWorkflow.NextStep
if len(runWorkflow.Participant) > 0 {
editWorkflow["ep_participants"] = strings.Join(runWorkflow.Participant, ",")
} else {
editWorkflow["ep_participants"] = ""
}
if receivedValue.YesOrNo == 2 {
if runWorkflow.NextStep == 0 {
editWorkflow["ep_state"] = 4
} else {
editWorkflow["ep_state"] = 2
}
} else {
editWorkflow["ep_state"] = receivedValue.YesOrNo
}
editWorkflow["ep_step"] = runWorkflow.Step
editWorkflow["ep_time"] = time.Now().Unix()
var evalProContEdit modelskpi.EvaluationProcess
err = evalProContEdit.EiteCont(map[string]interface{}{"ep_id": evalProCont.Id}, editWorkflow)
// uh := publicmethod.MapOut[string]()
// uh["editWorkflow"] = editWorkflow
// uh["runWorkflow"] = runWorkflow
if err != nil {
publicmethod.Result(104, err, c)
return
}
publicmethod.Result(0, err, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2023-04-10 16:52:14
@ 功能: 流程操作
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (w *WorkFlowRuning) ProcessOperation() {
total := len(w.List) //获取流程总长度
if total > 0 { //流程存在内容
if w.Step <= total && w.Step != 0 { //判断流程起点及流程有无超出范围
w.NextStep = w.Step + 1 //获取下一步步进值
if w.NextStep >= total {
w.NextStep = 0
}
userKey := strconv.FormatInt(w.Executor.Key, 10) //当前操作人Key
for i, v := range w.List { //遍历匹配节点
if v.Step < w.Step { //当前节点之前的节点全部置操作
w.List[i].State = 2
for _, usv := range v.UserList { //获取已参与进来的人
if !publicmethod.IsInTrue[string](usv.Id, w.Participant) {
w.Participant = append(w.Participant, usv.Id)
}
}
}
if v.Step == w.Step { //当前节点
w.List[i].State = 2 //节点置已操作
var atPresentWechat []string
var atPresent []string
for ui, uv := range v.UserList {
if !publicmethod.IsInTrue[string](uv.Id, w.Participant) {
w.Participant = append(w.Participant, uv.Id)
}
atPresent = append(atPresent, uv.Id)
atPresentWechat = append(atPresentWechat, uv.Wechat)
if uv.Id == userKey {
var userCarrLog currency_recipe.LogList
userCarrLog.State = w.YesOrNo //状态 1、未操作;2、通过;3、驳回
userCarrLog.Cause = w.Cause
userCarrLog.TimeVal = publicmethod.UnixTimeToDay(time.Now().Unix(), 1)
userCarrLog.Enclosure = w.Enclosure //附件
w.List[i].UserList[ui].LogList = append(w.List[i].UserList[ui].LogList, userCarrLog)
}
}
w.RunNode = v
w.WriteFlowLog()
if v.Type != 2 { //判断当前节点是不是操作
//不是抄送节点
//判断同意还是驳回
if w.YesOrNo == 2 {
w.NodeYes(total)
} else {
w.NodeNot(total, v.GoBackNode)
}
} else {
//是抄送节点
w.ProcessOperation()
return
}
}
}
} else { //流程已结束
w.NextStep = 0
for i, v := range w.List {
w.List[i].State = 2
for _, usv := range v.UserList {
if !publicmethod.IsInTrue[string](usv.Id, w.Participant) {
w.Participant = append(w.Participant, usv.Id)
}
}
}
}
}
}
/*
*
@ 作者: 秦东
@ 时间: 2023-04-11 09:32:38
@ 功能: 判断下一步要执行什么(拒绝)
@ 参数
#total 流程总步数
#nodeNumber 要退回的节点
@ 返回值
#
@ 方法原型
#
*/
func (w *WorkFlowRuning) NodeNot(total int, nodeNumber string) {
if total <= 1 {
w.NextStep = 1
}
for _, nv := range w.List {
if nv.NodeNumber == nodeNumber {
w.NextStep = nv.Step
w.Step = nv.Step
break
}
}
w.NodeYes(total)
}
/*
*
@ 作者: 秦东
@ 时间: 2023-04-11 09:26:41
@ 功能: 判断下一步要执行什么(同意)
@ 参数
#total 流程总步数
@ 返回值
#
@ 方法原型
#
*/
func (w *WorkFlowRuning) NodeYes(total int) {
if w.NextStep <= total && w.NextStep != 0 {
for i, v := range w.List {
if v.Step == w.NextStep {
writeLog := false
if v.Type == 2 {
w.Step = w.NextStep
writeLog = true
w.List[i].State = 2
}
var nextZhiXingRen []string
var atPresentWechat []string
for ni, nv := range v.UserList {
if !publicmethod.IsInTrue[string](nv.Id, w.Participant) {
w.Participant = append(w.Participant, nv.Id)
}
if !publicmethod.IsInTrue[string](nv.Id, nextZhiXingRen) {
nextZhiXingRen = append(nextZhiXingRen, nv.Id) //下一步执行人
}
if !publicmethod.IsInTrue[string](nv.Wechat, atPresentWechat) {
atPresentWechat = append(atPresentWechat, nv.Wechat)
}
if writeLog { //参送节点直接发送信息
var userCarrLog currency_recipe.LogList
userCarrLog.State = w.YesOrNo //状态 1、未操作;2、通过;3、驳回
userCarrLog.Cause = w.Cause
userCarrLog.TimeVal = publicmethod.UnixTimeToDay(time.Now().Unix(), 1)
userCarrLog.Enclosure = w.Enclosure //附件
w.List[i].UserList[ni].LogList = append(w.List[i].UserList[ni].LogList, userCarrLog)
}
}
w.NextNodeCont = v
w.NextExecutor = nextZhiXingRen
if writeLog {
w.RunNode = v
w.WriteFlowLog()
w.ProcessOperation()
return
}
}
}
}
}
/*
*
@ 作者: 秦东
@ 时间: 2023-04-10 16:52:24
@ 功能: 审批记录新增
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (w *WorkFlowRuning) WriteFlowLog() {
//审批记录
var stepsTotal int64
overall.CONSTANT_DB_KPI.Model(&modelskpi.OpenApprovalChangeLog{}).Where("`orderid` = ?", w.OrderKey).Count(&stepsTotal)
var flowLogCont modelskpi.OpenApprovalChangeLog
flowLogCont.Type = 1 //类型(1:部门;2:岗位)"`
flowLogCont.Title = w.RunNode.NodeName //节点名称"`
flowLogCont.Operator = w.Executor.Key //操作人"`
flowLogCont.OrderId = w.OrderKey //订单ID"`
flowLogCont.OperatorTime = time.Now().Unix() //操作时间"`
flowLogCont.Step = stepsTotal + 1 //操作第几步"`
flowLogCont.OperatorType = w.RunNode.State //操作状态(1:位操作;2:已操作)"`
flowLogCont.Msgid = "" //消息id,用于撤回应用消息"`
flowLogCont.ResponseCode = "" //仅消息类型为“按钮交互型”,“投票选择型”和“多项选择型”的模板卡片消息返回,应用可使用response_code调用更新模版卡片消息接口,24小时内有效,且只能使用一次"`
flowLogCont.Stepper = w.RunNode.Step //步进器"`
flowLogCont.ChangeIsTrue = 1 //是否可变更(1:可变更;2:不可变更)"`
flowLogCont.Eiteyime = time.Now().Unix() //变动时间"`
flowLogCont.YesOrNo = w.YesOrNo //未操作;1:同意;2:驳回;3:撤回"`
flowLogCont.Idea = w.Cause
fileJson, _ := json.Marshal(w.Executor)
flowLogCont.Annex = string(fileJson)
flowLogCont.AddCont()
}

38
api/version1/jurisdiction/jurisdictionpc/people.go

@ -63,12 +63,38 @@ func (a *ApiMethod) SearchPeople(c *gin.Context) {
var sendContList []EmployeesCont var sendContList []EmployeesCont
for _, v := range listCont { for _, v := range listCont {
var sendCont EmployeesCont var sendCont EmployeesCont
sendCont.Id = strconv.FormatInt(v.Id, 10) //`json:"id"` sendCont.Id = strconv.FormatInt(v.Key, 10) //`json:"id"`
sendCont.EmployeeName = v.Name //`json:"employeeName"` //人员名称 sendCont.EmployeeName = v.Name //`json:"employeeName"` //人员名称
sendCont.IsLeave = "0" //`json:"isLeave"` //行政组织名称 sendCont.IsLeave = "0" //`json:"isLeave"` //行政组织名称
sendCont.Open = "false" //`json:"open"` //上级ID sendCont.Open = "false" //`json:"open"` //上级ID
sendCont.Icon = v.Icon //`json:"icon"` //头像 sendCont.Icon = v.Icon //`json:"icon"` //头像
sendCont.IconToBase64 = v.IconPhoto //`json:"iconToBase64"` //头像 sendCont.IconToBase64 = v.IconPhoto //`json:"iconToBase64"` //头像
sendCont.Wechat = v.Wechat //微信Openid
if v.WorkWechat != "" {
sendCont.Wechat = v.WorkWechat //微信Openid
}
_, companyId, _, _, _ := publicmethod.GetOrgStructurees(v.AdminOrg)
if companyId != 0 {
var orgCont modelshr.AdministrativeOrganization
orgCont.GetCont(map[string]interface{}{"`id`": companyId}, "`name`")
sendCont.Departmentid = companyId //分厂Id
sendCont.DepartmentName = orgCont.Name //分厂名称
}
//获取岗位
if v.Position != 0 {
var postCont modelshr.Position
postCont.GetCont(map[string]interface{}{"`id`": v.Position}, "`name`")
sendCont.Postid = v.Position //职务Id
sendCont.PostName = postCont.Name //职务名称
}
if v.TeamId != 0 {
var teamCont modelshr.TeamGroup
teamCont.GetCont(map[string]interface{}{"`id`": v.TeamId}, "`name`")
sendCont.Tema = v.TeamId //班组Id
sendCont.TemaName = teamCont.Name //班组名称
}
sendContList = append(sendContList, sendCont) sendContList = append(sendContList, sendCont)
} }
publicmethod.ResultList(0, receivedValue.Page, receivedValue.PageSize, total, int64(len(sendContList)), sendContList, c) publicmethod.ResultList(0, receivedValue.Page, receivedValue.PageSize, total, int64(len(sendContList)), sendContList, c)

19
api/version1/jurisdiction/jurisdictionpc/type.go

@ -193,12 +193,19 @@ type FlowGetRoleList struct {
// 审批节点选人人员节点 // 审批节点选人人员节点
type EmployeesCont struct { type EmployeesCont struct {
Id string `json:"id"` Id string `json:"id"`
EmployeeName string `json:"employeeName"` //人员名称 EmployeeName string `json:"employeeName"` //人员名称
IsLeave string `json:"isLeave"` //行政组织名称 IsLeave string `json:"isLeave"` //行政组织名称
Open string `json:"open"` //上级ID Open string `json:"open"` //上级ID
Icon string `json:"icon"` //头像 Icon string `json:"icon"` //头像
IconToBase64 string `json:"iconToBase64"` //头像 IconToBase64 string `json:"iconToBase64"` //头像
Wechat string `json:"wechat"` //微信或企业微信
Departmentid int64 `json:"departmentid"` //部门ID
DepartmentName string `json:"departmentname"` //部门名称
Postid int64 `json:"postid"` //岗位ID
PostName string `json:"postname"` //岗位名称
Tema int64 `json:"tema"` //班组Id
TemaName string `json:"temaname"` //班组名称
} }
// 工作流审批角色输出 // 工作流审批角色输出

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

@ -1122,7 +1122,7 @@ func (a *ApiMethod) PostRectificationMeasures(c *gin.Context) {
operatorIsTreu.Operator = context.Key operatorIsTreu.Operator = context.Key
operatorIsTreu.OrderId = pwoCont.OrderId operatorIsTreu.OrderId = pwoCont.OrderId
operatorIsTreu.OperatorTime = time.Now().Unix() operatorIsTreu.OperatorTime = time.Now().Unix()
operatorIsTreu.Step = flowOneCont.Step operatorIsTreu.Step = int64(flowOneCont.Step)
operatorIsTreu.OperatorType = 2 operatorIsTreu.OperatorType = 2
operatorIsTreu.Msgid = "" operatorIsTreu.Msgid = ""
operatorIsTreu.ResponseCode = "" operatorIsTreu.ResponseCode = ""

2
api/version1/systemapproval/post_nature.go

@ -185,7 +185,7 @@ func UpDataAppconueFlowLog(orderId, clickUser int64, step, clickEnterInt, class
operatorIsTreu.Operator = clickUser operatorIsTreu.Operator = clickUser
operatorIsTreu.OrderId = orderId operatorIsTreu.OrderId = orderId
operatorIsTreu.OperatorTime = time.Now().Unix() operatorIsTreu.OperatorTime = time.Now().Unix()
operatorIsTreu.Step = flowCont.Step operatorIsTreu.Step = int64(flowCont.Step)
operatorIsTreu.OperatorType = 2 operatorIsTreu.OperatorType = 2
operatorIsTreu.Msgid = "" operatorIsTreu.Msgid = ""
operatorIsTreu.ResponseCode = "" operatorIsTreu.ResponseCode = ""

45
api/workflow/currency_recipe/general_method.go

@ -2,7 +2,6 @@ package currency_recipe
import ( import (
"encoding/json" "encoding/json"
"fmt"
"key_performance_indicators/models/modelshr" "key_performance_indicators/models/modelshr"
"key_performance_indicators/models/modelskpi" "key_performance_indicators/models/modelskpi"
"key_performance_indicators/overall" "key_performance_indicators/overall"
@ -54,6 +53,7 @@ func (w *WorkflowEngine) InitWorkflow(fields ...string) *WorkflowEngine {
err = workflowInfo.GetCont(map[string]interface{}{"`key`": w.Id, "`version`": w.VersionId}) err = workflowInfo.GetCont(map[string]interface{}{"`key`": w.Id, "`version`": w.VersionId})
} else { } else {
err = workflowInfo.GetCont(map[string]interface{}{"`key`": w.Id, "`state`": 1}) err = workflowInfo.GetCont(map[string]interface{}{"`key`": w.Id, "`state`": 1})
w.VersionId = workflowInfo.Version
} }
if err == nil { if err == nil {
json.Unmarshal([]byte(workflowInfo.Content), &w.WorkflowCont) json.Unmarshal([]byte(workflowInfo.Content), &w.WorkflowCont)
@ -84,7 +84,8 @@ func (w *WorkflowEngine) SendData() (sendCont SendOneWorkflow) {
var nodeInfo []NodeCont var nodeInfo []NodeCont
nodeInfo, sendCont.IsTrue, sendCont.Msg = w.promoter() nodeInfo, sendCont.IsTrue, sendCont.Msg = w.promoter()
sendCont.NodeContList = RectificationNode(nodeInfo) sendCont.NodeContList = RectificationNode(nodeInfo)
// fmt.Printf("输出工作流--->%v\n", sendCont) // sjkdjk, _ := json.Marshal(w)
// fmt.Printf("输出工作流--->%v\n", string(sjkdjk))
return return
} }
@ -137,12 +138,14 @@ func (w *WorkflowEngine) promoter() (nodeList []NodeCont, isTrue bool, msg strin
return return
} }
} }
nodeConfig := w.WorkflowCont.NodeConfig nodeConfig := w.WorkflowCont.NodeConfig
w.Step = 1 w.Step = 1
w.StarNodeNumber = nodeConfig.NodeNumber w.StarNodeNumber = nodeConfig.NodeNumber
//流程线 //流程线
var nodeCont NodeCont var nodeCont NodeCont
nodeCont.Step = w.Step //步伐 nodeCont.Step = w.Step //步伐
nodeCont.Type = nodeConfig.Type
nodeCont.NodeNumber = nodeConfig.NodeNumber //节点编号 nodeCont.NodeNumber = nodeConfig.NodeNumber //节点编号
nodeCont.NodeName = nodeConfig.NodeName //节点名称 nodeCont.NodeName = nodeConfig.NodeName //节点名称
nodeCont.State = 1 //状态 1、不点亮;2、点亮 nodeCont.State = 1 //状态 1、不点亮;2、点亮
@ -150,21 +153,26 @@ func (w *WorkflowEngine) promoter() (nodeList []NodeCont, isTrue bool, msg strin
// nodeCont.UserList []UserListFlowAll //节点操作人 // nodeCont.UserList []UserListFlowAll //节点操作人
nodeCont.UserList = append(nodeCont.UserList, SetOperator(w.ApplicantCont)) nodeCont.UserList = append(nodeCont.UserList, SetOperator(w.ApplicantCont))
nodeList = append(nodeList, nodeCont) nodeList = append(nodeList, nodeCont)
var childNode *PublicChildNode // var childNode *PublicChildNode
childNode = nodeConfig.ChildNode // fmt.Printf("nodeConfig.ChildNode-->%v\n", nodeConfig.ChildNode)
childNode := nodeConfig.ChildNode
acceptOrgId, _ := strconv.ParseInt(w.AcceptOrg, 10, 64) acceptOrgId, _ := strconv.ParseInt(w.AcceptOrg, 10, 64)
// nodeListCont, isTrues, msgs := childNode.AnalysisNode(w.Step, childNode.Attribute, w.StarNodeNumber, w.ApplicantCont, acceptOrgId) // nodeListCont, isTrues, msgs := childNode.AnalysisNode(w.Step, childNode.Attribute, w.StarNodeNumber, w.ApplicantCont, acceptOrgId)
// nodeList = append(nodeList, nodeListCont) // nodeList = append(nodeList, nodeListCont)
// isTrue = isTrues // isTrue = isTrues
// msg = msgs // msg = msgs
// isTrue = true // isTrue = true
listNode := childNode.CircularParsing(w.Step, childNode.Attribute, w.StarNodeNumber, w.ApplicantCont, acceptOrgId, w.JudCond) if childNode != nil {
// fmt.Printf("childNode.NodeContList-->%v\n", listNode) listNode := childNode.CircularParsing(w.Step, childNode.Attribute, w.StarNodeNumber, w.ApplicantCont, acceptOrgId, w.JudCond)
if len(listNode) > 1 { if len(listNode) > 1 {
for _, v := range listNode { for _, v := range listNode {
nodeList = append(nodeList, v) nodeList = append(nodeList, v)
}
} }
} }
// fmt.Printf("childNode.NodeContList-->%v\n", listNode)
isTrue = true
return return
} }
@ -191,6 +199,7 @@ func (w *WorkflowEngine) promoter() (nodeList []NodeCont, isTrue bool, msg strin
*/ */
func (p *PublicChildNode) AnalysisNode(step int, attribute, sendBackNode string, applicantCont modelshr.PersonArchives, acceptorg int64) (nodeList NodeCont, isTrue bool, msg string) { func (p *PublicChildNode) AnalysisNode(step int, attribute, sendBackNode string, applicantCont modelshr.PersonArchives, acceptorg int64) (nodeList NodeCont, isTrue bool, msg string) {
step++ step++
// fmt.Printf("%v\n",)
switch p.Type { //节点类型 switch p.Type { //节点类型
case 1, 3: //审批 case 1, 3: //审批
//流程线 //流程线
@ -299,7 +308,7 @@ func (p *PublicChildNode) AnalysisNode(step int, attribute, sendBackNode string,
} }
} }
} }
fmt.Printf("指定角色-->") // fmt.Printf("指定角色-->")
isOk := false isOk := false
if len(roleId) > 0 { if len(roleId) > 0 {
for _, v := range roleId { for _, v := range roleId {
@ -420,7 +429,7 @@ func BaseOrgGainOperator(orgId int64, performAction []NodeUserListCont) (userLis
if len(performAction) > 0 { if len(performAction) > 0 {
//获取行政组织所有行政组织上级和下级 //获取行政组织所有行政组织上级和下级
allOrg := publicmethod.HaveAllOrgRelation(orgId) allOrg := publicmethod.HaveAllOrgRelation(orgId)
// fmt.Printf("获取行政组织所有行政组织上级和下级--->%v\n", allOrg) // fmt.Printf("获取行政组织所有行政组织上级和下级--->%v--->%v\n", allOrg, orgId)
// postOftoOrg := make(map[string][]int64, 0) // postOftoOrg := make(map[string][]int64, 0)
var gainDirector GainLeveDirector var gainDirector GainLeveDirector
for _, v := range performAction { for _, v := range performAction {
@ -454,7 +463,7 @@ func (g *GainLeveDirector) GetPostBaseOrg(unifyPosId string, orgList []int64) {
} }
//获取相关职务数据 //获取相关职务数据
var posCont []modelshr.PostDutiesJob var posCont []modelshr.PostDutiesJob
err = overall.CONSTANT_DB_HR.Model(&modelshr.PostDutiesJob{}).Select("`id`,`adm_org`,`weight`").Where("`id` IN ?", posIdStr).Find(&posCont).Error err = overall.CONSTANT_DB_HR.Model(&modelshr.PostDutiesJob{}).Select("`id`,`name`,`adm_org`,`weight`").Where("`id` IN ?", posIdStr).Find(&posCont).Error
// fmt.Printf("获取职务关联得行政组织-1-->%v\n", orgIdList) // fmt.Printf("获取职务关联得行政组织-1-->%v\n", orgIdList)
if err != nil || len(posCont) < 1 { if err != nil || len(posCont) < 1 {
return return
@ -465,6 +474,7 @@ func (g *GainLeveDirector) GetPostBaseOrg(unifyPosId string, orgList []int64) {
if !publicmethod.IsInTrue[int64](v.AdministrativeOrganization, orgIdList) { if !publicmethod.IsInTrue[int64](v.AdministrativeOrganization, orgIdList) {
orgIdList = append(orgIdList, v.AdministrativeOrganization) orgIdList = append(orgIdList, v.AdministrativeOrganization)
var orgPosIdCont JudgeOrgOfPosition var orgPosIdCont JudgeOrgOfPosition
orgPosIdCont.Name = v.Name
orgPosIdCont.OrgId = v.AdministrativeOrganization orgPosIdCont.OrgId = v.AdministrativeOrganization
orgPosIdCont.PositionId = v.Id orgPosIdCont.PositionId = v.Id
orgPosIdCont.Weight = v.Weight orgPosIdCont.Weight = v.Weight
@ -472,6 +482,8 @@ func (g *GainLeveDirector) GetPostBaseOrg(unifyPosId string, orgList []int64) {
} }
} }
jieguo := publicmethod.Intersect[int64](orgList, orgIdList) //获取交集,判断是否有相关职位 jieguo := publicmethod.Intersect[int64](orgList, orgIdList) //获取交集,判断是否有相关职位
// fmt.Printf("获取交集,判断是否有相关职位-1-->%v-->%v-->%v-->%v\n", jieguo, orgList, orgIdList, orgPosId)
//获取相关岗位人员 //获取相关岗位人员
if len(jieguo) > 0 { if len(jieguo) > 0 {
for _, ovp := range orgPosId { for _, ovp := range orgPosId {
@ -648,3 +660,10 @@ func SetOperator(userCont modelshr.PersonArchives) (userNode UserListFlowAll) {
return return
} }
// 判断下一步操作
func (n *JudgeNextNodeCont) JudgeNextNode(step int) {
// for _, v := range n.NodeContList{
// }
}

26
api/workflow/currency_recipe/structural_analysis.go

@ -1,7 +1,6 @@
package currency_recipe package currency_recipe
import ( import (
"fmt"
"key_performance_indicators/models/modelshr" "key_performance_indicators/models/modelshr"
"key_performance_indicators/overall" "key_performance_indicators/overall"
"key_performance_indicators/overall/publicmethod" "key_performance_indicators/overall/publicmethod"
@ -27,13 +26,14 @@ import (
*/ */
func (p *PublicChildNode) CircularParsing(step int, attribute, sendBackNode string, applicantCont modelshr.PersonArchives, acceptorg int64, judgingCondition []JudgingCondition) (NodeContList []NodeCont) { func (p *PublicChildNode) CircularParsing(step int, attribute, sendBackNode string, applicantCont modelshr.PersonArchives, acceptorg int64, judgingCondition []JudgingCondition) (NodeContList []NodeCont) {
// fmt.Printf("循环接卸--->%v---->%v\n", p.NodeName, p.NodeNumber) // fmt.Printf("循环接卸--NodeName->%v---NodeNumber->%v---Attribute->%v---attribute->%v---Type->%v---Settype->%v-----SelectRange->%v---NodeUserList->%v\n", p.NodeName, p.NodeNumber, p.Attribute, attribute, p.Type, p.Settype, p.SelectRange, p.NodeUserList)
step++ step++
var nodeCont NodeCont var nodeCont NodeCont
nodeCont.Step = step //步伐 nodeCont.Step = step //步伐
nodeCont.NodeNumber = p.NodeNumber //节点编号 nodeCont.NodeNumber = p.NodeNumber //节点编号
nodeCont.NodeName = p.NodeName //节点名称 nodeCont.NodeName = p.NodeName //节点名称
nodeCont.FromNode = p.FromNode nodeCont.FromNode = p.FromNode
nodeCont.Type = p.Type
// nodeCont.ArriveNode = p.GotoNode // nodeCont.ArriveNode = p.GotoNode
nodeCont.State = 1 //状态 1、不点亮;2、点亮 nodeCont.State = 1 //状态 1、不点亮;2、点亮
if p.SendBackNode == "beginnode" { if p.SendBackNode == "beginnode" {
@ -63,7 +63,7 @@ func (p *PublicChildNode) CircularParsing(step int, attribute, sendBackNode stri
var gainUser GainLeveDirector var gainUser GainLeveDirector
gainUser.Step = 0 gainUser.Step = 0
gainUser.Leve = p.DirectorLevel gainUser.Leve = p.DirectorLevel
if attribute == "1" { if p.Attribute == "1" {
gainUser.GainLeveDirector(applicantCont.AdminOrg) gainUser.GainLeveDirector(applicantCont.AdminOrg)
} else { } else {
gainUser.GainLeveDirector(acceptorg) gainUser.GainLeveDirector(acceptorg)
@ -76,7 +76,7 @@ func (p *PublicChildNode) CircularParsing(step int, attribute, sendBackNode stri
case 3: //行政岗位 case 3: //行政岗位
if len(p.NodeUserList) > 0 { if len(p.NodeUserList) > 0 {
var userList []modelshr.PersonArchives var userList []modelshr.PersonArchives
if attribute == "1" { if p.Attribute == "1" {
userList = BaseOrgGainOperator(applicantCont.AdminOrg, p.NodeUserList) userList = BaseOrgGainOperator(applicantCont.AdminOrg, p.NodeUserList)
} else { } else {
userList = BaseOrgGainOperator(acceptorg, p.NodeUserList) userList = BaseOrgGainOperator(acceptorg, p.NodeUserList)
@ -118,7 +118,7 @@ func (p *PublicChildNode) CircularParsing(step int, attribute, sendBackNode stri
} }
} }
} }
fmt.Printf("指定角色-->") // fmt.Printf("指定角色-->")
if len(roleId) > 0 { if len(roleId) > 0 {
for _, v := range roleId { for _, v := range roleId {
@ -211,7 +211,7 @@ func (p *PublicChildNode) CircularParsing(step int, attribute, sendBackNode stri
lastStrp := step lastStrp := step
for _, pv := range p.ConditionNodes { for _, pv := range p.ConditionNodes {
listContNode, isOk := pv.ResolveRouting(step, p.Attribute, sendBackNode, applicantCont, acceptorg, judgingCondition) listContNode, isOk := pv.ResolveRouting(step, p.Attribute, sendBackNode, applicantCont, acceptorg, judgingCondition)
fmt.Printf("提交满足---->%v---->%v\n", isOk, listContNode) // fmt.Printf("提交满足---->%v---->%v\n", isOk, listContNode)
if isOk && len(listContNode) > 0 { if isOk && len(listContNode) > 0 {
// for _, lcnv := range listContNode { // for _, lcnv := range listContNode {
// NodeContList = append(NodeContList, lcnv) // NodeContList = append(NodeContList, lcnv)
@ -221,7 +221,7 @@ func (p *PublicChildNode) CircularParsing(step int, attribute, sendBackNode stri
// NodeContList = append(NodeContList, NodeContListEnd...) // NodeContList = append(NodeContList, NodeContListEnd...)
// } // }
fmt.Printf("提交满足--12213-->%v---->%v\n", isOk, listContNode) // fmt.Printf("提交满足--12213-->%v---->%v\n", isOk, listContNode)
lastStrp = lastStrp + len(listContNode) lastStrp = lastStrp + len(listContNode)
NodeContList = append(NodeContList, listContNode...) NodeContList = append(NodeContList, listContNode...)
@ -279,14 +279,15 @@ func (p *PublicChildNode) CircularParsing(step int, attribute, sendBackNode stri
#func (p *PublicChildNode) ResolveRouting(step int, attribute, sendBackNode string, applicantCont modelshr.PersonArchives, acceptorg int64, judgingCondition []JudgingCondition) (NodeContList []NodeCont, isTrue bool) #func (p *PublicChildNode) ResolveRouting(step int, attribute, sendBackNode string, applicantCont modelshr.PersonArchives, acceptorg int64, judgingCondition []JudgingCondition) (NodeContList []NodeCont, isTrue bool)
*/ */
func (p *PublicChildNode) ResolveRouting(step int, attribute, sendBackNode string, applicantCont modelshr.PersonArchives, acceptorg int64, judgingCondition []JudgingCondition) (NodeContList []NodeCont, isTrue bool) { func (p *PublicChildNode) ResolveRouting(step int, attribute, sendBackNode string, applicantCont modelshr.PersonArchives, acceptorg int64, judgingCondition []JudgingCondition) (NodeContList []NodeCont, isTrue bool) {
fmt.Printf("条件名称----->%v----->%v\n", p.NodeName, p.NodeNumber) // fmt.Printf("条件名称----->%v----->%v\n", p.NodeName, p.NodeNumber)
if len(p.ConditionList) > 0 { if len(p.ConditionList) > 0 {
var areYourOk []InterimCondition var areYourOk []InterimCondition
for _, c := range p.ConditionList { for _, c := range p.ConditionList {
// fmt.Printf("can--->%v\n", c) // jsondf, _ := json.Marshal(c)
// fmt.Printf("can-www-->%v\n", string(jsondf))
var areYourOkCont InterimCondition var areYourOkCont InterimCondition
areYourOkCont.Class = c.Type areYourOkCont.Class = strconv.Itoa(c.Type)
switch c.Type { switch areYourOkCont.Class {
case "1": //发起人 case "1": //发起人
areYourOkCont.TsTrue = true areYourOkCont.TsTrue = true
areYourOkCont.IsOk = JudgePeopleIsTrue(p.NodeUserList, p.Attribute, applicantCont, acceptorg) areYourOkCont.IsOk = JudgePeopleIsTrue(p.NodeUserList, p.Attribute, applicantCont, acceptorg)
@ -370,6 +371,7 @@ func (p *PublicChildNode) ResolveRouting(step int, attribute, sendBackNode strin
#func JudgeCustomConditions(condition []ConditionStruct, myCondition []CustomFields) (isOk bool) #func JudgeCustomConditions(condition []ConditionStruct, myCondition []CustomFields) (isOk bool)
*/ */
func JudgeCustomConditions(condition []ConditionStruct, myCondition []CustomFields) (isOk bool) { func JudgeCustomConditions(condition []ConditionStruct, myCondition []CustomFields) (isOk bool) {
// fmt.Printf("判断自定义条件--》%v--->%v\n", condition, myCondition)
if len(condition) < 1 || len(myCondition) < 1 { if len(condition) < 1 || len(myCondition) < 1 {
isOk = false isOk = false
return return
@ -551,6 +553,6 @@ func JudgePeopleIsTrue(condition []NodeUserListCont, attribute string, applicant
} }
} }
} }
fmt.Printf("角色哈哈哈哈-1-->%v\n", panDing) // fmt.Printf("角色哈哈哈哈-1-->%v\n", panDing)
return return
} }

21
api/workflow/currency_recipe/type.go

@ -86,7 +86,7 @@ type NodeUserListCont struct {
// 当审批单同时满足以下条件时进入此流程 // 当审批单同时满足以下条件时进入此流程
type ConditionListCont struct { type ConditionListCont struct {
ColumnID string `json:"columnId"` // ColumnID string `json:"columnId"` //
Type string `json:"type"` //1:发起人;2:关联数据表;3:自定义字段 Type int `json:"type"` //1:发起人;2:关联数据表;3:自定义字段
ConditionEn string `json:"conditionEn"` ConditionEn string `json:"conditionEn"`
ConditionCn string `json:"conditionCn"` ConditionCn string `json:"conditionCn"`
OptType string `json:"optType"` //["", "<", ">", "≤", "=", "≥"][optType] 计算符号 OptType string `json:"optType"` //["", "<", ">", "≤", "=", "≥"][optType] 计算符号
@ -144,14 +144,20 @@ type EquationStruct struct {
// 输出单条结构工作流 // 输出单条结构工作流
type SendOneWorkflow struct { type SendOneWorkflow struct {
IsTrue bool `json:"istrue"` //是否允许 IsTrue bool `json:"istrue"` //是否允许
Msg string `json:"msg"` //错误信息 Msg string `json:"msg"` //错误信息
NodeContList []NodeCont `json:"nodecontlist"` //审批节点列表 CurrentNode string `json:"currentnode"` //当前节点
CurrentUserKey string `json:"currentuserkey"` //当前操作人
CurrentUserOrg string `json:"currentuserorg"` //当前操作人行政组织
Step int `json:"step"` //当前第几步
NodeContList []NodeCont `json:"nodecontlist"` //审批节点列表
Version string `json:"version"` //b版本
} }
// 节点信息 // 节点信息
type NodeCont struct { type NodeCont struct {
Step int `json:"step"` //步伐 Step int `json:"step"` //步伐
Type int `json:"type"` //节点类型 0:发起人;1:审批;2:抄送;3:执行节点;4:路由;5:条件;
NodeNumber string `json:"nodenumber"` //节点编号 NodeNumber string `json:"nodenumber"` //节点编号
NodeName string `json:"nodename"` //节点名称 NodeName string `json:"nodename"` //节点名称
State int `json:"state"` //状态 1、不点亮;2、点亮 State int `json:"state"` //状态 1、不点亮;2、点亮
@ -165,6 +171,7 @@ type NodeCont struct {
RunScope int `json:"runscope"` //运行时选择范围 0:不可选,1:本公司;2:本部门;当RunType = 4时:1:自选;非1:不可自选 RunScope int `json:"runscope"` //运行时选择范围 0:不可选,1:本公司;2:本部门;当RunType = 4时:1:自选;非1:不可自选
CustomNode string `json:"customNode"` //由哪个节点指定本节点审批人 CustomNode string `json:"customNode"` //由哪个节点指定本节点审批人
ExecutionAddress string `json:"executionaddress"` //执行节点跳转页面 ExecutionAddress string `json:"executionaddress"` //执行节点跳转页面
JudgeList bool `json:"judgelist"` //是否可自己选中操作人
} }
// 节点操作人 // 节点操作人
@ -187,6 +194,7 @@ type UserListFlowAll struct {
type LogList struct { type LogList struct {
State int `json:"state"` //状态 1、未操作;2、通过;3、驳回 State int `json:"state"` //状态 1、未操作;2、通过;3、驳回
TimeVal string `json:"time"` TimeVal string `json:"time"`
Cause string `json:"cause"` //审批意见
Enclosure []EnclosureFormat `json:"enclosure"` //附件 Enclosure []EnclosureFormat `json:"enclosure"` //附件
} }
@ -206,6 +214,7 @@ type GainLeveDirector struct {
// 判断事那个行政组织得相关岗位 // 判断事那个行政组织得相关岗位
type JudgeOrgOfPosition struct { type JudgeOrgOfPosition struct {
publicmethod.PublicName
OrgId int64 OrgId int64
PositionId int64 PositionId int64
Weight int64 Weight int64
@ -231,3 +240,7 @@ type InterimCondition struct {
IsOk bool `json:"isok"` //符合与不符合 IsOk bool `json:"isok"` //符合与不符合
TsTrue bool `json:"istrue"` //操作与为操作 TsTrue bool `json:"istrue"` //操作与为操作
} }
type JudgeNextNodeCont struct {
NodeContList []NodeCont `json:"nodecontlist"` //审批节点列表
}

57
api/workflow/workflowengine/type.go

@ -1,6 +1,7 @@
package workflowengine package workflowengine
import ( import (
"key_performance_indicators/api/workflow/currency_recipe"
"key_performance_indicators/models/modelskpi" "key_performance_indicators/models/modelskpi"
"key_performance_indicators/overall/publicmethod" "key_performance_indicators/overall/publicmethod"
) )
@ -29,6 +30,7 @@ type NodeConfigStruct struct {
type PublicNodeWord struct { type PublicNodeWord struct {
IsTrue bool `json:"error"` //当前审批是否通过校验 IsTrue bool `json:"error"` //当前审批是否通过校验
NodeName string `json:"nodeName"` //节点名称 NodeName string `json:"nodeName"` //节点名称
Attribute string `json:"attribute"` //节点名称操作识别
Type int `json:"type"` // 0 发起人 1审批 2抄送 3条件 4路由 Type int `json:"type"` // 0 发起人 1审批 2抄送 3条件 4路由
PriorityLevel int `json:"priorityLevel"` //条件优先级 0,1,2,3,4,5,6,7,8,9,10 PriorityLevel int `json:"priorityLevel"` //条件优先级 0,1,2,3,4,5,6,7,8,9,10
Settype int `json:"settype"` // 审批人设置 1指定成员 2主管 4发起人自选 5发起人自己 7连续多级主管 Settype int `json:"settype"` // 审批人设置 1指定成员 2主管 4发起人自选 5发起人自己 7连续多级主管
@ -101,6 +103,7 @@ type PublishWorkFlowCont struct {
publicmethod.PublicName //工作流名称 publicmethod.PublicName //工作流名称
Describe string `json:"describe"` //描述 Describe string `json:"describe"` //描述
Flowcont FlowStructIng `json:"flowcont"` //流程主体 Flowcont FlowStructIng `json:"flowcont"` //流程主体
WeChat int `json:"wechat"` //关联企业微信
} }
// 输出工作流列表 // 输出工作流列表
@ -120,3 +123,57 @@ type EditWorkFlowInfo struct {
PublishWorkFlowCont PublishWorkFlowCont
VersionId string `json:"versionid"` //版本ID VersionId string `json:"versionid"` //版本ID
} }
// 获取工作流
type GetWorkFlowInfoIng struct {
FlowWorkId string `json:"flowworkid"` //
OrgId string `json:"orgid"` //接受考核得行政组织
Condition []MyCondition `json:"condition"`
}
// 自定义条件
type MyCondition struct {
Words string `json:"words"` //字段
Price string `json:"price"` //值
}
// 操作工作流
type OperateWorkflow struct {
Step int `json:"step"` //操作哪一步
NextStep int //下一步
OrderId int64 `json:"orderid"` //发起表单ID
Attribute int `json:"attribute"` //属性 1、定性;2、定量
OperationStatus int `json:"operationstatus"` //操作状态
ManipulatePeople ManipulatePeopleInfo //操作人相关
UploadFiles []currency_recipe.EnclosureFormat
WorkFlowList []currency_recipe.NodeCont //流程步进图
EndFlow bool //流程是否结束
Participant []string //参与人
NextNodeCont currency_recipe.NodeCont //下一个节点
NextNodeContExecutor []string //下一步执行人
CurrentNode currency_recipe.NodeCont //当前节点
}
// 附件文件
type UploadFilesCont struct {
publicmethod.PublicName //文件名称
FileUrl string `json:"fileUrl"` //文件访问地址
PhysicsPath string `json:"physicspath"` //文件物理地址
Type int `json:"type"` //类型 1:图片;2:视频;3:office文档;4:压缩文件;5:其他文件
FileSize int64 `json:"fileSize"` //文件大小(单位:B)
Size string `json:"size"` //文件大小文字描述
Tag string `json:"tag"` //文件后缀
}
// 操作人信息
type ManipulatePeopleInfo struct {
Key string `json:"key"` //操作人
OrgId string `json:"orgid"` //操作人行政组织
}
// 指标相关
type TargetInfo struct {
TargeiId int64
TableId int64
BylawsId int64
}

17
api/workflow/workflowengine/workflow.go

@ -66,6 +66,7 @@ func (a *ApiMethod) GetWorkFlowList(c *gin.Context) {
sendCont.VersionState = v.VersionState //状态(1:启用;2:禁用;3:删除)"` sendCont.VersionState = v.VersionState //状态(1:启用;2:禁用;3:删除)"`
sendCont.Time = v.Time //写入时间"` sendCont.Time = v.Time //写入时间"`
sendCont.VersionId = v.VersionId //附表ID sendCont.VersionId = v.VersionId //附表ID
sendCont.OpenWechat = v.OpenWechat
sendCont.Key = strconv.FormatInt(v.Id, 10) sendCont.Key = strconv.FormatInt(v.Id, 10)
sendListCont = append(sendListCont, sendCont) sendListCont = append(sendListCont, sendCont)
} }
@ -102,12 +103,20 @@ func (a *ApiMethod) PublishWorkFlow(c *gin.Context) {
publicmethod.Result(100, receivedValue, c) publicmethod.Result(100, receivedValue, c)
return return
} }
if receivedValue.WeChat == 0 {
receivedValue.WeChat = 1
}
flowContStr, err := json.Marshal(receivedValue.Flowcont) flowContStr, err := json.Marshal(receivedValue.Flowcont)
if err != nil { if err != nil {
publicmethod.Result(1, err, c, "您提交的流程格式不正确!") publicmethod.Result(1, err, c, "您提交的流程格式不正确!")
return return
} }
// hjsdahkf := publicmethod.MapOut[string]()
// hjsdahkf["flowContStr"] = string(flowContStr)
// hjsdahkf["Flowcont"] = receivedValue.Flowcont
// publicmethod.Result(1, hjsdahkf, c, "您提交的流程格式不正确!")
// return
flowKey, _ := strconv.ParseInt(receivedValue.Flowid, 10, 64) flowKey, _ := strconv.ParseInt(receivedValue.Flowid, 10, 64)
var workFlowCont modelskpi.WorkFlow var workFlowCont modelskpi.WorkFlow
@ -154,6 +163,7 @@ func (a *ApiMethod) PublishWorkFlow(c *gin.Context) {
workFlowCont.Time = dayTime //写入时间"` workFlowCont.Time = dayTime //写入时间"`
workFlowCont.Describe = receivedValue.Describe //描述 workFlowCont.Describe = receivedValue.Describe //描述
workFlowCont.State = 1 workFlowCont.State = 1
workFlowCont.OpenWechat = receivedValue.WeChat
workFlowVerSion.Key = flowKey //流程标号 workFlowVerSion.Key = flowKey //流程标号
workFlowVerSion.Content = string(flowContStr) //工作流主体 workFlowVerSion.Content = string(flowContStr) //工作流主体
@ -397,6 +407,10 @@ func (a *ApiMethod) EditWorkFlowCont(c *gin.Context) {
publicmethod.Result(100, receivedValue, c) publicmethod.Result(100, receivedValue, c)
return return
} }
if receivedValue.WeChat == 0 {
receivedValue.WeChat = 1
}
flowContStr, err := json.Marshal(receivedValue.Flowcont) flowContStr, err := json.Marshal(receivedValue.Flowcont)
if err != nil { if err != nil {
publicmethod.Result(1, err, c, "您提交的流程格式不正确!") publicmethod.Result(1, err, c, "您提交的流程格式不正确!")
@ -422,6 +436,9 @@ func (a *ApiMethod) EditWorkFlowCont(c *gin.Context) {
if workFlowCont.Describe != receivedValue.Describe { if workFlowCont.Describe != receivedValue.Describe {
saveMainData["`describe`"] = receivedValue.Describe saveMainData["`describe`"] = receivedValue.Describe
} }
if workFlowCont.OpenWechat != receivedValue.WeChat {
saveMainData["`open_wechat`"] = receivedValue.WeChat
}
if len(saveMainData) > 0 { if len(saveMainData) > 0 {
saveMainData["`time`"] = dayTime saveMainData["`time`"] = dayTime
var editWorkFlowMain modelskpi.WorkFlow var editWorkFlowMain modelskpi.WorkFlow

206
api/workflow/workflowengine/workflowapi.go

@ -0,0 +1,206 @@
package workflowengine
import (
"key_performance_indicators/api/workflow/currency_recipe"
"key_performance_indicators/models/modelshr"
"key_performance_indicators/overall/publicmethod"
"strconv"
"time"
"github.com/gin-gonic/gin"
)
/*
*
@ 作者: 秦东
@ 时间: 2023-04-03 15:06:49
@ 功能: 获取工作流
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) GetWorkFlowFullView(c *gin.Context) {
var receivedValue GetWorkFlowInfoIng
c.ShouldBindJSON(&receivedValue)
if receivedValue.FlowWorkId == "" {
publicmethod.Result(1, receivedValue, c, "未知流程")
return
}
if receivedValue.OrgId == "" {
publicmethod.Result(1, receivedValue, c, "未知流程")
return
}
// ohjf, _ := strconv.ParseInt(receivedValue.OrgId, 10, 64)
// var getAllOrg publicmethod.GetOrgAllParent
// // getAllOrg.GetOrgParentAllId(departmentId)
// getAllOrg.GetOrgSonAllId(ohjf)
// fmt.Printf("%v\n", getAllOrg.Id)
// return
//获取登录人信息
myLoginCont, _ := publicmethod.LoginMyCont(c)
myKey := strconv.FormatInt(myLoginCont.Key, 10)
var workflowInfo currency_recipe.WorkflowEngine
if len(receivedValue.Condition) > 0 {
//条件设定
var tijiao1 currency_recipe.JudgingCondition
tijiao1.Class = 1
//自定义判断
var zdyPd []currency_recipe.CustomFields
for _, v := range receivedValue.Condition {
var zdyPdCont currency_recipe.CustomFields
zdyPdCont.WordField = v.Words
zdyPdCont.LeftVal = v.Price
zdyPd = append(zdyPd, zdyPdCont)
}
tijiao1.MyCustom = zdyPd
workflowInfo.JudCond = append(workflowInfo.JudCond, tijiao1)
}
jieguo := workflowInfo.InitWorkflow(receivedValue.FlowWorkId, "", myKey, receivedValue.OrgId).SendData()
// sjkdjk, _ := json.Marshal(receivedValue)
// fmt.Printf("初始化条件---》%v/n", string(sjkdjk))
if !jieguo.IsTrue {
publicmethod.Result(1, jieguo, c, "未能获取到流程!")
} else {
jieguo.Step = 1
for _, v := range jieguo.NodeContList {
if v.Step == 1 {
jieguo.CurrentNode = v.NodeNumber
break
}
}
jieguo.Version = workflowInfo.VersionId
jieguo.CurrentUserKey = myKey
var cureeUserCont modelshr.PersonArchives
cureeUserCont.GetCont(map[string]interface{}{"`key`": myKey}, "`admin_org`")
jieguo.CurrentUserOrg = strconv.FormatInt(cureeUserCont.AdminOrg, 10)
publicmethod.Result(0, jieguo, c)
}
// senfdsd := publicmethod.MapOut[string]()
// senfdsd["jieguo"] = jieguo
// senfdsd["workflowInfo"] = workflowInfo
// publicmethod.Result(0, senfdsd, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2023-04-07 11:03:01
@ 功能: 验证工作流
@ 参数
#workflowInfo 工作流列表
@ 返回值
#isTrue 是否合格
@ 方法原型
#func JudgeWorkflowIsTrue(workflowInfo []currency_recipe.NodeCont) (isTrue bool)
*/
func JudgeWorkflowIsTrue(workflowInfo []currency_recipe.NodeCont) (isTrue bool) {
isTrue = true
if len(workflowInfo) < 1 {
isTrue = false
} else {
for _, v := range workflowInfo {
if v.JudgeList {
if len(v.UserList) < 1 {
isTrue = false
break
}
}
}
}
return
}
// 写工作流
func (o *OperateWorkflow) ManipulateWorkflow() (WorkFlowList []currency_recipe.NodeCont) {
workflowLength := len(o.WorkFlowList)
nextSet := o.Step + 1
o.NextStep = nextSet
o.EndFlow = false
if nextSet > workflowLength {
o.EndFlow = true
o.NextStep = 0
return
}
for i, v := range o.WorkFlowList {
if v.Step < o.Step {
o.WorkFlowList[i].State = 2
for _, usv := range v.UserList {
if !publicmethod.IsInTrue[string](usv.Id, o.Participant) {
o.Participant = append(o.Participant, usv.Id)
}
}
}
if v.Step == o.Step {
o.WorkFlowList[i].State = 2
for ui, uv := range v.UserList {
if uv.Id == o.ManipulatePeople.Key {
var userCarrLog currency_recipe.LogList
userCarrLog.State = o.OperationStatus //状态 1、未操作;2、通过;3、驳回
userCarrLog.TimeVal = publicmethod.UnixTimeToDay(time.Now().Unix(), 1)
userCarrLog.Enclosure = o.UploadFiles //附件
o.WorkFlowList[i].UserList[ui].LogList = append(o.WorkFlowList[i].UserList[ui].LogList, userCarrLog)
// fmt.Printf("测样---3333--->%v---》%v---》%v\n", v.NodeName, userCarrLog, v.NodeName)
}
if !publicmethod.IsInTrue[string](uv.Id, o.Participant) {
o.Participant = append(o.Participant, uv.Id)
}
}
o.CurrentNode = v
// fmt.Printf("测样---22222》%v---》%v---》%v\n", v.NodeName, v, v.NodeName)
}
//判断下一步要执行什么
if nextSet <= workflowLength {
if v.Step == nextSet {
// fmt.Printf("测样---1111》%v---》%v---》%v\n", workflowLength, nextSet, v.NodeName)
writeLog := false
if v.Type == 2 {
o.Step = nextSet
WorkFlowList = o.ManipulateWorkflow()
writeLog = true
o.WorkFlowList[i].State = 2
}
var nextZhiXingRen []string
for ni, nv := range v.UserList {
if !publicmethod.IsInTrue[string](nv.Id, o.Participant) {
o.Participant = append(o.Participant, nv.Id) //参与人
}
if !publicmethod.IsInTrue[string](nv.Id, nextZhiXingRen) {
nextZhiXingRen = append(nextZhiXingRen, nv.Id) //下一步执行人
}
if writeLog { //参送节点直接发送信息
var userCsCarrLog currency_recipe.LogList
userCsCarrLog.State = 2 //状态 1、未操作;2、通过;3、驳回
userCsCarrLog.TimeVal = publicmethod.UnixTimeToDay(time.Now().Unix(), 1)
userCsCarrLog.Enclosure = o.UploadFiles //附件
o.WorkFlowList[i].UserList[ni].LogList = append(o.WorkFlowList[i].UserList[ni].LogList, userCsCarrLog)
}
}
o.NextNodeContExecutor = nextZhiXingRen
o.NextNodeCont = v
}
}
}
// if o.WorkFlowList[88].State != nil {
// }
// fmt.Printf("测样---》%v---》%v", workflowLength, o.WorkFlowList[workflowLength-1])
WorkFlowList = o.WorkFlowList
return
}

2
apirouter/apishiyan/maptostruct.go

@ -34,5 +34,7 @@ func (a *ApiRouter) RouterGroup(router *gin.RouterGroup) {
//验证工作流 //验证工作流
apiRouter.POST("test_verify_workflow", methodBinding.TestAndVerifyWorkflow) //验证工作流函数 apiRouter.POST("test_verify_workflow", methodBinding.TestAndVerifyWorkflow) //验证工作流函数
//校正老流程
apiRouter.POST("check_old_workflow", methodBinding.CheckOldWorkflow) //校正老流程
} }
} }

3
apirouter/v1/departmentseting/pc.go

@ -71,5 +71,8 @@ func (a *ApiRouter) RouterGroupPc(router *gin.RouterGroup) {
//数据提报相关 //数据提报相关
apiRouter.POST("get_quantitative_tasks", methodBinding.GetQuantitativeTasks) //获取定量考核任务列表 apiRouter.POST("get_quantitative_tasks", methodBinding.GetQuantitativeTasks) //获取定量考核任务列表
apiRouter.POST("get_quality_tasks", methodBinding.GetQualityTasks) //获取定性考核任务列表
apiRouter.POST("get_qualbylaws_tasks", methodBinding.GetQualityBylawsTasks) //相关提报人定性考核细则列表
apiRouter.POST("submit_quality_assess", methodBinding.SubmitQualityAssess) //提交定性考核
} }
} }

5
apirouter/workflowchart/flowes.go

@ -15,5 +15,10 @@ func (a *ApiRouter) RouterGroup(router *gin.RouterGroup) {
apiRouter.GET("", workFlow.Index) //入口 apiRouter.GET("", workFlow.Index) //入口
apiRouter.POST("", workFlow.Index) //入口 apiRouter.POST("", workFlow.Index) //入口
apiRouter.POST("review_workflow", workFlow.ReviewWorkFlow) //生成审批流程流 apiRouter.POST("review_workflow", workFlow.ReviewWorkFlow) //生成审批流程流
apiRouter.POST("get_approval_record", workFlow.GetApprovalRecord) //流程记录
apiRouter.POST("look_work_flowcont", workFlow.LookWorkFlowCont) //查看流程记录详情
apiRouter.POST("examine_and_approve", workFlow.ExamineAndApprove) //执行审批
} }
} }

2
apirouter/workflowrouter/flowrouter.go

@ -32,5 +32,7 @@ func (a *ApiRouter) RouterGroup(router *gin.RouterGroup) {
apiRouter.POST("get_workflow_version_list", workFlow.GetWorkFlowVersionList) //获取流程版本列表 apiRouter.POST("get_workflow_version_list", workFlow.GetWorkFlowVersionList) //获取流程版本列表
apiRouter.POST("edit_workflow_cont", workFlow.EditWorkFlowCont) //编辑流程主体 apiRouter.POST("edit_workflow_cont", workFlow.EditWorkFlowCont) //编辑流程主体
apiRouter.POST("start_using_version", workFlow.StartUsingVersion) //启用流程版本 apiRouter.POST("start_using_version", workFlow.StartUsingVersion) //启用流程版本
apiRouter.POST("get_work_flow_fullview", workFlow.GetWorkFlowFullView) //获取顺序工作流
} }
} }

2
middleware/wechatapp/wechatcallback/event_processing.go

@ -224,7 +224,7 @@ func (b *ButtonEventQuestion) PostTemolateCallBack(orderId, clickEnter, systemAp
orderIdInt, _ := strconv.ParseInt(orderId, 10, 64) orderIdInt, _ := strconv.ParseInt(orderId, 10, 64)
operatorIsTreu.OrderId = orderIdInt operatorIsTreu.OrderId = orderIdInt
operatorIsTreu.OperatorTime = time.Now().Unix() operatorIsTreu.OperatorTime = time.Now().Unix()
operatorIsTreu.Step = flowOneCont.Step operatorIsTreu.Step = int64(flowOneCont.Step)
operatorIsTreu.OperatorType = 2 operatorIsTreu.OperatorType = 2
operatorIsTreu.Msgid = "" operatorIsTreu.Msgid = ""
operatorIsTreu.ResponseCode = b.ResponseCode operatorIsTreu.ResponseCode = b.ResponseCode

97
models/modelskpi/approval_record.go

@ -0,0 +1,97 @@
package modelskpi
import (
"key_performance_indicators/overall"
"strings"
)
/*
*
@ 作者: 秦东
@ 时间: 2023-04-08 10:28:42
@ 功能: 审批记录视图
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
type ApprovalRecord struct {
Id int64 `json:"id" gorm:"primaryKey;column:ep_id;type:bigint(20) unsigned;not null"`
OrderKey int64 `json:"orderkey" gorm:"column:ep_order_key;type:bigint(20) unsigned;default:0;not null;comment:发起表单key"`
Step int `json:"step" gorm:"column:ep_step;type:int(7) unsigned;default:1;not null;comment:当前执行到第几部"`
Content string `json:"content" gorm:"column:ep_cont;type:longtext;comment:流程步进值"`
NextContent string `json:"nextcontent" gorm:"column:ep_next_cont;type:mediumtext;comment:下一步内容"`
Time int64 `json:"time" gorm:"column:ep_time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"`
State int `json:"state" gorm:"column:ep_state;type:int(2) unsigned;default:1;not null;comment:1:草稿,2:审批中;3:驳回;4:归档;5:删除"`
RoleGroup int64 `json:"rolegroup" gorm:"column:ep_role_group;type:bigint(20) unsigned;default:0;not null;comment:角色组"`
TypeClass int `json:"type" gorm:"column:ep_type;type:tinyint(1) unsigned;default:1;not null;comment:1、定性;2、定量"`
Participants string `json:"participants" gorm:"column:ep_participants;type:mediumtext;comment:参与人"`
StartTime int64 `json:"starttime" gorm:"column:ep_start_time;type:bigint(20) unsigned;default:0;not null;comment:流程开始时间"`
NextStep int `json:"nextstep" gorm:"column:ep_next_step;type:int(7) unsigned;default:1;not null;comment:下一步"`
NextExecutor string `json:"nextexecutor" gorm:"column:ep_next_executor;type:mediumtext;comment:下一步执行人"`
SetupDepartment int64 `json:"setupdepartment" gorm:"column:ep_setup_department;type:bigint(20) unsigned;default:0;not null;comment:发起部门"`
Dimension string `json:"dimension" gorm:"column:ep_dimension;type:mediumtext;comment:维度"`
Target string `json:"target" gorm:"column:ep_target;type:mediumtext;comment:指标"`
DetailedTarget string `json:"detailedtarget" gorm:"column:ep_detailedtarget;type:mediumtext;comment:指标细则"`
AcceptDepartment int64 `json:"acceptdepartment" gorm:"column:ep_accept_department;type:bigint(20) unsigned;default:0;not null;comment:接受考核部门"`
HappenTime int64 `json:"happentime" gorm:"column:ep_happen_time;type:bigint(20) unsigned;default:0;not null;comment:发生时间"`
FlowKey int64 `json:"flowkey" gorm:"column:ep_flow_key;type:bigint(20) unsigned;default:0;not null;comment:工作流识别符"`
FlowVid int64 `json:"flowvid" gorm:"column:ep_flow_vid;type:bigint(20) unsigned;default:0;not null;comment:当前工作流版本号"`
EpOld int `json:"epold" gorm:"column:ep_old;type:int(1) unsigned;default:1;not null;comment:1:旧流程;2:新流程"`
Creater int64 `json:"creater" gorm:"column:ep_creater;type:bigint(20) unsigned;default:0;not null;comment:流程创始人"`
TargetTitle string `json:"targettitle" gorm:"column:target_title;type:varchar(255);comment:指标名称"`
BylawsTitle string `json:"bylawstitle" gorm:"column:bylaws_title;type:varchar(255);comment:细则名称"`
Clique int64 `json:"clique" gorm:"column:ep_clique;type:bigint(20) unsigned;default:0;not null;comment:公司"`
}
func (ApprovalRecord *ApprovalRecord) TableName() string {
return "approval_record"
}
// 编辑内容
func (cont *ApprovalRecord) EiteCont(whereMap interface{}, saveData interface{}) (err error) {
err = overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Updates(saveData).Error
return
}
// 获取内容
func (cont *ApprovalRecord) GetCont(whereMap interface{}, field ...string) (err error) {
gormDb := overall.CONSTANT_DB_KPI.Model(&cont)
if len(field) > 0 {
fieldStr := strings.Join(field, ",")
gormDb = gormDb.Select(fieldStr)
}
gormDb = gormDb.Where(whereMap)
err = gormDb.First(&cont).Error
return
}
// 根据条件获取总数
func (cont *ApprovalRecord) CountCont(whereMap interface{}) (countId int64) {
overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Count(&countId)
return
}
// 读取全部信息
func (cont *ApprovalRecord) ContMap(whereMap interface{}, field ...string) (countAry []ApprovalRecord, err error) {
gormDb := overall.CONSTANT_DB_KPI.Model(&cont)
if len(field) > 0 {
fieldStr := strings.Join(field, ",")
gormDb = gormDb.Select(fieldStr)
}
err = gormDb.Where(whereMap).Find(&countAry).Error
return
}
// 删除内容
func (cont *ApprovalRecord) DelCont(whereMap interface{}) (err error) {
err = overall.CONSTANT_DB_KPI.Where(whereMap).Delete(&cont).Error
return
}

7
models/modelskpi/evaluation_process.go

@ -13,7 +13,7 @@ type EvaluationProcess struct {
Content string `json:"content" gorm:"column:ep_cont;type:longtext;comment:流程步进值"` Content string `json:"content" gorm:"column:ep_cont;type:longtext;comment:流程步进值"`
NextContent string `json:"nextcontent" gorm:"column:ep_next_cont;type:mediumtext;comment:下一步内容"` NextContent string `json:"nextcontent" gorm:"column:ep_next_cont;type:mediumtext;comment:下一步内容"`
Time int64 `json:"time" gorm:"column:ep_time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` Time int64 `json:"time" gorm:"column:ep_time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"`
State int `json:"state" gorm:"column:ep_state;type:int(2) unsigned;default:1;not null;comment:1:起草,2:审批中;3:通过;4:驳回"` State int `json:"state" gorm:"column:ep_state;type:int(2) unsigned;default:1;not null;comment:1:草稿,2:审批中;3:驳回;4:归档;5:删除"`
RoleGroup int64 `json:"rolegroup" gorm:"column:ep_role_group;type:bigint(20) unsigned;default:0;not null;comment:角色组"` RoleGroup int64 `json:"rolegroup" gorm:"column:ep_role_group;type:bigint(20) unsigned;default:0;not null;comment:角色组"`
TypeClass int `json:"type" gorm:"column:ep_type;type:tinyint(1) unsigned;default:1;not null;comment:1、定性;2、定量"` TypeClass int `json:"type" gorm:"column:ep_type;type:tinyint(1) unsigned;default:1;not null;comment:1、定性;2、定量"`
Participants string `json:"participants" gorm:"column:ep_participants;type:mediumtext;comment:参与人"` Participants string `json:"participants" gorm:"column:ep_participants;type:mediumtext;comment:参与人"`
@ -26,6 +26,11 @@ type EvaluationProcess struct {
DetailedTarget string `json:"detailedtarget" gorm:"column:ep_detailedtarget;type:mediumtext;comment:指标细则"` DetailedTarget string `json:"detailedtarget" gorm:"column:ep_detailedtarget;type:mediumtext;comment:指标细则"`
AcceptDepartment int64 `json:"acceptdepartment" gorm:"column:ep_accept_department;type:bigint(20) unsigned;default:0;not null;comment:接受考核部门"` AcceptDepartment int64 `json:"acceptdepartment" gorm:"column:ep_accept_department;type:bigint(20) unsigned;default:0;not null;comment:接受考核部门"`
HappenTime int64 `json:"happentime" gorm:"column:ep_happen_time;type:bigint(20) unsigned;default:0;not null;comment:发生时间"` HappenTime int64 `json:"happentime" gorm:"column:ep_happen_time;type:bigint(20) unsigned;default:0;not null;comment:发生时间"`
FlowKey int64 `json:"flowkey" gorm:"column:ep_flow_key;type:bigint(20) unsigned;default:0;not null;comment:工作流识别符"`
FlowVid int64 `json:"flowvid" gorm:"column:ep_flow_vid;type:bigint(20) unsigned;default:0;not null;comment:当前工作流版本号"`
EpOld int `json:"epold" gorm:"column:ep_old;type:int(7) unsigned;default:1;not null;comment:1:旧流程;2:新流程"`
Creater int64 `json:"creater" gorm:"column:ep_creater;type:bigint(20) unsigned;default:0;not null;comment:流程创始人"`
Clique int64 `json:"clique" gorm:"column:ep_clique;type:bigint(20) unsigned;default:0;not null;comment:公司"`
} }
func (EvaluationProcess *EvaluationProcess) TableName() string { func (EvaluationProcess *EvaluationProcess) TableName() string {

6
models/modelskpi/open_approval_change_log.go

@ -13,14 +13,16 @@ type OpenApprovalChangeLog struct {
Operator int64 `json:"operator" gorm:"column:operator;type:bigint(20);comment:操作人"` Operator int64 `json:"operator" gorm:"column:operator;type:bigint(20);comment:操作人"`
OrderId int64 `json:"orderid" gorm:"column:orderid;type:bigint(20) unsigned;default:0;not null;comment:订单ID"` OrderId int64 `json:"orderid" gorm:"column:orderid;type:bigint(20) unsigned;default:0;not null;comment:订单ID"`
OperatorTime int64 `json:"operatortime" gorm:"column:operatortime;type:bigint(20) unsigned;default:0;not null;comment:操作时间"` OperatorTime int64 `json:"operatortime" gorm:"column:operatortime;type:bigint(20) unsigned;default:0;not null;comment:操作时间"`
Step int `json:"step" gorm:"column:step;type:int(5) unsigned;default:1;not null;comment:操作第几步"` Step int64 `json:"step" gorm:"column:step;type:int(5) unsigned;default:1;not null;comment:操作第几步"`
OperatorType int `json:"operatortype" gorm:"column:operatortype;type:int(1) unsigned;default:1;not null;comment:操作状态(1:位操作;2:已操作)"` OperatorType int `json:"operatortype" gorm:"column:operatortype;type:int(1) unsigned;default:1;not null;comment:操作状态(1:位操作;2:已操作)"`
Msgid string `json:"msgid" gorm:"column:msgid;type:varchar(255);comment:消息id,用于撤回应用消息"` Msgid string `json:"msgid" gorm:"column:msgid;type:varchar(255);comment:消息id,用于撤回应用消息"`
ResponseCode string `json:"responsecode" gorm:"column:response_code;type:varchar(255);comment:仅消息类型为“按钮交互型”,“投票选择型”和“多项选择型”的模板卡片消息返回,应用可使用response_code调用更新模版卡片消息接口,24小时内有效,且只能使用一次"` ResponseCode string `json:"responsecode" gorm:"column:response_code;type:varchar(255);comment:仅消息类型为“按钮交互型”,“投票选择型”和“多项选择型”的模板卡片消息返回,应用可使用response_code调用更新模版卡片消息接口,24小时内有效,且只能使用一次"`
Stepper int `json:"stepper" gorm:"column:stepper;type:int(5) unsigned;default:1;not null;comment:步进器"` Stepper int `json:"stepper" gorm:"column:stepper;type:int(5) unsigned;default:1;not null;comment:步进器"`
ChangeIsTrue int `json:"changeistrue" gorm:"column:change_is_true;type:int(1) unsigned;default:1;not null;comment:是否可变更(1:可变更;2:不可变更)"` ChangeIsTrue int `json:"changeistrue" gorm:"column:change_is_true;type:int(1) unsigned;default:1;not null;comment:是否可变更(1:可变更;2:不可变更)"`
Eiteyime int64 `json:"eiteyime" gorm:"column:eiteyime;type:bigint(20) unsigned;default:0;not null;comment:变动时间"` Eiteyime int64 `json:"eiteyime" gorm:"column:eiteyime;type:bigint(20) unsigned;default:0;not null;comment:变动时间"`
YesOrNo int `json:"yesorno" gorm:"column:yesorno;type:int(1) unsigned;default:0;not null;comment:0:未操作;1:同意;2:驳回;3:撤回"` YesOrNo int `json:"yesorno" gorm:"column:yesorno;type:int(1) unsigned;default:0;not null;comment:1:草稿,2:审批中;3:驳回;4:归档;5:删除"`
Idea string `json:"idea" gorm:"column:idea;type:longtext;comment:操作意见"`
Annex string `json:"annex" gorm:"column:annex;type:longtext;comment:附件"`
} }
func (OpenApprovalChangeLog *OpenApprovalChangeLog) TableName() string { func (OpenApprovalChangeLog *OpenApprovalChangeLog) TableName() string {

6
models/modelskpi/qualitative_evaluation.go

@ -41,6 +41,12 @@ func (QualitativeEvaluation *QualitativeEvaluation) TableName() string {
return "qualitative_evaluation" return "qualitative_evaluation"
} }
// 新增内容
func (cont *QualitativeEvaluation) AddCont() (err error) {
err = overall.CONSTANT_DB_KPI.Create(&cont).Error
return
}
// 编辑内容 // 编辑内容
func (cont *QualitativeEvaluation) EiteCont(whereMap interface{}, saveData interface{}) (err error) { func (cont *QualitativeEvaluation) EiteCont(whereMap interface{}, saveData interface{}) (err error) {
err = overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Updates(saveData).Error err = overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Updates(saveData).Error

95
models/modelskpi/qualitative_evaluation_view.go

@ -0,0 +1,95 @@
package modelskpi
import (
"key_performance_indicators/overall"
"strings"
"time"
)
type QualitativeEvaluationView struct {
Id int64 `json:"id" gorm:"primaryKey;column:qe_id;type:bigint(20) unsigned;not null;comment:Id;index"`
Title string `json:"title" gorm:"column:qe_title;type:text;comment:考核名称"`
DepartmentId string `json:"parentid" gorm:"column:qe_department_id;type:text;comment:执行考核部门ID"`
Dimension int64 `json:"dimension" gorm:"column:qe_dimension;type:bigint(20) unsigned;default:0;not null;comment:考核维度"`
Target int64 `json:"target" gorm:"column:qe_target;type:bigint(20) unsigned;default:0;not null;comment:考核指标"`
TargetSun int64 `json:"targetsun" gorm:"column:qe_target_sun;type:bigint(20) unsigned;default:0;not null;comment:考核指标子栏目"`
DetailedTarget int64 `json:"detailedtarget" gorm:"column:qe_detailed_target;type:bigint(20) unsigned;default:0;not null;comment:考核细则"`
Type int `json:"type" gorm:"column:qe_type;type:int(1) unsigned;default:1;not null;comment:1:定性考核;2:定量考核"`
Weight int64 `json:"weight" gorm:"column:qe_weight;type:int(5) unsigned;default:0;not null;comment:权重"`
Unit string `json:"unit" gorm:"column:qe_unit;type:varchar(255);comment:单位"`
ReferenceScore int64 `json:"referencescore" gorm:"column:qe_reference_score;type:int(9) unsigned;default:0;not null;comment:标准分值"`
State int `json:"state" gorm:"column:qe_state;type:int(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"`
Addtime int64 `json:"addtime" gorm:"column:qe_addtime;type:bigint(20) unsigned;default:0;not null;comment:添加时间"`
Eitetime int64 `json:"eitetime" gorm:"column:qe_eitetime;type:bigint(20) unsigned;default:0;not null;comment:编辑时间"`
Group int64 `json:"group" gorm:"column:qe_group;type:bigint(20) unsigned;default:0;not null;comment:归属集团"`
QualEvalId string `json:"qualevalid" gorm:"column:qe_qual_eval_id;type:varchar(200) unsigned;default:0;not null;comment:性质考核方案"`
Cycles int `json:"cycle" gorm:"column:qe_cycle;type:tinyint(1) unsigned;default:1;not null;comment:1:班;2:天;3:周;4:月;5:季度;6:年"`
CycleAttres int `json:"cycleattr" gorm:"column:qe_cycleattr;type:int(9) unsigned;default:1;not null;comment:辅助计数"`
AcceptEvaluation int64 `json:"acceptevaluation" gorm:"column:qe_accept_evaluation;type:bigint(20) unsigned;default:0;not null;comment:接受考核部门"`
Operator string `json:"operator" gorm:"column:qe_operator;type:text;comment:执行人"`
Content string `json:"content" gorm:"column:qe_content;type:text;comment:补充说明"`
MinScore int64 `json:"minscore" gorm:"column:qe_min_score;type:bigint(20) unsigned;default:0;not null;comment:最小分*100保存"`
MaxScore int64 `json:"maxscore" gorm:"column:qe_max_score;type:bigint(20) unsigned;default:0;not null;comment:最大分*100保存"`
CensorType string `json:"censortype" gorm:"column:qe_censor_type;type:tinyint(1) unsigned;default:1;not null;comment:检查方式"`
CensorCont string `json:"censorcont" gorm:"column:qe_censor_cont;type:longtext;comment:检查依据"`
CensorRate int `json:"censorrate" gorm:"column:qe_censor_rate;type:int(5) unsigned;default:1;not null;comment:检查频次"`
EtTitle string `json:"ettitle" gorm:"column:et_title;type:varchar(255);comment:指标名称"`
}
func (QualitativeEvaluationView *QualitativeEvaluationView) TableName() string {
return "qualitative_evaluation_view"
}
// 编辑内容
func (cont *QualitativeEvaluationView) EiteCont(whereMap interface{}, saveData interface{}) (err error) {
err = overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Updates(saveData).Error
return
}
// 获取内容
func (cont *QualitativeEvaluationView) GetCont(whereMap interface{}, field ...string) (err error) {
gormDb := overall.CONSTANT_DB_KPI.Model(&cont)
if len(field) > 0 {
fieldStr := strings.Join(field, ",")
gormDb = gormDb.Select(fieldStr)
}
gormDb = gormDb.Where(whereMap)
err = gormDb.First(&cont).Error
return
}
// 根据条件获取总数
func (cont *QualitativeEvaluationView) CountCont(whereMap interface{}) (countId int64) {
overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Count(&countId)
return
}
// 读取全部信息
func (cont *QualitativeEvaluationView) ContMap(whereMap interface{}, field ...string) (countAry []QualitativeEvaluationView, err error) {
gormDb := overall.CONSTANT_DB_KPI.Model(&cont)
if len(field) > 0 {
fieldStr := strings.Join(field, ",")
gormDb = gormDb.Select(fieldStr)
}
err = gormDb.Where(whereMap).Order("sort ASC").Find(&countAry).Error
return
}
// 删除内容
func (cont *QualitativeEvaluationView) DelCont(whereMap interface{}) (err error) {
err = overall.CONSTANT_DB_KPI.Where(whereMap).Delete(&cont).Error
return
}
// 判断子目标是否存在
func (cont *QualitativeEvaluationView) JudgeIsTrue(whereMap interface{}, addCont QualitativeEvaluationView) (err error) {
err = cont.GetCont(whereMap)
if err != nil {
err = overall.CONSTANT_DB_KPI.Create(&addCont).Error
} else {
if cont.State != 1 {
err = cont.EiteCont(map[string]interface{}{"`q_id`": cont.Id}, map[string]interface{}{"`q_state`": 1, "`q_time`": time.Now().Unix()})
}
}
return nil
}

12
models/modelskpi/register.go

@ -17,6 +17,12 @@ func (Register *Register) TableName() string {
return "register" return "register"
} }
// 添加
func (cont *Register) AddCont() (err error) {
err = overall.CONSTANT_DB_KPI.Create(&cont).Error
return
}
// 编辑内容 // 编辑内容
func (cont *Register) EiteCont(whereMap interface{}, saveData interface{}) (err error) { func (cont *Register) EiteCont(whereMap interface{}, saveData interface{}) (err error) {
err = overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Updates(saveData).Error err = overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Updates(saveData).Error
@ -57,9 +63,3 @@ func (cont *Register) DelCont(whereMap interface{}) (err error) {
err = overall.CONSTANT_DB_KPI.Where(whereMap).Delete(&cont).Error err = overall.CONSTANT_DB_KPI.Where(whereMap).Delete(&cont).Error
return return
} }
// 添加
func (cont *Register) AddCont() (err error) {
err = overall.CONSTANT_DB_KPI.Create(&cont).Error
return
}

11
models/modelskpi/work_flow.go

@ -7,11 +7,12 @@ import (
// 工作流 // 工作流
type WorkFlow struct { type WorkFlow struct {
Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id"` Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id"`
Name string `json:"name" gorm:"column:name;type:varchar(255) ;default:'';comment:维度"` Name string `json:"name" gorm:"column:name;type:varchar(255) ;default:'';comment:维度"`
Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:写入时间"` Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:写入时间"`
Describe string `json:"describe" gorm:"column:describe;type:longtext ;comment:描述"` Describe string `json:"describe" gorm:"column:describe;type:longtext ;comment:描述"`
State int `json:"state" gorm:"column:state;type:int(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` State int `json:"state" gorm:"column:state;type:int(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"`
OpenWechat int `json:"openwechat" gorm:"column:open_wechat;type:int(1) unsigned;default:1;not null;comment:是否开启企业微信通知及审批(1:无;2:开启通知;3:开启审批及通知)"`
} }
func (WorkFlow *WorkFlow) TableName() string { func (WorkFlow *WorkFlow) TableName() string {

1
models/modelskpi/work_flow_cont.go

@ -16,6 +16,7 @@ type WorkFlowCont struct {
VersionState int `json:"vstate" gorm:"column:vstate;type:int(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` VersionState int `json:"vstate" gorm:"column:vstate;type:int(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"`
Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:写入时间"` Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:写入时间"`
VersionId int64 `json:"vid" gorm:"column:vid;type:bigint(20) unsigned;not null;comment:Id"` //附表ID VersionId int64 `json:"vid" gorm:"column:vid;type:bigint(20) unsigned;not null;comment:Id"` //附表ID
OpenWechat int `json:"openwechat" gorm:"column:openwechat;type:int(1) unsigned;default:1;not null;comment:是否开启企业微信通知及审批(1:无;2:开启通知;3:开启审批及通知)"`
} }
func (WorkFlowCont *WorkFlowCont) TableName() string { func (WorkFlowCont *WorkFlowCont) TableName() string {

17
models/modelssystempermission/role_empower.go

@ -7,14 +7,15 @@ import (
// 权限配置 // 权限配置
type RoleEmpower struct { type RoleEmpower struct {
Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"`
RoleId int64 `json:"roleid" gorm:"column:role_id;type:bigint(20) unsigned;default:0;not null;comment:行政组织"` RoleId int64 `json:"roleid" gorm:"column:role_id;type:bigint(20) unsigned;default:0;not null;comment:行政组织"`
System string `json:"system" gorm:"column:system;type:varchar(255) ;comment:系统"` System string `json:"system" gorm:"column:system;type:varchar(255) ;comment:系统"`
PointId string `json:"pointid" gorm:"column:point_id;type:longtext;comment:权限点位"` PointId string `json:"pointid" gorm:"column:point_id;type:longtext;comment:权限点位"`
Operation string `json:"operation" gorm:"column:operation;type:longtext;comment:操作点位"` Operation string `json:"operation" gorm:"column:operation;type:longtext;comment:操作点位"`
State int `json:"state" gorm:"column:state;type:tinyint(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` State int `json:"state" gorm:"column:state;type:tinyint(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"`
Level int `json:"level" gorm:"column:level;type:int(1) unsigned;default:1;not null;comment:授权范围等级(1:本部门;2:本分部;3:所有)"` Level int `json:"level" gorm:"column:level;type:int(1) unsigned;default:1;not null;comment:授权范围等级(1:本部门;2:本分部;3:所有)"`
Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"`
Organization string `json:"organization" gorm:"column:organization;type:longtext;comment:行政组织列表"`
} }
func (RoleEmpower *RoleEmpower) TableName() string { func (RoleEmpower *RoleEmpower) TableName() string {

64
overall/publicmethod/formatOutput.go

@ -7,8 +7,10 @@ import (
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"key_performance_indicators/models/modelshr" "key_performance_indicators/models/modelshr"
"key_performance_indicators/models/modelssystempermission"
"key_performance_indicators/overall" "key_performance_indicators/overall"
"net/http" "net/http"
"strconv"
"strings" "strings"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
@ -78,7 +80,7 @@ func LoginMyCont(c *gin.Context) (myCont AuthenticationPower, err error) {
if exiPower == true { if exiPower == true {
jsonPowerCont, _ := json.Marshal(contextPower) jsonPowerCont, _ := json.Marshal(contextPower)
json.Unmarshal(jsonPowerCont, &powerInfo) json.Unmarshal(jsonPowerCont, &powerInfo)
fmt.Printf("LoginMyCont--------->%v--------->%v\n", powerInfo, string(jsonPowerCont)) // fmt.Printf("LoginMyCont--------->%v--------->%v\n", powerInfo, string(jsonPowerCont))
} }
PointIdList := strings.Split(powerInfo.PointId, ",") PointIdList := strings.Split(powerInfo.PointId, ",")
OrganizationList := strings.Split(powerInfo.Operation, ",") OrganizationList := strings.Split(powerInfo.Operation, ",")
@ -165,3 +167,63 @@ func CurlPostJosn(postUrl string, jsonData []byte) []byte {
body, _ := ioutil.ReadAll(resp.Body) body, _ := ioutil.ReadAll(resp.Body)
return body return body
} }
// 判断用户身份
func DetermineUserIdentity(userKey int64) (identity outShenFen) {
var userCont modelshr.PersonArchives
err := userCont.GetCont(map[string]interface{}{"`key`": userKey})
if err != nil {
identity.Level = 1
return
}
//角色权限范围判定
roleList := strings.Split(userCont.Role, ",")
var roleVerify modelssystempermission.RoleEmpower
overall.CONSTANT_DB_System_Permission.Where("`state` = 1 AND `system` = ? AND `id` IN ? ", "kpi", roleList).Find(&roleVerify)
//岗位权限范围判定
var postVerify modelssystempermission.Empower
postVerify.GetCont(map[string]interface{}{"`id`": userCont.Position, "`state`": 1, "`system`": "kpi"})
if roleVerify.Level >= postVerify.Level {
identity.Level = roleVerify.Level
} else {
identity.Level = postVerify.Level
}
switch identity.Level {
case 2:
identity.Level = 2
var sunOrg GetOrgAllParent
sunOrg.GetOrgSonAllId(userCont.MainDeparment)
identity.OrgList = sunOrg.Id
case 3:
identity.Level = 3
identity.Group = userCont.Company
case 4:
identity.Level = 4
if roleVerify.Organization != "" {
orgList := strings.Split(roleVerify.Organization, ",")
for _, v := range orgList {
orgIdInt, _ := strconv.ParseInt(v, 10, 64)
if !IsInTrue[int64](orgIdInt, identity.OrgList) {
identity.OrgList = append(identity.OrgList, orgIdInt)
}
}
}
if postVerify.Organization != "" {
orgListPost := strings.Split(postVerify.Organization, ",")
for _, pv := range orgListPost {
orgIdPostInt, _ := strconv.ParseInt(pv, 10, 64)
if !IsInTrue[int64](orgIdPostInt, identity.OrgList) {
identity.OrgList = append(identity.OrgList, orgIdPostInt)
}
}
}
case 5:
identity.Level = 5
identity.Group = 0
identity.OrgList = []int64{}
default:
identity.Level = 1
}
return
}

230
overall/publicmethod/technique.go

@ -139,6 +139,30 @@ func UnixTimeToDay(timeStamp int64, timeType int) (dateStr string) {
timeTemplate = "200601" timeTemplate = "200601"
case 22: case 22:
timeTemplate = "01-02" timeTemplate = "01-02"
case 23: //当前日期为本月第几周
monthFirstDayStr := DateToTimeStampOld(UnixTimeToDay(timeStamp, 10) + "-01 00:00:00") //获取指定月第一天时间戳
dayTime := time.Unix(monthFirstDayStr, 0)
dayOfWeek := int(dayTime.Weekday()) //获取本月第一天是周几
if dayOfWeek == 0 {
dayOfWeek = 7
}
dayNumber, dayNumberErr := strconv.ParseInt(UnixTimeToDay(timeStamp, 9), 10, 64) //获取今天是几号
if dayNumberErr != nil {
dayNumber = 1
}
daysAndWeeksDiff := dayNumber - (8 - int64(dayOfWeek))
if daysAndWeeksDiff <= 0 {
dateStr = "1"
} else {
daysAndWeeksDiffFlot, daysAndWeeksDiffFloatErr := strconv.ParseFloat(strconv.FormatInt(daysAndWeeksDiff, 10), 10)
if daysAndWeeksDiffFloatErr == nil {
daysWeeksDiffVal := math.Ceil(daysAndWeeksDiffFlot/7) + 1
dateStr = strconv.FormatFloat(daysWeeksDiffVal, 'f', -1, 64)
} else {
dateStr = "1"
}
}
default: default:
timeTemplate = "2006-01-02 15:04:05" //常规类型 timeTemplate = "2006-01-02 15:04:05" //常规类型
} }
@ -598,6 +622,7 @@ func RecursionOrgLeve(superior int64, leve int64) (groupId int64) {
if err != nil { if err != nil {
return return
} }
if orgMap.Level <= leve { if orgMap.Level <= leve {
groupId = orgMap.Id groupId = orgMap.Id
return return
@ -1732,7 +1757,9 @@ func (d *DateTimeTotimes) BaisStrToTime(dateTime string) {
if orgTimeErr { if orgTimeErr {
d.AllTime = orgTime d.AllTime = orgTime
d.Years = UnixTimeToDay(orgTime, 16) d.Years = UnixTimeToDay(orgTime, 16)
d.Quarter = UnixTimeToDay(orgTime, 19)
d.Months = UnixTimeToDay(orgTime, 17) d.Months = UnixTimeToDay(orgTime, 17)
d.Week = UnixTimeToDay(orgTime, 23)
d.Days = UnixTimeToDay(orgTime, 18) d.Days = UnixTimeToDay(orgTime, 18)
d.Hours = UnixTimeToDay(orgTime, 7) d.Hours = UnixTimeToDay(orgTime, 7)
d.Minutes = UnixTimeToDay(orgTime, 9) d.Minutes = UnixTimeToDay(orgTime, 9)
@ -1743,7 +1770,9 @@ func (d *DateTimeTotimes) BaisStrToTime(dateTime string) {
if orgTimeErr { if orgTimeErr {
d.AllTime = orgTime d.AllTime = orgTime
d.Years = UnixTimeToDay(orgTime, 16) d.Years = UnixTimeToDay(orgTime, 16)
d.Quarter = UnixTimeToDay(orgTime, 19)
d.Months = UnixTimeToDay(orgTime, 17) d.Months = UnixTimeToDay(orgTime, 17)
d.Week = UnixTimeToDay(orgTime, 23)
d.Days = UnixTimeToDay(orgTime, 18) d.Days = UnixTimeToDay(orgTime, 18)
d.Hours = UnixTimeToDay(orgTime, 7) d.Hours = UnixTimeToDay(orgTime, 7)
d.Minutes = UnixTimeToDay(orgTime, 9) d.Minutes = UnixTimeToDay(orgTime, 9)
@ -1753,7 +1782,9 @@ func (d *DateTimeTotimes) BaisStrToTime(dateTime string) {
if orgTimeErr { if orgTimeErr {
d.AllTime = orgTime d.AllTime = orgTime
d.Years = UnixTimeToDay(orgTime, 16) d.Years = UnixTimeToDay(orgTime, 16)
d.Quarter = UnixTimeToDay(orgTime, 19)
d.Months = UnixTimeToDay(orgTime, 17) d.Months = UnixTimeToDay(orgTime, 17)
d.Week = UnixTimeToDay(orgTime, 23)
d.Days = UnixTimeToDay(orgTime, 18) d.Days = UnixTimeToDay(orgTime, 18)
d.Hours = UnixTimeToDay(orgTime, 7) d.Hours = UnixTimeToDay(orgTime, 7)
d.Minutes = UnixTimeToDay(orgTime, 9) d.Minutes = UnixTimeToDay(orgTime, 9)
@ -1763,7 +1794,9 @@ func (d *DateTimeTotimes) BaisStrToTime(dateTime string) {
if orgTimeErr { if orgTimeErr {
d.AllTime = orgTime d.AllTime = orgTime
d.Years = UnixTimeToDay(orgTime, 16) d.Years = UnixTimeToDay(orgTime, 16)
d.Quarter = UnixTimeToDay(orgTime, 19)
d.Months = UnixTimeToDay(orgTime, 17) d.Months = UnixTimeToDay(orgTime, 17)
d.Week = UnixTimeToDay(orgTime, 23)
d.Days = UnixTimeToDay(orgTime, 18) d.Days = UnixTimeToDay(orgTime, 18)
d.Hours = UnixTimeToDay(orgTime, 7) d.Hours = UnixTimeToDay(orgTime, 7)
d.Minutes = UnixTimeToDay(orgTime, 9) d.Minutes = UnixTimeToDay(orgTime, 9)
@ -1773,7 +1806,9 @@ func (d *DateTimeTotimes) BaisStrToTime(dateTime string) {
if orgTimeErr { if orgTimeErr {
d.AllTime = orgTime d.AllTime = orgTime
d.Years = UnixTimeToDay(orgTime, 16) d.Years = UnixTimeToDay(orgTime, 16)
d.Quarter = UnixTimeToDay(orgTime, 19)
d.Months = UnixTimeToDay(orgTime, 17) d.Months = UnixTimeToDay(orgTime, 17)
d.Week = UnixTimeToDay(orgTime, 23)
d.Days = UnixTimeToDay(orgTime, 18) d.Days = UnixTimeToDay(orgTime, 18)
d.Hours = UnixTimeToDay(orgTime, 7) d.Hours = UnixTimeToDay(orgTime, 7)
d.Minutes = UnixTimeToDay(orgTime, 9) d.Minutes = UnixTimeToDay(orgTime, 9)
@ -1783,7 +1818,9 @@ func (d *DateTimeTotimes) BaisStrToTime(dateTime string) {
if orgTimeErr { if orgTimeErr {
d.AllTime = orgTime d.AllTime = orgTime
d.Years = UnixTimeToDay(orgTime, 16) d.Years = UnixTimeToDay(orgTime, 16)
d.Quarter = UnixTimeToDay(orgTime, 19)
d.Months = UnixTimeToDay(orgTime, 17) d.Months = UnixTimeToDay(orgTime, 17)
d.Week = UnixTimeToDay(orgTime, 23)
d.Days = UnixTimeToDay(orgTime, 18) d.Days = UnixTimeToDay(orgTime, 18)
d.Hours = UnixTimeToDay(orgTime, 7) d.Hours = UnixTimeToDay(orgTime, 7)
d.Minutes = UnixTimeToDay(orgTime, 9) d.Minutes = UnixTimeToDay(orgTime, 9)
@ -1863,27 +1900,190 @@ func (g *GetOrgAllParent) GetOrgParentAllId(orgId int64) {
// 获取所有下级 // 获取所有下级
func (g *GetOrgAllParent) GetOrgSonAllId(orgId int64) { func (g *GetOrgAllParent) GetOrgSonAllId(orgId int64) {
var orgAry []int64 var orgAry []int64
err := overall.CONSTANT_DB_HR.Model(&modelshr.AdministrativeOrganization{}).Select("`id`").Where("`state` = 1 AND `superior` = ?", orgId).Find(&orgAry).Error if orgId != 0 {
if err != nil { err := overall.CONSTANT_DB_HR.Model(&modelshr.AdministrativeOrganization{}).Select("`id`").Where("`state` = 1 AND `superior` = ?", orgId).Find(&orgAry).Error
return if err != nil {
} return
for _, v := range orgAry { }
if IsInTrue[int64](v, g.Id) == false { for _, v := range orgAry {
g.Id = append(g.Id, v) if !IsInTrue[int64](v, g.Id) {
g.GetOrgSonAllId(v) g.Id = append(g.Id, v)
} else { g.GetOrgSonAllId(v)
g.GetOrgSonAllId(v) } else {
g.GetOrgSonAllId(v)
}
} }
} }
} }
// 获取行政组织所有上级和下级 // 获取行政组织所有上级和下级
func HaveAllOrgRelation(orgId int64) []int64 { func HaveAllOrgRelation(orgId int64) []int64 {
departmentId := RecursionOrgLeve(orgId, 4) // departmentId := RecursionOrgLeve(orgId, 4)
// fmt.Printf("获取行政组--->%v--->%v\n", departmentId, orgId)
var getAllOrg GetOrgAllParent var getAllOrg GetOrgAllParent
getAllOrg.GetOrgParentAllId(departmentId) // getAllOrg.GetOrgParentAllId(departmentId)
getAllOrg.GetOrgSonAllId(departmentId) // getAllOrg.GetOrgSonAllId(departmentId)
getAllOrg.Id = append(getAllOrg.Id, orgId)
// getAllOrg.GetOrgSonAllId(orgId) getAllOrg.GetOrgParent(orgId, 4)
// fmt.Printf("获取行政组--2222->%v--->%v\n", getAllOrg.Id, orgId)
return getAllOrg.Id return getAllOrg.Id
} }
// 获取上下级
func (g *GetOrgAllParent) GetOrgParent(orgId, level int64) {
if orgId != 0 {
var orgCont modelshr.OrgContType
err := orgCont.GetCont(map[string]interface{}{"`id`": orgId, "`state`": 1}, "`superior`", "level")
if err == nil {
// fmt.Printf("获取行政组--2222->%v--->%v\n", orgCont.Level, level)
if orgCont.Level >= level {
g.GetOrgSonAllId(orgId)
g.GetOrgParent(orgCont.Superior, level)
}
}
}
}
//计算得分
/*
参数
@targetScore 指标分值
@resultval 结算值
@allPrizes 全奖值
@zeroPrizes 零奖值
@CappingVals 封顶值
@typeClass 1:定性2定量;3:观察指标
返回说明
@scoreVal 计算得分
@allPrize 全奖值
@zeroPrize 零奖值
@CappingVal 封顶值
@achievement 达成率
*/
func CalculateScore(targetScore int64, resultval, allPrizes, zeroPrizes, CappingVals float64, typeClass int) (scoreVal, allPrize, zeroPrize, CappingVal, achievement float64) {
allPrize = allPrizes / 100
zeroPrize = zeroPrizes / 100
CappingVal = CappingVals / 100
resultval = resultval / 100
//fmt.Printf("达成率--1-->targetScore:%v-->resultval:%v-->allPrize:%v-->zeroPrize:%v-->CappingVal:%v\n", targetScore, resultval, allPrize, zeroPrize, CappingVal)
//不修正精度的达成率
var achievementAll float64 = 0
if allPrize == 0 && zeroPrize == 0 { //全奖值与零奖值都为0 那么达成率 100 和实际得分是 指标分
achievement = 100
scoreVal = float64(targetScore)
if typeClass == 2 {
if resultval <= 0 {
scoreVal = 0
}
}
achievementAll = 100
//fmt.Printf("达成率--11-->%v-->%v-->%v-->%v-->%v-->%v-->%v\n", targetScore, resultval, scoreVal, allPrize, zeroPrize, CappingVal, achievement)
} else {
if allPrize > zeroPrize { //如果全奖值大于零奖值 执行一下操作
if resultval <= zeroPrize { //实际结算值小于零奖值 那么达成率和实际得分都是0
achievement = 0
scoreVal = 0
achievementAll = 0
// } else if resultval > allPrize { //实际结算值大于全奖值 执行一下操作
//fmt.Printf("达成率--7-->%v-->%v-->%v-->%v-->%v-->%v-->%v\n", targetScore, resultval, scoreVal, allPrize, zeroPrize, CappingVal, achievement)
} else { //实际结算值在全奖值 与 零奖值之间
chuShu := resultval - float64(zeroPrize)
beiChuShu := float64(allPrize) - float64(zeroPrize)
if beiChuShu != 0 {
achievement = DecimalEs(chuShu/beiChuShu, 4)
achievementAll = chuShu / beiChuShu
if achievement <= 0 {
//如果在全奖值大于零件值的情况下出现达成率为0或负数,则达成率和实际得分都是0
achievement = 0
scoreVal = 0
achievementAll = 0
//fmt.Printf("达成率--8-->%v-->%v-->%v-->%v-->%v-->%v-->%v\n", targetScore, resultval, scoreVal, allPrize, zeroPrize, CappingVal, achievement)
} else {
//fmt.Printf("达成率--9-1->targetScore:%v-->resultval:%v-->scoreVal:%v-->allPrize:%v-->zeroPrize:%v-->CappingVal:%v-->achievement:%v\n", targetScore, resultval, scoreVal, allPrize, zeroPrize, CappingVal, achievement)
if achievement*100 >= CappingVal {
//如果达成率大于等于封顶值
if CappingVal > 0 {
scoreVal = (CappingVal / 100) * float64(targetScore)
//fmt.Printf("达成率--9-2->targetScore:%v-->resultval:%v-->scoreVal:%v-->allPrize:%v-->zeroPrize:%v-->CappingVal:%v-->achievement:%v\n", targetScore, resultval, scoreVal, allPrize, zeroPrize, CappingVal, achievement)
} else {
//fmt.Printf("达成率--9-3->targetScore:%v-->resultval:%v-->scoreVal:%v-->allPrize:%v-->zeroPrize:%v-->CappingVal:%v-->achievement:%v\n", targetScore, resultval, scoreVal, allPrize, zeroPrize, CappingVal, achievement)
scoreVal = float64(targetScore)
}
} else {
// scoreVal = achievement * (float64(targetScore))
scoreVal = achievementAll * (float64(targetScore))
//fmt.Printf("达成率--9-4->targetScore:%v-->resultval:%v-->scoreVal:%v-->allPrize:%v-->zeroPrize:%v-->CappingVal:%v-->achievement:%v\n", targetScore, resultval, scoreVal, allPrize, zeroPrize, CappingVal, achievement)
}
//fmt.Printf("达成率--9-->targetScore:%v-->resultval:%v-->scoreVal:%v-->allPrize:%v-->zeroPrize:%v-->CappingVal:%v-->achievement:%v\n", targetScore, resultval, scoreVal, allPrize, zeroPrize, CappingVal, achievement)
}
achievement = DecimalEs(achievement*100, 4)
} else {
//被除数为0时 那么达成率和实际得分都是0
achievement = 0
scoreVal = 0
achievementAll = 0
//fmt.Printf("达成率--10-->%v-->%v-->%v-->%v-->%v-->%v-->%v\n", targetScore, resultval, scoreVal, allPrize, zeroPrize, CappingVal, achievement)
}
}
} else { //如果全奖值小于零奖值 执行一下操作
if resultval >= zeroPrize { //实际结算值大于零奖值 那么达成率和实际得分都是0
achievement = 0
scoreVal = 0
achievementAll = 0
//fmt.Printf("达成率--1-->%v-->%v-->%v-->%v-->%v-->%v-->%v\n", targetScore, resultval, scoreVal, allPrize, zeroPrize, CappingVal, achievement)
} else {
chuShu := resultval - float64(zeroPrize)
beiChuShu := float64(allPrize) - float64(zeroPrize)
if beiChuShu != 0 {
achievement = DecimalEs(chuShu/beiChuShu, 4)
achievementAll = chuShu / beiChuShu
if achievement <= 0 {
//如果在全奖值大于零件值的情况下出现达成率为0或负数,则达成率和实际得分都是0
achievement = 0
scoreVal = 0
achievementAll = 0
//fmt.Printf("达成率--2-->%v-->%v-->%v-->%v-->%v-->%v-->%v\n", targetScore, resultval, scoreVal, allPrize, zeroPrize, CappingVal, achievement)
} else {
if achievement*100 >= CappingVal {
//如果达成率大于等于封顶值
scoreVal = CappingVal * float64(targetScore) / 100
//fmt.Printf("达成率--3-->%v-->%v-->%v-->%v-->%v-->%v-->%v\n", targetScore, resultval, scoreVal, allPrize, zeroPrize, CappingVal, achievement)
} else {
// scoreVal = achievement * (float64(targetScore))
scoreVal = achievementAll * (float64(targetScore))
//fmt.Printf("达成率--4-->%v-->%v-->%v-->%v-->%v-->%v-->%v\n", targetScore, resultval, scoreVal, allPrize, zeroPrize, CappingVal, achievement)
}
}
achievement = DecimalEs(achievement*100, 4)
//fmt.Printf("达成率--6-->%v-->%v-->%v-->%v-->%v-->%v-->%v\n", targetScore, resultval, scoreVal, allPrize, zeroPrize, CappingVal, achievement)
} else {
//被除数为0时 那么达成率和实际得分都是0
achievement = 0
scoreVal = 0
achievementAll = 0
//fmt.Printf("达成率--5-->%v-->%v-->%v-->%v-->%v-->%v-->%v\n", targetScore, resultval, scoreVal, allPrize, zeroPrize, CappingVal, achievement)
}
}
}
}
if typeClass == 3 {
scoreVal = float64(targetScore)
//fmt.Printf("达成率--11-->%v-->%v-->%v-->%v-->%v-->%v-->%v\n", targetScore, resultval, scoreVal, allPrize, zeroPrize, CappingVal, achievement)
}
scoreVal = DecimalEs(scoreVal, 2)
allPrize = DecimalEs(allPrize, 2)
zeroPrize = DecimalEs(zeroPrize, 2)
CappingVal = DecimalEs(CappingVal, 2)
achievement = DecimalEs(achievement, 4)
//fmt.Printf("达成率--12-->%v-->%v-->%v-->%v-->%v-->%v-->%v\n", targetScore, resultval, scoreVal, allPrize, zeroPrize, CappingVal, achievement)
return
}

9
overall/publicmethod/type.go

@ -262,7 +262,9 @@ type EvaluPross struct {
// 时间转换 // 时间转换
type DateTimeTotimes struct { type DateTimeTotimes struct {
Years string `json:"years"` Years string `json:"years"`
Quarter string `json:"quarter"`
Months string `json:"months"` Months string `json:"months"`
Week string `json:"week"`
Days string `json:"days"` Days string `json:"days"`
Hours string `json:"hours"` Hours string `json:"hours"`
Minutes string `json:"minutes"` Minutes string `json:"minutes"`
@ -274,3 +276,10 @@ type DateTimeTotimes struct {
type GetOrgAllParent struct { type GetOrgAllParent struct {
Id []int64 `json:"id"` Id []int64 `json:"id"`
} }
// 输出判定身份
type outShenFen struct {
Level int
Group int64
OrgList []int64
}

Loading…
Cancel
Save