16 changed files with 801 additions and 22 deletions
@ -0,0 +1,326 @@ |
|||
package departmentpc |
|||
|
|||
import ( |
|||
"encoding/json" |
|||
"fmt" |
|||
"key_performance_indicators/api/version1/postseting/postweb" |
|||
"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-01-15 09:42:53 |
|||
@ 功能: 获取定量考核任务列表 |
|||
@ 参数 |
|||
|
|||
# |
|||
|
|||
@ 返回值 |
|||
|
|||
# |
|||
|
|||
@ 方法原型 |
|||
|
|||
# |
|||
*/ |
|||
func (a *ApiMethod) GetQuantitativeTasks(c *gin.Context) { |
|||
//获取登录人信息
|
|||
myLoginCont, _ := publicmethod.LoginMyCont(c) |
|||
//获取参数
|
|||
var receivedValue GetQuanTasks |
|||
c.ShouldBindJSON(&receivedValue) |
|||
var listCont []modelskpi.QualitativeEvaluation |
|||
gormDb := overall.CONSTANT_DB_KPI.Where("`qe_type` = 2 AND `qe_state` = 1 AND FIND_IN_SET(?,`qe_operator`)", myLoginCont.Key) |
|||
if receivedValue.OrgId != "" { |
|||
gormDb = gormDb.Where("qe_accept_evaluation = ?", receivedValue.OrgId) |
|||
} |
|||
if receivedValue.Title != "" { |
|||
gormDb = gormDb.Where("et_title LIKE ?", "%"+receivedValue.Title+"%") |
|||
} |
|||
err := gormDb.Order("qe_type ASC,qe_group ASC,qe_accept_evaluation ASC,qe_dimension ASC,qe_target ASC,qe_target_sun ASC,qe_detailed_target ASC").Find(&listCont).Error |
|||
if err != nil || len(listCont) < 1 { |
|||
publicmethod.Result(1, err, c, "您没有要参加的考核项目!") |
|||
return |
|||
} |
|||
var sendListCont []TargetContOutCont |
|||
for _, v := range listCont { |
|||
var sendCont TargetContOutCont |
|||
sendCont.Id = strconv.FormatInt(v.Id, 10) |
|||
sendCont.Type = v.Type |
|||
sendCont.Group = strconv.FormatInt(v.Group, 10) |
|||
//公司
|
|||
var groupCont modelshr.AdministrativeOrganization |
|||
groupCont.GetCont(map[string]interface{}{"`id`": v.Group}, "`name`") |
|||
sendCont.GroupNAme = groupCont.Name |
|||
//部门
|
|||
var departCont modelshr.AdministrativeOrganization |
|||
departCont.GetCont(map[string]interface{}{"`id`": v.AcceptEvaluation}, "`name`") |
|||
sendCont.DepartmentName = departCont.Name |
|||
sendCont.DepartmentId = strconv.FormatInt(v.AcceptEvaluation, 10) |
|||
sendCont.PlanVersionNumber = v.QualEvalId //执行方案版本号
|
|||
//维度相关信息
|
|||
sendCont.Dimension = strconv.FormatInt(v.Dimension, 10) |
|||
var dimeCont modelskpi.DutyClass |
|||
dimeCont.GetCont(map[string]interface{}{"`id`": v.Dimension}, "`title`") |
|||
sendCont.DimensionName = dimeCont.Title |
|||
//指标信息
|
|||
sendCont.Target = strconv.FormatInt(v.Target, 10) |
|||
var targetCont modelskpi.EvaluationTarget |
|||
targetCont.GetCont(map[string]interface{}{"`et_id`": v.Target}, "`et_title`", "`et_scoring_method`") |
|||
sendCont.TargetName = targetCont.Title |
|||
//子栏目
|
|||
sendCont.ScoringMethod = int64(targetCont.ScoringMethod) |
|||
if v.TargetSun != 0 { |
|||
sendCont.TargetSun = strconv.FormatInt(v.TargetSun, 10) |
|||
var sunTargetCont modelskpi.QualitativeTarget |
|||
sunTargetCont.GetCont(map[string]interface{}{"`q_id`": v.Target}, "`q_title`") |
|||
sendCont.TargetSunName = sunTargetCont.Title |
|||
} |
|||
//指标细则
|
|||
if v.DetailedTarget != 0 { |
|||
sendCont.DetailedTarget = strconv.FormatInt(v.DetailedTarget, 10) |
|||
var detailedTargetCont modelskpi.DetailedTarget |
|||
detailedTargetCont.GetCont(map[string]interface{}{"`dt_id`": v.Target}, "`dt_title`", "`dt_content`") |
|||
sendCont.DetailedTargetName = detailedTargetCont.Title |
|||
sendCont.Content = detailedTargetCont.Content |
|||
} |
|||
sendCont.Unit = v.Unit |
|||
sendCont.ReferenceScore = v.ReferenceScore |
|||
sendCont.Cycles = v.Cycles |
|||
sendCont.CycleAttres = v.CycleAttres |
|||
sendCont.State = v.State |
|||
userAry := strings.Split(v.Operator, ",") |
|||
sendCont.UserList = userAry |
|||
for _, u_v := range userAry { |
|||
var repoCont modelshr.PersonArchives |
|||
repoErr := repoCont.GetCont(map[string]interface{}{"`key`": u_v}, "`number`", "`name`") |
|||
if repoErr == nil { |
|||
var userCont QualEvalArrt |
|||
userCont.Id = u_v |
|||
userCont.Name = repoCont.Name |
|||
sendCont.UserListAry = append(sendCont.UserListAry, userCont) |
|||
} |
|||
} |
|||
sendCont.DimensionWeight, sendCont.TargetWeight = getPlanVersionWeghit(v.QualEvalId, strconv.FormatInt(v.Dimension, 10), strconv.FormatInt(v.Target, 10)) |
|||
//获取目标设定
|
|||
quanTitWhere := publicmethod.MapOut[string]() |
|||
quanTitWhere["company_id"] = v.Group |
|||
quanTitWhere["department_id"] = v.AcceptEvaluation |
|||
quanTitWhere["dimension"] = v.Dimension |
|||
quanTitWhere["target"] = v.Target |
|||
if v.DetailedTarget != 0 { |
|||
quanTitWhere["detailed"] = v.DetailedTarget |
|||
} |
|||
quanTitWhere["year"] = publicmethod.UnixTimeToDay(time.Now().Unix(), 16) |
|||
quanTitWhere["timecopy"] = AllZreoConfig(v.Cycles) |
|||
//目标值设定
|
|||
var quanTitCont modelskpi.QuanPeopleConfig |
|||
quanTitCont.GetCont(quanTitWhere) |
|||
//全奖值、零奖值、封顶值
|
|||
sendCont.ZeroPrize = strconv.FormatFloat(float64(quanTitCont.Zeroprize)/100, 'f', -1, 64) |
|||
sendCont.AllPrize = strconv.FormatFloat(float64(quanTitCont.Allprize)/100, 'f', -1, 64) |
|||
sendCont.CappingVal = quanTitCont.CappingVal / 100 |
|||
//获取实际值
|
|||
shiJiZhi := publicmethod.MapOut[string]() |
|||
shiJiZhi["fl_evaluation_user"] = myLoginCont.Key |
|||
shiJiZhi["fl_evaluation_department"] = myLoginCont.MainDeparment |
|||
shiJiZhi["fl_evaluation_group"] = myLoginCont.Company |
|||
|
|||
operationTime := time.Now().Unix() |
|||
if receivedValue.Time != "" { |
|||
strTime := fmt.Sprintf("%v-01 00:00:00", receivedValue.Time) |
|||
stringToTime, strToTimeErr := publicmethod.DateToTimeStamp(strTime) |
|||
if strToTimeErr == true { |
|||
operationTime = stringToTime |
|||
} else { |
|||
strTime = fmt.Sprintf("%v 00:00:00", receivedValue.Time) |
|||
stringToTime, strToTimeErr = publicmethod.DateToTimeStamp(strTime) |
|||
if strToTimeErr == true { |
|||
operationTime = stringToTime |
|||
} |
|||
} |
|||
} |
|||
switch v.Cycles { |
|||
case 1: |
|||
shiJiZhi["fl_year"] = publicmethod.ComputingTime(operationTime, 1) |
|||
shiJiZhi["fl_quarter"] = publicmethod.ComputingTime(operationTime, 2) |
|||
shiJiZhi["fl_month"] = publicmethod.ComputingTime(operationTime, 3) |
|||
shiJiZhi["fl_week"] = publicmethod.ComputingTime(operationTime, 4) |
|||
shiJiZhi["fl_day"] = publicmethod.ComputingTime(operationTime, 5) |
|||
case 2: |
|||
shiJiZhi["fl_year"] = publicmethod.ComputingTime(operationTime, 1) |
|||
shiJiZhi["fl_quarter"] = publicmethod.ComputingTime(operationTime, 2) |
|||
shiJiZhi["fl_month"] = publicmethod.ComputingTime(operationTime, 3) |
|||
shiJiZhi["fl_week"] = publicmethod.ComputingTime(operationTime, 4) |
|||
shiJiZhi["fl_day"] = publicmethod.ComputingTime(operationTime, 5) |
|||
case 3: |
|||
shiJiZhi["fl_year"] = publicmethod.ComputingTime(operationTime, 1) |
|||
shiJiZhi["fl_quarter"] = publicmethod.ComputingTime(operationTime, 2) |
|||
shiJiZhi["fl_month"] = publicmethod.ComputingTime(operationTime, 3) |
|||
shiJiZhi["fl_week"] = publicmethod.ComputingTime(operationTime, 4) |
|||
case 4: |
|||
shiJiZhi["fl_year"] = publicmethod.ComputingTime(operationTime, 1) |
|||
shiJiZhi["fl_quarter"] = publicmethod.ComputingTime(operationTime, 2) |
|||
shiJiZhi["fl_month"] = publicmethod.ComputingTime(operationTime, 3) |
|||
case 5: |
|||
shiJiZhi["fl_year"] = publicmethod.ComputingTime(operationTime, 1) |
|||
shiJiZhi["fl_quarter"] = publicmethod.ComputingTime(operationTime, 2) |
|||
case 6: |
|||
shiJiZhi["fl_year"] = publicmethod.ComputingTime(operationTime, 1) |
|||
default: |
|||
shiJiZhi["fl_year"] = publicmethod.ComputingTime(operationTime, 1) |
|||
shiJiZhi["fl_quarter"] = publicmethod.ComputingTime(operationTime, 2) |
|||
shiJiZhi["fl_month"] = publicmethod.ComputingTime(operationTime, 3) |
|||
shiJiZhi["fl_week"] = publicmethod.ComputingTime(operationTime, 4) |
|||
shiJiZhi["fl_day"] = publicmethod.ComputingTime(operationTime, 5) |
|||
} |
|||
actualValue := GetTimeIntervalDuty(shiJiZhi, v.Id) //实际值
|
|||
sendCont.Actual = strconv.FormatFloat(actualValue/100, 'f', -1, 64) |
|||
// chuShuVal := actualValue - quanTitCont.Zeroprize
|
|||
// beiChuShuVal := quanTitCont.Allprize - quanTitCont.Zeroprize
|
|||
// if beiChuShuVal > 0 {
|
|||
// sendCont.ReachScore = chuShuVal / beiChuShuVal
|
|||
// } else {
|
|||
// sendCont.ReachScore = 0
|
|||
// }
|
|||
_, sendCont.ReachScore = postweb.GetAchieAndActual(actualValue, float64(sendCont.TargetWeight), quanTitCont.Zeroprize, quanTitCont.Allprize, quanTitCont.CappingVal) |
|||
/* |
|||
* |
|||
@ 作者: 秦东 |
|||
@ 时间: 2022-10-28 15:09:33 |
|||
@ 功能: 计算达成率及得分 |
|||
@ 参数 |
|||
|
|||
#score 实际分 |
|||
#weight 指标权重 |
|||
#zeroprize 零奖值 |
|||
#allprize 全奖值 |
|||
#cappingval 封顶值 |
|||
|
|||
@ 返回值 |
|||
|
|||
#achievement 达成率 |
|||
#actual 得分 |
|||
|
|||
@ 函数原型 |
|||
|
|||
#GetAchieAndActual(score, weight, zeroprize, allprize, cappingval float64) (achievement, actual float64) |
|||
*/ |
|||
|
|||
if quanTitCont.Zeroprize == 0 && quanTitCont.Allprize == 0 { |
|||
sendCont.Reach = "未设置目标值" |
|||
} else { |
|||
dividend := quanTitCont.Allprize - quanTitCont.Zeroprize //被除数
|
|||
if dividend == 0 { |
|||
sendCont.Reach = "未设置目标值" |
|||
} else { |
|||
sendCont.Reach = fmt.Sprintf("(实际值-零奖值)/(全奖值-零奖值)") |
|||
} |
|||
} |
|||
sendCont.Reason = "" |
|||
sendCont.DetailedTarget = strconv.FormatInt(v.DetailedTarget, 10) |
|||
sendListCont = append(sendListCont, sendCont) |
|||
} |
|||
publicmethod.Result(0, sendListCont, c) |
|||
} |
|||
|
|||
/* |
|||
* |
|||
@ 作者: 秦东 |
|||
@ 时间: 2023-01-15 10:23:22 |
|||
@ 功能: 获取维度与指标权重 |
|||
@ 参数 |
|||
|
|||
#planKey 方案编号 |
|||
#dimensionId 维度 |
|||
#targetId 指标 |
|||
|
|||
@ 返回值 |
|||
|
|||
#dimensionIdWeghit 维度权重 |
|||
#targetIdWeghit 指标权重 |
|||
|
|||
@ 方法原型 |
|||
|
|||
#getPlanVersionWeghit(planKey, dimensionId, targetId string) (dimensionIdWeghit, targetIdWeghit int64) |
|||
*/ |
|||
func getPlanVersionWeghit(planKey, dimensionId, targetId string) (dimensionIdWeghit, targetIdWeghit int64) { |
|||
var planVersionCont modelskpi.PlanVersio |
|||
err := overall.CONSTANT_DB_KPI.Model(&modelskpi.PlanVersio{}).Select("`content`").Where("`key` = ?", planKey).First(&planVersionCont).Error |
|||
if err != nil { |
|||
return |
|||
} |
|||
var planVersioInfo []AddDutyNewCont |
|||
jsonErr := json.Unmarshal([]byte(planVersionCont.Content), &planVersioInfo) |
|||
if jsonErr != nil { |
|||
return |
|||
} |
|||
for _, v := range planVersioInfo { |
|||
if v.Id == dimensionId { |
|||
dimensionIdWeghit = int64(v.ZhiFraction) |
|||
for _, cv := range v.Child { |
|||
if cv.Id == targetId { |
|||
targetIdWeghit = cv.ReferenceScore |
|||
} |
|||
} |
|||
} |
|||
} |
|||
return |
|||
} |
|||
|
|||
/** |
|||
@ 作者: 秦东 |
|||
@ 时间: 2023-01-15 10:49:07 |
|||
@ 功能: 判断全奖与零奖参数 |
|||
@ 参数 |
|||
# |
|||
@ 返回值 |
|||
# |
|||
@ 方法原型 |
|||
# |
|||
*/ |
|||
// 判断全奖与零奖参数
|
|||
func AllZreoConfig(cycles int) (monthInt int64) { |
|||
switch cycles { |
|||
case 4: |
|||
monthInt = publicmethod.ComputingTime(time.Now().Unix(), 3) |
|||
case 5: |
|||
monthInt = publicmethod.ComputingTime(time.Now().Unix(), 2) |
|||
default: |
|||
|
|||
} |
|||
return |
|||
} |
|||
|
|||
// 获取定量考核时间内审批通过的考核数据
|
|||
func GetTimeIntervalDuty(whereData interface{}, schemeID int64) (actual float64) { |
|||
// jsonStr, _ := json.Marshal(whereData)
|
|||
// fmt.Printf("jsonStr------1------>%v\n", string(jsonStr))
|
|||
actual = 0 |
|||
//相关审批流
|
|||
var flowLogList []modelskpi.FlowLog |
|||
err := overall.CONSTANT_DB_KPI.Where("`fl_reply` IN (2,3) AND FIND_IN_SET(?,`fl_evaluation_id`)", schemeID).Where(whereData).Find(&flowLogList).Error |
|||
if err != nil { |
|||
return |
|||
} |
|||
for _, v := range flowLogList { |
|||
actual = actual + GetSchemeFlowData(v.Key, schemeID) |
|||
} |
|||
return |
|||
} |
|||
|
|||
// 获取指定审批流方案数据
|
|||
func GetSchemeFlowData(flowKwy, schemeID int64) (weightSum float64) { |
|||
weightSum = 0 |
|||
overall.CONSTANT_DB_KPI.Model(&modelskpi.FlowLogData{}).Where("`fld_evaluation_id` = ? AND `fld_flow_log` = ?", schemeID, flowKwy).Pluck("COALESCE(SUM(fld_score), 0) as qe_reference_score", &weightSum) |
|||
return |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
package workflow |
|||
|
|||
import ( |
|||
"key_performance_indicators/api/workflow/workflowengine" |
|||
) |
|||
|
|||
type ApiEntry struct { |
|||
WorkFlowApi workflowengine.ApiMethod |
|||
} |
|||
|
|||
var AppApiEntry = new(ApiEntry) |
|||
@ -0,0 +1,55 @@ |
|||
package workflowengine |
|||
|
|||
//当审批单同时满足以下条件时进入此流程
|
|||
type ConditionListCont struct { |
|||
ColumnID int `json:"columnId"` |
|||
Type int `json:"type"` |
|||
ConditionEn string `json:"conditionEn"` |
|||
ConditionCn string `json:"conditionCn"` |
|||
OptType string `json:"optType"` |
|||
Zdy1 string `json:"zdy1"` |
|||
Zdy2 string `json:"zdy2"` |
|||
Opt1 string `json:"opt1"` |
|||
Opt2 string `json:"opt2"` |
|||
ColumnDbname string `json:"columnDbname"` |
|||
ColumnType string `json:"columnType"` |
|||
ShowType string `json:"showType"` |
|||
ShowName string `json:"showName"` |
|||
FixedDownBoxValue string `json:"fixedDownBoxValue"` |
|||
} |
|||
|
|||
//操作人
|
|||
type NodeUserListCont struct { |
|||
TargetID int `json:"targetId"` |
|||
Type int `json:"type"` |
|||
Name string `json:"name"` |
|||
} |
|||
|
|||
//通用字段
|
|||
type PublicChildNode struct { |
|||
NodeName string `json:"nodeName"` //节点名称
|
|||
Error bool `json:"error"` //当前审批是否通过校验
|
|||
Type int `json:"type"` // 0 发起人 1审批 2抄送 3条件 4路由
|
|||
PriorityLevel int `json:"priorityLevel"` // 条件优先级
|
|||
Settype int `json:"settype"` // 审批人设置 1指定成员 2主管 4发起人自选 5发起人自己 7连续多级主管
|
|||
SelectMode int `json:"selectMode"` //审批人数 1选一个人 2选多个人
|
|||
SelectRange int `json:"selectRange"` //选择范围 1.全公司 2指定成员 2指定角色
|
|||
DirectorLevel int `json:"directorLevel"` //审批终点 最高层主管数
|
|||
ExamineMode int `json:"examineMode"` //多人审批时采用的审批方式 1依次审批 2会签
|
|||
NoHanderAction int `json:"noHanderAction"` //审批人为空时 1自动审批通过/不允许发起 2转交给审核管理员
|
|||
ExamineEndDirectorLevel int `json:"examineEndDirectorLevel"` //审批终点 第n层主管
|
|||
NodeUserList []NodeUserListCont `json:"nodeUserList"` //操作人
|
|||
CcSelfSelectFlag int `json:"ccSelfSelectFlag"` //允许发起人自选抄送人
|
|||
ConditionList []ConditionListCont `json:"conditionList"` //当审批单同时满足以下条件时进入此流程
|
|||
ChildNode *PublicChildNode `json:"childNode"` |
|||
ConditionNodes *[]PublicChildNode `json:"conditionNodes"` //
|
|||
} |
|||
|
|||
//工作流结构体
|
|||
type FlowStructIng struct { |
|||
TableId string `json:"tableId"` //流程ID
|
|||
WorkFlowDef WorkFlowDefStruct `json:"workFlowDef"` //工作流程定义
|
|||
DirectorMaxLevel int `json:"directorMaxLevel"` //审批主管最大层级
|
|||
FlowPermission []string `json:"flowPermission"` //发起人
|
|||
NodeConfig PublicChildNode `json:"nodeConfig"` //流程结构体
|
|||
} |
|||
@ -0,0 +1,21 @@ |
|||
package workflowengine |
|||
|
|||
import ( |
|||
"key_performance_indicators/overall/publicmethod" |
|||
"sync" |
|||
|
|||
"github.com/gin-gonic/gin" |
|||
) |
|||
|
|||
// 工作流引擎
|
|||
type ApiMethod struct{} |
|||
|
|||
// 协程设置
|
|||
var syncSeting = sync.WaitGroup{} |
|||
|
|||
// 系统内部审批处理
|
|||
func (a *ApiMethod) Index(c *gin.Context) { |
|||
outputCont := publicmethod.MapOut[string]() |
|||
outputCont["index"] = "工作流引擎入口" |
|||
publicmethod.Result(0, outputCont, c) |
|||
} |
|||
@ -0,0 +1,120 @@ |
|||
package workflowengine |
|||
|
|||
type JSONData struct { |
|||
TableID string `json:"tableId"` |
|||
WorkFlowDef struct { |
|||
Name string `json:"name"` |
|||
} `json:"workFlowDef"` |
|||
DirectorMaxLevel int `json:"directorMaxLevel"` |
|||
FlowPermission []interface{} `json:"flowPermission"` |
|||
NodeConfig struct { |
|||
NodeName string `json:"nodeName"` |
|||
Type int `json:"type"` |
|||
PriorityLevel int `json:"priorityLevel"` |
|||
Settype int `json:"settype"` |
|||
SelectMode int `json:"selectMode"` |
|||
SelectRange int `json:"selectRange"` |
|||
DirectorLevel int `json:"directorLevel"` |
|||
ExamineMode int `json:"examineMode"` |
|||
NoHanderAction int `json:"noHanderAction"` |
|||
ExamineEndDirectorLevel int `json:"examineEndDirectorLevel"` |
|||
CcSelfSelectFlag int `json:"ccSelfSelectFlag"` |
|||
ConditionList []interface{} `json:"conditionList"` |
|||
NodeUserList []interface{} `json:"nodeUserList"` |
|||
ChildNode struct { |
|||
NodeName string `json:"nodeName"` |
|||
Error bool `json:"error"` |
|||
Type int `json:"type"` |
|||
Settype int `json:"settype"` |
|||
SelectMode int `json:"selectMode"` |
|||
SelectRange int `json:"selectRange"` |
|||
DirectorLevel int `json:"directorLevel"` |
|||
ExamineMode int `json:"examineMode"` |
|||
NoHanderAction int `json:"noHanderAction"` |
|||
ExamineEndDirectorLevel int `json:"examineEndDirectorLevel"` |
|||
ChildNode struct { |
|||
NodeName string `json:"nodeName"` |
|||
Type int `json:"type"` |
|||
PriorityLevel int `json:"priorityLevel"` |
|||
Settype int `json:"settype"` |
|||
SelectMode int `json:"selectMode"` |
|||
SelectRange int `json:"selectRange"` |
|||
DirectorLevel int `json:"directorLevel"` |
|||
ExamineMode int `json:"examineMode"` |
|||
NoHanderAction int `json:"noHanderAction"` |
|||
ExamineEndDirectorLevel int `json:"examineEndDirectorLevel"` |
|||
CcSelfSelectFlag int `json:"ccSelfSelectFlag"` |
|||
ConditionList []interface{} `json:"conditionList"` |
|||
NodeUserList []interface{} `json:"nodeUserList"` |
|||
ChildNode struct { |
|||
NodeName string `json:"nodeName"` |
|||
Type int `json:"type"` |
|||
CcSelfSelectFlag int `json:"ccSelfSelectFlag"` |
|||
ChildNode interface{} `json:"childNode"` |
|||
NodeUserList []interface{} `json:"nodeUserList"` |
|||
Error bool `json:"error"` |
|||
} `json:"childNode"` |
|||
ConditionNodes []struct { |
|||
NodeName string `json:"nodeName"` |
|||
Type int `json:"type"` |
|||
PriorityLevel int `json:"priorityLevel"` |
|||
Settype int `json:"settype"` |
|||
SelectMode int `json:"selectMode"` |
|||
SelectRange int `json:"selectRange"` |
|||
DirectorLevel int `json:"directorLevel"` |
|||
ExamineMode int `json:"examineMode"` |
|||
NoHanderAction int `json:"noHanderAction"` |
|||
ExamineEndDirectorLevel int `json:"examineEndDirectorLevel"` |
|||
CcSelfSelectFlag int `json:"ccSelfSelectFlag"` |
|||
ConditionList []struct { |
|||
ColumnID int `json:"columnId"` |
|||
Type int `json:"type"` |
|||
ConditionEn string `json:"conditionEn"` |
|||
ConditionCn string `json:"conditionCn"` |
|||
OptType string `json:"optType"` |
|||
Zdy1 string `json:"zdy1"` |
|||
Zdy2 string `json:"zdy2"` |
|||
Opt1 string `json:"opt1"` |
|||
Opt2 string `json:"opt2"` |
|||
ColumnDbname string `json:"columnDbname"` |
|||
ColumnType string `json:"columnType"` |
|||
ShowType string `json:"showType"` |
|||
ShowName string `json:"showName"` |
|||
FixedDownBoxValue string `json:"fixedDownBoxValue"` |
|||
} `json:"conditionList"` |
|||
NodeUserList []struct { |
|||
TargetID int `json:"targetId"` |
|||
Type int `json:"type"` |
|||
Name string `json:"name"` |
|||
} `json:"nodeUserList"` |
|||
ChildNode struct { |
|||
NodeName string `json:"nodeName"` |
|||
Type int `json:"type"` |
|||
PriorityLevel int `json:"priorityLevel"` |
|||
Settype int `json:"settype"` |
|||
SelectMode int `json:"selectMode"` |
|||
SelectRange int `json:"selectRange"` |
|||
DirectorLevel int `json:"directorLevel"` |
|||
ExamineMode int `json:"examineMode"` |
|||
NoHanderAction int `json:"noHanderAction"` |
|||
ExamineEndDirectorLevel int `json:"examineEndDirectorLevel"` |
|||
CcSelfSelectFlag int `json:"ccSelfSelectFlag"` |
|||
ConditionList []interface{} `json:"conditionList"` |
|||
NodeUserList []struct { |
|||
TargetID int `json:"targetId"` |
|||
Type int `json:"type"` |
|||
Name string `json:"name"` |
|||
} `json:"nodeUserList"` |
|||
ChildNode interface{} `json:"childNode"` |
|||
ConditionNodes []interface{} `json:"conditionNodes"` |
|||
Error bool `json:"error"` |
|||
} `json:"childNode"` |
|||
ConditionNodes []interface{} `json:"conditionNodes"` |
|||
Error bool `json:"error"` |
|||
} `json:"conditionNodes"` |
|||
} `json:"childNode"` |
|||
NodeUserList []interface{} `json:"nodeUserList"` |
|||
} `json:"childNode"` |
|||
ConditionNodes []interface{} `json:"conditionNodes"` |
|||
} `json:"nodeConfig"` |
|||
} |
|||
@ -0,0 +1,62 @@ |
|||
package workflowengine |
|||
|
|||
import ( |
|||
"key_performance_indicators/overall/publicmethod" |
|||
|
|||
"github.com/gin-gonic/gin" |
|||
) |
|||
|
|||
/* |
|||
* |
|||
@ 作者: 秦东 |
|||
@ 时间: 2023-01-18 09:43:42 |
|||
@ 功能: 实验用 |
|||
@ 参数 |
|||
|
|||
# |
|||
|
|||
@ 返回值 |
|||
|
|||
# |
|||
|
|||
@ 方法原型 |
|||
|
|||
# |
|||
*/ |
|||
func (a *ApiMethod) ShiyanData(c *gin.Context) { |
|||
// jsonStr := `{"tableId":"1","workFlowDef":{"name":"合同审批"},"directorMaxLevel":4,"flowPermission":[],"nodeConfig":{"nodeName":"发起人","type":0,"priorityLevel":0,"settype":0,"selectMode":0,"selectRange":0,"directorLevel":0,"examineMode":0,"noHanderAction":0,"examineEndDirectorLevel":0,"ccSelfSelectFlag":0,"conditionList":[],"nodeUserList":[],"childNode":{"nodeName":"审核人","error":false,"type":1,"settype":2,"selectMode":0,"selectRange":0,"directorLevel":1,"examineMode":1,"noHanderAction":2,"examineEndDirectorLevel":0,"childNode":{"nodeName":"路由","type":4,"priorityLevel":1,"settype":1,"selectMode":0,"selectRange":0,"directorLevel":1,"examineMode":1,"noHanderAction":2,"examineEndDirectorLevel":1,"ccSelfSelectFlag":1,"conditionList":[],"nodeUserList":[],"childNode":{"nodeName":"抄送人","type":2,"ccSelfSelectFlag":1,"childNode":null,"nodeUserList":[],"error":false},"conditionNodes":[{"nodeName":"条件1","type":3,"priorityLevel":1,"settype":1,"selectMode":0,"selectRange":0,"directorLevel":1,"examineMode":1,"noHanderAction":2,"examineEndDirectorLevel":1,"ccSelfSelectFlag":1,"conditionList":[{"columnId":0,"type":1,"conditionEn":"","conditionCn":"","optType":"","zdy1":"","zdy2":"","opt1":"","opt2":"","columnDbname":"","columnType":"","showType":"","showName":"","fixedDownBoxValue":""}],"nodeUserList":[{"targetId":85,"type":1,"name":"天旭"}],"childNode":{"nodeName":"审核人","type":1,"priorityLevel":1,"settype":1,"selectMode":0,"selectRange":0,"directorLevel":1,"examineMode":1,"noHanderAction":2,"examineEndDirectorLevel":1,"ccSelfSelectFlag":1,"conditionList":[],"nodeUserList":[{"targetId":2515744,"type":1,"name":"哈哈哈哈"}],"childNode":null,"conditionNodes":[],"error":false},"conditionNodes":[],"error":false},{"nodeName":"条件2","type":3,"priorityLevel":2,"settype":1,"selectMode":0,"selectRange":0,"directorLevel":1,"examineMode":1,"noHanderAction":2,"examineEndDirectorLevel":1,"ccSelfSelectFlag":1,"conditionList":[],"nodeUserList":[],"childNode":null,"conditionNodes":[],"error":false}]},"nodeUserList":[]},"conditionNodes":[]}}`
|
|||
|
|||
// jsonStrSmaill := `{
|
|||
// "tableId": "1",
|
|||
// "workFlowDef": {
|
|||
// "name": "合同审批"
|
|||
// },
|
|||
// "directorMaxLevel": 4,
|
|||
// "flowPermission": {},
|
|||
// "nodeConfig": {
|
|||
// "nodeName": "发起人",
|
|||
// "type": 0,
|
|||
// "priorityLevel": 0,
|
|||
// "settype": 0,
|
|||
// "selectMode": 0,
|
|||
// "selectRange": 0,
|
|||
// "directorLevel": 0,
|
|||
// "examineMode": 0,
|
|||
// "noHanderAction": 0,
|
|||
// "examineEndDirectorLevel": 0,
|
|||
// "ccSelfSelectFlag": 0,
|
|||
// "conditionList": {},
|
|||
// "nodeUserList": {},
|
|||
// "conditionNodes": {}
|
|||
// }
|
|||
// }`
|
|||
|
|||
var workFlowStruct FlowStructIng |
|||
workFlowStruct.NodeConfig.NodeName = "发起人" |
|||
workFlowStruct.DirectorMaxLevel = 4 |
|||
// err := json.Unmarshal([]byte(jsonStrSmaill), &workFlowStruct)
|
|||
outData := publicmethod.MapOut[string]() |
|||
outData["workFlowStruct"] = workFlowStruct |
|||
// outData["err"] = err
|
|||
publicmethod.Result(0, workFlowStruct, c) |
|||
} |
|||
@ -0,0 +1,63 @@ |
|||
package workflowengine |
|||
|
|||
import "key_performance_indicators/overall/publicmethod" |
|||
|
|||
//工作流结构体
|
|||
type FlowStruct struct { |
|||
TableId string `json:"tableId"` //流程ID
|
|||
WorkFlowDef WorkFlowDefStruct `json:"workFlowDef"` //工作流程定义
|
|||
DirectorMaxLevel int `json:"directorMaxLevel"` //审批主管最大层级
|
|||
FlowPermission []string `json:"flowPermission"` //发起人
|
|||
NodeConfig NodeConfigStruct `json:"nodeConfig"` //流程结构体
|
|||
} |
|||
|
|||
//工作流程定义
|
|||
type WorkFlowDefStruct struct { |
|||
publicmethod.PublicName //流程名称
|
|||
} |
|||
|
|||
//流程结构体
|
|||
type NodeConfigStruct struct { |
|||
PublicNodeWord |
|||
ChildNode PublicNodeWord `json:"childNode"` //流程标准结构
|
|||
} |
|||
|
|||
//流程结构体通用字段
|
|||
type PublicNodeWord struct { |
|||
IsTrue bool `json:"error"` //当前审批是否通过校验
|
|||
NodeName string `json:"nodeName"` //节点名称
|
|||
Type int `json:"type"` // 0 发起人 1审批 2抄送 3条件 4路由
|
|||
PriorityLevel int `json:"priorityLevel"` //条件优先级 0,1,2,3,4,5,6,7,8,9,10
|
|||
Settype int `json:"settype"` // 审批人设置 1指定成员 2主管 4发起人自选 5发起人自己 7连续多级主管
|
|||
SelectMode int `json:"selectMode"` //审批人数 0不选 1选一个人 2选多个人
|
|||
SelectRange int `json:"selectRange"` //选择范围 0 1.全公司 2指定成员 2指定角色
|
|||
DirectorLevel int `json:"directorLevel"` //审批终点 最高层主管数
|
|||
ExamineMode int `json:"examineMode"` //多人审批时采用的审批方式 1依次审批 2会签
|
|||
NoHanderAction int `json:"noHanderAction"` //审批人为空时 1自动审批通过/不允许发起 2转交给审核管理员
|
|||
ExamineEndDirectorLevel int `json:"examineEndDirectorLevel"` //审批终点 第n层主管
|
|||
CcSelfSelectFlag int `json:"ccSelfSelectFlag"` //允许发起人自选抄送人
|
|||
ConditionList []ConditionListStruct `json:"conditionList"` //当审批单同时满足以下条件时进入此流程
|
|||
NodeUserList []NodeUserListType `json:"nodeUserList"` //操作人
|
|||
|
|||
} |
|||
|
|||
//审批条件结构体
|
|||
type ConditionListStruct struct { |
|||
ColumnId string `json:"columnId"` //发起人
|
|||
OptType string `json:"optType"` //运算符 ["", "<", ">", "≤", "=", "≥"][optType]
|
|||
Zdy1 string `json:"zdy1"` //自定义内容
|
|||
Zdy2 string `json:"zdy2"` //自定义内容
|
|||
Opt1 string `json:"opt1"` //左侧符号 < ≤
|
|||
Opt2 string `json:"opt2"` //右侧符号 < ≤
|
|||
ColumnDbname string `json:"columnDbname"` //条件字段名称
|
|||
ColumnType string `json:"columnType"` //条件字段类型
|
|||
ShowType string `json:"showType"` //checkBox多选 其他
|
|||
ShowName string `json:"showName"` //展示名
|
|||
FixedDownBoxValue string `json:"fixedDownBoxValue"` //多选数组
|
|||
} |
|||
|
|||
//操作人
|
|||
type NodeUserListType struct { |
|||
TargetId string `json:"targetId"` //操作人Key
|
|||
publicmethod.PublicName //操作人姓名
|
|||
} |
|||
@ -0,0 +1,14 @@ |
|||
package workflowrouter |
|||
|
|||
/** |
|||
@ 作者: 秦东 |
|||
@ 时间: 2023-01-18 09:33:49 |
|||
@ 功能: 工作流路由 |
|||
@ 参数 |
|||
# |
|||
@ 返回值 |
|||
# |
|||
@ 方法原型 |
|||
# |
|||
*/ |
|||
type ApiRouter struct{} |
|||
@ -0,0 +1,21 @@ |
|||
package workflowrouter |
|||
|
|||
import ( |
|||
"github.com/gin-gonic/gin" |
|||
|
|||
"key_performance_indicators/api/workflow" |
|||
) |
|||
|
|||
// 工作流
|
|||
func (a *ApiRouter) RouterGroup(router *gin.RouterGroup) { |
|||
apiRouter := router.Group("workflowapi") |
|||
|
|||
var workFlow = workflow.AppApiEntry.WorkFlowApi |
|||
{ |
|||
apiRouter.GET("", workFlow.Index) //入口
|
|||
apiRouter.POST("", workFlow.Index) //入口
|
|||
|
|||
//实验用接口
|
|||
apiRouter.POST("shiyan_data", workFlow.ShiyanData) //入口
|
|||
} |
|||
} |
|||
Loading…
Reference in new issue