From b004429c81fd3179f5fb408fc56f2657e3c0ebb9 Mon Sep 17 00:00:00 2001 From: wanghao Date: Fri, 1 Nov 2024 10:30:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20=E5=BA=93=E4=BD=8D?= =?UTF-8?q?=E9=94=81=E5=AE=9A=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/deploymentTargetDropDown.xml | 17 ++++ app/src/main/AndroidManifest.xml | 5 +- .../jingyuan_mes/HomePageActivity.java | 2 + .../adapter/store/LockLocationAdapter.java | 71 ++++++++++++++ .../entity/store/LocationLockInfo.java | 24 +++++ .../store/LocationlockingActivity.java | 96 +++++++++++++++++++ .../res/layout/activity_locationlocking.xml | 89 +++++++++++++++++ .../main/res/layout/item_lock_location.xml | 35 +++++++ .../res/layout/item_product_out_apply.xml | 2 +- 9 files changed, 339 insertions(+), 2 deletions(-) create mode 100644 .idea/deploymentTargetDropDown.xml create mode 100644 app/src/main/java/com/example/jingyuan_mes/adapter/store/LockLocationAdapter.java create mode 100644 app/src/main/java/com/example/jingyuan_mes/entity/store/LocationLockInfo.java create mode 100644 app/src/main/java/com/example/jingyuan_mes/store/LocationlockingActivity.java create mode 100644 app/src/main/res/layout/activity_locationlocking.xml create mode 100644 app/src/main/res/layout/item_lock_location.xml diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml new file mode 100644 index 0000000..386c62e --- /dev/null +++ b/.idea/deploymentTargetDropDown.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 7e90762..94f041b 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -32,12 +32,15 @@ android:theme="@style/Theme.Jingyuanmes" android:usesCleartextTraffic="true" tools:targetApi="31"> + + android:exported="true" /> diff --git a/app/src/main/java/com/example/jingyuan_mes/HomePageActivity.java b/app/src/main/java/com/example/jingyuan_mes/HomePageActivity.java index 7b2d902..37100e5 100644 --- a/app/src/main/java/com/example/jingyuan_mes/HomePageActivity.java +++ b/app/src/main/java/com/example/jingyuan_mes/HomePageActivity.java @@ -23,6 +23,7 @@ import com.example.jingyuan_mes.entity.MenuBeen; import com.example.jingyuan_mes.entity.store.PdaRouters; import com.example.jingyuan_mes.store.AssemblyOutActivity; import com.example.jingyuan_mes.store.InventoryTaskActivity; +import com.example.jingyuan_mes.store.LocationlockingActivity; import com.example.jingyuan_mes.store.MaterialInActivity; import com.example.jingyuan_mes.store.MaterialOutListActivity; import com.example.jingyuan_mes.store.MaterialPassActivity; @@ -87,6 +88,7 @@ public class HomePageActivity extends BaseActivity implements ItemClickCall { map.put("人工移库", RelocationTaskActivity.class); map.put("人工合库", RelocationTaskActivity.class); map.put("库存盘点", InventoryTaskActivity.class); + map.put("库位锁定/解锁", LocationlockingActivity.class); } private void initRequest() { diff --git a/app/src/main/java/com/example/jingyuan_mes/adapter/store/LockLocationAdapter.java b/app/src/main/java/com/example/jingyuan_mes/adapter/store/LockLocationAdapter.java new file mode 100644 index 0000000..334a3fa --- /dev/null +++ b/app/src/main/java/com/example/jingyuan_mes/adapter/store/LockLocationAdapter.java @@ -0,0 +1,71 @@ +package com.example.jingyuan_mes.adapter.store; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.databinding.DataBindingUtil; +import androidx.recyclerview.widget.RecyclerView; + +import com.example.jingyuan_mes.BR; +import com.example.jingyuan_mes.R; +import com.example.jingyuan_mes.databinding.ItemInventoryTaskBinding; +import com.example.jingyuan_mes.databinding.ItemLockLocationBinding; +import com.example.jingyuan_mes.entity.store.InventoryTaskBeen; +import com.example.jingyuan_mes.entity.store.LocationLockInfo; + +import java.util.List; + +/** + * @author wanghao + * @date 2024/1/31 15:18 + */ +public class LockLocationAdapter extends RecyclerView.Adapter { + private List list; + private Context context; + private LayoutInflater inflater; + + public LockLocationAdapter(Context context) { + this.context = context; + inflater = LayoutInflater.from(context); + } + + public void setList(List list) { + this.list = list; + } + + @NonNull + @Override + public ItemtViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + ItemLockLocationBinding binding = DataBindingUtil.inflate(inflater, R.layout.item_lock_location, parent, false); + return new ItemtViewHolder(binding); + } + + @Override + public void onBindViewHolder(@NonNull ItemtViewHolder holder, int position) { + var rawReturn = list.get(position); + var binding = holder.binding; + binding.setVariable(BR.vm,rawReturn); + } + + @Override + public int getItemCount() { + return list==null?0:list.size(); + } + + static class ItemtViewHolder extends RecyclerView.ViewHolder { + private ItemLockLocationBinding binding; + + public ItemtViewHolder(ItemLockLocationBinding binding) { + super(binding.getRoot()); + this.binding = binding; + } + + + } + + public interface MyItemClickCall{ + void onClick(int index,boolean tag); + } +} diff --git a/app/src/main/java/com/example/jingyuan_mes/entity/store/LocationLockInfo.java b/app/src/main/java/com/example/jingyuan_mes/entity/store/LocationLockInfo.java new file mode 100644 index 0000000..e0d376b --- /dev/null +++ b/app/src/main/java/com/example/jingyuan_mes/entity/store/LocationLockInfo.java @@ -0,0 +1,24 @@ +package com.example.jingyuan_mes.entity.store; + +import java.util.List; + +public class LocationLockInfo { + private String warehouseName; + private List locationCodes; + + public String getWarehouseName() { + return warehouseName; + } + + public void setWarehouseName(String warehouseName) { + this.warehouseName = warehouseName; + } + + public List getLocationCodes() { + return locationCodes; + } + + public void setLocationCodes(List locationCodes) { + this.locationCodes = locationCodes; + } +} diff --git a/app/src/main/java/com/example/jingyuan_mes/store/LocationlockingActivity.java b/app/src/main/java/com/example/jingyuan_mes/store/LocationlockingActivity.java new file mode 100644 index 0000000..e9f4480 --- /dev/null +++ b/app/src/main/java/com/example/jingyuan_mes/store/LocationlockingActivity.java @@ -0,0 +1,96 @@ +package com.example.jingyuan_mes.store; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.databinding.DataBindingUtil; +import androidx.databinding.ObservableBoolean; +import androidx.lifecycle.Observer; + +import android.database.Observable; +import android.os.Bundle; +import android.view.View; +import android.widget.Toast; + +import com.example.jingyuan_mes.R; +import com.example.jingyuan_mes.adapter.store.LockLocationAdapter; +import com.example.jingyuan_mes.base.BaseActivity; +import com.example.jingyuan_mes.base.MyRecultCall; +import com.example.jingyuan_mes.base.MyResult; +import com.example.jingyuan_mes.databinding.ActivityLocationlockingBinding; +import com.example.jingyuan_mes.entity.store.LocationLockInfo; +import com.example.jingyuan_mes.uitls.SharedPreferencesUtils; +import com.google.gson.reflect.TypeToken; +import com.lzy.okgo.OkGo; +import com.lzy.okgo.model.Response; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import okhttp3.RequestBody; + +public class LocationlockingActivity extends BaseActivity { +private ActivityLocationlockingBinding binding; +private LockLocationAdapter adapter; + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + binding = DataBindingUtil.setContentView(this, R.layout.activity_locationlocking); + adapter=new LockLocationAdapter(this); + binding.setAdapter(adapter); + + } + + @Override + protected void onResume() { + super.onResume(); + requestLocationList(); + } +private void requestLocationList(){ + OkGo.get(url + "/wms/mobile/getLockLocations") + .headers("Authorization", SharedPreferencesUtils.getstring("access_token", "")) + .execute(new MyRecultCall(dialog, this) { + @Override + public void onSuccess(Response response) { + super.onSuccess(response); + var body = response.body(); + if (body.getCode() == 200) { + // List list=gson.fromJson(body.getData().toString(),new TypeToken<>(){}.getType()); + // adapter.setList(list); + // adapter.notifyDataSetChanged(); + return; + } + String msg = body.getMsg(); + Toast.makeText(context, msg==null?"操作失败":msg, Toast.LENGTH_SHORT).show(); + } + }); +} + public void lockLocation(View view) { + requestLock("lockLocation"); + + } + + public void unLockLocation(View view) { + requestLock("unlockLocation"); + } + + private void requestLock(String uri) { + Map map=new HashMap<>(); + map.put("locationCode",binding.lockLocation.getText().toString().trim()); + OkGo.post(url + "/wms/mobile/"+uri) + .headers("Authorization", SharedPreferencesUtils.getstring("access_token", "")) + .upRequestBody(RequestBody.create(JSON, gson.toJson(map))) + .execute(new MyRecultCall(dialog, this) { + @Override + public void onSuccess(Response response) { + super.onSuccess(response); + var body = response.body(); + if (body.getCode() == 200) { + binding.lockLocation.setText(null); + } + String msg = body.getMsg(); + Toast.makeText(context, msg==null?"操作失败":msg, Toast.LENGTH_SHORT).show(); + } + }); + requestLocationList(); + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/activity_locationlocking.xml b/app/src/main/res/layout/activity_locationlocking.xml new file mode 100644 index 0000000..519f834 --- /dev/null +++ b/app/src/main/res/layout/activity_locationlocking.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +