You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
716 lines
24 KiB
716 lines
24 KiB
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()
|
|
}
|
|
|