日期:2014-05-20  浏览次数:20670 次

求助,有关ServletActionContext.getServletContext().getAttribute
现方法
Java code
public String initRegInfoMain() throws Exception {
        user = (User) this.getLoginUser();
        Dict dict = (Dict) ServletActionContext.getServletContext()
                .getAttribute(SysConstants.APPLICATION_DICT_12315);

        // 以下为设置各类下拉菜单
        this.setYesOrNoList(dict.getChildDict(Constants.CODETYPE_YESORNO, null)
                .getChildList());
        this.setInfoOriList(dict.getChildDict(Constants.CODETYPE_XXLY, null)
                .getChildList());
        this.setIncFormList(dict.getChildDict(Constants.CODETYPE_JSFS, null)
                .getChildList());
        this.setInfoTypeList(dict.getChildDict(Constants.CODETYPE_XXLB, null)
                .getChildList());

        this.setUnitProList(registerService.getUnitProList(user));
        this.setSexList(dict.getChildDict(Constants.CODETYPE_XB, null)
                .getChildList());
        this.setPerTypeList(dict.getChildDict(Constants.CODETYPE_RYLB, null)
                .getChildList());
        this.setPerIdeList(dict.getChildDict(Constants.CODETYPE_RYSF, null)
                .getChildList());
        this.setCerTypeList(dict.getChildDict(Constants.CODETYPE_ZJLX, null)
                .getChildList());

        this.setConSecOccTypeList(dict.getChildDict(Constants.CODETYPE_ZXWTLB,
                null).getChildList());
        this.setAffiDegList(dict.getChildDict(Constants.CODETYPE_QRCD, null)
                .getChildList());
        this.setPerInjTypeList(dict.getChildDict(Constants.CODETYPE_RSSHLX,
                null).getChildList());
        this.setPerInjAffiDegList(dict.getChildDict(Constants.CODETYPE_QRCD,
                null).getChildList());
        this.setUrgencyList(dict.getChildDict(Constants.CODETYPE_SJJB, null)
                .getChildList());
        this.setConlQuTypeList(dict.getChildDict(Constants.CODETYPE_ZXWTLB,
                null).getChildList());
        this.setAgainReasonList(dict.getChildDict(Constants.CODETYPE_ECSSHJBYY,
                null).getChildList());
        
        this.setMerImpSignList(dict.getChildDict(Constants.CODETYPE_JKBZ,
                null).getChildList()) ;
        

        // set各种必填项
        [color=#FF0000]HashMap map = (HashMap) ServletActionContext.getServletContext()
                .getAttribute(SysConstants.APPLICATION_REQUIREDITEM);[/color]
        this.setJbRequireItemList(map == null ? new HashMap() : map
                .get(Constants.DJ_REQUIREDITEM_JB) == null ? new HashMap()
                : (HashMap) map.get(Constants.DJ_REQUIREDITEM_JB));
        this.setZxRequireItemList(map == null ? new HashMap() : map
                .get(Constants.DJ_REQUIREDITEM_ZX) == null ? new HashMap()
                : (HashMap) map.get(Constants.DJ_REQUIREDITEM_ZX));
        this.setSsRequireItemList(map == null ? new HashMap() : map
                .get(Constants.DJ_REQUIREDITEM_SS) == null ? new HashMap()
                : (HashMap) map.get(Constants.DJ_REQUIREDITEM_SS));
        this.setJyRequireItemList(map == null ? new HashMap() : map
                .get(Constants.DJ_REQUIREDITEM_JY) == null ? new HashMap()
                : (HashMap) map.get(Constants.DJ_REQUIREDITEM_JY));
        this.setJjRequireItemList(map == null ? new HashMap() : map
                .get(Constants.DJ_REQUIREDITEM_JJ) == null ? new HashMap()
                : (HashMap) map.get(Constants.DJ_REQUIREDITEM_JJ));
        this.setQtRequireItemList(map == null ? new HashMap() : map
                .get(Constants.DJ_REQUIREDITEM_QT) == null ? new HashMap()
                : (HashMap) map.get(Constants.DJ_REQUIREDITEM_QT));
        String id = getInfoId();

        if (registerService.notEmpty(id)) {
            regBean.getReg(id);
            this.setPermissions(registerService.validationPermissions(user,
                    regBean.getRegister()));
            if (regBean != null) {
                if (registerService.notEmpty(regBean.getRegister().getAccRegPer())) {// 用户
                    User u = userService.getUserById(regBean.getRegister().getAccRegId());// (User)

                    this.setAccRegPerName(u == null ? "" : u.getUsername());
                } else {
                    this.setAccRegPerName(user.getUsername());
                }
                
                //如果登记人等于空,表示进入的是外部投诉页面,此处需要将当前登录用户 设置为登记人
                if(null == regBean.getRegister().getAccRegId()){
                    regBean.getRegister().setAccRegId(user.getId());
                    regBean.getRegister().setAccRegPer(user.getUsercode());
                }
                

                if (registerService.notEmpty(regBean.getRegister().getRegDepId())) {// 部门

                    Department12315 d = department12315Service
                            .getDepartment12315ById(regBean.getRegister().getRegDepId());// (Department12315)

                    this.setRegDepName(d == null ? "" : d.getDepartmentName());
                } else {
                    Department12315 d = department12315Service
                            .getDepartmentByDeptCode(regBean.getRegister().getRegDep());

                    this.setRegDepName(d == null ? "" : d.getDepartmentName());

                }

                if (regBean.getRegister().getRegTime() != null) {// 登记时间
                    setRegTime(DateUtils.convertDateTimeToString(regBean
                            .getRegister().getRegTime()));
                    this.setDateCompare(DateUtils.convertDateToString(regBean
                            .getRegister().getRegTime()));
                } else {
                    setRegTime(DateUtils.convertDateTimeToString(DateUtils
                            .getCurrentDateTime()));
                    this.setDateCompare(DateUtils.convertDateTimeToString(DateUtils
                            .getCurrentDateTime()));
                }

                if (!registerService.notEmpty(regBean.getInfoType())) {// 如果信息类别为空,则默认为咨询
                    // regBean.setInfoType("3");
                }

                // set购买时间和争议事件
                if (regBean.getRegister().getPurDate() != null)
                    setPurDate(DateUtils.convertDateToString(regBean
                            .getRegister().getPurDate()));

                if (regBean.getRegister().getDamDate() != null)
                    setDamDate(DateUtils.convertDateToString(regBean
                            .getRegister().getDamDate()));
                // 设置事发时间
                if (regBean.getRegister().getAccTime() != null)
                    this.setAccTime(DateUtils.convertDateToString(regBean
                            .getRegister().getAccTime()));
                // 设置客体类别
                if (registerService.notEmpty(regBean.getObType()))
                    setObTypeText(CoreUtils.getDictname(
                            Constants.CODETYPE_KTLB, regBean.getObType()));
                // 设置行业
                if (registerService.notEmpty(regBean.getUbIndType()))
                    setUbIndTypeText(CoreUtils.getDictname(
                            Constants.CODETYPE_ZTLB, regBean.getUbIndType()));

                // 提供方类型
                if (registerService.notEmpty(regBean.getReveType()))
                    setReveTypeText(CoreUtils.getDictname(
                            Constants.CODETYPE_TGFLX, regBean.getReveType()));
                
                // 主体类型
                if (registerService.notEmpty(regBean.getInvoType()))
                    setInvoTypeText(CoreUtils.getDictname(
                            Constants.CODETYPE_TGFLX, regBean.getInvoType()));

                // 设置咨询基本问题
                if (registerService.notEmpty(regBean.getConlBasQue()))
                    setConlBasQueText(CoreUtils.getDictname(
                            Constants.CODETYPE_ZXJBWT, regBean.getConlBasQue()));
                // 设置咨询范围
                if (registerService.notEmpty(regBean.getConlRange()))
                    setConlRangeText(CoreUtils.getDictname(
                            Constants.CODETYPE_ZXFW, regBean.getConlRange()));
                // 设置咨询法规
                if (registerService.notEmpty(regBean.getConlLaw()))
                    setConlLawText(CoreUtils.getDictname(
                            Constants.CODETYPE_ZXFG, regBean.getConlLaw()));
                // 设置申投诉基本问题
                if (registerService.notEmpty(regBean.getApplBasQue()))
                    setApplBasQueText(CoreUtils.getDictname(
                            Constants.CODETYPE_SSJBJBWT, regBean
                                    .getApplBasQue()));
                
                //设置计量单位
                if(registerService.notEmpty(regBean.getMeaUnit())){
                    this.setMeaUnitText(CoreUtils.getDictname(
                            Constants.CODETYPE_JLDW, regBean.getMeaUnit()));
                }
                // 设置国籍
                if (registerService.notEmpty(regBean.getCitizenship())) {
                    setCitizenshipText(CoreUtils.getDictname(
                            Constants.CODETYPE_GJ, regBean
                                    .getCitizenship()));
                }
                // 设置事发行政区划,因为直接从dictService里面取了一次Dict,所以运行有点慢,后期需要修改
                // if (registerService.notEmpty(regBean.getAccSceDistrict())) {
                // Dict accSceDistrictDict = (Dict) dictService
                // .getConditionDictName(regBean.getAccSceDistrict())
                // .get(0);
                // accSceDistrictDict = accSceDistrictDict.getParent();
                //
                // this.setAccSceDistrictList(accSceDistrictDict
                // .getChildList());
                // }
                // 设置事发行政区划
                Unit12315 unit = user.getUnit12315();
                String level = unit.getUnitLevel().toString().trim();
                String unitCode = unit.getUnitCode().trim();
                if (level.equals("3")) {
                    unit = unitService.queryUnit12315(unit.getParentUnitId());
                } else if (level.equals("4")) {
                    unit = unitService.queryUnit12315(unitService
                            .queryUnit12315(unit.getParentUnitId())
                            .getParentUnitId());
                } else if (level.equals("2")) {
                    if (unitCode.equals("429021") || unitCode.equals("429004")
                            || unitCode.equals("429006")
                            || unitCode.equals("429005")) {
                        unit = unitService.queryUnit12315(unit
                                .getParentUnitId());
                    }
                }
                this.setAccSceDistrictList(dict.getChildDict(
                        Constants.CODETYPE_XZQH, unit.getUnitCode())
                        .getChildList());

            }
        }

        // registerService.initRegInfoMain(this);

        return "initRegInfoMain";
    }