ScanUnloadingActivity.java 29.6 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727
package com.lijinji.scan;

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.text.InputFilter;
import android.util.SparseArray;
import android.util.SparseBooleanArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;

import com.lijinji.scan.adapter.AbsCommonAdapter;
import com.lijinji.scan.adapter.AbsViewHolder;
import com.lijinji.scan.adapter.RefreshParams;
import com.lijinji.scan.bean.BarcodeDataBean;
import com.lijinji.scan.bean.BarcodeOrderBean;
import com.lijinji.scan.bean.MenuOperationBean;
import com.lijinji.scan.bean.ProductLineBean;
import com.lijinji.scan.bean.ProductLineOrderBean;
import com.lijinji.scan.bean.ReceivingBean;
import com.lijinji.scan.bean.ReceivingOrderBean;
import com.lijinji.scan.bean.TableModel;
import com.lijinji.scan.https.HttpInterface;
import com.lijinji.scan.https.Subscribers.ProgressSubscriber;
import com.lijinji.scan.https.Subscribers.SubscriberOnNextListener;
import com.lijinji.scan.product.InputFilterMinMax;
import com.lijinji.scan.util.CommonActivity;
import com.lijinji.scan.util.Constant;
import com.lijinji.scan.util.DataBaseHelpter;
import com.lijinji.scan.util.WMSUtils;
import com.lijinji.scan.widget.MyListView;
import com.lijinji.scan.widget.SyncHorizontalScrollView;
import com.lijinji.scan.widget.pullrefresh.AbPullToRefreshView;
import com.zbar.scan.ScanCaptureAct;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class ScanUnloadingActivity extends CommonActivity {

    @BindView(R.id.right_title_container)
    LinearLayout rightTitleContainer;
    @BindView(R.id.title_horsv)
    SyncHorizontalScrollView titleHorsv;
    @BindView(R.id.left_container_listview)
    MyListView leftContainerListview;
    @BindView(R.id.right_container_listview)
    MyListView rightContainerListview;
    @BindView(R.id.content_horsv)
    SyncHorizontalScrollView contentHorsv;
    @BindView(R.id.pull_refresh_scroll)
    ScrollView pullRefreshScroll;
    @BindView(R.id.pulltorefreshview)
    AbPullToRefreshView pulltorefreshview;
    @BindView(R.id.allPage)
    TextView allPage;
    @BindView(R.id.alterPage)
    TextView alterPage;
    @BindView(R.id.fromPage)
    TextView fromPage;
    @BindView(R.id.firstPage)
    TextView firstPage;
    @BindView(R.id.upPage)
    TextView upPage;
    @BindView(R.id.downPage)
    TextView downPage;
    @BindView(R.id.lastPage)
    TextView lastPage;
    @BindView(R.id.jumpPage)
    TextView jumpPage;
    @BindView(R.id.scanUnloadingBtn)
    Button scanUnloadingBtn;
    @BindView(R.id.removeUnloadingBtn)
    Button removeUnloadingBtn;
    private Context mContext;
    private int RESULT_CODE = 1;
    private AbsCommonAdapter<TableModel> mRightAdapter;
    private String result;
    private int pageNo = 1;
    private int pageSize = 10;
    private int mAlertPage = 1;
    private int CHECKS_LENGTH = 13;
    private int upPageNo = pageNo;
    private List<ReceivingBean> receivingBeans;
    private List<ReceivingBean> selectReceivingBeans = new ArrayList<>();
    private SparseArray<CheckBox> mCheckBoxArray;
    private String[] checkStr = new String[CHECKS_LENGTH];
    private boolean[] checks = new boolean[CHECKS_LENGTH];
    private List<String> checkArray = new ArrayList<>();

    @Override
    protected void initActivityOnCreate(Bundle savedInstanceState) {
        super.initActivityOnCreate(savedInstanceState);
        setContentView(R.layout.activity_scan_unloading);
        ButterKnife.bind(this);
        mContext = this;
        setTitle(this.getString(R.string.app_name));
        initView();
        getReceivingsByCondition(pageNo);
    }

    private void initView() {
        getLayoutInflater().inflate(R.layout.unloading_right_title, rightTitleContainer);
        // 设置两个水平控件的联动
        titleHorsv.setScrollView(contentHorsv);
        contentHorsv.setScrollView(titleHorsv);
        initTableView();
        pulltorefreshview.setPullRefreshEnable(false);
        pulltorefreshview.setLoadMoreEnable(false);
        checkPermission();
    }

    private void checkPermission() {
        List<View> viewList = new ArrayList<>();
        viewList.add(scanUnloadingBtn);
        viewList.add(removeUnloadingBtn);
        List<MenuOperationBean> menuOperations = DataBaseHelpter.queryAllMenuOperation();
        WMSUtils.checkPermission(menuOperations, viewList);
    }

    public void initTableView() {
        mRightAdapter = new AbsCommonAdapter<TableModel>(mContext, R.layout.unloading_right_item) {
            @Override
            public void convert(AbsViewHolder helper, TableModel item, final int pos) {
                TextView tv_table_content_right_item0 = helper.getView(R.id.tv_table_content_right_item0);
                TextView tv_table_content_right_item1 = helper.getView(R.id.tv_table_content_right_item1);
                TextView tv_table_content_right_item2 = helper.getView(R.id.tv_table_content_right_item2);
                TextView tv_table_content_right_item3 = helper.getView(R.id.tv_table_content_right_item3);
                TextView tv_table_content_right_item4 = helper.getView(R.id.tv_table_content_right_item4);
                TextView tv_table_content_right_item5 = helper.getView(R.id.tv_table_content_right_item5);
                TextView tv_table_content_right_item6 = helper.getView(R.id.tv_table_content_right_item6);
                TextView tv_table_content_right_item7 = helper.getView(R.id.tv_table_content_right_item7);
                TextView tv_table_content_right_item8 = helper.getView(R.id.tv_table_content_right_item8);
                TextView tv_table_content_right_item9 = helper.getView(R.id.tv_table_content_right_item9);
                TextView tv_table_content_right_item10 = helper.getView(R.id.tv_table_content_right_item10);
                TextView tv_table_content_right_item11 = helper.getView(R.id.tv_table_content_right_item11);
                TextView tv_table_content_right_item12 = helper.getView(R.id.tv_table_content_right_item12);
                TextView tv_table_content_right_item13 = helper.getView(R.id.tv_table_content_right_item13);
//                TextView tv_table_content_right_item14 = helper.getView(R.id.tv_table_content_right_item14);
                TextView tv_table_content_right_item15 = helper.getView(R.id.tv_table_content_right_item15);
                TextView tv_table_content_right_item16 = helper.getView(R.id.tv_table_content_right_item16);
//                TextView tv_table_content_right_item17 = helper.getView(R.id.tv_table_content_right_item17);
//                TextView tv_table_content_right_item18 = helper.getView(R.id.tv_table_content_right_item18);

                tv_table_content_right_item0.setText(item.getText0());
                tv_table_content_right_item1.setText(item.getText1());
                tv_table_content_right_item2.setText(item.getText2());
                tv_table_content_right_item3.setText(item.getText3());
                tv_table_content_right_item4.setText(item.getText4());
                tv_table_content_right_item5.setText(item.getText5());
                tv_table_content_right_item6.setText(item.getText6());
                tv_table_content_right_item7.setText(item.getText7());
                tv_table_content_right_item8.setText(item.getText8());
                tv_table_content_right_item9.setText(item.getText9());
                tv_table_content_right_item10.setText(item.getText10());
                tv_table_content_right_item11.setText(item.getText11());
                tv_table_content_right_item12.setText(item.getText12());
                tv_table_content_right_item13.setText(item.getText13());
//                tv_table_content_right_item14.setText(item.getText14());
                tv_table_content_right_item15.setText(item.getText15());
                tv_table_content_right_item16.setText(item.getText16());
//                tv_table_content_right_item17.setText(item.getText17());
//                tv_table_content_right_item18.setText(item.getText18());

                View view = helper.getConvertView();
                ReceivingBean receivingBean = receivingBeans.get(pos);
                if (isSelectReceivingBean(receivingBean)) {
                    view.setBackgroundColor(getResources().getColor(R.color.colorPrimary));
                } else {
                    view.setBackgroundColor(getResources().getColor(R.color.white));
                }
            }
        };
        rightContainerListview.setAdapter(mRightAdapter);
        rightContainerListview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
                setSelectReceivingBean(receivingBeans.get(position));
                mRightAdapter.notifyDataSetChanged();
            }
        });
    }

    private boolean enableBarcode() {
        if (selectReceivingBeans == null) {
            WMSUtils.showShort(mContext.getString(R.string.please_select_one_barcode));
            return false;
        }
        if (selectReceivingBeans.size() != 1) {
            WMSUtils.showShort(mContext.getString(R.string.please_select_one_barcode));
            return false;
        }
        return true;
    }

    private boolean setSelectReceivingBean(ReceivingBean receivingBean) {
        boolean contained = false;
        int index = 0;
        for (ReceivingBean receivingBean1 : selectReceivingBeans) {
            index++;
            if (receivingBean1.getId() == receivingBean.getId()) {
                contained = true;
                break;
            }
        }
        if (contained) {
            selectReceivingBeans.remove(index - 1);
            return false;
        }
        selectReceivingBeans.add(receivingBean);
        return true;
    }

    private boolean isSelectReceivingBean(ReceivingBean receivingBean) {
        boolean contained = false;
        for (ReceivingBean receivingBean1 : selectReceivingBeans) {
            if (receivingBean1.getId() == receivingBean.getId()) {
                contained = true;
                break;
            }
        }
        if (contained) {
            return true;
        }
        return false;
    }

    private void clearSelecttTaskBean() {
        selectReceivingBeans.removeAll(selectReceivingBeans);
        selectReceivingBeans = new ArrayList<>();
        mRightAdapter.clearData(true);
    }

    private void setData(List<ReceivingBean> receivingBeanList) {
        doGetDatas(0, RefreshParams.REFRESH_DATA, receivingBeanList);
    }

    //模拟网络请求
    public void doGetDatas(int pageno, int state, List<ReceivingBean> receivingBeanList) {
        if (state == RefreshParams.REFRESH_DATA) {
            pulltorefreshview.onHeaderRefreshFinish();
        } else {
            pulltorefreshview.onFooterLoadFinish();
        }
        setDatas(receivingBeanList, state);
    }

    private void setDatas(List<ReceivingBean> receivingBeanList, int type) {
        List<TableModel> mDatas = new ArrayList<>();
        for (ReceivingBean receivingBean : receivingBeanList) {
            TableModel tableMode = new TableModel();
            tableMode.setText0(String.valueOf(receivingBean.getId()));
            tableMode.setText1(receivingBean.getThisPackQty());
            tableMode.setText2(cutTime(receivingBean.getReciveDate()));
            tableMode.setText3(cutTime(receivingBean.getProductDate()));
            tableMode.setText4(cutTime(receivingBean.getValidityDate()));
            tableMode.setText5(receivingBean.getItemBarcode());
            tableMode.setText6(receivingBean.getItemCode());
            tableMode.setText7(receivingBean.getItemName());
            tableMode.setText8(receivingBean.getBatch());
            tableMode.setText9(receivingBean.getQty());
            tableMode.setText10(receivingBean.getItemUnitCode());
            tableMode.setText11(receivingBean.getSupplierCode());
            tableMode.setText12(receivingBean.getSupplierName());
//            tableMode.setText12(getScanTitle(receivingBean.getGeneralSource()));
            tableMode.setText13(receivingBean.getLineNumbers());
//            tableMode.setText14(receivingBean.getActualQty());
            tableMode.setText15(receivingBean.getCreatedBy());
            tableMode.setText16(WMSUtils.freshTimeDate(receivingBean.getCreated()));
            tableMode.setText17(receivingBean.getUpdatedBy());
            tableMode.setText18(WMSUtils.freshTimeDate(receivingBean.getUpdated()));
            mDatas.add(tableMode);
        }
        boolean isMore;
        if (type == RefreshParams.LOAD_DATA) {
            isMore = true;
        } else {
            isMore = false;
        }
        mRightAdapter.addData(mDatas, isMore);
        //加载数据成功,增加页数
        mDatas.clear();
    }

    private void freshMenuText(int mAllPage, int mAlter) {
        allPage.setText(String.format(getResources().getString(R.string.all_page), mAllPage));
        alterPage.setText(String.format(getResources().getString(R.string.alter_page), 10));
        fromPage.setText(String.format(getResources().getString(R.string.from_page), pageNo, mAlter));
        firstPage.setText(String.format(getResources().getString(R.string.first_page)));
        upPage.setText(String.format(getResources().getString(R.string.up_page)));
        downPage.setText(String.format(getResources().getString(R.string.down_page)));
        lastPage.setText(String.format(getResources().getString(R.string.last_page)));
        jumpPage.setText(String.format(getResources().getString(R.string.jump_page)));
        if (mAlter > 1) {
            firstPage.setTextColor(getResources().getColor(R.color.black));
            lastPage.setTextColor(getResources().getColor(R.color.black));
            jumpPage.setTextColor(getResources().getColor(R.color.black));
            firstPage.setClickable(true);
            lastPage.setClickable(true);
            jumpPage.setClickable(true);
        } else {
            firstPage.setTextColor(getResources().getColor(R.color.gray_bg));
            lastPage.setTextColor(getResources().getColor(R.color.gray_bg));
            jumpPage.setTextColor(getResources().getColor(R.color.gray_bg));
            firstPage.setClickable(false);
            lastPage.setClickable(false);
            jumpPage.setClickable(false);
        }
        if (pageNo == 1) {
            upPage.setTextColor(getResources().getColor(R.color.gray_bg));
            upPage.setEnabled(false);
        } else {
            upPage.setTextColor(getResources().getColor(R.color.black));
            upPage.setEnabled(true);
        }

        if (pageNo == mAlter || mAlter == 0) {
            downPage.setTextColor(getResources().getColor(R.color.gray_bg));
            downPage.setEnabled(false);
        } else {
            downPage.setTextColor(getResources().getColor(R.color.black));
            downPage.setEnabled(true);
        }
    }

    private void showJumpDialog() {
        AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
        View view = LayoutInflater.from(mContext).inflate(R.layout.dialog_choose, null);
        TextView cancel = view.findViewById(R.id.choosepage_cancel);
        TextView sure = view.findViewById(R.id.choosepage_sure);
        final EditText edittext = view.findViewById(R.id.choosepage_edittext);
        edittext.setFilters(new InputFilter[]{new InputFilterMinMax(1, mAlertPage)});
        final Dialog dialog = builder.create();
        dialog.show();
        dialog.getWindow().setContentView(view);
        //使editext可以唤起软键盘
        dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
        cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });
        sure.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                getReceivingsByCondition(Integer.parseInt(edittext.getText().toString()));
                dialog.dismiss();
            }
        });
    }

    private String getScanTitle(int value) {
        switch (value) {
            case Constant.EMPTY_TASK_SCAN:
                return mContext.getString(R.string.empty_task_scan);
            case Constant.UNLOADING_SCAN:
                return mContext.getString(R.string.unloading_scan);
        }
        return mContext.getString(R.string.empty_task_scan);
    }

    private String cutTime(String time) {
        if (WMSUtils.isNotEmpty(time) && time.length() >= 10) {
            time = time.substring(0, 10);
        }
        return time;
    }

    private void showChooseProductLineDialog() {
        AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
        View view = LayoutInflater.from(mContext).inflate(R.layout.dialog_choose_productline, null);
        TextView cancel = view.findViewById(R.id.productLine_cancel);
        TextView sure = view.findViewById(R.id.productLine_sure);
        findCheckboxIds(view);
        setCheckStatus();
        final Dialog dialog = builder.create();
        dialog.show();
        dialog.getWindow().setContentView(view);
        //使editext可以唤起软键盘
        dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
        cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });
        sure.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                getCheckStatus();
                dialog.dismiss();
            }
        });
    }

    /**
     * 初始化标题的Checkbox的item引用
     */
    private void findCheckboxIds(View view) {
        mCheckBoxArray = new SparseArray<>();
        CheckBox checkBox1 = view.findViewById(R.id.checkBox1);
        mCheckBoxArray.put(0, checkBox1);
        CheckBox checkBox2 = view.findViewById(R.id.checkBox2);
        mCheckBoxArray.put(1, checkBox2);
        CheckBox checkBox3 = view.findViewById(R.id.checkBox3);
        mCheckBoxArray.put(2, checkBox3);
        CheckBox checkBox4 = view.findViewById(R.id.checkBox4);
        mCheckBoxArray.put(3, checkBox4);
        CheckBox checkBox5 = view.findViewById(R.id.checkBox5);
        mCheckBoxArray.put(4, checkBox5);
        CheckBox checkBox6 = view.findViewById(R.id.checkBox6);
        mCheckBoxArray.put(5, checkBox6);
        CheckBox checkBox7 = view.findViewById(R.id.checkBox7);
        mCheckBoxArray.put(6, checkBox7);
        CheckBox checkBox8 = view.findViewById(R.id.checkBox8);
        mCheckBoxArray.put(7, checkBox8);
        CheckBox checkBox9 = view.findViewById(R.id.checkBox9);
        mCheckBoxArray.put(8, checkBox9);
        CheckBox checkBox10 = view.findViewById(R.id.checkBox10);
        mCheckBoxArray.put(9, checkBox10);
        CheckBox checkBox11 = view.findViewById(R.id.checkBox11);
        mCheckBoxArray.put(10, checkBox11);
        CheckBox checkBox12 = view.findViewById(R.id.checkBox12);
        mCheckBoxArray.put(11, checkBox12);
        CheckBox checkBox13 = view.findViewById(R.id.checkBox13);
        mCheckBoxArray.put(12, checkBox13);
        for (int i = 0; i < CHECKS_LENGTH; i++) {
            CheckBox checkBox = mCheckBoxArray.get(i);
            checkStr[i] = checkBox.getText().toString();
        }
    }

    private void setCheckStatus() {
        for (int i = 0; i < CHECKS_LENGTH; i++) {
            CheckBox checkBox = mCheckBoxArray.get(i);
            checkBox.setChecked(checks[i]);
        }
    }

    private void getCheckStatus() {
        checkArray = new ArrayList<>();
        for (int i = 0; i < CHECKS_LENGTH; i++) {
            CheckBox checkBox = mCheckBoxArray.get(i);
            checks[i] = checkBox.isChecked();
            if (checks[i]) {
                checkArray.add(checkStr[i]);
            }
        }
    }


    private void startScanActivity() {
        Intent intent = new Intent();
        intent.setClass(mContext, ScanCaptureAct.class);
        this.startActivityForResult(intent, RESULT_CODE);
    }

    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (data != null) {
            result = data.getExtras().containsKey("SCAN_RESULT") ? data.getExtras().getString("SCAN_RESULT") : null;
            if (result != null) {
                scanBarcodeData(result);
//                getProductLineByCondition();
            }
        }
    }


    @OnClick({R.id.firstPage, R.id.upPage, R.id.downPage, R.id.lastPage, R.id.jumpPage, R.id.scanUnloadingBtn, R.id.removeUnloadingBtn, R.id.refreshBtn, R.id.chooseBtn})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.firstPage:
                getReceivingsByCondition(1);
                break;
            case R.id.upPage:
                getReceivingsByCondition(pageNo - 1);
                break;
            case R.id.downPage:
                getReceivingsByCondition(pageNo + 1);
                break;
            case R.id.lastPage:
                getReceivingsByCondition(mAlertPage);
                break;
            case R.id.jumpPage:
                showJumpDialog();
                break;
            case R.id.scanUnloadingBtn:
                startScanActivity();
                break;
            case R.id.removeUnloadingBtn:
                if (enableBarcode()) {
                    removeReveiving(selectReceivingBeans.get(0).getId());
                }
                break;
            case R.id.refreshBtn:
                getReceivingsByCondition(pageNo);
                break;
            case R.id.chooseBtn:
                showChooseProductLineDialog();
                break;
            default:
                break;
        }
    }

    private void scanBarcodeData(String code) {
        String lineNumbers = null;
        for (String check : checkArray) {
            if(lineNumbers == null) {
                lineNumbers = check;
            } else {
                lineNumbers = lineNumbers + "," + check;
            }
        }
        String userCode = WMSUtils.getData(Constant.LOGIN_NAME);
        HttpInterface.getInsstance().scanBarcodeData(new ProgressSubscriber<String>
                (mContext, dataListener), userCode, code, lineNumbers);
    }

    SubscriberOnNextListener dataListener = new SubscriberOnNextListener<String>() {
        @Override
        public void onNext(String str) {
            WMSUtils.showLong(mContext.getString(R.string.scan_success) + result);
            getReceivingsByCondition(pageNo);
        }

        @Override
        public void onError(String str) {
            WMSUtils.showLong(mContext.getString(R.string.scan_error) + result);
        }
    };

//    private void getBarcodeDataByCondition(int page) {
//        upPageNo = page;
//        String condition = "where generalSource = 1";
//        String condition2 = "";
//        String orderby = "id desc";
//        HttpInterface.getInsstance().getBarcodeDataByCondition(new ProgressSubscriber<BarcodeOrderBean>
//                (mContext, barcodeListener), upPageNo, pageSize, orderby, condition, condition2);
//    }
//
//    SubscriberOnNextListener barcodeListener = new SubscriberOnNextListener<BarcodeOrderBean>() {
//
//        @Override
//        public void onNext(BarcodeOrderBean barcodeOrderBean) {
//            clearSelecttTaskBean();
//            pageNo = upPageNo;
//            barcodeDataBeans = barcodeOrderBean.getDatas();
//            setData(barcodeDataBeans);
//            int size = barcodeOrderBean.getCount();
//            int alter = size / pageSize + 1;
//            if (size % pageSize == 0) {
//                alter = alter - 1;
//            }
//            mAlertPage = alter;
//            freshMenuText(size, alter);
//        }
//
//        @Override
//        public void onError(String str) {
//            clearSelecttTaskBean();
//        }
//    };

//    private void removeBarcodeData(int id) {
//        HttpInterface.getInsstance().removeBarcodeData(new ProgressSubscriber<String>
//                (mContext, removeListener), id);
//    }
//
//    SubscriberOnNextListener removeListener = new SubscriberOnNextListener<String>() {
//        @Override
//        public void onNext(String str) {
//            WMSUtils.showLong(mContext.getString(R.string.remove_success));
//            getBarcodeDataByCondition(pageNo);
//        }
//
//        @Override
//        public void onError(String str) {
//            getBarcodeDataByCondition(pageNo);
//        }
//    };

    private void getReceivingsByCondition(int page) {
        upPageNo = page;
        String condition = "";
        String condition2 = "";
        String orderby = "id desc";
        HttpInterface.getInsstance().getReceivingsByCondition(new ProgressSubscriber<ReceivingOrderBean>
                (mContext, getReceivingsListener), upPageNo, pageSize, orderby, condition, condition2);
    }

    SubscriberOnNextListener getReceivingsListener = new SubscriberOnNextListener<ReceivingOrderBean>() {

        @Override
        public void onNext(ReceivingOrderBean receivingOrderBean) {
            clearSelecttTaskBean();
            pageNo = upPageNo;
            receivingBeans = receivingOrderBean.getDatas();
            setData(receivingBeans);
            int size = receivingOrderBean.getCount();
            int alter = size / pageSize + 1;
            if (size % pageSize == 0) {
                alter = alter - 1;
            }
            mAlertPage = alter;
            freshMenuText(size, alter);
        }

        @Override
        public void onError(String str) {
            clearSelecttTaskBean();
        }
    };

    private void removeReveiving(int id) {
        HttpInterface.getInsstance().removeReveiving(new ProgressSubscriber<String>
                (mContext, reveingListener), id);
    }

    SubscriberOnNextListener reveingListener = new SubscriberOnNextListener<String>() {
        @Override
        public void onNext(String str) {
            WMSUtils.showLong(mContext.getString(R.string.remove_success));
            getReceivingsByCondition(pageNo);
        }

        @Override
        public void onError(String str) {
            getReceivingsByCondition(pageNo);
        }
    };



//    private void getProductLineByCondition() {
//        String condition = "";
//        String condition2 = "";
//        String orderby = "id desc";
//        HttpInterface.getInsstance().getProductLineByCondition(new ProgressSubscriber<ProductLineOrderBean>
//                (mContext, productLineListener), 1, 20, orderby, condition, condition2);
//    }
//
//    SubscriberOnNextListener productLineListener = new SubscriberOnNextListener<ProductLineOrderBean>() {
//
//        @Override
//        public void onNext(ProductLineOrderBean productLineOrderBean) {
//           List<ProductLineBean> productLineBeans = productLineOrderBean.getDatas();
//            showChooseProductLineDialog(productLineBeans);
//        }
//
//        @Override
//        public void onError(String str) {
//
//        }
//    };

//    private void showChooseProductLineDialog(List<ProductLineBean> productLineBeanList) {
//        final List<String> productLineCodes = new ArrayList<>();
//        final List<String> selectCodes = new ArrayList<>();
//        for(ProductLineBean productLineBean : productLineBeanList) {
//            productLineCodes.add(productLineBean.getCode());
//        }
//        String[] items = productLineCodes.toArray(new String[productLineCodes.size()]) ;
//        final boolean[] selected = new boolean[items.length];
//        for(int i=0; i < selected.length; i++) {
//            selected[i] = false;
//        }
//        new AlertDialog.Builder(this)
//        .setTitle("请选择生产线")
//        .setMultiChoiceItems(items, selected, new DialogInterface.OnMultiChoiceClickListener() {
//            @Override
//            public void onClick(DialogInterface dialogInterface, int i, boolean b) {
//                selected[i] = b;
//            }
//        })
//        .setNegativeButton("取消", new DialogInterface.OnClickListener() {
//            @Override
//            public void onClick(DialogInterface dialogInterface, int i) {
//                dialogInterface.dismiss();
//            }
//        })
//        .setPositiveButton("确定", new DialogInterface.OnClickListener() {
//            @Override
//            public void onClick(DialogInterface dialogInterface, int i) {
////                SparseBooleanArray checkedArray = ((AlertDialog) dialogInterface).getListView().getCheckedItemPositions();
//                for(int j=0; j < selected.length; j++) {
//                    boolean check = selected[j];
//                    if(check) {
//                        selectCodes.add(productLineCodes.get(j));
//                    }
//                }
//                int size = selectCodes.size();
//                if(size <= 0) {
//                    WMSUtils.showShort("请选择好生产线再确定");
//                    return;
//                }
//                String lineNumbers = null;
//                for(String line : selectCodes) {
//                    if(lineNumbers == null) {
//                        lineNumbers = line;
//                    } else {
//                        lineNumbers = lineNumbers + "," + line;
//                    }
//                }
//                scanBarcodeData(result, lineNumbers);
//            }
//        }).create().show();
//    }


}