diff --git a/api/version1/taskplatform/taskflow/flowengine.go b/api/version1/taskplatform/taskflow/flowengine.go index 37a5b01..2783720 100644 --- a/api/version1/taskplatform/taskflow/flowengine.go +++ b/api/version1/taskplatform/taskflow/flowengine.go @@ -92,12 +92,13 @@ func (a *ApiMethod) SaveFlowCont(c *gin.Context) { } } } - + saveData := publicmethod.MapOut[string]() + var customerForm modelAppPlatform.CustomerForm if isFormWrite { var customerForm modelAppPlatform.CustomerForm err = customerForm.GetCont(map[string]interface{}{"`id`": requestData.WorkFlowDef.FormKey}, "`permitstr`", "`userpermit`") if err == nil { - saveData := publicmethod.MapOut[string]() + if len(orgList) > 0 { if customerForm.PermitStr != "" { oldOrgList := strings.Split(customerForm.PermitStr, ",") @@ -118,14 +119,18 @@ func (a *ApiMethod) SaveFlowCont(c *gin.Context) { } else { flowVersion.UserPermit = customerForm.UserPermit } - saveData["flowkey"] = uuid + if len(saveData) > 0 { saveData["edit_time"] = time.Now().Unix() + saveData["classify"] = 2 customerForm.EiteCont(map[string]interface{}{"`id`": requestData.WorkFlowDef.FormKey}, saveData) } } } - + saveData["flowkey"] = uuid + saveData["edit_time"] = time.Now().Unix() + saveData["classify"] = 2 + customerForm.EiteCont(map[string]interface{}{"`id`": requestData.WorkFlowDef.FormKey}, saveData) sendMap := publicmethod.MapOut[string]() writeDb := overall.CONSTANT_DB_AppPlatform.Begin() flowErr := writeDb.Create(&worfFlowMain).Error diff --git a/config/configDatabase/database.go b/config/configDatabase/database.go index 025bd4f..35f7642 100644 --- a/config/configDatabase/database.go +++ b/config/configDatabase/database.go @@ -31,6 +31,7 @@ type MysqlSetUp struct { ServerMaster MasterMysqlSetUp `mapstructure:"servermaster" json:"servermaster" yaml:"servermaster"` //仓储系统数据库 TidbrMaster MasterMysqlSetUp `mapstructure:"tidbrmaster" json:"tidbrmaster" yaml:"tidbrmaster"` //仓储系统数据库 CustomerForm MasterMysqlSetUp `mapstructure:"customerFormDatabase" json:"customerFormDatabase" yaml:"customerFormDatabase"` //自定义表单数据库 + FlowLogDatabase MasterMysqlSetUp `mapstructure:"flowLogDatabase" json:"flowLogDatabase" yaml:"flowLogDatabase"` //工作流记录 } type MasterMysqlSetUp struct { diff --git a/initialization/databaseinit/mysql.go b/initialization/databaseinit/mysql.go index e43b4fe..893625b 100644 --- a/initialization/databaseinit/mysql.go +++ b/initialization/databaseinit/mysql.go @@ -12,140 +12,146 @@ func LoadDatabase() { //开启主数据库 overall.CONSTANT_DB_Master = sqlConfig.MasterMysql.OpenSql() if overall.CONSTANT_DB_Master == nil { - fmt.Printf("%v数据库开启失败!\n", sqlConfig.MasterMysql.Name) + fmt.Printf("%v:数据库开启失败!\n", sqlConfig.MasterMysql.Name) } else { - fmt.Printf("%v数据库开启成功!\n", sqlConfig.MasterMysql.Name) + fmt.Printf("%v:数据库开启成功!\n", sqlConfig.MasterMysql.Name) } //开启主数据库 overall.CONSTANT_DB_AppPlatform = sqlConfig.AppPlatformDatabase.OpenSql() if overall.CONSTANT_DB_AppPlatform == nil { - fmt.Printf("%v数据库开启失败!\n", sqlConfig.AppPlatformDatabase.Name) + fmt.Printf("%v:数据库开启失败!\n", sqlConfig.AppPlatformDatabase.Name) } else { - fmt.Printf("%v数据库开启成功!\n", sqlConfig.AppPlatformDatabase.Name) + fmt.Printf("%v:数据库开启成功!\n", sqlConfig.AppPlatformDatabase.Name) } //开启微信数据库 overall.CONSTANT_DB_Wechat = sqlConfig.WechatMysql.OpenSql() if overall.CONSTANT_DB_Master == nil { - fmt.Printf("%v数据库开启失败!\n", sqlConfig.WechatMysql.Name) + fmt.Printf("%v:数据库开启失败!\n", sqlConfig.WechatMysql.Name) } else { - fmt.Printf("%v数据库开启成功!\n", sqlConfig.WechatMysql.Name) + fmt.Printf("%v:数据库开启成功!\n", sqlConfig.WechatMysql.Name) } //开启Hr数据库 overall.CONSTANT_DB_HR = sqlConfig.HrMysql.OpenSql() if overall.CONSTANT_DB_HR == nil { - fmt.Printf("%v数据库开启失败!\n", sqlConfig.HrMysql.Name) + fmt.Printf("%v:数据库开启失败!\n", sqlConfig.HrMysql.Name) } else { - fmt.Printf("%v数据库开启成功!\n", sqlConfig.HrMysql.Name) + fmt.Printf("%v:数据库开启成功!\n", sqlConfig.HrMysql.Name) } //文档属性数据库 overall.CONSTANT_DB_FILE_BOOK = sqlConfig.FileBookDate.OpenSql() if overall.CONSTANT_DB_HR == nil { - fmt.Printf("%v数据库开启失败!\n", sqlConfig.FileBookDate.Name) + fmt.Printf("%v:数据库开启失败!\n", sqlConfig.FileBookDate.Name) } else { - fmt.Printf("%v数据库开启成功!\n", sqlConfig.FileBookDate.Name) + fmt.Printf("%v:数据库开启成功!\n", sqlConfig.FileBookDate.Name) } //错题库 overall.CONSTANT_DB_ERROR_SUBJECT = sqlConfig.ErrorSubjectDate.OpenSql() if overall.CONSTANT_DB_HR == nil { - fmt.Printf("%v数据库开启失败!\n", sqlConfig.ErrorSubjectDate.Name) + fmt.Printf("%v:数据库开启失败!\n", sqlConfig.ErrorSubjectDate.Name) } else { - fmt.Printf("%v数据库开启成功!\n", sqlConfig.ErrorSubjectDate.Name) + fmt.Printf("%v:数据库开启成功!\n", sqlConfig.ErrorSubjectDate.Name) } //自我测验 overall.CONSTANT_DB_MY_TEST = sqlConfig.MyTestDate.OpenSql() if overall.CONSTANT_DB_HR == nil { - fmt.Printf("%v数据库开启失败!\n", sqlConfig.MyTestDate.Name) + fmt.Printf("%v:数据库开启失败!\n", sqlConfig.MyTestDate.Name) } else { - fmt.Printf("%v数据库开启成功!\n", sqlConfig.MyTestDate.Name) + fmt.Printf("%v:数据库开启成功!\n", sqlConfig.MyTestDate.Name) } //图文信息数据库 overall.CONSTANT_DB_IMAGES_TEST = sqlConfig.ImageTextDate.OpenSql() if overall.CONSTANT_DB_HR == nil { - fmt.Printf("%v数据库开启失败!\n", sqlConfig.ImageTextDate.Name) + fmt.Printf("%v:数据库开启失败!\n", sqlConfig.ImageTextDate.Name) } else { - fmt.Printf("%v数据库开启成功!\n", sqlConfig.ImageTextDate.Name) + fmt.Printf("%v:数据库开启成功!\n", sqlConfig.ImageTextDate.Name) } //计分明细数据库 overall.CONSTANT_DB_SCORING = sqlConfig.ScoringDetailsDate.OpenSql() if overall.CONSTANT_DB_HR == nil { - fmt.Printf("%v数据库开启失败!\n", sqlConfig.ScoringDetailsDate.Name) + fmt.Printf("%v:数据库开启失败!\n", sqlConfig.ScoringDetailsDate.Name) } else { - fmt.Printf("%v数据库开启成功!\n", sqlConfig.ScoringDetailsDate.Name) + fmt.Printf("%v:数据库开启成功!\n", sqlConfig.ScoringDetailsDate.Name) } //趣味问答 overall.CONSTANT_DB_QA = sqlConfig.QuestionsAnswersDate.OpenSql() if overall.CONSTANT_DB_HR == nil { - fmt.Printf("%v数据库开启失败!\n", sqlConfig.QuestionsAnswersDate.Name) + fmt.Printf("%v:数据库开启失败!\n", sqlConfig.QuestionsAnswersDate.Name) } else { - fmt.Printf("%v数据库开启成功!\n", sqlConfig.QuestionsAnswersDate.Name) + fmt.Printf("%v:数据库开启成功!\n", sqlConfig.QuestionsAnswersDate.Name) } //风云榜统计数据库 overall.CONSTANT_DB_BILLBOARD = sqlConfig.BillboardDate.OpenSql() if overall.CONSTANT_DB_HR == nil { - fmt.Printf("%v数据库开启失败!\n", sqlConfig.BillboardDate.Name) + fmt.Printf("%v:数据库开启失败!\n", sqlConfig.BillboardDate.Name) } else { - fmt.Printf("%v数据库开启成功!\n", sqlConfig.BillboardDate.Name) + fmt.Printf("%v:数据库开启成功!\n", sqlConfig.BillboardDate.Name) } //健康上报数据库 overall.CONSTANT_DB_HEALTH = sqlConfig.HealthReportDate.OpenSql() if overall.CONSTANT_DB_HR == nil { - fmt.Printf("%v数据库开启失败!\n", sqlConfig.HealthReportDate.Name) + fmt.Printf("%v:数据库开启失败!\n", sqlConfig.HealthReportDate.Name) } else { - fmt.Printf("%v数据库开启成功!\n", sqlConfig.HealthReportDate.Name) + fmt.Printf("%v:数据库开启成功!\n", sqlConfig.HealthReportDate.Name) } //绩效考核数据库 overall.CONSTANT_DB_KPI = sqlConfig.KpiDate.OpenSql() if overall.CONSTANT_DB_HR == nil { - fmt.Printf("%v数据库开启失败!\n", sqlConfig.KpiDate.Name) + fmt.Printf("%v:数据库开启失败!\n", sqlConfig.KpiDate.Name) } else { - fmt.Printf("%v数据库开启成功!\n", sqlConfig.KpiDate.Name) + fmt.Printf("%v:数据库开启成功!\n", sqlConfig.KpiDate.Name) } //企业微信回调记录 overall.CONSTANT_DB_WECHAT_LOG = sqlConfig.WechatCallBackLogDate.OpenSql() if overall.CONSTANT_DB_HR == nil { - fmt.Printf("%v数据库开启失败!\n", sqlConfig.WechatCallBackLogDate.Name) + fmt.Printf("%v:数据库开启失败!\n", sqlConfig.WechatCallBackLogDate.Name) } else { - fmt.Printf("%v数据库开启成功!\n", sqlConfig.WechatCallBackLogDate.Name) + fmt.Printf("%v:数据库开启成功!\n", sqlConfig.WechatCallBackLogDate.Name) } //管理档案 overall.CONSTANT_DB_MANAGE_ARCHIVES = sqlConfig.Managearchives.OpenSql() if overall.CONSTANT_DB_MANAGE_ARCHIVES == nil { - fmt.Printf("%v数据库开启失败!\n", sqlConfig.Managearchives.Name) + fmt.Printf("%v:数据库开启失败!\n", sqlConfig.Managearchives.Name) } else { - fmt.Printf("%v数据库开启成功!\n", sqlConfig.Managearchives.Name) + fmt.Printf("%v:数据库开启成功!\n", sqlConfig.Managearchives.Name) } //系统权限配置数据库 overall.CONSTANT_DB_System_Permission = sqlConfig.SystemPermission.OpenSql() if overall.CONSTANT_DB_System_Permission == nil { - fmt.Printf("%v数据库开启失败!\n", sqlConfig.SystemPermission.Name) + fmt.Printf("%v:数据库开启失败!\n", sqlConfig.SystemPermission.Name) } else { - fmt.Printf("%v数据库开启成功!\n", sqlConfig.SystemPermission.Name) + fmt.Printf("%v:数据库开启成功!\n", sqlConfig.SystemPermission.Name) } //仓储系统 overall.CONSTANT_DB_Storage = sqlConfig.Storage.OpenSql() if overall.CONSTANT_DB_Storage == nil { - fmt.Printf("%v数据库开启失败!\n", sqlConfig.Storage.Name) + fmt.Printf("%v:数据库开启失败!\n", sqlConfig.Storage.Name) } else { - fmt.Printf("%v数据库开启成功!\n", sqlConfig.Storage.Name) + fmt.Printf("%v:数据库开启成功!\n", sqlConfig.Storage.Name) } overall.CONSTANT_DB_Server = sqlConfig.ServerMaster.OpenSql() if overall.CONSTANT_DB_Server == nil { - fmt.Printf("%v数据库开启失败!云服务器\n", sqlConfig.ServerMaster.Name) + fmt.Printf("%v:数据库开启失败!云服务器\n", sqlConfig.ServerMaster.Name) } else { - fmt.Printf("%v数据库开启成功!云服务器\n", sqlConfig.ServerMaster.Name) + fmt.Printf("%v:数据库开启成功!云服务器\n", sqlConfig.ServerMaster.Name) } overall.CONSTANT_DB_Tidb = sqlConfig.TidbrMaster.OpenSql() if overall.CONSTANT_DB_Tidb == nil { - fmt.Printf("%v数据库开启失败!私有云服务器\n", sqlConfig.TidbrMaster.Name) + fmt.Printf("%v:数据库开启失败!私有云服务器\n", sqlConfig.TidbrMaster.Name) } else { - fmt.Printf("%v数据库开启成功!私有云服务器\n", sqlConfig.TidbrMaster.Name) + fmt.Printf("%v:数据库开启成功!私有云服务器\n", sqlConfig.TidbrMaster.Name) } overall.CONSTANT_DB_CustomerForm = sqlConfig.CustomerForm.OpenSql() if overall.CONSTANT_DB_Tidb == nil { - fmt.Printf("%v数据库开启失败!服务器\n", sqlConfig.CustomerForm.Name) + fmt.Printf("%v:数据库开启失败!服务器\n", sqlConfig.CustomerForm.Name) } else { - fmt.Printf("%v数据库开启成功!服务器\n", sqlConfig.CustomerForm.Name) + fmt.Printf("%v:数据库开启成功!服务器\n", sqlConfig.CustomerForm.Name) + } + overall.CONSTANT_DB_WorkFlowLog = sqlConfig.FlowLogDatabase.OpenSql() + if overall.CONSTANT_DB_Tidb == nil { + fmt.Printf("%v:数据库开启失败!服务器\n", sqlConfig.FlowLogDatabase.Name) + } else { + fmt.Printf("%v:数据库开启成功!服务器\n", sqlConfig.FlowLogDatabase.Name) } } diff --git a/models/flowlog/work_flow_log.go b/models/flowlog/work_flow_log.go new file mode 100644 index 0000000..4bc8150 --- /dev/null +++ b/models/flowlog/work_flow_log.go @@ -0,0 +1,69 @@ +package flowlog + +import ( + "appPlatform/overall" + "strings" +) + +// 工作流日志 +type WorkFlowLog struct { + Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` + FlowId int64 `json:"flow_id" gorm:"column:flow_id;type:bigint(20) unsigned;default:0;not null;comment:执行的流程"` + Creater int64 `json:"creater" gorm:"column:creater;type:bigint(20) unsigned;default:0;not null;comment:操作人"` + Status int `json:"status" gorm:"column:status;type:int(1) unsigned;default:1;not null;comment:状态:1、草稿;2:驳回;3:通过;4:归档;5:删除"` + Content string `json:"content" gorm:"column:content;type:mediumtext;default:'';comment:审批意见"` + Annex string `json:"annex" gorm:"column:annex;type:mediumtext;default:'';comment:附件"` + Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` + EditTime int64 `json:"editTime" gorm:"column:edit_time;type:bigint(20) unsigned;default:0;not null;comment:编辑时间"` +} + +func (WorkFlowLog *WorkFlowLog) TableName() string { + return "work_flow_log" +} + +// 写入内容 +func (cont *WorkFlowLog) WriteCont() (err error) { + err = overall.CONSTANT_DB_WorkFlowLog.Create(&cont).Error + return +} + +// 编辑内容 +func (cont *WorkFlowLog) EiteCont(whereMap interface{}, saveData interface{}) (err error) { + err = overall.CONSTANT_DB_WorkFlowLog.Model(&cont).Where(whereMap).Updates(saveData).Error + return +} + +// 获取内容 +func (cont *WorkFlowLog) GetCont(whereMap interface{}, field ...string) (err error) { + gormDb := overall.CONSTANT_DB_WorkFlowLog.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 *WorkFlowLog) CountCont(whereMap interface{}) (countId int64) { + overall.CONSTANT_DB_WorkFlowLog.Model(&cont).Where(whereMap).Count(&countId) + return +} + +// 读取全部信息 +func (cont *WorkFlowLog) ContMap(whereMap interface{}, field ...string) (countAry []WorkFlowLog, err error) { + gormDb := overall.CONSTANT_DB_WorkFlowLog.Model(&cont) + if len(field) > 0 { + fieldStr := strings.Join(field, ",") + gormDb = gormDb.Select(fieldStr) + } + err = gormDb.Where(whereMap).Find(&countAry).Error + return +} + +// 删除内容 +func (cont *WorkFlowLog) DelCont(whereMap interface{}) (err error) { + err = overall.CONSTANT_DB_WorkFlowLog.Where(whereMap).Delete(&cont).Error + return +} diff --git a/models/modelAppPlatform/run_flow.go b/models/modelAppPlatform/run_flow.go new file mode 100644 index 0000000..d34d8f0 --- /dev/null +++ b/models/modelAppPlatform/run_flow.go @@ -0,0 +1,72 @@ +package modelAppPlatform + +import ( + "appPlatform/overall" + "strings" +) + +// 工作流执行主体 +// 字典类型 +type RunFlow struct { + Id int `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` + FlowKey int64 `json:"flow_key" gorm:"column:flow_key;type:bigint(20) unsigned;default:0;not null;comment:工作流主体"` + Version string `json:"version" gorm:"column:version;type:varchar(255);default:'';comment:使用得版本"` + + Creater int64 `json:"creater" gorm:"column:creater;type:bigint(20) unsigned;default:0;not null;comment:操作人"` + Status int `json:"status" gorm:"column:status;type:int(1) unsigned;default:1;not null;comment:状态:1、草稿;2:驳回;3:通过;4:归档;5:删除"` + Content string `json:"content" gorm:"column:content;type:mediumtext;default:'';comment:审批意见"` + Annex string `json:"annex" gorm:"column:annex;type:mediumtext;default:'';comment:附件"` + Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` + EditTime int64 `json:"editTime" gorm:"column:edit_time;type:bigint(20) unsigned;default:0;not null;comment:编辑时间"` +} + +func (RunFlow *RunFlow) TableName() string { + return "run_flow" +} + +// 写入内容 +func (cont *RunFlow) WriteCont() (err error) { + err = overall.CONSTANT_DB_AppPlatform.Create(&cont).Error + return +} + +// 编辑内容 +func (cont *RunFlow) EiteCont(whereMap interface{}, saveData interface{}) (err error) { + err = overall.CONSTANT_DB_AppPlatform.Model(&cont).Where(whereMap).Updates(saveData).Error + return +} + +// 获取内容 +func (cont *RunFlow) GetCont(whereMap interface{}, field ...string) (err error) { + gormDb := overall.CONSTANT_DB_AppPlatform.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 *RunFlow) CountCont(whereMap interface{}) (countId int64) { + overall.CONSTANT_DB_AppPlatform.Model(&cont).Where(whereMap).Count(&countId) + return +} + +// 读取全部信息 +func (cont *RunFlow) ContMap(whereMap interface{}, field ...string) (countAry []RunFlow, err error) { + gormDb := overall.CONSTANT_DB_AppPlatform.Model(&cont) + if len(field) > 0 { + fieldStr := strings.Join(field, ",") + gormDb = gormDb.Select(fieldStr) + } + err = gormDb.Where(whereMap).Find(&countAry).Error + return +} + +// 删除内容 +func (cont *RunFlow) DelCont(whereMap interface{}) (err error) { + err = overall.CONSTANT_DB_AppPlatform.Where(whereMap).Delete(&cont).Error + return +} diff --git a/overall/appConfig.go b/overall/appConfig.go index 7c97967..80e5441 100644 --- a/overall/appConfig.go +++ b/overall/appConfig.go @@ -43,6 +43,7 @@ var ( CONSTANT_DB_Storage *gorm.DB //仓储系统数据库 CONSTANT_DB_CustomerForm *gorm.DB //自定义表单数据库 + CONSTANT_DB_WorkFlowLog *gorm.DB //工作流历史记录 CONSTANT_DB_Server *gorm.DB //线上数据库 CONSTANT_DB_Tidb *gorm.DB //私有云数据库