From 38ee648bb18bd608173d081267a4591e728c40fc Mon Sep 17 00:00:00 2001 From: wangh <123456> Date: Thu, 18 Jan 2024 17:38:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20=E5=87=BA=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../example/beijing_daxing/CheckActivity.java | 5 +- .../beijing_daxing/HomePageActivity.java | 8 +- .../example/beijing_daxing/OutActivity.java | 83 +++++++++++++++++- .../beijing_daxing/base/MyApplication.java | 6 +- .../example/beijing_daxing/vm/OutStoreVm.java | 15 +++- app/src/main/res/layout/activity_check.xml | 2 - app/src/main/res/layout/activity_out.xml | 17 +++- app/src/main/res/mipmap-xhdpi/main_bg.png | Bin 441989 -> 0 bytes 8 files changed, 119 insertions(+), 17 deletions(-) delete mode 100644 app/src/main/res/mipmap-xhdpi/main_bg.png diff --git a/app/src/main/java/com/example/beijing_daxing/CheckActivity.java b/app/src/main/java/com/example/beijing_daxing/CheckActivity.java index a2afd1a..85ffec0 100644 --- a/app/src/main/java/com/example/beijing_daxing/CheckActivity.java +++ b/app/src/main/java/com/example/beijing_daxing/CheckActivity.java @@ -1,14 +1,17 @@ package com.example.beijing_daxing; import androidx.appcompat.app.AppCompatActivity; +import androidx.databinding.DataBindingUtil; import android.os.Bundle; +import com.example.beijing_daxing.databinding.ActivityCheckBinding; + public class CheckActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.activity_check); + ActivityCheckBinding binding= DataBindingUtil.setContentView(this,R.layout.activity_check); } } \ No newline at end of file diff --git a/app/src/main/java/com/example/beijing_daxing/HomePageActivity.java b/app/src/main/java/com/example/beijing_daxing/HomePageActivity.java index b5aef5d..4c02bf1 100644 --- a/app/src/main/java/com/example/beijing_daxing/HomePageActivity.java +++ b/app/src/main/java/com/example/beijing_daxing/HomePageActivity.java @@ -25,9 +25,13 @@ public class HomePageActivity extends AppCompatActivity { super.onCreate(savedInstanceState); ActivityHomePageBinding binding= DataBindingUtil. setContentView(this,R.layout.activity_home_page); List list = new ArrayList<>(); - list.add(new HomeIcon(R.mipmap.home_in, "轮挡入库", InActivity.class)); - list.add(new HomeIcon(R.mipmap.home_out, "轮挡领用出库", OutActivity.class)); + list.add(new HomeIcon(R.mipmap.home_in1, "轮挡入库", InActivity.class)); + list.add(new HomeIcon(R.mipmap.home_out1, "轮挡领用出库", OutActivity.class)); + list.add(new HomeIcon(R.mipmap.home_store_check, "仓库盘点", OutActivity.class)); list.add(new HomeIcon(R.mipmap.home_check, "轮挡巡检", CheckActivity.class)); + list.add(new HomeIcon(R.mipmap.home_check, "轮挡报废", CheckActivity.class)); + list.add(new HomeIcon(R.mipmap.home_in, "废品入库", CheckActivity.class)); + list.add(new HomeIcon(R.mipmap.home_out, "废品出库", CheckActivity.class)); /* try { if (!loginUser.equals("admin")) { diff --git a/app/src/main/java/com/example/beijing_daxing/OutActivity.java b/app/src/main/java/com/example/beijing_daxing/OutActivity.java index 9330dfd..1207231 100644 --- a/app/src/main/java/com/example/beijing_daxing/OutActivity.java +++ b/app/src/main/java/com/example/beijing_daxing/OutActivity.java @@ -1,14 +1,89 @@ package com.example.beijing_daxing; import androidx.appcompat.app.AppCompatActivity; - +import androidx.databinding.DataBindingUtil; import android.os.Bundle; +import android.view.View; +import android.widget.Toast; +import com.example.beijing_daxing.adapter.InAdapter; +import com.example.beijing_daxing.base.AdapterClickCall; +import com.example.beijing_daxing.base.BaseActivity; +import com.example.beijing_daxing.base.MyRecultCall; +import com.example.beijing_daxing.base.MyResult; +import com.example.beijing_daxing.been.InStoreSelectBody; +import com.example.beijing_daxing.databinding.ActivityOutBinding; +import com.example.beijing_daxing.entity.BaseLocation; +import com.example.beijing_daxing.uitls.SharedPreferencesUtils; +import com.example.beijing_daxing.vm.OutStoreVm; +import com.google.gson.reflect.TypeToken; +import com.lzy.okgo.OkGo; +import com.lzy.okgo.model.Response; +import java.util.ArrayList; +import java.util.List; +import okhttp3.RequestBody; -public class OutActivity extends AppCompatActivity { - +public class OutActivity extends BaseActivity implements AdapterClickCall { + private InAdapter adapter; + private OutStoreVm outVm; + private List epcList; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.activity_out); + ActivityOutBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_out); + adapter=new InAdapter(this); + epcList=new ArrayList<>(); + adapter.setList(epcList); + adapter.setAdapterClickCall(this); + binding.setAdapter(adapter); + outVm=new OutStoreVm(); + binding.setVm(outVm); + initRequest(); + } + + @Override + protected void sanRfid(List epcs) { + epcs.stream().forEach(t -> { + if (!epcList.contains(t)) { + epcList.add(t); + } + }); + adapter.notifyDataSetChanged(); } + + @Override + public void clickItem(int index) { + epcList.remove(index); + adapter.notifyDataSetChanged(); + } + private void initRequest() { + OkGo.post(url + "/outStore/select").tag(this).execute(new MyRecultCall(dialog, this) { + @Override + public void onSuccess(Response response) { + super.onSuccess(response); + List baseLocationList=gson.fromJson(response.body().getData().toString(), new TypeToken>(){}.getType()); + outVm.setAreaList(baseLocationList); + } + }); + } + public void out_submit(View view) { + String useUser = outVm.getUseUser(); + if (useUser == null || epcList.isEmpty()) return; + outVm.setEpcList(epcList); + outVm.setSubmitUser(SharedPreferencesUtils.getstring("user","test")); + OkGo.post(url + "/outStore/submit") + .upRequestBody(RequestBody.create(JSON, gson.toJson(outVm))) + .execute(new MyRecultCall(dialog,this){ + @Override + public void onSuccess(Response response) { + super.onSuccess(response); + if (response.body().getCode()==0){ + Toast.makeText(OutActivity.this, "提交成功", Toast.LENGTH_SHORT).show(); + finish(); + }else { + Toast.makeText(OutActivity.this, response.body().getMsg(), Toast.LENGTH_SHORT).show(); + } + } + }); + } + } \ No newline at end of file diff --git a/app/src/main/java/com/example/beijing_daxing/base/MyApplication.java b/app/src/main/java/com/example/beijing_daxing/base/MyApplication.java index 37c3c27..68fcf72 100644 --- a/app/src/main/java/com/example/beijing_daxing/base/MyApplication.java +++ b/app/src/main/java/com/example/beijing_daxing/base/MyApplication.java @@ -60,11 +60,11 @@ public class MyApplication extends Application { builder.sslSocketFactory(sslParams1.sSLSocketFactory, sslParams1.trustManager); builder.addInterceptor(loggingInterceptor); // 全局的读取超时时间 - builder.readTimeout(OkGo.DEFAULT_MILLISECONDS, TimeUnit.MILLISECONDS); + builder.readTimeout(3000, TimeUnit.MILLISECONDS); // 全局的写入超时时间 - builder.writeTimeout(OkGo.DEFAULT_MILLISECONDS, TimeUnit.MILLISECONDS); + builder.writeTimeout(3000, TimeUnit.MILLISECONDS); // 全局的连接超时时间 - builder.connectTimeout(OkGo.DEFAULT_MILLISECONDS, TimeUnit.MILLISECONDS); + builder.connectTimeout(3000, TimeUnit.MILLISECONDS); // 使用内存保持cookie,app退出后,cookie消失 builder.cookieJar(new CookieJarImpl(new MemoryCookieStore())); OkGo.getInstance().init(this).setOkHttpClient(builder.build()) // 建议设置OkHttpClient,不设置将使用默认的 diff --git a/app/src/main/java/com/example/beijing_daxing/vm/OutStoreVm.java b/app/src/main/java/com/example/beijing_daxing/vm/OutStoreVm.java index d590efc..5d6498f 100644 --- a/app/src/main/java/com/example/beijing_daxing/vm/OutStoreVm.java +++ b/app/src/main/java/com/example/beijing_daxing/vm/OutStoreVm.java @@ -1,7 +1,13 @@ package com.example.beijing_daxing.vm; +import android.view.View; +import android.widget.AdapterView; + import androidx.databinding.BaseObservable; +import com.example.beijing_daxing.entity.BaseLocation; + +import java.util.ArrayList; import java.util.List; /** @@ -16,6 +22,9 @@ public class OutStoreVm extends BaseObservable { private List areaList; + public void selectAreaCode(AdapterView adapterView, View view,int p,long id){ + this.areaCode=areaList.get(p); + } public List getEpcList() { return epcList; @@ -53,7 +62,9 @@ public class OutStoreVm extends BaseObservable { return areaList; } - public void setAreaList(List areaList) { - this.areaList = areaList; + public void setAreaList( List baseLocationList) { + areaList=new ArrayList<>(); + baseLocationList.forEach(t->areaList.add(t.getLocationCode())); + notifyChange(); } } diff --git a/app/src/main/res/layout/activity_check.xml b/app/src/main/res/layout/activity_check.xml index ceb565a..6f9c2d7 100644 --- a/app/src/main/res/layout/activity_check.xml +++ b/app/src/main/res/layout/activity_check.xml @@ -27,7 +27,6 @@ @@ -60,7 +59,6 @@ android:layout_width="110dp" android:layout_height="match_parent" android:background="@color/bg1" - android:text="选择原因:" /> + + android:textAlignment="center" + android:onItemSelected="@{vm.selectAreaCode}" + android:entries="@{vm.areaList}"/> + android:layout_height="match_parent" + android:maxLines="1" + android:singleLine="true" + android:imeOptions="actionDone" + android:text="@={vm.useUser}"/>