forked from JerryChen/DXPDA
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
717 lines
31 KiB
717 lines
31 KiB
package com.icssoft.icspda.activity;
|
|
|
|
import androidx.appcompat.app.AppCompatActivity;
|
|
|
|
import android.graphics.Color;
|
|
import android.os.Bundle;
|
|
import android.os.Handler;
|
|
import android.os.Message;
|
|
import android.os.SystemClock;
|
|
import android.text.Editable;
|
|
import android.text.TextUtils;
|
|
import android.text.TextWatcher;
|
|
import android.view.KeyEvent;
|
|
import android.view.View;
|
|
import android.view.inputmethod.EditorInfo;
|
|
import android.widget.Button;
|
|
import android.widget.EditText;
|
|
import android.widget.RadioButton;
|
|
import android.widget.TextView;
|
|
|
|
import com.bin.david.form.core.SmartTable;
|
|
import com.bin.david.form.data.column.Column;
|
|
import com.bin.david.form.data.table.TableData;
|
|
import com.google.gson.Gson;
|
|
import com.google.gson.JsonSyntaxException;
|
|
import com.google.gson.reflect.TypeToken;
|
|
import com.icssoft.icspda.R;
|
|
import com.icssoft.icspda.entity.ApplicationModel;
|
|
import com.icssoft.icspda.entity.ItemLotData;
|
|
import com.icssoft.icspda.entity.ItemLotDetailData;
|
|
import com.icssoft.icspda.entity.LotDetail;
|
|
import com.icssoft.icspda.net.WebServiceUtil;
|
|
import com.icssoft.icspda.util.BaseDialog;
|
|
import com.icssoft.icspda.util.HelpUtil;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
public class INVTransInActivity extends AppCompatActivity {
|
|
//region 变量初始化
|
|
private TextView tvMsg;
|
|
private String result;
|
|
private ApplicationModel applicationModel;
|
|
private List<LotDetail> lotDetails;
|
|
private List<ItemLotData> dataList;
|
|
private List<ItemLotDetailData> dataDetailList;
|
|
private SmartTable smartTable;
|
|
private SmartTable smartDetailTable;
|
|
// private EditText transferNo;
|
|
private EditText toBin;
|
|
private EditText barCode;
|
|
private Button btnDel;
|
|
private Button btnOk;
|
|
private RadioButton rbIn;
|
|
private RadioButton rbOut;
|
|
private int selectRowIndex = 999;
|
|
private String selectRowInvCode = "";
|
|
private TableData<ItemLotData> tableData;
|
|
private List<Column> columns;
|
|
private String ErrorMsg = "";
|
|
private Double LotQty;
|
|
private String InvCode;
|
|
private String WhCode;
|
|
private String ToWhCode;
|
|
private Double limitQty;
|
|
private long[] mHits = new long[2];//存储时间的数组
|
|
//endregion
|
|
|
|
private Handler handler = new Handler() {
|
|
@Override
|
|
public void handleMessage(Message msg) {
|
|
super.handleMessage(msg);
|
|
switch (msg.what) {
|
|
case 0:
|
|
dataList.clear();
|
|
dataDetailList.clear();
|
|
gridBarCode();
|
|
toBin.requestFocus();
|
|
HelpUtil.SetMsg(tvMsg, Color.BLUE, "源头单据扫描成功!");
|
|
break;
|
|
// case 1:
|
|
// HelpUtil.SetMsg(tvMsg, Color.RED, ErrorMsg);
|
|
// transferNo.postDelayed(new Runnable() {
|
|
// @Override
|
|
// public void run() {
|
|
// transferNo.requestFocus();
|
|
// }
|
|
// },1000);
|
|
// break;
|
|
case 2:
|
|
HelpUtil.SetMsg(tvMsg, Color.RED, ErrorMsg);
|
|
toBin.postDelayed(new Runnable() {
|
|
@Override
|
|
public void run() {
|
|
toBin.requestFocus();
|
|
}
|
|
},1000);
|
|
break;
|
|
case 3:
|
|
HelpUtil.SetMsg(tvMsg, Color.RED, ErrorMsg);
|
|
barCode.postDelayed(new Runnable() {
|
|
@Override
|
|
public void run() {
|
|
barCode.requestFocus();
|
|
}
|
|
},1000);
|
|
break;
|
|
case 5:
|
|
barCode.requestFocus();
|
|
HelpUtil.SetMsg(tvMsg, Color.BLUE, "调拨数量记录成功!");
|
|
break;
|
|
case 7:
|
|
HelpUtil.SetMsg(tvMsg,Color.BLUE,"库位条码扫描成功!");
|
|
barCode.postDelayed(new Runnable() {
|
|
@Override
|
|
public void run() {
|
|
barCode.requestFocus();
|
|
}
|
|
},1000);
|
|
break;
|
|
case 6:
|
|
clear();
|
|
HelpUtil.SetMsg(tvMsg, Color.BLUE, ErrorMsg);
|
|
break;
|
|
case 12:
|
|
barCode.requestFocus();
|
|
break;
|
|
case 99:
|
|
HelpUtil.SetMsg(tvMsg, Color.RED, ErrorMsg);
|
|
break;
|
|
case 100:
|
|
tableData = new TableData<>("两步调出", dataList, columns);
|
|
smartTable.setTableData(tableData);
|
|
HelpUtil.SetMsg(tvMsg, Color.BLUE, "移出成功");
|
|
break;
|
|
}
|
|
}
|
|
};
|
|
|
|
@Override
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
super.onCreate(savedInstanceState);
|
|
setContentView(R.layout.activity_invtransin);
|
|
bindView();
|
|
}
|
|
|
|
private void bindView() {
|
|
this.setTitle("两步调入");
|
|
tvMsg = findViewById(R.id.tv_msg);
|
|
smartTable = findViewById(R.id.table);
|
|
// transferNo = findViewById(R.id.et_transferNo);
|
|
toBin = findViewById(R.id.et_toBin);
|
|
barCode = findViewById(R.id.et_barcode);
|
|
btnDel = findViewById(R.id.btn_del);
|
|
btnOk = findViewById(R.id.btn_ok);
|
|
rbIn = findViewById(R.id.rbIn);
|
|
rbOut = findViewById(R.id.rbOut);
|
|
// HelpUtil.disableShowSoftInput(transferNo);
|
|
// HelpUtil.disableShowSoftInput(toBin);
|
|
// HelpUtil.disableShowSoftInput(barCode);
|
|
dataList = new ArrayList<>();
|
|
dataDetailList = new ArrayList<>();
|
|
|
|
// transferNo.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
|
// @Override
|
|
// public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
|
// try {
|
|
// if (actionId == EditorInfo.IME_ACTION_SEND || actionId == EditorInfo.IME_ACTION_DONE || actionId == EditorInfo.IME_ACTION_NEXT
|
|
// || (event != null && KeyEvent.KEYCODE_ENTER == event.getKeyCode() && KeyEvent.ACTION_DOWN == event.getAction())) {
|
|
// if (v.getText().length() > 0) {
|
|
// new Thread(new Runnable() {
|
|
// @Override
|
|
// public void run() {
|
|
// CheckTransferNoOut();
|
|
// }
|
|
// }).start();
|
|
// }
|
|
// }
|
|
// return false;
|
|
// } catch (Exception ex) {
|
|
// ErrorMsg = ex.getMessage();
|
|
// handler.sendEmptyMessage(99);
|
|
// }
|
|
//
|
|
// return false;
|
|
// }
|
|
// });
|
|
|
|
toBin.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
|
@Override
|
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
|
try {
|
|
if (actionId == EditorInfo.IME_ACTION_SEND || actionId == EditorInfo.IME_ACTION_DONE || actionId == EditorInfo.IME_ACTION_NEXT
|
|
|| (event != null && KeyEvent.KEYCODE_ENTER == event.getKeyCode() && KeyEvent.ACTION_DOWN == event.getAction())) {
|
|
if (v.getText().length() > 0) {
|
|
new Thread(new Runnable() {
|
|
@Override
|
|
public void run() {
|
|
CheckStackCode();
|
|
}
|
|
}).start();
|
|
}
|
|
}
|
|
return false;
|
|
} catch (Exception ex) {
|
|
ErrorMsg = ex.getMessage();
|
|
handler.sendEmptyMessage(99);
|
|
}
|
|
|
|
return false;
|
|
}
|
|
});
|
|
|
|
|
|
barCode.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
|
@Override
|
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
|
try {
|
|
if (actionId == EditorInfo.IME_ACTION_SEND || actionId == EditorInfo.IME_ACTION_DONE || actionId == EditorInfo.IME_ACTION_NEXT
|
|
|| (event != null && KeyEvent.KEYCODE_ENTER == event.getKeyCode() && KeyEvent.ACTION_DOWN == event.getAction())) {
|
|
if (v.toString().length() > 0) {
|
|
if (TextUtils.isEmpty(toBin.getText().toString().trim())) {
|
|
ErrorMsg = "请先扫描目标库位!";
|
|
handler.sendEmptyMessage(2);
|
|
}
|
|
|
|
if (rbIn.isChecked()) {
|
|
for (ItemLotDetailData itemLotDetailData : dataDetailList) {
|
|
if (itemLotDetailData.getInvCode().equals(barCode.getText())) {
|
|
ErrorMsg = "请勿扫描重复条码!";
|
|
handler.sendEmptyMessage(3);
|
|
}
|
|
}
|
|
}
|
|
new Thread(new Runnable() {
|
|
@Override
|
|
public void run() {
|
|
CheckLotNoForTransIn();
|
|
}
|
|
}).start();
|
|
}
|
|
}
|
|
return false;
|
|
} catch (Exception ex) {
|
|
ErrorMsg = ex.getMessage();
|
|
handler.sendEmptyMessage(99);
|
|
}
|
|
|
|
return false;
|
|
}
|
|
});
|
|
|
|
|
|
btnDel.setOnClickListener(new View.OnClickListener() {
|
|
@Override
|
|
public void onClick(View v) {
|
|
try {
|
|
// if (tableData != null && selectRowIndex != 999 && !TextUtils.isEmpty(selectRowInvCode)) {
|
|
// for (ItemLotData itemLotData : dataList) {
|
|
// if (itemLotData.getInvCode().equals(selectRowInvCode))
|
|
// dataList.remove(itemLotData);
|
|
// }
|
|
//
|
|
// tableData = new TableData<>("两步调入", dataList, columns);
|
|
// smartTable.setTableData(tableData);
|
|
//
|
|
// for (ItemLotDetailData itemLotDetailData : dataDetailList) {
|
|
// if (itemLotDetailData.getInvCode().equals(selectRowInvCode)) {
|
|
// dataDetailList.remove(itemLotDetailData);
|
|
// }
|
|
// }
|
|
//
|
|
// HelpUtil.SetMsg(tvMsg, Color.BLUE, "物料编码:" + selectRowInvCode + ",移除成功!");
|
|
// selectRowInvCode = "";
|
|
// selectRowIndex = 999;
|
|
// } else {
|
|
// HelpUtil.SetMsg(tvMsg, Color.RED, "尚未扫入任何条码!");
|
|
// }
|
|
if (tableData != null && selectRowIndex != 999 && !TextUtils.isEmpty(selectRowInvCode)) {
|
|
for (ItemLotDetailData itemLotDetailData : dataDetailList) {
|
|
if (itemLotDetailData.getInvCode().equals(selectRowInvCode))
|
|
dataDetailList.remove(itemLotDetailData);
|
|
}
|
|
|
|
tableData = new TableData<>("两步调入", dataList, columns);
|
|
smartTable.setTableData(tableData);
|
|
|
|
for (ItemLotData itemLotData : dataList) {
|
|
itemLotData.setCurrentQty("0.0");
|
|
}
|
|
|
|
HelpUtil.SetMsg(tvMsg, Color.BLUE, "物料编码:" + selectRowInvCode + ",移除成功!");
|
|
selectRowInvCode = "";
|
|
selectRowIndex = 999;
|
|
} else {
|
|
HelpUtil.SetMsg(tvMsg, Color.RED, "尚未扫入任何条码!");
|
|
}
|
|
} catch (Exception ex) {
|
|
HelpUtil.SetMsg(tvMsg, Color.RED, ex.getMessage());
|
|
}
|
|
}
|
|
});
|
|
|
|
btnOk.setOnClickListener(new View.OnClickListener() {
|
|
@Override
|
|
public void onClick(View v) {
|
|
if (dataList.size() <= 0) {
|
|
HelpUtil.SetMsg(tvMsg, Color.RED, "请先扫描条码!");
|
|
barCode.requestFocus();
|
|
return;
|
|
}
|
|
new Thread(new Runnable() {
|
|
@Override
|
|
public void run() {
|
|
WareHouseTransIn();
|
|
}
|
|
}).start();
|
|
}
|
|
});
|
|
}
|
|
|
|
public void CheckTransferNoOut() {
|
|
Map params = new HashMap();
|
|
params.put("TransferNo", "");
|
|
params.put("WorkPointCode", LoginActivity.user.getWorkPointCode());
|
|
try {
|
|
result = "";
|
|
result = WebServiceUtil.GetWSReturnInfo("CheckTransferNoOut", params);
|
|
if (result != null && result.length() != 0) {
|
|
applicationModel = new Gson().fromJson(result, ApplicationModel.class);
|
|
if (applicationModel.getCode().equals("0")) {
|
|
GetTransferDataIn();
|
|
handler.sendEmptyMessage(0);
|
|
} else {
|
|
ErrorMsg = applicationModel.getMsg();
|
|
handler.sendEmptyMessage(1);
|
|
return;
|
|
}
|
|
}
|
|
} catch (Exception ex) {
|
|
ErrorMsg = ex.getMessage();
|
|
handler.sendEmptyMessage(99);
|
|
}
|
|
}
|
|
|
|
private void GetTransferDataIn() {
|
|
Map params = new HashMap();
|
|
params.put("TransferNo", "");
|
|
params.put("workPoint", LoginActivity.user.getWorkPointCode());
|
|
try {
|
|
result = "";
|
|
result = WebServiceUtil.GetWSReturnInfo("GetTransferDataIn", params);
|
|
} catch (Exception ex) {
|
|
ErrorMsg = ex.getMessage();
|
|
handler.sendEmptyMessage(99);
|
|
}
|
|
}
|
|
|
|
private void gridBarCode() {
|
|
dataList = new Gson().fromJson(result, new TypeToken<ArrayList<ItemLotData>>() {
|
|
}.getType());
|
|
|
|
WhCode = dataList.get(dataList.size() - 1).getToWHCode();
|
|
ToWhCode = dataList.get(dataList.size() - 1).getToWHCode();
|
|
|
|
HelpUtil.InitSmartTable(smartTable, this.getApplicationContext());
|
|
|
|
//region 声明列
|
|
columns = new ArrayList<>();
|
|
columns.add(new Column("序号", "TransferLine"));
|
|
columns.add(new Column("源仓库", "FromWHCode"));
|
|
columns.add(new Column("目标仓库", "ToWHCode"));
|
|
columns.add(new Column("物料编码", "InvCode"));
|
|
columns.add(new Column("物料名称", "InvName"));
|
|
columns.add(new Column("规格型号", "InvStd"));
|
|
columns.add(new Column("计划数量", "PlanQty"));
|
|
columns.add(new Column("已发数量", "HasQty"));
|
|
columns.add(new Column("本次数量", "CurrentQty"));
|
|
columns.add(new Column("单位", "InvUom"));
|
|
// columns.add(new Column("项目号", "OrderNo"));
|
|
// columns.add(new Column("批次", "Batch"));
|
|
//endregion
|
|
|
|
tableData = new TableData<>("两步调入", dataList, columns);
|
|
|
|
tableData.setOnRowClickListener(new TableData.OnRowClickListener<ItemLotData>() {
|
|
@Override
|
|
public void onClick(Column column, ItemLotData itemLotData, int col, final int row) {
|
|
System.arraycopy(mHits, 1, mHits, 0, mHits.length - 1);
|
|
mHits[mHits.length - 1] = SystemClock.uptimeMillis();
|
|
if (mHits[0] >= (SystemClock.uptimeMillis() - 500)) {
|
|
showSMTableDialog(itemLotData.getInvCode(), itemLotData.getTransferLine());
|
|
} else {
|
|
HelpUtil.ChangeRowBackgroundColor(smartTable, row);
|
|
smartTable.invalidate();
|
|
selectRowIndex = row;
|
|
selectRowInvCode = itemLotData.getInvCode();
|
|
// selectRowVouchNo = dispatchListData.getVouchRow();
|
|
HelpUtil.SetMsg(tvMsg, Color.BLUE, "当前选中第" + row + "行,物料编码为:" + itemLotData.getInvCode());
|
|
}
|
|
}
|
|
});
|
|
|
|
smartTable.setTableData(tableData);
|
|
}
|
|
|
|
private void CheckStackCode() {
|
|
Map params = new HashMap();
|
|
params.put("StackCode", toBin.getText().toString());
|
|
params.put("WorkPointCode", LoginActivity.user.getWorkPointCode());
|
|
try {
|
|
result = "";
|
|
result = WebServiceUtil.GetWSReturnInfo("CheckStackCode", params);
|
|
if (result != null && result.length() != 0) {
|
|
applicationModel = new Gson().fromJson(result, ApplicationModel.class);
|
|
if (applicationModel.getCode().equals("0")) {
|
|
for (LotDetail lot:lotDetails){
|
|
if (!applicationModel.getData().equals(lot.getWHCode())) {
|
|
ErrorMsg = "目标库位与源头单据不符,请确认后重新扫描!";
|
|
handler.sendEmptyMessage(2);
|
|
} else {
|
|
handler.sendEmptyMessage(7);
|
|
}
|
|
}
|
|
} else {
|
|
ErrorMsg = "库位条码不存在!";
|
|
handler.sendEmptyMessage(2);
|
|
}
|
|
}
|
|
} catch (Exception ex) {
|
|
ErrorMsg = ex.getMessage();
|
|
handler.sendEmptyMessage(99);
|
|
}
|
|
}
|
|
|
|
private void showSMTableDialog(String InvCode, String TransferLine) {
|
|
List<ItemLotDetailData> dData = new ArrayList<>();
|
|
for (ItemLotDetailData itemLotDetailData : dataDetailList) {
|
|
if (itemLotDetailData.getTransferLine().equals(TransferLine)
|
|
&& itemLotDetailData.getInvCode().equals(InvCode)) {
|
|
dData.add(itemLotDetailData);
|
|
}
|
|
}
|
|
View tableView = View.inflate(this, R.layout.detialinfo, null);
|
|
smartDetailTable = tableView.findViewById(R.id.detailTable);
|
|
smartDetailTable.getConfig().setShowTableTitle(false);
|
|
smartDetailTable.getConfig().setShowXSequence(false);
|
|
smartDetailTable.getConfig().setShowYSequence(false);
|
|
smartDetailTable.getConfig().setFixedTitle(true);
|
|
smartDetailTable.setData(dData);
|
|
BaseDialog dialog = new BaseDialog.Builder(this).setFillWidth(true).setContentView(tableView).create();
|
|
dialog.show();
|
|
}
|
|
|
|
private void CheckLotNoForTransIn() {
|
|
Map params = new HashMap();
|
|
params.put("TransNO", "");
|
|
params.put("BarCode", barCode.getText().toString().trim());
|
|
params.put("WorkPointCode", LoginActivity.user.getWorkPointCode());
|
|
try {
|
|
result = "";
|
|
result = WebServiceUtil.GetWSReturnInfo("CheckLotnoForTransIn", params);
|
|
if (result.equals("[{}]")) {
|
|
ErrorMsg = "条码不存在!";
|
|
handler.sendEmptyMessage(3);
|
|
return;
|
|
} else {
|
|
GetLotData();
|
|
}
|
|
} catch (Exception ex) {
|
|
ErrorMsg = ex.getMessage();
|
|
handler.sendEmptyMessage(99);
|
|
}
|
|
}
|
|
|
|
private void GetLotData() {
|
|
try {
|
|
boolean isExist = false;
|
|
Double planQty = 0.0;
|
|
Double currentQty = 0.0;
|
|
Double sendQty = 0.0;
|
|
lotDetails = new Gson().fromJson(result, new TypeToken<ArrayList<LotDetail>>() {
|
|
}.getType());
|
|
if (rbIn.isChecked()) {
|
|
for (LotDetail lot : lotDetails) {
|
|
for (int i = 0; i < dataList.size(); i++) {
|
|
ItemLotData itemLotData = dataList.get(i);
|
|
if (itemLotData.getFromWHCode().equals(lot.getWHCode())
|
|
&& itemLotData.getInvCode().equals(lot.getInvCode())) {
|
|
planQty += Double.parseDouble(itemLotData.getPlanQty());
|
|
currentQty += Double.parseDouble(itemLotData.getCurrentQty());
|
|
sendQty += Double.parseDouble(itemLotData.getHasQty());
|
|
isExist = true;
|
|
selectRowIndex = i;
|
|
HelpUtil.ChangeRowBackgroundColor(smartTable, selectRowIndex);
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (isExist) {
|
|
LotQty = lot.getLotQty();
|
|
InvCode = lot.getInvCode();
|
|
if (planQty < currentQty + sendQty + LotQty) {
|
|
ErrorMsg = "扫描的条码数量超出了剩余计划数量,请确认后重新扫描";
|
|
handler.sendEmptyMessage(3);
|
|
return;
|
|
}
|
|
for (ItemLotDetailData itemLotDetailData : dataDetailList) {
|
|
if (itemLotDetailData.getLotNo().toUpperCase().equals(lot.getLotNo().toUpperCase())) {
|
|
ErrorMsg = "请勿扫描重复条码!";
|
|
handler.sendEmptyMessage(3);
|
|
return;
|
|
}
|
|
}
|
|
} else {
|
|
ErrorMsg = "条码对应仓库及物料与源头单据不符!";
|
|
handler.sendEmptyMessage(3);
|
|
return;
|
|
}
|
|
SetMainTableQty();
|
|
DetailSum();
|
|
tableData = new TableData<>("两步调入", dataList, columns);
|
|
smartTable.setTableData(tableData);
|
|
handler.sendEmptyMessage(5);
|
|
}
|
|
} else if (rbOut.isChecked()) {
|
|
if (dataDetailList != null && dataDetailList.size() > 0 && !dataDetailList.get(0).getTransferLine().equals("0")) {
|
|
for (int i = dataDetailList.size() - 1; i >= 0; i--) {
|
|
ItemLotDetailData rows = dataDetailList.get(i);
|
|
if (rows.getLotNo().toUpperCase().equals(barCode.getText().toString().toUpperCase())) {
|
|
for (ItemLotData row : dataList) {
|
|
if (rows.getInvCode().equals(row.getInvCode()) && Double.parseDouble(row.getCurrentQty()) > 0
|
|
&& rows.getTransferLine().equals(row.getTransferLine())) {
|
|
row.setCurrentQty(Double.parseDouble(row.getCurrentQty()) - Double.parseDouble(rows.getCurrentQty()) + "");
|
|
dataDetailList.remove(rows);
|
|
handler.sendEmptyMessage(100);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} catch (Exception ex) {
|
|
ErrorMsg = ex.getMessage();
|
|
handler.sendEmptyMessage(99);
|
|
}
|
|
}
|
|
|
|
private void SetMainTableQty() {
|
|
for (int j = 0; j < dataList.size(); j++) {
|
|
ItemLotData row = dataList.get(j);
|
|
String ItemCode = row.getInvCode();
|
|
Double PlanQTY = Double.parseDouble(row.getPlanQty());
|
|
Double SendQTY = Double.parseDouble(row.getHasQty());
|
|
Double CurrentQTY = Double.parseDouble(row.getCurrentQty());
|
|
if (ItemCode.equals(InvCode)) {
|
|
if (LotQty > PlanQTY - SendQTY - CurrentQTY && PlanQTY - SendQTY - CurrentQTY != 0 && LotQty != 0) {
|
|
LotQty = LotQty - (PlanQTY - SendQTY - CurrentQTY);
|
|
row.setCurrentQty((CurrentQTY + (PlanQTY - SendQTY - CurrentQTY)) + "");
|
|
ItemLotDetailData itemLotDetailData = new ItemLotDetailData();
|
|
itemLotDetailData.setLotNo(barCode.getText().toString().trim());
|
|
itemLotDetailData.setInvCode(row.getInvCode());
|
|
itemLotDetailData.setInvName(row.getInvName());
|
|
itemLotDetailData.setLotQty(LotQty.toString());
|
|
itemLotDetailData.setTransferLine(row.getTransferLine());
|
|
itemLotDetailData.setCurrentQty((PlanQTY - SendQTY - CurrentQTY) + "");
|
|
itemLotDetailData.setStockCode(toBin.getText().toString().trim());
|
|
// itemLotDetailData.setTransferNo(transferNo.getText().toString().trim());
|
|
dataDetailList.add(itemLotDetailData);
|
|
} else if (LotQty <= PlanQTY - SendQTY && LotQty != 0 && (PlanQTY - SendQTY - CurrentQTY) != 0) {
|
|
row.setCurrentQty((CurrentQTY + LotQty) + "");
|
|
ItemLotDetailData itemLotDetailData = new ItemLotDetailData();
|
|
itemLotDetailData.setLotNo(barCode.getText().toString().trim());
|
|
itemLotDetailData.setInvCode(row.getInvCode());
|
|
itemLotDetailData.setInvName(row.getInvName());
|
|
itemLotDetailData.setLotQty(LotQty.toString());
|
|
itemLotDetailData.setTransferLine(row.getTransferLine());
|
|
itemLotDetailData.setCurrentQty(LotQty + "");
|
|
itemLotDetailData.setStockCode(toBin.getText().toString().trim());
|
|
// itemLotDetailData.setTransferNo(transferNo.getText().toString().trim());
|
|
dataDetailList.add(itemLotDetailData);
|
|
LotQty = 0.00;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void DetailSum() {
|
|
List<ItemLotDetailData> newDataDetailList = new ArrayList<>();
|
|
for (ItemLotDetailData row : dataDetailList) {
|
|
if (newDataDetailList != null) {
|
|
if (newDataDetailList.size() > 0) {
|
|
for (ItemLotDetailData item : newDataDetailList) {
|
|
if (item.getInvCode().toUpperCase().equals(row.getInvCode().toUpperCase())
|
|
&& item.getTransferLine().equals(row.getTransferLine())) {
|
|
item.setCurrentQty((Double.parseDouble(item.getCurrentQty()) + Double.parseDouble(row.getCurrentQty())) + "");
|
|
} else {
|
|
newDataDetailList.add(row);
|
|
}
|
|
}
|
|
} else {
|
|
newDataDetailList.add(row);
|
|
}
|
|
}
|
|
}
|
|
dataDetailList = newDataDetailList;
|
|
}
|
|
|
|
private void WareHouseTransIn() {
|
|
String PORowList = "";
|
|
String POQtyList = "";
|
|
String BarCodeList = "";
|
|
String BarCodeQtyList = "";
|
|
String BinCodeList = "";
|
|
String BarCodeRowList = "";
|
|
Double PlanQty = 0.0;
|
|
Double HasQty = 0.0;
|
|
for (ItemLotData itemLotData : dataList) {
|
|
PlanQty += Double.parseDouble(itemLotData.getPlanQty());//计划数量
|
|
HasQty += Double.parseDouble(itemLotData.getHasQty()) + Double.parseDouble(itemLotData.getCurrentQty());//已发数量+本次数量
|
|
}
|
|
|
|
if (PlanQty > HasQty) {
|
|
ErrorMsg = "该单据尚有条码未扫入,请补全后再提交!";
|
|
handler.sendEmptyMessage(3);
|
|
return;
|
|
}
|
|
|
|
for (ItemLotData itemLotData : dataList) {
|
|
if (Double.parseDouble(itemLotData.getCurrentQty()) > 0) {
|
|
if (PORowList.equals("")) {
|
|
PORowList += "" + itemLotData.getTransferLine() + "";
|
|
POQtyList += "" + Double.parseDouble(itemLotData.getCurrentQty()) + "";
|
|
} else {
|
|
PORowList += "," + itemLotData.getTransferLine() + "";
|
|
POQtyList += "," + Double.parseDouble(itemLotData.getCurrentQty()) + "";
|
|
}
|
|
}
|
|
}
|
|
|
|
for (ItemLotDetailData itemLotDetailData : dataDetailList) {
|
|
if (!itemLotDetailData.getTransferLine().equals("0")) {
|
|
if (Double.parseDouble(itemLotDetailData.getCurrentQty()) > 0) {
|
|
if (BarCodeList.equals("")) {
|
|
BarCodeRowList += "" + itemLotDetailData.getTransferLine() + "";
|
|
BarCodeList += "" + itemLotDetailData.getLotNo() + "";
|
|
BarCodeQtyList += "" + Double.parseDouble(itemLotDetailData.getCurrentQty()) + "";
|
|
BinCodeList += "" + itemLotDetailData.getStockCode() + "";
|
|
} else {
|
|
BarCodeRowList += "," + itemLotDetailData.getTransferLine() + "";
|
|
BarCodeList += "," + itemLotDetailData.getLotNo() + "";
|
|
BarCodeQtyList += "," + Double.parseDouble(itemLotDetailData.getCurrentQty()) + "";
|
|
BinCodeList += "," + itemLotDetailData.getStockCode() + "";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
Map params = new HashMap();
|
|
params.put("POCode", "");
|
|
params.put("PORowList", PORowList);
|
|
params.put("POQtyList", POQtyList);
|
|
params.put("BarCodeRowList", BarCodeRowList);
|
|
params.put("BarCodeList", BarCodeList);
|
|
params.put("BarCodeQtyList", BarCodeQtyList);
|
|
params.put("BinCodeList", BinCodeList);
|
|
params.put("userCode", LoginActivity.user.getUserCode());
|
|
params.put("userName", LoginActivity.user.getUserName());
|
|
params.put("workPoint", LoginActivity.user.getWorkPointCode());
|
|
params.put("Type", "调拨");
|
|
|
|
try {
|
|
result = "";
|
|
result = WebServiceUtil.GetWSReturnInfo("WareHouseTransIn", params);
|
|
if (result != null && result.length() != 0) {
|
|
applicationModel = new Gson().fromJson(result, ApplicationModel.class);
|
|
if (applicationModel.getCode().equals("0")) {
|
|
ErrorMsg = "调拨成功!";
|
|
handler.sendEmptyMessage(6);
|
|
} else {
|
|
ErrorMsg = applicationModel.getMsg();
|
|
handler.sendEmptyMessage(3);
|
|
}
|
|
}
|
|
} catch (Exception ex) {
|
|
ErrorMsg = ex.getMessage();
|
|
handler.sendEmptyMessage(99);
|
|
}
|
|
}
|
|
|
|
private void clear() {
|
|
// transferNo.setText("");
|
|
toBin.setText("");
|
|
barCode.setText("");
|
|
// transferNo.requestFocus();
|
|
dataList.clear();
|
|
dataDetailList.clear();
|
|
// ItemLotData itemLotData = new ItemLotData();
|
|
// itemLotData.setTransferLine("");
|
|
// itemLotData.setFromWHCode("");
|
|
// itemLotData.setToWHCode("");
|
|
// itemLotData.setInvCode("");
|
|
// itemLotData.setInvName("");
|
|
// itemLotData.setInvStd("");
|
|
// itemLotData.setCurrentQty("");
|
|
// itemLotData.setPlanQty("");
|
|
// itemLotData.setHasQty("");
|
|
// itemLotData.setCurrentQty("");
|
|
// itemLotData.setInvUom("");
|
|
// dataList.add(itemLotData);
|
|
tableData = new TableData<>("两步调入", dataList, columns);
|
|
smartTable.setTableData(tableData);
|
|
}
|
|
}
|