1. 功能介绍

    批量操作数据

  2. 代码片段

    1. HTML写法(参考quickstart/web/examples/basic/VipcustList.html)

      < jwcid="@wade:PageRedirect"
      value="删除"
      desc="VIP客户资料"
      class="e_bLinkDelete"
      onclick="if (!queryBox(this, 'vips')) return false;pageSubmit(this, 'deleteVipcusts')"/>
      
    2. JAVA(BEAN)写法(参考quickstart/src/doc/../examples/basic/ExamplesBean.java)

      1. 批量新增

        /**
         * 批量创建VIP客户资料
         * @param pd
         * @param dataset
         * @throws Exception
         */
        public void createVipcusts(PageData pd, IDataset dataset) throws Exception {
        	ExamplesDAO dao = new ExamplesDAO(pd);
        	
        	for (int i=0; i<dataset.size(); i++) {
        		IData data = (IData) dataset.get(i);
        		data.put("USER_ID", data.get("USECUST_ID"));
        		data.put("CUST_ID", data.get("USECUST_ID"));
        		data.put("CUST_NAME", data.get("USECUST_NAME"));
        		data.put("VIP_ID", dao.getSequence("SEQ_VIP_ID"));
        		data.put("REMOVE_TAG", ExampleFactory.VIP_REMOVETAG_VALID);
        		data.put("NET_TYPE_CODE", ExampleFactory.VIP_NETTYPE_DEFAULT);
        		data.put("IN_STAFF_ID", pd.getContext().getStaffId());
        		data.put("IN_DEPART_ID", pd.getContext().getDeptId());
        		data.put("CITY_CODE", pd.getContext().getCityId());
        		data.put("EPARCHY_CODE", pd.getContext().getEpachyId());
        		data.put("JOIN_DATE", common.getSysTime());
        		data.put("IN_DATE", common.getSysTime());
        	}
        	dao.insert("TF_F_CUST_VIP", dataset);	//批量插入资料集到表
        }
        
      2. 通用批量删除

        /**
         * 批量删除VIP客户资料
         * @param pd
         * @param vips
         * @throws Exception
         */
        public void deleteVipcusts(PageData pd, String[] vips) throws Exception {
        	ExamplesDAO dao = new ExamplesDAO(pd);
        	
        	IDataset dataset = new DatasetList();
        	for (int i=0; i<vips.length; i++) {
        		IData data = new DataMap();
        		data.put("VIP_ID", vips[i]);
        		dataset.add(data);
        	}
        	
        	dao.delete("TF_F_CUST_VIP", dataset);	//批量删除结果集
        }
        
      3. 自定义批量操作

        /**
        * 批量执行数据(用户通用的insert,update,delete批量无法完成的情况)
        * @param eparchy_code
        * @return IDataset
        * @throws Exception
        */
        public void batchUpdateVipcusts(IData param) throws Exception {
        //获取数组数据
        String[] vip_ids = common.getValues(param.get("VIP_ID"));
        String[] cust_names = common.getValues(param.get("CUST_NAME"));
        String[] cust_types = common.getValues(param.get("CUST_TYPE"));
        	
        String sql = "update TF_F_VIP_CUST set CUST_NAME = ? and CUST_TYPE = ? where VIP_ID = ?";
        	Parameter[] params = new Parameter[vip_ids.length];
        	for (int i=0; i<params.length; i++) {
        		//构造绑定对象,按顺序绑定参数值
        		params[i] = new Parameter();
        		params[i].add(cust_names[i]);
        		params[i].add(cust_types[i]);
        		params[i].add(vip_ids[i]);
        	}
        	
        	//批量执行
        	executeBatch(sql, params);
        }