/*
 * 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.HstJsonUtil;
import com.hst.framework.constants.AppServiceConstants;
import com.hst.framework.constants.WebConstants;
import com.hst.framework.util.HstToolsUtil;
import com.hst.taxService.action.TaxWxCommonAppAction;
import com.hst.taxService.domain.WxZhxxDomain;
import com.hst.taxService.service.TaxWxGzzListAppService;
import java.util.List;
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/taxWxGzzList", results={@Result(name="queryGzzList", type="json")})
public class TaxWxGzzListAppAction
extends ExtendAction {
    private static final long serialVersionUID = 1L;
    public static Log _logger = LogFactory.getLog(TaxWxCommonAppAction.class);
    private TaxCommonAppServiceDomain domain;

    public String queryGzzList() throws Exception {
        block10: {
            TaxCommonReturnDomain errorDomain;
            TaxCommonReturnDomain returnDomain;
            block9: {
                TaxWxGzzListAppService service = (TaxWxGzzListAppService)this.getService();
                new TaxCommonAppServiceDomain();
                returnDomain = new TaxCommonReturnDomain();
                errorDomain = null;
                this.getDomain();
                try {
                    List<WxZhxxDomain> zhxxList = service.queryZhxxList();
                    for (WxZhxxDomain zhxxDom : zhxxList) {
                        service.doSaveWxYhxx(zhxxDom);
                    }
                    service.doWxYhdygxCl();
                    returnDomain.setCode("00");
                }
                catch (Exception e) {
                    errorDomain = this.handleException(e);
                    e.printStackTrace();
                    this.handleServiceException(returnDomain, errorDomain.getCode(), errorDomain.getMess());
                    return "queryGzzList";
                }
                if (!AppServiceConstants.TAX_APP_SUCCESS.equals(returnDomain.getCode())) break block9;
                try {
                    this.domain.setRetJson(HstJsonUtil.beanToJson(returnDomain));
                    break block10;
                }
                catch (Exception exception) {
                    this.handleException(returnDomain, AppServiceConstants.TAX_BEAN_TO_JSON_ERROR);
                    return "queryGzzList";
                }
            }
            try {
                this.handleServiceException(returnDomain, returnDomain.getCode(), returnDomain.getMess());
                return "queryGzzList";
            }
            catch (Exception e) {
                errorDomain = this.handleException(e);
                this.handleException(returnDomain, errorDomain.getCode(), errorDomain.getMess());
            }
        }
        return "queryGzzList";
    }

    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="taxWxGzzListAppServiceImp")
    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;
    }
}
