package com.customization.htsc.integration;

import com.engine.core.cfg.annotation.CommandDynamicProxy;
import com.engine.core.interceptor.AbstractCommandProxy;
import com.engine.core.interceptor.Command;
import com.engine.workflow.cmd.requestForm.RemarkSubmitCmd;
import com.engine.workflow.entity.requestForm.RequestOperationResultBean;
import weaver.filter.WeaverRequest;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.workflow.request.WFAutoApproveThreadPoolUtil;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * Author:wanxq
 * Date:2021/04/01 19:53
 * Description: 集成门户统一已办
 * Copyright:上海泛微网络科技股份有限公司
 */
@CommandDynamicProxy(target = RemarkSubmitCmd.class, desc = "集成门户统一已办")
public class PushNshfDoneDataCmd extends AbstractCommandProxy<Map<String, Object>> {
    @Override
    public Map<String, Object> execute(Command<Map<String, Object>> targetCommand) {
        BaseBean bb = new BaseBean();
        RemarkSubmitCmd remarkSubmitCmd = (RemarkSubmitCmd) targetCommand;
        HttpServletRequest request = remarkSubmitCmd.getRequest();//从request中可以取到参数，不用以前的方法了
        //执行标准的业务处理
        Map<String, Object> result = nextExecute(targetCommand);
        RequestOperationResultBean resultBean = (RequestOperationResultBean) result.get("data");
        String executeResult = resultBean.getType().name();

        if("SUCCESS".equals(executeResult)){
            //创建线程处理已办数据推送
            WeaverRequest weaverRequest = new WeaverRequest(request);
            PushDataThread pushDataThread = new PushDataThread(weaverRequest);
            WFAutoApproveThreadPoolUtil.getFixedThreadPool().execute(pushDataThread);
        }

        return result;
    }


}
