增加 库位锁定功能
parent
fab4355c84
commit
b004429c81
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="deploymentTargetDropDown">
|
||||
<targetSelectedWithDropDown>
|
||||
<Target>
|
||||
<type value="QUICK_BOOT_TARGET" />
|
||||
<deviceKey>
|
||||
<Key>
|
||||
<type value="VIRTUAL_DEVICE_PATH" />
|
||||
<value value="C:\Users\wanghao\.android\avd\Pixel_XL_API_33.avd" />
|
||||
</Key>
|
||||
</deviceKey>
|
||||
</Target>
|
||||
</targetSelectedWithDropDown>
|
||||
<timeTargetWasSelectedWithDropDown value="2024-11-01T00:38:54.800638200Z" />
|
||||
</component>
|
||||
</project>
|
@ -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<LockLocationAdapter.ItemtViewHolder> {
|
||||
private List<LocationLockInfo> list;
|
||||
private Context context;
|
||||
private LayoutInflater inflater;
|
||||
|
||||
public LockLocationAdapter(Context context) {
|
||||
this.context = context;
|
||||
inflater = LayoutInflater.from(context);
|
||||
}
|
||||
|
||||
public void setList(List<LocationLockInfo> 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);
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.example.jingyuan_mes.entity.store;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class LocationLockInfo {
|
||||
private String warehouseName;
|
||||
private List<String> locationCodes;
|
||||
|
||||
public String getWarehouseName() {
|
||||
return warehouseName;
|
||||
}
|
||||
|
||||
public void setWarehouseName(String warehouseName) {
|
||||
this.warehouseName = warehouseName;
|
||||
}
|
||||
|
||||
public List<String> getLocationCodes() {
|
||||
return locationCodes;
|
||||
}
|
||||
|
||||
public void setLocationCodes(List<String> locationCodes) {
|
||||
this.locationCodes = locationCodes;
|
||||
}
|
||||
}
|
@ -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.<MyResult>get(url + "/wms/mobile/getLockLocations")
|
||||
.headers("Authorization", SharedPreferencesUtils.getstring("access_token", ""))
|
||||
.execute(new MyRecultCall(dialog, this) {
|
||||
@Override
|
||||
public void onSuccess(Response<MyResult> response) {
|
||||
super.onSuccess(response);
|
||||
var body = response.body();
|
||||
if (body.getCode() == 200) {
|
||||
// List<LocationLockInfo> 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<String,String> map=new HashMap<>();
|
||||
map.put("locationCode",binding.lockLocation.getText().toString().trim());
|
||||
OkGo.<MyResult>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<MyResult> 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();
|
||||
}
|
||||
}
|
@ -0,0 +1,89 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<data>
|
||||
|
||||
<variable
|
||||
name="title"
|
||||
type="String" />
|
||||
<variable
|
||||
name="adapter"
|
||||
type="com.example.jingyuan_mes.adapter.store.LockLocationAdapter" />
|
||||
</data>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
tools:context=".store.LocationlockingActivity">
|
||||
|
||||
<include
|
||||
layout="@layout/toolbar"
|
||||
app:title='@{title??"库位锁定和解锁"}' />
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginEnd="4dp">
|
||||
|
||||
<TextView
|
||||
style="@style/text_title"
|
||||
android:layout_width="90dp"
|
||||
android:layout_height="match_parent"
|
||||
android:text="扫描库位:" />
|
||||
<!-- -->
|
||||
<EditText
|
||||
android:id="@+id/lock_location"
|
||||
style="@style/text_san"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="45dp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<Button
|
||||
style="@style/button_style"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="55dp"
|
||||
android:layout_margin="20dp"
|
||||
android:layout_weight="1"
|
||||
android:onClick="lockLocation"
|
||||
android:text="锁定" />
|
||||
|
||||
<Button
|
||||
style="@style/button_style"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="55dp"
|
||||
android:layout_margin="20dp"
|
||||
android:layout_weight="1"
|
||||
android:backgroundTint="@color/green"
|
||||
android:onClick="unLockLocation"
|
||||
android:text="解锁" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<TextView
|
||||
style="@style/item_title_left"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="已锁定库位" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/white"
|
||||
android:padding="5dp"
|
||||
android:adapter="@{adapter}"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
|
||||
|
||||
</LinearLayout>
|
||||
</layout>
|
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<data>
|
||||
<variable
|
||||
name="vm"
|
||||
type="com.example.jingyuan_mes.entity.store.LocationLockInfo" />
|
||||
</data>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/item_bg">
|
||||
|
||||
<TextView
|
||||
style="@style/item_title"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="match_parent"
|
||||
android:text="@{vm.warehouseName}" />
|
||||
|
||||
<View
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/white" />
|
||||
|
||||
<TextView
|
||||
style="@style/item_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="2"
|
||||
android:minHeight="45dp"
|
||||
android:text="@{vm.locationCodes.toString()}" />
|
||||
|
||||
</LinearLayout>
|
||||
</layout>
|
Loading…
Reference in New Issue