package com.jqyd.son; import java.util.ArrayList; import java.util.HashMap; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.AdapterView; import android.widget.ListView; import android.widget.AdapterView.OnItemClickListener; import com.jqyd.adapter.MyAdapter; import com.jqyd.app.MyApp; import com.jqyd.app.VirtualData; import com.jqyd.manager.R; import com.jqyd.model.CustomerModule; import com.jqyd.model.EmpsModule; import com.jqyd.model.GroupsModule; import com.jqyd.model.ProTypeModule; import com.jqyd.shareInterface.Optdb_interfce; public class Fzcx extends Activity {//分组查询 private ListView fzLv; private MyAdapter adapter; private ArrayList<HashMap<String,String>> list = new ArrayList<HashMap<String,String>>(); private MyApp myApp; private Optdb_interfce db = null; private String groupNums = ""; private ArrayList<String> groupNumList = new ArrayList<String>(); private boolean flag_cust = false;//用来判断当前显示内容是员工、客户还是分组 private ArrayList<Bundle> listBundle = new ArrayList<Bundle>();//存放bundle,用于不同Activity之间进行跳转传参 protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.list); myApp = (MyApp) this.getApplication(); db = new Optdb_interfce(Fzcx.this); if(myApp.getModuleName().equals("kq") || myApp.getModuleName().equals("sczf") || myApp.getModuleName().equals("scjc") || myApp.getModuleName().equals("khtxl") || myApp.getModuleName().equals("echf")){ //list = VirtualData.getCustGroupInfo(); groupNums = myApp.getGroupNums(); if(groupNums.equals("")){ ArrayList<Object> li = db.searchFGroups("0",1);//取出一级分组编号 for(int i=0;i<li.size();i++){ HashMap<String,String> map = new HashMap<String,String>(); GroupsModule group = (GroupsModule) li.get(i); map.put("textView1", group.getGname()); list.add(map); groupNumList.add(group.getGid()+""); } }else{ ArrayList<Object> li = db.searchFGroups(groupNums,1);//逐级取出分组编号及分组名称 //判断分组下是否有客户存在,如果存在,则直接在当前界面显示出来,否则不显示 ArrayList<Object> custs = new ArrayList<Object>(); if(myApp.getModuleName().equals("echf") || myApp.getModuleName().equals("qzkhtxl")){ custs = db.searchCustsByMoreGps(groupNums,2); }else{ custs = db.searchCustsByMoreGps(groupNums,1); } groupNums = ""; //分组循环 for(int i=0;i<li.size();i++){ HashMap<String,String> map = new HashMap<String,String>(); GroupsModule group = (GroupsModule) li.get(i); map.put("textView1", group.getGname()); list.add(map); groupNumList.add(group.getGid()+""); } //客户循环 for(int j=0;j<custs.size();j++){ HashMap<String,String> map = new HashMap<String,String>(); Bundle bundle = new Bundle(); CustomerModule cust = (CustomerModule) custs.get(j); map.put("textView1", cust.getShort_name()); list.add(map); bundle.putString("cid", cust.getCid()); bundle.putString("cname", cust.getCname()); bundle.putString("linkman", cust.getLinkman()); bundle.putString("link_sim", cust.getLink_sim()); bundle.putString("address", cust.getAddress()); bundle.putString("lon", cust.getLon()); bundle.putString("lat", cust.getLat()); bundle.putString("clon", cust.getClon()); bundle.putString("clat", cust.getClat()); listBundle.add(bundle); flag_cust = true; } } }else if(myApp.getModuleName().equals("ygtxl")){ //list = VirtualData.getCustGroupInfo(); groupNums = myApp.getGroupNums(); if(groupNums.equals("")){ ArrayList<Object> li = db.searchFGroups("0",2);//取出一级分组编号 for(int i=0;i<li.size();i++){ HashMap<String,String> map = new HashMap<String,String>(); GroupsModule group = (GroupsModule) li.get(i); map.put("textView1", group.getGname()); list.add(map); groupNumList.add(group.getGid()+""); } }else{ System.out.println("分组编号:"+groupNums); ArrayList<Object> li = db.searchFGroups(groupNums,2);//逐级取出分组编号及分组名称 //判断分组下是否有员工存在,如果存在,则直接在当前界面显示出来,否则不显示 ArrayList<Object> emps = db.searchEmpsByMoreGps(groupNums); groupNums = ""; //分组循环 for(int i=0;i<li.size();i++){ HashMap<String,String> map = new HashMap<String,String>(); GroupsModule group = (GroupsModule) li.get(i); map.put("textView1", group.getGname()); list.add(map); groupNumList.add(group.getGid()+""); } System.out.println("员工数:"+emps.size()); //员工循环 for(int j=0;j<emps.size();j++){ HashMap<String,String> map = new HashMap<String,String>(); Bundle bundle = new Bundle(); EmpsModule emp = (EmpsModule) emps.get(j); System.out.println("员工姓名:"+emp.getXm()); map.put("textView1", emp.getXm()); list.add(map); bundle.putString("department", emp.getDepartment()); bundle.putString("dwhm", emp.getDwhm()); bundle.putString("honor", emp.getHonor()); bundle.putString("email", emp.getEmail()); bundle.putString("xm", emp.getXm()); listBundle.add(bundle); flag_cust = true; } System.out.println("是否有员工:"+flag_cust); } }else if(myApp.getModuleName().equals("xszs")){ //list = VirtualData.getCustGroupInfo(); groupNums = myApp.getGroupNums(); if(groupNums.equals("")){ ArrayList<Object> li = db.searchFGroups("0",3);//取出一级分组编号 for(int i=0;i<li.size();i++){ HashMap<String,String> map = new HashMap<String,String>(); GroupsModule group = (GroupsModule) li.get(i); map.put("textView1", group.getGname()); list.add(map); groupNumList.add(group.getGid()+""); } }else{ ArrayList<Object> li = db.searchFGroups(groupNums,3);//逐级取出分组编号及分组名称 //判断分组下是否有产品存在,如果存在,则直接在当前界面显示出来,否则不显示 ArrayList<Object> products = db.searchProsByMoreGps(groupNums); groupNums = ""; //分组循环 for(int i=0;i<li.size();i++){ HashMap<String,String> map = new HashMap<String,String>(); GroupsModule group = (GroupsModule) li.get(i); map.put("textView1", group.getGname()); list.add(map); groupNumList.add(group.getGid()+""); } //产品循环 for(int j=0;j<products.size();j++){ HashMap<String,String> map = new HashMap<String,String>(); Bundle bundle = new Bundle(); ProTypeModule product = (ProTypeModule) products.get(j); map.put("textView1", product.getName()); list.add(map); bundle.putString("p_name", product.getName()); bundle.putString("p_type", product.getModel()); bundle.putString("p_status", product.getStatus()); bundle.putString("p_unit", product.getUnit()); bundle.putString("p_cbj", product.getCbPrise()); bundle.putString("p_pbj", product.getPfPrise()); bundle.putString("p_lsj", product.getLsPrise()); bundle.putString("p_factory", product.getProducer()); bundle.putString("p_addr", product.getOrigin()); bundle.putString("p_bz", product.getDescription()); bundle.putString("p_sort", product.getType()); listBundle.add(bundle); flag_cust = true; } } }else if(myApp.getModuleName().equals("xssb")){ list = VirtualData.getCustGroupInfo(); }else if(myApp.getModuleName().equals("jpsb")){ list = VirtualData.getCustGroupInfo(); }else if(myApp.getModuleName().equals("kcsb")){ list = VirtualData.getCustGroupInfo(); } db.close_SqlDb(); fzLv=(ListView) findViewById(R.id.list); initData(); } private void initData() { adapter=new MyAdapter(list, this,-1); fzLv.setAdapter(adapter); fzLv.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // TODO Auto-generated method stub //startActivity(new Intent().setClass(Fzcx.this, SonList.class)); if(flag_cust){ if(myApp.getModuleName().equals("khtxl") || myApp.getModuleName().equals("ygtxl")){ Bundle bundle = listBundle.get(position); Intent intent =new Intent(); intent.putExtras(bundle); intent.setClass(Fzcx.this, LxrInfo.class); startActivity(intent); finish(); }else if(myApp.getModuleName().equals("kq")){ Bundle bundle = listBundle.get(position); Intent intent =new Intent(); intent.putExtras(bundle); intent.putExtra("point", 2); intent.setClass(Fzcx.this, Ddxq.class); startActivity(intent); finish(); }else if(myApp.getModuleName().equals("scjc")){ Bundle bundle = listBundle.get(position); Intent intent =new Intent(); intent.putExtras(bundle); intent.setClass(Fzcx.this, Scjc.class); startActivity(intent); finish(); }else if(myApp.getModuleName().equals("echf") || myApp.getModuleName().equals("sczf") ){ Bundle bundle = listBundle.get(position); Intent intent =new Intent(); intent.putExtras(bundle); intent.setClass(Fzcx.this, VisCust.class); startActivity(intent); finish(); }else if(myApp.getModuleName().equals("xszs")){ Bundle bundle = listBundle.get(position); Intent intent =new Intent(); intent.putExtras(bundle); intent.putExtra("moduleName", "xszs"); intent.setClass(Fzcx.this, Info.class); startActivity(intent); finish(); } }else{ String groupNum = groupNumList.get(position); myApp.setGroupNums(groupNum); startActivity(new Intent().setClass(Fzcx.this, Fzcx.class)); } } }); } }