|
|
@ -5,14 +5,20 @@ import android.content.Intent; |
|
|
import android.support.annotation.NonNull; |
|
|
import android.support.annotation.NonNull; |
|
|
import android.support.v7.widget.Toolbar; |
|
|
import android.support.v7.widget.Toolbar; |
|
|
import android.view.View; |
|
|
import android.view.View; |
|
|
import android.widget.AdapterView; |
|
|
|
|
|
import android.widget.ListView; |
|
|
import android.widget.ListView; |
|
|
|
|
|
|
|
|
import com.google.zxing.integration.android.IntentIntegrator; |
|
|
import com.google.zxing.integration.android.IntentIntegrator; |
|
|
import com.google.zxing.integration.android.IntentResult; |
|
|
import com.google.zxing.integration.android.IntentResult; |
|
|
import com.qhclh.ytzh.R; |
|
|
import com.qhclh.ytzh.R; |
|
|
import com.qhclh.ytzh.base.BaseActivity; |
|
|
import com.qhclh.ytzh.base.BaseActivity; |
|
|
import com.qhclh.ytzh.bean.ScanBean; |
|
|
|
|
|
|
|
|
import com.qhclh.ytzh.bean.MaojiScanBean; |
|
|
|
|
|
import com.qhclh.ytzh.home.RpcUrl; |
|
|
|
|
|
import com.qhclh.ytzh.tasks.ViewOnClickTask; |
|
|
|
|
|
import com.qhclh.ytzh.utils.DateTimeUtil; |
|
|
|
|
|
|
|
|
|
|
|
import org.forks.jsonrpc.JsonRpcResult; |
|
|
|
|
|
import org.forks.jsonrpc.RpcFacade; |
|
|
|
|
|
import org.forks.jsonrpc.RpcObject; |
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
import java.util.ArrayList; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
@ -33,8 +39,8 @@ public class ScanResultActivity extends BaseActivity { |
|
|
private String scanStr = ""; |
|
|
private String scanStr = ""; |
|
|
private boolean scanf = false; |
|
|
private boolean scanf = false; |
|
|
|
|
|
|
|
|
private List<ScanBean> scanBeanList; |
|
|
|
|
|
private ScanAdapter scanAdapter; |
|
|
|
|
|
|
|
|
private List<MaojiScanBean> scanBeanList; |
|
|
|
|
|
private MaojiScanAdapter scanAdapter; |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
protected int setLayoutId() { |
|
|
protected int setLayoutId() { |
|
|
@ -65,10 +71,29 @@ public class ScanResultActivity extends BaseActivity { |
|
|
protected void onResume() { |
|
|
protected void onResume() { |
|
|
super.onResume(); |
|
|
super.onResume(); |
|
|
if (scanf == false) { |
|
|
if (scanf == false) { |
|
|
dongtaiQuanxian(); |
|
|
|
|
|
|
|
|
getactive(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private RpcObject rpcObj; |
|
|
|
|
|
private void getactive() { |
|
|
|
|
|
ViewOnClickTask getactiveTask = new ViewOnClickTask(this,"加载中...") { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
protected void successUI() { |
|
|
|
|
|
dongtaiQuanxian(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public Object call() throws Exception { |
|
|
|
|
|
JsonRpcResult result = RpcFacade.rpcCall(RpcUrl.ToFoodFactoryTransportLogRpc_getactive); |
|
|
|
|
|
rpcObj = result.getRpcObject(RpcUrl.ToFoodFactoryTransportLogRpc_fanhui); |
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
getactiveTask.execute(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final int REQUEST_PERMISSION_CAMERA_CODE = 102; |
|
|
private static final int REQUEST_PERMISSION_CAMERA_CODE = 102; |
|
|
|
|
|
|
|
|
@ -96,7 +121,17 @@ public class ScanResultActivity extends BaseActivity { |
|
|
// 设置要扫描的条码类型,ONE_D_CODE_TYPES:一维码,QR_CODE_TYPES-二维码 |
|
|
// 设置要扫描的条码类型,ONE_D_CODE_TYPES:一维码,QR_CODE_TYPES-二维码 |
|
|
integrator.setDesiredBarcodeFormats(IntentIntegrator.QR_CODE_TYPES); |
|
|
integrator.setDesiredBarcodeFormats(IntentIntegrator.QR_CODE_TYPES); |
|
|
integrator.setCaptureActivity(ScanActivity.class); |
|
|
integrator.setCaptureActivity(ScanActivity.class); |
|
|
integrator.setPrompt("请扫描"); //底部的提示文字,设为""可以置空 |
|
|
|
|
|
|
|
|
if (rpcObj == null) { |
|
|
|
|
|
integrator.setPrompt("进入养殖场请扫描"); //底部的提示文字,设为""可以置空 |
|
|
|
|
|
}else { |
|
|
|
|
|
if ("入养殖场".equals(rpcObj.getNamedValue("State").getName())) { |
|
|
|
|
|
integrator.setPrompt("离开养殖场请扫描"); |
|
|
|
|
|
}else if ("出养殖场".equals(rpcObj.getNamedValue("State").getName())) { |
|
|
|
|
|
integrator.setPrompt("到达食品厂请扫描"); |
|
|
|
|
|
}else if ("到食品厂".equals(rpcObj.getNamedValue("State").getName())) { |
|
|
|
|
|
integrator.setPrompt("到达挂鸡台请扫描"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
integrator.setCameraId(0); //前置或者后置摄像头 |
|
|
integrator.setCameraId(0); //前置或者后置摄像头 |
|
|
integrator.setBeepEnabled(false); //扫描成功的「哔哔」声,默认开启 |
|
|
integrator.setBeepEnabled(false); //扫描成功的「哔哔」声,默认开启 |
|
|
integrator.setBarcodeImageEnabled(true); |
|
|
integrator.setBarcodeImageEnabled(true); |
|
|
@ -113,16 +148,83 @@ public class ScanResultActivity extends BaseActivity { |
|
|
finish(); |
|
|
finish(); |
|
|
} else { |
|
|
} else { |
|
|
scanStr = result.getContents(); |
|
|
scanStr = result.getContents(); |
|
|
System.out.println("aaa++++++++"+scanStr); |
|
|
|
|
|
// for (int i=0;i<4;i++){ |
|
|
|
|
|
// scanBeanList.add(new ScanBean(i,"车牌号"+i,"司机"+i,"联系方式"+i,"批次"+i,"厂址"+i, |
|
|
|
|
|
// "时间"+i,"数量"+i,"免疫"+i,"均匀度"+i,"起始时间"+i,"到达时间"+i)); |
|
|
|
|
|
// } |
|
|
|
|
|
// scanAdapter = new ScanAdapter(this,scanBeanList); |
|
|
|
|
|
// lv_infos.setAdapter(scanAdapter); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (rpcObj == null) { |
|
|
|
|
|
EnterBreedFactory(); |
|
|
|
|
|
}else { |
|
|
|
|
|
if ("入养殖场".equals(rpcObj.getNamedValue("State").getName())) { |
|
|
|
|
|
LeaveBreedFactory(); |
|
|
|
|
|
}else if ("出养殖场".equals(rpcObj.getNamedValue("State").getName())) { |
|
|
|
|
|
ArriveFoodFactory(); |
|
|
|
|
|
}else if ("到食品厂".equals(rpcObj.getNamedValue("State").getName())) { |
|
|
|
|
|
ArriveUnloadingPoint(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
super.onActivityResult(requestCode, resultCode, data); |
|
|
super.onActivityResult(requestCode, resultCode, data); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void EnterBreedFactory() { |
|
|
|
|
|
ViewOnClickTask leaveTask = new ViewOnClickTask(this,"加载中...") { |
|
|
|
|
|
@Override |
|
|
|
|
|
protected void successUI() { |
|
|
|
|
|
MaojiScanBean scanBean = new MaojiScanBean(); |
|
|
|
|
|
scanBean.setId(rpcObj.getLong("ID")); |
|
|
|
|
|
scanBean.setInfos_carname(rpcObj.getString("Car_Name")); |
|
|
|
|
|
scanBean.setInfos_driver(rpcObj.getString("Employee_Name")); |
|
|
|
|
|
scanBean.setInfos_yangzhichang(rpcObj.getString("BreedFactory_Name")); |
|
|
|
|
|
scanBean.setShipingchang(rpcObj.getString("FoodFactory_Name")); |
|
|
|
|
|
if (rpcObj.getDate("InBreedFactoryTime")!=null) { |
|
|
|
|
|
scanBean.setDaodayangzhichang(DateTimeUtil.getYMD4(rpcObj.getDate("InBreedFactoryTime"))); |
|
|
|
|
|
}else { |
|
|
|
|
|
scanBean.setDaodayangzhichang(""); |
|
|
|
|
|
} |
|
|
|
|
|
if (rpcObj.getDate("OutBreedFactoryTime")!=null) { |
|
|
|
|
|
scanBean.setLikaiyangzhichang(DateTimeUtil.getYMD4(rpcObj.getDate("OutBreedFactoryTime"))); |
|
|
|
|
|
}else { |
|
|
|
|
|
scanBean.setLikaiyangzhichang(""); |
|
|
|
|
|
} |
|
|
|
|
|
if (rpcObj.getDate("ArriveFoodFactoryTime")!=null) { |
|
|
|
|
|
scanBean.setDaodashipingchang(DateTimeUtil.getYMD4(rpcObj.getDate("ArriveFoodFactoryTime"))); |
|
|
|
|
|
}else { |
|
|
|
|
|
scanBean.setDaodashipingchang(""); |
|
|
|
|
|
} |
|
|
|
|
|
if (rpcObj.getDate("ArriveUnloadingPointTime")!=null) { |
|
|
|
|
|
scanBean.setDaodaguajipingtai(DateTimeUtil.getYMD4(rpcObj.getDate("ArriveUnloadingPointTime"))); |
|
|
|
|
|
}else { |
|
|
|
|
|
scanBean.setDaodaguajipingtai(""); |
|
|
|
|
|
} |
|
|
|
|
|
if (rpcObj.getString("Employee_HandPhone")!=null) { |
|
|
|
|
|
scanBean.setInfos_phone(rpcObj.getString("Employee_HandPhone")); |
|
|
|
|
|
}else { |
|
|
|
|
|
scanBean.setInfos_phone(""); |
|
|
|
|
|
} |
|
|
|
|
|
scanBeanList.clear(); |
|
|
|
|
|
scanBeanList.add(scanBean); |
|
|
|
|
|
|
|
|
|
|
|
scanAdapter = new MaojiScanAdapter(ScanResultActivity.this,scanBeanList); |
|
|
|
|
|
lv_infos.setAdapter(scanAdapter); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public Object call() throws Exception { |
|
|
|
|
|
JsonRpcResult result = RpcFacade.rpcCall(RpcUrl.ToFoodFactoryTransportLogRpc_EnterBreedFactory,scanStr); |
|
|
|
|
|
rpcObj = result.getRpcObject(RpcUrl.ToFoodFactoryTransportLogRpc_fanhui); |
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
leaveTask.execute(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void LeaveBreedFactory() { |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void ArriveFoodFactory() { |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void ArriveUnloadingPoint() { |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |