|
|
@@ -0,0 +1,345 @@
|
|
|
+package com.uas.rd_equipment.fragment;
|
|
|
+
|
|
|
+import android.app.Activity;
|
|
|
+import android.content.Intent;
|
|
|
+import android.graphics.Color;
|
|
|
+import android.view.KeyEvent;
|
|
|
+import android.view.View;
|
|
|
+import android.view.inputmethod.EditorInfo;
|
|
|
+import android.widget.AdapterView;
|
|
|
+import android.widget.ArrayAdapter;
|
|
|
+import android.widget.Button;
|
|
|
+import android.widget.ImageView;
|
|
|
+import android.widget.Spinner;
|
|
|
+import android.widget.TextView;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.android.volley.Request;
|
|
|
+import com.uas.rd_equipment.R;
|
|
|
+import com.uas.rd_equipment.activity.FunctionActivity;
|
|
|
+import com.uas.rd_equipment.camera.CaptureActivity;
|
|
|
+import com.uas.rd_equipment.camera.CodeUtils;
|
|
|
+import com.uas.rd_equipment.global.GloableParams;
|
|
|
+import com.uas.rd_equipment.tools.SharedPreUtil;
|
|
|
+import com.uas.rd_equipment.util.CameraUtil;
|
|
|
+import com.uas.rd_equipment.util.CommonUtil;
|
|
|
+import com.uas.rd_equipment.util.Constants;
|
|
|
+import com.uas.rd_equipment.util.FastjsonUtil;
|
|
|
+import com.uas.rd_equipment.util.HttpCallback;
|
|
|
+import com.uas.rd_equipment.util.HttpParams;
|
|
|
+import com.uas.rd_equipment.util.StringUtil;
|
|
|
+import com.uas.rd_equipment.util.VollyRequest;
|
|
|
+import com.uas.rd_equipment.view.ClearableEditText;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Created by cjh-sail on 2023-02-01
|
|
|
+ */
|
|
|
+public class DeviceStatusChangeFragment extends BaseFragment implements AdapterView.OnItemSelectedListener{
|
|
|
+
|
|
|
+
|
|
|
+ private Spinner spinner;
|
|
|
+ private ArrayAdapter adapter;
|
|
|
+ private String dc_code;
|
|
|
+ private String dc_emname;
|
|
|
+ private String dc_devcode;
|
|
|
+ private String de_name;
|
|
|
+ private String dc_reason;
|
|
|
+ private String dc_remark;
|
|
|
+ private String dc_id;
|
|
|
+ private String maintenanceType;
|
|
|
+ private static final int SCAN_BARCODE_CODE = 111;
|
|
|
+ private ClearableEditText ce_de_code;
|
|
|
+ private ImageView storage_recharge_scan_iv;
|
|
|
+ private String de_code;
|
|
|
+ private int mFocusId;
|
|
|
+ private Button btn_commit;
|
|
|
+ private TextView tv_prompt;
|
|
|
+ private List<String> linecodeBeanList;
|
|
|
+ private TextView tv_de_code;
|
|
|
+ private TextView tv_de_name;
|
|
|
+ private TextView tv_de_spec;
|
|
|
+ private TextView tv_de_currentcentername;
|
|
|
+ private TextView tv_de_currentlinecode;
|
|
|
+ private TextView tv_de_lefttime;
|
|
|
+ private TextView tv_de_manageman;
|
|
|
+ private TextView de_managemantel;
|
|
|
+ private TextView tv_de_vendor;
|
|
|
+ private TextView tv_de_contact;
|
|
|
+ private TextView tv_de_telvendor;
|
|
|
+ private String de_runstatus;
|
|
|
+ private TextView tv_de_status;
|
|
|
+ private ClearableEditText cle_change;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected int getLayout() {
|
|
|
+ return R.layout.fragment_devicestatuschange;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initViews() {
|
|
|
+ FunctionActivity.setTitle(getString(R.string.title_storage_CHANGE));
|
|
|
+
|
|
|
+ spinner = root.findViewById(R.id.spinner02);
|
|
|
+ ce_de_code = root.findViewById(R.id.ce_de_code);
|
|
|
+ storage_recharge_scan_iv = root.findViewById(R.id.storage_recharge_scan_iv);
|
|
|
+ btn_commit = root.findViewById(R.id.btn_commit);
|
|
|
+ tv_prompt = root.findViewById(R.id.tv_prompt);
|
|
|
+ tv_de_code = root.findViewById(R.id.tv_de_code);
|
|
|
+ tv_de_name = root.findViewById(R.id.tv_de_name);
|
|
|
+ tv_de_spec = root.findViewById(R.id.tv_de_spec);
|
|
|
+ tv_de_currentcentername = root.findViewById(R.id.tv_de_currentcentername);
|
|
|
+ tv_de_currentlinecode = root.findViewById(R.id.tv_de_currentlinecode);
|
|
|
+ tv_de_lefttime = root.findViewById(R.id.tv_de_lefttime);
|
|
|
+ tv_de_manageman = root.findViewById(R.id.tv_de_manageman);
|
|
|
+ de_managemantel = root.findViewById(R.id.de_managemantel);
|
|
|
+ tv_de_vendor = root.findViewById(R.id.tv_de_vendor);
|
|
|
+ tv_de_contact = root.findViewById(R.id.tv_de_contact);
|
|
|
+ tv_de_telvendor = root.findViewById(R.id.tv_de_telvendor);
|
|
|
+ tv_de_status = root.findViewById(R.id.tv_de_status);
|
|
|
+ cle_change = root.findViewById(R.id.cle_change);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ spinner.setOnItemSelectedListener(this);
|
|
|
+ ce_de_code.requestFocus();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initEvents() {
|
|
|
+ ce_de_code.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
|
|
+ @Override
|
|
|
+ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
|
|
+ if (actionId == EditorInfo.IME_ACTION_DONE
|
|
|
+ || actionId == EditorInfo.IME_ACTION_SEND
|
|
|
+ || (event != null && event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
|
|
|
+ String va_code = ce_de_code.getText().toString().trim();
|
|
|
+ getNewData(va_code);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ storage_recharge_scan_iv.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ ce_de_code.requestFocus();
|
|
|
+ if (CameraUtil.hasCamera()) {
|
|
|
+ if (root.findFocus() != null) {
|
|
|
+ mFocusId = root.findFocus().getId();
|
|
|
+ Intent intent = new Intent();
|
|
|
+ intent.setClass(mActivity, CaptureActivity.class);
|
|
|
+ startActivityForResult(intent, SCAN_BARCODE_CODE);
|
|
|
+ SharedPreUtil.saveString(mActivity, Constants.STORAGEERECHADD, "NO");
|
|
|
+ } else {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "请选择您要操作的输入框");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, getString(R.string.no_camera_detected));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initDatas() {
|
|
|
+ linecodeBeanList = new ArrayList<>();
|
|
|
+ linecodeBeanList.add("待使用");
|
|
|
+ linecodeBeanList.add("使用中");
|
|
|
+ linecodeBeanList.add("停用中");
|
|
|
+ linecodeBeanList.add("封存中");
|
|
|
+
|
|
|
+ adapter = new ArrayAdapter(mActivity,R.layout.item_sapinnerstr, R.id.text_spinner, linecodeBeanList);
|
|
|
+
|
|
|
+ spinner.setAdapter(adapter);
|
|
|
+
|
|
|
+ spinner.setVisibility(View.VISIBLE);
|
|
|
+ btn_commit.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ getNewCommitData();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //提交保存
|
|
|
+ public void getNewCommitData(){
|
|
|
+ if (cle_change.getText().toString().trim().isEmpty()){
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "请填写变更说明");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ progressDialog.show();
|
|
|
+ VollyRequest.getInstance().stringRequest(new HttpParams.Builder()
|
|
|
+ .url(GloableParams.ASTATIONTHE_SELECT_DEVICESTATUSCHANGE)
|
|
|
+ .method(Request.Method.GET)
|
|
|
+ .addParam("de_code",ce_de_code.getText().toString().trim())//de_code
|
|
|
+ .addParam("de_runstatus",maintenanceType)//maintenanceType
|
|
|
+ .addParam("dc_remark",cle_change.getText().toString().trim())
|
|
|
+ .build(), new HttpCallback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(int flag, Object o) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ tv_prompt.setVisibility(View.VISIBLE);
|
|
|
+ tv_prompt.setTextColor(Color.GREEN);
|
|
|
+ tv_prompt.setText("提交成功");
|
|
|
+ ce_de_code.setText("");
|
|
|
+ ce_de_code.requestFocus();
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ tv_prompt.setVisibility(View.VISIBLE);
|
|
|
+ tv_prompt.setTextColor(Color.RED);
|
|
|
+ tv_prompt.setText(failStr);
|
|
|
+ ce_de_code.setText("");
|
|
|
+ ce_de_code.requestFocus();
|
|
|
+// CommonUtil.toastNoRepeat(mActivity, failStr);
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
|
|
+ maintenanceType=linecodeBeanList.get(position);
|
|
|
+ if (maintenanceType.equals("待使用")){
|
|
|
+ maintenanceType="UNUSED";
|
|
|
+ }else if (maintenanceType.equals("使用中")){
|
|
|
+ maintenanceType="USING";
|
|
|
+ }else if (maintenanceType.equals("停用中")){
|
|
|
+ maintenanceType="STOP";
|
|
|
+ }else if (maintenanceType.equals("封存中")){
|
|
|
+ maintenanceType="SEALED";
|
|
|
+ }else {
|
|
|
+ maintenanceType="";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onNothingSelected(AdapterView<?> parent) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onFragmentBackPressed() {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onHiddenChanged(boolean hidden) {
|
|
|
+ super.onHiddenChanged(hidden);
|
|
|
+ if (hidden) {
|
|
|
+ ((FunctionActivity) getActivity()).setMoreBtnVisible(false);
|
|
|
+ } else {
|
|
|
+ FunctionActivity.setTitle(getString(R.string.title_storage_CHANGE));
|
|
|
+ ((FunctionActivity) getActivity()).setMoreBtnVisible(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public void getNewData(String de_codes){
|
|
|
+ progressDialog.show();
|
|
|
+ VollyRequest.getInstance().stringRequest(new HttpParams.Builder()
|
|
|
+ .url(GloableParams.ASTATIONTHE_SWEEP_DATA)
|
|
|
+ .method(Request.Method.GET)
|
|
|
+ .addParam("de_code", de_codes)
|
|
|
+ .addParam("checkdevice","nocheck")
|
|
|
+ .build(), new HttpCallback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(int flag, Object o) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ String result = o.toString();
|
|
|
+ JSONObject resultObject = JSON.parseObject(result);
|
|
|
+ JSONObject dataObject = resultObject.getJSONObject("device");
|
|
|
+ String de_code1 = FastjsonUtil.getText(dataObject, "DE_CODE");
|
|
|
+ String de_name1 = FastjsonUtil.getText(dataObject, "DE_NAME");
|
|
|
+ de_code = de_code1;
|
|
|
+ de_name=de_name1;
|
|
|
+
|
|
|
+ tv_de_code.setText(FastjsonUtil.getText(dataObject, "DE_CODE"));
|
|
|
+ tv_de_vendor.setText(FastjsonUtil.getText(dataObject, "DE_VENDOR"));
|
|
|
+ tv_de_name.setText(FastjsonUtil.getText(dataObject, "DE_NAME"));
|
|
|
+ tv_de_spec.setText(FastjsonUtil.getText(dataObject, "DE_SPEC"));
|
|
|
+ tv_de_currentcentername.setText(FastjsonUtil.getText(dataObject, "DE_CURRENTCENTERCODE"));
|
|
|
+ tv_de_contact.setText(FastjsonUtil.getText(dataObject, "DE_CONTACT"));
|
|
|
+ tv_de_telvendor.setText(FastjsonUtil.getText(dataObject, "DE_TELVENDOR"));
|
|
|
+ tv_de_currentlinecode.setText(FastjsonUtil.getText(dataObject, "DE_CURRENTLINECODE"));
|
|
|
+ tv_de_lefttime.setText(FastjsonUtil.getText(dataObject, "DE_LEFTTIME"));
|
|
|
+ tv_de_manageman.setText(FastjsonUtil.getText(dataObject, "DE_MANAGEMAN"));
|
|
|
+ de_managemantel.setText(FastjsonUtil.getText(dataObject, "DE_MANAGEPHONE"));
|
|
|
+ de_runstatus = FastjsonUtil.getText(dataObject, "DE_RUNSTATUS");//状态
|
|
|
+ if (!StringUtil.isEmpty(de_runstatus)){
|
|
|
+ if (de_runstatus.equals("UNUSED")){
|
|
|
+ tv_de_status.setText("待使用");
|
|
|
+ }else if (de_runstatus.equals("USING")){
|
|
|
+ tv_de_status.setText("使用中");
|
|
|
+ }else if (de_runstatus.equals("BREAKING")){
|
|
|
+ tv_de_status.setText("维修中");
|
|
|
+ }else if (de_runstatus.equals("CONIFRMBREAKING")){
|
|
|
+ tv_de_status.setText("故障待确认");
|
|
|
+ }else if (de_runstatus.equals("CONFIRMREPAIR")){
|
|
|
+ tv_de_status.setText("维修待确认");
|
|
|
+ }else if (de_runstatus.equals("REVIEW")){
|
|
|
+ tv_de_status.setText("待评审");
|
|
|
+ }else if (de_runstatus.equals("SCRAP")){
|
|
|
+ tv_de_status.setText("已报废");
|
|
|
+ }else if (de_runstatus.equals("UNTALLY")){
|
|
|
+ tv_de_status.setText("待点检");
|
|
|
+ }else if (de_runstatus.equals("STOP")){
|
|
|
+ tv_de_status.setText("停用中");
|
|
|
+ }else if (de_runstatus.equals("SEALED")){
|
|
|
+ tv_de_status.setText("封存中");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, failStr);
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
+ super.onActivityResult(requestCode, resultCode, data);
|
|
|
+ if (resultCode != Activity.RESULT_OK) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (requestCode == SCAN_BARCODE_CODE && data != null) {
|
|
|
+ if (data.getExtras() != null) {
|
|
|
+ String result = data.getExtras().getString(CodeUtils.RESULT_STRING);
|
|
|
+ if (mFocusId == R.id.ce_de_code) {
|
|
|
+ ce_de_code.setText(result);
|
|
|
+ ce_de_code.setSelection(result.length());
|
|
|
+ getNewData(result);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|