//#import Util.js
//#import base64.js
//#import HttpUtil.js
//#import session.js
//#import $@projectCode:services/modelService.jsx
//#import @handlers/include/checklogin.jsx
//#import  @handlers/include/util.jsx
//#import $owl_task_info:services/modelService.jsx


function main(){
    var env = checklogin();
    if(!env){
        return;
    }
    var shopId = env.shopId;
    var warehouseId = env.warehouseId;
    var loginId = env.loginId;
    var roleId = env.roleId;
    var orgId = env.orgId;
    var spec = @spec;
    var tableId = 'owl_' + spec._t;
    var m = shopId;
    ///////////////////////////////

//判断是subplatform,还是shop,还是platform
    var params = JSON.parse($body);
    var searchArgs = params.searchArgs;
    var templateId = params.templateId;

    var sort = params.sort;
    var exportRange = params.exportRange;
    var outputTarget = params.outputTarget;
    var ids = params.ids;

    var taskParams = {
        searchArgs:searchArgs,
        roleId:roleId,
        tableId:tableId,
        sort:sort,
        orgId:orgId,
        loginId:loginId,
        exportRange:exportRange,
        outputTarget:outputTarget,
        templateId:templateId,
        ids:ids
    }

    var now = new Date().getTime();
    var taskInfo = {
        submitDate: now,
        appId:'@projectCode',
        pageId:'tasks/exportExTask.jsx',
        state:'notstart',
        params:JSON.stringify(taskParams)
    };
    owl_task_infoService.add(taskInfo);
    var taskInfoId = taskInfo.id;
    JobsService.submitExportTask('@projectCode', 'tasks/exportExTask.jsx',{
        taskParams:taskParams,
        taskInfoId:"" + taskInfoId
    },now);

    var ret = {
        state:'ok',
        taskInfoId : taskInfoId
    }
    out.print(JSON.stringify(ret));
    return;







}
main();