/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  javax.annotation.Resource
 *  org.apache.commons.logging.Log
 *  org.apache.commons.logging.LogFactory
 *  org.apache.struts2.convention.annotation.Action
 *  org.apache.struts2.convention.annotation.Result
 *  org.springframework.context.annotation.Scope
 *  org.springframework.stereotype.Controller
 */
package com.hst.taxService.action;

import com.hst.common.action.ExtendAction;
import com.hst.common.domain.BaseAppServiceDomain;
import com.hst.common.domain.TaxCommonAppServiceDomain;
import com.hst.common.domain.TaxCommonReturnDomain;
import com.hst.common.service.BaseBusinessService;
import com.hst.common.util.DomainUtil;
import com.hst.common.util.HstJsonUtil;
import com.hst.framework.constants.AppServiceConstants;
import com.hst.framework.constants.WebConstants;
import com.hst.framework.util.HstToolsUtil;
import com.hst.taxService.service.TaxCtais2CommonAppService;
import javax.annotation.Resource;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

@Controller
@Scope(value="prototype")
@Action(value="/service/taxCtais2Common", results={@Result(name="doCtais2Service", type="json")})
public class TaxCtais2CommonAction
extends ExtendAction {
    private static final long serialVersionUID = 1L;
    public static Log _logger = LogFactory.getLog(TaxCtais2CommonAction.class);
    private TaxCommonAppServiceDomain domain;

    /*
     * Unable to fully structure code
     * Enabled aggressive block sorting
     * Enabled unnecessary exception pruning
     * Enabled aggressive exception aggregation
     */
    public String doCtais2Service() throws Exception {
        service = (TaxCtais2CommonAppService)this.getService();
        appDomain = null;
        returnDomain = null;
        errorDomain = null;
        ywId = this.getDomain().getYwId();
        returnDomain = DomainUtil.getDomain(ywId);
        try {
            appDomain = DomainUtil.getAppServiceDomain(ywId, this.getDomain().getParmJson());
            if (appDomain == null) {
                this.handleException(returnDomain, AppServiceConstants.TAX_JSONPARSE_ERROR);
                return "doCtais2Service";
            }
        }
        catch (Exception v0) {
            this.handleException(returnDomain, AppServiceConstants.TAX_JSONPARSE_ERROR);
            return "doCtais2Service";
        }
        try {
            if (AppServiceConstants.YWID_TAX_CTAIS2_FPPZJBXXCX.equals(ywId)) {
                returnDomain = service.queryFppzjbxxcx(appDomain, ywId);
            } else if (!AppServiceConstants.YWID_TAX_CTAIS2_FPJX.equals(ywId)) {
                if (AppServiceConstants.YWID_TAX_CTAIS2_FPYJ.equals(ywId)) {
                    returnDomain = service.queryFpyj(appDomain, ywId);
                } else if (!AppServiceConstants.YWID_TAX_CTAIS2_FPTP.equals(ywId)) {
                    if (AppServiceConstants.YWID_TAX_CTAIS2_FPLGBDY.equals(ywId)) {
                        returnDomain = service.queryFplgbdy(appDomain, ywId);
                    } else if (AppServiceConstants.YWID_TAX_CTAIS2_FPLGBDYHS.equals(ywId)) {
                        returnDomain = service.queryFplgbhs(appDomain, ywId);
                    } else if (AppServiceConstants.YWID_TAX_CTAIS2_NSRFPJC.equals(ywId)) {
                        returnDomain = service.queryNsrfpjc(appDomain, ywId);
                    } else if (AppServiceConstants.YWID_TAX_CTAIS2_NSRFPYJXX.equals(ywId)) {
                        returnDomain = service.queryNsrfpyjxx(appDomain, ywId);
                    } else if (AppServiceConstants.YWID_TAX_CTAIS2_FPFS_SAVE.equals(ywId)) {
                        returnDomain = service.queryFpxs(appDomain, ywId);
                    } else if (AppServiceConstants.YWID_TAX_CTAIS2_NSRFPLGXX.equals(ywId)) {
                        returnDomain = service.queryNsrFplgxx(appDomain, ywId);
                    } else if (AppServiceConstants.YWID_TAX_CTAIS2_FPFSKCXX.equals(ywId)) {
                        returnDomain = service.queryFpfskcxx(appDomain, ywId);
                    }
                }
            }
            if (returnDomain == null) {
                returnDomain = new TaxCommonReturnDomain();
                this.handleException(returnDomain, AppServiceConstants.TAX_APP_ERROR);
                return "doCtais2Service";
            }
            ** GOTO lbl57
        }
        catch (Exception e) {
            try {
                errorDomain = this.handleException(e);
                e.printStackTrace();
                this.handleServiceException(returnDomain, errorDomain.getCode(), errorDomain.getMess());
                return "doCtais2Service";
lbl57:
                // 1 sources

                if (!AppServiceConstants.TAX_APP_SUCCESS.equals(returnDomain.getCode())) {
                    this.handleServiceException(returnDomain, returnDomain.getCode(), returnDomain.getMess());
                    return "doCtais2Service";
                }
                try {
                    this.domain.setRetJson(HstJsonUtil.beanToJson(returnDomain));
                    return "doCtais2Service";
                }
                catch (Exception v1) {
                    this.handleException(returnDomain, AppServiceConstants.TAX_BEAN_TO_JSON_ERROR);
                    return "doCtais2Service";
                }
            }
            catch (Exception e) {
                errorDomain = this.handleException(e);
                this.handleException(returnDomain, errorDomain.getCode(), errorDomain.getMess());
            }
        }
        return "doCtais2Service";
    }

    public String commonHandle(BaseAppServiceDomain appDomain) throws Exception {
        return AppServiceConstants.TAX_APP_SUCCESS;
    }

    public void handleException(TaxCommonReturnDomain returnDomain, String code) throws Exception {
        if (returnDomain == null) {
            returnDomain = new TaxCommonReturnDomain();
        }
        returnDomain.setCode(code);
        String message = this.handleExceptionMessage(returnDomain.getCode());
        returnDomain.setMess(message);
        this.domain.setRetJson(HstJsonUtil.beanToJson(returnDomain));
        if (WebConstants.LOG_KZ_ERRORS.equals("Y")) {
            _logger.error((Object)message);
        }
    }

    public void handleException(TaxCommonReturnDomain returnDomain, String code, String error) throws Exception {
        if (returnDomain == null) {
            returnDomain = new TaxCommonReturnDomain();
        }
        returnDomain.setCode(code);
        String message = this.handleExceptionMessage(returnDomain.getCode());
        if (HstToolsUtil.isNullOrEmpty(error)) {
            returnDomain.setMess(message);
        } else {
            returnDomain.setMess(String.valueOf(message) + error);
        }
        this.domain.setRetJson(HstJsonUtil.beanToJson(returnDomain));
    }

    public void handleServiceException(TaxCommonReturnDomain returnDomain, String code, String error) throws Exception {
        returnDomain.setCode(code);
        String message = this.handleExceptionMessage(returnDomain.getCode());
        if (HstToolsUtil.isNullOrEmpty(error)) {
            returnDomain.setMess(message);
        } else {
            returnDomain.setMess(String.valueOf(message) + error);
        }
        this.domain.setRetJson(HstJsonUtil.beanToJson(returnDomain));
    }

    public String handleExceptionMessage(String code) throws Exception {
        String message = "";
        if (HstToolsUtil.isNullOrEmpty(code)) {
            return message;
        }
        message = AppServiceConstants.TAX_CODE_MESS_MAP.containsKey(code) ? AppServiceConstants.TAX_CODE_MESS_MAP.get(code) : (code.length() <= 2 ? "" : "\u672a\u5b9a\u4e49\u7684\u9519\u8bef\uff01");
        return message;
    }

    @Override
    @Resource(name="taxCtais2CommonAppServiceImp")
    public void setService(BaseBusinessService service) {
        super.setService(service);
    }

    @Override
    public TaxCommonAppServiceDomain getDomain() {
        if (this.domain == null) {
            this.domain = new TaxCommonAppServiceDomain();
        }
        return this.domain;
    }

    public void setDomain(TaxCommonAppServiceDomain domain) {
        this.domain = domain;
    }
}
