2024-02-06 21:44:02 +08:00
|
|
|
|
package com.novelbook.android.Fragments;
|
|
|
|
|
|
|
|
|
|
import android.content.DialogInterface;
|
|
|
|
|
import android.support.v7.app.AlertDialog;
|
|
|
|
|
import android.text.TextUtils;
|
|
|
|
|
import android.util.Log;
|
|
|
|
|
import android.view.KeyEvent;
|
|
|
|
|
import android.view.View;
|
|
|
|
|
import android.widget.EditText;
|
|
|
|
|
import android.widget.LinearLayout;
|
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
|
|
|
|
import com.google.gson.Gson;
|
|
|
|
|
import com.google.gson.reflect.TypeToken;
|
|
|
|
|
import com.novelbook.android.BuildConfig;
|
|
|
|
|
import com.novelbook.android.Main2Activity;
|
|
|
|
|
import com.novelbook.android.MyApp;
|
|
|
|
|
import com.novelbook.android.R;
|
|
|
|
|
import com.novelbook.android.bean.StockOutPort;
|
|
|
|
|
import com.novelbook.android.netsubscribe.BookSubscribe;
|
|
|
|
|
import com.novelbook.android.netutils.HttpMethods;
|
|
|
|
|
import com.novelbook.android.netutils.OnSuccessAndFaultListener;
|
|
|
|
|
import com.novelbook.android.netutils.OnSuccessAndFaultSub;
|
|
|
|
|
import com.novelbook.android.utils.Constants;
|
|
|
|
|
import com.novelbook.android.utils.WmsUtil;
|
|
|
|
|
|
|
|
|
|
import org.json.JSONObject;
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.lang.reflect.Type;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
import butterknife.BindView;
|
|
|
|
|
import butterknife.OnClick;
|
|
|
|
|
import butterknife.OnEditorAction;
|
|
|
|
|
import okhttp3.Call;
|
|
|
|
|
import okhttp3.Callback;
|
|
|
|
|
import okhttp3.Request;
|
|
|
|
|
import okhttp3.Response;
|
|
|
|
|
import okhttp3.ResponseBody;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class StockOutPickOneByOne extends BasicFragment {
|
|
|
|
|
|
|
|
|
|
public static final String TAG = StockOutPickOneByOne.class.getSimpleName();
|
|
|
|
|
|
|
|
|
|
@BindView(R.id.edFlowNo)
|
|
|
|
|
EditText edFlowNo;
|
|
|
|
|
|
|
|
|
|
@BindView(R.id.edLoc)
|
|
|
|
|
EditText edLoc;
|
|
|
|
|
|
|
|
|
|
@BindView(R.id.edPickcnt)
|
|
|
|
|
EditText edPickcnt;
|
|
|
|
|
|
|
|
|
|
@BindView(R.id.locationId)
|
|
|
|
|
TextView tvLocationId;
|
|
|
|
|
@BindView(R.id.orderno)
|
|
|
|
|
TextView orderno;
|
|
|
|
|
@BindView(R.id.tvtranArea)
|
|
|
|
|
TextView tvTranArea;
|
|
|
|
|
@BindView(R.id.tvTranLoc)
|
|
|
|
|
TextView tvTranLoc;
|
|
|
|
|
@BindView(R.id.custom)
|
|
|
|
|
TextView custom;
|
|
|
|
|
@BindView(R.id.goodsName)
|
|
|
|
|
TextView goodsName ;
|
|
|
|
|
// @BindView(R.id.barcode)
|
|
|
|
|
// TextView tvBarcode;
|
|
|
|
|
|
|
|
|
|
// @BindView(R.id.manufacture)
|
|
|
|
|
// TextView manufacture;
|
|
|
|
|
@BindView(R.id.spec)
|
|
|
|
|
TextView spec;
|
|
|
|
|
@BindView(R.id.productDate)
|
|
|
|
|
TextView productDate;
|
|
|
|
|
@BindView(R.id.validDate)
|
|
|
|
|
TextView validDate;
|
|
|
|
|
@BindView(R.id.batch)
|
|
|
|
|
TextView batch;
|
|
|
|
|
@BindView(R.id.avCount)
|
|
|
|
|
TextView tvCount;
|
|
|
|
|
@BindView(R.id.unit)
|
|
|
|
|
TextView unit;
|
|
|
|
|
@BindView(R.id.tvPages)
|
|
|
|
|
TextView tvPages;
|
|
|
|
|
|
|
|
|
|
@BindView(R.id.packcnt)
|
|
|
|
|
TextView packcnt;
|
|
|
|
|
@BindView(R.id.tvMinOperationUnit)
|
|
|
|
|
TextView tvMinOperationUnit;
|
|
|
|
|
@BindView(R.id.tvMinOperationUnit2)
|
|
|
|
|
TextView tvMinOperationUnit2;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@BindView(R.id.btnLastPage)
|
|
|
|
|
TextView btnLastPage;
|
|
|
|
|
|
|
|
|
|
@BindView(R.id.btnNextPage)
|
|
|
|
|
TextView btnNextPage;
|
|
|
|
|
|
|
|
|
|
@BindView(R.id.btnConfirm)
|
|
|
|
|
TextView btnConfirm;
|
|
|
|
|
|
|
|
|
|
@BindView(R.id.lltaskId)
|
|
|
|
|
LinearLayout lltask;
|
|
|
|
|
|
|
|
|
|
@BindView(R.id.edTaskId)
|
|
|
|
|
EditText edTaskId;
|
|
|
|
|
|
|
|
|
|
@BindView(R.id.llbatch)
|
|
|
|
|
LinearLayout llbatch;
|
|
|
|
|
|
|
|
|
|
@BindView(R.id.llbulk)
|
|
|
|
|
LinearLayout llbulk;
|
|
|
|
|
|
|
|
|
|
@BindView(R.id.tvUnit2)
|
|
|
|
|
TextView tvUnit2;
|
|
|
|
|
|
|
|
|
|
@BindView(R.id.edBulkcnt)
|
|
|
|
|
EditText edBulk;
|
|
|
|
|
@BindView(R.id.tvVirtialCnt)
|
|
|
|
|
TextView tvVirtialCnt;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String taskId;
|
|
|
|
|
@OnEditorAction(R.id.edTaskId)
|
|
|
|
|
boolean taskIdIn(KeyEvent key){
|
|
|
|
|
if (!WmsUtil.isKeyEnterDown(key)) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
taskId = edTaskId.getText().toString().trim().replaceAll("\\r|\\n","");
|
|
|
|
|
if(!TextUtils.isEmpty(taskId)){
|
|
|
|
|
failureMsg="";
|
|
|
|
|
isPickSuccess =false;
|
|
|
|
|
// resetInput();
|
|
|
|
|
doGetTaskDetail(taskId);
|
|
|
|
|
edTaskId.setText("");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String flowNo, lastCustomerId="",lastJobNo="";
|
|
|
|
|
|
|
|
|
|
boolean isPickSuccess;
|
|
|
|
|
|
|
|
|
|
private int currentPage;
|
|
|
|
|
|
|
|
|
|
private List< StockOutPort> mListOutTasks = new ArrayList<>();
|
|
|
|
|
@Override
|
|
|
|
|
protected void initDebugData() {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected int getLayoutRes() {
|
|
|
|
|
return R.layout.fragment_stock_out_pick_one_by_one;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void initData() {
|
|
|
|
|
btnLastPage.setEnabled(false);
|
|
|
|
|
btnNextPage.setEnabled(false);
|
|
|
|
|
btnConfirm.setEnabled(false);
|
|
|
|
|
edTaskId.setEnabled( MyApp.user.hasSpecialAuth("按下架任务编号获取任务"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void fillData11() {
|
|
|
|
|
// setInfo( failureMsg);
|
|
|
|
|
goNexPage();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
protected void fillData() {
|
|
|
|
|
if(TextUtils.isEmpty((failureMsg)))
|
|
|
|
|
setInfo( failureMsg);
|
|
|
|
|
|
|
|
|
|
fillTaskDetail();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
isPickSuccess = failureMsg!=null && failureMsg.equals(("成功"));
|
|
|
|
|
if(isPickSuccess){
|
|
|
|
|
|
|
|
|
|
// resetInput();
|
|
|
|
|
// edLoc.setText("");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// flowNo=locCode=taskId="";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void resetInput() {
|
|
|
|
|
// mStockOutPort = new StockOutPort();
|
|
|
|
|
fillTaskDetail();
|
|
|
|
|
// mStockOutPort=null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void initViews() {
|
|
|
|
|
// title="出库下架";
|
|
|
|
|
///edLoc.requestFocus();
|
|
|
|
|
|
|
|
|
|
if(!TextUtils.isEmpty(flowNo)){
|
|
|
|
|
edFlowNo.setText(flowNo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public StockOutPickOneByOne() {
|
|
|
|
|
// Required empty public constructor
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void processArguments() {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private StockOutPort mStockOutPort(){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
btnLastPage.setEnabled(currentPage>0);
|
|
|
|
|
btnNextPage.setEnabled(currentPage+1<mListOutTasks.size());
|
|
|
|
|
if(mListOutTasks.size()==0){
|
|
|
|
|
btnNextPage.setEnabled((!TextUtils.isEmpty((lastJobNo))));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( mListOutTasks .size()==0){
|
|
|
|
|
return new StockOutPort();
|
|
|
|
|
}
|
|
|
|
|
currentPage=currentPage<0?0:currentPage;
|
|
|
|
|
currentPage=currentPage>= mListOutTasks .size()?mListOutTasks.size()-1:currentPage;
|
|
|
|
|
return mListOutTasks.get(currentPage);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
public static StockOutPickOneByOne newInstance() {
|
|
|
|
|
StockOutPickOneByOne fragment = new StockOutPickOneByOne();
|
|
|
|
|
return fragment;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void fillTaskDetail() {
|
|
|
|
|
|
|
|
|
|
llbulk.setVisibility(View.VISIBLE);
|
|
|
|
|
llbatch.setVisibility(View.VISIBLE);
|
|
|
|
|
if(mListOutTasks.size()==0){
|
|
|
|
|
|
|
|
|
|
// return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tvUnit2.setText(mStockOutPort().getUnit());
|
|
|
|
|
|
|
|
|
|
tvLocationId.setText(mStockOutPort().getLocationId());
|
|
|
|
|
orderno.setText(mStockOutPort().getPickOrderNo());
|
|
|
|
|
custom.setText(mStockOutPort().getCustomerName());
|
|
|
|
|
goodsName.setText( mStockOutPort().getGoodsId().length()>0? mStockOutPort().getGoodsName() + " | " + mStockOutPort().getGoodsId():"");
|
|
|
|
|
// tvBarcode.setText(mStockOutPort().getBarCode());
|
|
|
|
|
// manufacture.setText(mStockOutPort().getManufacturer());
|
|
|
|
|
spec.setText(mStockOutPort().getSpec());
|
|
|
|
|
productDate.setText(mStockOutPort().getProductDate());
|
|
|
|
|
validDate.setText(mStockOutPort().getValidDate());
|
|
|
|
|
batch.setText(mStockOutPort().getBatch());
|
2024-03-06 20:44:57 +08:00
|
|
|
|
tvCount.setText(mStockOutPort().getPcs()==0?mStockOutPort().getCount()+"" : mStockOutPort().getPcs()+"");
|
2024-03-29 16:35:54 +08:00
|
|
|
|
tvCount.setText( mStockOutPort().getCount() +"");
|
|
|
|
|
|
2024-02-06 21:44:02 +08:00
|
|
|
|
unit.setText(mStockOutPort().getUnit());
|
|
|
|
|
//packcnt.setText( mStockOutPort().getPcs() +"");
|
|
|
|
|
packcnt.setText( mStockOutPort().getMinOperateCount() +"");
|
|
|
|
|
// tvTranArea.setText(mStockOutPort().getTranAreaName());
|
|
|
|
|
tvTranArea.setText(mStockOutPort().getTranAreaName() + " " + mStockOutPort().getTranLocationId());
|
2024-03-29 16:35:54 +08:00
|
|
|
|
// tvMinOperationUnit.setText(mStockOutPort().getPickUnit() );
|
|
|
|
|
tvMinOperationUnit.setText(mStockOutPort().getUnit() );
|
2024-02-06 21:44:02 +08:00
|
|
|
|
tvMinOperationUnit2.setText(mStockOutPort().getPickUnit() );
|
|
|
|
|
edTaskId.setText(mStockOutPort().getId());
|
|
|
|
|
//edLoc.setEnabled(mStockOutPort().getPickState()== Enums.enumPickState.未拣);
|
|
|
|
|
tvVirtialCnt.setText(mStockOutPort().getVirtialCnt()+"");
|
|
|
|
|
edLoc.setHint(mStockOutPort().getLocationId());;
|
|
|
|
|
edPickcnt.setText( "0");
|
|
|
|
|
edBulk.setText("0");
|
|
|
|
|
// edPickcnt.setEnabled(false);
|
|
|
|
|
btnConfirm.setEnabled(false);
|
|
|
|
|
tvPages.setText( "/" );
|
|
|
|
|
if( !TextUtils.isEmpty(mStockOutPort().getId()) )
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
2024-03-29 16:35:54 +08:00
|
|
|
|
|
|
|
|
|
boolean isweight =isWeighUnit(mStockOutPort().getPickUnit());
|
2024-02-06 21:44:02 +08:00
|
|
|
|
int pcs = mStockOutPort().getPcs()*100;
|
|
|
|
|
float minO =mStockOutPort().getMinOperateCount()*100;
|
|
|
|
|
float r = (pcs*minO)/10000;
|
|
|
|
|
float cnt = mStockOutPort().getCount();
|
|
|
|
|
float bulk= cnt -r;
|
|
|
|
|
|
2024-03-29 16:35:54 +08:00
|
|
|
|
if (isweight) {
|
|
|
|
|
llbatch.setVisibility(View.GONE);
|
|
|
|
|
llbulk.setVisibility(View.VISIBLE);
|
|
|
|
|
|
|
|
|
|
edBulk.setText(mStockOutPort().getCount()+"") ;
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
|
|
edPickcnt.setText(mStockOutPort().getPcs()+""); //
|
|
|
|
|
|
|
|
|
|
edBulk.setText( bulk+"") ;
|
|
|
|
|
// edPickcnt.setText(r+"");
|
|
|
|
|
if(r>0){
|
|
|
|
|
|
|
|
|
|
llbatch.setVisibility(View.VISIBLE);
|
|
|
|
|
}else{
|
|
|
|
|
llbatch.setVisibility(View.GONE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(bulk>0){
|
|
|
|
|
llbulk.setVisibility(View.VISIBLE);
|
|
|
|
|
}else{
|
|
|
|
|
llbulk.setVisibility(View.GONE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
llbatch.setVisibility(View.GONE);
|
|
|
|
|
boolean isweight =isWeighUnit(mStockOutPort().getUnit());
|
2024-02-06 21:44:02 +08:00
|
|
|
|
|
|
|
|
|
if(!mStockOutPort().getUnit().equalsIgnoreCase(mStockOutPort().getPickUnit())){
|
|
|
|
|
|
|
|
|
|
llbulk.setVisibility(isweight ?View.GONE:View.VISIBLE);//库存单位称重,不显示零数部分
|
|
|
|
|
|
|
|
|
|
}else if(isweight){ //分拣单位和库存单位都是 斤
|
|
|
|
|
llbatch.setVisibility(View.GONE);
|
|
|
|
|
}else{ //分拣单位和库存单位一致,且不为斤
|
|
|
|
|
llbulk.setVisibility(View.GONE);
|
|
|
|
|
}
|
2024-03-29 16:35:54 +08:00
|
|
|
|
*/
|
|
|
|
|
|
2024-02-06 21:44:02 +08:00
|
|
|
|
|
|
|
|
|
if(!lastCustomerId.equalsIgnoreCase( mStockOutPort().getCustomerId())){
|
|
|
|
|
edFlowNo.setText("");
|
|
|
|
|
lastCustomerId= mStockOutPort().getCustomerId();
|
|
|
|
|
}
|
|
|
|
|
edLoc.setText("");
|
|
|
|
|
// edLoc.setEnabled(true);
|
|
|
|
|
|
|
|
|
|
if( !TextUtils.isEmpty( mStockOutPort().getCustomerId() ) &&connectBlueWeight(edBulk,mStockOutPort().getPickUnit(),edFlowNo) ){
|
2024-03-29 16:35:54 +08:00
|
|
|
|
// edPickcnt.setText("0");
|
|
|
|
|
edBulk.setText(mStockOutPort().getCount()+"");
|
2024-02-06 21:44:02 +08:00
|
|
|
|
edLoc.setText(mStockOutPort().getLocationId()); //货位分蔬菜。。
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// edLoc.setEnabled(false);
|
|
|
|
|
// edPickcnt.setEnabled(false);
|
|
|
|
|
}else if(TextUtils.isEmpty( mStockOutPort().getCustomerId() ) ) {
|
|
|
|
|
// connectBlueWeight(null,mStockOutPort().getPickUnit(),edFlowNo); //判断连接还是断开蓝牙
|
|
|
|
|
edPickcnt.setEnabled(true); //后台验证数量,无特殊权限不可提交修改数量
|
|
|
|
|
edFlowNo.setEnabled(true);
|
|
|
|
|
if(edFlowNo.getText().toString().startsWith("W")){
|
|
|
|
|
edFlowNo.setText("");
|
|
|
|
|
}
|
|
|
|
|
// edPickcnt.setText(mStockOutPort().getCount()+"");
|
|
|
|
|
|
2024-03-29 16:35:54 +08:00
|
|
|
|
/*
|
2024-02-06 21:44:02 +08:00
|
|
|
|
if(mStockOutPort().getPcs()>0) {
|
|
|
|
|
llbatch.setVisibility(View.VISIBLE);
|
|
|
|
|
if (bulk == 0) {
|
|
|
|
|
if (mStockOutPort().getPickUnit().equalsIgnoreCase(mStockOutPort().getUnit())) {
|
|
|
|
|
llbulk.setVisibility(View.GONE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-03-29 16:35:54 +08:00
|
|
|
|
*/
|
2024-02-06 21:44:02 +08:00
|
|
|
|
|
|
|
|
|
if(bulk>0){
|
|
|
|
|
llbulk.setVisibility(View.VISIBLE);
|
|
|
|
|
if(mStockOutPort().getPcs()==0){
|
|
|
|
|
if(mStockOutPort().getPickUnit().equalsIgnoreCase(mStockOutPort().getUnit())){
|
|
|
|
|
llbatch.setVisibility(View.GONE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
btnConfirm.setEnabled(true);
|
|
|
|
|
lastJobNo = mStockOutPort().getJobNo();
|
|
|
|
|
tvPages.setText(currentPage+1 +"/" +mListOutTasks.size());
|
|
|
|
|
|
|
|
|
|
if(BuildConfig.DEBUG) {
|
|
|
|
|
edLoc.setText(mStockOutPort().getLocationId());
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
if(mStockOutPort().getUnit().equalsIgnoreCase(mStockOutPort().getPickUnit())){
|
|
|
|
|
if (edBulk.getText().toString().equals("0")) {
|
|
|
|
|
edBulk.setText(mStockOutPort().getCount() + "");
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
if (edPickcnt.getText().toString().equals("0")) {
|
|
|
|
|
edPickcnt.setText(mStockOutPort().getPcs() + "");
|
|
|
|
|
}
|
|
|
|
|
if (edBulk.getText().toString().equals("0")) {
|
|
|
|
|
edBulk.setText(mStockOutPort().getCount() + "");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
if (edFlowNo.getText().length() == 0) {
|
|
|
|
|
edFlowNo.setText(mStockOutPort().getPickOrderNo());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
edLoc.requestFocus();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void doGetTaskDetail(String taskId) {
|
|
|
|
|
setInfo("");
|
|
|
|
|
|
|
|
|
|
BookSubscribe.getPickDetail(taskId ,true,
|
|
|
|
|
new OnSuccessAndFaultSub(new OnSuccessAndFaultListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(String result) {
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
StockOutPort mStockOutPort = null;
|
|
|
|
|
Gson gson = new Gson();
|
|
|
|
|
List< StockOutPort> lst = new ArrayList<StockOutPort>();
|
|
|
|
|
Type type = new TypeToken<ArrayList<StockOutPort>>(){}.getType();
|
|
|
|
|
lst =(List<StockOutPort>) gson.fromJson(result,type);
|
|
|
|
|
if(lst.size()==0){
|
|
|
|
|
failureMsg= "任务不存在";
|
|
|
|
|
handler.sendEmptyMessage(2);
|
|
|
|
|
|
|
|
|
|
}else
|
|
|
|
|
for (StockOutPort obj: lst
|
|
|
|
|
) {
|
|
|
|
|
mStockOutPort =obj;
|
|
|
|
|
mListOutTasks.add(currentPage,mStockOutPort);
|
|
|
|
|
handler.sendEmptyMessage(1);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Log.d(TAG,"get StockOutPort succeed, port goods name is " +mStockOutPort().getGoodsName() );
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
Log.e(TAG, "onSuccess: 解析失败", e);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
Log.d(TAG, "progress: progress to hide");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(JSONObject jsonObject) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public void onFault(String errorMsg) {
|
|
|
|
|
//tvIp.setText("failure");
|
|
|
|
|
//失败
|
|
|
|
|
Log.e(TAG, "error on get firstpage: " + errorMsg);
|
|
|
|
|
failureMsg =errorMsg;
|
|
|
|
|
handler.sendEmptyMessage(2);
|
|
|
|
|
}
|
|
|
|
|
}, this.getActivity(),true));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String locationId;
|
|
|
|
|
@OnEditorAction(R.id.edLoc)
|
|
|
|
|
boolean locationIn(KeyEvent key){
|
|
|
|
|
if (!WmsUtil.isKeyEnterDown(key)) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
locationId = edLoc.getText().toString().trim().replaceAll("\\r|\\n","");
|
|
|
|
|
if(locationId.length()<10 ){
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setInfo("");
|
|
|
|
|
|
|
|
|
|
if(!TextUtils.isEmpty(locationId)){
|
|
|
|
|
|
|
|
|
|
edLoc.selectAll();
|
|
|
|
|
// editLoc.requestFocus();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(locationId.contains(":999")) { //to print
|
|
|
|
|
|
|
|
|
|
String url = "http://%s/DNlight/printOutTaskCode?userId=%s&orderType=%s";
|
|
|
|
|
url = String.format(url, locationId, MyApp.user.getID(), 0);
|
|
|
|
|
doPrintTasks(url);
|
|
|
|
|
edLoc.setText("");
|
|
|
|
|
return false;
|
|
|
|
|
} else if(mListOutTasks.size()==0){ // to get new tasks
|
|
|
|
|
assingeOutTasks();
|
|
|
|
|
return false;
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
|
|
beforeFinishTask();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void assingeOutTasks() {
|
|
|
|
|
Map<String,String> map = new HashMap<>();
|
|
|
|
|
//string lastJobNo, string locationId,int warehouse
|
|
|
|
|
|
|
|
|
|
if(TextUtils.isEmpty(locationId)){
|
|
|
|
|
locationId=mStockOutPort().getLocationId();
|
|
|
|
|
}
|
|
|
|
|
if(TextUtils.isEmpty(locationId)){
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
map.put("lastJobNo",lastJobNo);
|
|
|
|
|
map.put("locationId",locationId);
|
|
|
|
|
BookSubscribe.taskAssignByLocation(map,
|
|
|
|
|
new OnSuccessAndFaultSub(new OnSuccessAndFaultListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(String result) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(JSONObject jsonObject) {
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
Type type = new TypeToken<ArrayList<StockOutPort>>(){}.getType();
|
|
|
|
|
mListOutTasks =(List<StockOutPort>) gson.fromJson(jsonObject.getString("Data"),type);
|
|
|
|
|
// if(lst.size()>0){
|
|
|
|
|
// taskItem = lst.get(0);
|
|
|
|
|
// }
|
|
|
|
|
currentPage=0;
|
|
|
|
|
Log.d(TAG,"return result out task size: " + mListOutTasks.size());
|
|
|
|
|
handler.sendEmptyMessage(1);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
Log.e(TAG, "onSuccess: 解析失败", e);
|
|
|
|
|
}
|
|
|
|
|
Log.d(TAG, "progress: progress to hide");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public void onFault(String errorMsg) {
|
|
|
|
|
//tvIp.setText("failure");
|
|
|
|
|
//失败
|
|
|
|
|
Log.e(TAG, "error on get : " + errorMsg);
|
|
|
|
|
failureMsg =errorMsg;
|
|
|
|
|
handler.sendEmptyMessage(2);
|
|
|
|
|
}
|
|
|
|
|
}, this.getActivity(),true));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void getAssignedOutTasks() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BookSubscribe.getTaskAssigned(MyApp.user.getID(),locationId,0,0,
|
|
|
|
|
false,0,0,-1,
|
|
|
|
|
new OnSuccessAndFaultSub(new OnSuccessAndFaultListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(String result) {
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
Log.d(TAG,"get result is " + result);
|
|
|
|
|
|
|
|
|
|
Gson gson = new Gson();
|
|
|
|
|
|
|
|
|
|
Type type = new TypeToken<ArrayList<StockOutPort>>(){}.getType();
|
|
|
|
|
mListOutTasks =(List<StockOutPort>) gson.fromJson(result,type);
|
|
|
|
|
currentPage=0;
|
|
|
|
|
Log.d(TAG, "mListOutTasks size " + mListOutTasks.size());
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
Log.e(TAG, "onSuccess: 解析失败", e);
|
|
|
|
|
}
|
|
|
|
|
Log.d(TAG, "progress: progress to hide");
|
|
|
|
|
handler.sendEmptyMessage(1);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(JSONObject jsonObject) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public void onFault(String errorMsg) {
|
|
|
|
|
//tvIp.setText("failure");
|
|
|
|
|
//失败
|
|
|
|
|
Log.e(TAG, "error on get firstpage: " + errorMsg);
|
|
|
|
|
failureMsg =errorMsg;
|
|
|
|
|
handler.sendEmptyMessage(2);
|
|
|
|
|
}
|
|
|
|
|
}, this.getActivity(),true));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void beforeFinishTask() {
|
|
|
|
|
if(TextUtils.isEmpty(mStockOutPort().getId())){
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
locationId = edLoc.getText().toString().trim().replaceAll("\\r|\\n","");
|
|
|
|
|
if (!locationId.equalsIgnoreCase(mStockOutPort().getLocationId())) {
|
|
|
|
|
|
|
|
|
|
if(locationId.length()>3 && !locationId.substring(0,2).equalsIgnoreCase(mStockOutPort().getLocationId().substring(0,2))){ //货区不同
|
|
|
|
|
assingeOutTasks();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
edLoc.selectAll();
|
|
|
|
|
setInfo("下架请扫描货位条码 " + mStockOutPort().getLocationId());
|
|
|
|
|
edLoc.requestFocus();
|
|
|
|
|
return ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// btnConfirm.setEnabled(false);
|
|
|
|
|
isPickSuccess =false;
|
|
|
|
|
failureMsg="";
|
|
|
|
|
//string flowNo, string waveNo, string pickOrderNo, int id, decimal pickCount
|
|
|
|
|
|
|
|
|
|
flowNo = edFlowNo.getText().toString().trim().replaceAll("\\r|\\n","");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float cnt =0f;
|
|
|
|
|
try{
|
|
|
|
|
cnt= Float.valueOf(edPickcnt.getText().toString())
|
|
|
|
|
*mStockOutPort().getMinOperateCount()*100/100
|
|
|
|
|
+ Float.valueOf(edBulk.getText().toString()) ;
|
|
|
|
|
if(cnt<0){
|
|
|
|
|
throw new Exception();
|
|
|
|
|
}
|
|
|
|
|
}catch (Exception er){
|
|
|
|
|
|
|
|
|
|
showMessageOnUiThread(activity,"请输入正确的数量");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(cnt>0 && TextUtils.isEmpty(flowNo)){
|
|
|
|
|
setInfo("请输入容器号");
|
|
|
|
|
edFlowNo.requestFocus();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Map<String,String> map = new HashMap<>();
|
|
|
|
|
map.put("flowNo",flowNo);
|
|
|
|
|
map.put("waveNo","");
|
|
|
|
|
map.put("pickOrderNo",mStockOutPort().getPickOrderNo());
|
|
|
|
|
map.put("id",mStockOutPort().getId());
|
|
|
|
|
// map.put("pickCount",mStockOutPort().getCount());
|
|
|
|
|
map.put("pickCount",cnt+"");
|
|
|
|
|
|
|
|
|
|
float reqCnt =mStockOutPort().getCount();
|
|
|
|
|
float diff =Math.abs(cnt - reqCnt);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float pct =Math.abs(cnt - mStockOutPort().getCount()) *100 / mStockOutPort().getCount();
|
|
|
|
|
pct =diff*100 / reqCnt;
|
|
|
|
|
|
|
|
|
|
// if(cnt != mStockOutPort().getCount()){
|
|
|
|
|
if(pct > Constants.allowPercent){
|
|
|
|
|
new AlertDialog.Builder(getActivity())
|
|
|
|
|
.setTitle("提示")
|
|
|
|
|
.setMessage("拣货数量异常,是否确定下架?")
|
|
|
|
|
.setNegativeButton("取消", new DialogInterface.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
|
dialog.dismiss();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.setPositiveButton("下架", new DialogInterface.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
|
doFinishTask(map);
|
|
|
|
|
}
|
|
|
|
|
}).setCancelable(true).show();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
doFinishTask(map);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
void doFinishTask( Map<String,String> map ){
|
|
|
|
|
|
|
|
|
|
btnConfirm.setEnabled(false);
|
|
|
|
|
locationId = mStockOutPort().getLocationId();
|
|
|
|
|
|
|
|
|
|
BookSubscribe.finishPickItem(map,
|
|
|
|
|
new OnSuccessAndFaultSub(new OnSuccessAndFaultListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(String result) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(JSONObject jsonObject) {
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
failureMsg =jsonObject.getString("Data");
|
|
|
|
|
isPickSuccess = failureMsg!=null && failureMsg.equals(("成功"));
|
|
|
|
|
showMessageOnUiThread(getActivity(),failureMsg);
|
|
|
|
|
if(isPickSuccess ) {
|
|
|
|
|
if ( !TextUtils.isEmpty( mStockOutPort().getCustomerId() ) &&connectBlueWeight(edBulk, mStockOutPort().getPickUnit(),null)) {
|
|
|
|
|
Log.d(TAG, "to print ticket......................: ");
|
|
|
|
|
|
|
|
|
|
printToBlue(Integer.valueOf( mStockOutPort().getRecType())==12? mStockOutPort().getTranAreaName() : mStockOutPort().getCustomerName(), mStockOutPort().getGoodsName(),
|
|
|
|
|
map.get("pickCount") + mStockOutPort().getUnit(), flowNo,MyApp.user.getEm_name() + " " + getFormatedDate(),
|
|
|
|
|
flowNo);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List< StockOutPort> tmp = new ArrayList<>();
|
|
|
|
|
for (StockOutPort s: mListOutTasks ) {
|
|
|
|
|
if(s.getId() !=mStockOutPort().getId()){
|
|
|
|
|
tmp.add(s);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mListOutTasks = tmp;
|
|
|
|
|
|
|
|
|
|
// doGetTaskDetail(mStockOutPort().getId());
|
|
|
|
|
if(mListOutTasks.size()==0){
|
|
|
|
|
assingeOutTasks();
|
|
|
|
|
}else {
|
|
|
|
|
currentPage=0;
|
|
|
|
|
handler.sendEmptyMessage(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
handler.sendEmptyMessage(2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Log.d(TAG,"return result: " + failureMsg );
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
Log.e(TAG, "onSuccess: 解析失败", e);
|
|
|
|
|
}
|
|
|
|
|
// Log.d(TAG, "progress: progress to hide");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public void onFault(String errorMsg) {
|
|
|
|
|
//tvIp.setText("failure");
|
|
|
|
|
//失败
|
|
|
|
|
Log.e(TAG, "error on get firstpage: " + errorMsg);
|
|
|
|
|
failureMsg =errorMsg;
|
|
|
|
|
handler.sendEmptyMessage(2);
|
|
|
|
|
}
|
|
|
|
|
}, this.getActivity(),true));
|
|
|
|
|
|
|
|
|
|
btnConfirm.setEnabled(true);
|
|
|
|
|
}
|
|
|
|
|
void doPrintTasks(String url){
|
|
|
|
|
Request request = new Request.Builder()
|
|
|
|
|
.url(url).build();
|
|
|
|
|
|
|
|
|
|
showProgressDialog();
|
|
|
|
|
HttpMethods.getOkClient().newCall(request).enqueue(new Callback() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onFailure(Call call, IOException e) {
|
|
|
|
|
Log.d(TAG, " print out tasks onFailure(int, Header[],byte[], Throwable ) was received");
|
|
|
|
|
failureMsg="打印信息发送失败";
|
|
|
|
|
handler.sendEmptyMessage(2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onResponse(Call call, Response response) throws IOException {
|
|
|
|
|
if(response.code()!=200) {
|
|
|
|
|
Log.e(TAG, "print tasks onResponse:return code" +response.code() );
|
|
|
|
|
}
|
|
|
|
|
ResponseBody body = response.body();
|
|
|
|
|
final String result =body.string();
|
|
|
|
|
Log.e(TAG, "print tasks onResponse result: " + result);
|
|
|
|
|
try {
|
|
|
|
|
failureMsg="打印信息发送成功";
|
|
|
|
|
handler.sendEmptyMessage(12);
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
Log.e(TAG, "onResponse: ",e );
|
|
|
|
|
}finally {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void goLastPage() {
|
|
|
|
|
if(currentPage>0) {
|
|
|
|
|
currentPage--;
|
|
|
|
|
}
|
|
|
|
|
fillData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void goNexPage() {
|
|
|
|
|
Log.d(TAG,"currentPage " + currentPage );
|
|
|
|
|
Log.d(TAG,"mListOutTasks.size " + mListOutTasks.size() );
|
|
|
|
|
|
|
|
|
|
currentPage = currentPage >= mListOutTasks.size() ?mListOutTasks.size()-1:currentPage;
|
|
|
|
|
currentPage =currentPage<0?0:currentPage;
|
|
|
|
|
|
|
|
|
|
if(currentPage<mListOutTasks.size()-1) {
|
|
|
|
|
currentPage++;
|
|
|
|
|
fillData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
@OnClick({R.id.btnConfirm,R.id.btnNextPage,R.id.btnLastPage, R.id.btnGoSeeds})
|
|
|
|
|
void btnOnClick(View view) {
|
|
|
|
|
setInfo("");
|
|
|
|
|
switch (view.getId()) {
|
|
|
|
|
case R.id.btnConfirm:
|
|
|
|
|
beforeFinishTask();
|
|
|
|
|
break;
|
|
|
|
|
case R.id.btnNextPage:
|
|
|
|
|
goNexPage();
|
|
|
|
|
break;
|
|
|
|
|
case R.id.btnLastPage:
|
|
|
|
|
goLastPage();
|
|
|
|
|
break;
|
|
|
|
|
case R.id.btnGoSeeds:
|
|
|
|
|
goSeeds();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
// case R.id.btnBlueInput:
|
|
|
|
|
// ((Main2Activity)activity).connectScale(edSeedsBulkCnt);;
|
|
|
|
|
// break;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-06 20:44:57 +08:00
|
|
|
|
|
|
|
|
|
boolean canBack;
|
2024-02-06 21:44:02 +08:00
|
|
|
|
private void goSeeds() {
|
|
|
|
|
|
2024-03-06 20:44:57 +08:00
|
|
|
|
if(canBack) {
|
|
|
|
|
popBack();
|
|
|
|
|
}else{
|
|
|
|
|
( (Main2Activity)activity).showSeedsOut(edFlowNo.getText().toString(),false);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
canBack=!canBack;
|
2024-02-06 21:44:02 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onResume(){
|
|
|
|
|
super.onResume();
|
|
|
|
|
edFlowNo.setText(flowNo);
|
|
|
|
|
connectBlues();
|
|
|
|
|
getAssignedOutTasks();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setFlowNo(String flowNo) {
|
|
|
|
|
this.flowNo=flowNo;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|