超级管理员 1 year ago
parent
commit
3df3e55458
  1. 1945
      api/version1/customerApp/appControll.go
  2. 226
      api/version1/customerApp/runAppControll.go
  3. 179
      api/version1/customerApp/type.go
  4. 67
      api/version1/customerform/form.go
  5. 206
      api/version1/customerform/formTable.go
  6. 819
      api/version1/customerform/formTableView.go
  7. 68
      api/version1/customerform/listField.go
  8. 73
      api/version1/customerform/type.go
  9. 7
      api/version1/entry.go
  10. 48
      api/version1/publicapi/api.go
  11. 14
      api/version1/publicapi/type.go
  12. 813
      api/version1/taskplatform/taskflow/appTaskFlow.go
  13. 6
      api/version1/taskplatform/taskflow/editformflow.go
  14. 1
      api/version1/taskplatform/taskflow/flowType.go
  15. 4
      api/version1/taskplatform/taskflow/flowengine.go
  16. 41
      api/version1/taskplatform/taskflow/types.go
  17. 164
      api/version1/taskplatform/taskmanagement/appControl.go
  18. 2
      api/version1/taskplatform/taskmanagement/flowNode.go
  19. 1
      api/version1/taskplatform/taskmanagement/flowType.go
  20. 14
      api/version1/taskplatform/taskmanagement/formcontrol.go
  21. 31
      api/version1/taskplatform/taskmanagement/ruanTask.go
  22. 286
      api/version1/taskplatform/taskmanagement/runTaskFlow.go
  23. 112
      api/version1/taskplatform/taskmanagement/runWorkFlow.go
  24. 37
      apirouter/v1/customerformrouter/router.go
  25. 1
      apirouter/v1/public/router.go
  26. 14
      apirouter/v1/taskrouter/taskrouter.go
  27. 3
      initialization/app/run.go
  28. 97
      models/customerForm/runFlowTask.go
  29. 3
      models/customerForm/runWorkflow.go
  30. 5
      models/customerForm/taskrecord.go
  31. 86
      models/modelAppPlatform/appmenus.go
  32. 38
      models/modelAppPlatform/customer_form.go
  33. 31
      models/modelAppPlatform/customer_form_version.go
  34. 3
      models/modelAppPlatform/customer_form_view.go
  35. 90
      overall/publicmethod/technique.go

1945
api/version1/customerApp/appControll.go

File diff suppressed because it is too large

226
api/version1/customerApp/runAppControll.go

@ -0,0 +1,226 @@
package customerApp
import (
"appPlatform/models/modelAppPlatform"
"appPlatform/models/modelshr"
"appPlatform/overall"
"appPlatform/overall/publicmethod"
"strconv"
"strings"
"github.com/gin-gonic/gin"
)
/*
*
@ 作者: 秦东
@ 时间: 2024-05-29 16:34:23
@ 功能: 鉴定当权人员是否有权限使用
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) AppJwtPower(c *gin.Context) {
var requestData JwtPower
err := c.ShouldBindJSON(&requestData)
if err != nil {
publicmethod.Result(100, err, c)
return
}
if requestData.Id == "" {
publicmethod.Result(102, err, c)
return
}
context, _ := c.Get(overall.MyContJwt)
var userCont modelshr.ManCont
userCont.GetLoginCont(context) //当前操作人
if userCont.Role != "" {
roleAry := strings.Split(userCont.Role, ",")
if len(roleAry) > 0 {
if publicmethod.IsInTrue[string]("1", roleAry) {
publicmethod.Result(0, true, c)
return
}
}
}
var custFormInfo modelAppPlatform.CustomerForm
err = custFormInfo.GetCont(map[string]interface{}{"`signCode`": requestData.Id}, "`id`", "`appManager`", "`appRoleManager`", "`appOrgMan`", "`userpermit`", "`postpermit`", "`orgpermit`")
if err != nil {
publicmethod.Result(0, false, c)
return
}
if requestData.Types == 2 {
//操作权限
var jwtIsTrue TreeJwtPower
if custFormInfo.AppRoleManager != "" {
syncSeting.Add(1)
go jwtIsTrue.JwtRoleViewsIsTrue(custFormInfo.AppRoleManager, userCont.Role)
}
if custFormInfo.AppOrgMan != "" {
syncSeting.Add(1)
go jwtIsTrue.JwtOrgViewsIsTrue(custFormInfo.OrgPermit, userCont.AdminOrg)
}
if custFormInfo.AppManager != "" {
userKey := strconv.FormatInt(userCont.Key, 10)
syncSeting.Add(1)
go jwtIsTrue.JwtPeopleViewsIsTrue(custFormInfo.AppManager, userKey)
}
syncSeting.Wait()
if jwtIsTrue.Role || jwtIsTrue.Org || jwtIsTrue.People {
publicmethod.Result(0, true, c)
return
} else {
publicmethod.Result(0, false, c)
return
}
} else {
//可见范围
var jwtIsTrue TreeJwtPower
if custFormInfo.PostPermit != "" {
syncSeting.Add(1)
go jwtIsTrue.JwtRoleViewsIsTrue(custFormInfo.PostPermit, userCont.Role)
}
if custFormInfo.OrgPermit != "" {
syncSeting.Add(1)
go jwtIsTrue.JwtOrgViewsIsTrue(custFormInfo.OrgPermit, userCont.AdminOrg)
}
if custFormInfo.UserPermit != "" {
userKey := strconv.FormatInt(userCont.Key, 10)
syncSeting.Add(1)
go jwtIsTrue.JwtPeopleViewsIsTrue(custFormInfo.UserPermit, userKey)
}
syncSeting.Wait()
if jwtIsTrue.Role || jwtIsTrue.Org || jwtIsTrue.People {
publicmethod.Result(0, true, c)
return
} else {
publicmethod.Result(0, false, c)
return
}
}
}
/*
*
@ 作者: 秦东
@ 时间: 2024-05-30 08:10:32
@ 功能: 使用人鉴权
@ 参数
#jwpUser 使用人员
#userKEy 个人权限
@ 返回值
#
@ 方法原型
#
*/
func (t *TreeJwtPower) JwtPeopleViewsIsTrue(jwpUser, userKEy string) {
defer syncSeting.Done()
if jwpUser == "" {
t.People = true
} else {
if userKEy == "" {
t.People = false
} else {
jwtRoleAry := strings.Split(jwpUser, ",")
if publicmethod.IsInTrue[string](userKEy, jwtRoleAry) {
t.People = true
} else {
t.People = false
}
}
}
}
/*
*
@ 作者: 秦东
@ 时间: 2024-05-30 08:24:55
@ 功能: 鉴定行政组织授权
@ 参数
#jwpRoel 应用行政组织
#userRole 个人行政组织
@ 返回值
#
@ 方法原型
#
*/
func (t *TreeJwtPower) JwtOrgViewsIsTrue(jwpOrg string, userOrg int64) {
if jwpOrg == "" {
t.Org = true
} else {
if userOrg == 0 {
t.Org = false
} else {
var allOrg []int64
jwtOrgAry := strings.Split(jwpOrg, ",")
for _, v := range jwtOrgAry {
orgId, _ := strconv.ParseInt(v, 10, 64)
var sunOrg publicmethod.GetOrgAllParent
sunOrg.GetOrgSonAllId(orgId)
allOrg = append(allOrg, orgId)
allOrg = append(allOrg, sunOrg.Id...)
}
if publicmethod.IsInTrue[int64](userOrg, allOrg) {
t.Org = true
} else {
t.Org = false
}
}
}
}
/*
*
@ 作者: 秦东
@ 时间: 2024-05-30 08:10:32
@ 功能: 角色鉴权
@ 参数
#jwpRoel 应用权限
#userRole 个人权限
@ 返回值
#
@ 方法原型
#
*/
func (t *TreeJwtPower) JwtRoleViewsIsTrue(jwpRoel, userRole string) {
defer syncSeting.Done()
if jwpRoel == "" {
t.Role = true
} else {
if userRole == "" {
t.Role = false
} else {
jwtRoleAry := strings.Split(jwpRoel, ",")
userRoleAry := strings.Split(userRole, ",")
t.Role = false
for _, v := range userRoleAry {
if publicmethod.IsInTrue[string](v, jwtRoleAry) {
t.Role = true
}
}
}
}
}

179
api/version1/customerApp/type.go

@ -0,0 +1,179 @@
package customerApp
import (
"appPlatform/api/version1/publicapi"
"appPlatform/models/modelAppPlatform"
"appPlatform/overall/publicmethod"
"sync"
"github.com/gin-gonic/gin"
)
// 协程设置
var syncSeting = sync.WaitGroup{}
type ApiMethod struct{}
/*
*
@ 作者: 秦东
@ 时间: 2024-04-23 10:09:05
@ 功能: 自定义App入口
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) Index(c *gin.Context) {
outputCont := publicmethod.MapOut[string]()
outputCont["index"] = "自定义App入口"
publicmethod.Result(0, outputCont, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2024-04-23 13:40:21
@ 功能: App菜单树
*/
type AppMenuTree struct {
Id string `json:"id"`
Label string `json:"label"`
Types int `json:"type"`
Svg string `json:"svg" `
PcIsShow int `json:"pcIsShow"`
WapIsShow int `json:"wapIsShow"`
Parent string `json:"parent"`
Appkey string `json:"appkey"`
IsLock int `json:"isLock"`
Sort int64 `json:"sort"`
State int `json:"state"`
IsMain int `json:"isMain"`
Children []AppMenuTree `json:"children"`
}
// app菜单参数
type AppMenuInfo struct {
publicmethod.PublicName
Appkey string `json:"appkey"`
Types int `json:"type"`
Group string `json:"group"`
}
// 接收菜单树'=
type AppMenuTreeSave struct {
publicmethod.PublicId
MenuTree []AppMenuTree `json:"menuTree"`
}
// 修改名称
type EditAppMenuNAme struct {
Id string `json:"id"`
Label string `json:"label"`
}
// 循环菜单树
type XunhuanMenuTree struct {
MenuTree []AppMenuTree `json:"menuTree"`
}
// 显示和隐藏App菜单项
type HideOrShowAppMenu struct {
Types int `json:"types"`
MenuInfo AppMenuTree `json:"menuInfo"`
}
// App表单通用参数
type AppFormPageInfo struct {
Types int `json:"type"` // 1表单 2列表 3:app 4:app表单
Name string `json:"name"` // 表单名称,用于在显示所有已创建的表单列表里显示
Source string `json:"source"` // 数据源允许在表单属性设置里修改的
Dict string `json:"dict"` //表单校正参数
Data string `json:"data"` //表单数据
JsonData string `json:"jsondata"` //json化表单数据
Classify int `json:"classify"` //分类1:表单;2:流程表单" 3:应用
}
// 添加App表单接收参数
type AddAppFormPageInfo struct {
AppKey string `json:"appKey"` //app标识符
GroupKey string `json:"groupKey"` //归属分组
MenuId string `json:"menuId"` //归属菜单
SignCode string `json:"appSignCode"` //表单唯一识别符号
AppFormPageInfo
}
// 编辑App表单接收参数
type EditAppFormPageInfo struct {
Id string `json:"id"` //App表单ID
Version string `json:"version"` //app表单版本Id
AppKey string `json:"appKey"` //app标识符
GroupKey string `json:"groupKey"` //归属分组
MenuId string `json:"menuId"` //归属菜单
SignCode string `json:"signCode"` //表单唯一识别符号
AppFormPageInfo
}
type LookCustomerFormInfo struct {
modelAppPlatform.CustomerFormView
States int `json:"states" gorm:"-"`
GroupKey string `json:"groupKey" gorm:"-"`
PermitList [][]int64 `json:"permit_list" gorm:"-"`
FormField []string `json:"formField" gorm:"-"`
}
// app基础设置参数
type AppSetupInfo struct {
publicmethod.PublicId
Title string `json:"title"`
GroupKey string `json:"groupKey"`
AppSvg string `json:"appSvg"`
Appdescribe string `json:"appdescribe"`
}
// 设置可见人员
type SetAppLookViews struct {
publicmethod.PublicId
OrgRoleUs []publicapi.UserOrgRole `json:"orgRoleUs"`
}
// app管理员这只是称呼
type AppAdminKey struct {
Key []string `json:"key"`
}
// 返回管理人员
type CallBackAppOrgRoleUs struct {
AppOrgMan []publicapi.UserOrgRole `json:"orgRoleUs"` //应用管理行政组织
AppRoleManager []publicapi.UserOrgRole `json:"appRoleManager"` //应用管理角色
AppManager []publicapi.UserOrgRole `json:"appManager"` //应用管理员
OrgPermit []publicapi.UserOrgRole `json:"orgPermit"` //授权范围可见行政组织
PostPermit []publicapi.UserOrgRole `json:"postPermit"` //授权范围可见角色
UserPermit []publicapi.UserOrgRole `json:"userPermit"` //授权范围可见人员
}
// 搜索应用下得表单
type SearchAppTable struct {
publicmethod.PublicId
publicmethod.PublicName
publicmethod.PagesTurn
}
// Jwt鉴权
type JwtPower struct {
publicmethod.PublicId
Types int `json:"types"` //1:可见范围;2:操作权限
}
// 三方鉴权
type TreeJwtPower struct {
Role bool
Org bool
People bool
}

67
api/version1/customerform/form.go

@ -83,6 +83,7 @@ func (a *ApiMethod) CustomerFormList(c *gin.Context) {
var versionInfo modelAppPlatform.CustomerFormVersion
versionInfo.GetCont(map[string]interface{}{"`status`": 1, "`tablekey`": v.TableNames}, "`id`")
formList[i].VersionId = strconv.FormatInt(versionInfo.Id, 10)
formList[i].SignCodeStr = strconv.FormatInt(v.SignCode, 10)
// sendList = append(sendList, sendCont)
}
publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(formList)), formList, c)
@ -133,20 +134,44 @@ func HaveCustomerFormCreaterUs(tableKey string) (userCont modelshr.PersonArchive
#
*/
func (a *ApiMethod) ProductionMarkOfCustomerForm(c *gin.Context) {
var requestData AppOrForm
c.ShouldBindJSON(&requestData)
formNAme := "customer_form"
switch requestData.Types {
case 1:
formNAme = "customer_form"
case 2:
formNAme = "app"
case 3:
formNAme = "app_form"
default:
formNAme = "customer_form"
}
uuid := publicmethod.GetUUid(1)
tableName := fmt.Sprintf("customer_form_%v", uuid)
tableName := fmt.Sprintf("%v_%v", formNAme, uuid)
for {
isTrue := overall.CONSTANT_DB_CustomerForm.Migrator().HasTable(tableName)
if !isTrue {
break
} else {
uuid = publicmethod.GetUUid(1)
tableName = fmt.Sprintf("customer_form_%v", uuid)
tableName = fmt.Sprintf("%v_%v", formNAme, uuid)
}
}
var sendCont SendCustomerFormConfig
sendCont.FormName = fmt.Sprintf("未命名表单_%v", uuid)
switch requestData.Types {
case 1:
sendCont.FormName = fmt.Sprintf("未命名表单_%v", uuid)
case 2:
sendCont.FormName = fmt.Sprintf("未命名App_%v", uuid)
case 3:
sendCont.FormName = fmt.Sprintf("未命名App表单_%v", uuid)
default:
sendCont.FormName = fmt.Sprintf("未命名表单_%v", uuid)
}
sendCont.FormLogo = tableName
sendCont.SignCode = strconv.FormatInt(uuid, 10)
publicmethod.Result(0, sendCont, c)
}
@ -356,6 +381,34 @@ func (a *ApiMethod) LookCustomerForm(c *gin.Context) {
sendCont.Icon = customerFormCont.Icon
sendCont.FlowIsOpen = customerFormCont.FlowIsOpen
json.Unmarshal([]byte(customerFormCont.Permit), &sendCont.PermitList)
if formVersion.TableKey != "" {
masterFieldAry, mastErr := ReadDatabaseForm(formVersion.TableKey)
if mastErr == nil {
for _, v := range masterFieldAry {
if !publicmethod.IsInTrue[string](v.Field, sendCont.FormField) {
sendCont.FormField = append(sendCont.FormField, v.Field)
}
}
}
}
if formVersion.TableStructure != "" {
var sunTable map[string]string
err = json.Unmarshal([]byte(formVersion.TableStructure), &sunTable)
if err == nil {
for _, v := range sunTable {
sonFieldAry, sunErr := ReadDatabaseForm(v)
if sunErr == nil {
for _, v := range sonFieldAry {
if !publicmethod.IsInTrue[string](v.Field, sendCont.FormField) {
sendCont.FormField = append(sendCont.FormField, v.Field)
}
}
}
}
}
}
publicmethod.Result(0, sendCont, c)
}
@ -440,8 +493,14 @@ func (a *ApiMethod) HaveCustomerFormVersion(c *gin.Context) {
publicmethod.Result(1, err, c, "未知设置数据!请检查!")
return
}
var list []modelAppPlatform.CustomerFormVersion
var list []SendVersionCont
overall.CONSTANT_DB_AppPlatform.Where("`tablekey` = ? AND `status` BETWEEN ? AND ?", requestData.Id, 1, 2).Find(&list)
for i, v := range list {
list[i].CreaterTimeStr = publicmethod.UnixTimeToDay(v.CreaterTime, 24)
var userCont modelshr.PersonArchives
userCont.GetCont(map[string]interface{}{"`key`": v.Creater}, "`name`")
list[i].CreaterName = userCont.Name
}
publicmethod.Result(0, list, c)
}

206
api/version1/customerform/formTable.go

@ -599,7 +599,7 @@ func (a *ApiMethod) GainTableField(c *gin.Context) {
return
}
var customerFormMaster modelAppPlatform.CustomerFormView
err = customerFormMaster.GetCont(map[string]interface{}{"`cfid`": requestData.Id, "`status`": 1}, "`tablekey`", "`table_structure`", "`mastesform`", "`mastesformjson`")
err = customerFormMaster.GetCont(map[string]interface{}{"`cfid`": requestData.Id, "`status`": 1}, "`tablekey`", "`table_structure`", "`mastesform`", "`mastesformjson`", "`name`")
if err != nil {
publicmethod.Result(1, err, c, "未知表单!无法获取字段!")
return
@ -611,6 +611,7 @@ func (a *ApiMethod) GainTableField(c *gin.Context) {
return
}
sendTableList := publicmethod.MapOut[string]()
sendTableList["masterTableName"] = customerFormMaster.Name
sendTableList["masterTable"] = masterTable
if customerFormMaster.TableStructure != "" { //判断是否有主体子表单
var sunTable map[string]interface{}
@ -774,7 +775,8 @@ func TableFieldCompare(tableFieldList []Result, jsonFieldList []FormFieldInfo) (
fieldInfo.ActiveValue = jv.ActiveValue //activeValue"`
fieldInfo.InactiveValue = jv.InactiveValue //inactiveValue"`
fieldInfo.Options = jv.Options //options"`
fieldInfo.Control = jv.Control //control"`
fieldInfo.Config = jv.Config //config"`
fieldList = append(fieldList, fieldInfo)
}
}
@ -837,7 +839,6 @@ func TableFieldCompare(tableFieldList []Result, jsonFieldList []FormFieldInfo) (
if len(patternInfo) >= 1 {
fieldInfo.Pattern = patternInfo[0]
}
// fieldInfo.FieldClass = v. //fieldClass"`
// fieldInfo.ActiveValue = v. //activeValue"`
// fieldInfo.InactiveValue = v. //inactiveValue"`
@ -884,7 +885,9 @@ func GainFormTableField(formTableName string) (fieldList []Result, err error) {
fieldList[i].Type = attFiled[0]
}
if v.Field == "id" {
fieldList[i].Comment = "Id"
}
patternInfo := strings.Split(v.Type, "(")
if len(patternInfo) >= 1 {
fieldList[i].Pattern = patternInfo[0]
@ -962,6 +965,7 @@ func (f *FormJsonFieldInfo) AnalyzingFormJson(tableName string, unitList []inter
}
// fmt.Printf("unitList---->%T====>%v\n", listInfo["control"], listInfo["control"])
if controlVal, ok := listInfo["control"]; ok {
// fmt.Printf("unitList--123-->%T====>%v\n", controlVal, controlVal)
if controlMap, ok := controlVal.(map[string]interface{}); ok {
if activeVal, ok := controlMap["activeValue"]; ok {
if activeValStr, ok := activeVal.(string); ok {
@ -973,6 +977,41 @@ func (f *FormJsonFieldInfo) AnalyzingFormJson(tableName string, unitList []inter
unitInfo.InactiveValue = InactiveValStr
}
}
// fmt.Printf("unitList--5656-->%T====>%v\n", controlMap["optionsValue3Formid"], controlMap["optionsValue3Formid"])
// fmt.Printf("unitList--7788-->%T====>%v\n", controlMap["optionsValue3Field"], controlMap["optionsValue3Field"])
if optValId, ok := controlMap["optionsValue3Formid"]; ok {
// fmt.Printf("optValId:%v\n", optValId)
// fmt.Printf("optValId--5656-->%T====>%v\n", optValId, optValId)
if optValIdStr, ok := optValId.(string); ok {
unitInfo.Control.OptionsValue3Formid = optValIdStr
}
// unitInfo.Control.OptionsValue3Formid = optValId
// controlMap["optionsValue3Formid"] = optValId
}
if optValField, ok := controlMap["optionsValue3Field"]; ok {
// fmt.Printf("optValField:%v\n", optValField)
// fmt.Printf("optValField--5656-->%T====>%v\n", optValField, optValField)
if optValFieldStr, ok := optValField.(string); ok {
unitInfo.Control.OptionsValue3Field = optValFieldStr
}
// controlMap["optionsValue3Field"] = optValField
// unitInfo.Control.OptionsValue3Field = optValField
}
}
// unitInfo.Control.OptionsValue3Field = "254f6sdf46"
}
if configVal, ok := listInfo["config"]; ok {
if configMap, ok := configVal.(map[string]interface{}); ok {
if configMApVal, ok := configMap["optionsType"]; ok {
fmt.Printf("optvMap---->%T====>%v\n", configMApVal, configMApVal)
if configMApValStr, ok := configMApVal.(float64); ok {
unitInfo.Config.OptionsType = configMApValStr
}
}
}
}
if optionsVal, ok := listInfo["options"]; ok {
@ -981,7 +1020,7 @@ func (f *FormJsonFieldInfo) AnalyzingFormJson(tableName string, unitList []inter
if optvMap, ok := optv.(map[string]interface{}); ok {
var optInfo OptionsInfo
fmt.Printf("optvMap---->%T====>%v\n", optvMap["label"], optvMap["label"])
// fmt.Printf("optvMap---->%T====>%v\n", optvMap["label"], optvMap["label"])
if labelVal, ok := optvMap["label"]; ok {
if labelValStr, ok := labelVal.(string); ok {
optInfo.Label = labelValStr
@ -999,6 +1038,8 @@ func (f *FormJsonFieldInfo) AnalyzingFormJson(tableName string, unitList []inter
}
}
fieldInfo = append(fieldInfo, unitInfo)
fmt.Printf("unitInfo--1->:%v\n", unitInfo)
fmt.Printf("fieldInfo-2->:%v\n", fieldInfo)
}
}
}
@ -1152,6 +1193,9 @@ func (a *ApiMethod) GainFormPageListCont(c *gin.Context) {
if requestData.PageSize == 0 {
requestData.Page = 20
}
context, _ := c.Get(overall.MyContJwt)
var userCont modelshr.ManCont
userCont.GetLoginCont(context) //当前操作人
var formInfo modelAppPlatform.CustomerFormView
err = formInfo.GetCont(map[string]interface{}{"`cfid`": requestData.FormId, "`status`": 1}, "`tablekey`", "`table_structure`", "`mastesform`", "`mastesformjson`", "`listjson`", "`flowIsOpen`", "`flowkey`")
if err != nil {
@ -1163,12 +1207,14 @@ func (a *ApiMethod) GainFormPageListCont(c *gin.Context) {
var formList []map[string]interface{}
// gormDb := overall.CONSTANT_DB_CustomerForm.Table(formInfo.TableKey)
tableName := fmt.Sprintf("`%v` as f", formInfo.TableKey)
gormDb := overall.CONSTANT_DB_CustomerForm.Table(tableName).Select("f.*,t.status as taskStatus")
gormDb := overall.CONSTANT_DB_CustomerForm.Table(tableName).Select("f.*,t.status as taskStatus,t.runFlowId")
// if err == nil {
// gormDb = gormDb.Where(why)
// }
gormDb = gormDb.Joins("LEFT JOIN `taskrecord` as t ON f.masters_key = t.masters_key")
gormDb = gormDb.Where("`states` BETWEEN ? AND ?", 1, 2)
gormDb = gormDb.Where("f.`creater` = ? ", userCont.Key)
gormDb = gormDb.Where("f.`states` BETWEEN ? AND ?", 1, 2)
gormDb = AnalysisSerachTermSql(requestData.SearchData, gormDb)
var total int64
totalErr := gormDb.Count(&total).Error
@ -1177,7 +1223,7 @@ func (a *ApiMethod) GainFormPageListCont(c *gin.Context) {
}
gormDb = publicmethod.PageTurningSettings(gormDb, requestData.Page, requestData.PageSize)
err = gormDb.Order("`id` DESC").Find(&formList).Error
err = gormDb.Order("f.`id` DESC").Find(&formList).Error
if err != nil && len(formList) < 1 {
publicmethod.Result(0, err, c)
return
@ -1197,22 +1243,21 @@ func (a *ApiMethod) GainFormPageListCont(c *gin.Context) {
}
}
context, _ := c.Get(overall.MyContJwt)
var userCont modelshr.ManCont
userCont.GetLoginCont(context) //当前操作人
//获取任务状态
for i, v := range formList {
formList[i]["isRetract"] = false
if mastrKey, ok := v["masters_key"]; ok {
if mastrKey, ok := v["runFlowId"]; ok {
// fmt.Printf("masters_key----------->%v\n", v["masters_key"])
var runFlowInfo customerForm.RunWorkflow
runFlowInfo.GetCont(map[string]interface{}{"`flow_key`": mastrKey}, "`current_step`", "`next_step`")
runFlowInfo.GetCont(map[string]interface{}{"`id`": mastrKey}, "`id`", "`current_step`", "`next_step`")
formList[i]["runFlowInfo"] = runFlowInfo.Id
// fmt.Printf("runFlowInfo----------->%v--------->%v\n", runFlowInfo, v["taskStatus"])
if stateVal, ok := v["taskStatus"]; ok {
// fmt.Printf("NextStep----------->%T----------->%v--------->%v--------->%v\n", stateVal, stateVal, runFlowInfo.NextStep, runFlowInfo.CurrentStep)
if stauval, ok := stateVal.(string); ok {
if stauval == "3" && runFlowInfo.NextStep != 0 {
// fmt.Printf("IsRetract----------->%T----------->%v----------->%v\n", formList[i]["creater"], formList[i]["creater"], userCont.Name)
if runFlowInfo.CurrentStep == 1 {
if createrName, ok := formList[i]["creater"].(string); ok {
if createrName == userCont.Name {
@ -1226,7 +1271,12 @@ func (a *ApiMethod) GainFormPageListCont(c *gin.Context) {
}
}
if mastrKeyVal, ok := v["masters_key"]; ok {
// fmt.Printf("mastrKeyVal----------->%T----------->%v\n", mastrKeyVal, mastrKeyVal)
if mastrKeyUint64, ok := mastrKeyVal.(uint64); ok {
formList[i]["masters_key"] = strconv.FormatUint(mastrKeyUint64, 10)
}
}
}
// publicmethod.Result(100, formList, c)
@ -1244,7 +1294,7 @@ func (l *ListPageFields) DevelopSpecificationsSend(listData []map[string]interfa
for _, v := range listData {
sendInfo := publicmethod.MapOut[string]()
for mi, mv := range v {
// fmt.Printf("%v = %v\n", mi, mv)
fmt.Printf("%v = %v\n", mi, mv)
switch mi {
case "creater":
var myInfo modelshr.PersonArchives
@ -1373,16 +1423,134 @@ func AnalysisSerachTermSql(why string, gormDb *gorm.DB) *gorm.DB {
if v.Values != nil && v.Values != "" && v.Values != "" {
switch v.Pattern {
case "int":
likeSql := fmt.Sprintf("`%v` = %v", v.Field, v.Values)
likeSql := fmt.Sprintf("f.`%v` = %v", v.Field, v.Values)
gormDb = gormDb.Where(likeSql)
case "bigint":
likeSql := fmt.Sprintf("`%v` = %v", v.Field, v.Values)
likeSql := fmt.Sprintf("f.`%v` = %v", v.Field, v.Values)
gormDb = gormDb.Where(likeSql)
default:
likeSql := fmt.Sprintf("%v LIKE %v%v%v", v.Field, "'%", v.Values, "%'")
likeSql := fmt.Sprintf("f.%v LIKE %v%v%v", v.Field, "'%", v.Values, "%'")
gormDb = gormDb.Where(likeSql)
}
}
}
return gormDb
}
/*
*
@ 作者: 秦东
@ 时间: 2024-07-06 13:42:03
@ 功能: 列表展示需要字段
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) GainListTableField(c *gin.Context) {
var requestData publicmethod.PublicId
err := c.ShouldBindJSON(&requestData)
if err != nil {
publicmethod.Result(100, err, c)
return
}
if requestData.Id == "" {
publicmethod.Result(1, err, c, "未知表单!无法获取字段!")
return
}
var customerFormMaster modelAppPlatform.CustomerFormView
err = customerFormMaster.GetCont(map[string]interface{}{"`cfid`": requestData.Id, "`status`": 1}, "`tablekey`", "`table_structure`", "`mastesform`", "`mastesformjson`", "`name`")
if err != nil {
publicmethod.Result(1, err, c, "未知表单!无法获取字段!")
return
}
masterTable, err := GainFormTableField(customerFormMaster.TableKey)
if err != nil {
publicmethod.Result(1, err, c, "未知表单!无法获取字段!")
return
}
sendTableList := publicmethod.MapOut[string]()
// sendTableList["masterTableName"] = customerFormMaster.Name
// sendTableList["masterTable"] = masterTable
if customerFormMaster.TableStructure != "" { //判断是否有主体子表单
var sunTable map[string]interface{}
err = json.Unmarshal([]byte(customerFormMaster.TableStructure), &sunTable)
if err == nil {
sunTableMap := publicmethod.MapOut[string]()
for _, v := range sunTable { //遍历子表单名称
if vStr, ok := v.(string); ok {
sunTableMap[vStr], err = GainFormTableField(vStr)
}
}
// sendTableList["sunTable"] = sunTableMap
}
}
var unitCont map[string]interface{}
json.Unmarshal([]byte(customerFormMaster.MastesFormJson), &unitCont)
var formFieldAry FormJsonFieldInfo
if list, ok := unitCont["list"]; ok {
if listAry, ok := list.([]interface{}); ok {
formFieldAry.AnalyzingFormJson("", listAry)
}
}
var allKeyWords []ViewListMode
var mapKeyWords []ViewListMode
var cardKeyWords []ViewListMode
var timeKeyWords []ViewListMode
sendTableList["isMap"] = false
sendTableList["isCard"] = false
for _, v := range masterTable {
var keyWords ViewListMode
keyWords.Label = v.Comment
if v.Field == "id" {
keyWords.Label = "Id"
}
keyWords.Value = v.Field
allKeyWords = append(allKeyWords, keyWords)
if v.Field == "creater_time" || v.Field == "edit_time" {
timeKeyWords = append(timeKeyWords, keyWords)
}
}
for _, fv := range formFieldAry.MasterInfo {
if publicmethod.IsInTrue(fv.FieldClass, []string{"datePicker", "timePicker"}) {
var keyWordsTime ViewListMode
keyWordsTime.Label = fv.Label
keyWordsTime.Value = fv.Id
timeKeyWords = append(timeKeyWords, keyWordsTime)
}
if publicmethod.IsInTrue(fv.FieldClass, []string{"baidumap"}) {
var keyWordsMap ViewListMode
keyWordsMap.Label = fv.Label
keyWordsMap.Value = fv.Id
mapKeyWords = append(mapKeyWords, keyWordsMap)
sendTableList["isMap"] = true
}
if publicmethod.IsInTrue(fv.FieldClass, []string{"lowcodeImage"}) {
var keyWordsMap ViewListMode
keyWordsMap.Label = fv.Label
keyWordsMap.Value = fv.Id
cardKeyWords = append(cardKeyWords, keyWordsMap)
sendTableList["isCard"] = true
}
}
sendTableList["allKeyWords"] = allKeyWords
sendTableList["mapKeyWords"] = mapKeyWords
sendTableList["timeKeyWords"] = timeKeyWords
sendTableList["cardKeyWords"] = cardKeyWords
publicmethod.Result(0, sendTableList, c)
}

819
api/version1/customerform/formTableView.go

@ -0,0 +1,819 @@
package customerform
import (
"appPlatform/models/customerForm"
"appPlatform/models/modelAppPlatform"
"appPlatform/models/modelshr"
"appPlatform/overall"
"appPlatform/overall/publicmethod"
"encoding/json"
"fmt"
"strconv"
"strings"
"github.com/gin-gonic/gin"
"gorm.io/gorm"
)
/*
*
@ 作者: 秦东
@ 时间: 2024-07-08 15:41:37
@ 功能: 多视图数据处理
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) MultiViewPAge(c *gin.Context) {
var requestData ViewListSearch
c.ShouldBindJSON(&requestData)
if requestData.FormId == "" {
publicmethod.Result(1, requestData, c, "未知表单!无法获取字段!2")
return
}
if requestData.Page == 0 {
requestData.Page = 1
}
if requestData.PageSize == 0 {
requestData.Page = 20
}
context, _ := c.Get(overall.MyContJwt)
var userCont modelshr.ManCont
userCont.GetLoginCont(context) //当前操作人
var formInfo modelAppPlatform.CustomerFormView
err := formInfo.GetCont(map[string]interface{}{"`cfid`": requestData.FormId, "`status`": 1}, "`tablekey`", "`table_structure`", "`mastesform`", "`mastesformjson`", "`listjson`", "`flowIsOpen`", "`flowkey`")
if err != nil {
publicmethod.Result(1, err, c, "未知表单!无法获取字段!")
return
}
var formList []map[string]interface{}
sendListInfo := publicmethod.MapOut[string]()
var sendTimeList []interface{}
tableName := fmt.Sprintf("`%v` as f", formInfo.TableKey)
gormDb := overall.CONSTANT_DB_CustomerForm.Table(tableName).Select("f.*,t.status as taskStatus,t.runFlowId")
gormDb = gormDb.Joins("LEFT JOIN `taskrecord` as t ON f.masters_key = t.masters_key")
gormDb = gormDb.Where("f.`creater` = ? ", userCont.Key)
gormDb = gormDb.Where("f.`states` BETWEEN ? AND ?", 1, 2)
gormDb = AnalysisSerachTermSql(requestData.SearchData, gormDb)
var total int64
totalErr := gormDb.Count(&total).Error
if totalErr != nil {
total = 0
}
gormDb = publicmethod.PageTurningSettings(gormDb, requestData.Page, requestData.PageSize)
switch requestData.ViewClass.Class {
case "date":
gormDb = gormDb.Order("`id` DESC")
case "time":
if requestData.ViewClass.SortWord != "" {
if requestData.ViewClass.Sort == 1 {
gormDb = gormDb.Order(fmt.Sprintf("`%v` DESC", requestData.ViewClass.SortWord))
} else {
gormDb = gormDb.Order(fmt.Sprintf("`%v` ASC", requestData.ViewClass.SortWord))
}
} else {
if requestData.ViewClass.Sort == 1 {
gormDb = gormDb.Order("`id` DESC")
} else {
gormDb = gormDb.Order("`id` ASC")
}
}
case "gantt":
if requestData.ViewClass.SortWord != "" {
if requestData.ViewClass.Sort == 1 {
gormDb = gormDb.Order(fmt.Sprintf("`%v` DESC", requestData.ViewClass.SortWord))
} else {
gormDb = gormDb.Order(fmt.Sprintf("`%v` ASC", requestData.ViewClass.SortWord))
}
} else {
if requestData.ViewClass.Sort == 1 {
gormDb = gormDb.Order("`id` DESC")
} else {
gormDb = gormDb.Order("`id` ASC")
}
}
case "map":
if requestData.ViewClass.SortWord != "" {
if requestData.ViewClass.Sort == 1 {
gormDb = gormDb.Order(fmt.Sprintf("`%v` DESC", requestData.ViewClass.SortWord))
} else {
gormDb = gormDb.Order(fmt.Sprintf("`%v` ASC", requestData.ViewClass.SortWord))
}
} else {
if requestData.ViewClass.Sort == 1 {
gormDb = gormDb.Order("`id` DESC")
} else {
gormDb = gormDb.Order("`id` ASC")
}
}
default:
gormDb = gormDb.Order("`id` DESC")
}
err = gormDb.Find(&formList).Error
if err != nil && len(formList) < 1 {
publicmethod.Result(0, err, c)
return
}
// pageMyTola := len()
// fmt.Printf("列表数据解析---1->%v\n", formInfo.ListJson)
//获取任务状态
for i, v := range formList {
formList[i]["isRetract"] = false
if mastrKey, ok := v["runFlowId"]; ok {
// fmt.Printf("masters_key----------->%v\n", v["masters_key"])
var runFlowInfo customerForm.RunWorkflow
runFlowInfo.GetCont(map[string]interface{}{"`id`": mastrKey}, "`id`", "`current_step`", "`next_step`")
formList[i]["runFlowInfo"] = strconv.FormatInt(runFlowInfo.Id, 10)
formList[i]["runFlowId"] = strconv.FormatInt(runFlowInfo.Id, 10)
// fmt.Printf("runFlowInfo----------->%v--------->%v\n", runFlowInfo, v["taskStatus"])
if stateVal, ok := v["taskStatus"]; ok {
// fmt.Printf("NextStep----------->%T----------->%v--------->%v--------->%v\n", stateVal, stateVal, runFlowInfo.NextStep, runFlowInfo.CurrentStep)
if stauval, ok := stateVal.(string); ok {
if stauval == "3" && runFlowInfo.NextStep != 0 {
if runFlowInfo.CurrentStep == 1 {
if createrName, ok := formList[i]["creater"].(string); ok {
if createrName == userCont.Name {
formList[i]["isRetract"] = true
}
}
}
}
}
}
}
if mastrKeyVal, ok := v["masters_key"]; ok {
// fmt.Printf("mastrKeyVal----------->%T----------->%v\n", mastrKeyVal, mastrKeyVal)
if mastrKeyUint64, ok := mastrKeyVal.(uint64); ok {
formList[i]["masters_key"] = strconv.FormatUint(mastrKeyUint64, 10)
}
}
}
if requestData.OlaData != "" {
var oldDataAry interface{}
err = json.Unmarshal([]byte(requestData.OlaData), &oldDataAry)
if err == nil {
if oldVal, ok := oldDataAry.([]interface{}); ok {
var oldList []map[string]interface{}
for _, v := range oldVal {
if mv, mvOk := v.(map[string]interface{}); mvOk {
if mvla, isOk := mv["class_type$unit"]; isOk {
timeInt, _ := publicmethod.StringToInt64(mvla)
if timeInt != 1 {
oldInfo := publicmethod.MapOut[string]()
for key, val := range mv {
if key != "class_type$unit" {
oldInfo[key] = val
}
if key == "creater_time" {
// creTime, _ := publicmethod.StringToInt64(mvla)
// oldInfo[key] =
if sVal, isTrue := val.(string); isTrue {
var creTimeAll publicmethod.DateTimeTotimes
creTimeAll.BaisStrToTime(sVal)
creTime, _ := publicmethod.StringToInt64(creTimeAll.AllTime)
oldInfo[key] = creTime
}
// fmt.Printf("formList----> %T----> %v\n", val, val)
}
if key == "edit_time" {
if sVal, isTrue := val.(string); isTrue {
var creTimeAll publicmethod.DateTimeTotimes
creTimeAll.BaisStrToTime(sVal)
creTime, _ := publicmethod.StringToInt64(creTimeAll.AllTime)
oldInfo[key] = creTime
}
}
}
oldList = append(oldList, oldInfo)
}
}
}
}
// fmt.Printf("mvla----> %T----> %v\n", oldList, oldList)
if len(oldList) > 0 {
oldList = append(oldList, formList...)
formList = oldList
}
}
}
}
// fmt.Printf("formList----> %v----> %v\n", len(formList), formList)
if formInfo.ListJson != "" {
var listFieldsMap ListPageFields
err = json.Unmarshal([]byte(formInfo.ListJson), &listFieldsMap)
// fmt.Printf("列表数据解析---->%v\n", err)
if err == nil {
lik, formListAry, dayAry := listFieldsMap.TimeViewWordHandle(formList, requestData.ViewClass)
// timeAry := publicmethod.MapOut[string]()
sendListInfo["listInfo"] = formListAry
sendListInfo["dayList"] = dayAry
sendListInfo["lik"] = lik
for _, lv := range lik {
if len(lv.List) > 0 {
for _, lvlv := range lv.List {
sendTimeList = append(sendTimeList, lvlv)
}
// sendTimeList = append(sendTimeList, lv)
}
}
// formList = appenlikd(formList, timeAry)
}
}
publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(formList)), sendTimeList, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2024-07-09 08:57:05
@ 功能: 时间轴视图数据输出
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (l *ListPageFields) TimeViewWordHandle(listData []map[string]interface{}, viewCalss ViewKeyType) ([]TimeFenGe, []map[string]interface{}, []string) {
// fmt.Printf("TimeViewWordHandle:%v------------>%v\n", len(listData), listData)
var sendList []map[string]interface{}
var dayAry []string
var lik []TimeFenGe
switch viewCalss.Class {
case "date":
case "time":
_, _, listTime := l.GainStartOrEndTime(listData, viewCalss)
lik = listTime
// startTime := int64(0)
// endTime := int64(0)
// sendInfo := publicmethod.MapOut[string]()
// for _, lv := range listData {
// for mi, mv := range lv {
// if mi == viewCalss.SortWord {
// mvInt, _ := publicmethod.StringToInt64(mv)
// if startTime == 0 && endTime == 0 {
// startTime = mvInt
// endTime = mvInt
// } else {
// if startTime <= mvInt {
// startTime = mvInt
// }
// if endTime >= mvInt {
// endTime = mvInt
// }
// }
// }
// }
// }
// jsondd, _ := json.Marshal(listTime)
// fmt.Printf("猎头结果:%v================%v================%v\n", len(listTime), string(jsondd), listTime)
for _, v := range listTime {
if len(v.List) > 0 {
info := publicmethod.MapOut[string]()
info[v.DateTime] = v.List
sendList = append(sendList, info)
dayAry = append(dayAry, v.DateTime)
// for _, lv := range v.List {
// sendList = append(sendList, lv)
// }
}
}
// sendList = listTime
case "gantt":
case "map":
default:
sendList = l.DevelopSpecificationsSend(listData)
}
// fmt.Printf("获取起止时间--->%v---->%v\n", len(lik), lik)
return lik, sendList, dayAry
}
/*
*
@ 作者: 秦东
@ 时间: 2024-07-09 10:14:44
@ 功能: 获取起止时间
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (l *ListPageFields) GainStartOrEndTime(listData []map[string]interface{}, viewCalss ViewKeyType) (startTime, endTime int64, sendTime []TimeFenGe) {
for _, lv := range listData {
for mi, mv := range lv {
if mi == viewCalss.SortWord {
mvInt, _ := publicmethod.StringToInt64(mv)
if startTime == 0 && endTime == 0 {
startTime = mvInt
endTime = mvInt
} else {
if startTime <= mvInt {
startTime = mvInt
}
if endTime >= mvInt {
endTime = mvInt
}
}
}
}
}
tianShu, _ := publicmethod.DayBetweenDate(publicmethod.UnixTimeToDay(startTime, 14), publicmethod.UnixTimeToDay(endTime, 14))
fmt.Printf("天数: %v\n", tianShu)
if viewCalss.Sort == 1 {
beginTime := publicmethod.TimeUnixToTime(startTime, "s")
for i := 0; i <= tianShu; i++ {
yesterday := beginTime.AddDate(0, 0, -i)
var timeInfo TimeFenGe
riqi := publicmethod.UnixTimeToDay(yesterday.Unix(), 14)
timeInfo.DateTime = riqi
timeInfo.WeekDay, _ = publicmethod.GetWeekday(riqi)
timeInfo.Day = publicmethod.UnixTimeToDay(yesterday.Unix(), 18)
timeInfo.Stor = i
timeInfo.TimeUnix = yesterday.Unix()
begin, end := publicmethod.TimeUnixDayStartAndEnd(yesterday.Unix())
timeInfo.StartAndEnd.Start = begin
timeInfo.StartAndEnd.End = end
listAry := l.DaBaoShuJu(viewCalss.SortWord, begin, end, listData)
if len(listAry) > 0 {
gd := make(map[string]interface{})
gd["dateTime"] = publicmethod.UnixTimeToDay(yesterday.Unix(), 40)
gd["weekDay"], _ = publicmethod.GetWeekday(riqi)
gd["day"] = publicmethod.UnixTimeToDay(yesterday.Unix(), 18)
gd["class_type$unit"] = 1
timeInfo.List = append(timeInfo.List, gd)
timeInfo.List = append(timeInfo.List, listAry...)
} else {
timeInfo.List = l.DaBaoShuJu(viewCalss.SortWord, begin, end, listData)
}
// DaBaoShuJu(riqi, viewCalss.SortWord, begin, end, listData)
sendTime = append(sendTime, timeInfo)
}
} else {
beginTime := publicmethod.TimeUnixToTime(endTime, "s")
for i := 0; i <= tianShu; i++ {
yesterday := beginTime.AddDate(0, 0, -i)
var timeInfo TimeFenGe
riqi := publicmethod.UnixTimeToDay(yesterday.Unix(), 14)
timeInfo.DateTime = riqi
timeInfo.WeekDay, _ = publicmethod.GetWeekday(riqi)
timeInfo.Day = publicmethod.UnixTimeToDay(yesterday.Unix(), 18)
timeInfo.Stor = i
timeInfo.TimeUnix = yesterday.Unix()
begin, end := publicmethod.TimeUnixDayStartAndEnd(yesterday.Unix())
timeInfo.StartAndEnd.Start = begin
timeInfo.StartAndEnd.End = end
listAry := l.DaBaoShuJu(viewCalss.SortWord, begin, end, listData)
if len(listAry) > 0 {
gd := make(map[string]interface{})
gd["dateTime"] = publicmethod.UnixTimeToDay(yesterday.Unix(), 40)
gd["weekDay"], _ = publicmethod.GetWeekday(riqi)
gd["day"] = publicmethod.UnixTimeToDay(yesterday.Unix(), 18)
gd["class_type$unit"] = 1
timeInfo.List = append(timeInfo.List, gd)
timeInfo.List = append(timeInfo.List, listAry...)
} else {
timeInfo.List = l.DaBaoShuJu(viewCalss.SortWord, begin, end, listData)
}
// DaBaoShuJu(riqi, viewCalss.SortWord, begin, end, listData)
sendTime = append(sendTime, timeInfo)
}
}
return
}
/*
*
@ 作者: 秦东
@ 时间: 2024-07-09 11:39:52
@ 功能: 打包数据
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (l *ListPageFields) DaBaoShuJu(sortWord string, startTime, endTime int64, listData []map[string]interface{}) (sendData []interface{}) {
// fmt.Printf("打包--->%v\n", sortWord)
sc := make([]interface{}, 0)
for _, v := range listData {
if mv, ok := v[sortWord]; ok {
// fmt.Printf("打包--1->%v->%T\n", mv, mv)
idInt, _ := publicmethod.StringToInt64(mv)
// fmt.Printf("打包--1->%v->%T->%v->%T\n", mv, mv, idInt, idInt)
if idInt >= startTime && idInt <= endTime {
v[sortWord] = publicmethod.UnixTimeToDay(idInt, 11)
v["class_type$unit"] = 2
for mi, mv := range v {
switch mi {
case "creater":
if sortWord != "creater" {
var myInfo modelshr.PersonArchives
myInfo.GetCont(map[string]interface{}{"`key`": mv}, "`name`")
v[mi] = myInfo.Name
}
case "creater_time":
if sortWord != "creater_time" {
timeInt, _ := publicmethod.StringToInt64(mv)
v[mi] = publicmethod.UnixTimeToDay(timeInt, 11)
}
case "edit_time":
if sortWord != "edit_time" {
timeInt, _ := publicmethod.StringToInt64(mv)
v[mi] = publicmethod.UnixTimeToDay(timeInt, 11)
}
default:
_, v[mi] = l.BaseTableAttrViewField(mi, mv)
// sendInfo[mi] = publicmethod.TypeToInterface(mv)
}
}
sc = append(sc, v)
// sendData = append(sendData, sc)
}
}
}
if len(sc) > 0 {
// sendVal := publicmethod.MapOut[string]()
// sendVal[riqi] = sc
sendData = sc
}
return
}
/*
*
@ 作者: 秦东
@ 时间: 2024-04-02 08:14:10
@ 功能: 按照制定列表字段输出(视图)
*/
func (l *ListPageFields) DevelopSpecificViewSend(listData []map[string]interface{}) []map[string]interface{} {
var sendList []map[string]interface{}
for _, v := range listData {
sendInfo := publicmethod.MapOut[string]()
for mi, mv := range v {
fmt.Printf("%v = %v\n", mi, mv)
// switch mi {
// case "creater":
// var myInfo modelshr.PersonArchives
// myInfo.GetCont(map[string]interface{}{"`key`": mv}, "`name`")
// sendInfo["创建人"] = myInfo.Name
// case "creater_time":
// timeInt, _ := publicmethod.StringToInt64(mv)
// sendInfo["创建时间"] = publicmethod.UnixTimeToDay(timeInt, 27)
// case "edit_time":
// timeInt, _ := publicmethod.StringToInt64(mv)
// sendInfo["编辑时间"] = publicmethod.UnixTimeToDay(timeInt, 27)
// case "id":
// if idInt, ok := mv.(int64); ok {
// sendInfo["Id"] = strconv.FormatInt(idInt, 10)
// }
// idInt, _ := publicmethod.StringToInt64(mv)
// sendInfo["Id"] = idInt
// default:
// // sendInfo[mi] = l.BaseTableAttrField(mi, mv)
// key, val := l.BaseTableAttrViewField(mi, mv)
// if key != "" {
// sendInfo[key] = val
// }
// // sendInfo[mi] = publicmethod.TypeToInterface(mv)
// }
key, val := l.BaseTableAttrViewField(mi, mv)
if key != "" {
sendInfo[key] = val
}
}
// fmt.Printf("================================\n")
sendList = append(sendList, sendInfo)
}
return sendList
}
/*
*
@ 作者: 秦东
@ 时间: 2024-04-02 11:42:20
@ 功能: 根据字段显示格式处理数据(字段)
*/
func (l *ListPageFields) BaseTableAttrViewField(key string, val interface{}) (string, interface{}) {
// fmt.Printf("根据字段显示格式处理数据(字段):%v==1==>%v\n", key, len(l.TableData.Columns))
if len(l.TableData.Columns) < 0 {
return "", val
}
keyStr := ""
for _, v := range l.TableData.Columns {
// fmt.Printf("根据字段显示格式处理数据(字段):%v====>%v\n", key, v.Id)
if v.Id == key {
// fmt.Printf("根据字段显示格式处理数据(字段):%v\n", v.Label)
switch v.FieldClass {
case "checkbox":
if val != nil {
var checkboxStrAry []interface{}
var checkboxAry []string
if valStr, ok := val.(string); ok {
err := json.Unmarshal([]byte(valStr), &checkboxStrAry)
if err == nil {
for _, v := range checkboxStrAry {
checkboxAry = append(checkboxAry, publicmethod.TypeToInterface(v))
}
}
}
if len(checkboxAry) > 0 {
var jieGuo []string
for _, ov := range v.Options {
if publicmethod.IsInTrue[string](ov.Value, checkboxAry) {
jieGuo = append(jieGuo, ov.Label)
}
}
val = strings.Join(jieGuo, ",")
}
}
case "orgCentent":
var orgCont modelshr.AdministrativeOrganization
orgCont.GetCont(map[string]interface{}{"`id`": val}, "name")
return v.Label, orgCont.Name
case "baidumap":
var mapAry []string
if valStr, ok := val.(string); ok {
mapAry = strings.Split(valStr, "|*@*|")
}
if len(mapAry) > 0 {
return v.Label, mapAry[0]
}
default:
return v.Label, publicmethod.TypeToInterface(val)
}
}
}
return keyStr, val
}
/*
*
@ 作者: 秦东
@ 时间: 2024-07-16 14:02:42
@ 功能: 根据日期获取数据
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) GainCalendarList(c *gin.Context) {
var requestData CalendarSearch
c.ShouldBindJSON(&requestData)
if len(requestData.TimeAry) < 1 && len(requestData.TimeMonthAry) < 1 {
publicmethod.Result(1, requestData, c, "未知日期!无法获取字段!2")
return
}
if requestData.Search.FormId == "" {
publicmethod.Result(1, requestData, c, "未知表单!无法获取字段!")
return
}
if requestData.Search.Page == 0 {
requestData.Search.Page = 1
}
if requestData.Search.PageSize == 0 {
requestData.Search.Page = 20
}
var listField []SearchButtonInfo
json.Unmarshal([]byte(requestData.Search.SearchData), &listField)
context, _ := c.Get(overall.MyContJwt)
var userCont modelshr.ManCont
userCont.GetLoginCont(context) //当前操作人
var formInfo modelAppPlatform.CustomerFormView
err := formInfo.GetCont(map[string]interface{}{"`cfid`": requestData.Search.FormId, "`status`": 1}, "`tablekey`", "`table_structure`", "`mastesform`", "`mastesformjson`", "`listjson`", "`flowIsOpen`", "`flowkey`")
if err != nil {
publicmethod.Result(1, err, c, "未知表单!无法获取字段!")
return
}
var listFieldsMap ListPageFields
json.Unmarshal([]byte(formInfo.ListJson), &listFieldsMap)
if requestData.Types != 1 {
var listSynv CalendarList
for _, v := range requestData.TimeAry {
syncSeting.Add(1)
go listSynv.GetDayCont(v, formInfo.TableKey, userCont, requestData.Search, listField, listFieldsMap.View, formInfo.ListJson)
}
syncSeting.Wait()
sendListArt := TimeHaveAry(requestData.TimeAry, listSynv.List)
if len(sendListArt) == 1 {
var onInfo TimeAryInfo
for _, v := range sendListArt {
onInfo = v
}
publicmethod.Result(0, onInfo, c)
return
}
publicmethod.Result(0, sendListArt, c)
} else {
var sendMonthList []interface{}
for _, v := range requestData.TimeMonthAry {
var listSynv CalendarList
for _, tv := range v {
syncSeting.Add(1)
go listSynv.GetDayCont(tv, formInfo.TableKey, userCont, requestData.Search, listField, listFieldsMap.View, formInfo.ListJson)
}
syncSeting.Wait()
// sendListArt := TimeHaveAry(v, listSynv.List)
// fmt.Printf("每段结构---->%v\n=================================\n", sendListArt)
sendMonthList = append(sendMonthList, TimeHaveAry(v, listSynv.List))
}
publicmethod.Result(0, sendMonthList, c)
}
}
/*
*
@ 作者: 秦东
@ 时间: 2024-07-17 08:55:56
@ 功能: 结果与日期合并
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func TimeHaveAry(dateList []TimeAryInfo, listDate []map[string]interface{}) []TimeAryInfo {
for ti, tv := range dateList {
fmt.Printf("测试类型--->%v=============>%v\n", ti, tv)
for _, v := range listDate {
for mi, mv := range v {
if tv.Date == mi {
dateList[ti].List = mv
}
}
}
}
return dateList
}
/*
*
@ 作者: 秦东
@ 时间: 2024-07-16 14:09:26
@ 功能: 按天获取数据
@ 参数
#day 日历单个日期参数
#tableName 要操作得数据表
#userCont 当前操作人
#Search 搜索条件
#listField 自定义表单查询条件
#viewCondition 视图设定
#listJson 字段处理
@ 返回值
#
@ 方法原型
#
*/
func (c *CalendarList) GetDayCont(day TimeAryInfo, tableName string, userCont modelshr.ManCont, Search FormPageListAttr, listField []SearchButtonInfo, viewCondition map[string]ViewInfo, listJson string) {
defer syncSeting.Done()
tableName = fmt.Sprintf("`%v` as f", tableName)
gormDb := overall.CONSTANT_DB_CustomerForm.Table(tableName).Select("f.*,t.status as taskStatus,t.runFlowId")
gormDb = gormDb.Joins("LEFT JOIN `taskrecord` as t ON f.masters_key = t.masters_key")
gormDb = gormDb.Where("f.`creater` = ? ", userCont.Key)
gormDb = gormDb.Where("f.`states` BETWEEN ? AND ?", 1, 2)
gormDb = AnalysisSerachTermSqlIng(listField, gormDb)
if class, isOk := viewCondition["date"]; isOk {
if class.Status {
startTime, endTime := publicmethod.OenDayStartOrEndTime(day.Date, 1)
if class.Form.StartTime != "" && class.Form.EndTime != "" {
whySql := fmt.Sprintf("f.`%v` BETWEEN %v AND %v OR f.`%v` BETWEEN %v AND %v", class.Form.StartTime, startTime, endTime, class.Form.EndTime, startTime, endTime)
gormDb = gormDb.Where(whySql)
} else if class.Form.StartTime != "" && class.Form.EndTime == "" {
whySql := fmt.Sprintf("f.`%v` BETWEEN %v AND %v", class.Form.StartTime, startTime, endTime)
gormDb = gormDb.Where(whySql)
} else if class.Form.StartTime == "" && class.Form.EndTime != "" {
whySql := fmt.Sprintf("f.`%v` BETWEEN %v AND %v", class.Form.EndTime, startTime, endTime)
gormDb = gormDb.Where(whySql)
}
}
}
var formList []map[string]interface{}
err := gormDb.Order("`id` DESC").Find(&formList).Error
if listJson != "" {
var listFieldsMap ListPageFields
err = json.Unmarshal([]byte(listJson), &listFieldsMap)
if err == nil {
formList = listFieldsMap.DevelopSpecificationsSend(formList)
}
}
if err == nil {
inDate := publicmethod.MapOut[string]()
inDate[day.Date] = formList
c.List = append(c.List, inDate)
// c.List = append(c.List, inDate)
// c.List = make(map[string]interface{})
// c.List[day.Date] = formList
}
}
/*
*
@ 作者: 秦东
@ 时间: 2024-07-16 15:53:51
@ 功能: 自定义表单查询条件
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func AnalysisSerachTermSqlIng(why []SearchButtonInfo, gormDb *gorm.DB) *gorm.DB {
if len(why) < 1 {
return gormDb
}
for _, v := range why {
if v.Values != nil && v.Values != "" {
switch v.Pattern {
case "int":
likeSql := fmt.Sprintf("f.`%v` = %v", v.Field, v.Values)
gormDb = gormDb.Where(likeSql)
case "bigint":
likeSql := fmt.Sprintf("f.`%v` = %v", v.Field, v.Values)
gormDb = gormDb.Where(likeSql)
default:
likeSql := fmt.Sprintf("f.%v LIKE %v%v%v", v.Field, "'%", v.Values, "%'")
gormDb = gormDb.Where(likeSql)
}
}
}
return gormDb
}

68
api/version1/customerform/listField.go

@ -1,24 +1,38 @@
package customerform
type ListPageFields struct {
TableData TableDataInfo `json:"tableData"`
SearchData []SearchButtonInfo `json:"searchData"`
Loading bool `json:"loading"`
AttrObj interface{} `json:"attrObj"`
Config ConfigInfo `json:"config"`
TagList interface{} `json:"tagList"`
FormId interface{} `json:"formId"`
FormList []interface{} `json:"formList"`
Name string `json:"name"`
TreeData interface{} `json:"treeData"`
PreviewVisible bool `json:"previewVisible"`
TabsName string `json:"tabsName"`
FormFieldList []interface{} `json:"formFieldList"`
FormApi FormApiInfor `json:"formApi"`
Dict interface{} `json:"dict"`
RefreshTable bool `json:"refreshTable"`
TableData TableDataInfo `json:"tableData"`
SearchData []SearchButtonInfo `json:"searchData"`
Loading bool `json:"loading"`
AttrObj interface{} `json:"attrObj"`
Config ConfigInfo `json:"config"`
TagList interface{} `json:"tagList"`
FormId interface{} `json:"formId"`
FormList []interface{} `json:"formList"`
Name string `json:"name"`
TreeData interface{} `json:"treeData"`
PreviewVisible bool `json:"previewVisible"`
TabsName string `json:"tabsName"`
FormFieldList []interface{} `json:"formFieldList"`
FormApi FormApiInfor `json:"formApi"`
Dict interface{} `json:"dict"`
RefreshTable bool `json:"refreshTable"`
View map[string]ViewInfo `json:"view"`
}
type ViewInfo struct {
Status bool `json:"status"`
IsClick bool `json:"isClick"`
Form FormInfo `json:"form"`
}
type FormInfo struct {
StartTime string `json:"startTime"`
EndTime string `json:"endTime"`
DayType int `json:"dayType"`
SortWord string `json:"sortWord"`
Sort int `json:"sort"`
MapWord string `json:"mapWord"`
}
type FormApiInfor struct {
Type string `json:"type"`
AddApiUrl string `json:"addApiUrl"`
@ -71,3 +85,25 @@ type TableFormUnit struct {
type SunFormInfoStruct struct {
SunFormInfo []map[string][]UnitAttribute `json:"sunFormInfo"` //子表
}
// 输出视图条件类型模型
type ViewListMode struct {
Label string `json:"label"`
Value interface{} `json:"value"`
}
// 数据时间分割
type TimeFenGe struct {
DateTime string `json:"dateTime"`
WeekDay string `json:"weekDay"`
Day string `json:"day"`
Stor int `json:"stor"`
TimeUnix int64 `json:"timeUnix"`
StartAndEnd StartAndEndInfo `json:"startAndEnd"`
List []interface{} `json:"list"`
}
type StartAndEndInfo struct {
Start int64 `json:"start"`
End int64 `json:"end"`
}

73
api/version1/customerform/type.go

@ -194,12 +194,14 @@ type SendCustomerForm struct {
CreaterTimeStr string `json:"creatertimeStr" gorm:"-"`
FlowKeyStr string `json:"flowkeyStr" gorm:"-"`
VersionId string `json:"versionId" gorm:"-"`
SignCodeStr string `json:"signCodeStr" gorm:"-"`
}
// 输出自定义表格基础信息
type SendCustomerFormConfig struct {
FormName string `json:"formname"`
FormLogo string `json:"formlogo"`
SignCode string `json:"signCode"`
}
// 提交自定义表单数据
@ -226,6 +228,7 @@ type LookCustomerFormInfo struct {
States int `json:"states"`
GroupKey string `json:"groupKey"`
PermitList [][]int64 `json:"permit_list"`
FormField []string `json:"formField"`
}
// 接收自定义表单设置数据
@ -400,9 +403,19 @@ type FormFieldInfo struct {
FieldClass string `json:"fieldClass"`
ActiveValue string `json:"activeValue"`
InactiveValue string `json:"inactiveValue"`
Config ConfigType `json:"config"`
Control ControlType `json:"control"`
Options []OptionsInfo `json:"options"`
}
type ConfigType struct {
OptionsType float64 `json:"optionsType"`
}
type ControlType struct {
OptionsValue3Formid string `json:"optionsValue3Formid"`
OptionsValue3Field string `json:"optionsValue3Field"`
}
type OptionsInfo struct {
Label string `json:"label"`
Value string `json:"value"`
@ -443,8 +456,66 @@ type SearchButtonInfo struct {
ActiveValue string `json:"activeValue"`
InactiveValue string `json:"inactiveValue"`
Options []OptionsInfo `json:"options"`
Config string `json:"config"`
Config interface{} `json:"config"`
Label string `json:"label"`
IsSearch bool `json:"isSearch"`
Values interface{} `json:"value"`
}
// 输出版本信息
type SendVersionCont struct {
modelAppPlatform.CustomerFormVersion
CreaterName string `json:"createrName" gorm:"-"`
CreaterTimeStr string `json:"dayTime" gorm:"-"`
}
// 生成App还是表单
type AppOrForm struct {
Types int `json:"types"` //1:表单;2:app 3:app表单
}
// 多种视图展示
type ViewListSearch struct {
FormPageListAttr
ViewClass ViewKeyType `json:"viewClass"`
OlaData string `json:"oldData"`
}
type ViewKeyType struct {
Class string `json:"class"`
SortWord string `json:"sortWord"`
Sort int `json:"sort"`
StartTime string `json:"startTime"`
EndTime string `json:"endTime"`
DayType int `json:"dayType"`
MapWord string `json:"mapWord"`
}
// 根据日历搜索数据
type CalendarSearch struct {
Search FormPageListAttr `json:"search"`
TimeAry []TimeAryInfo `json:"timeAry"`
TimeMonthAry [][]TimeAryInfo `json:"timeMonthAry"`
Types int `json:"types"`
}
type TimeAryInfo struct {
Title int `json:"title"`
IsCurrent bool `json:"isCurrent"`
IsHolidays bool `json:"isHolidays"`
IsWorks bool `json:"isWorks"`
Date string `json:"date"`
Lunars string `json:"lunars"`
LunarsChinese string `json:"lunarsChinese"`
LunarsChina string `json:"lunarsChina"`
IsNow bool `json:"isNow"`
SolarDay string `json:"solarDay"`
LunarDay bool `json:"lunarDay"`
Animal string `json:"animal"`
Astro string `json:"astro"`
Term bool `json:"term"`
List interface{} `json:"list"`
}
type CalendarList struct {
List []map[string]interface{}
}

7
api/version1/entry.go

@ -1,6 +1,7 @@
package version1
import (
"appPlatform/api/version1/customerApp"
"appPlatform/api/version1/customerform"
datacenter "appPlatform/api/version1/dataCenter"
"appPlatform/api/version1/datamanagement/redisController"
@ -30,8 +31,10 @@ type ApiEntry struct {
NewsClassApi newsclass.ApiMethod //新闻类
RedisManagApi redisController.ApiMethod
MathsApi matsformula.ApiMethod
WechatApi workWechat.ApiMethod //微信相关项目
DataCenterApi datacenter.ApiMethod //数据中台
WechatApi workWechat.ApiMethod //微信相关项目
DataCenterApi datacenter.ApiMethod //数据中台
CustomerAppApi customerApp.ApiMethod //自定App
}
var AppApiEntry = new(ApiEntry)

48
api/version1/publicapi/api.go

@ -5,6 +5,7 @@ import (
"appPlatform/middleware/grocerystore"
"appPlatform/models/modelshr"
"appPlatform/models/modelsschool"
"appPlatform/models/modelssystempermission"
"appPlatform/overall"
"appPlatform/overall/publicmethod"
"encoding/json"
@ -1191,3 +1192,50 @@ func (a *ApiMethod) SilentLogin(c *gin.Context) {
publicmethod.CurlPostJosn("http://120.224.6.6:39168/shiyan/write_token", sendDate)
publicmethod.Result(0, saveData, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2024-05-27 09:29:13
@ 功能: 获取角色列表
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) GainAllRole(c *gin.Context) {
var requestData publicmethod.PublicName
err := c.ShouldBindJSON(&requestData)
var sendData []UserOrgRole
// if err != nil {
// publicmethod.Result(0, sendData, c)
// return
// }
gormDb := overall.CONSTANT_DB_System_Permission.Model(&modelssystempermission.SystemRole{}).Where("state = 1")
if requestData.Name != "" {
gormDb = gormDb.Where("`name` LIKE ?", "%"+requestData.Name+"%")
}
var roleList []modelssystempermission.SystemRole
err = gormDb.Find(&roleList).Error
if err != nil || len(roleList) < 1 {
publicmethod.Result(0, sendData, c)
return
}
for _, v := range roleList {
var user UserOrgRole
user.Id = strconv.FormatInt(v.Id, 10)
user.Title = v.Name
user.Img = ""
user.IsPick = 2
user.Types = 3
sendData = append(sendData, user)
}
publicmethod.Result(0, sendData, c)
}

14
api/version1/publicapi/type.go

@ -94,3 +94,17 @@ type OnleyOneName struct {
publicmethod.PublicName
NameAry []string
}
// 行政组织面包屑
type OrgCrumb struct {
publicmethod.PublicId
Title string `json:"title"`
}
// 行政组织、人员、角色通用面包屑
type UserOrgRole struct {
OrgCrumb
Img string `json:"img"`
IsPick int `json:"isPick"`
Types int `json:"types"`
}

813
api/version1/taskplatform/taskflow/appTaskFlow.go

@ -0,0 +1,813 @@
package taskflow
import (
"appPlatform/api/version1/customerform"
"appPlatform/api/version1/taskplatform/taskmanagement"
"appPlatform/models/customerForm"
"appPlatform/models/modelAppPlatform"
"appPlatform/models/modelshr"
"appPlatform/overall"
"appPlatform/overall/publicmethod"
"encoding/json"
"fmt"
"strconv"
"strings"
"time"
"github.com/gin-gonic/gin"
)
/*
*
@ 作者: 秦东
@ 时间: 2024-06-06 16:37:39
@ 功能: 获取App任务(任务流版本)
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) GainAppTaskList(c *gin.Context) {
var requestData AppTaskSearch
c.ShouldBindJSON(&requestData)
if requestData.Id == "" {
publicmethod.Result(100, requestData, c)
return
}
if requestData.Page == 0 {
requestData.Page = 1
}
if requestData.PageSize == 0 {
requestData.PageSize = 10
}
context, _ := c.Get(overall.MyContJwt)
var userCont modelshr.ManCont
userCont.GetLoginCont(context) //当前操作人
gormDb := overall.CONSTANT_DB_CustomerForm.Model(&customerForm.RunFlowTask{}).Select("`id`").Where("appKey = ?", requestData.Id)
switch requestData.Class {
case 2: //待办事宜
gormDb = gormDb.Where("`status` = 3 AND FIND_IN_SET(?,`next_executor`)", userCont.Key)
case 3: //已办事宜
gormDb = gormDb.Where("`status` IN (2,3,4) AND FIND_IN_SET(?,`participants`) AND NOT FIND_IN_SET(?,`next_executor`) AND `creater` <> ?", userCont.Key, userCont.Key, userCont.Key)
case 4: //草稿箱
gormDb = gormDb.Where("`status` = 1 AND `creater` = ?", userCont.Key)
case 5: //抄送我的
gormDb = gormDb.Where("`status` IN (2,3,4) AND FIND_IN_SET(?,`makeCopy`)", userCont.Key)
default: //我的请求
gormDb = gormDb.Where("`status` IN (1,2,3,4) AND `creater` = ?", userCont.Key)
}
if requestData.Title != "" {
gormDb = gormDb.Where("`title` LIKE ?", "%"+requestData.Title+"%")
}
if requestData.State != 0 {
gormDb = gormDb.Where("`status` = ?", requestData.State)
}
//获取总数
var total int64
totalErr := gormDb.Count(&total).Error
if totalErr != nil {
total = 0
}
var idAry []int64
gormDb = publicmethod.PageTurningSettings(gormDb, requestData.Page, requestData.PageSize)
err := gormDb.Order("`update_time` desc").Find(&idAry).Error
var userList []SendAppTaskFlowInfo
if err != nil || len(idAry) < 1 {
publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(userList)), userList, c)
return
}
overall.CONSTANT_DB_CustomerForm.Model(&customerForm.RunFlowTask{}).Where("`id` IN ?", idAry).Order("`start_time` desc").Find(&userList)
for i := 0; i < len(userList); i++ {
userList[i].FormVersionId = strconv.FormatInt(userList[i].VersionId, 10)
userList[i].IdStr = strconv.FormatInt(userList[i].Id, 10)
userList[i].FlowKeys = strconv.FormatInt(userList[i].FlowKey, 10)
userList[i].CreaterInfo = GainSmaillUserInfo[int64](userList[i].Creater)
userList[i].MastersKeyStr = strconv.FormatInt(userList[i].MastersKey, 10)
if userList[i].NextExecutor != "" {
nextAry := strings.Split(userList[i].NextExecutor, ",")
for _, v := range nextAry {
userList[i].CurrentNodeUser = append(userList[i].CurrentNodeUser, GainSmaillUserInfo[string](v))
}
}
userList[i].StartDate = publicmethod.UnixTimeToDay(userList[i].StartTime, 27)
if userList[i].NextStep != 0 {
nodeCont, idTrue := GainCurreNode(userList[i].FlowCont, userList[i].CurrentStep, userList[i].NextStep, userList[i].Status)
if idTrue {
userList[i].CurrentNodeName = nodeCont.NodeName
}
}
if userList[i].MastesForm == "" || userList[i].MastesFormJson == "" {
userList[i].MastesForm, userList[i].MastesFormJson = GainTaskFormData(userList[i].FlowKey)
}
if userList[i].Status == 3 && userList[i].NextStep != 0 {
if userList[i].CurrentStep == 1 {
userList[i].IsRetract = true
}
}
}
publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(userList)), userList, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2024-06-07 11:06:14
@ 功能: 获取App任务包含非流程表单
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) GainAppAllTaskList(c *gin.Context) {
var requestData AppAllTaskSearch
c.ShouldBindJSON(&requestData)
if requestData.Id == "" {
publicmethod.Result(100, requestData, c)
return
}
if requestData.Page == 0 {
requestData.Page = 1
}
if requestData.PageSize == 0 {
requestData.PageSize = 10
}
context, _ := c.Get(overall.MyContJwt)
var userCont modelshr.ManCont
userCont.GetLoginCont(context) //当前操作人
gormDb := overall.CONSTANT_DB_CustomerForm.Model(&customerForm.TaskRecord{}).Select("`id`").Where("appKey = ?", requestData.Id)
switch requestData.Class {
case 2: //草稿箱
gormDb = gormDb.Where("`status` = 1 AND `creater` = ?", userCont.Key)
default: //我的请求
gormDb = gormDb.Where("`status` IN (1,2,3,4) AND `creater` = ?", userCont.Key)
}
if requestData.Title != "" {
gormDb = gormDb.Where("`title` LIKE ?", "%"+requestData.Title+"%")
}
//获取总数
var total int64
totalErr := gormDb.Count(&total).Error
if totalErr != nil {
total = 0
}
var idAry []int64
gormDb = publicmethod.PageTurningSettings(gormDb, requestData.Page, requestData.PageSize)
err := gormDb.Order("`id` desc").Find(&idAry).Error
var userList []SendTaskInfo
if err != nil || len(idAry) < 1 {
publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(userList)), userList, c)
return
}
overall.CONSTANT_DB_CustomerForm.Model(&customerForm.TaskRecord{}).Where("`id` IN ?", idAry).Order("`id` desc").Find(&userList)
for i := 0; i < len(userList); i++ {
userList[i].IdStr = strconv.FormatInt(userList[i].Id, 10)
userList[i].CreaterTimeStr = publicmethod.UnixTimeToDay(userList[i].CreaterTime, 27)
userList[i].RunFlowIdStr = strconv.FormatInt(userList[i].RunFlowId, 10)
userList[i].VersionIdStr = strconv.FormatInt(userList[i].VersionId, 10)
userList[i].MastersKeyStr = strconv.FormatInt(userList[i].MastersKey, 10)
userList[i].FlowKeyStr = strconv.FormatInt(userList[i].FlowKey, 10)
userList[i].FlowRunSingStr = strconv.FormatInt(userList[i].FlowRunSing, 10)
userList[i].TableKeyStr = strconv.FormatInt(userList[i].TableKey, 10)
userList[i].AppKeyStr = strconv.FormatInt(userList[i].AppKey, 10)
userList[i].CreaterInfo = GainSmaillUserInfo[int64](userList[i].Creater)
if userList[i].Types == 1 && userList[i].Status == 3 && userList[i].RunFlowId != 0 {
var runFlowInfo customerForm.RunWorkflow
runFlowInfo.GetCont(map[string]interface{}{"`id`": userList[i].RunFlowId}, "`current_step`", "`next_step`", "`creater`")
if runFlowInfo.NextStep != 0 && runFlowInfo.CurrentStep == 1 {
if runFlowInfo.Creater == userCont.Key {
userList[i].IsRetract = true
}
}
}
}
publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(userList)), userList, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2024-06-07 13:27:30
@ 功能: 启动流程
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) RunAppWorkFlow(c *gin.Context) {
var requestData publicmethod.PublicId
err := c.ShouldBindJSON(&requestData)
if err != nil {
publicmethod.Result(100, err, c)
return
}
if requestData.Id == "" {
publicmethod.Result(100, err, c)
return
}
var taskInfo customerForm.TaskRecord
err = taskInfo.GetCont(map[string]interface{}{"`id`": requestData.Id})
if err != nil {
publicmethod.Result(107, err, c)
return
}
context, _ := c.Get(overall.MyContJwt)
var userCont modelshr.ManCont
userCont.GetLoginCont(context) //当前操作人
creetTime := time.Now().Unix() //当前时间
//获取任务
var runFlowInfo customerForm.RunWorkflow
err = runFlowInfo.GetCont(map[string]interface{}{"`flow_key`": taskInfo.MastersKey})
if err != nil { //不存在,则新建工作流
//获取流程详情
var flowVersionInfo modelAppPlatform.WorkFlowVersion
flowVersionInfo.GetCont(map[string]interface{}{"`id`": taskInfo.FlowRunSing}, "`content`")
uuid := publicmethod.GetUUid(1)
runUuId := publicmethod.GetUUid(6)
//执行工作流内容
var workFlowInfo customerForm.RunWorkflow
workFlowInfo.Id = uuid
workFlowInfo.FlowKey, _ = strconv.ParseInt(requestData.Id, 10, 64) //统一识别符(任务标识符)
workFlowInfo.Version = strconv.FormatInt(taskInfo.FlowRunSing, 10) //工作流版本
workFlowInfo.VersionCont = flowVersionInfo.Content //当前工作流内容
workFlowInfo.Creater = userCont.Key //流程发起人
workFlowInfo.Status = 3 //状态:1、草稿;2:驳回;3:审批中;4:归档;5:删除
workFlowInfo.StartTime = creetTime //开始时间
workFlowInfo.UpdateTime = creetTime //更新时间
workFlowInfo.RunKey = runUuId //当前执行识别符
// startCreaterKey := strconv.FormatInt(userCont.Key, 10) //当前操作人
//执行流程
// var executeWorkflow RunWorkFlow
// executeWorkflow.Step = 0 //执行第几部
// executeWorkflow.FlowList = requestData.FlowList
// executeWorkflow.Participant = append(executeWorkflow.Participant, startCreaterKey)
// executeWorkflow.TotalSteps = len(requestData.FlowList) //流程总长度
// executeWorkflow.Uuid = uuid //流程唯一识别符
// executeWorkflow.RunUid = runUuId //执行Uid
} else {
//存在,则发起工作流
}
}
/*
*
@ 作者: 秦东
@ 时间: 2024-06-07 16:05:33
@ 功能: 编辑任务内容
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) EditTaskAppInfo(c *gin.Context) {
var requestData publicmethod.PublicId
err := c.ShouldBindJSON(&requestData)
if err != nil {
publicmethod.Result(100, err, c)
return
}
if requestData.Id == "" {
publicmethod.Result(1, err, c, "未知表单参数!请核对1后重新提交!")
return
}
//Step1:判断任务是处在什么状态
var taskInfo customerForm.TaskRecord
err = taskInfo.GetCont(map[string]interface{}{"`masters_key`": requestData.Id}, "`version_id`", "`mastesformjson`", "`status`", "`types`", `flow_key`, "`masters_key`")
if err != nil {
publicmethod.Result(1, err, c, "流程不存在!不可进行下一步")
return
}
if !publicmethod.IsInTrue[int](taskInfo.Status, []int{1, 2, 4}) {
publicmethod.Result(1, err, c, "流程既不是草稿,也未发表、归档!不可进行下一步")
return
}
//Step2:展开表单
var formJsonCont customerform.CustomerFormMaster
json.Unmarshal([]byte(taskInfo.MastesFormJson), &formJsonCont)
//Step3:获取流程使用得表单数据表
var customerFormInfo modelAppPlatform.CustomerFormVersion
err = customerFormInfo.GetCont(map[string]interface{}{"`id`": taskInfo.VersionId}, "`tablekey`", "`table_structure`", "`dict`")
if err != nil {
publicmethod.Result(107, err, c)
return
}
var formUnitCont customerform.FormUnitInfo
formUnitCont.GainMasterAndSunFormUnit(customerFormInfo.TableKey, formJsonCont.List, true)
masterUnitList := make(map[string]customerform.MasterStruct)
for _, v := range formUnitCont.MasterInfo {
masterUnitList[v.Name] = v
}
mastKeyName, sunKeyName := formUnitCont.GainMasterAndSunFormUnitNameKey()
masterDataInfo := GainCurrendLogData(taskInfo.MastersKey, customerFormInfo, formUnitCont, masterUnitList)
var logDataInfo FormDataLog
logDataInfo.FlowKey = taskInfo.MastersKey
logDataInfo.GainFlowFoemLog()
fmt.Printf("主表的数据返回值--->%v\n--->%v\n", masterDataInfo, logDataInfo.NewData)
if len(logDataInfo.NewData) > 0 {
logTime := logDataInfo.NewData["logTime"]
newDataInfo := publicmethod.MapOut[string]()
for i, v := range masterDataInfo {
fmt.Printf("logDataInfo.masterDataInfo---->%v:%v--------->%T\n", i, v, v)
for j, jv := range logDataInfo.NewData {
if i == j {
if i == "masters_key" {
if mastKey, ok := jv.(uint64); ok {
newDataInfo[i] = strconv.FormatUint(mastKey, 10)
}
} else if i == "creater" {
if createrKey, ok := jv.(int64); ok {
newDataInfo[i] = strconv.FormatInt(createrKey, 10)
}
} else {
newDataInfo[i] = jv
}
}
if j == "explicate" {
newDataInfo["explicate"] = jv
}
}
}
logDataInfo.NewData = masterDataInfo
logDataInfo.NewData["logTime"] = logTime
masterDataInfo = newDataInfo
} else {
isWrite := true
for i, v := range masterDataInfo {
fmt.Printf("logDataInfo.masterDataInfo--1-->%v:%v--------->%T\n", i, v, v)
if i == "masters_key" {
if mastKey, ok := v.(uint64); ok {
masterDataInfo[i] = strconv.FormatUint(mastKey, 10)
}
}
if i == "creater" {
if createrKey, ok := v.(int64); ok {
masterDataInfo[i] = strconv.FormatInt(createrKey, 10)
}
}
if i == "explicate" {
isWrite = false
}
}
if isWrite {
masterDataInfo["explicate"] = ""
}
}
masterDataInfo["flowKey"] = strconv.FormatInt(taskInfo.FlowKey, 10)
sendData := publicmethod.MapOut[string]()
sendData["masterDataInfo"] = masterDataInfo
publicmethod.Result(0, sendData, c)
return
sendNewData := publicmethod.MapOut[string]()
sendSunNewData := publicmethod.MapOut[string]()
for i, v := range logDataInfo.NewData {
if val, isOk := v.([]map[string]interface{}); !isOk {
for mi, mv := range mastKeyName {
if mi == i {
sendNewData[mv] = v
}
}
} else {
// fmt.Printf("获取数据类型:---4-->%v----->%v\n", val, sunKeyName[i])
var newSunData []map[string]interface{}
for _, sv := range val {
sunOld := publicmethod.MapOut[string]()
for smi, smv := range sv {
for sui, suv := range sunKeyName[i] {
if sui == smi {
sunOld[suv] = smv
}
if smi == "id" {
sunOld[suv] = smv
}
}
}
newSunData = append(newSunData, sunOld)
fmt.Printf("获取数据类型:---4-->%v----->%v\n", sv, newSunData)
}
sendSunNewData[i] = newSunData
}
}
for i, v := range sendSunNewData {
sendNewData[i] = v
}
if len(sendNewData) > 0 {
sendNewData["logTime"] = logDataInfo.NewData["logTime"]
}
fmt.Printf("获取数据类型:----->%v\n", sendNewData)
sendData["newData"] = sendNewData
sendData["oldData"] = EditLogCont(logDataInfo.OldData, mastKeyName, sunKeyName)
sendData["newDataLen"] = len(sendNewData)
sendData["logistrue"] = false
if len(sendNewData) > 0 || len(logDataInfo.OldData) > 0 {
sendData["logistrue"] = true
}
publicmethod.Result(0, sendData, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2024-06-10 11:27:13
@ 功能: 再次保存草稿箱内容
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) SaveDraftAgain(c *gin.Context) {
data, err := c.GetRawData() //接收表单提交得数据
if err != nil {
publicmethod.Result(100, err, c)
return
}
mapData := publicmethod.MapOut[string]() //初始化MAP
err = json.Unmarshal(data, &mapData) //将json字符串转换成Map
if err != nil {
publicmethod.Result(100, err, c)
return
}
taskId := ""
if taskIdVal, ok := mapData["masters_key"]; !ok {
publicmethod.Result(1, err, c, "非法表单!不能提交数据!")
return
} else {
if akValStr, ok := taskIdVal.(string); ok {
taskId = akValStr
}
}
var formCont modelAppPlatform.CustomerFormView
err = formCont.GetCont(map[string]interface{}{"`id`": mapData["versionId"]})
if err != nil {
publicmethod.Result(107, err, c)
return
}
var sunFormName []string //子表名称集合
if formCont.TableStructure != "" { //拆解获取子表名称
var sunFormStruct map[string]string
err = json.Unmarshal([]byte(formCont.TableStructure), &sunFormStruct)
if err == nil {
for _, v := range sunFormStruct {
if !publicmethod.IsInTrue[string](v, sunFormName) {
sunFormName = append(sunFormName, v)
}
}
}
}
masterField := publicmethod.MapOut[string]() //主表数据
sunFieldAry := publicmethod.MapOut[string]() //子表数据
for k, v := range mapData {
if !publicmethod.IsInTrue[string](k, sunFormName) {
if !publicmethod.IsInTrue[string](k, []string{"formId"}) {
masterField[k] = v
}
} else {
sunFieldAry[k] = v
}
}
context, _ := c.Get(overall.MyContJwt)
var userCont modelshr.ManCont
userCont.GetLoginCont(context) //当前操作人
cureeTime := time.Now().Unix()
var formJsonCont customerform.CustomerFormMaster
json.Unmarshal([]byte(formCont.MastesFormJson), &formJsonCont) //解析表单字符串
var formUnitCont customerform.FormUnitInfo
formUnitCont.GainMasterAndSunFormUnit(formCont.TableKey, formJsonCont.List, true) //获取主表及子表相关组件
//主表组件
masterUnitList := make(map[string]customerform.MasterStruct)
for _, v := range formUnitCont.MasterInfo {
masterUnitList[v.Name] = v
}
sendInfo := publicmethod.MapOut[string]()
masrWriteMap := taskmanagement.MakeFormMapData(formCont.Flowkey, userCont.Key, cureeTime, masterField, masterUnitList, 2)
if len(masrWriteMap) > 0 {
oldMasterData, _ := taskmanagement.MasterTableHandle(formCont.TableKey, userCont.Key, cureeTime, masrWriteMap)
sendInfo["oldMasterData"] = oldMasterData
}
//判断是否有子表
if len(sunFieldAry) > 0 {
//有子表
sunTypeAry := make(map[string]map[string]customerform.MasterStruct)
for _, v := range formUnitCont.SunFormInfo {
sunTypeAry[v.TableName] = v.UbitInfo
}
sunTableData := EditSunDatabase(formCont.Flowkey, userCont.Key, cureeTime, formCont.TableKey, masrWriteMap, sunFieldAry, sunTypeAry)
sendInfo["sunTableData"] = sunTableData
if len(sunTableData) > 0 {
sonList, _ := taskmanagement.SonTableHandle(taskId, userCont.Key, cureeTime, sunFieldAry)
sendInfo["sonList"] = sonList
}
}
sendInfo["taskId"] = taskId
sendInfo["mapData"] = mapData
sendInfo["masterField"] = masterField
sendInfo["sunFieldAry"] = sunFieldAry
sendInfo["masterUnitList"] = masterUnitList
sendInfo["cureeTime"] = cureeTime
sendInfo["masrWriteMap"] = masrWriteMap
publicmethod.Result(0, sendInfo, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2024-06-13 11:20:04
@ 功能: 重新提交有流程就发动流程无流程就正常发表
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) AfreshAppSubmit(c *gin.Context) {
data, err := c.GetRawData() //接收表单提交得数据
if err != nil {
publicmethod.Result(100, err, c)
return
}
mapData := publicmethod.MapOut[string]() //初始化MAP
err = json.Unmarshal(data, &mapData) //将json字符串转换成Map
if err != nil {
publicmethod.Result(100, err, c)
return
}
taskId := ""
if taskIdVal, ok := mapData["masters_key"]; !ok {
publicmethod.Result(1, err, c, "非法表单!不能提交数据!")
return
} else {
if akValStr, ok := taskIdVal.(string); ok {
taskId = akValStr
}
}
var flowListAry []RunFlow
if flowAry, ok := mapData["flowList"]; ok {
if akFlowValStr, ok := flowAry.(string); ok {
json.Unmarshal([]byte(akFlowValStr), &flowListAry)
}
}
var formCont modelAppPlatform.CustomerFormView
err = formCont.GetCont(map[string]interface{}{"`id`": mapData["versionId"]})
if err != nil {
publicmethod.Result(107, err, c)
return
}
var sunFormName []string //子表名称集合
if formCont.TableStructure != "" { //拆解获取子表名称
var sunFormStruct map[string]string
err = json.Unmarshal([]byte(formCont.TableStructure), &sunFormStruct)
if err == nil {
for _, v := range sunFormStruct {
if !publicmethod.IsInTrue[string](v, sunFormName) {
sunFormName = append(sunFormName, v)
}
}
}
}
masterField := publicmethod.MapOut[string]() //主表数据
sunFieldAry := publicmethod.MapOut[string]() //子表数据
for k, v := range mapData {
if !publicmethod.IsInTrue[string](k, sunFormName) {
if !publicmethod.IsInTrue[string](k, []string{"formId"}) {
masterField[k] = v
}
} else {
sunFieldAry[k] = v
}
}
context, _ := c.Get(overall.MyContJwt)
var userCont modelshr.ManCont
userCont.GetLoginCont(context) //当前操作人
cureeTime := time.Now().Unix()
var formJsonCont customerform.CustomerFormMaster
json.Unmarshal([]byte(formCont.MastesFormJson), &formJsonCont) //解析表单字符串
var formUnitCont customerform.FormUnitInfo
formUnitCont.GainMasterAndSunFormUnit(formCont.TableKey, formJsonCont.List, true) //获取主表及子表相关组件
//主表组件
masterUnitList := make(map[string]customerform.MasterStruct)
for _, v := range formUnitCont.MasterInfo {
masterUnitList[v.Name] = v
}
sendInfo := publicmethod.MapOut[string]()
masrWriteMap := taskmanagement.MakeFormMapData(formCont.Flowkey, userCont.Key, cureeTime, masterField, masterUnitList, 2)
if len(masrWriteMap) > 0 {
oldMasterData, _ := taskmanagement.MasterTableHandle(formCont.TableKey, userCont.Key, cureeTime, masrWriteMap)
sendInfo["oldMasterData"] = oldMasterData
}
//判断是否有子表
if len(sunFieldAry) > 0 {
//有子表
sunTypeAry := make(map[string]map[string]customerform.MasterStruct)
for _, v := range formUnitCont.SunFormInfo {
sunTypeAry[v.TableName] = v.UbitInfo
}
sunTableData := EditSunDatabase(formCont.Flowkey, userCont.Key, cureeTime, formCont.TableKey, masrWriteMap, sunFieldAry, sunTypeAry)
sendInfo["sunTableData"] = sunTableData
if len(sunTableData) > 0 {
sonList, _ := taskmanagement.SonTableHandle(taskId, userCont.Key, cureeTime, sunFieldAry)
sendInfo["sonList"] = sonList
}
}
//开启流程的
if formCont.FlowIsOpen == 1 {
var runFlowInfo customerForm.RunWorkflow
err = runFlowInfo.GetCont(map[string]interface{}{"`flow_key`": taskId}, "`id`", "`next_executor`", "`current_step`", "`next_step`", "`participants`", "`flow_key`", "`flow_cont`", "`runKey`")
saveTask := publicmethod.MapOut[string]() //修改任务
if err != nil {
uuid := publicmethod.GetUUid(1)
runUuId := publicmethod.GetUUid(6)
var taskInfo customerForm.TaskRecord
taskInfo.GetCont(map[string]interface{}{"`masters_key`": taskId}, "`flow_key`", "`flow_run_sing`")
//获取流程详情
var flowVersionInfo modelAppPlatform.WorkFlowVersion
flowVersionInfo.GetCont(map[string]interface{}{"`id`": taskInfo.FlowRunSing}, "`content`")
//执行工作流内容
var workFlowInfo customerForm.RunWorkflow
workFlowInfo.Id = uuid
workFlowInfo.FlowKey = taskInfo.FlowKey //统一识别符(任务标识符)
workFlowInfo.Version = strconv.FormatInt(taskInfo.FlowRunSing, 10) //工作流版本
workFlowInfo.VersionCont = flowVersionInfo.Content //当前工作流内容
workFlowInfo.Creater = userCont.Key //流程发起人
workFlowInfo.Status = 3 //状态:1、草稿;2:驳回;3:审批中;4:归档;5:删除
workFlowInfo.StartTime = cureeTime //开始时间
workFlowInfo.UpdateTime = cureeTime //更新时间
workFlowInfo.RunKey = runUuId //当前执行识别符
startCreaterKey := strconv.FormatInt(userCont.Key, 10) //当前操作人
//执行流程
var executeWorkflow RunWorkFlow
executeWorkflow.Step = 0 //执行第几部
executeWorkflow.FlowList = flowListAry
executeWorkflow.Participant = append(executeWorkflow.Participant, startCreaterKey)
executeWorkflow.TotalSteps = len(flowListAry) //流程总长度
executeWorkflow.Uuid = uuid //流程唯一识别符
executeWorkflow.RunUid = runUuId //执行Uid
executeWorkflow.GainRunNode(startCreaterKey, 2, "发起审批")
flowJsonCont, _ := json.Marshal(executeWorkflow.FlowList) //将步进流转化成json流
workFlowInfo.FlowCont = string(flowJsonCont) //流程执行体
workFlowInfo.CurrentStep = executeWorkflow.Step
workFlowInfo.NextStep = executeWorkflow.NextStep
//参与人去重
var parUser []string
for _, v := range executeWorkflow.Participant {
if !publicmethod.IsInTrue[string](v, parUser) {
parUser = append(parUser, v)
}
}
workFlowInfo.Participants = strings.Join(parUser, ",")
nextRunUser := executeWorkflow.NextRunNodeUser(1)
workFlowInfo.NextExecutor = strings.Join(nextRunUser, ",")
if executeWorkflow.NextStep <= 0 {
workFlowInfo.Status = 4
}
err = workFlowInfo.WriteCont() //写入执行工作流
if err != nil {
var taskInfo customerForm.TaskRecord
taskInfo.EiteCont(map[string]interface{}{"`masters_key`": taskId}, map[string]interface{}{"`status`": 1})
publicmethod.Result(10001, err, c, "流程写入失败!请重新发起")
return
}
if executeWorkflow.NextStep <= 0 {
var taskCont customerForm.TaskRecord
taskCont.EiteCont(map[string]interface{}{"`masters_key`": taskId}, map[string]interface{}{"`status`": 4})
} else {
var taskCont customerForm.TaskRecord
taskCont.EiteCont(map[string]interface{}{"`masters_key`": taskId}, map[string]interface{}{"`status`": 3})
}
// saveTask["`flow_key`"] = 2
} else {
var flowList []taskmanagement.RunFlow
err = json.Unmarshal([]byte(runFlowInfo.FlowCont), &flowList)
if err != nil {
publicmethod.Result(107, err, c)
return
}
startUs := strconv.FormatInt(userCont.Key, 10) //当前操作人
runUuId := publicmethod.GetUUid(6)
//执行流程
var runFlow taskmanagement.RunWorkFlow
runFlow.Step = 0 //执行第几部
runFlow.FlowList = flowList
runFlow.Participant = append(runFlow.Participant, startUs)
runFlow.TotalSteps = len(flowList) //流程总长度
runFlow.Uuid = runFlowInfo.Id
runFlow.RunUid = runUuId
runFlow.GainRunNode(startUs, 2, "重新发起流程")
flowJsonCont, _ := json.Marshal(runFlow.FlowList) //将步进流转化成json流
SaveFlowCont := publicmethod.MapOut[string]()
SaveFlowCont["`flow_cont`"] = string(flowJsonCont)
SaveFlowCont["`current_step`"] = runFlow.Step
SaveFlowCont["`next_step`"] = runFlow.NextStep
SaveFlowCont["`runKey`"] = runUuId
//参与人去重
var parUser []string
for _, v := range runFlow.Participant {
if !publicmethod.IsInTrue[string](v, parUser) {
parUser = append(parUser, v)
}
}
SaveFlowCont["`participants`"] = strings.Join(parUser, ",")
nextRunUser := runFlow.NextRunNodeUser(1)
SaveFlowCont["`next_executor`"] = strings.Join(nextRunUser, ",")
SaveFlowCont["`status`"] = 3
if runFlow.NextStep <= 0 {
SaveFlowCont["`status`"] = 4
}
SaveFlowCont["`update_time`"] = time.Now().Unix()
err = runFlowInfo.EiteCont(map[string]interface{}{"`id`": runFlowInfo.Id}, SaveFlowCont)
if err != nil {
publicmethod.Result(106, err, c)
return
}
}
saveTask["`status`"] = 3
saveTask["`edit_time`"] = time.Now().Unix()
var taskInfo customerForm.TaskRecord
taskInfo.EiteCont(map[string]interface{}{"`masters_key`": taskId}, saveTask)
} else { //未开启流程的表单
saveTask := publicmethod.MapOut[string]() //修改任务
saveTask["`status`"] = 2
saveTask["`edit_time`"] = time.Now().Unix()
var taskInfo customerForm.TaskRecord
taskInfo.EiteCont(map[string]interface{}{"`masters_key`": taskId}, saveTask)
}
// sendInfo["taskId"] = taskId
// sendInfo["mapData"] = mapData
// sendInfo["masterField"] = masterField
// sendInfo["sunFieldAry"] = sunFieldAry
// sendInfo["masterUnitList"] = masterUnitList
// sendInfo["cureeTime"] = cureeTime
// sendInfo["masrWriteMap"] = masrWriteMap
publicmethod.Result(0, sendInfo, c)
}

6
api/version1/taskplatform/taskflow/editformflow.go

@ -261,7 +261,11 @@ func GainCurrendLogData(flowKey int64, customerFormInfo modelAppPlatform.Custome
if err != nil {
return masterFormCont
}
jsonCont, _ := json.Marshal(masterUnitList)
fmt.Printf("主表的数据--->%v\n--->%v\n", masterFormCont, string(jsonCont))
masterFormCont = taskmanagement.CustomerFormCallBackVal(masterFormCont, masterUnitList)
fmt.Printf("主表的数据-1-->%v\n--->%v\n", masterFormCont, string(jsonCont))
if customerFormInfo.TableStructure != "" {
sunFormTable := publicmethod.MapOut[string]()
err = json.Unmarshal([]byte(customerFormInfo.TableStructure), &sunFormTable)
@ -313,7 +317,7 @@ func GainCurrendLogData(flowKey int64, customerFormInfo modelAppPlatform.Custome
*/
func (f *FormDataLog) GainFlowFoemLog() {
var logDataList []reviseform.EditFormDataLog
err := overall.CONSTANT_DB_ReviseFormData.Where("`flow_key` = ?", f.FlowKey).Order("`addTime` desc").Find(&logDataList).Error
err := overall.CONSTANT_DB_ReviseFormData.Where("`masters_key` = ?", f.FlowKey).Order("`addTime` desc").Find(&logDataList).Error
if err != nil {
return
}

1
api/version1/taskplatform/taskflow/flowType.go

@ -62,6 +62,7 @@ type NodePublicInfo struct {
ChildNode *NodePublicInfo `json:"childNode"` //子节点
Matrix MatrixInfo `json:"matrix"` //
HelpTips string `json:"helpTips"` //
}
//矩阵信息

4
api/version1/taskplatform/taskflow/flowengine.go

@ -269,7 +269,9 @@ func (a *ApiMethod) EditFlowCont(c *gin.Context) {
}
}
err = flowVersionInfo.EiteCont(why, editInfo)
var flowVersion modelAppPlatform.WorkFlowVersion
// err = flowVersionInfo.EiteCont(why, editInfo)
err = flowVersion.EiteCont(why, editInfo)
if err != nil {
publicmethod.Result(106, err, c)
return

41
api/version1/taskplatform/taskflow/types.go

@ -2,6 +2,7 @@ package taskflow
import (
"appPlatform/api/version1/customerform"
"appPlatform/models/customerForm"
"appPlatform/models/modelAppPlatform"
"appPlatform/overall/publicmethod"
"sync"
@ -243,6 +244,20 @@ type SendTaskFlowInfo struct {
IsRetract bool `json:"isRetract" gorm:"-"` //是否可以撤回
}
// 输出任务列表
type SendAppTaskFlowInfo struct {
customerForm.RunFlowTask
FlowKeys string `json:"flowkeys" gorm:"-"` //唯一标识符
CreaterInfo UserSmallInfo `json:"creatorInfo" gorm:"-"` //创建人信息
StartDate string `json:"startDate" gorm:"-"` //创建日期
CurrentNodeName string `json:"currentNodeName" gorm:"-"` //当前节点名称
CurrentNodeUser []UserSmallInfo `json:"currentNodeUser" gorm:"-"` //节点操作人
IdStr string `json:"idStr" gorm:"-"` //
FormVersionId string `json:"formVersionId" gorm:"-"`
IsRetract bool `json:"isRetract" gorm:"-"` //是否可以撤回
MastersKeyStr string `json:"mastersKeyStr" gorm:"-"` //唯一标识符
}
// 人员剪短信息
type UserSmallInfo struct {
Id int64 `json:"id"`
@ -318,3 +333,29 @@ type FlowFormPowerInfo struct {
FormData string `json:"formData"`
FormPower string `json:"formPower"`
}
// app任务参数
type AppTaskSearch struct {
publicmethod.PublicId
QueryTaskFlow
}
type AppAllTaskSearch struct {
publicmethod.PublicId
publicmethod.PagesTurn
Class int `json:"class"` //类型:1、我创建的;2、草稿箱
Title string `json:"title"` //任务标题
}
type SendTaskInfo struct {
customerForm.TaskRecord
IdStr string `json:"idStr" gorm:"-"`
CreaterInfo UserSmallInfo `json:"createrInfo" gorm:"-"` //创建人姓名
CreaterTimeStr string `json:"createrTimeStr" gorm:"-"` //创建时间
VersionIdStr string `json:"versionIdStr" gorm:"-"`
MastersKeyStr string `json:"mastersKeyStr" gorm:"-"`
FlowKeyStr string `json:"flowKeyStr" gorm:"-"`
FlowRunSingStr string `json:"flowRunSingStr" gorm:"-"`
TableKeyStr string `json:"tableKeyStr" gorm:"-"`
AppKeyStr string `json:"appKeyStr" gorm:"-"`
IsRetract bool `json:"isRetract" gorm:"-"`
RunFlowIdStr string `json:"runFlowIdStr" gorm:"-"`
}

164
api/version1/taskplatform/taskmanagement/appControl.go

@ -0,0 +1,164 @@
package taskmanagement
import (
"appPlatform/api/version1/customerform"
"appPlatform/models/customerForm"
"appPlatform/models/modelAppPlatform"
"appPlatform/models/modelshr"
"appPlatform/overall"
"appPlatform/overall/publicmethod"
"encoding/json"
"fmt"
"strconv"
"time"
"github.com/gin-gonic/gin"
)
/*
*
@ 作者: 秦东
@ 时间: 2024-06-06 13:57:55
@ 功能: 自定义App表单新增记录
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) CreateAppTask(c *gin.Context) {
data, err := c.GetRawData() //接收表单提交得数据
if err != nil {
publicmethod.Result(100, err, c)
return
}
mapData := publicmethod.MapOut[string]() //初始化MAP
err = json.Unmarshal(data, &mapData) //将接收的json字符串参数转换成Map
if err != nil {
publicmethod.Result(100, err, c)
return
}
if _, ok := mapData["versionId"]; !ok {
publicmethod.Result(1, err, c, "非法表单!不能提交数据!")
return
}
status := 1
if _, ok := mapData["status"]; ok {
fmt.Printf("mapData[status]:%v------------->%T\n", mapData["status"], mapData["status"])
if vFloat64, isOk := mapData["status"].(float64); isOk {
vStr := strconv.FormatFloat(vFloat64, 'f', -1, 64)
status, _ = strconv.Atoi(vStr)
}
}
var formCont modelAppPlatform.CustomerFormView //获取指定版本的表单
err = formCont.GetCont(map[string]interface{}{"`id`": mapData["versionId"]})
if err != nil {
publicmethod.Result(107, err, c)
return
}
var sunFormName []string //子表名称集合
if formCont.TableStructure != "" { //拆解获取子表名称
var sunFormStruct map[string]string
err = json.Unmarshal([]byte(formCont.TableStructure), &sunFormStruct)
if err == nil {
for _, v := range sunFormStruct {
if !publicmethod.IsInTrue[string](v, sunFormName) {
sunFormName = append(sunFormName, v)
}
}
}
}
masterField := publicmethod.MapOut[string]() //主表数据
sunFieldAry := publicmethod.MapOut[string]() //子表数据
for k, v := range mapData {
if !publicmethod.IsInTrue[string](k, sunFormName) {
if !publicmethod.IsInTrue[string](k, []string{"formId", "id"}) {
masterField[k] = v
}
} else {
sunFieldAry[k] = v
}
}
context, _ := c.Get(overall.MyContJwt)
var userCont modelshr.ManCont
userCont.GetLoginCont(context) //当前操作人
uuid := publicmethod.GetUUid(1) //统一识别符
cureeTime := time.Now().Unix() //写入时间
var formJsonCont customerform.CustomerFormMaster
json.Unmarshal([]byte(formCont.MastesFormJson), &formJsonCont)
var formUnitCont customerform.FormUnitInfo
formUnitCont.GainMasterAndSunFormUnit(formCont.TableKey, formJsonCont.List, true)
masterUnitList := make(map[string]customerform.MasterStruct)
for _, v := range formUnitCont.MasterInfo {
masterUnitList[v.Name] = v
}
masrWriteMap := MakeFormMapData(uuid, userCont.Key, cureeTime, masterField, masterUnitList, 1)
masrWriteMap["flowIsOpen"] = formCont.FlowIsOpen
//任务列表
var taskCont customerForm.TaskRecord
taskCont.MastersKey = uuid
taskCont.Title = fmt.Sprintf("%v-%v(%v)-%v", formCont.Name, userCont.Name, userCont.Number, publicmethod.UnixTimeToDay(cureeTime, 14)) //标题"`
taskCont.AppKey = formCont.Groupid
taskCont.TableKey = formCont.SignCode
taskCont.Creater = userCont.Key //创建人"`
taskCont.CreaterTime = cureeTime //创建时间"`
taskCont.EditTime = cureeTime //编辑时间"`
taskCont.Types = formCont.FlowIsOpen //类型(1:流程表单;2:普通表单)"`
taskCont.VersionId = formCont.Id //来源于哪个表单"`
taskCont.Status = status
if formCont.FlowIsOpen == 1 {
taskCont.Status = status
taskCont.FlowKey = formCont.Flowkey
var flowInfo modelAppPlatform.FlowVersion
flowInfo.GetCont(map[string]interface{}{"`key`": formCont.Flowkey, "`state`": 1}, "`id`")
taskCont.FlowRunSing = flowInfo.Id
}
//判断是否
if len(sunFieldAry) > 0 {
//有子表
sunTypeAry := make(map[string]map[string]customerform.MasterStruct)
for _, v := range formUnitCont.SunFormInfo {
sunTypeAry[v.TableName] = v.UbitInfo
}
err = WriteSunDatabase(uuid, userCont.Key, cureeTime, formCont.TableKey, masrWriteMap, sunFieldAry, sunTypeAry)
} else {
// //无子表
err = overall.CONSTANT_DB_CustomerForm.Table(formCont.TableKey).Create(masrWriteMap).Error
publicmethod.WriteLog("write", "写入自定义表单", formCont.TableKey, err)
}
if err != nil {
publicmethod.Result(104, err, c)
return
}
taskCont.MastesForm = formCont.MastesForm
taskCont.MastesFormJson = formCont.MastesFormJson
err = overall.CONSTANT_DB_CustomerForm.Create(&taskCont).Error
// for k, v := range masrWriteMap {
// fmt.Printf("%v----> %T\n", k, v)
// }
publicmethod.WriteLog("write", "写入任务", err, taskCont)
sendData := publicmethod.MapOut[string]()
sendData["uuid"] = strconv.FormatInt(uuid, 10)
sendData["cureeTime"] = cureeTime
sendData["formUnitCont"] = formUnitCont
sendData["masterField"] = masterField
sendData["sunFieldAry"] = sunFieldAry
sendData["sunFieldAry_len"] = len(sunFieldAry)
sendData["masrWriteMap"] = masrWriteMap
sendData["sunFormName"] = sunFormName
sendData["mapData"] = mapData
publicmethod.Result(0, sendData, c)
}

2
api/version1/taskplatform/taskmanagement/flowNode.go

@ -39,6 +39,7 @@ type NodePublicInfo struct {
ChildNode *NodePublicInfo `json:"childNode"` //子节点
Matrix MatrixInfo `json:"matrix"` //
HelpTips string `json:"helpTips"` //节点帮助说明
}
type NodePublicInfoES struct {
@ -146,6 +147,7 @@ type RunFlow struct {
RunType int `json:"runtype"` //运行时选择 0:禁闭;1:发起人自选,2:发起人自己,3:有选中得节点指定,4:抄送节点
RunScope int `json:"runscope"` //运行时选择范围 0:不可选,1:本公司;2:本部门;当RunType = 4时:1:自选;非1:不可自选
// Operational bool `json:"operational"` //是否可提交审批意见
HelpTips string `json:"helpTips"` //节点帮助说明
}
//操作人

1
api/version1/taskplatform/taskmanagement/flowType.go

@ -16,6 +16,7 @@ type RunWorkFlow struct {
TotalSteps int //总步数
FlowList []RunFlow //流程
Participant []string //参与人
MakeCopy []string //抄送人
NewFlowList []RunFlow //流程
Uuid int64 //
RunUid int64 //执行Uid

14
api/version1/taskplatform/taskmanagement/formcontrol.go

@ -799,11 +799,21 @@ func (a *ApiMethod) AddCustomerForm(c *gin.Context) {
publicmethod.Result(100, err, c)
return
}
status := 2
if _, ok := mapData["formId"]; !ok {
publicmethod.Result(1, err, c, "非法表单!不能提交数据!")
return
}
if val, ok := mapData["status"]; !ok {
if valInt, isTrue := val.(int); isTrue {
status = valInt
if valInt <= 0 {
status = 2
}
}
} else {
status = 2
}
var formCont modelAppPlatform.CustomerFormView //获取指定版本的表单
err = formCont.GetCont(map[string]interface{}{"`id`": mapData["formId"]})
if err != nil {
@ -862,7 +872,7 @@ func (a *ApiMethod) AddCustomerForm(c *gin.Context) {
taskCont.EditTime = cureeTime //编辑时间"`
taskCont.Types = formCont.FlowIsOpen //类型(1:流程表单;2:普通表单)"`
taskCont.VersionId = formCont.Id //来源于哪个表单"`
taskCont.Status = 2
taskCont.Status = status
if formCont.FlowIsOpen == 1 {
taskCont.Status = 3
taskCont.FlowKey = formCont.Flowkey

31
api/version1/taskplatform/taskmanagement/ruanTask.go

@ -331,7 +331,7 @@ func (a *ApiMethod) SoftDeletion(c *gin.Context) {
var tableVersion modelAppPlatform.CustomerFormView
err = tableVersion.GetCont(map[string]interface{}{"`id`": v.VersionId}, "`tablekey`", "`table_structure`")
if err == nil {
EditTablePageInfo(v.MastersKey, requestData.IsTrue, 3, tableVersion.TableKey, tableVersion.TableStructure)
EditTablePageInfo(v.MastersKey, requestData.IsTrue, 5, tableVersion.TableKey, tableVersion.TableStructure)
}
}
publicmethod.Result(0, err, c)
@ -537,6 +537,7 @@ func (a *ApiMethod) EditCustomerTable(c *gin.Context) {
sendInfo["masterKey"] = masterKey
sendInfo["MasterTableHandle"] = masterOldData
sendInfo["err"] = err
sendInfo["runFlowId"] = strconv.FormatInt(taskInfo.RunFlowId, 10)
publicmethod.Result(0, sendInfo, c)
}
@ -649,13 +650,17 @@ func SonTableSaveData(sunTableName, masterKey string, creater, cureeTime int64,
func MasterTableHandle(tableName string, creater, cureeTime int64, newsData map[string]interface{}) (map[string]interface{}, error) {
var oldData map[string]interface{}
if len(newsData) > 0 {
id := ""
var id interface{}
editData := publicmethod.MapOut[string]()
for i, v := range newsData {
fmt.Printf("i:%v---->v:%v\n", i, v)
if i == "id" {
if idStr, ok := v.(string); ok {
id = idStr
}
// if idStr, ok := v.(string); ok {
// id = idStr
// } else {
// id = idStr
// }
id = v
}
if !publicmethod.RemoveReservedWord(i) {
editData[i] = v
@ -737,6 +742,7 @@ func (a *ApiMethod) GainEditDataLog(c *gin.Context) {
if v.SunDataCont != "" {
logCont["sunList"], _ = AnalysisSonLog(v.SunDataCont, tableUnitList.SunFormInfo)
}
logCont["explicate"] = v.Explicate
logAry = append(logAry, logCont)
}
sendData["logAry"] = logAry
@ -1062,6 +1068,7 @@ func ReformFlow(step int, nodeList []RunFlow) (nodeKey string, nextStep int, nod
nodeInfo.NodeKey = v.NodeKey //节点识别符
nodeInfo.NodeName = v.NodeName //节点名称
nodeInfo.Status = v.Status //1:未到达;2:已审批;3:已驳回;4:再次审批
nodeInfo.HelpTips = v.HelpTips
if i-1 >= 0 {
nodeInfo.FromNode = nodeNum[i-1]
}
@ -1134,7 +1141,7 @@ func (n *NodePublicInfo) CircularParsing(step int, creater modelshr.ManCont, org
nodeInfo.NodeName = n.NodeName
nodeInfo.Status = 1
nodeInfo.FromNode = n.FromNode
nodeInfo.HelpTips = n.HelpTips
if n.SendBackNode == "" {
nodeInfo.GoBackNode = "beginnode"
} else {
@ -2104,7 +2111,7 @@ func (a *ApiMethod) RetractRunWorkFlow(c *gin.Context) {
return
}
var runFlowInfo customerForm.RunWorkflow
err = runFlowInfo.GetCont(map[string]interface{}{"`flow_key`": requestData.Id}, "`id`", "`next_executor`", "`current_step`", "`next_step`", "`participants`", "`flow_key`", "`flow_cont`", "`runKey`")
err = runFlowInfo.GetCont(map[string]interface{}{"`id`": requestData.Id}, "`id`", "`next_executor`", "`current_step`", "`next_step`", "`participants`", "`flow_key`", "`flow_cont`", "`runKey`")
if err != nil {
publicmethod.Result(107, err, c)
return
@ -2146,24 +2153,24 @@ func (a *ApiMethod) RetractRunWorkFlow(c *gin.Context) {
if stepVal < 0 {
stepVal = 0
}
operatorAry, _ := FindOperator(userKey, runFlowInfo.RunKey, 3, flowList[stepVal].Operator, "主动回")
operatorAry, _ := FindOperator(userKey, runFlowInfo.RunKey, 3, flowList[stepVal].Operator, "主动回")
flowList[stepVal].Operator = operatorAry
fmt.Printf("operatorAry------------>%v\n", operatorAry)
saveFlowInfo["`flow_cont`"], _ = json.Marshal(flowList)
FlowRunLog(runFlowInfo.FlowKey, userCont.Key, 1, flowList[stepVal].NodeKey, "撤回申请", "")
FlowRunLog(runFlowInfo.Id, userCont.Key, 1, flowList[stepVal].NodeKey, "撤回申请", "")
} else {
FlowRunLog(runFlowInfo.FlowKey, userCont.Key, 1, "", "撤回申请", "")
FlowRunLog(runFlowInfo.Id, userCont.Key, 1, "", "撤回申请", "")
}
var runEditFlowInfo customerForm.RunWorkflow
err = runEditFlowInfo.EiteCont(map[string]interface{}{"`flow_key`": requestData.Id}, saveFlowInfo)
err = runEditFlowInfo.EiteCont(map[string]interface{}{"`id`": requestData.Id}, saveFlowInfo)
if err != nil {
publicmethod.Result(106, err, c)
return
}
var taskInfo customerForm.TaskRecord
taskInfo.EiteCont(map[string]interface{}{"`masters_key`": requestData.Id}, saveTaskInfo)
taskInfo.EiteCont(map[string]interface{}{"`runFlowId`": runFlowInfo.Id}, saveTaskInfo)
publicmethod.Result(0, err, c)
}

286
api/version1/taskplatform/taskmanagement/runTaskFlow.go

@ -0,0 +1,286 @@
package taskmanagement
import (
"appPlatform/models/customerForm"
"appPlatform/models/modelshr"
"appPlatform/overall"
"appPlatform/overall/publicmethod"
"encoding/json"
"fmt"
"strconv"
"strings"
"time"
"github.com/gin-gonic/gin"
)
/*
*
@ 作者: 秦东
@ 时间: 2024-06-18 09:11:38
@ 功能: 执行工作流
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) RunTaskFlow(c *gin.Context) {
var requestData SubmitAppResults
err := c.ShouldBindJSON(&requestData)
if err != nil {
publicmethod.Result(100, err, c)
return
}
if requestData.Id == "" {
publicmethod.Result(100, err, c)
return
}
if requestData.AgreeOrRefuse == 0 {
requestData.AgreeOrRefuse = 2
}
where := publicmethod.MapOut[string]()
where["`id`"] = requestData.Id
var flowInfo customerForm.RunWorkflow
err = flowInfo.GetCont(where)
if err != nil {
publicmethod.Result(107, err, c)
return
}
if flowInfo.NextStep == 0 || flowInfo.Status != 3 {
publicmethod.Result(1, err, c, "此流程再不可审批状态!您的提交无效")
return
}
if len(requestData.FlowList) < 1 {
if flowInfo.FlowCont != "" {
err = json.Unmarshal([]byte(flowInfo.FlowCont), &requestData.FlowList)
if err != nil {
publicmethod.Result(1, err, c, "流程异常!您的提交无效")
return
}
} else {
publicmethod.Result(1, err, c, "流程异常!您的提交无效")
return
}
}
context, _ := c.Get(overall.MyContJwt)
var userCont modelshr.ManCont
userCont.GetLoginCont(context) //当前操作人
//执行流程
var runFlow RunWorkFlow
runFlow.Step = flowInfo.NextStep
runFlow.TotalSteps = len(requestData.FlowList) //流程总长度
runFlow.Uuid = flowInfo.FlowKey
runFlow.RunUid = flowInfo.RunKey
runFlow.Participant = strings.Split(flowInfo.Participants, ",")
runFlow.FlowList = requestData.FlowList
runFlow.RunNodeHandle(userCont.Key, requestData.AgreeOrRefuse, requestData.Suggest)
if runFlow.IsRun {
publicmethod.Result(1, err, c, runFlow.Msg)
return
}
flowJsonCont, _ := json.Marshal(runFlow.FlowList) //将步进流转化成json流
saveFlowInfo := publicmethod.MapOut[string]()
saveTaskInfo := publicmethod.MapOut[string]()
saveFlowInfo["`flow_cont`"] = flowJsonCont
saveFlowInfo["`current_step`"] = runFlow.Step
saveFlowInfo["`next_step`"] = runFlow.NextStep
if flowInfo.Participants != "" {
oldUser := strings.Split(flowInfo.Participants, ",")
runFlow.Participant = append(runFlow.Participant, oldUser...)
}
//参与人去重
var parUser []string
for _, v := range runFlow.Participant {
if !publicmethod.IsInTrue[string](v, parUser) {
parUser = append(parUser, v)
}
}
saveFlowInfo["`participants`"] = strings.Join(parUser, ",")
var tsakInfos customerForm.TaskRecord
tsakInfos.GetCont(map[string]interface{}{"`runFlowId`": requestData.Id}, "`participant`")
if len(parUser) > 0 {
oldTaskUser := strings.Split(tsakInfos.Participant, ",")
for _, v := range parUser {
if !publicmethod.IsInTrue[string](v, oldTaskUser) {
oldTaskUser = append(oldTaskUser, v)
}
}
saveTaskInfo["`participant`"] = strings.Join(parUser, ",")
}
//抄送人
if flowInfo.MakeCopy != "" {
oldCopyUser := strings.Split(flowInfo.MakeCopy, ",")
runFlow.MakeCopy = append(runFlow.MakeCopy, oldCopyUser...)
}
var copyMan []string
for _, v := range runFlow.MakeCopy {
if !publicmethod.IsInTrue[string](v, copyMan) {
copyMan = append(copyMan, v)
}
}
saveFlowInfo["`makeCopy`"] = strings.Join(copyMan, ",")
//下一步执行人
nextRunUser := runFlow.NextRunNodeUser(requestData.AgreeOrRefuse)
saveFlowInfo["`next_executor`"] = strings.Join(nextRunUser, ",")
saveFlowInfo["`update_time`"] = time.Now().Unix()
if requestData.AgreeOrRefuse == 1 {
if runFlow.NextStep != 0 {
saveFlowInfo["`status`"] = 3
saveTaskInfo["`status`"] = 3
} else {
saveFlowInfo["`status`"] = 4
saveTaskInfo["`status`"] = 4
JudgeEditFlow(flowInfo.FlowKey)
}
} else {
saveFlowInfo["`runKey`"] = publicmethod.GetUUid(6)
if runFlow.Step != 1 {
saveFlowInfo["`status`"] = 3
} else {
saveFlowInfo["`status`"] = 2
saveTaskInfo["`status`"] = 1
}
}
saveTaskInfo["`edit_time`"] = time.Now().Unix()
gordb := overall.CONSTANT_DB_CustomerForm.Begin()
flowErr := gordb.Model(&customerForm.RunWorkflow{}).Where(where).Updates(saveFlowInfo).Error
taskErr := gordb.Model(&customerForm.TaskRecord{}).Where("`runFlowId` = ?", requestData.Id).Updates(saveTaskInfo).Error
if flowErr != nil || taskErr != nil {
gordb.Rollback()
publicmethod.Result(100, err, c, "数据提交失败!请重新提交!")
return
}
gordb.Commit()
publicmethod.Result(0, err, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2024-06-18 09:18:27
@ 功能: 执行节点处理
@ 参数
#userKey 当前处理人
#AgreeToRefuse 1同意2驳回
#Suggest 审批意见
@ 返回值
#
@ 方法原型
#
*/
func (r *RunWorkFlow) RunNodeHandle(userKey int64, AgreeToRefuse int, Suggest string) {
//判断流程是否存在
if len(r.FlowList) < 1 {
return
}
userKeyStr := strconv.FormatInt(userKey, 10) //当前操作人识别符转字符类型
fmt.Printf("执行节点处理--->%v------>%v\n", r.Step, r.NextStep)
//遍历流程判断当前要执行的步骤
for i := 0; i < r.TotalSteps; i++ {
if r.FlowList[i].Step == r.Step { //获取当前操作节点
//Step1:判断当前节点是不是抄送节点
if r.FlowList[i].Types == 2 {
currentStep, nextStep := PaceStep(r.RunUid, r.Step, r.TotalSteps, r.FlowList[i])
for _, op := range r.FlowList[i].Operator {
r.MakeCopy = append(r.MakeCopy, op.Id)
userkIntId, _ := strconv.ParseInt(op.Id, 10, 64)
title := fmt.Sprintf("向%v发送抄送数据", op.Name)
FlowRunLog(r.Uuid, userkIntId, AgreeToRefuse, r.FlowList[i].NodeKey, title, "")
// fmt.Printf("抄送人---->%v---->%v\n", userkIntId, title)
}
r.Step = currentStep
r.NextStep = nextStep
if nextStep > 0 {
if JudgeRunNode(nextStep, r.FlowList) {
r.Step = nextStep
r.RunNodeHandle(userKey, AgreeToRefuse, Suggest)
}
}
} else {
r.IsRun, r.Msg = JudgeOperUser(userKey, r.RunUid, r.FlowList[i].Operator) //判断操作人是有操作权限或是否已经操作过
if r.IsRun {
return
} else {
if AgreeToRefuse != 1 { //驳回操作
r.FlowList[i].Status = 3
operatorAry, nodeUser := FindOperator(userKeyStr, r.RunUid, 3, r.FlowList[i].Operator, Suggest)
r.FlowList[i].Operator = operatorAry
r.Participant = append(r.Participant, nodeUser...)
r.RejectNode(r.FlowList[i].GoBackNode)
return
} else {
currentStep, nextStep := PaceStep(r.RunUid, r.Step, r.TotalSteps, r.FlowList[i])
fmt.Printf("同意操作---->%v---->%v---->%v\n", currentStep, nextStep, r.FlowList[i].Types)
r.FlowList[i].Status = 2
operatorAry, nodeUser := FindOperator(userKeyStr, r.RunUid, 2, r.FlowList[i].Operator, Suggest)
r.FlowList[i].Operator = operatorAry
r.Participant = append(r.Participant, nodeUser...)
switch r.FlowList[i].Types {
case 0:
r.Step = currentStep
r.NextStep = nextStep
FlowRunLog(r.Uuid, userKey, 2, r.FlowList[i].NodeKey, "发起流程", "")
if JudgeRunNode(nextStep, r.FlowList) {
r.Step = nextStep
r.FlowStepRun(userKey, AgreeToRefuse, Suggest)
}
return
case 1:
r.Step = currentStep
r.NextStep = nextStep
// fmt.Printf("判断是否继续执行---->%v\n", JudgeRunNode(nextStep, r.FlowList))
FlowRunLog(r.Uuid, userKey, 2, r.FlowList[i].NodeKey, Suggest, "")
if JudgeRunNode(nextStep, r.FlowList) {
r.Step = nextStep
r.RunNodeHandle(userKey, AgreeToRefuse, Suggest)
}
case 2:
if currentStep+1 < r.TotalSteps {
r.Step = currentStep + 1
if nextStep+1 <= r.TotalSteps {
r.NextStep = nextStep + 1
} else {
r.NextStep = 0
}
} else {
r.Step = r.TotalSteps
r.NextStep = 0
}
for _, op := range r.FlowList[i].Operator {
r.MakeCopy = append(r.MakeCopy, op.Id)
userkIntId, _ := strconv.ParseInt(op.Id, 10, 64)
title := fmt.Sprintf("向%v发送抄送数据", op.Name)
FlowRunLog(r.Uuid, userkIntId, AgreeToRefuse, r.FlowList[i].NodeKey, title, "")
}
case 3:
r.Step = currentStep
r.NextStep = nextStep
FlowRunLog(r.Uuid, userKey, 2, r.FlowList[i].NodeKey, Suggest, "")
if JudgeRunNode(nextStep, r.FlowList) {
r.Step = nextStep
r.RunNodeHandle(userKey, AgreeToRefuse, Suggest)
}
default:
}
}
}
}
}
}
}

112
api/version1/taskplatform/taskmanagement/runWorkFlow.go

@ -72,7 +72,7 @@ func (a *ApiMethod) StartRunWorkFlow(c *gin.Context) {
//执行工作流内容
var workFlowInfo customerForm.RunWorkflow
workFlowInfo.Id = uuid
workFlowInfo.FlowKey, _ = strconv.ParseInt(requestData.Id, 10, 64) //统一识别符(任务标识符)
workFlowInfo.FlowKey = taskInfo.FlowKey //统一识别符(任务标识符)
workFlowInfo.Version = strconv.FormatInt(taskInfo.FlowRunSing, 10) //工作流版本
workFlowInfo.VersionCont = flowVersionInfo.Content //当前工作流内容
workFlowInfo.Creater = userCont.Key //流程发起人
@ -115,6 +115,7 @@ func (a *ApiMethod) StartRunWorkFlow(c *gin.Context) {
workFlowInfo.Status = 4
}
}
fmt.Printf("步进值-1--%v---->%v》", executeWorkflow.Step, executeWorkflow.NextStep)
err = workFlowInfo.WriteCont() //写入执行工作流
if err != nil {
var taskInfo customerForm.TaskRecord
@ -124,10 +125,10 @@ func (a *ApiMethod) StartRunWorkFlow(c *gin.Context) {
}
if executeWorkflow.NextStep <= 0 {
var taskCont customerForm.TaskRecord
taskCont.EiteCont(map[string]interface{}{"`masters_key`": requestData.Id}, map[string]interface{}{"`status`": 4})
taskCont.EiteCont(map[string]interface{}{"`masters_key`": requestData.Id}, map[string]interface{}{"`status`": 4, "`runFlowId`": uuid})
} else {
var taskCont customerForm.TaskRecord
taskCont.EiteCont(map[string]interface{}{"`masters_key`": requestData.Id}, map[string]interface{}{"`status`": requestData.State})
taskCont.EiteCont(map[string]interface{}{"`masters_key`": requestData.Id}, map[string]interface{}{"`status`": requestData.State, "`runFlowId`": uuid})
}
publicmethod.Result(0, err, c)
}
@ -216,6 +217,7 @@ func (r *RunWorkFlow) GainRunNode(userKey string, AgreeToRefuse int, runCont str
r.FlowList[i].Operator = operatorAry
r.FlowList[i].Status = AgreeToRefuse
r.Participant = append(r.Participant, nodeUser...)
fmt.Printf("节点类型设置---->%v---->%v---->%v\n", r.FlowList[i].Types, currentStep, nextStep)
switch r.FlowList[i].Types { //0:发起节点;1:审批节点;2:抄送;3:执行节点
case 0:
r.Step = currentStep
@ -389,6 +391,8 @@ func PaceStep(runId int64, step, totalSteps int, nodeInfo RunFlow) (currentStep,
if nodeInfo.ExamineMode == 0 { //多人审批时采用的审批方式。0:无操作 1依次审批 2会签 3:非会签
}
duoren, _ := json.Marshal(nodeInfo)
fmt.Printf("当前操作节点----->%v\n", string(duoren))
switch nodeInfo.ExamineMode {
case 0:
if step >= totalSteps {
@ -509,7 +513,7 @@ func (a *ApiMethod) DraftsInitiateApproval(c *gin.Context) {
userCont.GetLoginCont(context) //当前操作人
creetTime := time.Now().Unix() //当前时间
var runInfo customerForm.RunWorkflow
err = runInfo.GetCont(map[string]interface{}{"`flow_key`": requestData.Id}, "`flow_cont`", "`current_step`", "`runKey`", "`participants`")
err = runInfo.GetCont(map[string]interface{}{"`id`": requestData.Id}, "`flow_cont`", "`current_step`", "`runKey`", "`participants`")
if err != nil {
publicmethod.Result(107, err, c)
return
@ -559,13 +563,13 @@ func (a *ApiMethod) DraftsInitiateApproval(c *gin.Context) {
saveFlow["`update_time`"] = creetTime
saveTask["edit_time"] = creetTime
var saveRunInfo customerForm.RunWorkflow
err = saveRunInfo.EiteCont(map[string]interface{}{"`flow_key`": requestData.Id}, saveFlow)
err = saveRunInfo.EiteCont(map[string]interface{}{"`id`": requestData.Id}, saveFlow)
if err != nil {
publicmethod.Result(106, err, c)
return
}
var saveTaskInfo customerForm.TaskRecord
saveTaskInfo.EiteCont(map[string]interface{}{"`masters_key`": requestData.Id}, saveTask)
saveTaskInfo.EiteCont(map[string]interface{}{"`runFlowId`": requestData.Id}, saveTask)
publicmethod.Result(0, err, c)
}
@ -598,7 +602,8 @@ func (a *ApiMethod) GainRunTaskWorkflow(c *gin.Context) {
return
}
var runFlowInfo customerForm.RunWorkflow
err = runFlowInfo.GetCont(map[string]interface{}{"`flow_key`": requestData.Id})
// err = runFlowInfo.GetCont(map[string]interface{}{"`flow_key`": requestData.Id})
err = runFlowInfo.GetCont(map[string]interface{}{"`id`": requestData.Id})
if err != nil || runFlowInfo.FlowCont == "" {
publicmethod.Result(107, err, c)
return
@ -887,7 +892,7 @@ func (a *ApiMethod) AfreshRunWorkflow(c *gin.Context) {
return
}
var runFlowInfo customerForm.RunWorkflow
err = runFlowInfo.GetCont(map[string]interface{}{"`flow_key`": requestData.Id}, "`id`", "`next_executor`", "`current_step`", "`next_step`", "`participants`", "`flow_key`", "`flow_cont`", "`runKey`")
err = runFlowInfo.GetCont(map[string]interface{}{"`id`": requestData.Id}, "`id`", "`next_executor`", "`current_step`", "`next_step`", "`participants`", "`flow_key`", "`flow_cont`", "`runKey`")
if err != nil {
publicmethod.Result(107, err, c)
return
@ -942,7 +947,7 @@ func (a *ApiMethod) AfreshRunWorkflow(c *gin.Context) {
saveTask := publicmethod.MapOut[string]()
saveTask["`status`"] = 3
saveTask["`edit_time`"] = time.Now().Unix()
taskInfo.EiteCont(map[string]interface{}{"`masters_key`": requestData.Id}, saveTask)
taskInfo.EiteCont(map[string]interface{}{"`runFlowId`": requestData.Id}, saveTask)
publicmethod.Result(0, runFlowInfo, c)
}
@ -1166,7 +1171,7 @@ func (a *ApiMethod) AuthorizeWorkflow(c *gin.Context) {
requestData.AgreeOrRefuse = 2
}
where := publicmethod.MapOut[string]()
where["`flow_key`"] = requestData.Id
where["`id`"] = requestData.Id
var flowInfo customerForm.RunWorkflow
err = flowInfo.GetCont(where)
if err != nil {
@ -1202,6 +1207,9 @@ func (a *ApiMethod) AuthorizeWorkflow(c *gin.Context) {
runFlow.Participant = strings.Split(flowInfo.Participants, ",")
runFlow.FlowList = requestData.FlowList
runFlow.FlowStepRun(userCont.Key, requestData.AgreeOrRefuse, requestData.Suggest)
// publicmethod.Result(1, runFlow, c, runFlow.Msg)
// return
if runFlow.IsRun {
publicmethod.Result(1, err, c, runFlow.Msg)
return
@ -1224,6 +1232,31 @@ func (a *ApiMethod) AuthorizeWorkflow(c *gin.Context) {
}
}
saveFlowInfo["`participants`"] = strings.Join(parUser, ",")
var tsakInfos customerForm.TaskRecord
tsakInfos.GetCont(map[string]interface{}{"`runFlowId`": requestData.Id}, "`participant`")
if len(parUser) > 0 {
oldTaskUser := strings.Split(tsakInfos.Participant, ",")
for _, v := range parUser {
if !publicmethod.IsInTrue[string](v, oldTaskUser) {
oldTaskUser = append(oldTaskUser, v)
}
}
saveTaskInfo["`participant`"] = strings.Join(parUser, ",")
}
//抄送人
if flowInfo.MakeCopy != "" {
oldCopyUser := strings.Split(flowInfo.MakeCopy, ",")
runFlow.MakeCopy = append(runFlow.MakeCopy, oldCopyUser...)
}
var copyMan []string
for _, v := range runFlow.MakeCopy {
if !publicmethod.IsInTrue[string](v, copyMan) {
copyMan = append(copyMan, v)
}
}
saveFlowInfo["`makeCopy`"] = strings.Join(copyMan, ",")
//下一步执行人
nextRunUser := runFlow.NextRunNodeUser(requestData.AgreeOrRefuse)
saveFlowInfo["`next_executor`"] = strings.Join(nextRunUser, ",")
@ -1249,7 +1282,7 @@ func (a *ApiMethod) AuthorizeWorkflow(c *gin.Context) {
saveTaskInfo["`edit_time`"] = time.Now().Unix()
gordb := overall.CONSTANT_DB_CustomerForm.Begin()
flowErr := gordb.Model(&customerForm.RunWorkflow{}).Where(where).Updates(saveFlowInfo).Error
taskErr := gordb.Model(&customerForm.TaskRecord{}).Where("`masters_key` = ?", requestData.Id).Updates(saveTaskInfo).Error
taskErr := gordb.Model(&customerForm.TaskRecord{}).Where("`runFlowId` = ?", requestData.Id).Updates(saveTaskInfo).Error
if flowErr != nil || taskErr != nil {
gordb.Rollback()
publicmethod.Result(100, err, c, "数据提交失败!请重新提交!")
@ -1420,6 +1453,9 @@ func (r *RunWorkFlow) FlowStepRun(userKey int64, AgreeToRefuse int, Suggest stri
return
} else { //同意操作
currentStep, nextStep := PaceStep(r.RunUid, r.Step, r.TotalSteps, r.FlowList[i])
fmt.Printf("同意操作---->%v---->%v---->%v\n", currentStep, nextStep, r.FlowList[i].Types)
r.FlowList[i].Status = 2
operatorAry, nodeUser := FindOperator(userKeyStr, r.RunUid, 2, r.FlowList[i].Operator, Suggest)
r.FlowList[i].Operator = operatorAry
@ -1442,6 +1478,7 @@ func (r *RunWorkFlow) FlowStepRun(userKey int64, AgreeToRefuse int, Suggest stri
r.NextStep = nextStep
// fmt.Printf("执行曹总--0->%v->%v\n", r.Step, r.NextStep)
for _, op := range r.FlowList[i].Operator {
r.MakeCopy = append(r.MakeCopy, op.Id)
userkIntId, _ := strconv.ParseInt(op.Id, 10, 64)
title := fmt.Sprintf("向%v发送抄送数据", op.Name)
FlowRunLog(r.Uuid, userkIntId, AgreeToRefuse, r.FlowList[i].NodeKey, title, "")
@ -1549,3 +1586,56 @@ func JudgeOperUser(userKey, runId int64, Operator []OperatorList) (bool, string)
}
return false, ""
}
/*
*
@ 作者: 秦东
@ 时间: 2024-06-04 10:27:12
@ 功能: 获取执行流程
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) GainRunFlowStart(c *gin.Context) {
var requestData publicmethod.PublicId
err := c.ShouldBindJSON(&requestData)
if err != nil {
publicmethod.Result(100, err, c)
return
}
if requestData.Id == "" {
publicmethod.Result(107, err, c)
return
}
var flowPage modelAppPlatform.FlowVersion //获取当前启用的流程信息
err = flowPage.GetCont(map[string]interface{}{"`key`": requestData.Id, "`state`": 1})
var flowCont FlowMainBody //整体流程架构
var sendInfo SendFlowInfo //执行流程
if err != nil && flowPage.Content == "" {
publicmethod.Result(0, sendInfo, c)
return
}
err = json.Unmarshal([]byte(flowPage.Content), &flowCont) //解析流程列表
if err != nil {
publicmethod.Result(0, sendInfo, c)
return
}
context, _ := c.Get(overall.MyContJwt)
var userCont modelshr.ManCont
userCont.GetLoginCont(context) //获取当前操作人
var judgeWhy []ConditionListInfo //判断条件
var ddd []NodelPeopleInfo
workFlowInfo := flowCont.NodeConfig.CircularParsing(1, userCont, userCont.AdminOrg, judgeWhy, ddd)
sendInfo.Step = 1
sendInfo.NodeKey, sendInfo.NextStep, sendInfo.FlowList = ReformFlow(1, workFlowInfo)
publicmethod.Result(0, sendInfo, c)
}

37
apirouter/v1/customerformrouter/router.go

@ -49,5 +49,42 @@ func (a *ApiRouter) RouterGroupPc(router *gin.RouterGroup) {
apiRouter.POST("gainFormListCont", methodBinding.GainFormListCont) //获取表单列表数据
apiRouter.POST("gainFormPageListCont", methodBinding.GainFormPageListCont) //获取表单列表翻页数据
apiRouter.POST("gainListTableField", methodBinding.GainListTableField) //列表展示需要字段
apiRouter.POST("multiViewPage", methodBinding.MultiViewPAge) //多视图数据处理
apiRouter.POST("gainCalendarList", methodBinding.GainCalendarList) //日历视图数据处理
}
appApiRouter := router.Group("app")
var methodAppHand = version1.AppApiEntry.CustomerAppApi
{
appApiRouter.GET("", methodAppHand.Index) //入口
appApiRouter.POST("", methodAppHand.Index) //入口
appApiRouter.POST("createApp", methodAppHand.CreateApp) //创建APP
appApiRouter.POST("gainAppEditPsge", methodAppHand.GainAppEditPsge) //获取应用编辑页面信息
appApiRouter.POST("ginOthenMenuTree", methodAppHand.GinOthenMenuTree) //获取除固定菜单以外的数据
appApiRouter.POST("saveAppMenu", methodAppHand.SaveAppMenu) //新增菜单
appApiRouter.POST("gainAllAppMenu", methodAppHand.GainAllAppMenu) //获取完整APP菜单树
appApiRouter.POST("editAppMenuCont", methodAppHand.EditAppMenuCont) //修改App菜单结构
appApiRouter.POST("editAppMenuLable", methodAppHand.EditAppMenuLable) //修改菜单名称
appApiRouter.POST("appMenuShowOrHide", methodAppHand.AppMenuShowOrHide) //显示和隐藏菜单
appApiRouter.POST("delAppMenu", methodAppHand.DelAppMenu) //删除app菜单
appApiRouter.POST("createAppForm", methodAppHand.CreateAppForm) //写入app表单菜单
appApiRouter.POST("gainAppPageInfo", methodAppHand.GainAppPageInfo) //获取app页面综合信息
appApiRouter.POST("editAppPageInfo", methodAppHand.EditAppPageInfo) //编辑App表单数据
appApiRouter.POST("saveOtherVersion", methodAppHand.SaveOtherVersion) //保存新版本
appApiRouter.POST("previewAppFormVersion", methodAppHand.PreviewAppFormVersion) //预览App多版本表单页面
appApiRouter.POST("appBasicSettings", methodAppHand.AppBasicSettings) //设置App基础
appApiRouter.POST("gainLookViews", methodAppHand.GainLookViews) //获取可见范围数据及应用管理
appApiRouter.POST("setLookViews", methodAppHand.SetLookViews) //设置可见范围
appApiRouter.POST("setAppManagerInfo", methodAppHand.SetAppManagerInfo) //设置管理使用人员
appApiRouter.POST("gianAppFormTable", methodAppHand.GianAppFormTable) //获取应用下属表单
appApiRouter.POST("setCustomerFormState", methodAppHand.SetCustomerFormState) //设置自定义表单状态
appApiRouter.POST("appJwtPower", methodAppHand.AppJwtPower) //鉴定当权人员是否有权限使用
}
}

1
apirouter/v1/public/router.go

@ -24,5 +24,6 @@ func (a *ApiRouter) RouterGroupPc(router *gin.RouterGroup) {
apiRouter.POST("obtainToken", methodBinding.ObtainToken) //一键登录授权
apiRouter.GET("verifyIdentity", methodBinding.VerifyIdentity) //验证身份登录
apiRouter.POST("silentLogin", methodBinding.SilentLogin) //验证无感登录
apiRouter.POST("gainAllRole", methodBinding.GainAllRole) //获取角色列表
}
}

14
apirouter/v1/taskrouter/taskrouter.go

@ -42,6 +42,11 @@ func (a *ApiRouter) RouterGroupPc(router *gin.RouterGroup) {
apiRouter.POST("afreshRunWorkflow", taskManagementRouter.AfreshRunWorkflow) //重新发起流程
apiRouter.POST("applyForTableFormData", taskManagementRouter.ApplyForTableFormData) //申请修改数据
apiRouter.POST("authorizeWorkflow", taskManagementRouter.AuthorizeWorkflow) //审批处理
apiRouter.POST("gainRunFlowStart", taskManagementRouter.GainRunFlowStart) //获取执行流程
apiRouter.POST("createAppTask", taskManagementRouter.CreateAppTask) //自定义App表单新增记录
apiRouter.POST("runTaskFlow", taskManagementRouter.RunTaskFlow) //执行工作流
}
taskFlowApi := router.Group("task_flow")
@ -83,5 +88,14 @@ func (a *ApiRouter) RouterGroupPc(router *gin.RouterGroup) {
taskFlowApi.POST("editLookPowerView", taskFlowRouter.EditLookPowerView) //编辑可见范围
taskFlowApi.POST("setUpMsg", taskFlowRouter.SetUpMsg) //编辑消息提醒
taskFlowApi.POST("gainSetUpMsg", taskFlowRouter.GainSetUpMsg) //获取消息设置
taskFlowApi.POST("gainAppTaskList", taskFlowRouter.GainAppTaskList) //获取App任务(任务流版本)
taskFlowApi.POST("gainAppAllTaskList", taskFlowRouter.GainAppAllTaskList) //获取App任务(包含非流程表单)
taskFlowApi.POST("editTaskAppInfo", taskFlowRouter.EditTaskAppInfo) //编辑任务内容
taskFlowApi.POST("saveDraftAgain", taskFlowRouter.SaveDraftAgain) //再次保存草稿箱内容
taskFlowApi.POST("afreshAppSubmit", taskFlowRouter.AfreshAppSubmit) // 重新提交(有流程就发动流程,无流程就正常发表)
}
}

3
initialization/app/run.go

@ -1,10 +1,10 @@
package app
import (
"fmt"
"appPlatform/initialization/initviper"
"appPlatform/initialization/route"
"appPlatform/overall"
"fmt"
)
type server interface {
@ -22,5 +22,6 @@ func RunItem() {
startUp := InitServer(portStr, routers)
fmt.Printf("\n\n默认API运行地址:http://127.0.0.1%s\n", portStr)
runErr := startUp.ListenAndServe().Error()
fmt.Printf("\n\n%s\n", runErr)
panic(fmt.Errorf(runErr))
}

97
models/customerForm/runFlowTask.go

@ -0,0 +1,97 @@
package customerForm
import (
"appPlatform/overall"
"strings"
)
// 工作流执行主体
// 字典类型
type RunFlowTask struct {
Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"`
FlowKey int64 `json:"flowKey" 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:使用得版本"`
Status int `json:"status" gorm:"column:status;type:int(1) unsigned;default:1;not null;comment:状态:1、草稿;2:驳回;3:通过;4:归档;5:删除"`
FlowCont string `json:"flowcont" gorm:"column:flow_cont;type:longtext;comment:流程执行体"`
Creater int64 `json:"creater" gorm:"column:creater;type:bigint(20) unsigned;default:0;not null;comment:流程发起人"`
CurrentStep int `json:"currentStep" gorm:"column:current_step;type:int(4) unsigned;default:1;not null;comment:当前节点"`
NextStep int `json:"nextStep" gorm:"column:next_step;type:int(4) unsigned;default:0;not null;comment:下一个节点。0:代表没有下一个节点。流程结束"`
NextExecutor string `json:"nextExecutor" gorm:"column:next_executor;type:mediumtext;default:'';comment:下一步执行人"`
Participants string `json:"participants" gorm:"column:participants;type:longtext;comment:参与人"`
StartTime int64 `json:"startTime" gorm:"column:start_time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"`
UpdateTime int64 `json:"update_time" gorm:"column:update_time;type:bigint(20) unsigned;default:0;not null;comment:编辑时间"`
VersionCont string `json:"versionCont" gorm:"column:version_cont;type:longtext;comment:版本流程内容"`
RunKey int64 `json:"runKey" gorm:"column:runKey;type:bigint(20) unsigned;default:0;not null;comment:当前执行识别符"`
Title string `json:"title" gorm:"column:title;type:varchar(255) unsigned;default:'';not null;comment:标题"`
TaskCreate int64 `json:"taskCreate" gorm:"column:taskCreate;type:bigint(20) unsigned;default:0;not null;comment:创建人"`
CreaterTime int64 `json:"creater_time" gorm:"column:creater_time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"`
Types int `json:"types" gorm:"column:types;type:int(1) unsigned;default:1;not null;comment:类型(1:普通表单;2:流程表单)"`
VersionId int64 `json:"version_id" gorm:"column:version_id;type:bigint(20) unsigned;default:0;not null;comment:来源于哪个表单"`
State int `json:"state" gorm:"column:state;type:int(1) unsigned;default:1;not null;comment:状态(1:草稿,2:发表;3:审批中;4:归档;5:删除)"`
// MastersKey int64 `json:"masters_key" gorm:"column:masters_key;type:bigint(20) unsigned;default:0;not null;comment:主表标识"`
TaskFlowKey int64 `json:"taskFlowKey" gorm:"column:taskFlowKey;type:bigint(20) unsigned;default:0;not null;comment:主表标识"`
FlowRunSing int64 `json:"flowRunSing" gorm:"column:flow_run_sing;type:bigint(20) unsigned;default:0;not null;comment:主表标识"`
MastesForm string `json:"mastesform" gorm:"column:mastesform;type:longtext;default:'';comment:表单结构"`
MastesFormJson string `json:"mastesformjson" gorm:"column:mastesformjson;type:longtext;default:'';comment:表单结构json"`
Visibility int `json:"visibility" gorm:"column:visibility;type:int(1) unsigned;default:1;not null;comment:1、所有人;2、自定义"`
AuthorizationRoles string `json:"authorizationRoles" gorm:"column:authorizationRoles;type:mediumtext;comment:授权角色"`
AuthorizedPersonnel string `json:"authorizedPersonnel" gorm:"column:authorizedPersonnel;type:mediumtext;comment:授权人员"`
AuthorizedOrg string `json:"authorizedOrg" gorm:"column:authorizedOrg;type:mediumtext;comment:授权行政组织"`
AuthorizedPosition string `json:"authorizedPosition" gorm:"column:authorizedPosition;type:mediumtext;comment:授权职务"`
Participant string `json:"participant" gorm:"column:participant;type:longtext;default:'';comment:表单结构json"`
TableKey int64 `json:"tableKey" gorm:"column:tableKey;type:bigint(20) unsigned;default:0;not null;comment:归属自定义表"`
AppKey int64 `json:"appKey" gorm:"column:appKey;type:bigint(20) unsigned;default:0;not null;comment:归属App(0:非app表单)"`
MakeCopy string `json:"makeCopy" gorm:"column:makeCopy;type:mediumtext;comment:抄送人"`
MastersKey int64 `json:"masters_key" gorm:"column:masters_key;type:bigint(20) unsigned;default:0;not null;comment:主表识别符"`
}
func (RunFlowTask *RunFlowTask) TableName() string {
return "runFlowTask"
}
// 写入内容
func (cont *RunFlowTask) WriteCont() (err error) {
err = overall.CONSTANT_DB_CustomerForm.Create(&cont).Error
return
}
// 编辑内容
func (cont *RunFlowTask) EiteCont(whereMap interface{}, saveData interface{}) (err error) {
err = overall.CONSTANT_DB_CustomerForm.Model(&cont).Where(whereMap).Updates(saveData).Error
return
}
// 获取内容
func (cont *RunFlowTask) GetCont(whereMap interface{}, field ...string) (err error) {
gormDb := overall.CONSTANT_DB_CustomerForm.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 *RunFlowTask) CountCont(whereMap interface{}) (countId int64) {
overall.CONSTANT_DB_CustomerForm.Model(&cont).Where(whereMap).Count(&countId)
return
}
// 读取全部信息
func (cont *RunFlowTask) ContMap(whereMap interface{}, field ...string) (countAry []RunFlowTask, err error) {
gormDb := overall.CONSTANT_DB_CustomerForm.Model(&cont)
if len(field) > 0 {
fieldStr := strings.Join(field, ",")
gormDb = gormDb.Select(fieldStr)
}
err = gormDb.Where(whereMap).Find(&countAry).Error
return
}
// 删除内容
func (cont *RunFlowTask) DelCont(whereMap interface{}) (err error) {
err = overall.CONSTANT_DB_CustomerForm.Where(whereMap).Delete(&cont).Error
return
}

3
models/customerForm/runWorkflow.go

@ -22,10 +22,11 @@ type RunWorkflow struct {
UpdateTime int64 `json:"update_time" gorm:"column:update_time;type:bigint(20) unsigned;default:0;not null;comment:编辑时间"`
VersionCont string `json:"versionCont" gorm:"column:version_cont;type:longtext;comment:版本流程内容"`
RunKey int64 `json:"runKey" gorm:"column:runKey;type:bigint(20) unsigned;default:0;not null;comment:当前执行识别符"`
MakeCopy string `json:"makeCopy" gorm:"column:makeCopy;type:mediumtext;comment:抄送人"`
}
func (RunWorkflow *RunWorkflow) TableName() string {
return "runWorkflow"
return "runworkflow"
}
// 写入内容

5
models/customerForm/taskrecord.go

@ -7,7 +7,7 @@ import (
// 自定义表单任务表
type TaskRecord struct {
Id int `json:"id" gorm:"primaryKey;column:id;type:int(5) unsigned;not null;comment:Id;index"`
Id int64 `json:"id" gorm:"primaryKey;column:id;type:int(5) unsigned;not null;comment:Id;index"`
Title string `json:"title" gorm:"column:title;type:varchar(255) unsigned;default:'';not null;comment:标题"`
Creater int64 `json:"creater" gorm:"column:creater;type:bigint(20) unsigned;default:0;not null;comment:创建人"`
CreaterTime int64 `json:"creater_time" gorm:"column:creater_time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"`
@ -26,6 +26,9 @@ type TaskRecord struct {
AuthorizedOrg string `json:"authorizedOrg" gorm:"column:authorizedOrg;type:mediumtext;comment:授权行政组织"`
AuthorizedPosition string `json:"authorizedPosition" gorm:"column:authorizedPosition;type:mediumtext;comment:授权职务"`
Participant string `json:"participant" gorm:"column:participant;type:longtext;default:'';comment:表单结构json"`
TableKey int64 `json:"tableKey" gorm:"column:tableKey;type:bigint(20) unsigned;default:0;not null;comment:归属自定义表"`
AppKey int64 `json:"appKey" gorm:"column:appKey;type:bigint(20) unsigned;default:0;not null;comment:归属App(0:非app表单)"`
RunFlowId int64 `json:"runFlowId" gorm:"column:runFlowId;type:bigint(20) unsigned;default:0;not null;comment:正在执行得流程"`
}
func (TaskRecord *TaskRecord) TableName() string {

86
models/modelAppPlatform/appmenus.go

@ -0,0 +1,86 @@
package modelAppPlatform
import (
"appPlatform/overall"
"strings"
)
/*
*
@ 作者: 秦东
@ 时间: 2024-04-23 11:25:43
@ 功能: 自定义应用菜单表
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
type Appmenus struct {
Id int64 `json:"id" gorm:"primaryKey;column:id;type:int(5) unsigned;not null;comment:Id;index"`
Label string `json:"label" gorm:"column:label;type:varchar(255) unsigned;default:'';not null;comment:节点名称"`
Types int `json:"type" gorm:"column:type;type:int(1) unsigned;default:1;not null;comment:节点类型 1:目录;2:菜单"`
Svg string `json:"svg" gorm:"column:svg;type:varchar(255) DEFAULT '' comment:图标"`
PcIsShow int `json:"pcIsShow" gorm:"column:pcIsShow;type:int(1) unsigned DEFAULT '1' comment:pc端显示与隐藏(1:显示;非1:隐藏)"`
WapIsShow int `json:"wapIsShow" gorm:"column:wapIsShow;type:int(1) unsigned DEFAULT '1' comment:移动端显示与隐藏(1:显示;非1:隐藏)"`
Parent int64 `json:"parent" gorm:"column:parent;type:bigint(20) unsigned;default:0;not null;comment:上级"`
Appkey int64 `json:"appkey" gorm:"column:appkey;type:bigint(20) unsigned;default:0;not null;comment:归属哪个应用"`
CreaterTime int64 `json:"creater_time" gorm:"column:creater_time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"`
EditTime int64 `json:"edit_time" gorm:"column:edit_time;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:创建人"`
IsLock int `json:"isLock" gorm:"column:isLock;type:int(1) unsigned NOT NULL DEFAULT '2' comment:是否为固定菜单(1:是;2:否)"`
Sort int64 `json:"sort" gorm:"column:sort;type:int(5) unsigned NOT NULL DEFAULT '50' comment:排序"`
State int `json:"state" gorm:"column:state;type:int(1) unsigned NOT NULL DEFAULT '1' comment:状态(1:启用;2:禁用;3:删除)"`
IsMain int `json:"isMain" gorm:"column:isMain;type:int(1) unsigned NOT NULL DEFAULT '2' comment:1:入口;2:不是入口"`
}
func (Appmenus *Appmenus) TableName() string {
return "appmenus"
}
// 编辑内容
func (cont *Appmenus) EiteCont(whereMap interface{}, saveData interface{}) (err error) {
err = overall.CONSTANT_DB_AppPlatform.Model(&cont).Where(whereMap).Updates(saveData).Error
return
}
// 获取内容
func (cont *Appmenus) 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 *Appmenus) CountCont(whereMap interface{}) (countId int64) {
overall.CONSTANT_DB_AppPlatform.Model(&cont).Where(whereMap).Count(&countId)
return
}
// 读取全部信息
func (cont *Appmenus) ContMap(whereMap interface{}, field ...string) (countAry []Appmenus, 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 *Appmenus) DelCont(whereMap interface{}) (err error) {
err = overall.CONSTANT_DB_AppPlatform.Where(whereMap).Delete(&cont).Error
return
}

38
models/modelAppPlatform/customer_form.go

@ -7,22 +7,28 @@ import (
// 字典类型
type CustomerForm struct {
Id int64 `json:"id" gorm:"primaryKey;column:id;type:int(5) unsigned;not null;comment:Id;index"`
Name string `json:"name" gorm:"column:name;type:varchar(255) unsigned;default:'';not null;comment:表单名称"`
TableNames string `json:"tablename" gorm:"column:tablename;type:varchar(255) unsigned;default:'';not null;comment:创建表单名称"`
Classify int `json:"classify" gorm:"column:classify;type:int(1) unsigned;default:1;not null;comment:分类1:表单;2:流程表单"`
Permit string `json:"permit" gorm:"column:permit;type:mediumtext;default:'';comment:授权范围"`
PermitStr string `json:"permitstr" gorm:"column:permitstr;type:mediumtext;default:'';comment:授权范围"`
States int `json:"states" gorm:"column:states;type:int(1) unsigned;default:1;not null;comment:显示状态(1:启用;2:禁用,3:删除)"`
CreaterTime int64 `json:"createrTime" gorm:"column:creater_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:编辑时间"`
FlowKey int64 `json:"flowkey" gorm:"column:flowkey;type:bigint(20) unsigned;default:0;not null;comment:关联工作流"`
UserPermit string `json:"userpermit" gorm:"column:userpermit;type:mediumtext;default:'';comment:授权范围可见人员"`
PostPermit string `json:"postpermit" gorm:"column:postpermit;type:mediumtext;default:'';comment:授权范围可见角色"`
Groupid int64 `json:"groupid" gorm:"column:groupid;type:bigint(20) unsigned;default:0;not null;comment:分组Id"`
Icon string `json:"icon" gorm:"column:icon;type:varchar(255);default:'';comment:图标"`
FlowIsOpen int `json:"flowIsOpen" gorm:"column:flowIsOpen;type:int(1) unsigned;default:2;not null;comment:是否开启工作流(1:启用;2:禁用)"`
ListJson string `json:"listjson" gorm:"column:listjson;type:longtext;default:'';comment:列表结构体"`
Id int64 `json:"id" gorm:"primaryKey;column:id;type:int(5) unsigned;not null;comment:Id;index"`
Name string `json:"name" gorm:"column:name;type:varchar(255) unsigned;default:'';not null;comment:表单名称"`
TableNames string `json:"tablename" gorm:"column:tablename;type:varchar(255) unsigned;default:'';not null;comment:创建表单名称"`
Classify int `json:"classify" gorm:"column:classify;type:int(1) unsigned;default:1;not null;comment:分类1:表单;2:流程表单"`
Permit string `json:"permit" gorm:"column:permit;type:mediumtext;default:'';comment:授权范围"`
PermitStr string `json:"permitstr" gorm:"column:permitstr;type:mediumtext;default:'';comment:授权范围"`
States int `json:"states" gorm:"column:states;type:int(1) unsigned;default:1;not null;comment:显示状态(1:启用;2:禁用,3:删除)"`
CreaterTime int64 `json:"createrTime" gorm:"column:creater_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:编辑时间"`
FlowKey int64 `json:"flowkey" gorm:"column:flowkey;type:bigint(20) unsigned;default:0;not null;comment:关联工作流"`
UserPermit string `json:"userpermit" gorm:"column:userpermit;type:mediumtext;default:'';comment:授权范围可见人员"`
PostPermit string `json:"postpermit" gorm:"column:postpermit;type:mediumtext;default:'';comment:授权范围可见角色"`
Groupid int64 `json:"groupid" gorm:"column:groupid;type:bigint(20) unsigned;default:0;not null;comment:分组Id"`
Icon string `json:"icon" gorm:"column:icon;type:varchar(255);default:'';comment:图标"`
FlowIsOpen int `json:"flowIsOpen" gorm:"column:flowIsOpen;type:int(1) unsigned;default:2;not null;comment:是否开启工作流(1:启用;2:禁用)"`
ListJson string `json:"listjson" gorm:"column:listjson;type:longtext;default:'';comment:列表结构体"`
SignCode int64 `json:"signCode" gorm:"column:signCode;type:bigint(20) unsigned NOT NULL DEFAULT '0';comment:唯一标识"`
Describe string `json:"describe" gorm:"column:describe;type:longtext;default:'';comment:描述"`
OrgPermit string `json:"orgpermit" gorm:"column:orgpermit;type:mediumtext;default:'';comment:授权范围可见行政组织"`
AppManager string `json:"appManager" gorm:"column:appManager;type:mediumtext;default:'';comment:应用管理员"`
AppRoleManager string `json:"appRoleManager" gorm:"column:appRoleManager;type:mediumtext;default:'';comment:应用管理角色"`
AppOrgMan string `json:"appOrgMan" gorm:"column:appOrgMan;type:mediumtext;default:'';comment:应用管理行政组织"`
}
func (CustomerForm *CustomerForm) TableName() string {

31
models/modelAppPlatform/customer_form_version.go

@ -7,25 +7,26 @@ import (
// 自定义表单版本列表
type CustomerFormVersion struct {
Id int64 `json:"id" gorm:"primaryKey;column:id;type:int(5) unsigned;not null;comment:Id;index"`
TableKey string `json:"tablekey" gorm:"column:tablekey;type:varchar(255) unsigned;default:'';not null;comment:表单标识符"`
Version int64 `json:"version" gorm:"column:version;type:int(5) unsigned;default:1;not null;comment:版本号"`
Status int `json:"status" gorm:"column:status;type:int(1) unsigned;default:1;not null;comment:显示状态(1:启用;2:禁用,3:删除)"`
MastesForm string `json:"mastesform" gorm:"column:mastesform;type:longtext;default:'';comment:表单结构"`
MastesFormJson string `json:"mastesformjson" gorm:"column:mastesformjson;type:longtext;default:'';comment:表单结构json"`
Creater int64 `json:"creater" gorm:"column:creater;type:bigint(20) unsigned;default:0;not null;comment:创建人"`
CreaterTime 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:编辑时间"`
FlowKey int64 `json:"flowkey" gorm:"column:flowkey;type:bigint(20) unsigned;default:0;not null;comment:关联工作流"`
TableStructure string `json:"table_structure" gorm:"column:table_structure;type:longtext;default:'';comment:字表结构"`
Dict string `json:"dict" gorm:"column:dict;type:mediumtext;default:'';comment:字表结构"`
PowerStr string `json:"powerstr" gorm:"column:powerstr;type:longtext;default:'';comment:权限结构"`
ListPage string `json:"listPage" gorm:"column:listPage;type:longtext;default:'';comment:列表结构"`
Visibility int `json:"visibility" gorm:"column:stavisibilitytus;type:int(1) unsigned;default:1;not null;comment:1、所有人,2、自定义"`
Id int64 `json:"id" gorm:"primaryKey;column:id;type:int(5) unsigned;not null;comment:Id;index"`
TableKey string `json:"tablekey" gorm:"column:tablekey;type:varchar(255) unsigned;default:'';not null;comment:表单标识符"`
Version int64 `json:"version" gorm:"column:version;type:int(5) unsigned;default:1;not null;comment:版本号"`
Status int `json:"status" gorm:"column:status;type:int(1) unsigned;default:1;not null;comment:显示状态(1:启用;2:禁用,3:删除)"`
MastesForm string `json:"mastesform" gorm:"column:mastesform;type:longtext;default:'';comment:表单结构"`
MastesFormJson string `json:"mastesformjson" gorm:"column:mastesformjson;type:longtext;default:'';comment:表单结构json"`
Creater int64 `json:"creater" gorm:"column:creater;type:bigint(20) unsigned;default:0;not null;comment:创建人"`
CreaterTime 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:编辑时间"`
// FlowKey int64 `json:"flowkey" gorm:"column:flowkey;type:bigint(20) unsigned;default:0;not null;comment:关联工作流"`
TableStructure string `json:"table_structure" gorm:"column:table_structure;type:longtext;default:'';comment:字表结构"`
Dict string `json:"dict" gorm:"column:dict;type:mediumtext;default:'';comment:字表结构"`
PowerStr string `json:"powerstr" gorm:"column:powerstr;type:longtext;default:'';comment:权限结构"`
// ListPage string `json:"listPage" gorm:"column:listPage;type:longtext;default:'';comment:列表结构"`
Visibility int `json:"visibility" gorm:"column:visibility;type:int(1) unsigned;default:1;not null;comment:1、所有人,2、自定义"`
AuthorizationRoles string `json:"authorizationRoles" gorm:"column:authorizationRoles;type:mediumtext;default:'';comment:授权角色"`
AuthorizedPersonnel string `json:"authorizedPersonnel" gorm:"column:authorizedPersonnel;type:mediumtext;default:'';comment:授权人员"`
AuthorizedOrg string `json:"authorizedOrg" gorm:"column:authorizedOrg;type:mediumtext;default:'';comment:授权行政组织"`
AuthorizedPosition string `json:"authorizedPosition" gorm:"column:authorizedPosition;type:mediumtext;default:'';comment:授权职务"`
SignCode int64 `json:"signCode" gorm:"column:signCode;type:bigint(20) unsigned NOT NULL DEFAULT '0';comment:唯一标识"`
}
func (CustomerFormVersion *CustomerFormVersion) TableName() string {

3
models/modelAppPlatform/customer_form_view.go

@ -11,6 +11,7 @@ type CustomerFormView struct {
TableKey string `json:"tablekey" gorm:"column:tablekey;type:varchar(255) unsigned;default:'';not null;comment:表单标识符"`
Version int `json:"version" gorm:"column:version;type:int(5) unsigned;default:1;not null;comment:版本号"`
Status int `json:"status" gorm:"column:status;type:int(1) unsigned;default:1;not null;comment:显示状态(1:启用;2:禁用,3:删除)"`
States int `json:"states" gorm:"column:states;type:int(1) unsigned;default:1;not null;comment:显示状态(1:启用;2:禁用,3:删除)"`
MastesForm string `json:"mastesform" gorm:"column:mastesform;type:longtext;default:'';comment:表单结构"`
MastesFormJson string `json:"mastesformjson" gorm:"column:mastesformjson;type:longtext;default:'';comment:表单结构json"`
Creater int64 `json:"creater" gorm:"column:creater;type:bigint(20) unsigned;default:0;not null;comment:创建人"`
@ -37,6 +38,8 @@ type CustomerFormView struct {
AuthorizedPersonnel string `json:"authorizedPersonnel" gorm:"column:authorizedPersonnel;type:mediumtext;default:'';comment:授权人员"`
AuthorizedOrg string `json:"authorizedOrg" gorm:"column:authorizedOrg;type:mediumtext;default:'';comment:授权行政组织"`
AuthorizedPosition string `json:"authorizedPosition" gorm:"column:authorizedPosition;type:mediumtext;default:'';comment:授权职务"`
SignCode int64 `json:"signCode" gorm:"column:signCode;type:bigint(20) unsigned NOT NULL DEFAULT '0';comment:唯一标识"`
Describe string `json:"describe" gorm:"column:describe;type:longtext;default:'';comment:描述"`
}
func (CustomerFormView *CustomerFormView) TableName() string {

90
overall/publicmethod/technique.go

@ -216,6 +216,8 @@ func UnixTimeToDay(timeStamp int64, timeType int) (dateStr string) {
timeTemplate = "1"
case 39:
timeTemplate = "2"
case 40:
timeTemplate = "2006/01"
default:
timeTemplate = "2006-01-02 15:04:05" //常规类型
}
@ -532,6 +534,10 @@ func StringToInt64(val interface{}) (int64, error) {
return int64(valData), nil
case uint64:
return int64(valData), nil
case float64:
val := strconv.FormatFloat(valData, 'f', -1, 64)
valInt, err := strconv.ParseInt(val, 10, 64)
return valInt, err
default:
return 0, nil
}
@ -859,6 +865,22 @@ func GetGroupOrDepartPower(parentId int64, departId ...int64) int64 {
return orgCont.Id
}
// 判断指定日期是周几
func GetWeekday(date string) (string, error) {
layout := "2006-01-02"
t, err := time.Parse(layout, date)
if err != nil {
return fmt.Sprintf("%v", time.Sunday), err
}
dayOfWeek := t.Weekday()
var weekdays = [...]string{
"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六",
}
return fmt.Sprintf(weekdays[dayOfWeek]), nil
}
// 时间计算(年、季、月、周、日、时、分、秒)
func ComputingTime(timeStamp int64, timeType int) (timeDataInt int64) {
var timeData string = "1"
@ -1676,7 +1698,7 @@ func GetAppointMonthStarAndEndTime(dayTime string) (startTime, endTime int64) {
return
}
// 获取指定的起止时间副本
// 获取指定的起止时间副本
func GetAppointMonthStarAndEndTimeEs(dayTime string) (startTime, endTime int64) {
dataTypeAll := "2006-01-02"
firstToTime := StringToTimeIng("d", dayTime)
@ -1700,6 +1722,46 @@ func StringToTimeIng(unit, str string) (res time.Time) {
return
}
// 一天的起止时间(时间戳版本)
func TimeUnixDayStartAndEnd(timeVal int64) (start, end int64) {
timeStr := UnixTimeToDay(timeVal, 14)
startTimeStr := fmt.Sprintf("%v 00:00:00", timeStr)
endTimeStr := fmt.Sprintf("%v 23:59:59", timeStr)
start = DateToTimeStampOld(startTimeStr)
end = DateToTimeStampOld(endTimeStr)
return
}
// 计算日期差
func DayBetweenDate(oneDay, twoDay string) (int, error) {
const layout = "2006-01-02"
t1, err := time.Parse(layout, oneDay)
if err != nil {
return 0, err
}
t2, err := time.Parse(layout, twoDay)
if err != nil {
return 0, err
}
// 计算日期差
duration := t1.Sub(t2)
// 转换为天数
days := int(duration.Hours() / 24)
return days, nil
}
// 时间戳转换成time格式
func TimeUnixToTime(timeData int64, unit string) (res time.Time) {
timeStr := UnixTimeToDay(timeData, 11)
loc, _ := time.LoadLocation("Local")
layout, ok := timeLayoutMap[unit]
if !ok {
layout = timeLayoutMap["s"]
}
res, _ = time.ParseInLocation(layout, timeStr, loc)
return
}
// 递归无限极菜单树
/*
@jurisd 起始位置
@ -1796,6 +1858,28 @@ func MergeStruct[T GenericityVariable](aryOen, aryTwo []T) (structAry []T) {
return
}
/*
*
@ 作者: 秦东
@ 时间: 2024-07-16 16:02:25
@ 功能: 一天的开始与结束时间
@day 日期
@class 1:返回时间戳,2:返回日期
*/
func OenDayStartOrEndTime(day string, class int) (startTime, endTime interface{}) {
var creTimeAll DateTimeTotimes
creTimeAll.BaisStrToTime(day)
timeVal := UnixTimeToDay(creTimeAll.AllTime, 14)
if class == 1 {
startTime = DateToTimeStampOld(fmt.Sprintf("%v 00:00:00", timeVal))
endTime = DateToTimeStampOld(fmt.Sprintf("%v 23:59:59", timeVal))
} else {
startTime = fmt.Sprintf("%v 00:00:00", timeVal)
endTime = fmt.Sprintf("%v 23:59:59", timeVal)
}
return
}
// 根据字符串组合时间
//补全时间
/*
@ -1875,7 +1959,7 @@ func (d *DateTimeTotimes) BaisStrToTime(dateTime string) {
default:
}
fmt.Printf("dateTime:%v---1--->%v\n", dateTime, len(dateTime))
// fmt.Printf("dateTime:%v---1--->%v\n", dateTime, len(dateTime))
orgTime, orgTimeErr := DateToTimeStamp(fmt.Sprintf("%v-01-01 12:00:00", dateTime))
if orgTimeErr {
d.AllTime = orgTime
@ -2761,6 +2845,6 @@ func TypeToInterface(val interface{}) string {
@ 功能: 去除字段保留字
*/
func RemoveReservedWord(val string) bool {
reservedWord := []string{"id", "masters_key", "creater_time", "edit_time", "flow_id", "states", "flowIsOpen"}
reservedWord := []string{"id", "masters_key", "creater_time", "edit_time", "flow_id", "states", "flowIsOpen", "explicate"}
return IsInTrue[string](val, reservedWord)
}

Loading…
Cancel
Save