<bean id="testManager" class="zyl.TestManager"></bean> 

package zyl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.junit.Before;
import org.junit.Test;

import com.enation.eop.resource.model.EopSite;
import com.enation.eop.sdk.context.EopContext;
import com.enation.framework.test.SpringTestSupport;
import com.enation.seveneast.model.ExamTypeDetail;
import com.enation.seveneast.model.PaperLog;
import com.enation.seveneast.model.Question;
import com.enation.seveneast.service.IExamTypeDetailManager;
import com.enation.seveneast.service.IPaperTeacherManager;

/**
 * 订单测试
 * 
 * @author zyl 2010-4-6下午05:04:30
 */
public class zylTest extends SpringTestSupport {

	private String sessionid = "AC95B4420D5CE0C61BC98F99E6700B74";
	private TestManager testManager;
	@Before
	public void mock() {

		testManager = this.getBean("testManager");

		EopSite site = new EopSite();
		site.setUserid(2);
		site.setId(2);
		EopContext context = new EopContext();
		context.setCurrentSite(site);
		EopContext.setContext(context);

	}

	@Test
	public void test() {
	this.testManager.test(1);
	}

	public TestManager getTestManager() {
		return testManager;
	}

	public void setTestManager(TestManager testManager) {
		this.testManager = testManager;
	}

}





package zyl;

import java.util.List;
import java.util.Map;

import zyl.Test.Regions;

import com.enation.eop.sdk.database.BaseSupport;
import com.enation.seveneast.model.EclassTeacher;
import com.enation.seveneast.model.EclassTeacherOther;
import com.enation.seveneast.service.IEclassTeacherotherManager;

public class TestManager extends BaseSupport{









	public List test(int catid) {
		try {


//		String sql="select * from es_teacherinfo where cat_id="+catid;
//		List list = this.daoSupport.queryForList(sql);
	String sql =	
		"SELECT "+
		"es_regions.region_id,     "+
		"es_regions.p_region_id,   "+
		"es_regions.region_path,   "+
		"es_regions.region_grade,  "+
		"es_regions.local_name,    "+
		"es_regions.code,          "+
		"es_regions.fullspell,     "+
		"es_regions.thinspell,     "+
		"es_regions.attrid,        "+
		"es_regions.disabled,      "+
		"es_regions.officdocid     "+
		"FROM                      "+
		"bj ,                      "+
		"es_regions                "+
		"WHERE                     "+
		"bj.code =  es_regions.code";

	List<Map> list = this.daoSupport.queryForList(sql);
	int id =6225;//5994;//3815;//3521;



		for(Map p:list){
			String grade=p.get("region_grade").toString();	
		if(Integer.parseInt(grade.trim())==3){
			String sql1="select * from bj  where code like '"+p.get("code")+"%'";
			List<Map> rList=this.daoSupport.queryForList(sql1);
		Map temp=null;	
			for(Map r:rList){
				int code1=Integer.parseInt(r.get("code").toString());
				int code=Integer.parseInt(p.get("code").toString());
				boolean b =code1==code;
				System.out.println(b+"  "+r.get("code")+":"+p.get("code"));
				if(code1==code){
					temp=r;
					System.out.println("list1.remove "+r.toString());
				}else{
					System.out.println("pre id:"+id);
					id++;
					System.out.println("this id:"+id);
					if(id==9997){
						id=9999;
						//Exception e = new Exception("超出9998");
						//e.printStackTrace();
						//return null;
					} 
					if(id==9998){
						id=9999;
					}
					String regions_attr_sql=
							"SELECT                      "+
							"es_regions_attr.id          "+
							"FROM                        "+
							"es_regions_attr             "+
							"WHERE                       "+
							"es_regions_attr.name =  '"+r.get("attrid")+"' ";
					System.out.println("regions_attr_sql"+regions_attr_sql);
					Map m =this.daoSupport.queryForMap(regions_attr_sql);

					String region_path=p.get("region_path").toString()+id;
					String pid=p.get("region_id").toString();
String sql2="INSERT INTO `es_regions` " +
"(`region_id`,`p_region_id`,`region_path`,`region_grade`,`local_name`,`code`,`fullspell`,`thinspell`,`attrid`,`disabled`,`officdocid`) " +
"VALUES ("+id+","+pid+",'"+region_path+",',4,'"+r.get("local_name")+"',"+r.get("code")+",'','',"+m.get("id")+",0,0);";

				System.out.println(sql2);	

					this.daoSupport.execute(sql2);
				}
				System.out.println(r.toString());
			}
			rList.remove(temp);
			}
		}
		} catch (Exception ex) {
			ex.printStackTrace();
			// TODO: handle exception
		}
		return null;
	}



}