ShipmentActivity.java
4.61 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
package com.huaheng.robot.shipment;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import com.huaheng.robot.R;
import com.huaheng.robot.https.HttpInterface;
import com.huaheng.robot.https.Subscribers.ProgressSubscriber;
import com.huaheng.robot.https.Subscribers.SubscriberOnNextListener;
import com.huaheng.robot.util.CommonActivity;
import com.huaheng.robot.util.Constant;
import com.huaheng.robot.util.SpeechUtil;
import com.huaheng.robot.util.WMSLog;
import com.huaheng.robot.util.WMSUtils;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
public class ShipmentActivity extends CommonActivity {
@BindView(R.id.info)
TextView info;
@BindView(R.id.shipmentBtn)
Button shipmentBtn;
@BindView(R.id.lowerBtn)
Button lowerBtn;
private String materialCode = "123456";
private ArrayList<ShipmentBill> shipmentBills = new ArrayList<>();
private List<Integer> mTaskIds = null;
private boolean calling = false;
private Context mContext;
@Override
protected void initActivityOnCreate(Bundle savedInstanceState) {
super.initActivityOnCreate(savedInstanceState);
setContentView(R.layout.activity_shipment);
ButterKnife.bind(this);
mContext = this;
String lineName = WMSUtils.getData(Constant.CURREN_LINE_NAME);
String station = WMSUtils.getData(Constant.CURREN_STATION);
setTitle(lineName + " " + station);
initView();
}
private void initView() {
initList();
}
private void freshInfo() {
info.setText("当前状态小车正在送货过来");
if(calling) {
shipmentBtn.setEnabled(false);
shipmentBtn.setBackgroundResource(R.mipmap.button6);
}
}
private void initList() {
ShipmentBill shipmentBill = new ShipmentBill();
shipmentBill.setMaterialCode(materialCode);
shipmentBill.setQty(new BigDecimal(1));
shipmentBill.setLocation(null);
shipmentBill.setPoint(1001);
shipmentBills.add(shipmentBill);
}
@OnClick({R.id.shipmentBtn, R.id.lowerBtn})
public void onViewClicked(View view) {
switch (view.getId()) {
case R.id.shipmentBtn:
autoShipment(shipmentBills);
break;
case R.id.lowerBtn:
break;
}
}
private void autoShipment(List<ShipmentBill> shipmentBills) {
HttpInterface.getInsstance().autoShipment(new ProgressSubscriber<List<Integer>>(this, shipmentListener), shipmentBills);
}
SubscriberOnNextListener shipmentListener = new SubscriberOnNextListener<List<Integer>>() {
@Override
public void onNext(List<Integer> headerList) {
ShipmentTaskModel shipmentTaskCreateModel = new ShipmentTaskModel();
shipmentTaskCreateModel.setPriority((short)0);
shipmentTaskCreateModel.setTaskType(1); //优先整出
int[] headerIds = new int[headerList.size()];
for(int i=0; i< headerList.size(); i++) {
headerIds[i] = headerList.get(i);
}
shipmentTaskCreateModel.setShipmentContainerHeaderIds(headerIds);
createShipTask(shipmentTaskCreateModel);
}
@Override
public void onError(String str) {
}
};
private void createShipTask(ShipmentTaskModel shipmentTaskCreateModel) {
HttpInterface.getInsstance().createShipTask(new ProgressSubscriber<List<Integer>>(this,createShipTaskListener), shipmentTaskCreateModel);
}
SubscriberOnNextListener createShipTaskListener = new SubscriberOnNextListener<List<Integer>>() {
@Override
public void onNext(List<Integer> result) {
mTaskIds = result;
executeList(result);
}
@Override
public void onError(String str) {
WMSLog.d("onError:" + str);
}
};
private void executeList(List<Integer> taskIdS) {
HttpInterface.getInsstance().executeList(new ProgressSubscriber<String>(this, executeListener), taskIdS);
}
SubscriberOnNextListener executeListener = new SubscriberOnNextListener<String>() {
@Override
public void onNext(String result) {
WMSUtils.showShort(mContext.getString(R.string.call_material_success));
calling = true;
freshInfo();
}
@Override
public void onError(String str) {
WMSLog.d("onError:" + str);
}
};
}