达翔pda
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

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. package com.icssoft.icspda.activity;
  2. import androidx.appcompat.app.AppCompatActivity;
  3. import android.graphics.Color;
  4. import android.os.Bundle;
  5. import android.os.Handler;
  6. import android.os.Message;
  7. import android.os.SystemClock;
  8. import android.text.Editable;
  9. import android.text.TextUtils;
  10. import android.text.TextWatcher;
  11. import android.view.KeyEvent;
  12. import android.view.View;
  13. import android.view.inputmethod.EditorInfo;
  14. import android.widget.Button;
  15. import android.widget.EditText;
  16. import android.widget.RadioButton;
  17. import android.widget.TextView;
  18. import com.bin.david.form.core.SmartTable;
  19. import com.bin.david.form.data.column.Column;
  20. import com.bin.david.form.data.table.TableData;
  21. import com.google.gson.Gson;
  22. import com.google.gson.JsonSyntaxException;
  23. import com.google.gson.reflect.TypeToken;
  24. import com.icssoft.icspda.R;
  25. import com.icssoft.icspda.entity.ApplicationModel;
  26. import com.icssoft.icspda.entity.ItemLotData;
  27. import com.icssoft.icspda.entity.ItemLotDetailData;
  28. import com.icssoft.icspda.entity.LotDetail;
  29. import com.icssoft.icspda.net.WebServiceUtil;
  30. import com.icssoft.icspda.util.BaseDialog;
  31. import com.icssoft.icspda.util.HelpUtil;
  32. import java.util.ArrayList;
  33. import java.util.HashMap;
  34. import java.util.List;
  35. import java.util.Map;
  36. public class INVTransInActivity extends AppCompatActivity {
  37. //region 变量初始化
  38. private TextView tvMsg;
  39. private String result;
  40. private ApplicationModel applicationModel;
  41. private List<LotDetail> lotDetails;
  42. private List<ItemLotData> dataList;
  43. private List<ItemLotDetailData> dataDetailList;
  44. private SmartTable smartTable;
  45. private SmartTable smartDetailTable;
  46. // private EditText transferNo;
  47. private EditText toBin;
  48. private EditText barCode;
  49. private Button btnDel;
  50. private Button btnOk;
  51. private RadioButton rbIn;
  52. private RadioButton rbOut;
  53. private int selectRowIndex = 999;
  54. private String selectRowInvCode = "";
  55. private TableData<ItemLotData> tableData;
  56. private List<Column> columns;
  57. private String ErrorMsg = "";
  58. private Double LotQty;
  59. private String InvCode;
  60. private String WhCode;
  61. private String ToWhCode;
  62. private Double limitQty;
  63. private long[] mHits = new long[2];//存储时间的数组
  64. //endregion
  65. private Handler handler = new Handler() {
  66. @Override
  67. public void handleMessage(Message msg) {
  68. super.handleMessage(msg);
  69. switch (msg.what) {
  70. case 0:
  71. dataList.clear();
  72. dataDetailList.clear();
  73. gridBarCode();
  74. toBin.requestFocus();
  75. HelpUtil.SetMsg(tvMsg, Color.BLUE, "源头单据扫描成功!");
  76. break;
  77. // case 1:
  78. // HelpUtil.SetMsg(tvMsg, Color.RED, ErrorMsg);
  79. // transferNo.postDelayed(new Runnable() {
  80. // @Override
  81. // public void run() {
  82. // transferNo.requestFocus();
  83. // }
  84. // },1000);
  85. // break;
  86. case 2:
  87. HelpUtil.SetMsg(tvMsg, Color.RED, ErrorMsg);
  88. toBin.postDelayed(new Runnable() {
  89. @Override
  90. public void run() {
  91. toBin.requestFocus();
  92. }
  93. },1000);
  94. break;
  95. case 3:
  96. HelpUtil.SetMsg(tvMsg, Color.RED, ErrorMsg);
  97. barCode.postDelayed(new Runnable() {
  98. @Override
  99. public void run() {
  100. barCode.requestFocus();
  101. }
  102. },1000);
  103. break;
  104. case 5:
  105. barCode.requestFocus();
  106. HelpUtil.SetMsg(tvMsg, Color.BLUE, "调拨数量记录成功!");
  107. break;
  108. case 7:
  109. HelpUtil.SetMsg(tvMsg,Color.BLUE,"库位条码扫描成功!");
  110. barCode.postDelayed(new Runnable() {
  111. @Override
  112. public void run() {
  113. barCode.requestFocus();
  114. }
  115. },1000);
  116. break;
  117. case 6:
  118. clear();
  119. HelpUtil.SetMsg(tvMsg, Color.BLUE, ErrorMsg);
  120. break;
  121. case 12:
  122. barCode.requestFocus();
  123. break;
  124. case 99:
  125. HelpUtil.SetMsg(tvMsg, Color.RED, ErrorMsg);
  126. break;
  127. case 100:
  128. tableData = new TableData<>("两步调出", dataList, columns);
  129. smartTable.setTableData(tableData);
  130. HelpUtil.SetMsg(tvMsg, Color.BLUE, "移出成功");
  131. break;
  132. }
  133. }
  134. };
  135. @Override
  136. protected void onCreate(Bundle savedInstanceState) {
  137. super.onCreate(savedInstanceState);
  138. setContentView(R.layout.activity_invtransin);
  139. bindView();
  140. }
  141. private void bindView() {
  142. this.setTitle("两步调入");
  143. tvMsg = findViewById(R.id.tv_msg);
  144. smartTable = findViewById(R.id.table);
  145. // transferNo = findViewById(R.id.et_transferNo);
  146. toBin = findViewById(R.id.et_toBin);
  147. barCode = findViewById(R.id.et_barcode);
  148. btnDel = findViewById(R.id.btn_del);
  149. btnOk = findViewById(R.id.btn_ok);
  150. rbIn = findViewById(R.id.rbIn);
  151. rbOut = findViewById(R.id.rbOut);
  152. // HelpUtil.disableShowSoftInput(transferNo);
  153. // HelpUtil.disableShowSoftInput(toBin);
  154. // HelpUtil.disableShowSoftInput(barCode);
  155. dataList = new ArrayList<>();
  156. dataDetailList = new ArrayList<>();
  157. // transferNo.setOnEditorActionListener(new TextView.OnEditorActionListener() {
  158. // @Override
  159. // public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
  160. // try {
  161. // if (actionId == EditorInfo.IME_ACTION_SEND || actionId == EditorInfo.IME_ACTION_DONE || actionId == EditorInfo.IME_ACTION_NEXT
  162. // || (event != null && KeyEvent.KEYCODE_ENTER == event.getKeyCode() && KeyEvent.ACTION_DOWN == event.getAction())) {
  163. // if (v.getText().length() > 0) {
  164. // new Thread(new Runnable() {
  165. // @Override
  166. // public void run() {
  167. // CheckTransferNoOut();
  168. // }
  169. // }).start();
  170. // }
  171. // }
  172. // return false;
  173. // } catch (Exception ex) {
  174. // ErrorMsg = ex.getMessage();
  175. // handler.sendEmptyMessage(99);
  176. // }
  177. //
  178. // return false;
  179. // }
  180. // });
  181. toBin.setOnEditorActionListener(new TextView.OnEditorActionListener() {
  182. @Override
  183. public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
  184. try {
  185. if (actionId == EditorInfo.IME_ACTION_SEND || actionId == EditorInfo.IME_ACTION_DONE || actionId == EditorInfo.IME_ACTION_NEXT
  186. || (event != null && KeyEvent.KEYCODE_ENTER == event.getKeyCode() && KeyEvent.ACTION_DOWN == event.getAction())) {
  187. if (v.getText().length() > 0) {
  188. new Thread(new Runnable() {
  189. @Override
  190. public void run() {
  191. CheckStackCode();
  192. }
  193. }).start();
  194. }
  195. }
  196. return false;
  197. } catch (Exception ex) {
  198. ErrorMsg = ex.getMessage();
  199. handler.sendEmptyMessage(99);
  200. }
  201. return false;
  202. }
  203. });
  204. barCode.setOnEditorActionListener(new TextView.OnEditorActionListener() {
  205. @Override
  206. public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
  207. try {
  208. if (actionId == EditorInfo.IME_ACTION_SEND || actionId == EditorInfo.IME_ACTION_DONE || actionId == EditorInfo.IME_ACTION_NEXT
  209. || (event != null && KeyEvent.KEYCODE_ENTER == event.getKeyCode() && KeyEvent.ACTION_DOWN == event.getAction())) {
  210. if (v.toString().length() > 0) {
  211. if (TextUtils.isEmpty(toBin.getText().toString().trim())) {
  212. ErrorMsg = "请先扫描目标库位!";
  213. handler.sendEmptyMessage(2);
  214. }
  215. if (rbIn.isChecked()) {
  216. for (ItemLotDetailData itemLotDetailData : dataDetailList) {
  217. if (itemLotDetailData.getInvCode().equals(barCode.getText())) {
  218. ErrorMsg = "请勿扫描重复条码!";
  219. handler.sendEmptyMessage(3);
  220. }
  221. }
  222. }
  223. new Thread(new Runnable() {
  224. @Override
  225. public void run() {
  226. CheckLotNoForTransIn();
  227. }
  228. }).start();
  229. }
  230. }
  231. return false;
  232. } catch (Exception ex) {
  233. ErrorMsg = ex.getMessage();
  234. handler.sendEmptyMessage(99);
  235. }
  236. return false;
  237. }
  238. });
  239. btnDel.setOnClickListener(new View.OnClickListener() {
  240. @Override
  241. public void onClick(View v) {
  242. try {
  243. // if (tableData != null && selectRowIndex != 999 && !TextUtils.isEmpty(selectRowInvCode)) {
  244. // for (ItemLotData itemLotData : dataList) {
  245. // if (itemLotData.getInvCode().equals(selectRowInvCode))
  246. // dataList.remove(itemLotData);
  247. // }
  248. //
  249. // tableData = new TableData<>("两步调入", dataList, columns);
  250. // smartTable.setTableData(tableData);
  251. //
  252. // for (ItemLotDetailData itemLotDetailData : dataDetailList) {
  253. // if (itemLotDetailData.getInvCode().equals(selectRowInvCode)) {
  254. // dataDetailList.remove(itemLotDetailData);
  255. // }
  256. // }
  257. //
  258. // HelpUtil.SetMsg(tvMsg, Color.BLUE, "物料编码:" + selectRowInvCode + ",移除成功!");
  259. // selectRowInvCode = "";
  260. // selectRowIndex = 999;
  261. // } else {
  262. // HelpUtil.SetMsg(tvMsg, Color.RED, "尚未扫入任何条码!");
  263. // }
  264. if (tableData != null && selectRowIndex != 999 && !TextUtils.isEmpty(selectRowInvCode)) {
  265. for (ItemLotDetailData itemLotDetailData : dataDetailList) {
  266. if (itemLotDetailData.getInvCode().equals(selectRowInvCode))
  267. dataDetailList.remove(itemLotDetailData);
  268. }
  269. tableData = new TableData<>("两步调入", dataList, columns);
  270. smartTable.setTableData(tableData);
  271. for (ItemLotData itemLotData : dataList) {
  272. itemLotData.setCurrentQty("0.0");
  273. }
  274. HelpUtil.SetMsg(tvMsg, Color.BLUE, "物料编码:" + selectRowInvCode + ",移除成功!");
  275. selectRowInvCode = "";
  276. selectRowIndex = 999;
  277. } else {
  278. HelpUtil.SetMsg(tvMsg, Color.RED, "尚未扫入任何条码!");
  279. }
  280. } catch (Exception ex) {
  281. HelpUtil.SetMsg(tvMsg, Color.RED, ex.getMessage());
  282. }
  283. }
  284. });
  285. btnOk.setOnClickListener(new View.OnClickListener() {
  286. @Override
  287. public void onClick(View v) {
  288. if (dataList.size() <= 0) {
  289. HelpUtil.SetMsg(tvMsg, Color.RED, "请先扫描条码!");
  290. barCode.requestFocus();
  291. return;
  292. }
  293. new Thread(new Runnable() {
  294. @Override
  295. public void run() {
  296. WareHouseTransIn();
  297. }
  298. }).start();
  299. }
  300. });
  301. }
  302. public void CheckTransferNoOut() {
  303. Map params = new HashMap();
  304. params.put("TransferNo", "");
  305. params.put("WorkPointCode", LoginActivity.user.getWorkPointCode());
  306. try {
  307. result = "";
  308. result = WebServiceUtil.GetWSReturnInfo("CheckTransferNoOut", params);
  309. if (result != null && result.length() != 0) {
  310. applicationModel = new Gson().fromJson(result, ApplicationModel.class);
  311. if (applicationModel.getCode().equals("0")) {
  312. GetTransferDataIn();
  313. handler.sendEmptyMessage(0);
  314. } else {
  315. ErrorMsg = applicationModel.getMsg();
  316. handler.sendEmptyMessage(1);
  317. return;
  318. }
  319. }
  320. } catch (Exception ex) {
  321. ErrorMsg = ex.getMessage();
  322. handler.sendEmptyMessage(99);
  323. }
  324. }
  325. private void GetTransferDataIn() {
  326. Map params = new HashMap();
  327. params.put("TransferNo", "");
  328. params.put("workPoint", LoginActivity.user.getWorkPointCode());
  329. try {
  330. result = "";
  331. result = WebServiceUtil.GetWSReturnInfo("GetTransferDataIn", params);
  332. } catch (Exception ex) {
  333. ErrorMsg = ex.getMessage();
  334. handler.sendEmptyMessage(99);
  335. }
  336. }
  337. private void gridBarCode() {
  338. dataList = new Gson().fromJson(result, new TypeToken<ArrayList<ItemLotData>>() {
  339. }.getType());
  340. WhCode = dataList.get(dataList.size() - 1).getToWHCode();
  341. ToWhCode = dataList.get(dataList.size() - 1).getToWHCode();
  342. HelpUtil.InitSmartTable(smartTable, this.getApplicationContext());
  343. //region 声明列
  344. columns = new ArrayList<>();
  345. columns.add(new Column("序号", "TransferLine"));
  346. columns.add(new Column("源仓库", "FromWHCode"));
  347. columns.add(new Column("目标仓库", "ToWHCode"));
  348. columns.add(new Column("物料编码", "InvCode"));
  349. columns.add(new Column("物料名称", "InvName"));
  350. columns.add(new Column("规格型号", "InvStd"));
  351. columns.add(new Column("计划数量", "PlanQty"));
  352. columns.add(new Column("已发数量", "HasQty"));
  353. columns.add(new Column("本次数量", "CurrentQty"));
  354. columns.add(new Column("单位", "InvUom"));
  355. // columns.add(new Column("项目号", "OrderNo"));
  356. // columns.add(new Column("批次", "Batch"));
  357. //endregion
  358. tableData = new TableData<>("两步调入", dataList, columns);
  359. tableData.setOnRowClickListener(new TableData.OnRowClickListener<ItemLotData>() {
  360. @Override
  361. public void onClick(Column column, ItemLotData itemLotData, int col, final int row) {
  362. System.arraycopy(mHits, 1, mHits, 0, mHits.length - 1);
  363. mHits[mHits.length - 1] = SystemClock.uptimeMillis();
  364. if (mHits[0] >= (SystemClock.uptimeMillis() - 500)) {
  365. showSMTableDialog(itemLotData.getInvCode(), itemLotData.getTransferLine());
  366. } else {
  367. HelpUtil.ChangeRowBackgroundColor(smartTable, row);
  368. smartTable.invalidate();
  369. selectRowIndex = row;
  370. selectRowInvCode = itemLotData.getInvCode();
  371. // selectRowVouchNo = dispatchListData.getVouchRow();
  372. HelpUtil.SetMsg(tvMsg, Color.BLUE, "当前选中第" + row + "行,物料编码为:" + itemLotData.getInvCode());
  373. }
  374. }
  375. });
  376. smartTable.setTableData(tableData);
  377. }
  378. private void CheckStackCode() {
  379. Map params = new HashMap();
  380. params.put("StackCode", toBin.getText().toString());
  381. params.put("WorkPointCode", LoginActivity.user.getWorkPointCode());
  382. try {
  383. result = "";
  384. result = WebServiceUtil.GetWSReturnInfo("CheckStackCode", params);
  385. if (result != null && result.length() != 0) {
  386. applicationModel = new Gson().fromJson(result, ApplicationModel.class);
  387. if (applicationModel.getCode().equals("0")) {
  388. for (LotDetail lot:lotDetails){
  389. if (!applicationModel.getData().equals(lot.getWHCode())) {
  390. ErrorMsg = "目标库位与源头单据不符,请确认后重新扫描!";
  391. handler.sendEmptyMessage(2);
  392. } else {
  393. handler.sendEmptyMessage(7);
  394. }
  395. }
  396. } else {
  397. ErrorMsg = "库位条码不存在!";
  398. handler.sendEmptyMessage(2);
  399. }
  400. }
  401. } catch (Exception ex) {
  402. ErrorMsg = ex.getMessage();
  403. handler.sendEmptyMessage(99);
  404. }
  405. }
  406. private void showSMTableDialog(String InvCode, String TransferLine) {
  407. List<ItemLotDetailData> dData = new ArrayList<>();
  408. for (ItemLotDetailData itemLotDetailData : dataDetailList) {
  409. if (itemLotDetailData.getTransferLine().equals(TransferLine)
  410. && itemLotDetailData.getInvCode().equals(InvCode)) {
  411. dData.add(itemLotDetailData);
  412. }
  413. }
  414. View tableView = View.inflate(this, R.layout.detialinfo, null);
  415. smartDetailTable = tableView.findViewById(R.id.detailTable);
  416. smartDetailTable.getConfig().setShowTableTitle(false);
  417. smartDetailTable.getConfig().setShowXSequence(false);
  418. smartDetailTable.getConfig().setShowYSequence(false);
  419. smartDetailTable.getConfig().setFixedTitle(true);
  420. smartDetailTable.setData(dData);
  421. BaseDialog dialog = new BaseDialog.Builder(this).setFillWidth(true).setContentView(tableView).create();
  422. dialog.show();
  423. }
  424. private void CheckLotNoForTransIn() {
  425. Map params = new HashMap();
  426. params.put("TransNO", "");
  427. params.put("BarCode", barCode.getText().toString().trim());
  428. params.put("WorkPointCode", LoginActivity.user.getWorkPointCode());
  429. try {
  430. result = "";
  431. result = WebServiceUtil.GetWSReturnInfo("CheckLotnoForTransIn", params);
  432. if (result.equals("[{}]")) {
  433. ErrorMsg = "条码不存在!";
  434. handler.sendEmptyMessage(3);
  435. return;
  436. } else {
  437. GetLotData();
  438. }
  439. } catch (Exception ex) {
  440. ErrorMsg = ex.getMessage();
  441. handler.sendEmptyMessage(99);
  442. }
  443. }
  444. private void GetLotData() {
  445. try {
  446. boolean isExist = false;
  447. Double planQty = 0.0;
  448. Double currentQty = 0.0;
  449. Double sendQty = 0.0;
  450. lotDetails = new Gson().fromJson(result, new TypeToken<ArrayList<LotDetail>>() {
  451. }.getType());
  452. if (rbIn.isChecked()) {
  453. for (LotDetail lot : lotDetails) {
  454. for (int i = 0; i < dataList.size(); i++) {
  455. ItemLotData itemLotData = dataList.get(i);
  456. if (itemLotData.getFromWHCode().equals(lot.getWHCode())
  457. && itemLotData.getInvCode().equals(lot.getInvCode())) {
  458. planQty += Double.parseDouble(itemLotData.getPlanQty());
  459. currentQty += Double.parseDouble(itemLotData.getCurrentQty());
  460. sendQty += Double.parseDouble(itemLotData.getHasQty());
  461. isExist = true;
  462. selectRowIndex = i;
  463. HelpUtil.ChangeRowBackgroundColor(smartTable, selectRowIndex);
  464. break;
  465. }
  466. }
  467. if (isExist) {
  468. LotQty = lot.getLotQty();
  469. InvCode = lot.getInvCode();
  470. if (planQty < currentQty + sendQty + LotQty) {
  471. ErrorMsg = "扫描的条码数量超出了剩余计划数量,请确认后重新扫描";
  472. handler.sendEmptyMessage(3);
  473. return;
  474. }
  475. for (ItemLotDetailData itemLotDetailData : dataDetailList) {
  476. if (itemLotDetailData.getLotNo().toUpperCase().equals(lot.getLotNo().toUpperCase())) {
  477. ErrorMsg = "请勿扫描重复条码!";
  478. handler.sendEmptyMessage(3);
  479. return;
  480. }
  481. }
  482. } else {
  483. ErrorMsg = "条码对应仓库及物料与源头单据不符!";
  484. handler.sendEmptyMessage(3);
  485. return;
  486. }
  487. SetMainTableQty();
  488. DetailSum();
  489. tableData = new TableData<>("两步调入", dataList, columns);
  490. smartTable.setTableData(tableData);
  491. handler.sendEmptyMessage(5);
  492. }
  493. } else if (rbOut.isChecked()) {
  494. if (dataDetailList != null && dataDetailList.size() > 0 && !dataDetailList.get(0).getTransferLine().equals("0")) {
  495. for (int i = dataDetailList.size() - 1; i >= 0; i--) {
  496. ItemLotDetailData rows = dataDetailList.get(i);
  497. if (rows.getLotNo().toUpperCase().equals(barCode.getText().toString().toUpperCase())) {
  498. for (ItemLotData row : dataList) {
  499. if (rows.getInvCode().equals(row.getInvCode()) && Double.parseDouble(row.getCurrentQty()) > 0
  500. && rows.getTransferLine().equals(row.getTransferLine())) {
  501. row.setCurrentQty(Double.parseDouble(row.getCurrentQty()) - Double.parseDouble(rows.getCurrentQty()) + "");
  502. dataDetailList.remove(rows);
  503. handler.sendEmptyMessage(100);
  504. break;
  505. }
  506. }
  507. }
  508. }
  509. }
  510. }
  511. } catch (Exception ex) {
  512. ErrorMsg = ex.getMessage();
  513. handler.sendEmptyMessage(99);
  514. }
  515. }
  516. private void SetMainTableQty() {
  517. for (int j = 0; j < dataList.size(); j++) {
  518. ItemLotData row = dataList.get(j);
  519. String ItemCode = row.getInvCode();
  520. Double PlanQTY = Double.parseDouble(row.getPlanQty());
  521. Double SendQTY = Double.parseDouble(row.getHasQty());
  522. Double CurrentQTY = Double.parseDouble(row.getCurrentQty());
  523. if (ItemCode.equals(InvCode)) {
  524. if (LotQty > PlanQTY - SendQTY - CurrentQTY && PlanQTY - SendQTY - CurrentQTY != 0 && LotQty != 0) {
  525. LotQty = LotQty - (PlanQTY - SendQTY - CurrentQTY);
  526. row.setCurrentQty((CurrentQTY + (PlanQTY - SendQTY - CurrentQTY)) + "");
  527. ItemLotDetailData itemLotDetailData = new ItemLotDetailData();
  528. itemLotDetailData.setLotNo(barCode.getText().toString().trim());
  529. itemLotDetailData.setInvCode(row.getInvCode());
  530. itemLotDetailData.setInvName(row.getInvName());
  531. itemLotDetailData.setLotQty(LotQty.toString());
  532. itemLotDetailData.setTransferLine(row.getTransferLine());
  533. itemLotDetailData.setCurrentQty((PlanQTY - SendQTY - CurrentQTY) + "");
  534. itemLotDetailData.setStockCode(toBin.getText().toString().trim());
  535. // itemLotDetailData.setTransferNo(transferNo.getText().toString().trim());
  536. dataDetailList.add(itemLotDetailData);
  537. } else if (LotQty <= PlanQTY - SendQTY && LotQty != 0 && (PlanQTY - SendQTY - CurrentQTY) != 0) {
  538. row.setCurrentQty((CurrentQTY + LotQty) + "");
  539. ItemLotDetailData itemLotDetailData = new ItemLotDetailData();
  540. itemLotDetailData.setLotNo(barCode.getText().toString().trim());
  541. itemLotDetailData.setInvCode(row.getInvCode());
  542. itemLotDetailData.setInvName(row.getInvName());
  543. itemLotDetailData.setLotQty(LotQty.toString());
  544. itemLotDetailData.setTransferLine(row.getTransferLine());
  545. itemLotDetailData.setCurrentQty(LotQty + "");
  546. itemLotDetailData.setStockCode(toBin.getText().toString().trim());
  547. // itemLotDetailData.setTransferNo(transferNo.getText().toString().trim());
  548. dataDetailList.add(itemLotDetailData);
  549. LotQty = 0.00;
  550. }
  551. }
  552. }
  553. }
  554. private void DetailSum() {
  555. List<ItemLotDetailData> newDataDetailList = new ArrayList<>();
  556. for (ItemLotDetailData row : dataDetailList) {
  557. if (newDataDetailList != null) {
  558. if (newDataDetailList.size() > 0) {
  559. for (ItemLotDetailData item : newDataDetailList) {
  560. if (item.getInvCode().toUpperCase().equals(row.getInvCode().toUpperCase())
  561. && item.getTransferLine().equals(row.getTransferLine())) {
  562. item.setCurrentQty((Double.parseDouble(item.getCurrentQty()) + Double.parseDouble(row.getCurrentQty())) + "");
  563. } else {
  564. newDataDetailList.add(row);
  565. }
  566. }
  567. } else {
  568. newDataDetailList.add(row);
  569. }
  570. }
  571. }
  572. dataDetailList = newDataDetailList;
  573. }
  574. private void WareHouseTransIn() {
  575. String PORowList = "";
  576. String POQtyList = "";
  577. String BarCodeList = "";
  578. String BarCodeQtyList = "";
  579. String BinCodeList = "";
  580. String BarCodeRowList = "";
  581. Double PlanQty = 0.0;
  582. Double HasQty = 0.0;
  583. for (ItemLotData itemLotData : dataList) {
  584. PlanQty += Double.parseDouble(itemLotData.getPlanQty());//计划数量
  585. HasQty += Double.parseDouble(itemLotData.getHasQty()) + Double.parseDouble(itemLotData.getCurrentQty());//已发数量+本次数量
  586. }
  587. if (PlanQty > HasQty) {
  588. ErrorMsg = "该单据尚有条码未扫入,请补全后再提交!";
  589. handler.sendEmptyMessage(3);
  590. return;
  591. }
  592. for (ItemLotData itemLotData : dataList) {
  593. if (Double.parseDouble(itemLotData.getCurrentQty()) > 0) {
  594. if (PORowList.equals("")) {
  595. PORowList += "" + itemLotData.getTransferLine() + "";
  596. POQtyList += "" + Double.parseDouble(itemLotData.getCurrentQty()) + "";
  597. } else {
  598. PORowList += "," + itemLotData.getTransferLine() + "";
  599. POQtyList += "," + Double.parseDouble(itemLotData.getCurrentQty()) + "";
  600. }
  601. }
  602. }
  603. for (ItemLotDetailData itemLotDetailData : dataDetailList) {
  604. if (!itemLotDetailData.getTransferLine().equals("0")) {
  605. if (Double.parseDouble(itemLotDetailData.getCurrentQty()) > 0) {
  606. if (BarCodeList.equals("")) {
  607. BarCodeRowList += "" + itemLotDetailData.getTransferLine() + "";
  608. BarCodeList += "" + itemLotDetailData.getLotNo() + "";
  609. BarCodeQtyList += "" + Double.parseDouble(itemLotDetailData.getCurrentQty()) + "";
  610. BinCodeList += "" + itemLotDetailData.getStockCode() + "";
  611. } else {
  612. BarCodeRowList += "," + itemLotDetailData.getTransferLine() + "";
  613. BarCodeList += "," + itemLotDetailData.getLotNo() + "";
  614. BarCodeQtyList += "," + Double.parseDouble(itemLotDetailData.getCurrentQty()) + "";
  615. BinCodeList += "," + itemLotDetailData.getStockCode() + "";
  616. }
  617. }
  618. }
  619. }
  620. Map params = new HashMap();
  621. params.put("POCode", "");
  622. params.put("PORowList", PORowList);
  623. params.put("POQtyList", POQtyList);
  624. params.put("BarCodeRowList", BarCodeRowList);
  625. params.put("BarCodeList", BarCodeList);
  626. params.put("BarCodeQtyList", BarCodeQtyList);
  627. params.put("BinCodeList", BinCodeList);
  628. params.put("userCode", LoginActivity.user.getUserCode());
  629. params.put("userName", LoginActivity.user.getUserName());
  630. params.put("workPoint", LoginActivity.user.getWorkPointCode());
  631. params.put("Type", "调拨");
  632. try {
  633. result = "";
  634. result = WebServiceUtil.GetWSReturnInfo("WareHouseTransIn", params);
  635. if (result != null && result.length() != 0) {
  636. applicationModel = new Gson().fromJson(result, ApplicationModel.class);
  637. if (applicationModel.getCode().equals("0")) {
  638. ErrorMsg = "调拨成功!";
  639. handler.sendEmptyMessage(6);
  640. } else {
  641. ErrorMsg = applicationModel.getMsg();
  642. handler.sendEmptyMessage(3);
  643. }
  644. }
  645. } catch (Exception ex) {
  646. ErrorMsg = ex.getMessage();
  647. handler.sendEmptyMessage(99);
  648. }
  649. }
  650. private void clear() {
  651. // transferNo.setText("");
  652. toBin.setText("");
  653. barCode.setText("");
  654. // transferNo.requestFocus();
  655. dataList.clear();
  656. dataDetailList.clear();
  657. // ItemLotData itemLotData = new ItemLotData();
  658. // itemLotData.setTransferLine("");
  659. // itemLotData.setFromWHCode("");
  660. // itemLotData.setToWHCode("");
  661. // itemLotData.setInvCode("");
  662. // itemLotData.setInvName("");
  663. // itemLotData.setInvStd("");
  664. // itemLotData.setCurrentQty("");
  665. // itemLotData.setPlanQty("");
  666. // itemLotData.setHasQty("");
  667. // itemLotData.setCurrentQty("");
  668. // itemLotData.setInvUom("");
  669. // dataList.add(itemLotData);
  670. tableData = new TableData<>("两步调入", dataList, columns);
  671. smartTable.setTableData(tableData);
  672. }
  673. }