--[[ 编码: 名称: MOBOX-LUA-FUNC-EPI 作者:HAN 日期:2025-1-21 级别:BASIS 函数:main 输入的body体 {func = "函数名称", ...} 功能: 更改记录: --]] json = require ("json") mobox = require("OILua_JavelinExt") m3 = require("oi_base_mobox") function main( strLuaDEID ) local nRet, body, err_code, strValue local strClsID, strObjID, strAttrs err_code = 0 -- 获取接口传入的数据 nRet, body = m3.GetSysDataJson(strLuaDEID) if ( nRet ~= 0 ) then err_code = 200 strValue = "WebAPI输入参数的格式有问题!"..body goto api_call_return end if ( body.func == nil ) then err_code = 200 strValue = "WebAPI输入参数的格式有问题! func 必须有值" goto api_call_return end if ( body.func == "getCurEditDataObjAttr" ) then nRet, strValue = mobox.getCurEditDataObjAttr( body.strLuaDEID, table.unpack(body.attr_name) ) elseif ( body.func == "setCurEditDataObjAttr" ) then nRet, strValue = mobox.setCurEditDataObjAttr( body.strLuaDEID, body.strAttrSetInfo ) elseif ( body.func == "getCurEditDataObjID" ) then nRet, strClsID, strObjID = mobox.getCurEditDataObjID( body.strLuaDEID ) if ( nRet == 0 ) then local result = { code = err_code, ret_parameter_num = 2, value = strClsID, value2 = strObjID } m3.EPI_Return( strLuaDEID, result ) return end elseif ( body.func == "getCurMasterInfo" ) then nRet, strValue = mobox.getCurMasterInfo( body.strLuaDEID ) elseif ( body.func == "getCurEditOldDataObjAttr" ) then nRet, strValue = mobox.getCurEditOldDataObjAttr( body.strLuaDEID, table.unpack(body.attr_name) ) elseif ( body.func == "getCurEditExtInfo" ) then nRet, strValue = mobox.getCurEditExtInfo( body.strLuaDEID ) elseif ( body.func == "getCurEditDataPacket" ) then nRet, strValue = mobox.getCurEditDataPacket( body.strLuaDEID ) elseif ( body.func == "getDataObjAttr" ) then nRet, strValue = mobox.getDataObjAttr( body.strLuaDEID, body.strClsName, body.strObjID, table.unpack(body.attr_name) ) elseif ( body.func == "setDataObjAttr" ) then nRet, strValue = mobox.setDataObjAttr( body.strLuaDEID, body.strClsName, body.strObjID, body.strAttrInfo ) elseif ( body.func == "setDataObjAce" ) then nRet, strValue = mobox.setDataObjAce( body.strLuaDEID, body.strClsName, body.strObjID, body.strAceSet ) elseif ( body.func == "setDataObjState" ) then nRet, strValue = mobox.setDataObjState( body.strLuaDEID, body.strClsName, body.strObjID, body.strState ) elseif ( body.func == "setDataObjStateByCondition" ) then nRet, strValue = mobox.setDataObjStateByCondition( body.strLuaDEID, body.strClassName, body.strCondition, body.strState, body.bTriggerEvent ) elseif ( body.func == "getDataObjAttrByKeyAttr" ) then nRet, strObjID, strAttrs = mobox.getDataObjAttrByKeyAttr( body.strLuaDEID, body.strClsName, body.strCondition, table.unpack(body.attr_name) ) if ( nRet == 0 ) then local result = { code = err_code, ret_parameter_num = 2, value = strObjID, value2 = strAttrs } m3.EPI_Return( strLuaDEID, result ) return end elseif ( body.func == "allocObject" ) then nRet, strValue = mobox.allocObject( body.strClassID ) elseif ( body.func == "allocObject2" ) then nRet, strValue = mobox.allocObject2( body.strClassID, body.bAllAttr ) elseif ( body.func == "formatLuaJson" ) then nRet, strValue = mobox.formatLuaJson( body.strLuaJson ) elseif ( body.func == "luaJsonToObjAttrs" ) then nRet, strValue = mobox.luaJsonToObjAttrs( body.strClassID, body.strLuaJson ) elseif ( body.func == "objAttrsToLuaJson" ) then nRet, strValue = mobox.objAttrsToLuaJson( body.strClassID, body.strObjAttrs ) elseif ( body.func == "luaJsonToObjJson" ) then nRet, strValue = mobox.luaJsonToObjJson( body.strClassID, body.strLuaJson ) elseif ( body.func == "objJsonToLuaJson" ) then nRet, strValue = mobox.objJsonToLuaJson( body.strClassID, body.strObjJson ) elseif ( body.func == "objAttrToObjJson" ) then nRet, strValue = mobox.objAttrToObjJson( body.strClassID, body.strObjAttrs ) elseif ( body.func == "objJsonToObjAttr" ) then nRet, strValue = mobox.objJsonToObjAttr( body.strClassID, body.strObjJson ) elseif ( body.func == "incDataObjAccQty" ) then nRet, strValue = mobox.incDataObjAccQty( body.strLuaDEID, body.strClassID, body.strCondition, body.strMaxQtyAttr, body.strAccQtyAttr, body.fQty, body.bExactQty ) elseif ( body.func == "decDataObjAccQty" ) then nRet, strValue = mobox.decDataObjAccQty( body.strLuaDEID, body.strClassID, body.strCondition, body.strAccQtyAttr, body.fQty ) elseif ( body.func == "createDataObj" ) then nRet, strValue = mobox.createDataObj( body.strLuaDEID, body.strClsName, body.strAttrs, body.bReturnLuaAttr, body.bUpdateExist, body.bTrigSysEvent, body.strMasterClsName, body.strMasterObjID ) elseif ( body.func == "createDataObj2" ) then nRet, strValue = mobox.createDataObj2( body.strLuaDEID, body.strClsName, body.strObjJson, body.bUpdateExist, body.bTrigSysEvent, body.strMasterClsName, body.strMasterObjID ) elseif ( body.func == "insertrDataObj" ) then nRet, strValue = mobox.insertrDataObj( body.strLuaDEID, body.strClsName, body.strDataJson, body.bRunSysEvent, body.bUpdateExist ) elseif ( body.func == "updateDataObj" ) then nRet, strValue = mobox.updateDataObj( body.strLuaDEID, body.strClsName, body.strDataJson, body.bRunSysEvent ) elseif ( body.func == "updateDataAttrByCondition" ) then nRet, strValue = mobox.updateDataAttrByCondition( body.strLuaDEID, body.strClsName, body.strCondition, body.strSetSQL ) elseif ( body.func == "updateTableAttrByCondition" ) then nRet, strValue = mobox.updateTableAttrByCondition( body.strLuaDEID, body.strTableName, body.strCondition, body.strSetSQL ) elseif ( body.func == "dbdeleteData" ) then nRet, strValue = mobox.dbdeleteData( body.strLuaDEID, body.strClsName, body.strCondition ) elseif ( body.func == "deleteDataObject" ) then nRet, strValue = mobox.deleteDataObject( body.strLuaDEID, body.strClsName, body.strCondition ) elseif ( body.func == "queryDataObjAttr" ) then nRet, strValue = mobox.queryDataObjAttr( body.strLuaDEID, body.strClsName, body.strCondition, body.strOrder, table.unpack(body.attr_name) ) elseif ( body.func == "queryDataObjAttr2" ) then nRet, strValue = mobox.queryDataObjAttr2( body.strLuaDEID, body.strClsName, body.strCondition, body.strOrder, body.nPageSize, table.unpack(body.attr_name) ) elseif ( body.func == "queryDataObjAttr2_1" ) then nRet, strValue = mobox.queryDataObjAttr2( body.strQueryID, body.nPage ) elseif ( body.func == "queryDataObjAttr3" ) then nRet, strValue = mobox.queryDataObjAttr3( body.strLuaDEID, body.strClsName, body.strCondition, body.nRetCount, body.strOrder, table.unpack(body.attr_name) ) elseif ( body.func == "queryOneDataObjAttr2" ) then nRet, strValue = mobox.queryOneDataObjAttr2( body.strLuaDEID, body.strClsName, body.strCondition, body.strOrderBy, table.unpack(body.attr_name) ) elseif ( body.func == "queryTable" ) then nRet, strValue = mobox.queryTable( body.strLuaDEID, body.strTabName, body.strFieldList, body.nRetCount, body.strCondition, body.strOrderBy ) elseif ( body.func == "queryTable2" ) then nRet, strValue = mobox.queryTable2( body.strLuaDEID, body.strTabName, body.strFieldList, body.nPageSize, table.unpack(body.attr_name) ) elseif ( body.func == "queryTable2_1" ) then nRet, strValue = mobox.queryTable2( body.strLuaDEID, body.nPage ) elseif ( body.func == "queryMultiTable" ) then nRet, strValue = mobox.queryMultiTable( body.strLuaDEID, body.strAttrInfo, body.strFromTabInfo, body.nRetCount, body.strCondition, body.strOrderBy ) elseif ( body.func == "queryMultiTable2" ) then nRet, strValue = mobox.queryMultiTable2( body.strLuaDEID, body.strAttrInfo, body.strFromTabInfo, body.nPageSize, table.unpack(body.attr_name) ) elseif ( body.func == "queryMultiTable2_1" ) then nRet, strValue = mobox.queryMultiTable2( body.strLuaDEID, body.nPage ) elseif ( body.func == "getDataObjCount" ) then nRet, strValue = mobox.getDataObjCount( body.strLuaDEID, body.strClsName, body.strCondition ) elseif ( body.func == "groupDataObjAttr" ) then nRet, strValue = mobox.groupDataObjAttr( body.strLuaDEID, body.strClsName, body.strCondition, body.strAttr, body.strOrder ) elseif ( body.func == "getDataObjGroupCount" ) then nRet, strValue = mobox.getDataObjGroupCount( body.strLuaDEID, body.strClassName, body.strGroupAttr, body.strCondition ) elseif ( body.func == "groupDataObjAttrSum" ) then nRet, strValue = mobox.groupDataObjAttrSum( body.strLuaDEID, body.strClassName, body.strCondition, body.strGroupAttr, table.unpack(body.attr_name) ) elseif ( body.func == "getDataObjAttrGroupSum" ) then nRet, strValue = mobox.getDataObjAttrGroupSum( body.strLuaDEID, body.strClassName, body.strCondition, body.strGroupAttrs, body.strSumAttrs, body.strOtherAttrs, body.strOrderBy ) elseif ( body.func == "groupDataObjAttrs" ) then nRet, strValue = mobox.groupDataObjAttrs( body.strLuaDEID, body.strClsName, body.strCondition, body.strOrderBy, table.unpack(body.attr_name) ) elseif ( body.func == "groupTableAttrs" ) then nRet, strValue = mobox.groupTableAttrs( body.strLuaDEID, body.strTabName, body.strCondition, body.strOrder, table.unpack(body.attr_name) ) elseif ( body.func == "getDBRecordCount" ) then nRet, strValue = mobox.getDBRecordCount( body.strLuaDEID, body.strTabName, body.strCondition ) elseif ( body.func == "getDataObjAttrSum" ) then nRet, strValue = mobox.getDataObjAttrSum( body.strLuaDEID, body.strClsName, body.strCondition, table.unpack(body.attr_name) ) elseif ( body.func == "getDataObjAttrSum2" ) then nRet, strValue = mobox.getDataObjAttrSum2( body.strLuaDEID, body.strClsName, body.strCondition, table.unpack(body.attr_name) ) elseif ( body.func == "getDataObjAttrAvg" ) then nRet, strValue = mobox.getDataObjAttrAvg( body.strLuaDEID, body.strClsName, body.strCondition, table.unpack(body.attr_name) ) elseif ( body.func == "getDataObjAttrAvg2" ) then nRet, strValue = mobox.getDataObjAttrAvg2( body.strLuaDEID, body.strClsName, body.strCondition, table.unpack(body.attr_name) ) elseif ( body.func == "existThisData" ) then nRet, strValue = mobox.existThisData( body.strLuaDEID, body.strClsName, body.strCondition ) elseif ( body.func == "getDictItemIInfo" ) then nRet, strValue = mobox.getDictItemIInfo( body.strDirctName, body.strDirctItemName ) elseif ( body.func == "getDictItemIInfo2" ) then nRet, strValue = mobox.getDictItemIInfo2( body.strLuaDEID, body.strDirctName, body.strDirctItemName ) elseif ( body.func == "addDictItem" ) then nRet, strValue = mobox.addDictItem( body.strDirctName, body.strDirctItemName ) elseif ( body.func == "deleteDictItem" ) then nRet, strValue = mobox.deleteDictItem( body.strDirctName, body.strDirctItemName ) elseif ( body.func == "reloadDictData" ) then nRet, strValue = mobox.reloadDictData( body.strLuaDEID ) elseif ( body.func == "getGlobalAttr" ) then nRet, strValue = mobox.getGlobalAttr( body.strLuaDEID, table.unpack(body.attr_name) ) elseif ( body.func == "setGlobalAttr" ) then nRet, strValue = mobox.setGlobalAttr( body.strLuaDEID, body.strAttrSet ) elseif ( body.func == "getCacheValue" ) then nRet, strValue = mobox.getCacheValue( body.strKey, body.strGroupID ) elseif ( body.func == "setCacheValue" ) then nRet, strValue = mobox.setCacheValue( body.strKey, body.strValue, body.strGroupID ) elseif ( body.func == "removeCacheValue" ) then nRet, strValue = mobox.removeCacheValue( body.strKey, body.strGroupID ) elseif ( body.func == "getCurUserInfo" ) then nRet, strValue = mobox.getCurUserInfo( body.strLuaDEID ) elseif ( body.func == "getUserInfo" ) then nRet, strValue = mobox.getUserInfo( body.strUserLogin, body.bDetail, body.bWithClientInfo ) elseif ( body.func == "getUserTerminalInfo" ) then nRet, strValue = mobox.getUserTerminalInfo( body.strUserLogin ) elseif ( body.func == "getInputParameter2" ) then nRet, strValue = mobox.getInputParameter2( body.strLuaDEID ) elseif ( body.func == "stopProgram" ) then nRet, strValue = mobox.stopProgram( body.strLuaDEID, body.strMsgInfo ) elseif ( body.func == "error" ) then nRet, strValue = mobox.error( body.strLuaDEID, body.strErrInfo ) elseif ( body.func == "setAction" ) then nRet, strValue = mobox.setAction( body.strLuaDEID, body.strAction ) elseif ( body.func == "setInfo" ) then nRet, strValue = mobox.setInfo( body.strLuaDEID, body.strInfo, body.nInfoCloseTime ) elseif ( body.func == "returnValue" ) then nRet, strValue = mobox.returnValue( body.strLuaDEID, body.nRetStrIsJson, body.strReturn, body.nRetResType ) elseif ( body.func == "getLuaDEInfo" ) then nRet, strValue = mobox.getLuaDEInfo( body.strLuaDEID ) elseif ( body.func == "getSerialNumber" ) then nRet, strValue = mobox.getSerialNumber( body.strCodeType, body.strHeadCode, body.nCodeSize ) elseif ( body.func == "getSerialMaxNumber" ) then nRet, strValue = mobox.getSerialMaxNumber( body.strCodeType, body.strHeadCode, body.nCodeOrderLen ) elseif ( body.func == "removeSerialNumber" ) then nRet, strValue = mobox.removeSerialNumber( body.strCodeType, body.strHeadCode ) elseif ( body.func == "base64ToStr" ) then nRet, strValue = mobox.base64ToStr( body.strBase64 ) elseif ( body.func == "strToBase64" ) then nRet, strValue = mobox.strToBase64( body.strData ) elseif ( body.func == "getParameter" ) then nRet, strValue = mobox.getParameter( body.strLuaDEID, body.strParameterCode ) elseif ( body.func == "sendHttpRequest" ) then nRet, strValue = mobox.sendHttpRequest( body.strUrl, body.strHeader, body.strBody, body.strMethod ) elseif ( body.func == "sendHttpRequest_Get" ) then nRet, strValue = mobox.sendHttpRequest_Get( body.strUrl, body.strHeader ) elseif ( body.func == "genReqVerify" ) then nRet, strValue = mobox.genReqVerify( body.strAppKey, body.strAppSecret, body.strReqUser ) elseif ( body.func == "getInputParameter2" ) then nRet, strValue = mobox.getInputParameter2( body.strLuaDEID ) elseif ( body.func == "getInputParameter2" ) then nRet, strValue = mobox.getInputParameter2( body.strLuaDEID ) elseif ( body.func == "triggerClsEvent" ) then nRet, strValue = mobox.triggerClsEvent( body.strLuaDEID, body.strClsName, body.strObjID, body.strEventName, body.strParameter, body.strDataJson ) elseif ( body.func == "triggerClsEventBatch" ) then nRet, strValue = mobox.triggerClsEventBatch( body.strLuaDEID, body.strClsName, body.strCondition, body.strEventName, body.strDataJson, body.strDisplayName ) elseif ( body.func == "addBackendScriptProc" ) then nRet, strValue = mobox.addBackendScriptProc( body.strClassID, body.strEventName, body.strDataJson ) elseif ( body.func == "getBackendScriptProcResult" ) then nRet, strValue = mobox.getBackendScriptProcResult( body.strProcID ) elseif ( body.func == "addSysWFP" ) then nRet, strValue = mobox.addSysWFP( body.strLuaDEID, body.nWFPType, body.strDataJson, body.strClsName, body.strObjID, body.strObjName, body.nTriggerType, body.strTriggerTime, body.strEventName, body.strDisplayName, body.strSrcName, body.bIsSys ) elseif ( body.func == "deleteSysWFP" ) then nRet, strValue = mobox.deleteSysWFP( body.strLuaDEID, body.strCondition ) elseif ( body.func == "writeSysLog" ) then nRet, strValue = mobox.writeSysLog( body.strLogType, body.strLogContent ) elseif ( body.func == "getCurTime_MS" ) then nRet, strValue = mobox.getCurTime_MS( ) elseif ( body.func == "addProcSQL" ) then nRet, strValue = mobox.addProcSQL( body.strSQL ) elseif ( body.func == "addProcSQL2" ) then nRet, strValue = mobox.addProcSQL2( body.strClassName, body.strObjID, body.strUpdateSet ) elseif ( body.func == "addProcSQL3" ) then nRet, strValue = mobox.addProcSQL3( body.strClassName, body.strCondition, body.strUpdateSet ) elseif ( body.func == "addProcSQL4" ) then nRet, strValue = mobox.addProcSQL4( body.strSQL ) elseif ( body.func == "writeLuaLog" ) then nRet, strValue = mobox.writeLuaLog( body.strLogContent ) elseif ( body.func == "startTransaction" ) then nRet, strValue = mobox.startTransaction( body.strLuaDEID ) elseif ( body.func == "commit" ) then nRet, strValue = mobox.commit( body.strLuaDEID ) elseif ( body.func == "abort" ) then nRet, strValue = mobox.abort( body.strLuaDEID ) else err_code = 200 strValue = "WebAPI输入参数的格式有问题! 没有定义名为'"..body.func.."'的wms内部函数!" goto api_call_return end if (nRet ~= 0 ) then err_code = 201 end ::api_call_return:: -- 设置返回结果 local result = { code = err_code, ret_parameter_num = 1, -- 说明返回参数只有一个 value = strValue } m3.EPI_Return( strLuaDEID, result ) end