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.
936 lines
33 KiB
936 lines
33 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, 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, userIdentity.OrgList)
|
|
default:
|
|
}
|
|
fmt.Printf("userIdentity------------>%v\n", userIdentity)
|
|
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、定量"`
|
|
sendCont.NextStep = evalProCont.NextStep
|
|
if evalProCont.Creater != 0 {
|
|
var creaCont modelshr.PersonArchives
|
|
creaCont.GetCont(map[string]interface{}{"`key`": evalProCont.Creater}, "`name`")
|
|
sendCont.CreaterName = creaCont.Name
|
|
}
|
|
sendCont.DepartmentId = evalProCont.AcceptDepartment
|
|
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
|
|
nextRunType := 1
|
|
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)
|
|
// sendCont.RunType = nextNodeCont.Type
|
|
nextRunType = nextNodeCont.Type
|
|
//获取登录人信息
|
|
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,sf_enclosure").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
|
|
if v.Enclosure != "" {
|
|
json.Unmarshal([]byte(v.Enclosure), &dingXingCong.Enclosure)
|
|
}
|
|
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)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//获取责任划分
|
|
var dutyListCont []modelskpi.DivisionResponsibilities
|
|
err = overall.CONSTANT_DB_KPI.Model(&modelskpi.DivisionResponsibilities{}).Select("df_type,df_user_name,df_user_key,df_weight,df_user_number").Where("df_sf_id = ?", evalProCont.OrderKey).Find(&dutyListCont).Error
|
|
if err == nil && len(dutyListCont) > 0 {
|
|
sendCont.DivisionIsShow = 1
|
|
for _, dlv := range dutyListCont {
|
|
var dutyCont DivisionListCont
|
|
dutyCont.Type = dlv.Type //类型
|
|
dutyCont.UserName = dlv.UserName //姓名
|
|
dutyCont.UserNumber = dlv.UserNumber //工号
|
|
dutyCont.UserKey = strconv.FormatInt(dlv.UserKey, 10) //识别码
|
|
dutyCont.Weight = publicmethod.DecimalEs(float64(dlv.Weight)/100, 2) //权重
|
|
sendCont.DivisionList = append(sendCont.DivisionList, dutyCont)
|
|
}
|
|
}
|
|
|
|
if sendCont.Actionable == 1 {
|
|
if sendCont.SetExecutor == 1 {
|
|
sendCont.DivisionIsShow = 1
|
|
sendCont.DivisLoofOfEdit = 1
|
|
} else {
|
|
sendCont.DivisLoofOfEdit = 2
|
|
}
|
|
if nextRunType == 3 {
|
|
sendCont.RunType = 1
|
|
} else {
|
|
sendCont.RunType = 2
|
|
}
|
|
|
|
} else {
|
|
sendCont.DivisLoofOfEdit = 2
|
|
sendCont.RunType = 2
|
|
}
|
|
// fmt.Printf("nextRunType------>%v\n", nextRunType)
|
|
//获取整改措施
|
|
var measureList []modelskpi.RectificationMeasures
|
|
err = overall.CONSTANT_DB_KPI.Model(&modelskpi.RectificationMeasures{}).Select("rm_user_key,rm_state,rm_time,rm_content,rm_files").Where("depart_post = 1 AND rm_order = ?", evalProCont.OrderKey).Find(&measureList).Error
|
|
if err == nil && len(measureList) > 0 {
|
|
sendCont.MeasureIsShow = 1
|
|
for _, mlv := range measureList {
|
|
var measUser modelshr.PersonArchives
|
|
measUser.GetCont(map[string]interface{}{"`key`": mlv.UserKey}, "`name`", "`number`", "`admin_org`")
|
|
var measCont MeasureCont
|
|
measCont.UserName = measUser.Name //姓名
|
|
measCont.UserNumber = measUser.Number //工号
|
|
measCont.UserKey = strconv.FormatInt(mlv.UserKey, 10) //识别符
|
|
var orgCont modelshr.AdministrativeOrganization
|
|
orgCont.GetCont(map[string]interface{}{"`id`": measUser.AdminOrg}, "`name`")
|
|
measCont.OrgNAme = orgCont.Name //行政组织
|
|
measCont.Cause = mlv.Content //整改内容
|
|
if mlv.Enclosure != "" {
|
|
hjsdj := json.Unmarshal([]byte(mlv.Enclosure), &measCont.Enclosure)
|
|
fmt.Printf("hjsdj----------->%+v\n", hjsdj)
|
|
}
|
|
measCont.Time = publicmethod.UnixTimeToDay(mlv.Time, 1) //整改内容
|
|
sendCont.MeasureList = append(sendCont.MeasureList, measCont)
|
|
}
|
|
|
|
} else {
|
|
if sendCont.RunType == 1 {
|
|
sendCont.MeasureIsShow = 1
|
|
}
|
|
}
|
|
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.NextStep != receivedValue.Step {
|
|
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
|
|
|
|
//判断是否需要写入责任人
|
|
if receivedValue.SetExecutor == 1 {
|
|
if len(receivedValue.ExecutorList) > 0 {
|
|
//责任划分
|
|
var addDivisRespon []modelskpi.DivisionResponsibilities
|
|
for _, elv := range receivedValue.ExecutorList {
|
|
var userInfo modelshr.PersonArchives
|
|
userInfo.GetCont(map[string]interface{}{"key": elv.UserKey})
|
|
if elv.Type == 1 {
|
|
|
|
runWorkflow.DesignatedOperator.UserList = append(runWorkflow.DesignatedOperator.UserList, currency_recipe.SetOperator(userInfo))
|
|
}
|
|
var addDivCont modelskpi.DivisionResponsibilities
|
|
addDivCont.ScoreFlow = evalProCont.OrderKey //归属加减分关联值"`
|
|
addDivCont.Type = elv.Type //责任类型(1、主要责任人;2、互保责任人;3、责任班组;4、责任班组长;5、主管;6、三大员;7、厂长、主任)"`
|
|
addDivCont.UserName = userInfo.Name //责任人名"`
|
|
addDivCont.UserNumber = userInfo.Number //责任人工号"`
|
|
addDivCont.UserKey = userInfo.Key //责任人KEY"`
|
|
addDivCont.Department = userInfo.AdminOrg //责任人部门"`
|
|
addDivCont.Group = userInfo.Company //责任人集团"`
|
|
addDivCont.Tema = userInfo.TeamId //责任人班组"`
|
|
weightFloat64, _ := strconv.ParseFloat(elv.Weight, 64)
|
|
weightInt64, _ := strconv.ParseInt(strconv.FormatFloat(weightFloat64*100, 'f', -1, 64), 10, 64)
|
|
addDivCont.Weight = weightInt64 //比重"`*100
|
|
addDivCont.Time = time.Now().Unix() //创建时间"`
|
|
addDivCont.EiteTime = time.Now().Unix() //修改时间"`
|
|
addDivCont.DistributionUser = publicmethod.GetUUid(8) //分配任key"`
|
|
addDivCont.EvaluationDepartment = myLoginCont.MainDeparment //测评部门"`
|
|
addDivCont.EvaluationUser = myLoginCont.Key //测评人"`
|
|
addDivCont.EvaluationGroup = myLoginCont.Company //测评集团"`
|
|
addDivisRespon = append(addDivisRespon, addDivCont)
|
|
}
|
|
if len(runWorkflow.DesignatedOperator.UserList) > 0 {
|
|
runWorkflow.DesignatedOperator.IsTrue = true
|
|
} else {
|
|
runWorkflow.DesignatedOperator.IsTrue = false
|
|
}
|
|
if len(addDivisRespon) > 0 {
|
|
var delDivCont modelskpi.DivisionResponsibilities
|
|
delDivCont.DelCont(map[string]interface{}{"df_sf_id": evalProCont.OrderKey})
|
|
overall.CONSTANT_DB_KPI.Create(&addDivisRespon)
|
|
}
|
|
} else {
|
|
publicmethod.Result(1, err, c, "未划分责任人!请先划分责任人!")
|
|
return
|
|
}
|
|
}
|
|
//提交整改意见
|
|
if receivedValue.CorrectiveAction.IsTrue == 1 {
|
|
if receivedValue.CorrectiveAction.Content == "" {
|
|
publicmethod.Result(1, err, c, "请输入整改意见!")
|
|
return
|
|
} else {
|
|
runWorkflow.CorrectiveAction.IsTrue = 1
|
|
runWorkflow.CorrectiveAction.Content = receivedValue.CorrectiveAction.Content
|
|
var fileListCont []currency_recipe.EnclosureFormat
|
|
if len(receivedValue.CorrectiveAction.Enclosure) > 0 {
|
|
for _, ev := range receivedValue.CorrectiveAction.Enclosure {
|
|
var fileCont currency_recipe.EnclosureFormat
|
|
fileCont.FileName = ev.Name //附件名称
|
|
fileCont.FilePath = ev.FileUrl //附件地址
|
|
fileCont.Type = ev.Type //附件类型
|
|
fmt.Printf("副将---->%v\n---->%v\n", fileCont, ev)
|
|
runWorkflow.CorrectiveAction.Annex = append(runWorkflow.CorrectiveAction.Annex, fileCont)
|
|
fileListCont = append(fileListCont, fileCont)
|
|
}
|
|
}
|
|
var userInfo modelshr.PersonArchives
|
|
userInfo.GetCont(map[string]interface{}{"key": myLoginCont.Key})
|
|
var writeRectMeas modelskpi.RectificationMeasures
|
|
writeRectMeas.UserKey = userInfo.Key //整改人"`
|
|
writeRectMeas.Department = userInfo.AdminOrg //整改部门"`
|
|
writeRectMeas.Group = userInfo.Company //集团"`
|
|
writeRectMeas.OrderKey = evalProCont.OrderKey //订单ID"`
|
|
writeRectMeas.State = 2 //1:草果;2:审批中;3:不合格;4:合格"`
|
|
writeRectMeas.Time = time.Now().Unix() //创建时间"`
|
|
writeRectMeas.EiteTime = time.Now().Unix() //修改时间"`
|
|
writeRectMeas.Content = receivedValue.CorrectiveAction.Content //整改内容"`
|
|
|
|
if len(fileListCont) > 0 {
|
|
fileJson, _ := json.Marshal(fileListCont)
|
|
writeRectMeas.Enclosure = string(fileJson) //附件"`
|
|
}
|
|
writeRectMeas.DepartPost = 1 //1、部门;2:岗位"`
|
|
fmt.Printf("附件---->%v\n---->%v\n", fileListCont, writeRectMeas)
|
|
writeRectMeas.AddCont()
|
|
}
|
|
}
|
|
|
|
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"] = ""
|
|
}
|
|
replyState := receivedValue.YesOrNo
|
|
if receivedValue.YesOrNo == 2 {
|
|
if runWorkflow.NextStep == 0 {
|
|
editWorkflow["ep_state"] = 4
|
|
replyState = 4
|
|
} else {
|
|
editWorkflow["ep_state"] = 2
|
|
replyState = 2
|
|
}
|
|
} else {
|
|
editWorkflow["ep_state"] = receivedValue.YesOrNo
|
|
replyState = receivedValue.YesOrNo
|
|
}
|
|
if runWorkflow.NextStep == 0 {
|
|
editWorkflow["ep_step"] = len(runWorkflow.List)
|
|
} else {
|
|
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
|
|
}
|
|
if evalProCont.TypeClass == 1 {
|
|
//定性
|
|
scoFlwWhe := publicmethod.MapOut[string]()
|
|
scoFlwWhe["sf_key"] = evalProCont.OrderKey
|
|
var seeScoreFlowCont modelskpi.ScoreFlow
|
|
scoErr := seeScoreFlowCont.GetCont(scoFlwWhe, "sf_id")
|
|
if scoErr == nil {
|
|
seeScoreFlowCont.EiteCont(scoFlwWhe, map[string]interface{}{"sf_reply": replyState})
|
|
}
|
|
} else {
|
|
flwWhe := publicmethod.MapOut[string]()
|
|
flwWhe["fl_key"] = evalProCont.OrderKey
|
|
//定量
|
|
var flowLogInfo modelskpi.FlowLog
|
|
flwErr := flowLogInfo.GetCont(flwWhe, "fl_id")
|
|
if flwErr == nil {
|
|
flowLogInfo.EiteCont(flwWhe, map[string]interface{}{"fl_reply": replyState})
|
|
}
|
|
}
|
|
|
|
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.AddNodeOperator(v.NodeNumber)
|
|
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 {
|
|
for ui, _ := range v.UserList {
|
|
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.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)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
func (w *WorkFlowRuning) AddNodeOperator(nodeNumber string) {
|
|
if w.DesignatedOperator.IsTrue {
|
|
for i, v := range w.List {
|
|
if v.CustomNode == nodeNumber {
|
|
w.List[i].UserList = w.DesignatedOperator.UserList
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 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
|
|
stepVal := nv.Step - 1
|
|
if stepVal < 1 {
|
|
w.Step = 1
|
|
} else {
|
|
w.Step = stepVal
|
|
}
|
|
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 = 2 //状态 1、未操作;2、通过;3、驳回
|
|
userCarrLog.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()
|
|
}
|
|
|