33 changed files with 2462 additions and 84 deletions
@ -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) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -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() |
||||
|
} |
||||
@ -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 |
||||
|
} |
||||
@ -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 |
||||
|
} |
||||
@ -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 |
||||
|
} |
||||
Loading…
Reference in new issue