|
|
|
@ -1,10 +1,43 @@ |
|
|
|
package com.qhclh.ytzh.work.CatchChicken; |
|
|
|
|
|
|
|
import android.support.v7.app.AlertDialog; |
|
|
|
import android.support.v7.widget.Toolbar; |
|
|
|
import android.view.KeyEvent; |
|
|
|
import android.view.LayoutInflater; |
|
|
|
import android.view.Menu; |
|
|
|
import android.view.MenuItem; |
|
|
|
import android.view.View; |
|
|
|
import android.view.ViewGroup; |
|
|
|
import android.view.inputmethod.EditorInfo; |
|
|
|
import android.widget.AdapterView; |
|
|
|
import android.widget.EditText; |
|
|
|
import android.widget.ListView; |
|
|
|
import android.widget.TextView; |
|
|
|
|
|
|
|
import com.qhclh.ytzh.R; |
|
|
|
import com.qhclh.ytzh.base.BaseActivity; |
|
|
|
import com.qhclh.ytzh.bean.BreedBean; |
|
|
|
import com.qhclh.ytzh.home.RpcUrl; |
|
|
|
import com.qhclh.ytzh.tasks.ViewOnClickTask; |
|
|
|
import com.qhclh.ytzh.ui.CalendarDialogFragment; |
|
|
|
import com.qhclh.ytzh.ui.RefreshLayout; |
|
|
|
import com.qhclh.ytzh.utils.DateTimeUtil; |
|
|
|
import com.qhclh.ytzh.work.carsmannage.FactryidBean; |
|
|
|
import com.qhclh.ytzh.work.carsmannage.TimeEvent; |
|
|
|
import com.qhclh.ytzh.work.carsmannage.UseridBean; |
|
|
|
import com.qhclh.ytzh.work.scan.BreedAdapter; |
|
|
|
|
|
|
|
import org.forks.jsonrpc.JsonRpcResult; |
|
|
|
import org.forks.jsonrpc.RpcFacade; |
|
|
|
import org.forks.jsonrpc.RpcObject; |
|
|
|
import org.greenrobot.eventbus.EventBus; |
|
|
|
import org.greenrobot.eventbus.Subscribe; |
|
|
|
import org.greenrobot.eventbus.ThreadMode; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
import butterknife.BindView; |
|
|
|
|
|
|
|
@ -12,11 +45,20 @@ import butterknife.BindView; |
|
|
|
* Created by 青花瓷 on 2018/5/8. |
|
|
|
*/ |
|
|
|
|
|
|
|
public class CCInfosActivity extends BaseActivity { |
|
|
|
public class CCInfosActivity extends BaseActivity implements CalendarDialogFragment.CalendarClickListener, RefreshLayout.OnLoadListener { |
|
|
|
@BindView(R.id.toolbar) |
|
|
|
Toolbar mToolbar; |
|
|
|
@BindView(R.id.rfl_cc) |
|
|
|
RefreshLayout rfl_cc; |
|
|
|
@BindView(R.id.lv_cc) |
|
|
|
ListView lv_cc; |
|
|
|
|
|
|
|
private List<CCInfosBean> list; |
|
|
|
private CCInfosAdapter adapter; |
|
|
|
private int page =0; |
|
|
|
private long userID; |
|
|
|
private long factryID; |
|
|
|
private long choseTime; |
|
|
|
@Override |
|
|
|
protected int setLayoutId() { |
|
|
|
return R.layout.act_catchchickeninfos; |
|
|
|
@ -24,16 +66,310 @@ public class CCInfosActivity extends BaseActivity { |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void initView() { |
|
|
|
|
|
|
|
if (!EventBus.getDefault().isRegistered(this)) { |
|
|
|
EventBus.getDefault().register(this); |
|
|
|
} |
|
|
|
initToolbar(mToolbar, "扫码记录", new View.OnClickListener() { |
|
|
|
@Override |
|
|
|
public void onClick(View view) { |
|
|
|
finish(); |
|
|
|
} |
|
|
|
}); |
|
|
|
rfl_cc.setEnabled(false); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void initData() { |
|
|
|
|
|
|
|
list = new ArrayList<>(); |
|
|
|
adapter = new CCInfosAdapter(this,list); |
|
|
|
lv_cc.setAdapter(adapter); |
|
|
|
page = 0; |
|
|
|
Query(userID,factryID,choseTime,0); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void initOper() { |
|
|
|
rfl_cc.setOnLoadListener(this); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public boolean onCreateOptionsMenu(Menu menu) { |
|
|
|
getMenuInflater().inflate(R.menu.screen, menu); |
|
|
|
menu.findItem(R.id.sc_time).setVisible(true); |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public boolean onOptionsItemSelected(MenuItem item) { |
|
|
|
switch (item.getItemId()) { |
|
|
|
case R.id.sc_time: |
|
|
|
new CalendarDialogFragment().show(getSupportFragmentManager(), "start"); |
|
|
|
break; |
|
|
|
case R.id.sc_driver: |
|
|
|
getDriver(""); |
|
|
|
break; |
|
|
|
case R.id.sc_factry: |
|
|
|
getFactry(""); |
|
|
|
break; |
|
|
|
} |
|
|
|
return super.onOptionsItemSelected(item); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void getDriver(final String s) { |
|
|
|
ViewOnClickTask driverTask = new ViewOnClickTask(this,"加载中...") { |
|
|
|
List<RpcObject> rpcobj; |
|
|
|
@Override |
|
|
|
protected void successUI() { |
|
|
|
int size = rpcobj.size(); |
|
|
|
farmnameList.clear(); |
|
|
|
farmidList.clear(); |
|
|
|
breedList.clear(); |
|
|
|
|
|
|
|
if("".equals(s)) { |
|
|
|
BreedBean first = new BreedBean(); |
|
|
|
first.setId(0); |
|
|
|
first.setName("全部"); |
|
|
|
breedList.add(first); |
|
|
|
} |
|
|
|
for (int i=0;i<size;i++){ |
|
|
|
farmnameList.add(rpcobj.get(i).getString("Item2")); |
|
|
|
farmidList.add(rpcobj.get(i).getString("Item1")); |
|
|
|
BreedBean breed = new BreedBean(); |
|
|
|
breed.setId(Long.parseLong(rpcobj.get(i).getString("Item1"))); |
|
|
|
breed.setName(rpcobj.get(i).getString("Item2")); |
|
|
|
breedList.add(breed); |
|
|
|
} |
|
|
|
showDialogB(0); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Object call() throws Exception { |
|
|
|
JsonRpcResult result = RpcFacade.rpcCall(RpcUrl.GetChoiceBoxWords,"B3ProduceUnitedInfos_司机",s,""); |
|
|
|
rpcobj = result.getRpcObjectList(RpcUrl.GetChoiceBoxWords_fanhui); |
|
|
|
return null; |
|
|
|
} |
|
|
|
}; |
|
|
|
driverTask.execute(); |
|
|
|
} |
|
|
|
|
|
|
|
private List<String> farmnameList = new ArrayList<>(); |
|
|
|
private List<String> farmidList= new ArrayList<>(); |
|
|
|
private List<BreedBean> breedList = new ArrayList<>(); |
|
|
|
private void getFactry(final String _breedname) { |
|
|
|
ViewOnClickTask farmTask = new ViewOnClickTask(this,"加载中...") { |
|
|
|
List<RpcObject> rpcobj; |
|
|
|
@Override |
|
|
|
protected void successUI() { |
|
|
|
int size = rpcobj.size(); |
|
|
|
farmnameList.clear(); |
|
|
|
farmidList.clear(); |
|
|
|
breedList.clear(); |
|
|
|
|
|
|
|
if ("".equals(_breedname)) { |
|
|
|
BreedBean first = new BreedBean(); |
|
|
|
first.setId(0); |
|
|
|
first.setName("全部"); |
|
|
|
breedList.add(first); |
|
|
|
} |
|
|
|
|
|
|
|
for (int i=0;i<size;i++){ |
|
|
|
farmnameList.add(rpcobj.get(i).getString("Item2")); |
|
|
|
farmidList.add(rpcobj.get(i).getString("Item1")); |
|
|
|
BreedBean breed = new BreedBean(); |
|
|
|
breed.setId(Long.parseLong(rpcobj.get(i).getString("Item1"))); |
|
|
|
breed.setName(rpcobj.get(i).getString("Item2")); |
|
|
|
breedList.add(breed); |
|
|
|
} |
|
|
|
showDialogB(1); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Object call() throws Exception { |
|
|
|
JsonRpcResult result = RpcFacade.rpcCall(RpcUrl.GetChoiceBoxWords,"B3ProduceUnitedInfos_养殖场",_breedname,""); |
|
|
|
rpcobj = result.getRpcObjectList(RpcUrl.GetChoiceBoxWords_fanhui); |
|
|
|
return null; |
|
|
|
} |
|
|
|
}; |
|
|
|
farmTask.execute(); |
|
|
|
} |
|
|
|
|
|
|
|
private EditText edit_search_breed; |
|
|
|
private String breedname; |
|
|
|
private AlertDialog alertDialog; |
|
|
|
private void showDialogB(final int which) { |
|
|
|
AlertDialog.Builder builder; |
|
|
|
LayoutInflater inflater = (LayoutInflater) CCInfosActivity.this.getSystemService(LAYOUT_INFLATER_SERVICE); |
|
|
|
View layout = inflater.inflate(R.layout.show_breed, (ViewGroup) findViewById(R.id.layout_view)); |
|
|
|
ListView myListView = (ListView) layout.findViewById(R.id.show_list_breed); |
|
|
|
edit_search_breed = (EditText) layout.findViewById(R.id.edit_search_breed); |
|
|
|
|
|
|
|
BreedAdapter adapter = new BreedAdapter(this,breedList); |
|
|
|
myListView.setAdapter(adapter); |
|
|
|
|
|
|
|
///< edittext搜索 |
|
|
|
edit_search_breed.setOnEditorActionListener(new TextView.OnEditorActionListener() { |
|
|
|
@Override |
|
|
|
public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) { |
|
|
|
if (i == EditorInfo.IME_ACTION_DONE || (keyEvent != null && keyEvent.getKeyCode() == KeyEvent.KEYCODE_ENTER)) { |
|
|
|
breedname = textView.getText().toString(); |
|
|
|
if (breedname.equals("")) { |
|
|
|
} |
|
|
|
if (which ==0){ |
|
|
|
getDriver(breedname); |
|
|
|
}else if (which == 1){ |
|
|
|
getFactry(breedname); |
|
|
|
} |
|
|
|
alertDialog.dismiss(); |
|
|
|
return true; |
|
|
|
} |
|
|
|
return false; |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
myListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { |
|
|
|
@Override |
|
|
|
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { |
|
|
|
if (which ==0){ |
|
|
|
EventBus.getDefault().post(new UseridBean(l)); |
|
|
|
}else if (which == 1){ |
|
|
|
EventBus.getDefault().post(new FactryidBean(l)); |
|
|
|
} |
|
|
|
|
|
|
|
alertDialog.dismiss(); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
builder = new AlertDialog.Builder(this); |
|
|
|
builder.setView(layout); |
|
|
|
alertDialog = builder.create(); |
|
|
|
alertDialog.show(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onStartCalendarClick(Date date) { |
|
|
|
EventBus.getDefault().post(new TimeEvent(date.getTime())); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onEndCalendarClick(Date date) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Subscribe(threadMode = ThreadMode.MAIN) |
|
|
|
public void onEvent(TimeEvent event){ |
|
|
|
choseTime = event.getTime(); |
|
|
|
page = 0; |
|
|
|
Query(userID,factryID,choseTime,0); |
|
|
|
} |
|
|
|
@Subscribe(threadMode = ThreadMode.MAIN) |
|
|
|
public void onEvent(UseridBean event){ |
|
|
|
userID = event.getId(); |
|
|
|
page = 0; |
|
|
|
Query(userID,factryID,choseTime,0); |
|
|
|
} |
|
|
|
@Subscribe(threadMode = ThreadMode.MAIN) |
|
|
|
public void onEvent(FactryidBean event){ |
|
|
|
factryID = event.getId(); |
|
|
|
page = 0; |
|
|
|
Query(userID,factryID,choseTime,0); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onDestroy() { |
|
|
|
super.onDestroy(); |
|
|
|
if (EventBus.getDefault().isRegistered(this)) { |
|
|
|
EventBus.getDefault().unregister(this); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onLoad() { |
|
|
|
rfl_cc.postDelayed(new Runnable() { |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
rfl_cc.setLoading(false); |
|
|
|
Query(userID,factryID,choseTime,1); |
|
|
|
} |
|
|
|
},1000); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void Query(final long userid,final long factryid,final long time,final int flag) { |
|
|
|
if (flag ==1){ |
|
|
|
page++; |
|
|
|
} |
|
|
|
ViewOnClickTask queryTask = new ViewOnClickTask(CCInfosActivity.this,"加载中...") { |
|
|
|
List<RpcObject> rpcObj; |
|
|
|
@Override |
|
|
|
protected void successUI() { |
|
|
|
if (flag != 1) { |
|
|
|
list.clear(); |
|
|
|
} |
|
|
|
for (int i=0;i<rpcObj.size();i++) { |
|
|
|
CCInfosBean ccInfosBean = new CCInfosBean(); |
|
|
|
if (rpcObj.get(i).getLong("ID")!=null) { |
|
|
|
ccInfosBean.setID(rpcObj.get(i).getLong("ID")); |
|
|
|
} |
|
|
|
if (rpcObj.get(i).getLong("Domain_ID")!=null) { |
|
|
|
ccInfosBean.setDomain_ID(rpcObj.get(i).getLong("Domain_ID")); |
|
|
|
} |
|
|
|
if (rpcObj.get(i).getString("Employee_Name")!=null){ |
|
|
|
ccInfosBean.setEmployee_Name(rpcObj.get(i).getString("Employee_Name")); |
|
|
|
} |
|
|
|
if (rpcObj.get(i).getString("BreedFactory_Name")!=null){ |
|
|
|
ccInfosBean.setBreedFactory_Name(rpcObj.get(i).getString("BreedFactory_Name")); |
|
|
|
} |
|
|
|
if (rpcObj.get(i).getString("Employee_HandPhone")!=null){ |
|
|
|
ccInfosBean.setEmployee_HandPhone(rpcObj.get(i).getString("Employee_HandPhone")); |
|
|
|
} |
|
|
|
if (rpcObj.get(i).getDate("Time")!=null){ |
|
|
|
ccInfosBean.setTime(DateTimeUtil.getYMD4(rpcObj.get(i).getDate("Time"))); |
|
|
|
} |
|
|
|
list.add(ccInfosBean); |
|
|
|
} |
|
|
|
|
|
|
|
adapter.notifyDataSetChanged(); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Object call() throws Exception { |
|
|
|
RpcObject queryObj = RpcObject.create(RpcUrl.ChickTransportLogRpc_canshu); |
|
|
|
queryObj.setInt("PageSize",10); |
|
|
|
queryObj.setInt("CurrentPageIndex",page); |
|
|
|
List<Object> select = queryObj.getList("Select"); |
|
|
|
select.add("ID"); |
|
|
|
select.add("Domain_ID"); |
|
|
|
select.add("Employee_Name"); |
|
|
|
select.add("BreedFactory_Name"); |
|
|
|
select.add("Employee_HandPhone"); |
|
|
|
select.add("Time"); |
|
|
|
|
|
|
|
Map<Object, Object> where = queryObj.getMap("Where"); |
|
|
|
if (userid != 0) { |
|
|
|
where.put("User_ID", userid); |
|
|
|
} |
|
|
|
if (factryid != 0) { |
|
|
|
where.put("BreedFactory_ID", factryid); |
|
|
|
} |
|
|
|
if (time != 0) { |
|
|
|
where.put("CreateTime", time / 1000); |
|
|
|
} |
|
|
|
|
|
|
|
List<Object> orderList = queryObj.getList("OrderBy"); |
|
|
|
RpcObject orderBy = RpcObject.create(RpcUrl.DayProductRpc_Query_order); |
|
|
|
orderBy.setString("Name", "CreateTime"); |
|
|
|
orderBy.setBoolean("Desc", true); |
|
|
|
orderList.add(orderBy); |
|
|
|
|
|
|
|
JsonRpcResult result = RpcFacade.rpcCall(RpcUrl.CatchChickenQuery,queryObj); |
|
|
|
rpcObj = result.getRpcObjectList(RpcUrl.CatchChickenInsert_fanhui); |
|
|
|
return null; |
|
|
|
} |
|
|
|
}; |
|
|
|
queryTask.execute(); |
|
|
|
} |
|
|
|
} |