package weaver.interfaces.htsc.capitalbusinessPayment;

import com.engine.htsc.capitalbusinessPayment.dao.OperateLiquidationDataDao;
import com.engine.htsc.convertor.EcologyValueConvertor;
import com.engine.htsc.doc.model.UserInfoModel;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.RequestInfo;
import weaver.workflow.request.RequestManager;


/**
 * 流程提交至出纳节点前操作Action
 * 保存数据至数据中心
 */
public class SaveToDataCenterAction extends BaseBean implements Action {

    @Override
    public String execute(RequestInfo requestInfo) {
        String requestId = Util.null2String(requestInfo.getRequestid());
        try {
            RequestManager requestManager = requestInfo.getRequestManager();
            UserInfoModel currentUser = EcologyValueConvertor.getUserInfoModelById(String.valueOf(requestManager.getUser().getUID()));
            OperateLiquidationDataDao dao = new OperateLiquidationDataDao();
            dao.saveToDC(requestId, currentUser);
        } catch (Exception e) {
            e.printStackTrace();
            writeLog("requestId:" + requestId + " 写入数据中心失败"+e);
            return Action.FAILURE_AND_CONTINUE;
        }
        return Action.SUCCESS;
    }

}
