InventoryActivity.java
9.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
package com.huaheng.tab;
import android.app.AlertDialog;
import android.app.Dialog;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.huaheng.common.Constant;
import com.huaheng.common.WMSLog;
import com.huaheng.common.WMSUtils;
import com.huaheng.common.adapter.AbsCommonAdapter;
import com.huaheng.common.adapter.AbsViewHolder;
import com.huaheng.common.model.BaseBean;
import com.huaheng.common.model.Inventory;
import com.huaheng.common.model.OrderTable;
import com.huaheng.common.model.ShipmentDetail;
import com.huaheng.common.model.TableModel;
import com.huaheng.common.model.TotalInventory;
import com.huaheng.httplib.HttpInterface;
import com.huaheng.httplib.Subscribers.ProgressSubscriber;
import com.huaheng.httplib.Subscribers.SubscriberOnNextListener;
import com.huaheng.tab.util.TableActivity;
import java.util.ArrayList;
import java.util.List;
import butterknife.ButterKnife;
import butterknife.OnClick;
/**
* Created by youjie on 2020/5/25
*/
public class InventoryActivity extends TableActivity {
@Override
protected void initActivityOnCreate(Bundle savedInstanceState) {
super.initActivityOnCreate(savedInstanceState);
setButtonView(R.layout.activity_total_inventory);
ButterKnife.bind(this);
setTitle(mContext.getString(R.string.inventory));
initTableView();
getTalbeByCondition(pageNo);
}
public void initTableView() {
addTitleText("项目号", Constant.TITLE_TIME_WIDTH);
addTitleText("物料编码", Constant.TITLE_TIME_WIDTH);
addTitleText("物料名称", Constant.TITLE_NORMAL_WIDTH);
addTitleText("锁线机", Constant.TITLE_NORMAL_WIDTH);
addTitleText("内页P数", Constant.TITLE_NORMAL_WIDTH);
addTitleText("容器号", Constant.TITLE_NORMAL_WIDTH);
addTitleText("库位号", Constant.TITLE_NORMAL_WIDTH);
addTitleText("数量", Constant.TITLE_NORMAL_WIDTH);
addTitleText("创建人", Constant.TITLE_NORMAL_WIDTH);
addTitleText("创建时间", Constant.TITLE_TIME_WIDTH);
addTitleText("更新人", Constant.TITLE_NORMAL_WIDTH);
addTitleText("更新时间", Constant.TITLE_TIME_WIDTH);
mRightAdapter = new AbsCommonAdapter<TableModel>(mContext, R.layout.table_right_item) {
@Override
public void convert(AbsViewHolder helper, TableModel item, final int pos) {
LinearLayout linearLayout = helper.getView(R.id.tableLineLayout);
linearLayout.removeAllViews();
List<String> contentList = item.getContentList();
addMessageText(linearLayout, Constant.TITLE_TIME_WIDTH, contentList.get(0));
addMessageText(linearLayout, Constant.TITLE_TIME_WIDTH, contentList.get(1));
addMessageText(linearLayout, Constant.TITLE_NORMAL_WIDTH, contentList.get(2));
addMessageText(linearLayout, Constant.TITLE_NORMAL_WIDTH, contentList.get(3));
addMessageText(linearLayout, Constant.TITLE_NORMAL_WIDTH, contentList.get(4));
addMessageText(linearLayout, Constant.TITLE_NORMAL_WIDTH, contentList.get(5));
addMessageText(linearLayout, Constant.TITLE_NORMAL_WIDTH, contentList.get(6));
addMessageText(linearLayout, Constant.TITLE_NORMAL_WIDTH, contentList.get(7));
addMessageText(linearLayout, Constant.TITLE_NORMAL_WIDTH, contentList.get(8));
addMessageText(linearLayout, Constant.TITLE_TIME_WIDTH, contentList.get(9));
addMessageText(linearLayout, Constant.TITLE_NORMAL_WIDTH, contentList.get(10));
addMessageText(linearLayout, Constant.TITLE_TIME_WIDTH, contentList.get(11));
// setSelectBackground(helper, pos);
}
};
}
@Override
public void setDatas(List<BaseBean> baseBeans, int type) {
List<TableModel> mDatas = new ArrayList<>();
for (BaseBean baseBean : baseBeans) {
TableModel tableMode = new TableModel();
Inventory inventory = (Inventory) baseBean;
ArrayList<String> contentList = new ArrayList<>();
contentList.add(String.valueOf(inventory.getProject()));
contentList.add(inventory.getMaterialCode());
contentList.add(inventory.getMaterialName());
contentList.add(inventory.getLinecode());
contentList.add(inventory.getPqty());
contentList.add(inventory.getContainerCode());
contentList.add(inventory.getLocationCode());
contentList.add(String.valueOf(inventory.getQty().intValue()));
contentList.add(String.valueOf(inventory.getCreatedBy()));
contentList.add(String.valueOf(inventory.getCreated()));
contentList.add(String.valueOf(inventory.getLastUpdatedBy()));
contentList.add(String.valueOf(inventory.getLastUpdated()));
tableMode.setContentList(contentList);
mDatas.add(tableMode);
}
mRightAdapter.addData(mDatas, false);
//加载数据成功,增加页数
mDatas.clear();
}
private void showSearchDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
View view = LayoutInflater.from(mContext).inflate(R.layout.dialog_search_inventory, null);
TextView cancel = view.findViewById(R.id.modify_qty_cancel);
TextView sure = view.findViewById(R.id.modify_qty_sure);
final EditText projectEdit = view.findViewById(R.id.projectEdit);
final EditText materialEdit = view.findViewById(R.id.materialEdit);
final Dialog dialog = builder.create();
dialog.show();
dialog.getWindow().setContentView(view);
dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
cancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
sure.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String project = projectEdit.getText().toString();
String materialCode = materialEdit.getText().toString();
mobileTotalInventory(pageNo, pageSize, project, materialCode);
dialog.dismiss();
}
});
}
@Override
public void select(BaseBean baseBean) {
Inventory inventory = (Inventory) baseBean;
mobileTotalInventoryDetail(inventory.getProject(), inventory.getMaterialCode());
}
@OnClick({R.id.refreshBtn, R.id.searchBtn})
public void onViewClicked(View view) {
switch (view.getId()) {
case R.id.refreshBtn:
getTalbeByCondition(pageNo);
break;
case R.id.searchBtn:
showSearchDialog();
break;
}
}
@Override
protected void getTalbeByCondition(int page) {
totalInventory(page);
}
private void totalInventory(int page) {
mobileTotalInventory(page, 10, null, null);
}
private void mobileTotalInventory(int pageNumber, int pageSize, String project, String materialCode) {
HttpInterface.getInsstance(mContext).mobileTotalInventory(new ProgressSubscriber<TotalInventory>(mContext, mobileTotalInventoryListener), pageNumber, pageSize, project, materialCode);
}
SubscriberOnNextListener mobileTotalInventoryListener = new SubscriberOnNextListener<TotalInventory>() {
@Override
public void onNext(TotalInventory totalInventory) {
clearSelectBean();
List<Inventory> inventories = totalInventory.getList();
for(Inventory inventory : inventories) {
inventory.setContainerCode("");
inventory.setLocationCode("");
}
tableBeans = (List) inventories;
pageNo = upPageNo;
setData(tableBeans);
freshMenuText(totalInventory.getTotal());
}
@Override
public void onError(String str) {
upPageNo = pageNo;
mRightAdapter.clearData(true);
}
};
private void mobileTotalInventoryDetail(String project, String materialCode) {
HttpInterface.getInsstance(mContext).mobileTotalInventoryDetail(new ProgressSubscriber<List<Inventory>>(mContext, mobileTotalInventoryDetailListener), project, materialCode);
}
SubscriberOnNextListener mobileTotalInventoryDetailListener = new SubscriberOnNextListener<List<Inventory>>() {
@Override
public void onNext(List<Inventory> inventorys) {
clearSelectBean();
tableBeans = (List)inventorys;
pageNo = upPageNo;
setData(tableBeans);
// freshMenuText(totalInventory.getTotal());
}
@Override
public void onError(String str) {
upPageNo = pageNo;
mRightAdapter.clearData(true);
}
};
}