def saveWorkFlow(): # 添加流程 flow = flask.request.form.get('content') if not flow: return flask.jsonify({ 'code': ErrorCode.NoContentInReq, 'id': -1 }) flowId = flask.request.form.get('id') code = ErrorCode.NoError if flowId: code = WorkFlowDao.updateWorkflow(flowId, flow, getUserId()) else: wf = WorkFlow(flow, getUserId()) code = WorkFlowDao.saveWorkflow(wf) flowId = wf.id uiData = flask.request.form.get('uidata') if uiData: code = UiDataDao.setData(flowId, uiData, getUserId()) return flask.jsonify({ 'code': code, 'id': flowId })
def prepareDir(): flowId = flask.request.form.get('flowId') rootDir = flask.request.form.get('dir') classify = flask.request.form.get('classify', config.DEFAULT_RES_CLASSIFY) userid = getUserId() try: username = LoginInfoDao.queryUsernameByuserid(userid) except: config.Log.info(traceback.format_exc()) code = ErrorCode.NoError if not flowId: code = ErrorCode.NoFlowIdInReq elif not rootDir: code = ErrorCode.NoDirInReq elif not userid: code = ErrorCode.NotFindUser else: flow = WorkFlowDao.queryWorkflow(flowId, getUserId()) if not flow: code = ErrorCode.NotFindFlowById else: code = fs.prepareDirOnWebos(userid, username, rootDir, flow.content) return flask.jsonify({'code':code})
def delWorkFlow(): userId = getUserId() # 删除流程 flowId = flask.request.form.get('id') if not flowId: return flask.jsonify({'code': ErrorCode.NoFlowIdInReq}) flow = WorkFlowDao.queryWorkflow(flowId, userId) if flow.userId != userId: return flask.jsonify({'code': ErrorCode.CannotDeleteMutualFlow}) UiDataDao.deleteUiDataByFlowId(flowId, userId) taskIdList = TaskDao.queryTaskIdByFlowId(flowId, userId) for id in taskIdList: TaskStateDao.deleteTaskState(id, userId) TaskDao.deleteByFlowId(flowId, userId) code = WorkFlowDao.deleteWorkflow(flowId, userId) return flask.jsonify({'code': code})
def flowSocializationById(): # 流程所有者将流程公有化(所有用户可见但只有所有者可修改、删除) flowId = flask.request.form.get('id') if not flowId: return flask.jsonify({ 'code': ErrorCode.NoFlowIdInReq }) flow = WorkFlowDao.queryWorkflow(flowId, getUserId()) if flow: flow.type = 'mutual' WorkFlowDao.saveWorkflow(flow) return flask.jsonify({ 'code': ErrorCode.NoError, 'flowId': flowId }) else: return flask.jsonify({ 'code': ErrorCode.NotFindFlowById, 'flowId': flowId })
def startTask(): taskId = flask.request.form.get('id') if not taskId: return flask.jsonify({'code': ErrorCode.NoTaskIdInReq}) userId = getUserId() # userId = '200010035103900' task = TaskDao.queryTask(taskId, userId) if not task: return flask.jsonify({'code': ErrorCode.NotFindTaskById}) flow = WorkFlowDao.queryWorkflow(task.flowId, userId) if not flow: return flask.jsonify({'code': ErrorCode.NotFindFlowById}) return _requestTaskServerRetCode(taskId, TaskRequestType.StartTask, { 'task': task.dumpDetail(), 'flow': flow.dumpDetail() })
def getWorkFlow(id): wf = WorkFlowDao.queryWorkflow(id, getUserId()) return flask.jsonify(wf.dumpDetail() if wf else {})
def getMutualFlow(): wfs = [wf.dumpInfo() for wf in WorkFlowDao.getMutualFlowList()] return flask.jsonify(wfs)
def getWorkFlowListByKey(key): wfs = [wf.dumpInfo() for wf in WorkFlowDao.queryByKey(key, getUserId())] return flask.jsonify(wfs)
def getWorkFlowList(): # config.Log.info('userid = %s' % getUserId()) wfs = [wf.dumpInfo() for wf in WorkFlowDao.workflowList(getUserId())] return flask.jsonify(wfs)