|
|
@@ -1,842 +0,0 @@
|
|
|
-package com.uas.huayun.activity;
|
|
|
-
|
|
|
-import android.app.Activity;
|
|
|
-import android.app.Dialog;
|
|
|
-import android.content.Intent;
|
|
|
-import android.content.pm.PackageManager;
|
|
|
-import android.graphics.drawable.BitmapDrawable;
|
|
|
-import android.os.Handler;
|
|
|
-import android.support.annotation.NonNull;
|
|
|
-import android.text.TextUtils;
|
|
|
-import android.util.Log;
|
|
|
-import android.view.Gravity;
|
|
|
-import android.view.KeyEvent;
|
|
|
-import android.view.LayoutInflater;
|
|
|
-import android.view.MotionEvent;
|
|
|
-import android.view.View;
|
|
|
-import android.view.Window;
|
|
|
-import android.widget.AdapterView;
|
|
|
-import android.widget.Button;
|
|
|
-import android.widget.CheckBox;
|
|
|
-import android.widget.CompoundButton;
|
|
|
-import android.widget.GridView;
|
|
|
-import android.widget.ImageView;
|
|
|
-import android.widget.LinearLayout;
|
|
|
-import android.widget.PopupWindow;
|
|
|
-import android.widget.SimpleAdapter;
|
|
|
-import android.widget.TextView;
|
|
|
-
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
-import com.alibaba.fastjson.JSONArray;
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.android.volley.Request;
|
|
|
-import com.android.volley.toolbox.StringRequest;
|
|
|
-import com.scwang.smartrefresh.layout.api.RefreshLayout;
|
|
|
-import com.scwang.smartrefresh.layout.listener.OnRefreshListener;
|
|
|
-import com.uas.huayun.R;
|
|
|
-import com.uas.huayun.application.PdaApplication;
|
|
|
-import com.uas.huayun.bean.Master;
|
|
|
-import com.uas.huayun.bean.MoreEventBusBean;
|
|
|
-import com.uas.huayun.fragment.BaseFragment;
|
|
|
-import com.uas.huayun.fragment.WorkOrderSearchFragment;
|
|
|
-import com.uas.huayun.global.GloableParams;
|
|
|
-import com.uas.huayun.listener.MyEditorActionListener;
|
|
|
-import com.uas.huayun.tools.DataSourceManager;
|
|
|
-import com.uas.huayun.tools.SharedPreUtil;
|
|
|
-import com.uas.huayun.tools.VolleyUtil;
|
|
|
-import com.uas.huayun.util.CameraUtil;
|
|
|
-import com.uas.huayun.util.CommonUtil;
|
|
|
-import com.uas.huayun.util.Constants;
|
|
|
-import com.uas.huayun.util.FastjsonUtil;
|
|
|
-import com.uas.huayun.util.HttpCallback;
|
|
|
-import com.uas.huayun.util.HttpParams;
|
|
|
-import com.uas.huayun.util.LogUtil;
|
|
|
-import com.uas.huayun.util.PermissionUtil;
|
|
|
-import com.uas.huayun.util.StringUtil;
|
|
|
-import com.uas.huayun.util.VolleyRequest;
|
|
|
-import com.uas.huayun.util.VollyRequest;
|
|
|
-import com.uas.huayun.view.ClearableEditText;
|
|
|
-import com.uas.huayun.view.business.StaffUpPopup;
|
|
|
-import com.uuzuche.lib_zxing.activity.CaptureActivity;
|
|
|
-import com.uuzuche.lib_zxing.activity.CodeUtils;
|
|
|
-
|
|
|
-import org.greenrobot.eventbus.EventBus;
|
|
|
-import org.greenrobot.eventbus.Subscribe;
|
|
|
-
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-
|
|
|
-import razerdp.basepopup.BasePopupWindow;
|
|
|
-
|
|
|
-public class IndexActivity extends BaseActivity implements AdapterView.OnItemClickListener, View.OnClickListener, StaffUpPopup.OnStaffUpListener {
|
|
|
- private final int SCAN_STAFF_CODE = 0x999;
|
|
|
- private static final String TAG = "IndexActivity";
|
|
|
- private ArrayList<HashMap<String, Object>> gridItemList;
|
|
|
- private GridView menuGridView;
|
|
|
- private TextView actionbarTextVeiw;
|
|
|
- private TextView tv_metrimal_name;
|
|
|
- private PopupWindow mExitPopupWindow;
|
|
|
- private TextView mPositionR, mFeeding, mCurDoc, mUnfinish, tv_pihao,
|
|
|
- mEmCodeTv, mEmNameTv, mScName, mStaffTextView, mScrapTextView;
|
|
|
- private String sc_code = null, mStaffName, mStaffCode,sc_name;
|
|
|
- private RefreshLayout mRefreshLayout;
|
|
|
- private PopupWindow editPW;
|
|
|
- private String MACODE = null; //工单编号
|
|
|
- public BaseFragment mFragment;
|
|
|
- private ClearableEditText edit_et;
|
|
|
- private Button mBackButton;
|
|
|
- private StaffUpPopup mStaffUpPopup;
|
|
|
- private StringRequest mStringRequest;
|
|
|
- private TextView index_qty;
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void onDestroy() {
|
|
|
-// SharedPreUtil.removeAll(getApplicationContext());
|
|
|
- VolleyUtil.distoryVolley();
|
|
|
- super.onDestroy();
|
|
|
- EventBus.getDefault().unregister(this);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void initViews() {
|
|
|
- setContentView(R.layout.activity_index);
|
|
|
- mEmCodeTv = findViewById(R.id.em_code_tv);
|
|
|
- mEmNameTv = findViewById(R.id.em_name_tv);
|
|
|
- tv_metrimal_name=findViewById(R.id.tv_metrimal_name);
|
|
|
- actionbarTextVeiw = (TextView) findViewById(R.id.actionbar);
|
|
|
- actionbarTextVeiw.setText("UAS车间工作站管理");
|
|
|
- menuGridView = (GridView) findViewById(R.id.grid_menu);
|
|
|
- mPositionR = (TextView) findViewById(R.id.index_position_resource);
|
|
|
- mScName = (TextView) findViewById(R.id.scname_tv);
|
|
|
- // mFeeding = (TextView) findViewById(R.id.index_feeding);
|
|
|
- mCurDoc = (TextView) findViewById(R.id.index_cur_doc);
|
|
|
- mUnfinish = (TextView) findViewById(R.id.index_unfinish_number);
|
|
|
- index_qty = findViewById(R.id.index_qty);
|
|
|
- mBackButton = findViewById(R.id.btn_actionbar_withback);
|
|
|
- // mStaffTextView = findViewById(R.id.index_staff_info_tv);
|
|
|
- mScrapTextView = findViewById(R.id.index_scrap_number);
|
|
|
- tv_pihao=findViewById(R.id.tv_pihao);
|
|
|
-
|
|
|
- findViewById(R.id.index_edit).setOnClickListener(this);
|
|
|
- mRefreshLayout = findViewById(R.id.SmartRefreshLayout_id);
|
|
|
- mRefreshLayout.setEnableLoadMore(false);
|
|
|
- gridItemList = DataSourceManager.getDataSourceManager().getIndexMainGridItemList();
|
|
|
- findViewById(R.id.btn_actionbar_scan_iv).setOnClickListener(this);
|
|
|
- SimpleAdapter adapter = new SimpleAdapter(this, gridItemList, R.layout.item_grid,
|
|
|
- new String[]{DataSourceManager.KEY_GRID_ITEMIMG, DataSourceManager.KEY_GRID_ITEMNAME},
|
|
|
- new int[]{R.id.griditem_img, R.id.griditem_name});
|
|
|
- menuGridView.setAdapter(adapter);
|
|
|
-
|
|
|
- mStaffUpPopup = new StaffUpPopup(this, this);
|
|
|
-
|
|
|
- View view = View.inflate(this, R.layout.pop_exit_application, null);
|
|
|
- view.findViewById(R.id.pop_exit_cancel_tv).setOnClickListener(this);
|
|
|
- view.findViewById(R.id.pop_exit_minimize_tv).setOnClickListener(this);
|
|
|
- view.findViewById(R.id.pop_exit_exit_tv).setOnClickListener(this);
|
|
|
-
|
|
|
- mExitPopupWindow = new PopupWindow(view, LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, true);
|
|
|
- mExitPopupWindow.setBackgroundDrawable(new BitmapDrawable());
|
|
|
- mExitPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
|
|
|
- @Override
|
|
|
- public void onDismiss() {
|
|
|
- closeExitPopupWindow();
|
|
|
- }
|
|
|
- });
|
|
|
- mFragment = new WorkOrderSearchFragment();
|
|
|
- sc_code=SharedPreUtil.getString(this,Constants.FLAG.GANG_WEI_SOURCE_CODE,"");
|
|
|
- sc_name=SharedPreUtil.getString(this,Constants.FLAG.GANG_WEI_SOURCE_NAME,"");
|
|
|
- new Handler().postDelayed(new Runnable() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- if (!StringUtil.isEmpty(sc_code)) {
|
|
|
- handleCode(sc_code, true);
|
|
|
- }else{
|
|
|
- initEditPopupWindow();
|
|
|
- }
|
|
|
- }
|
|
|
- },500);
|
|
|
-
|
|
|
-
|
|
|
- getPrintTemplate();
|
|
|
- EventBus.getDefault().register(this);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void initEvents() {
|
|
|
- menuGridView.setOnItemClickListener(this);
|
|
|
- menuGridView.setOnTouchListener(new View.OnTouchListener() {
|
|
|
- @Override
|
|
|
- public boolean onTouch(View v, MotionEvent event) {
|
|
|
- //控制gridView不滚动
|
|
|
- if (event.getAction() == MotionEvent.ACTION_MOVE)
|
|
|
- return true;
|
|
|
- return false;
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- mRefreshLayout.setOnRefreshListener(new OnRefreshListener() {
|
|
|
- @Override
|
|
|
- public void onRefresh(RefreshLayout refreshLayout) {
|
|
|
- if (StringUtil.isEmpty(sc_code)) {
|
|
|
- CommonUtil.toastNoRepeat(IndexActivity.this, "请先采集岗位资源");
|
|
|
- mRefreshLayout.finishRefresh(0);
|
|
|
- return;
|
|
|
- }
|
|
|
- getDeviceline(sc_code);
|
|
|
- mRefreshLayout.finishRefresh(0);
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- mBackButton.setOnClickListener(new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View v) {
|
|
|
- finish();
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onClick(View v) {
|
|
|
- int Id = v.getId();
|
|
|
- switch (Id) {
|
|
|
- case R.id.pop_exit_cancel_tv:
|
|
|
- closeExitPopupWindow();
|
|
|
- break;
|
|
|
- case R.id.pop_exit_exit_tv:
|
|
|
- PdaApplication.removeAllDataCache();
|
|
|
- System.exit(0);
|
|
|
- break;
|
|
|
- case R.id.pop_exit_minimize_tv:
|
|
|
- closeExitPopupWindow();
|
|
|
- moveTaskToBack(isFinishing());
|
|
|
- break;
|
|
|
- case R.id.index_edit:
|
|
|
- initEditPopupWindow();
|
|
|
- break;
|
|
|
- case R.id.btn_actionbar_scan_iv:
|
|
|
- if (CameraUtil.hasCamera()) {
|
|
|
- Intent intent = new Intent();
|
|
|
- intent.setClass(IndexActivity.this, CaptureActivity.class);
|
|
|
- startActivityForResult(intent, Constants.FLAG.SCAN_BARCODE_CODE);
|
|
|
- } else {
|
|
|
- CommonUtil.toastNoRepeat(IndexActivity.this, getString(R.string.no_camera_detected));
|
|
|
- }
|
|
|
- break;
|
|
|
- default:
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
- super.onActivityResult(requestCode, resultCode, data);
|
|
|
-
|
|
|
- if (data != null && data.getExtras() != null) {
|
|
|
- if (requestCode == Constants.FLAG.SCAN_BARCODE_CODE && resultCode == Activity.RESULT_OK) {
|
|
|
- String result = data.getExtras().getString(CodeUtils.RESULT_STRING) + "";
|
|
|
- LogUtil.i("onActivityResult", result);
|
|
|
- if (!StringUtil.isEmpty(result)) {
|
|
|
- mPositionR.setText(result);
|
|
|
- sc_code = result;
|
|
|
- handleCode(result, true);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (requestCode == Constants.FLAG.GET_COMMON_ITEM && resultCode == 1847) {
|
|
|
- String result = data.getStringExtra("ITEM_DATA");
|
|
|
- if(result.contains("(")){
|
|
|
- edit_et.setText(result.split("\\(")[0]);
|
|
|
- edit_et.setSelection(result.split("\\(")[0].length());
|
|
|
- }
|
|
|
- }
|
|
|
- if (requestCode == SCAN_STAFF_CODE && resultCode == Activity.RESULT_OK) {
|
|
|
- String scanResult = CommonUtil.getScanResult(data);
|
|
|
- mStaffUpPopup.setEmidText(scanResult);
|
|
|
- onStaffUp(scanResult);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- private void initEditPopupWindow() {
|
|
|
- View contView = LayoutInflater.from(this).inflate(R.layout.index_edit_pup, null);
|
|
|
- edit_et = (ClearableEditText) contView.findViewById(R.id.edit_et);
|
|
|
- TextView sure_tv = (TextView) contView.findViewById(R.id.sure_tv);
|
|
|
- TextView cancle_tv = (TextView) contView.findViewById(R.id.cancle_tv);
|
|
|
- ImageView search_im = contView.findViewById(R.id.search_im);
|
|
|
-
|
|
|
-// search_im.setVisibility(View.GONE);
|
|
|
- editPW = new PopupWindow(contView, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT, true);
|
|
|
- editPW.setTouchable(true);
|
|
|
- editPW.setBackgroundDrawable(new BitmapDrawable());
|
|
|
- editPW.setOnDismissListener(new BasePopupWindow.OnDismissListener() {
|
|
|
- @Override
|
|
|
- public void onDismiss() {
|
|
|
- closeListPopupWindow();
|
|
|
- }
|
|
|
- });
|
|
|
- View parentView = getWindow().findViewById(Window.ID_ANDROID_CONTENT);
|
|
|
- editPW.showAtLocation(parentView, Gravity.CENTER, 0, 0);
|
|
|
- CommonUtil.setBackgroundAlpha(this, 0.5f);
|
|
|
-
|
|
|
- sure_tv.setOnClickListener(new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View v) {
|
|
|
- String code = edit_et.getText().toString().trim();
|
|
|
- handleCode(code, true);
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- search_im.setOnClickListener(new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View v) {
|
|
|
- Intent intent = new Intent(IndexActivity.this, CommonSeclecActivity.class);
|
|
|
- intent.putExtra("title", "岗位资源");
|
|
|
- intent.putExtra("type", 1);
|
|
|
- startActivityForResult(intent, Constants.FLAG.GET_COMMON_ITEM);
|
|
|
- }
|
|
|
- });
|
|
|
- CommonUtil.setEditorActionListener(edit_et, new MyEditorActionListener() {
|
|
|
- @Override
|
|
|
- public void MyEditorAction(String text, int actionId, KeyEvent event) {
|
|
|
- String code = edit_et.getText().toString().trim();
|
|
|
- handleCode(code, true);
|
|
|
- }
|
|
|
- });
|
|
|
- cancle_tv.setOnClickListener(new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View v) {
|
|
|
- closeListPopupWindow();
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- //修改岗位资源操作
|
|
|
-
|
|
|
- /**
|
|
|
- * @param code
|
|
|
- * @param isCheck 当修改岗位资源或者切换时
|
|
|
- */
|
|
|
- private void handleCode(String code, Boolean isCheck) {
|
|
|
- if (StringUtil.isEmpty(code)) return;
|
|
|
- closeListPopupWindow();
|
|
|
- if (!isCheck) {
|
|
|
- getDeviceline(code);
|
|
|
- return;
|
|
|
- }
|
|
|
- progressDialog.show();
|
|
|
- VollyRequest.getInstance().stringRequest(new HttpParams.Builder()
|
|
|
- .url(GloableParams.ADDRESS_PDA_INDEX_CHECKSOURCEEMP)
|
|
|
- .method(Request.Method.GET)
|
|
|
- .tag(TAG + "checkSourceEmp")
|
|
|
- .flag(0)
|
|
|
- .addParam("sc_code", code)
|
|
|
- .build(), new HttpCallback() {
|
|
|
- @Override
|
|
|
- public void onSuccess(int flag, Object o) throws Exception {
|
|
|
- progressDialog.dismiss();
|
|
|
- try {
|
|
|
- JSONObject dataObject = FastjsonUtil.getJSONObject(o.toString(), "data");
|
|
|
- showDataView(dataObject);
|
|
|
-
|
|
|
- } catch (Exception e) {
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onFail(int flag, String failStr) throws Exception {
|
|
|
- progressDialog.dismiss();
|
|
|
- CommonUtil.toastNoRepeat(IndexActivity.this, failStr);
|
|
|
- }
|
|
|
-
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- private void closeListPopupWindow() {
|
|
|
- if (editPW != null) {
|
|
|
- editPW.dismiss();
|
|
|
- editPW = null;
|
|
|
- CommonUtil.setBackgroundAlpha(this, 1f);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void initDatas() {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- private void getDeviceline(String scCode) {
|
|
|
- progressDialog.show();
|
|
|
- mStaffCode = "";
|
|
|
- mStaffName = "";
|
|
|
- VollyRequest.getInstance().stringRequest(new HttpParams.Builder()
|
|
|
- .url(GloableParams.ADDRESS_PDA_INDEX_GETDEVICELINE)
|
|
|
- .method(Request.Method.GET)
|
|
|
- .tag(TAG + "getDeviceline")
|
|
|
- .flag(0)
|
|
|
- .addParam("sc_code", scCode)
|
|
|
- .build(), new HttpCallback() {
|
|
|
- @Override
|
|
|
- public void onSuccess(int flag, Object o) throws Exception {
|
|
|
- try {
|
|
|
- Boolean isSuccess = FastjsonUtil.getBoolean(o.toString(), "success");
|
|
|
- if (isSuccess) {
|
|
|
- JSONObject dataObject = FastjsonUtil.getJSONObject(o.toString(), "data");
|
|
|
- showDataView(dataObject);
|
|
|
- } else {
|
|
|
-
|
|
|
- }
|
|
|
- progressDialog.dismiss();
|
|
|
-
|
|
|
- } catch (Exception e) {
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onFail(int flag, String failStr) throws Exception {
|
|
|
- progressDialog.dismiss();
|
|
|
- CommonUtil.toastNoRepeat(IndexActivity.this, failStr);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- private void showDataView(JSONObject dataObject) {
|
|
|
- if (!StringUtil.isEmpty(dataObject.getString("SC_CODE"))) {
|
|
|
- sc_code = dataObject.getString("SC_CODE");
|
|
|
- SharedPreUtil.saveString(this, "SC_CODE", sc_code);
|
|
|
- mPositionR.setText(sc_code);
|
|
|
- SharedPreUtil.saveString(this,Constants.FLAG.GANG_WEI_SOURCE_CODE,sc_code);
|
|
|
- String sc_name = dataObject.getString("SC_NAME");
|
|
|
- if (sc_name.length() == 0 || sc_name == "") {
|
|
|
- sc_name = "-";
|
|
|
- }
|
|
|
- sc_name = "(" + sc_name + ")";
|
|
|
- mScName.setText(sc_name);
|
|
|
- SharedPreUtil.saveString(this,Constants.FLAG.GANG_WEI_SOURCE_NAME,sc_name);
|
|
|
- } else {
|
|
|
- CommonUtil.toastNoRepeat(this, "岗位资源数据为空");
|
|
|
- return;
|
|
|
- }
|
|
|
- if (!StringUtil.isEmpty(dataObject.getString("DL_MACODE"))) {
|
|
|
- MACODE = dataObject.getString("DL_MACODE");
|
|
|
- SharedPreUtil.saveString(this, "MA_CODE", dataObject.getString("DL_MACODE"));
|
|
|
- mCurDoc.setText(MACODE);
|
|
|
- } else {
|
|
|
- mCurDoc.setText("");
|
|
|
- }
|
|
|
- if (!StringUtil.isEmpty(dataObject.getString("MA_QTY"))) {//UNFINISHQQTY
|
|
|
- mUnfinish.setText(dataObject.getString("MA_QTY"));
|
|
|
- } else {
|
|
|
- mUnfinish.setText("");
|
|
|
- }
|
|
|
- if (!StringUtil.isEmpty(dataObject.getString("QTY"))) {
|
|
|
- index_qty.setText(dataObject.getString("QTY"));
|
|
|
- }else {
|
|
|
- index_qty.setText("");
|
|
|
- }
|
|
|
-
|
|
|
- if (!StringUtil.isEmpty(dataObject.getString("SC_STEPCODE"))) {
|
|
|
- tv_pihao.setText(dataObject.getString("SC_STEPCODE"));
|
|
|
- } else {
|
|
|
- tv_pihao.setText("");
|
|
|
- }
|
|
|
- //待设置
|
|
|
- tv_metrimal_name.setText(dataObject.getString("PR_DETAIL"));
|
|
|
- mScrapTextView.setText(FastjsonUtil.getText(dataObject, "NGQTY"));//MA_ONLINESCRAPQTY
|
|
|
- mStaffName = FastjsonUtil.getText(dataObject, "UO_EMNAME");
|
|
|
- mStaffCode = TextUtils.isEmpty(FastjsonUtil.getText(dataObject, "UO_EMCODE"))?
|
|
|
- SharedPreUtil.getString(this, Constants.FLAG.CACHE_USER_EMCODE, "")
|
|
|
- :FastjsonUtil.getText(dataObject, "UO_EMCODE");
|
|
|
- // mStaffTextView.setText(mStaffName + (TextUtils.isEmpty(mStaffCode) ? "" : ("(" + mStaffCode + ")")));
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void onResume() {
|
|
|
- super.onResume();
|
|
|
- mEmCodeTv.setText("(" + SharedPreUtil.getString(this, Constants.FLAG.CACHE_USER_EMCODE, "-") + ")");
|
|
|
- mEmNameTv.setText(SharedPreUtil.getString(this, Constants.FLAG.CACHE_USER_EMNAME, "-"));
|
|
|
- //新增---给上线人员设置默认值
|
|
|
- mStaffCode =SharedPreUtil.getString(this, Constants.FLAG.CACHE_USER_EMCODE, "");
|
|
|
- sc_code=SharedPreUtil.getString(this,Constants.FLAG.GANG_WEI_SOURCE_CODE,"");
|
|
|
- sc_name=SharedPreUtil.getString(this,Constants.FLAG.GANG_WEI_SOURCE_NAME,"");
|
|
|
- mPositionR.setText(sc_code);
|
|
|
- mScName.setText(sc_name);
|
|
|
-// if (!StringUtil.isEmpty(sc_code)) {
|
|
|
-// handleCode(sc_code, true);
|
|
|
-// }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void onNewIntent(Intent intent) {
|
|
|
- super.onNewIntent(intent);
|
|
|
- boolean needClear = intent.getBooleanExtra(Constants.FLAG.NEED_CLEAR_SCCODE, false);
|
|
|
- String fromSc_Code = intent.getStringExtra(Constants.FLAG.SC_CODE);
|
|
|
- LogUtil.i("getDevicelineneedClear", needClear + "");
|
|
|
- LogUtil.i("getDevicelinefromSc_Code", fromSc_Code + "");
|
|
|
- if (!StringUtil.isEmpty(fromSc_Code) && !needClear) {
|
|
|
- handleCode(fromSc_Code, false);
|
|
|
- } else if (!StringUtil.isEmpty(fromSc_Code) && needClear) {
|
|
|
- sc_code = null;
|
|
|
- mPositionR.setText("");
|
|
|
- mScName.setText("");
|
|
|
- mFeeding.setText("");
|
|
|
- mCurDoc.setText("");
|
|
|
- mUnfinish.setText("");
|
|
|
- } else {
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- int pageType = -1;
|
|
|
- @Override
|
|
|
- public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
|
- String itemName = (String) gridItemList.get(position).get(DataSourceManager.KEY_GRID_ITEMNAME);
|
|
|
- //岗位
|
|
|
- String station = mPositionR.getText().toString().trim();//岗位资源
|
|
|
- if (StringUtil.isEmpty(station)) {
|
|
|
- CommonUtil.toastNoRepeat(this, "请先采集岗位资源");
|
|
|
- return;
|
|
|
- } else {
|
|
|
- //工单暂停,工单切换,实时报工
|
|
|
- if (TextUtils.isEmpty(mStaffCode) && (GloableParams.GRIDNAME_WORK_PAUSE.equals(itemName)
|
|
|
- || GloableParams.GRIDNAME_WORK_SWITCH.equals(itemName)
|
|
|
-// || GloableParams.GRIDNAME_TIME_REPORT.equals(itemName)
|
|
|
- || GloableParams.GRIDNAME_TIME_REPORT_DETAIL.equals(itemName))) {
|
|
|
- CommonUtil.toastNoRepeat(this, "当前没有上线人员,请先进行人员上线");
|
|
|
- } else {
|
|
|
- //工单号为空,启动工单
|
|
|
- String workOrder = mCurDoc.getText().toString().trim();
|
|
|
- //工步移交和工步接收
|
|
|
- if(GloableParams.GRIDNAME_STEP_TRANSFER.equals(itemName)
|
|
|
- ||GloableParams.GRIDNAME_STEP_RECEIVE.equals(itemName)
|
|
|
- ||GloableParams.GRIDNAME_BULIANG_CAIJI.equals(itemName)
|
|
|
- ||GloableParams.GRIDNAME_CHAI_PI.equals(itemName)
|
|
|
- ||GloableParams.GRIDNAME_TIAO_ZHAN.equals(itemName)
|
|
|
- ||GloableParams.GRIDNAME_TIME_REPORT.equals(itemName)
|
|
|
- ||GloableParams.GRIDNAME_HE_PI.equals(itemName)){
|
|
|
- goFragment(position);
|
|
|
- }else if(GloableParams.GRIDNAME_WORK_PAUSE.equals(itemName)){//解除绑定
|
|
|
- if(TextUtils.isEmpty(workOrder)){
|
|
|
- CommonUtil.toastNoRepeat(this, "暂无在线工单,无法进行解除绑定操作");
|
|
|
- return;
|
|
|
- }
|
|
|
- List<Master> masterList = DataSourceManager.getDataSourceManager().getMasterList();
|
|
|
- String maName = masterList.get(position).getMaName();
|
|
|
- String userName = SharedPreUtil.getString(this, "user_name", null);
|
|
|
- pageType = VolleyUtil.FRAGMENT_LOGIN;
|
|
|
- Dialog dia = new Dialog(IndexActivity.this);
|
|
|
- dia.setContentView(R.layout.dialog_custom);
|
|
|
- CheckBox check_alldelete = dia.findViewById(R.id.check_alldelete);
|
|
|
- LinearLayout lineone = dia.findViewById(R.id.lineone);
|
|
|
- LinearLayout linetwo = dia.findViewById(R.id.linetwo);
|
|
|
- TextView tv_info = dia.findViewById(R.id.tv_info);
|
|
|
- ClearableEditText et_pwd_login = dia.findViewById(R.id.et_pwd_login);
|
|
|
- Button btn_cancel = dia.findViewById(R.id.btn_cancel);//取消
|
|
|
- Button btn_confirm = dia.findViewById(R.id.btn_confirm);//确定
|
|
|
- tv_info.setText("工单:"+workOrder);
|
|
|
- dia.show();
|
|
|
- check_alldelete.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
- @Override
|
|
|
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
|
|
- if (isChecked==true){
|
|
|
- lineone.setVisibility(View.GONE);
|
|
|
- linetwo.setVisibility(View.VISIBLE);
|
|
|
- }else {
|
|
|
- lineone.setVisibility(View.VISIBLE);
|
|
|
- linetwo.setVisibility(View.GONE);
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- dia.setCanceledOnTouchOutside(true);
|
|
|
- btn_confirm.setOnClickListener(new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View v) {
|
|
|
- String password = SharedPreUtil.getString(IndexActivity.this, Constants.FLAG.LOGINPASSOWRD, null);
|
|
|
- String et_pwd_logintrim = et_pwd_login.getText().toString().trim();
|
|
|
- if (check_alldelete.isChecked()){
|
|
|
- if (et_pwd_logintrim.isEmpty()){
|
|
|
- CommonUtil.toastNoRepeat(IndexActivity.this,"请输入密码");
|
|
|
- return;
|
|
|
- }
|
|
|
- if (!StringUtil.isEmpty(password)){
|
|
|
- if (et_pwd_logintrim.equals(password)){
|
|
|
- getalldeltes(workOrder);
|
|
|
- dia.dismiss();
|
|
|
- }else {
|
|
|
- CommonUtil.toastNoRepeat(IndexActivity.this, "密码不正确");
|
|
|
- }
|
|
|
- }
|
|
|
- }else {
|
|
|
- getDatagong(workOrder);
|
|
|
- dia.dismiss();
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- btn_cancel.setOnClickListener(new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View v) {
|
|
|
- dia.dismiss();
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- }else{
|
|
|
- if (StringUtil.isEmpty(workOrder)){
|
|
|
- //工单启动,人员换岗
|
|
|
- if (GloableParams.GRIDNAME_WORK_START.equals(itemName)) {
|
|
|
- goFragment(position);
|
|
|
- } else {
|
|
|
- CommonUtil.toastNoRepeat(this, "暂无在线工单,可点击工单绑定进行操作");
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (GloableParams.GRIDNAME_WORK_START.equals(itemName)) {//工单启动
|
|
|
- CommonUtil.toastNoRepeat(this, "已有在线工单不需要进行工单绑定");
|
|
|
- } else {
|
|
|
- goFragment(position);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Subscribe
|
|
|
- public void onMessageEvent(MoreEventBusBean evensst) {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- //全部删除
|
|
|
- public void getalldeltes(String workOrder){
|
|
|
- progressDialog.show();
|
|
|
- VollyRequest.getInstance().stringRequest(mStringRequest,
|
|
|
- new HttpParams.Builder()
|
|
|
- .url(GloableParams.ADDRESS_PDA_DELETEMSSALL)
|
|
|
- .method(Request.Method.POST)
|
|
|
- .tag(TAG + "deleteMSSAll")
|
|
|
- .flag(0)
|
|
|
- .addParam("ma_code",workOrder)
|
|
|
- .addParam("sc_code", mPositionR.getText().toString().trim())
|
|
|
- .build(), new HttpCallback() {
|
|
|
- @Override
|
|
|
- public void onSuccess(int flag, Object o) throws Exception {
|
|
|
- try {
|
|
|
- progressDialog.dismiss();
|
|
|
- Boolean isSuccess = FastjsonUtil.getBoolean(o.toString(), "success");
|
|
|
- if (isSuccess) {
|
|
|
-// JSONObject dataObject = FastjsonUtil.getJSONObject(o.toString(),"data");
|
|
|
- getDatagong(workOrder);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- } catch (Exception e) {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onFail(int flag, String failStr) throws Exception {
|
|
|
- progressDialog.dismiss();
|
|
|
- CommonUtil.toastNoRepeat(IndexActivity.this, failStr);
|
|
|
- }
|
|
|
-
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- //解除绑定
|
|
|
- public void getDatagong(String workOrder){
|
|
|
- Log.e("workOrder",workOrder);
|
|
|
- Log.e("mPositionR",mPositionR.getText().toString().trim());
|
|
|
- progressDialog.show();
|
|
|
- VollyRequest.getInstance().stringRequest(mStringRequest,
|
|
|
- new HttpParams.Builder()
|
|
|
- .url(GloableParams.ADDRESS_PDA_STOPMA)
|
|
|
- .method(Request.Method.POST)
|
|
|
- .tag("stopMa")
|
|
|
- .flag(0)
|
|
|
- .addParam("ma_code",workOrder)
|
|
|
- .addParam("sc_code",mPositionR.getText().toString().trim())
|
|
|
- .build(), new HttpCallback() {
|
|
|
- @Override
|
|
|
- public void onSuccess(int flag, Object o) throws Exception {
|
|
|
- Boolean isSuccess = FastjsonUtil.getBoolean(o.toString(),"success");
|
|
|
- if (isSuccess){
|
|
|
- CommonUtil.toastNoRepeat(IndexActivity.this,"解绑成功!");
|
|
|
- JSONObject dataObject = FastjsonUtil.getJSONObject(o.toString(),"data");
|
|
|
- Intent intent = new Intent(IndexActivity.this, IndexActivity.class);
|
|
|
- intent.putExtra(Constants.FLAG.SC_CODE,sc_code);
|
|
|
- startActivity(intent);
|
|
|
- Log.e("密码","解绑成功");
|
|
|
- }else{
|
|
|
- CommonUtil.toastNoRepeat(IndexActivity.this,"解绑失败!");
|
|
|
- }
|
|
|
- progressDialog.dismiss();
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onFail(int flag, String failStr) throws Exception {
|
|
|
- progressDialog.dismiss();
|
|
|
- CommonUtil.toastNoRepeat(IndexActivity.this, failStr);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- private void staffDown() {
|
|
|
- progressDialog.show();
|
|
|
- VollyRequest.getInstance().stringRequest(new HttpParams.Builder()
|
|
|
- .url(GloableParams.ADDRESS_PDASHOP_DOWNSORUCEMAN)
|
|
|
- .method(Request.Method.POST)
|
|
|
- .addParam("sc_code", sc_code)
|
|
|
- .addParam("em_code", SharedPreUtil.getString(this, Constants.FLAG.CACHE_USER_EMCODE, ""))
|
|
|
- .build(), new HttpCallback() {
|
|
|
- @Override
|
|
|
- public void onSuccess(int flag, Object o) throws Exception {
|
|
|
- progressDialog.dismiss();
|
|
|
- try {
|
|
|
- CommonUtil.toastNoRepeat(IndexActivity.this, "人员下线成功");
|
|
|
- String result = o.toString();
|
|
|
- JSONObject resultObject = JSON.parseObject(result);
|
|
|
- JSONObject dataObject = FastjsonUtil.getJSONObject(resultObject, "data");
|
|
|
- showDataView(dataObject);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onFail(int flag, String failStr) throws Exception {
|
|
|
- progressDialog.dismiss();
|
|
|
- CommonUtil.toastNoRepeat(IndexActivity.this, failStr);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- private void goFragment(int position) {
|
|
|
- //将选中的ItemName传递给功能Activity(FunctionActivity)
|
|
|
- String itemName = (String) gridItemList.get(position).get(DataSourceManager.KEY_GRID_ITEMNAME);
|
|
|
- Intent intent = new Intent(IndexActivity.this, FunctionActivity.class);
|
|
|
- intent.putExtra(DataSourceManager.KEY_GRID_ITEMNAME, itemName);
|
|
|
- intent.putExtra(Constants.FLAG.SC_CODE, sc_code);
|
|
|
- intent.putExtra(Constants.FLAG.MA_CODE, mCurDoc.getText().toString());
|
|
|
- startActivity(intent);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onStaffScan() {
|
|
|
- if (CameraUtil.hasCamera()) {
|
|
|
- Intent intent = new Intent();
|
|
|
- intent.setClass(this, CaptureActivity.class);
|
|
|
- startActivityForResult(intent, SCAN_STAFF_CODE);
|
|
|
- } else {
|
|
|
- CommonUtil.toastNoRepeat(this, getString(R.string.no_camera_detected));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onStaffUp(String emid) {
|
|
|
- if (emid != null) {
|
|
|
- progressDialog.show();
|
|
|
- VollyRequest.getInstance().stringRequest(new HttpParams.Builder()
|
|
|
- .url(GloableParams.ADDRESS_PDASHOP_UPSORUCEMAN)
|
|
|
- .method(Request.Method.POST)
|
|
|
- .addParam("sc_code", sc_code)
|
|
|
- .addParam("em_id", emid)
|
|
|
- .addParam("em_code", SharedPreUtil.getString(this, Constants.FLAG.CACHE_USER_EMCODE, ""))
|
|
|
- .build(), new HttpCallback() {
|
|
|
- @Override
|
|
|
- public void onSuccess(int flag, Object o) throws Exception {
|
|
|
- progressDialog.dismiss();
|
|
|
- try {
|
|
|
- JSONObject dataObject = FastjsonUtil.getJSONObject(o.toString(), "data");
|
|
|
- showDataView(dataObject);
|
|
|
- mStaffUpPopup.dismiss();
|
|
|
- CommonUtil.toastNoRepeat(IndexActivity.this, "人员上线成功");
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onFail(int flag, String failStr) throws Exception {
|
|
|
- progressDialog.dismiss();
|
|
|
- CommonUtil.toastNoRepeat(IndexActivity.this, failStr);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
|
|
- super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
|
|
- if (requestCode == PermissionUtil.DEFAULT_REQUEST) {
|
|
|
- if (grantResults.length != 1 || grantResults[0] != PackageManager.PERMISSION_GRANTED) {
|
|
|
- //没有获取到权限
|
|
|
- } else {
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onBackPressed() {
|
|
|
- super.onBackPressed();
|
|
|
- /*if (mExitPopupWindow.isShowing()) {
|
|
|
- closeExitPopupWindow();
|
|
|
- } else {
|
|
|
- if (mExitPopupWindow != null) {
|
|
|
- CommonUtil.setBackgroundAlpha(this, 0.5f);
|
|
|
- mExitPopupWindow.showAtLocation(getWindow().getDecorView(), Gravity.CENTER, 0, 0);
|
|
|
- }
|
|
|
- }*/
|
|
|
- }
|
|
|
- private void getPrintTemplate() {
|
|
|
- VolleyRequest.getInstance().stringRequest(mStringRequest,
|
|
|
- new HttpParams.Builder()
|
|
|
- .url(GloableParams.ADDRESS_BARINFO_PRINTMODEL)
|
|
|
- .method(Request.Method.GET)
|
|
|
- .flag(0)
|
|
|
- .tag("barinfoPrint")
|
|
|
- .addParam("caller", "Lotno!PDAPrint")//Barcode!PDAPrint仓库
|
|
|
- .build(), new HttpCallback() {
|
|
|
- @Override
|
|
|
- public void onSuccess(int flag, Object o) throws Exception {
|
|
|
- try {
|
|
|
- String result = o.toString();
|
|
|
- Log.e("prints", result);
|
|
|
- if (FastjsonUtil.validate(result)) {
|
|
|
- JSONObject resultObject = JSON.parseObject(result);
|
|
|
- JSONArray dataArray = resultObject.getJSONArray("data");
|
|
|
- if (dataArray != null && dataArray.size() > 0) {
|
|
|
- SharedPreUtil.saveString(IndexActivity.this, Constants.FLAG.PRINT_TEMPLATE_CACHE, dataArray.toJSONString());
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onFail(int flag, String failStr) throws Exception {
|
|
|
- Log.e("printf", failStr);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- private void closeExitPopupWindow() {
|
|
|
- if (mExitPopupWindow != null) {
|
|
|
- mExitPopupWindow.dismiss();
|
|
|
- CommonUtil.setBackgroundAlpha(this, 1f);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-}
|