midway-fatcms 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +14 -14
- package/.prettierrc.js +4 -4
- package/README.md +406 -406
- package/dist/config/config.default.d.ts +3 -3
- package/dist/config/config.default.js +177 -177
- package/dist/config/utils.d.ts +1 -1
- package/dist/config/utils.js +23 -23
- package/dist/configuration.d.ts +7 -7
- package/dist/configuration.js +113 -113
- package/dist/controller/base/BaseApiController.d.ts +49 -49
- package/dist/controller/base/BaseApiController.js +198 -198
- package/dist/controller/gateway/AnyApiGatewayController.d.ts +13 -13
- package/dist/controller/gateway/AnyApiGatewayController.js +55 -55
- package/dist/controller/gateway/AsyncTaskController.d.ts +20 -20
- package/dist/controller/gateway/AsyncTaskController.js +181 -181
- package/dist/controller/gateway/CrudMtdGatewayController.d.ts +21 -21
- package/dist/controller/gateway/CrudMtdGatewayController.js +122 -122
- package/dist/controller/gateway/CrudStdGatewayController.d.ts +39 -39
- package/dist/controller/gateway/CrudStdGatewayController.js +149 -149
- package/dist/controller/gateway/DocGatewayController.d.ts +27 -27
- package/dist/controller/gateway/DocGatewayController.js +181 -181
- package/dist/controller/gateway/FileController.d.ts +32 -32
- package/dist/controller/gateway/FileController.js +160 -160
- package/dist/controller/gateway/FlowInstanceController.d.ts +16 -16
- package/dist/controller/gateway/FlowInstanceController.js +48 -48
- package/dist/controller/gateway/ProxyApiGatewayController.d.ts +18 -18
- package/dist/controller/gateway/ProxyApiGatewayController.js +78 -78
- package/dist/controller/gateway/PublicApiController.d.ts +33 -33
- package/dist/controller/gateway/PublicApiController.js +194 -194
- package/dist/controller/gateway/StaticController.d.ts +23 -23
- package/dist/controller/gateway/StaticController.js +280 -280
- package/dist/controller/helpers.controller.d.ts +36 -36
- package/dist/controller/helpers.controller.js +187 -187
- package/dist/controller/home.controller.d.ts +9 -9
- package/dist/controller/home.controller.js +78 -78
- package/dist/controller/manage/AnyApiMangeApi.d.ts +10 -10
- package/dist/controller/manage/AnyApiMangeApi.js +98 -98
- package/dist/controller/manage/AppLogMangeApi.d.ts +10 -10
- package/dist/controller/manage/AppLogMangeApi.js +88 -88
- package/dist/controller/manage/AppMangeApi.d.ts +12 -12
- package/dist/controller/manage/AppMangeApi.js +101 -101
- package/dist/controller/manage/AppPageMangeApi.d.ts +10 -10
- package/dist/controller/manage/AppPageMangeApi.js +87 -87
- package/dist/controller/manage/AppSchemaHistoryApi.d.ts +10 -10
- package/dist/controller/manage/AppSchemaHistoryApi.js +83 -83
- package/dist/controller/manage/CrudMethodsMangeApi.d.ts +10 -10
- package/dist/controller/manage/CrudMethodsMangeApi.js +84 -84
- package/dist/controller/manage/CrudStandardDesignApi.d.ts +46 -46
- package/dist/controller/manage/CrudStandardDesignApi.js +367 -367
- package/dist/controller/manage/DataDictManageApi.d.ts +17 -17
- package/dist/controller/manage/DataDictManageApi.js +165 -165
- package/dist/controller/manage/DeployManageApi.d.ts +21 -21
- package/dist/controller/manage/DeployManageApi.js +203 -203
- package/dist/controller/manage/DocLibManageApi.d.ts +10 -10
- package/dist/controller/manage/DocLibManageApi.js +104 -104
- package/dist/controller/manage/DocManageApi.d.ts +11 -11
- package/dist/controller/manage/DocManageApi.js +130 -130
- package/dist/controller/manage/FileManageApi.d.ts +13 -13
- package/dist/controller/manage/FileManageApi.js +77 -77
- package/dist/controller/manage/FlowConfigManageApi.d.ts +12 -12
- package/dist/controller/manage/FlowConfigManageApi.js +109 -109
- package/dist/controller/manage/LowCodeTplManageApi.d.ts +13 -13
- package/dist/controller/manage/LowCodeTplManageApi.js +86 -86
- package/dist/controller/manage/MenuManageApi.d.ts +11 -11
- package/dist/controller/manage/MenuManageApi.js +104 -104
- package/dist/controller/manage/ProxyApiMangeApi.d.ts +10 -10
- package/dist/controller/manage/ProxyApiMangeApi.js +87 -87
- package/dist/controller/manage/SuperAdminManageApi.d.ts +24 -24
- package/dist/controller/manage/SuperAdminManageApi.js +153 -153
- package/dist/controller/manage/SysConfigMangeApi.d.ts +12 -12
- package/dist/controller/manage/SysConfigMangeApi.js +133 -133
- package/dist/controller/manage/SystemInfoManageApi.d.ts +12 -12
- package/dist/controller/manage/SystemInfoManageApi.js +82 -82
- package/dist/controller/manage/UserAccountManageApi.d.ts +16 -16
- package/dist/controller/manage/UserAccountManageApi.js +153 -153
- package/dist/controller/manage/WorkbenchMangeApi.d.ts +11 -11
- package/dist/controller/manage/WorkbenchMangeApi.js +106 -106
- package/dist/controller/myinfo/AuthController.d.ts +37 -37
- package/dist/controller/myinfo/AuthController.js +157 -157
- package/dist/controller/myinfo/MyInfoController.d.ts +13 -13
- package/dist/controller/myinfo/MyInfoController.js +51 -51
- package/dist/controller/render/AppRenderController.d.ts +12 -12
- package/dist/controller/render/AppRenderController.js +93 -93
- package/dist/controller/test.controller.d.ts +8 -8
- package/dist/controller/test.controller.js +51 -51
- package/dist/filter/default.filter.d.ts +7 -7
- package/dist/filter/default.filter.js +23 -23
- package/dist/filter/notfound.filter.d.ts +5 -5
- package/dist/filter/notfound.filter.js +20 -20
- package/dist/index.d.ts +111 -111
- package/dist/index.js +129 -129
- package/dist/interface.d.ts +30 -30
- package/dist/interface.js +3 -3
- package/dist/libs/crud-pro/CrudPro.d.ts +51 -37
- package/dist/libs/crud-pro/CrudPro.js +207 -146
- package/dist/libs/crud-pro/defaultConfigs.d.ts +4 -4
- package/dist/libs/crud-pro/defaultConfigs.js +15 -15
- package/dist/libs/crud-pro/exceptions.d.ts +106 -106
- package/dist/libs/crud-pro/exceptions.js +119 -119
- package/dist/libs/crud-pro/interfaces.d.ts +195 -175
- package/dist/libs/crud-pro/interfaces.js +12 -12
- package/dist/libs/crud-pro/models/ExecuteContext.d.ts +50 -50
- package/dist/libs/crud-pro/models/ExecuteContext.js +87 -87
- package/dist/libs/crud-pro/models/ExecuteContextFunc.d.ts +38 -38
- package/dist/libs/crud-pro/models/ExecuteContextFunc.js +72 -72
- package/dist/libs/crud-pro/models/FuncContext.d.ts +18 -18
- package/dist/libs/crud-pro/models/FuncContext.js +6 -6
- package/dist/libs/crud-pro/models/RequestCfgModel.d.ts +65 -65
- package/dist/libs/crud-pro/models/RequestCfgModel.js +81 -81
- package/dist/libs/crud-pro/models/RequestModel.d.ts +25 -25
- package/dist/libs/crud-pro/models/RequestModel.js +113 -113
- package/dist/libs/crud-pro/models/ResModel.d.ts +20 -20
- package/dist/libs/crud-pro/models/ResModel.js +2 -2
- package/dist/libs/crud-pro/models/ServiceHub.d.ts +20 -20
- package/dist/libs/crud-pro/models/ServiceHub.js +2 -2
- package/dist/libs/crud-pro/models/SqlCfgModel.d.ts +23 -23
- package/dist/libs/crud-pro/models/SqlCfgModel.js +40 -40
- package/dist/libs/crud-pro/models/SqlSegArg.d.ts +6 -6
- package/dist/libs/crud-pro/models/SqlSegArg.js +12 -12
- package/dist/libs/crud-pro/models/Transaction.d.ts +50 -50
- package/dist/libs/crud-pro/models/Transaction.js +184 -184
- package/dist/libs/crud-pro/models/TransactionMySQL.d.ts +19 -19
- package/dist/libs/crud-pro/models/TransactionMySQL.js +48 -48
- package/dist/libs/crud-pro/models/TransactionPostgres.d.ts +19 -19
- package/dist/libs/crud-pro/models/TransactionPostgres.js +64 -64
- package/dist/libs/crud-pro/models/TransactionSqlServer.d.ts +9 -9
- package/dist/libs/crud-pro/models/TransactionSqlServer.js +61 -61
- package/dist/libs/crud-pro/models/keys.d.ts +111 -111
- package/dist/libs/crud-pro/models/keys.js +156 -156
- package/dist/libs/crud-pro/services/CrudProCachedCfgService.d.ts +11 -11
- package/dist/libs/crud-pro/services/CrudProCachedCfgService.js +73 -73
- package/dist/libs/crud-pro/services/CrudProDataFilterService.d.ts +17 -0
- package/dist/libs/crud-pro/services/CrudProDataFilterService.js +53 -0
- package/dist/libs/crud-pro/services/CrudProExecuteFuncService.d.ts +9 -9
- package/dist/libs/crud-pro/services/CrudProExecuteFuncService.js +125 -125
- package/dist/libs/crud-pro/services/CrudProExecuteSqlService.d.ts +17 -17
- package/dist/libs/crud-pro/services/CrudProExecuteSqlService.js +224 -224
- package/dist/libs/crud-pro/services/CrudProFieldUpdateService.d.ts +9 -9
- package/dist/libs/crud-pro/services/CrudProFieldUpdateService.js +51 -51
- package/dist/libs/crud-pro/services/CrudProFieldValidateService.d.ts +13 -13
- package/dist/libs/crud-pro/services/CrudProFieldValidateService.js +148 -148
- package/dist/libs/crud-pro/services/CrudProGenSqlCondition.d.ts +25 -25
- package/dist/libs/crud-pro/services/CrudProGenSqlCondition.js +385 -385
- package/dist/libs/crud-pro/services/CrudProGenSqlService.d.ts +25 -25
- package/dist/libs/crud-pro/services/CrudProGenSqlService.js +165 -165
- package/dist/libs/crud-pro/services/CrudProOriginToExecuteSql.d.ts +32 -32
- package/dist/libs/crud-pro/services/CrudProOriginToExecuteSql.js +345 -339
- package/dist/libs/crud-pro/services/CrudProServiceBase.d.ts +24 -24
- package/dist/libs/crud-pro/services/CrudProServiceBase.js +88 -88
- package/dist/libs/crud-pro/services/CrudProTableMetaService.d.ts +12 -9
- package/dist/libs/crud-pro/services/CrudProTableMetaService.js +167 -77
- package/dist/libs/crud-pro/services/CurdProServiceHub.d.ts +34 -32
- package/dist/libs/crud-pro/services/CurdProServiceHub.js +69 -64
- package/dist/libs/crud-pro/utils/CompareUtils.d.ts +9 -9
- package/dist/libs/crud-pro/utils/CompareUtils.js +25 -25
- package/dist/libs/crud-pro/utils/CrudMonitor.d.ts +9 -9
- package/dist/libs/crud-pro/utils/CrudMonitor.js +12 -12
- package/dist/libs/crud-pro/utils/DatabaseName.d.ts +9 -9
- package/dist/libs/crud-pro/utils/DatabaseName.js +50 -50
- package/dist/libs/crud-pro/utils/DateTimeUtils.d.ts +7 -7
- package/dist/libs/crud-pro/utils/DateTimeUtils.js +21 -21
- package/dist/libs/crud-pro/utils/MemoryRefreshCache.d.ts +19 -19
- package/dist/libs/crud-pro/utils/MemoryRefreshCache.js +47 -47
- package/dist/libs/crud-pro/utils/MessageParseUtils.d.ts +5 -5
- package/dist/libs/crud-pro/utils/MessageParseUtils.js +33 -33
- package/dist/libs/crud-pro/utils/MixinUtils.d.ts +40 -40
- package/dist/libs/crud-pro/utils/MixinUtils.js +259 -259
- package/dist/libs/crud-pro/utils/ModelUtils.d.ts +11 -11
- package/dist/libs/crud-pro/utils/ModelUtils.js +54 -54
- package/dist/libs/crud-pro/utils/MultiKeyMap.d.ts +11 -11
- package/dist/libs/crud-pro/utils/MultiKeyMap.js +63 -63
- package/dist/libs/crud-pro/utils/SqlFuncUtils.d.ts +5 -5
- package/dist/libs/crud-pro/utils/SqlFuncUtils.js +29 -29
- package/dist/libs/crud-pro/utils/TypeUtils.d.ts +40 -40
- package/dist/libs/crud-pro/utils/TypeUtils.js +166 -166
- package/dist/libs/crud-pro/utils/ValidateUtils.d.ts +3 -3
- package/dist/libs/crud-pro/utils/ValidateUtils.js +165 -165
- package/dist/libs/crud-pro/utils/pool/MySQLUtils.d.ts +3 -3
- package/dist/libs/crud-pro/utils/pool/MySQLUtils.js +19 -19
- package/dist/libs/crud-pro/utils/pool/PostgresUtils.d.ts +3 -3
- package/dist/libs/crud-pro/utils/pool/PostgresUtils.js +20 -20
- package/dist/libs/crud-pro/utils/pool/SqlServerUtils.d.ts +3 -3
- package/dist/libs/crud-pro/utils/pool/SqlServerUtils.js +20 -20
- package/dist/libs/crud-pro/utils/sqlConvert/convertColumnName.d.ts +4 -4
- package/dist/libs/crud-pro/utils/sqlConvert/convertColumnName.js +35 -35
- package/dist/libs/crud-pro/utils/sqlConvert/convertMix.js +24 -24
- package/dist/libs/crud-pro/utils/sqlConvert/convertMsSql.d.ts +2 -2
- package/dist/libs/crud-pro/utils/sqlConvert/convertMsSql.js +14 -14
- package/dist/libs/crud-pro/utils/sqlConvert/convertPgSql.d.ts +2 -2
- package/dist/libs/crud-pro/utils/sqlConvert/convertPgSql.js +14 -14
- package/dist/libs/global-config/global-config.d.ts +71 -71
- package/dist/libs/global-config/global-config.js +38 -38
- package/dist/libs/utils/AsymmetricCrypto.d.ts +76 -76
- package/dist/libs/utils/AsymmetricCrypto.js +261 -261
- package/dist/libs/utils/base64.d.ts +9 -9
- package/dist/libs/utils/base64.js +42 -42
- package/dist/libs/utils/common-dto.d.ts +18 -18
- package/dist/libs/utils/common-dto.js +40 -40
- package/dist/libs/utils/crypto-utils.d.ts +3 -3
- package/dist/libs/utils/crypto-utils.js +55 -55
- package/dist/libs/utils/errorToString.d.ts +20 -20
- package/dist/libs/utils/errorToString.js +79 -79
- package/dist/libs/utils/fatcms-request.d.ts +45 -45
- package/dist/libs/utils/fatcms-request.js +161 -161
- package/dist/libs/utils/format-url.d.ts +17 -17
- package/dist/libs/utils/format-url.js +30 -30
- package/dist/libs/utils/functions.d.ts +11 -11
- package/dist/libs/utils/functions.js +99 -99
- package/dist/libs/utils/ordernum-utils.d.ts +22 -22
- package/dist/libs/utils/ordernum-utils.js +35 -35
- package/dist/libs/utils/parseConfig.d.ts +8 -8
- package/dist/libs/utils/parseConfig.js +47 -47
- package/dist/libs/utils/parseCreateSql.d.ts +10 -10
- package/dist/libs/utils/parseCreateSql.js +87 -87
- package/dist/libs/utils/render-utils.d.ts +40 -40
- package/dist/libs/utils/render-utils.js +158 -158
- package/dist/middleware/forbidden.middleware.d.ts +74 -74
- package/dist/middleware/forbidden.middleware.js +318 -318
- package/dist/middleware/global.middleware.d.ts +40 -40
- package/dist/middleware/global.middleware.js +310 -310
- package/dist/middleware/permission.middleware.d.ts +88 -88
- package/dist/middleware/permission.middleware.js +145 -145
- package/dist/middleware/rediscache.middleware.d.ts +28 -28
- package/dist/middleware/rediscache.middleware.js +114 -114
- package/dist/middleware/redislock.middleware.d.ts +29 -29
- package/dist/middleware/redislock.middleware.js +106 -106
- package/dist/middleware/tx.middleware.d.ts +55 -55
- package/dist/middleware/tx.middleware.js +83 -83
- package/dist/models/AsyncTaskModel.d.ts +74 -74
- package/dist/models/AsyncTaskModel.js +31 -31
- package/dist/models/FlowModel.d.ts +227 -227
- package/dist/models/FlowModel.js +53 -53
- package/dist/models/RedisKeys.d.ts +15 -15
- package/dist/models/RedisKeys.js +18 -18
- package/dist/models/SystemEntities.d.ts +118 -118
- package/dist/models/SystemEntities.js +18 -18
- package/dist/models/SystemPerm.d.ts +96 -96
- package/dist/models/SystemPerm.js +101 -101
- package/dist/models/SystemTables.d.ts +25 -25
- package/dist/models/SystemTables.js +28 -28
- package/dist/models/WorkbenchInfoTools.d.ts +7 -7
- package/dist/models/WorkbenchInfoTools.js +20 -20
- package/dist/models/bizmodels.d.ts +150 -150
- package/dist/models/bizmodels.js +62 -62
- package/dist/models/contextLogger.d.ts +27 -27
- package/dist/models/contextLogger.js +119 -119
- package/dist/models/devops.d.ts +12 -12
- package/dist/models/devops.js +19 -19
- package/dist/models/userSession.d.ts +67 -67
- package/dist/models/userSession.js +179 -179
- package/dist/schedule/anonymousContext.d.ts +15 -15
- package/dist/schedule/anonymousContext.js +74 -74
- package/dist/schedule/index.d.ts +4 -4
- package/dist/schedule/index.js +10 -10
- package/dist/schedule/runSchedule.d.ts +12 -12
- package/dist/schedule/runSchedule.js +68 -68
- package/dist/schedule/scheduleNames.d.ts +15 -15
- package/dist/schedule/scheduleNames.js +19 -19
- package/dist/service/AuthService.d.ts +56 -56
- package/dist/service/AuthService.js +251 -251
- package/dist/service/EnumInfoService.d.ts +30 -30
- package/dist/service/EnumInfoService.js +97 -97
- package/dist/service/FileCenterService.d.ts +64 -64
- package/dist/service/FileCenterService.js +422 -422
- package/dist/service/SysAppService.d.ts +15 -15
- package/dist/service/SysAppService.js +108 -108
- package/dist/service/SysConfigService.d.ts +10 -10
- package/dist/service/SysConfigService.js +64 -64
- package/dist/service/SysDictDataService.d.ts +9 -9
- package/dist/service/SysDictDataService.js +72 -72
- package/dist/service/SysMenuService.d.ts +51 -51
- package/dist/service/SysMenuService.js +58 -58
- package/dist/service/UserAccountService.d.ts +23 -23
- package/dist/service/UserAccountService.js +107 -107
- package/dist/service/UserSessionService.d.ts +43 -43
- package/dist/service/UserSessionService.js +163 -163
- package/dist/service/VisitStatService.d.ts +14 -14
- package/dist/service/VisitStatService.js +161 -161
- package/dist/service/WorkbenchService.d.ts +59 -59
- package/dist/service/WorkbenchService.js +249 -249
- package/dist/service/anyapi/AnyApiSandboxService.d.ts +15 -15
- package/dist/service/anyapi/AnyApiSandboxService.js +110 -110
- package/dist/service/anyapi/AnyApiService.d.ts +27 -27
- package/dist/service/anyapi/AnyApiService.js +181 -181
- package/dist/service/asyncTask/AsyncTaskRunnerService.d.ts +50 -50
- package/dist/service/asyncTask/AsyncTaskRunnerService.js +287 -287
- package/dist/service/asyncTask/AsyncTaskService.d.ts +7 -7
- package/dist/service/asyncTask/AsyncTaskService.js +34 -34
- package/dist/service/asyncTask/handler/ExcelInfoModel.d.ts +10 -10
- package/dist/service/asyncTask/handler/ExcelInfoModel.js +2 -2
- package/dist/service/asyncTask/handler/ExportExcelAsyncTaskHandler.d.ts +7 -7
- package/dist/service/asyncTask/handler/ExportExcelAsyncTaskHandler.js +216 -216
- package/dist/service/asyncTask/handler/ExportExcelByInnerHttpHandler.d.ts +36 -36
- package/dist/service/asyncTask/handler/ExportExcelByInnerHttpHandler.js +141 -141
- package/dist/service/asyncTask/handler/ExportExcelByStdCrudHandler.d.ts +46 -46
- package/dist/service/asyncTask/handler/ExportExcelByStdCrudHandler.js +135 -135
- package/dist/service/base/ApiBaseService.d.ts +22 -22
- package/dist/service/base/ApiBaseService.js +60 -60
- package/dist/service/base/ApiRateLimiter.d.ts +10 -10
- package/dist/service/base/ApiRateLimiter.js +51 -51
- package/dist/service/base/BaseService.d.ts +46 -46
- package/dist/service/base/BaseService.js +131 -131
- package/dist/service/base/cache/CacheServiceFactory.d.ts +26 -26
- package/dist/service/base/cache/CacheServiceFactory.js +122 -122
- package/dist/service/base/cache/CtxCache.d.ts +18 -18
- package/dist/service/base/cache/CtxCache.js +37 -37
- package/dist/service/base/cache/DiskCache.d.ts +19 -19
- package/dist/service/base/cache/DiskCache.js +81 -81
- package/dist/service/base/cache/MemoryCache.d.ts +12 -12
- package/dist/service/base/cache/MemoryCache.js +58 -58
- package/dist/service/base/cache/NoneCache.d.ts +10 -10
- package/dist/service/base/cache/NoneCache.js +19 -19
- package/dist/service/base/cache/RedisCache.d.ts +14 -14
- package/dist/service/base/cache/RedisCache.js +31 -31
- package/dist/service/crudstd/CrudStdActionService.d.ts +17 -17
- package/dist/service/crudstd/CrudStdActionService.js +32 -32
- package/dist/service/crudstd/CrudStdConstant.d.ts +58 -58
- package/dist/service/crudstd/CrudStdConstant.js +64 -64
- package/dist/service/crudstd/CrudStdRelationService.d.ts +11 -11
- package/dist/service/crudstd/CrudStdRelationService.js +179 -179
- package/dist/service/crudstd/CrudStdService.d.ts +59 -59
- package/dist/service/crudstd/CrudStdService.js +348 -348
- package/dist/service/curd/CrudProQuick.d.ts +60 -60
- package/dist/service/curd/CrudProQuick.js +167 -167
- package/dist/service/curd/CurdMixByAccountService.d.ts +14 -14
- package/dist/service/curd/CurdMixByAccountService.js +166 -166
- package/dist/service/curd/CurdMixByDictService.d.ts +12 -12
- package/dist/service/curd/CurdMixByDictService.js +114 -114
- package/dist/service/curd/CurdMixByLinkToCustomService.d.ts +30 -30
- package/dist/service/curd/CurdMixByLinkToCustomService.js +209 -209
- package/dist/service/curd/CurdMixBySysConfigService.d.ts +13 -13
- package/dist/service/curd/CurdMixBySysConfigService.js +116 -116
- package/dist/service/curd/CurdMixByWorkbenchService.d.ts +11 -11
- package/dist/service/curd/CurdMixByWorkbenchService.js +80 -80
- package/dist/service/curd/CurdMixService.d.ts +28 -28
- package/dist/service/curd/CurdMixService.js +100 -100
- package/dist/service/curd/CurdMixUtils.d.ts +57 -57
- package/dist/service/curd/CurdMixUtils.js +331 -331
- package/dist/service/curd/CurdProService.d.ts +32 -32
- package/dist/service/curd/CurdProService.js +215 -215
- package/dist/service/curd/fixCfgModel.d.ts +3 -3
- package/dist/service/curd/fixCfgModel.js +104 -104
- package/dist/service/curd/fixSoftDelete.d.ts +6 -6
- package/dist/service/curd/fixSoftDelete.js +43 -43
- package/dist/service/flow/FlowConfigService.d.ts +41 -41
- package/dist/service/flow/FlowConfigService.js +95 -95
- package/dist/service/flow/FlowInstanceCrudService.d.ts +35 -35
- package/dist/service/flow/FlowInstanceCrudService.js +257 -257
- package/dist/service/flow/FlowInstanceService.d.ts +88 -88
- package/dist/service/flow/FlowInstanceService.js +451 -451
- package/dist/service/proxyapi/ProxyApiLoadService.d.ts +21 -21
- package/dist/service/proxyapi/ProxyApiLoadService.js +167 -167
- package/dist/service/proxyapi/ProxyApiService.d.ts +61 -61
- package/dist/service/proxyapi/ProxyApiService.js +317 -317
- package/dist/service/proxyapi/ProxyApiUtils.d.ts +15 -15
- package/dist/service/proxyapi/ProxyApiUtils.js +34 -34
- package/dist/service/proxyapi/RouteHandler.d.ts +6 -6
- package/dist/service/proxyapi/RouteHandler.js +9 -9
- package/dist/service/proxyapi/RouteTrie.d.ts +12 -12
- package/dist/service/proxyapi/RouteTrie.js +64 -64
- package/dist/service/proxyapi/WeightedRandom.d.ts +9 -9
- package/dist/service/proxyapi/WeightedRandom.js +31 -31
- package/dist/service/proxyapi/WeightedRoundRobin.d.ts +8 -8
- package/dist/service/proxyapi/WeightedRoundRobin.js +33 -33
- package/index.d.ts +10 -10
- package/package.json +87 -87
- package/src/libs/crud-pro/CrudPro.ts +71 -0
- package/src/libs/crud-pro/interfaces.ts +22 -0
- package/src/libs/crud-pro/models/ServiceHub.ts +2 -2
- package/src/libs/crud-pro/services/CrudProDataFilterService.ts +58 -0
- package/src/libs/crud-pro/services/CrudProOriginToExecuteSql.ts +10 -1
- package/src/libs/crud-pro/services/CrudProTableMetaService.ts +145 -40
- package/src/libs/crud-pro/services/CurdProServiceHub.ts +10 -3
- package/src/libs/crud-pro/utils/CrudMonitor.ts +13 -13
- package/src/libs/utils/AsymmetricCrypto.ts +307 -307
- package/src/libs/utils/format-url.ts +29 -29
- package/src/libs/utils/render-utils.ts +223 -223
- package/src/models/WorkbenchInfoTools.ts +19 -19
- package/src/service/SysAppService.ts +103 -103
- package/src/service/SysDictDataService.ts +63 -63
- package/src/service/SysMenuService.ts +87 -87
- package/src/service/WorkbenchService.ts +279 -279
- package/src/service/base/cache/CacheServiceFactory.ts +135 -135
- package/src/service/base/cache/CtxCache.ts +45 -45
- package/src/service/base/cache/DiskCache.ts +90 -90
- package/src/service/base/cache/MemoryCache.ts +68 -68
- package/src/service/base/cache/NoneCache.ts +24 -24
- package/src/service/base/cache/RedisCache.ts +41 -41
- package/src/service/curd/CurdMixByAccountService.ts +177 -177
- package/src/service/curd/fixSoftDelete.ts +58 -58
- package/tsconfig.json +32 -32
|
@@ -1,451 +1,451 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.FlowInstanceService = void 0;
|
|
13
|
-
const core_1 = require("@midwayjs/core");
|
|
14
|
-
const _ = require("lodash");
|
|
15
|
-
const moment = require("moment");
|
|
16
|
-
const FlowModel_1 = require("../../models/FlowModel");
|
|
17
|
-
const FlowConfigService_1 = require("./FlowConfigService");
|
|
18
|
-
const functions_1 = require("../../libs/utils/functions");
|
|
19
|
-
const FlowInstanceCrudService_1 = require("./FlowInstanceCrudService");
|
|
20
|
-
const BaseService_1 = require("../../service/base/BaseService");
|
|
21
|
-
function isTaskRunning(taskInstance) {
|
|
22
|
-
return [FlowModel_1.TaskStatusEnum.PENDING, FlowModel_1.TaskStatusEnum.PROCESSING].includes(taskInstance.task_status);
|
|
23
|
-
}
|
|
24
|
-
function isTaskDone(taskInstance) {
|
|
25
|
-
return !isTaskRunning(taskInstance);
|
|
26
|
-
}
|
|
27
|
-
function isNodeRunning(nodeStatus) {
|
|
28
|
-
return [FlowModel_1.NodeStatusEnum.PENDING, FlowModel_1.NodeStatusEnum.PROCESSING].includes(nodeStatus);
|
|
29
|
-
}
|
|
30
|
-
function isNodeDone(nodeStatus) {
|
|
31
|
-
return !isNodeRunning(nodeStatus);
|
|
32
|
-
}
|
|
33
|
-
function checkRequiredFields(requiredFields, flowInstance) {
|
|
34
|
-
const missingFields = requiredFields.filter(field => {
|
|
35
|
-
const flowInstanceAny = flowInstance;
|
|
36
|
-
return !flowInstanceAny[field];
|
|
37
|
-
});
|
|
38
|
-
if (missingFields.length > 0) {
|
|
39
|
-
throw new Error(`Missing required fields: ${missingFields.join(', ')}`);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
function getCurrentDateTime() {
|
|
43
|
-
return moment().format("YYYY-MM-DD HH:mm:ss");
|
|
44
|
-
}
|
|
45
|
-
let FlowInstanceService = class FlowInstanceService extends BaseService_1.BaseService {
|
|
46
|
-
getCurrentUserAccountId() {
|
|
47
|
-
var _a;
|
|
48
|
-
const sessionInfo = (_a = this.ctx.userSession) === null || _a === void 0 ? void 0 : _a.getSessionInfo();
|
|
49
|
-
return (sessionInfo === null || sessionInfo === void 0 ? void 0 : sessionInfo.accountId) || '';
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* 创建业务对象实例之前,先创建流程实例。
|
|
53
|
-
* 创建流程实例
|
|
54
|
-
* @param flowInstance
|
|
55
|
-
*/
|
|
56
|
-
async createFlowInstance(flowInstance) {
|
|
57
|
-
checkRequiredFields(['flow_code', 'flow_version', 'ticket_no'], flowInstance);
|
|
58
|
-
const parsedFlowConfig = await this.flowConfigService.getParsedFlowConfig(flowInstance.flow_code, flowInstance.flow_version);
|
|
59
|
-
// 开始节点
|
|
60
|
-
const startNode = parsedFlowConfig.getStartNode();
|
|
61
|
-
flowInstance.flow_instance_current_nodeid = startNode.id;
|
|
62
|
-
flowInstance.flow_instance_status = FlowModel_1.FlowInstanceStatus.RUNNING;
|
|
63
|
-
flowInstance.created_by = this.getCurrentUserAccountId();
|
|
64
|
-
// 创建节点实例
|
|
65
|
-
await this.flowInstanceCrudService.createNodeInstanceByNodeConfig(flowInstance, startNode, parsedFlowConfig);
|
|
66
|
-
// 创建任务实例
|
|
67
|
-
await this.createTasksByNodeConfig(flowInstance, startNode, parsedFlowConfig);
|
|
68
|
-
// 执行流程实例
|
|
69
|
-
await this.executeFlowInstance(flowInstance, parsedFlowConfig);
|
|
70
|
-
const flowInstanceId = await this.flowInstanceCrudService.saveFlowInstance(flowInstance);
|
|
71
|
-
const nodeInfo = parsedFlowConfig.getNodeInfoByNodeId(flowInstance.flow_instance_current_nodeid);
|
|
72
|
-
const createdFlowInstance = {
|
|
73
|
-
...flowInstance,
|
|
74
|
-
id: flowInstanceId || '',
|
|
75
|
-
flow_instance_id: flowInstanceId || '',
|
|
76
|
-
flow_instance_current_nodename: nodeInfo.name || '',
|
|
77
|
-
};
|
|
78
|
-
return createdFlowInstance;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* 创建任务实例
|
|
82
|
-
* @param flowInstance
|
|
83
|
-
* @param nodeCfg
|
|
84
|
-
* @param parsedFlowConfig
|
|
85
|
-
* @returns
|
|
86
|
-
*/
|
|
87
|
-
async createTasksByNodeConfig(flowInstance, nodeCfg, parsedFlowConfig) {
|
|
88
|
-
const getFlowInstanceAssignees = (flowInstance) => {
|
|
89
|
-
// TODO
|
|
90
|
-
throw new Error('Function not implemented.');
|
|
91
|
-
};
|
|
92
|
-
const userList = getFlowInstanceAssignees(flowInstance);
|
|
93
|
-
if (!userList || userList.length === 0) {
|
|
94
|
-
// 无需人工处理
|
|
95
|
-
return [];
|
|
96
|
-
}
|
|
97
|
-
const taskInstances = [];
|
|
98
|
-
for (const user of userList) {
|
|
99
|
-
const taskInstance = await this.flowInstanceCrudService.createTaskInstance(flowInstance, nodeCfg, user);
|
|
100
|
-
taskInstances.push(taskInstance);
|
|
101
|
-
}
|
|
102
|
-
return taskInstances;
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* 用户手动提交任务操作动作
|
|
106
|
-
* @param submitTask
|
|
107
|
-
*/
|
|
108
|
-
async submitTask(submitTask) {
|
|
109
|
-
const taskInstance = await this.flowInstanceCrudService.getTaskInstance(submitTask.task_instance_id);
|
|
110
|
-
if (!taskInstance) {
|
|
111
|
-
throw new Error('任务实例不存在');
|
|
112
|
-
}
|
|
113
|
-
if (!isTaskRunning(taskInstance)) {
|
|
114
|
-
throw new Error('任务状态不是运行中,不能提交');
|
|
115
|
-
}
|
|
116
|
-
if (taskInstance.task_user_id !== this.getCurrentUserAccountId()) {
|
|
117
|
-
throw new Error('任务处理人不是当前用户');
|
|
118
|
-
}
|
|
119
|
-
const flowInstance = await this.flowInstanceCrudService.getFlowInstance(taskInstance.flow_instance_id);
|
|
120
|
-
if (!flowInstance) {
|
|
121
|
-
throw new Error('流程实例不存在');
|
|
122
|
-
}
|
|
123
|
-
if (flowInstance.flow_instance_status !== FlowModel_1.FlowInstanceStatus.RUNNING) {
|
|
124
|
-
throw new Error('流程实例状态不是运行中,不能提交任务');
|
|
125
|
-
}
|
|
126
|
-
const parsedFlowConfig = await this.flowConfigService.getParsedFlowConfig(flowInstance.flow_code, flowInstance.flow_version);
|
|
127
|
-
const context1 = (0, functions_1.parseJsonObject)(flowInstance.flow_instance_context || '{}');
|
|
128
|
-
const context2 = (0, functions_1.parseJsonObject)(submitTask.flow_instance_context_updated || '{}');
|
|
129
|
-
flowInstance.flow_instance_context = _.merge({}, context1, context2);
|
|
130
|
-
const currNode = parsedFlowConfig.getNodeInfoByNodeId(taskInstance.node_cfg_id || '');
|
|
131
|
-
if (!currNode) {
|
|
132
|
-
throw new Error('node not found');
|
|
133
|
-
}
|
|
134
|
-
const updateTaskData = {};
|
|
135
|
-
updateTaskData.id = taskInstance.id;
|
|
136
|
-
if (submitTask.task_audit_result === FlowModel_1.AuditResultEnum.APPROVED) {
|
|
137
|
-
// 用户处理结果为已通过
|
|
138
|
-
updateTaskData.task_status = FlowModel_1.TaskStatusEnum.APPROVED;
|
|
139
|
-
updateTaskData.task_finished_at = moment().format("YYYY-MM-DD HH:mm:ss");
|
|
140
|
-
updateTaskData.task_audit_result = FlowModel_1.AuditResultEnum.APPROVED;
|
|
141
|
-
updateTaskData.task_audit_comment = submitTask.task_audit_comment || '';
|
|
142
|
-
}
|
|
143
|
-
else if (submitTask.task_audit_result === FlowModel_1.AuditResultEnum.REJECTED) {
|
|
144
|
-
// 用户处理结果为已驳回
|
|
145
|
-
updateTaskData.task_status = FlowModel_1.TaskStatusEnum.REJECTED;
|
|
146
|
-
updateTaskData.task_finished_at = moment().format("YYYY-MM-DD HH:mm:ss");
|
|
147
|
-
updateTaskData.task_audit_result = FlowModel_1.AuditResultEnum.REJECTED;
|
|
148
|
-
updateTaskData.task_audit_comment = submitTask.task_audit_comment || '';
|
|
149
|
-
}
|
|
150
|
-
else {
|
|
151
|
-
// 用户处理结果为已取消
|
|
152
|
-
updateTaskData.task_status = FlowModel_1.TaskStatusEnum.FINISHED;
|
|
153
|
-
updateTaskData.task_finished_at = moment().format("YYYY-MM-DD HH:mm:ss");
|
|
154
|
-
}
|
|
155
|
-
await this.flowInstanceCrudService.saveTaskInstance(updateTaskData);
|
|
156
|
-
await this.executeFlowInstance(flowInstance, parsedFlowConfig);
|
|
157
|
-
await this.flowInstanceCrudService.saveFlowInstance(flowInstance);
|
|
158
|
-
return {
|
|
159
|
-
task_id: taskInstance.id,
|
|
160
|
-
task_status: updateTaskData.task_status,
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* 执行一下流程实例
|
|
165
|
-
* @param flowInstance
|
|
166
|
-
* @param parsedFlowConfig
|
|
167
|
-
* @returns
|
|
168
|
-
*/
|
|
169
|
-
async executeFlowInstance(flowInstance, parsedFlowConfig) {
|
|
170
|
-
const taskList = await this.flowInstanceCrudService.getTaskInstanceListByFlowInstanceId(flowInstance.id || '');
|
|
171
|
-
if (!taskList || taskList.length === 0) {
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
const nodeInstanceList = await this.flowInstanceCrudService.getNodeInstanceListByFlowInstanceId(flowInstance.id || '');
|
|
175
|
-
if (!nodeInstanceList || nodeInstanceList.length === 0) {
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
178
|
-
if (flowInstance.flow_instance_status !== FlowModel_1.FlowInstanceStatus.RUNNING) {
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
const currentNodeCfgIdList = (0, functions_1.parseJsonObject)(flowInstance.flow_instance_current_nodeids);
|
|
182
|
-
const newNextNodeIdList = [];
|
|
183
|
-
for (let i = 0; i < currentNodeCfgIdList.length; i++) {
|
|
184
|
-
const currentNodeCfgId = currentNodeCfgIdList[i];
|
|
185
|
-
const currentNodeCfgInfo = parsedFlowConfig.getNodeInfoByNodeId(currentNodeCfgId || '');
|
|
186
|
-
if (!currentNodeCfgInfo) {
|
|
187
|
-
throw new Error('current node not found');
|
|
188
|
-
}
|
|
189
|
-
// 执行 自动通过任务
|
|
190
|
-
await this.executeAutoDoneTask(flowInstance, currentNodeCfgInfo, taskList, parsedFlowConfig);
|
|
191
|
-
// 执行 系统任务
|
|
192
|
-
await this.executeSystemTaskList(flowInstance, currentNodeCfgInfo, taskList, parsedFlowConfig);
|
|
193
|
-
// 计算当前节点的新状态
|
|
194
|
-
const currentNodeNewStatus = await this.executeCalcCurrentNewNodeStatus(flowInstance, currentNodeCfgInfo, taskList);
|
|
195
|
-
const currentNodeInstance = await this.flowInstanceCrudService.getNodeInstance(`${flowInstance.id}`, currentNodeCfgId || '');
|
|
196
|
-
// 当前节点最新状态 已完成
|
|
197
|
-
if (isNodeDone(currentNodeNewStatus)) {
|
|
198
|
-
const updateNodeInstance = {};
|
|
199
|
-
updateNodeInstance.id = currentNodeInstance.id;
|
|
200
|
-
updateNodeInstance.node_status = currentNodeNewStatus;
|
|
201
|
-
await this.flowInstanceCrudService.saveNodeInstance(updateNodeInstance);
|
|
202
|
-
const nextNodeIdList0 = await this.executeCreateNextTaskAndNode(flowInstance, updateNodeInstance, parsedFlowConfig);
|
|
203
|
-
if (nextNodeIdList0 && nextNodeIdList0.length > 0) {
|
|
204
|
-
newNextNodeIdList.push(...nextNodeIdList0);
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
else {
|
|
208
|
-
newNextNodeIdList.push(currentNodeCfgId);
|
|
209
|
-
}
|
|
210
|
-
flowInstance.flow_instance_current_nodeids = newNextNodeIdList;
|
|
211
|
-
flowInstance.flow_instance_current_nodeid = newNextNodeIdList[0] || null;
|
|
212
|
-
}
|
|
213
|
-
// 只有一个节点,并且是结束节点。流程结束。
|
|
214
|
-
if (flowInstance.flow_instance_current_nodeids.length === 1) {
|
|
215
|
-
// 到达最后一个节点,流程实例结束。流程结束节点只有一个。
|
|
216
|
-
const curNodeInfo = parsedFlowConfig.getNodeInfoByNodeId(flowInstance.flow_instance_current_nodeid || '');
|
|
217
|
-
if (curNodeInfo && curNodeInfo.type === FlowConfigService_1.FlowNodeCfgTypeEnum.EndNode) {
|
|
218
|
-
flowInstance.flow_instance_status = FlowModel_1.FlowInstanceStatus.FINISHED;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* 创建下一个任务节点实例
|
|
224
|
-
* @param flowInstance
|
|
225
|
-
* @param updateNodeInstance
|
|
226
|
-
* @param parsedFlowConfig
|
|
227
|
-
*/
|
|
228
|
-
async executeCreateNextTaskAndNode(flowInstance, updateNodeInstance, parsedFlowConfig) {
|
|
229
|
-
const nextNodeCfgList = await this.executeGetNextNodeByEdgeList(flowInstance, `${updateNodeInstance.id}`, parsedFlowConfig);
|
|
230
|
-
if (!nextNodeCfgList || nextNodeCfgList.length === 0) {
|
|
231
|
-
return [];
|
|
232
|
-
}
|
|
233
|
-
const nextNodeCfgIdList = nextNodeCfgList.map(item => item.id || '').filter(Boolean);
|
|
234
|
-
for (let index = 0; index < nextNodeCfgList.length; index++) {
|
|
235
|
-
const nextNodeCfg = nextNodeCfgList[index];
|
|
236
|
-
// 创建任务实例
|
|
237
|
-
await this.createTasksByNodeConfig(flowInstance, nextNodeCfg, parsedFlowConfig);
|
|
238
|
-
// 创建节点实例
|
|
239
|
-
await this.flowInstanceCrudService.createNodeInstanceByNodeConfigReUse(flowInstance, nextNodeCfg, parsedFlowConfig);
|
|
240
|
-
}
|
|
241
|
-
return nextNodeCfgIdList;
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* 执行系统任务
|
|
245
|
-
* @param flowInstance
|
|
246
|
-
* @param currentNode
|
|
247
|
-
* @param taskList
|
|
248
|
-
* @param parsedFlowConfig
|
|
249
|
-
* @returns
|
|
250
|
-
*/
|
|
251
|
-
async executeSystemTaskList(flowInstance, currentNode, taskList, parsedFlowConfig) {
|
|
252
|
-
const runningTaskList = taskList.filter(task => isTaskRunning(task));
|
|
253
|
-
if (runningTaskList.length === 0) {
|
|
254
|
-
return;
|
|
255
|
-
}
|
|
256
|
-
for (let index = 0; index < runningTaskList.length; index++) {
|
|
257
|
-
const task = runningTaskList[index];
|
|
258
|
-
const nodeInfo = parsedFlowConfig.getNodeInfoByNodeId(task.node_cfg_id || '');
|
|
259
|
-
if (nodeInfo.type === FlowConfigService_1.FlowNodeCfgTypeEnum.SystemNode) {
|
|
260
|
-
await this.executeSystemTask(flowInstance, task, nodeInfo, parsedFlowConfig);
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
/**
|
|
265
|
-
* 执行系统任务
|
|
266
|
-
* @param flowInstance
|
|
267
|
-
* @param task
|
|
268
|
-
* @param nodeInfo
|
|
269
|
-
* @param parsedFlowConfig
|
|
270
|
-
* @returns
|
|
271
|
-
*/
|
|
272
|
-
async executeSystemTask(flowInstance, task, nodeInfo, parsedFlowConfig) {
|
|
273
|
-
// TODO,发送邮件、调用其他系统接口等。
|
|
274
|
-
throw new Error('Method not implemented.');
|
|
275
|
-
}
|
|
276
|
-
/**
|
|
277
|
-
* 执行自动通过任务
|
|
278
|
-
* @param flowInstance
|
|
279
|
-
* @param currentNode
|
|
280
|
-
* @param taskList
|
|
281
|
-
* @param parsedFlowConfig
|
|
282
|
-
* @returns
|
|
283
|
-
*/
|
|
284
|
-
async executeAutoDoneTask(flowInstance, currentNode, taskList, parsedFlowConfig) {
|
|
285
|
-
const runningTaskList = taskList.filter(task => isTaskRunning(task));
|
|
286
|
-
if (runningTaskList.length === 0) {
|
|
287
|
-
return;
|
|
288
|
-
}
|
|
289
|
-
const expressContext = {};
|
|
290
|
-
for (let index = 0; index < runningTaskList.length; index++) {
|
|
291
|
-
const task = runningTaskList[index];
|
|
292
|
-
const updateTaskData = {
|
|
293
|
-
id: task.id,
|
|
294
|
-
};
|
|
295
|
-
const nodeInfo = parsedFlowConfig.getNodeInfoByNodeId(task.node_cfg_id || '');
|
|
296
|
-
const autoApprovedResult = await this.evaluateBoolExpress(nodeInfo.autoApprovedExpress, expressContext);
|
|
297
|
-
if (autoApprovedResult) {
|
|
298
|
-
// 自动通过
|
|
299
|
-
updateTaskData.task_status = FlowModel_1.TaskStatusEnum.APPROVED;
|
|
300
|
-
updateTaskData.task_finished_at = getCurrentDateTime();
|
|
301
|
-
updateTaskData.task_audit_result = FlowModel_1.AuditResultEnum.APPROVED;
|
|
302
|
-
updateTaskData.task_audit_comment = '自动通过';
|
|
303
|
-
updateTaskData.is_sysdone = 1;
|
|
304
|
-
Object.assign(task, updateTaskData);
|
|
305
|
-
await this.flowInstanceCrudService.saveTaskInstance(updateTaskData);
|
|
306
|
-
}
|
|
307
|
-
else {
|
|
308
|
-
const autoRejectedResult = await this.evaluateBoolExpress(nodeInfo.autoRejectExpress, expressContext);
|
|
309
|
-
if (autoRejectedResult) {
|
|
310
|
-
// 自动驳回
|
|
311
|
-
updateTaskData.task_status = FlowModel_1.TaskStatusEnum.REJECTED;
|
|
312
|
-
updateTaskData.task_finished_at = getCurrentDateTime();
|
|
313
|
-
updateTaskData.task_audit_result = FlowModel_1.AuditResultEnum.REJECTED;
|
|
314
|
-
updateTaskData.task_audit_comment = '自动驳回';
|
|
315
|
-
updateTaskData.is_sysdone = 1;
|
|
316
|
-
Object.assign(task, updateTaskData);
|
|
317
|
-
await this.flowInstanceCrudService.saveTaskInstance(updateTaskData);
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
/**
|
|
323
|
-
* 执行一个js表达式,返回boolean
|
|
324
|
-
* @param express
|
|
325
|
-
* @param context
|
|
326
|
-
* @returns
|
|
327
|
-
*/
|
|
328
|
-
async evaluateBoolExpress(express, context) {
|
|
329
|
-
if (!express || typeof express !== 'string' || express.length === 0) {
|
|
330
|
-
return false;
|
|
331
|
-
}
|
|
332
|
-
const result = "" + this.evaluate(express, context);
|
|
333
|
-
return result === 'true';
|
|
334
|
-
}
|
|
335
|
-
/**
|
|
336
|
-
* 根据taskList的结果,计算当前节点的新状态。
|
|
337
|
-
* @param flowInstance
|
|
338
|
-
* @param currentNode
|
|
339
|
-
* @param taskList
|
|
340
|
-
*/
|
|
341
|
-
async executeCalcCurrentNewNodeStatus(flowInstance, currentNode, taskList) {
|
|
342
|
-
// 审批节点
|
|
343
|
-
if (currentNode.type === FlowConfigService_1.FlowNodeCfgTypeEnum.ManualAuditNode) {
|
|
344
|
-
// 会签
|
|
345
|
-
if (currentNode.whereManyUserStrategy === FlowConfigService_1.WhereManyUserStrategyEnum.CounterWork) {
|
|
346
|
-
// 会签节点
|
|
347
|
-
const isAllApproved = taskList.every(task => task.task_audit_result === FlowModel_1.AuditResultEnum.APPROVED);
|
|
348
|
-
if (isAllApproved) {
|
|
349
|
-
return FlowModel_1.NodeStatusEnum.APPROVED;
|
|
350
|
-
}
|
|
351
|
-
const isAnyRejected = taskList.some(task => task.task_audit_result === FlowModel_1.AuditResultEnum.REJECTED);
|
|
352
|
-
if (isAnyRejected) {
|
|
353
|
-
return FlowModel_1.NodeStatusEnum.REJECTED;
|
|
354
|
-
}
|
|
355
|
-
return FlowModel_1.NodeStatusEnum.PENDING;
|
|
356
|
-
}
|
|
357
|
-
// 50%的人会签
|
|
358
|
-
if (currentNode.whereManyUserStrategy === FlowConfigService_1.WhereManyUserStrategyEnum.CounterWork50Approvaled) {
|
|
359
|
-
// 50%通过,节点审批通过
|
|
360
|
-
const is50Approved = taskList.filter(task => task.task_audit_result === FlowModel_1.AuditResultEnum.APPROVED).length >= taskList.length / 2;
|
|
361
|
-
if (is50Approved) {
|
|
362
|
-
return FlowModel_1.NodeStatusEnum.APPROVED;
|
|
363
|
-
}
|
|
364
|
-
// 50%驳回,节点审批驳回
|
|
365
|
-
const is50Rejected = taskList.filter(task => task.task_audit_result === FlowModel_1.AuditResultEnum.REJECTED).length >= taskList.length / 2;
|
|
366
|
-
if (is50Rejected) {
|
|
367
|
-
return FlowModel_1.NodeStatusEnum.REJECTED;
|
|
368
|
-
}
|
|
369
|
-
return FlowModel_1.NodeStatusEnum.PENDING;
|
|
370
|
-
}
|
|
371
|
-
// 任意一个通过,节点审批通过
|
|
372
|
-
if (currentNode.whereManyUserStrategy === FlowConfigService_1.WhereManyUserStrategyEnum.EitherWork) {
|
|
373
|
-
// 所有通过,节点审批通过
|
|
374
|
-
const isAnyApproved = taskList.some(task => task.task_audit_result === FlowModel_1.AuditResultEnum.APPROVED);
|
|
375
|
-
if (isAnyApproved) {
|
|
376
|
-
return FlowModel_1.NodeStatusEnum.APPROVED;
|
|
377
|
-
}
|
|
378
|
-
// 有一个驳回,节点审批驳回
|
|
379
|
-
const isAnyRejected = taskList.some(task => task.task_audit_result === FlowModel_1.AuditResultEnum.REJECTED);
|
|
380
|
-
if (isAnyRejected) {
|
|
381
|
-
return FlowModel_1.NodeStatusEnum.REJECTED;
|
|
382
|
-
}
|
|
383
|
-
return FlowModel_1.NodeStatusEnum.PENDING;
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
// 普通的工作节点
|
|
387
|
-
if (currentNode.type === FlowConfigService_1.FlowNodeCfgTypeEnum.ManualWorkNode) {
|
|
388
|
-
// 会签节点
|
|
389
|
-
if (currentNode.whereManyUserStrategy === FlowConfigService_1.WhereManyUserStrategyEnum.CounterWork) {
|
|
390
|
-
// 所有人的任务都完成,工作节点完成
|
|
391
|
-
const isAllApproved = taskList.every(task => isTaskDone(task));
|
|
392
|
-
if (isAllApproved) {
|
|
393
|
-
return FlowModel_1.NodeStatusEnum.FINISHED;
|
|
394
|
-
}
|
|
395
|
-
return FlowModel_1.NodeStatusEnum.PENDING;
|
|
396
|
-
}
|
|
397
|
-
// 50%的人会签工作完成,工作节点完成
|
|
398
|
-
if (currentNode.whereManyUserStrategy === FlowConfigService_1.WhereManyUserStrategyEnum.CounterWork50Approvaled) {
|
|
399
|
-
// 50%的工作完成,工作节点完成
|
|
400
|
-
const is50Approved = taskList.filter(task => isTaskDone(task)).length >= taskList.length / 2;
|
|
401
|
-
if (is50Approved) {
|
|
402
|
-
return FlowModel_1.NodeStatusEnum.FINISHED;
|
|
403
|
-
}
|
|
404
|
-
return FlowModel_1.NodeStatusEnum.PENDING;
|
|
405
|
-
}
|
|
406
|
-
// 任意一个任务完成,工作节点完成
|
|
407
|
-
if (currentNode.whereManyUserStrategy === FlowConfigService_1.WhereManyUserStrategyEnum.EitherWork) {
|
|
408
|
-
// 任意一个任务完成,工作节点完成
|
|
409
|
-
const isAnyApproved = taskList.some(task => isTaskDone(task));
|
|
410
|
-
if (isAnyApproved) {
|
|
411
|
-
return FlowModel_1.NodeStatusEnum.FINISHED;
|
|
412
|
-
}
|
|
413
|
-
return FlowModel_1.NodeStatusEnum.PENDING;
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
return FlowModel_1.NodeStatusEnum.FINISHED;
|
|
417
|
-
}
|
|
418
|
-
async executeGetNextNodeByEdgeList(flowInstance, curNodeCfgId, parsedFlowConfig) {
|
|
419
|
-
/**
|
|
420
|
-
* 获取当前节点的下一个边缘列表
|
|
421
|
-
*/
|
|
422
|
-
const nextEdgeList = parsedFlowConfig.getNextEdgeList(curNodeCfgId);
|
|
423
|
-
if (!nextEdgeList || nextEdgeList.length === 0) {
|
|
424
|
-
return [];
|
|
425
|
-
}
|
|
426
|
-
const nextNodeList = [];
|
|
427
|
-
for (const edge of nextEdgeList) {
|
|
428
|
-
const isMatched = await this.executeMatchExpress(flowInstance, edge.matchExpress);
|
|
429
|
-
if (isMatched) {
|
|
430
|
-
const nextNode = parsedFlowConfig.getNodeInfoByNodeId(edge.targetRef);
|
|
431
|
-
nextNodeList.push(nextNode);
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
return nextNodeList;
|
|
435
|
-
}
|
|
436
|
-
async executeMatchExpress(flowInstance, matchExpress) {
|
|
437
|
-
throw new Error('Method not implemented.');
|
|
438
|
-
}
|
|
439
|
-
};
|
|
440
|
-
__decorate([
|
|
441
|
-
(0, core_1.Inject)(),
|
|
442
|
-
__metadata("design:type", FlowConfigService_1.FlowConfigService)
|
|
443
|
-
], FlowInstanceService.prototype, "flowConfigService", void 0);
|
|
444
|
-
__decorate([
|
|
445
|
-
(0, core_1.Inject)(),
|
|
446
|
-
__metadata("design:type", FlowInstanceCrudService_1.FlowInstanceCrudService)
|
|
447
|
-
], FlowInstanceService.prototype, "flowInstanceCrudService", void 0);
|
|
448
|
-
FlowInstanceService = __decorate([
|
|
449
|
-
(0, core_1.Provide)()
|
|
450
|
-
], FlowInstanceService);
|
|
451
|
-
exports.FlowInstanceService = FlowInstanceService;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.FlowInstanceService = void 0;
|
|
13
|
+
const core_1 = require("@midwayjs/core");
|
|
14
|
+
const _ = require("lodash");
|
|
15
|
+
const moment = require("moment");
|
|
16
|
+
const FlowModel_1 = require("../../models/FlowModel");
|
|
17
|
+
const FlowConfigService_1 = require("./FlowConfigService");
|
|
18
|
+
const functions_1 = require("../../libs/utils/functions");
|
|
19
|
+
const FlowInstanceCrudService_1 = require("./FlowInstanceCrudService");
|
|
20
|
+
const BaseService_1 = require("../../service/base/BaseService");
|
|
21
|
+
function isTaskRunning(taskInstance) {
|
|
22
|
+
return [FlowModel_1.TaskStatusEnum.PENDING, FlowModel_1.TaskStatusEnum.PROCESSING].includes(taskInstance.task_status);
|
|
23
|
+
}
|
|
24
|
+
function isTaskDone(taskInstance) {
|
|
25
|
+
return !isTaskRunning(taskInstance);
|
|
26
|
+
}
|
|
27
|
+
function isNodeRunning(nodeStatus) {
|
|
28
|
+
return [FlowModel_1.NodeStatusEnum.PENDING, FlowModel_1.NodeStatusEnum.PROCESSING].includes(nodeStatus);
|
|
29
|
+
}
|
|
30
|
+
function isNodeDone(nodeStatus) {
|
|
31
|
+
return !isNodeRunning(nodeStatus);
|
|
32
|
+
}
|
|
33
|
+
function checkRequiredFields(requiredFields, flowInstance) {
|
|
34
|
+
const missingFields = requiredFields.filter(field => {
|
|
35
|
+
const flowInstanceAny = flowInstance;
|
|
36
|
+
return !flowInstanceAny[field];
|
|
37
|
+
});
|
|
38
|
+
if (missingFields.length > 0) {
|
|
39
|
+
throw new Error(`Missing required fields: ${missingFields.join(', ')}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function getCurrentDateTime() {
|
|
43
|
+
return moment().format("YYYY-MM-DD HH:mm:ss");
|
|
44
|
+
}
|
|
45
|
+
let FlowInstanceService = class FlowInstanceService extends BaseService_1.BaseService {
|
|
46
|
+
getCurrentUserAccountId() {
|
|
47
|
+
var _a;
|
|
48
|
+
const sessionInfo = (_a = this.ctx.userSession) === null || _a === void 0 ? void 0 : _a.getSessionInfo();
|
|
49
|
+
return (sessionInfo === null || sessionInfo === void 0 ? void 0 : sessionInfo.accountId) || '';
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* 创建业务对象实例之前,先创建流程实例。
|
|
53
|
+
* 创建流程实例
|
|
54
|
+
* @param flowInstance
|
|
55
|
+
*/
|
|
56
|
+
async createFlowInstance(flowInstance) {
|
|
57
|
+
checkRequiredFields(['flow_code', 'flow_version', 'ticket_no'], flowInstance);
|
|
58
|
+
const parsedFlowConfig = await this.flowConfigService.getParsedFlowConfig(flowInstance.flow_code, flowInstance.flow_version);
|
|
59
|
+
// 开始节点
|
|
60
|
+
const startNode = parsedFlowConfig.getStartNode();
|
|
61
|
+
flowInstance.flow_instance_current_nodeid = startNode.id;
|
|
62
|
+
flowInstance.flow_instance_status = FlowModel_1.FlowInstanceStatus.RUNNING;
|
|
63
|
+
flowInstance.created_by = this.getCurrentUserAccountId();
|
|
64
|
+
// 创建节点实例
|
|
65
|
+
await this.flowInstanceCrudService.createNodeInstanceByNodeConfig(flowInstance, startNode, parsedFlowConfig);
|
|
66
|
+
// 创建任务实例
|
|
67
|
+
await this.createTasksByNodeConfig(flowInstance, startNode, parsedFlowConfig);
|
|
68
|
+
// 执行流程实例
|
|
69
|
+
await this.executeFlowInstance(flowInstance, parsedFlowConfig);
|
|
70
|
+
const flowInstanceId = await this.flowInstanceCrudService.saveFlowInstance(flowInstance);
|
|
71
|
+
const nodeInfo = parsedFlowConfig.getNodeInfoByNodeId(flowInstance.flow_instance_current_nodeid);
|
|
72
|
+
const createdFlowInstance = {
|
|
73
|
+
...flowInstance,
|
|
74
|
+
id: flowInstanceId || '',
|
|
75
|
+
flow_instance_id: flowInstanceId || '',
|
|
76
|
+
flow_instance_current_nodename: nodeInfo.name || '',
|
|
77
|
+
};
|
|
78
|
+
return createdFlowInstance;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* 创建任务实例
|
|
82
|
+
* @param flowInstance
|
|
83
|
+
* @param nodeCfg
|
|
84
|
+
* @param parsedFlowConfig
|
|
85
|
+
* @returns
|
|
86
|
+
*/
|
|
87
|
+
async createTasksByNodeConfig(flowInstance, nodeCfg, parsedFlowConfig) {
|
|
88
|
+
const getFlowInstanceAssignees = (flowInstance) => {
|
|
89
|
+
// TODO
|
|
90
|
+
throw new Error('Function not implemented.');
|
|
91
|
+
};
|
|
92
|
+
const userList = getFlowInstanceAssignees(flowInstance);
|
|
93
|
+
if (!userList || userList.length === 0) {
|
|
94
|
+
// 无需人工处理
|
|
95
|
+
return [];
|
|
96
|
+
}
|
|
97
|
+
const taskInstances = [];
|
|
98
|
+
for (const user of userList) {
|
|
99
|
+
const taskInstance = await this.flowInstanceCrudService.createTaskInstance(flowInstance, nodeCfg, user);
|
|
100
|
+
taskInstances.push(taskInstance);
|
|
101
|
+
}
|
|
102
|
+
return taskInstances;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* 用户手动提交任务操作动作
|
|
106
|
+
* @param submitTask
|
|
107
|
+
*/
|
|
108
|
+
async submitTask(submitTask) {
|
|
109
|
+
const taskInstance = await this.flowInstanceCrudService.getTaskInstance(submitTask.task_instance_id);
|
|
110
|
+
if (!taskInstance) {
|
|
111
|
+
throw new Error('任务实例不存在');
|
|
112
|
+
}
|
|
113
|
+
if (!isTaskRunning(taskInstance)) {
|
|
114
|
+
throw new Error('任务状态不是运行中,不能提交');
|
|
115
|
+
}
|
|
116
|
+
if (taskInstance.task_user_id !== this.getCurrentUserAccountId()) {
|
|
117
|
+
throw new Error('任务处理人不是当前用户');
|
|
118
|
+
}
|
|
119
|
+
const flowInstance = await this.flowInstanceCrudService.getFlowInstance(taskInstance.flow_instance_id);
|
|
120
|
+
if (!flowInstance) {
|
|
121
|
+
throw new Error('流程实例不存在');
|
|
122
|
+
}
|
|
123
|
+
if (flowInstance.flow_instance_status !== FlowModel_1.FlowInstanceStatus.RUNNING) {
|
|
124
|
+
throw new Error('流程实例状态不是运行中,不能提交任务');
|
|
125
|
+
}
|
|
126
|
+
const parsedFlowConfig = await this.flowConfigService.getParsedFlowConfig(flowInstance.flow_code, flowInstance.flow_version);
|
|
127
|
+
const context1 = (0, functions_1.parseJsonObject)(flowInstance.flow_instance_context || '{}');
|
|
128
|
+
const context2 = (0, functions_1.parseJsonObject)(submitTask.flow_instance_context_updated || '{}');
|
|
129
|
+
flowInstance.flow_instance_context = _.merge({}, context1, context2);
|
|
130
|
+
const currNode = parsedFlowConfig.getNodeInfoByNodeId(taskInstance.node_cfg_id || '');
|
|
131
|
+
if (!currNode) {
|
|
132
|
+
throw new Error('node not found');
|
|
133
|
+
}
|
|
134
|
+
const updateTaskData = {};
|
|
135
|
+
updateTaskData.id = taskInstance.id;
|
|
136
|
+
if (submitTask.task_audit_result === FlowModel_1.AuditResultEnum.APPROVED) {
|
|
137
|
+
// 用户处理结果为已通过
|
|
138
|
+
updateTaskData.task_status = FlowModel_1.TaskStatusEnum.APPROVED;
|
|
139
|
+
updateTaskData.task_finished_at = moment().format("YYYY-MM-DD HH:mm:ss");
|
|
140
|
+
updateTaskData.task_audit_result = FlowModel_1.AuditResultEnum.APPROVED;
|
|
141
|
+
updateTaskData.task_audit_comment = submitTask.task_audit_comment || '';
|
|
142
|
+
}
|
|
143
|
+
else if (submitTask.task_audit_result === FlowModel_1.AuditResultEnum.REJECTED) {
|
|
144
|
+
// 用户处理结果为已驳回
|
|
145
|
+
updateTaskData.task_status = FlowModel_1.TaskStatusEnum.REJECTED;
|
|
146
|
+
updateTaskData.task_finished_at = moment().format("YYYY-MM-DD HH:mm:ss");
|
|
147
|
+
updateTaskData.task_audit_result = FlowModel_1.AuditResultEnum.REJECTED;
|
|
148
|
+
updateTaskData.task_audit_comment = submitTask.task_audit_comment || '';
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
// 用户处理结果为已取消
|
|
152
|
+
updateTaskData.task_status = FlowModel_1.TaskStatusEnum.FINISHED;
|
|
153
|
+
updateTaskData.task_finished_at = moment().format("YYYY-MM-DD HH:mm:ss");
|
|
154
|
+
}
|
|
155
|
+
await this.flowInstanceCrudService.saveTaskInstance(updateTaskData);
|
|
156
|
+
await this.executeFlowInstance(flowInstance, parsedFlowConfig);
|
|
157
|
+
await this.flowInstanceCrudService.saveFlowInstance(flowInstance);
|
|
158
|
+
return {
|
|
159
|
+
task_id: taskInstance.id,
|
|
160
|
+
task_status: updateTaskData.task_status,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* 执行一下流程实例
|
|
165
|
+
* @param flowInstance
|
|
166
|
+
* @param parsedFlowConfig
|
|
167
|
+
* @returns
|
|
168
|
+
*/
|
|
169
|
+
async executeFlowInstance(flowInstance, parsedFlowConfig) {
|
|
170
|
+
const taskList = await this.flowInstanceCrudService.getTaskInstanceListByFlowInstanceId(flowInstance.id || '');
|
|
171
|
+
if (!taskList || taskList.length === 0) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
const nodeInstanceList = await this.flowInstanceCrudService.getNodeInstanceListByFlowInstanceId(flowInstance.id || '');
|
|
175
|
+
if (!nodeInstanceList || nodeInstanceList.length === 0) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
if (flowInstance.flow_instance_status !== FlowModel_1.FlowInstanceStatus.RUNNING) {
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
const currentNodeCfgIdList = (0, functions_1.parseJsonObject)(flowInstance.flow_instance_current_nodeids);
|
|
182
|
+
const newNextNodeIdList = [];
|
|
183
|
+
for (let i = 0; i < currentNodeCfgIdList.length; i++) {
|
|
184
|
+
const currentNodeCfgId = currentNodeCfgIdList[i];
|
|
185
|
+
const currentNodeCfgInfo = parsedFlowConfig.getNodeInfoByNodeId(currentNodeCfgId || '');
|
|
186
|
+
if (!currentNodeCfgInfo) {
|
|
187
|
+
throw new Error('current node not found');
|
|
188
|
+
}
|
|
189
|
+
// 执行 自动通过任务
|
|
190
|
+
await this.executeAutoDoneTask(flowInstance, currentNodeCfgInfo, taskList, parsedFlowConfig);
|
|
191
|
+
// 执行 系统任务
|
|
192
|
+
await this.executeSystemTaskList(flowInstance, currentNodeCfgInfo, taskList, parsedFlowConfig);
|
|
193
|
+
// 计算当前节点的新状态
|
|
194
|
+
const currentNodeNewStatus = await this.executeCalcCurrentNewNodeStatus(flowInstance, currentNodeCfgInfo, taskList);
|
|
195
|
+
const currentNodeInstance = await this.flowInstanceCrudService.getNodeInstance(`${flowInstance.id}`, currentNodeCfgId || '');
|
|
196
|
+
// 当前节点最新状态 已完成
|
|
197
|
+
if (isNodeDone(currentNodeNewStatus)) {
|
|
198
|
+
const updateNodeInstance = {};
|
|
199
|
+
updateNodeInstance.id = currentNodeInstance.id;
|
|
200
|
+
updateNodeInstance.node_status = currentNodeNewStatus;
|
|
201
|
+
await this.flowInstanceCrudService.saveNodeInstance(updateNodeInstance);
|
|
202
|
+
const nextNodeIdList0 = await this.executeCreateNextTaskAndNode(flowInstance, updateNodeInstance, parsedFlowConfig);
|
|
203
|
+
if (nextNodeIdList0 && nextNodeIdList0.length > 0) {
|
|
204
|
+
newNextNodeIdList.push(...nextNodeIdList0);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
newNextNodeIdList.push(currentNodeCfgId);
|
|
209
|
+
}
|
|
210
|
+
flowInstance.flow_instance_current_nodeids = newNextNodeIdList;
|
|
211
|
+
flowInstance.flow_instance_current_nodeid = newNextNodeIdList[0] || null;
|
|
212
|
+
}
|
|
213
|
+
// 只有一个节点,并且是结束节点。流程结束。
|
|
214
|
+
if (flowInstance.flow_instance_current_nodeids.length === 1) {
|
|
215
|
+
// 到达最后一个节点,流程实例结束。流程结束节点只有一个。
|
|
216
|
+
const curNodeInfo = parsedFlowConfig.getNodeInfoByNodeId(flowInstance.flow_instance_current_nodeid || '');
|
|
217
|
+
if (curNodeInfo && curNodeInfo.type === FlowConfigService_1.FlowNodeCfgTypeEnum.EndNode) {
|
|
218
|
+
flowInstance.flow_instance_status = FlowModel_1.FlowInstanceStatus.FINISHED;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* 创建下一个任务节点实例
|
|
224
|
+
* @param flowInstance
|
|
225
|
+
* @param updateNodeInstance
|
|
226
|
+
* @param parsedFlowConfig
|
|
227
|
+
*/
|
|
228
|
+
async executeCreateNextTaskAndNode(flowInstance, updateNodeInstance, parsedFlowConfig) {
|
|
229
|
+
const nextNodeCfgList = await this.executeGetNextNodeByEdgeList(flowInstance, `${updateNodeInstance.id}`, parsedFlowConfig);
|
|
230
|
+
if (!nextNodeCfgList || nextNodeCfgList.length === 0) {
|
|
231
|
+
return [];
|
|
232
|
+
}
|
|
233
|
+
const nextNodeCfgIdList = nextNodeCfgList.map(item => item.id || '').filter(Boolean);
|
|
234
|
+
for (let index = 0; index < nextNodeCfgList.length; index++) {
|
|
235
|
+
const nextNodeCfg = nextNodeCfgList[index];
|
|
236
|
+
// 创建任务实例
|
|
237
|
+
await this.createTasksByNodeConfig(flowInstance, nextNodeCfg, parsedFlowConfig);
|
|
238
|
+
// 创建节点实例
|
|
239
|
+
await this.flowInstanceCrudService.createNodeInstanceByNodeConfigReUse(flowInstance, nextNodeCfg, parsedFlowConfig);
|
|
240
|
+
}
|
|
241
|
+
return nextNodeCfgIdList;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* 执行系统任务
|
|
245
|
+
* @param flowInstance
|
|
246
|
+
* @param currentNode
|
|
247
|
+
* @param taskList
|
|
248
|
+
* @param parsedFlowConfig
|
|
249
|
+
* @returns
|
|
250
|
+
*/
|
|
251
|
+
async executeSystemTaskList(flowInstance, currentNode, taskList, parsedFlowConfig) {
|
|
252
|
+
const runningTaskList = taskList.filter(task => isTaskRunning(task));
|
|
253
|
+
if (runningTaskList.length === 0) {
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
for (let index = 0; index < runningTaskList.length; index++) {
|
|
257
|
+
const task = runningTaskList[index];
|
|
258
|
+
const nodeInfo = parsedFlowConfig.getNodeInfoByNodeId(task.node_cfg_id || '');
|
|
259
|
+
if (nodeInfo.type === FlowConfigService_1.FlowNodeCfgTypeEnum.SystemNode) {
|
|
260
|
+
await this.executeSystemTask(flowInstance, task, nodeInfo, parsedFlowConfig);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* 执行系统任务
|
|
266
|
+
* @param flowInstance
|
|
267
|
+
* @param task
|
|
268
|
+
* @param nodeInfo
|
|
269
|
+
* @param parsedFlowConfig
|
|
270
|
+
* @returns
|
|
271
|
+
*/
|
|
272
|
+
async executeSystemTask(flowInstance, task, nodeInfo, parsedFlowConfig) {
|
|
273
|
+
// TODO,发送邮件、调用其他系统接口等。
|
|
274
|
+
throw new Error('Method not implemented.');
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* 执行自动通过任务
|
|
278
|
+
* @param flowInstance
|
|
279
|
+
* @param currentNode
|
|
280
|
+
* @param taskList
|
|
281
|
+
* @param parsedFlowConfig
|
|
282
|
+
* @returns
|
|
283
|
+
*/
|
|
284
|
+
async executeAutoDoneTask(flowInstance, currentNode, taskList, parsedFlowConfig) {
|
|
285
|
+
const runningTaskList = taskList.filter(task => isTaskRunning(task));
|
|
286
|
+
if (runningTaskList.length === 0) {
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
const expressContext = {};
|
|
290
|
+
for (let index = 0; index < runningTaskList.length; index++) {
|
|
291
|
+
const task = runningTaskList[index];
|
|
292
|
+
const updateTaskData = {
|
|
293
|
+
id: task.id,
|
|
294
|
+
};
|
|
295
|
+
const nodeInfo = parsedFlowConfig.getNodeInfoByNodeId(task.node_cfg_id || '');
|
|
296
|
+
const autoApprovedResult = await this.evaluateBoolExpress(nodeInfo.autoApprovedExpress, expressContext);
|
|
297
|
+
if (autoApprovedResult) {
|
|
298
|
+
// 自动通过
|
|
299
|
+
updateTaskData.task_status = FlowModel_1.TaskStatusEnum.APPROVED;
|
|
300
|
+
updateTaskData.task_finished_at = getCurrentDateTime();
|
|
301
|
+
updateTaskData.task_audit_result = FlowModel_1.AuditResultEnum.APPROVED;
|
|
302
|
+
updateTaskData.task_audit_comment = '自动通过';
|
|
303
|
+
updateTaskData.is_sysdone = 1;
|
|
304
|
+
Object.assign(task, updateTaskData);
|
|
305
|
+
await this.flowInstanceCrudService.saveTaskInstance(updateTaskData);
|
|
306
|
+
}
|
|
307
|
+
else {
|
|
308
|
+
const autoRejectedResult = await this.evaluateBoolExpress(nodeInfo.autoRejectExpress, expressContext);
|
|
309
|
+
if (autoRejectedResult) {
|
|
310
|
+
// 自动驳回
|
|
311
|
+
updateTaskData.task_status = FlowModel_1.TaskStatusEnum.REJECTED;
|
|
312
|
+
updateTaskData.task_finished_at = getCurrentDateTime();
|
|
313
|
+
updateTaskData.task_audit_result = FlowModel_1.AuditResultEnum.REJECTED;
|
|
314
|
+
updateTaskData.task_audit_comment = '自动驳回';
|
|
315
|
+
updateTaskData.is_sysdone = 1;
|
|
316
|
+
Object.assign(task, updateTaskData);
|
|
317
|
+
await this.flowInstanceCrudService.saveTaskInstance(updateTaskData);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* 执行一个js表达式,返回boolean
|
|
324
|
+
* @param express
|
|
325
|
+
* @param context
|
|
326
|
+
* @returns
|
|
327
|
+
*/
|
|
328
|
+
async evaluateBoolExpress(express, context) {
|
|
329
|
+
if (!express || typeof express !== 'string' || express.length === 0) {
|
|
330
|
+
return false;
|
|
331
|
+
}
|
|
332
|
+
const result = "" + this.evaluate(express, context);
|
|
333
|
+
return result === 'true';
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* 根据taskList的结果,计算当前节点的新状态。
|
|
337
|
+
* @param flowInstance
|
|
338
|
+
* @param currentNode
|
|
339
|
+
* @param taskList
|
|
340
|
+
*/
|
|
341
|
+
async executeCalcCurrentNewNodeStatus(flowInstance, currentNode, taskList) {
|
|
342
|
+
// 审批节点
|
|
343
|
+
if (currentNode.type === FlowConfigService_1.FlowNodeCfgTypeEnum.ManualAuditNode) {
|
|
344
|
+
// 会签
|
|
345
|
+
if (currentNode.whereManyUserStrategy === FlowConfigService_1.WhereManyUserStrategyEnum.CounterWork) {
|
|
346
|
+
// 会签节点
|
|
347
|
+
const isAllApproved = taskList.every(task => task.task_audit_result === FlowModel_1.AuditResultEnum.APPROVED);
|
|
348
|
+
if (isAllApproved) {
|
|
349
|
+
return FlowModel_1.NodeStatusEnum.APPROVED;
|
|
350
|
+
}
|
|
351
|
+
const isAnyRejected = taskList.some(task => task.task_audit_result === FlowModel_1.AuditResultEnum.REJECTED);
|
|
352
|
+
if (isAnyRejected) {
|
|
353
|
+
return FlowModel_1.NodeStatusEnum.REJECTED;
|
|
354
|
+
}
|
|
355
|
+
return FlowModel_1.NodeStatusEnum.PENDING;
|
|
356
|
+
}
|
|
357
|
+
// 50%的人会签
|
|
358
|
+
if (currentNode.whereManyUserStrategy === FlowConfigService_1.WhereManyUserStrategyEnum.CounterWork50Approvaled) {
|
|
359
|
+
// 50%通过,节点审批通过
|
|
360
|
+
const is50Approved = taskList.filter(task => task.task_audit_result === FlowModel_1.AuditResultEnum.APPROVED).length >= taskList.length / 2;
|
|
361
|
+
if (is50Approved) {
|
|
362
|
+
return FlowModel_1.NodeStatusEnum.APPROVED;
|
|
363
|
+
}
|
|
364
|
+
// 50%驳回,节点审批驳回
|
|
365
|
+
const is50Rejected = taskList.filter(task => task.task_audit_result === FlowModel_1.AuditResultEnum.REJECTED).length >= taskList.length / 2;
|
|
366
|
+
if (is50Rejected) {
|
|
367
|
+
return FlowModel_1.NodeStatusEnum.REJECTED;
|
|
368
|
+
}
|
|
369
|
+
return FlowModel_1.NodeStatusEnum.PENDING;
|
|
370
|
+
}
|
|
371
|
+
// 任意一个通过,节点审批通过
|
|
372
|
+
if (currentNode.whereManyUserStrategy === FlowConfigService_1.WhereManyUserStrategyEnum.EitherWork) {
|
|
373
|
+
// 所有通过,节点审批通过
|
|
374
|
+
const isAnyApproved = taskList.some(task => task.task_audit_result === FlowModel_1.AuditResultEnum.APPROVED);
|
|
375
|
+
if (isAnyApproved) {
|
|
376
|
+
return FlowModel_1.NodeStatusEnum.APPROVED;
|
|
377
|
+
}
|
|
378
|
+
// 有一个驳回,节点审批驳回
|
|
379
|
+
const isAnyRejected = taskList.some(task => task.task_audit_result === FlowModel_1.AuditResultEnum.REJECTED);
|
|
380
|
+
if (isAnyRejected) {
|
|
381
|
+
return FlowModel_1.NodeStatusEnum.REJECTED;
|
|
382
|
+
}
|
|
383
|
+
return FlowModel_1.NodeStatusEnum.PENDING;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
// 普通的工作节点
|
|
387
|
+
if (currentNode.type === FlowConfigService_1.FlowNodeCfgTypeEnum.ManualWorkNode) {
|
|
388
|
+
// 会签节点
|
|
389
|
+
if (currentNode.whereManyUserStrategy === FlowConfigService_1.WhereManyUserStrategyEnum.CounterWork) {
|
|
390
|
+
// 所有人的任务都完成,工作节点完成
|
|
391
|
+
const isAllApproved = taskList.every(task => isTaskDone(task));
|
|
392
|
+
if (isAllApproved) {
|
|
393
|
+
return FlowModel_1.NodeStatusEnum.FINISHED;
|
|
394
|
+
}
|
|
395
|
+
return FlowModel_1.NodeStatusEnum.PENDING;
|
|
396
|
+
}
|
|
397
|
+
// 50%的人会签工作完成,工作节点完成
|
|
398
|
+
if (currentNode.whereManyUserStrategy === FlowConfigService_1.WhereManyUserStrategyEnum.CounterWork50Approvaled) {
|
|
399
|
+
// 50%的工作完成,工作节点完成
|
|
400
|
+
const is50Approved = taskList.filter(task => isTaskDone(task)).length >= taskList.length / 2;
|
|
401
|
+
if (is50Approved) {
|
|
402
|
+
return FlowModel_1.NodeStatusEnum.FINISHED;
|
|
403
|
+
}
|
|
404
|
+
return FlowModel_1.NodeStatusEnum.PENDING;
|
|
405
|
+
}
|
|
406
|
+
// 任意一个任务完成,工作节点完成
|
|
407
|
+
if (currentNode.whereManyUserStrategy === FlowConfigService_1.WhereManyUserStrategyEnum.EitherWork) {
|
|
408
|
+
// 任意一个任务完成,工作节点完成
|
|
409
|
+
const isAnyApproved = taskList.some(task => isTaskDone(task));
|
|
410
|
+
if (isAnyApproved) {
|
|
411
|
+
return FlowModel_1.NodeStatusEnum.FINISHED;
|
|
412
|
+
}
|
|
413
|
+
return FlowModel_1.NodeStatusEnum.PENDING;
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
return FlowModel_1.NodeStatusEnum.FINISHED;
|
|
417
|
+
}
|
|
418
|
+
async executeGetNextNodeByEdgeList(flowInstance, curNodeCfgId, parsedFlowConfig) {
|
|
419
|
+
/**
|
|
420
|
+
* 获取当前节点的下一个边缘列表
|
|
421
|
+
*/
|
|
422
|
+
const nextEdgeList = parsedFlowConfig.getNextEdgeList(curNodeCfgId);
|
|
423
|
+
if (!nextEdgeList || nextEdgeList.length === 0) {
|
|
424
|
+
return [];
|
|
425
|
+
}
|
|
426
|
+
const nextNodeList = [];
|
|
427
|
+
for (const edge of nextEdgeList) {
|
|
428
|
+
const isMatched = await this.executeMatchExpress(flowInstance, edge.matchExpress);
|
|
429
|
+
if (isMatched) {
|
|
430
|
+
const nextNode = parsedFlowConfig.getNodeInfoByNodeId(edge.targetRef);
|
|
431
|
+
nextNodeList.push(nextNode);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
return nextNodeList;
|
|
435
|
+
}
|
|
436
|
+
async executeMatchExpress(flowInstance, matchExpress) {
|
|
437
|
+
throw new Error('Method not implemented.');
|
|
438
|
+
}
|
|
439
|
+
};
|
|
440
|
+
__decorate([
|
|
441
|
+
(0, core_1.Inject)(),
|
|
442
|
+
__metadata("design:type", FlowConfigService_1.FlowConfigService)
|
|
443
|
+
], FlowInstanceService.prototype, "flowConfigService", void 0);
|
|
444
|
+
__decorate([
|
|
445
|
+
(0, core_1.Inject)(),
|
|
446
|
+
__metadata("design:type", FlowInstanceCrudService_1.FlowInstanceCrudService)
|
|
447
|
+
], FlowInstanceService.prototype, "flowInstanceCrudService", void 0);
|
|
448
|
+
FlowInstanceService = __decorate([
|
|
449
|
+
(0, core_1.Provide)()
|
|
450
|
+
], FlowInstanceService);
|
|
451
|
+
exports.FlowInstanceService = FlowInstanceService;
|