/** 根据ID取得数据 */ public void findById() { this.setSiteName(""); String sql = "select s.productcode," + "(case s.productcode when 'all' then '首页面' when 'register' then '注册页面' when 'actIndex' then '宣传页面' when 'readIndex' then '阅读投保须知页面' else p.contplanname end) as contplanname," + " s.sitename,s.sitecode,s.sitetype," + "s.url," + "s.content,s.paymode " + "from ledadsource s, lepplan p " + "where s.productcode = p.contplancode(+)"; String sqlWhere = getSqlWhere(); sql += sqlWhere; ExeSQL tExeSQL = new ExeSQL(); SSRS tSSRS = new SSRS(); tSSRS = tExeSQL.execSQL(sql); int rows = tSSRS.getMaxRow(); if (rows > 0) { this.setProductCode(tSSRS.GetText(1, 1)); this.setContplanname(tSSRS.GetText(1, 2)); this.setSiteName(tSSRS.GetText(1, 3)); this.setSiteCode(tSSRS.GetText(1, 4)); this.setSiteType(tSSRS.GetText(1, 5)); this.setUrl(tSSRS.GetText(1, 6)); this.setContent(tSSRS.GetText(1, 7)); String paymodesCode = tSSRS.GetText(1, 8); String[] paymodeArr = paymodesCode.split("\\$"); if (paymodeArr != null && paymodeArr.length > 0) { StringBuffer payModeNameSQL = new StringBuffer("select codename from ledcode where codetype='paymode'"); payModeNameSQL.append(" and code in("); for (int j = 0, numbers = paymodeArr.length; j < numbers; j++) { payModeNameSQL.append("'"); payModeNameSQL.append(paymodeArr[j]); payModeNameSQL.append("'"); if (j < numbers - 1) payModeNameSQL.append(","); } payModeNameSQL.append(")"); tSSRS = tExeSQL.execSQL(payModeNameSQL.toString()); String paymodeName = ""; for (int k = 1, totalRows = tSSRS.MaxRow; k <= totalRows; k++) { paymodeName = paymodeName + tSSRS.GetText(k, 1) + " "; } this.setPayModeNames(paymodeName); } } else { this.setProductCode(""); this.setContplanname(""); this.setSiteName(""); this.setSiteCode(""); this.setSiteType(""); this.setUrl(""); this.setContent(""); this.setPayModeNames(""); } }
/** 取得所有广告来源URL */ public void find() { adList = new Vector<LEDAdSourceSchema>(); String sql = "select s.productcode," + "(case s.productcode when 'all' then '首页面' when 'register' then '注册页面' when 'actIndex' then '宣传页面' when 'readIndex' then '阅读投保须知页面' else p.contplanname end) as contplanname," + " s.sitename,s.sitecode,s.sitetype," + "s.url," + "s.content " + "from ledadsource s, lepplan p " + "where s.productcode = p.contplancode(+)"; String sqlWhere = getSqlWhere(); sql += sqlWhere; sql += " order by productcode"; ExeSQL tExeSQL = new ExeSQL(); SSRS tSSRS = new SSRS(); tSSRS = tExeSQL.execSQL(sql); for (int i = 1; i <= tSSRS.getMaxRow(); i++) { AdSourceMadel adSource = new AdSourceMadel(); adSource.setProductCode(tSSRS.GetText(i, 1)); adSource.setContplanname(tSSRS.GetText(i, 2)); adSource.setSiteName(tSSRS.GetText(i, 3)); adSource.setSiteCode(tSSRS.GetText(i, 4)); adSource.setSiteType(tSSRS.GetText(i, 5)); adSource.setUrl(tSSRS.GetText(i, 6)); adSource.setContent(tSSRS.GetText(i, 7)); adList.add(adSource); } }
public List<SelectItem> getProductCodeList() { if (this.productCodeList != null && this.productCodeList.size() > 0) { return this.productCodeList; } String sql = "select contplancode,contplanname from lepplan"; ExeSQL tExeSQL = new ExeSQL(); SSRS tSSRS = new SSRS(); tSSRS = tExeSQL.execSQL(sql); for (int i = 1; i <= tSSRS.getMaxRow(); i++) { productCodeList.add(new SelectItem(tSSRS.GetText(i, 1), tSSRS.GetText(i, 2))); } return this.productCodeList; }
/** * 检验网站缩写是否在数据库中存在 * * @param event */ public void checkSiteCode(ActionEvent event) { HtmlInputText inputText = (HtmlInputText) event.getComponent().findComponent("siteCode"); String siteCode = (String) inputText.getValue(); if (siteCode == null || "".equals(siteCode)) { this.setSiteType(""); return; } String sql = "select siteCode,siteType from ledadsource where siteCode='" + siteCode + "'"; ExeSQL tExeSQL = new ExeSQL(); SSRS tSSRS = new SSRS(); tSSRS = tExeSQL.execSQL(sql); int row = tSSRS.getMaxRow(); if (row > 0) { this.setSiteType(tSSRS.GetText(1, 2)); return; } this.setSiteType(""); }
/** 保存数据 */ public void save() { if (this.getSiteName() == null || "".equals(this.getSiteName())) { operateResult = "Fail|" + "网站名称不能为空!"; return; } if (this.getSiteCode() == null || "".equals(this.getSiteCode())) { operateResult = "Fail|" + "网站缩写不能为空!"; return; } if (this.getProductCode() == null || "".equals(this.getProductCode())) { operateResult = "Fail|" + "产品不能为空!"; return; } if (this.getSiteType() == null || "".equals(this.getSiteType())) { operateResult = "Fail|" + "网站类型不能为空!"; return; } if (this.payModelList == null || this.payModelList.length < 1) { operateResult = "Fail|" + "支付方式不能为空!"; return; } String type = ""; String sql = "select siteCode,siteType from ledadsource where siteCode='" + this.getSiteCode() + "'"; ExeSQL tExeSQL = new ExeSQL(); SSRS tSSRS = new SSRS(); tSSRS = tExeSQL.execSQL(sql); int row = tSSRS.getMaxRow(); if (row > 0) { type = tSSRS.GetText(1, 2); if (!this.getSiteType().equals(type)) { operateResult = "Fail|网站编码在数据库中已存在,输入的网站类型与存在的不一致!"; return; } } sql = "select siteCode from ledadsource where " + "siteCode='" + this.getSiteCode() + "' " + "and productcode='" + this.getProductCode() + "'"; tExeSQL = new ExeSQL(); tSSRS = new SSRS(); tSSRS = tExeSQL.execSQL(sql); row = tSSRS.getMaxRow(); if (row > 0) { operateResult = "Fail|" + "添加失败!该数据在数据库中已存在!"; return; } if ("all".equals(this.getProductCode())) { this.setVisitedPage("首页面"); } else if ("register".equals(this.getProductCode())) { this.setVisitedPage("注册页面"); } else if ("actIndex".equals(this.getProductCode())) { this.setVisitedPage("宣传页面"); } else if ("readIndex".equals(this.getProductCode())) { this.setVisitedPage("阅读投保须知页面"); } else { sql = "select contplanname from lepplan where contplancode='" + this.getProductCode() + "' and plantype='00'"; this.setVisitedPage(tExeSQL.getOneValue(sql)); } String siteUrl = "http://icare.metlife.com.cn/visit.jsf?source="; LisIDEA tLisIDEA = new LisIDEA(); siteUrl = siteUrl + tLisIDEA.encryptString(this.getSiteCode()); siteUrl = siteUrl + "&product=" + tLisIDEA.encryptString(this.getProductCode()); LEDAdSourceSchema tLEDAdSourceSchema = new LEDAdSourceSchema(); tLEDAdSourceSchema.setContent(this.getContent()); tLEDAdSourceSchema.setProductCode(this.getProductCode()); tLEDAdSourceSchema.setSiteCode(this.getSiteCode()); tLEDAdSourceSchema.setSiteName(this.getSiteName()); tLEDAdSourceSchema.setSiteType(this.getSiteType()); tLEDAdSourceSchema.setUrl(siteUrl); tLEDAdSourceSchema.setPayMode(this.getPayMode()); tLEDAdSourceSchema.setVisitedPage(this.getVisitedPage()); MMap map = new MMap(); map.put(tLEDAdSourceSchema, "INSERT"); PubSubmit tPubSubmit = new PubSubmit(); VData cVData = new VData(); cVData.add(map); if (!tPubSubmit.submitData(cVData, "")) { operateResult = "Fail|添加失败"; return; } else { operateResult = "Succ|添加成功"; initData(); find(); return; } }