|
|
@ -50,10 +50,12 @@ import com.techscan.wk.rxbus.RxBus; |
|
|
|
import com.techscan.wk.rxretrofit.BaseObserver; |
|
|
|
import com.techscan.wk.rxretrofit.BaseResponseBean; |
|
|
|
import com.techscan.wk.rxretrofit.HttpMethods; |
|
|
|
import com.techscan.wk.rxretrofit.exception.ApiException; |
|
|
|
import com.techscan.wk.ui.baseAct.BasicDataListActivity; |
|
|
|
import com.techscan.wk.ui.scan.CustomCaptureActivity; |
|
|
|
import com.techscan.wk.utils.AntiShakeUtils; |
|
|
|
import com.techscan.wk.utils.BarAnalysisUtils; |
|
|
|
import com.techscan.wk.utils.DialogUtil; |
|
|
|
import com.techscan.wk.utils.FindUtils; |
|
|
|
import com.techscan.wk.utils.SoundUtils; |
|
|
|
import com.techscan.wk.utils.ToastUtil; |
|
|
@ -65,6 +67,9 @@ import org.litepal.LitePal; |
|
|
|
|
|
|
|
import java.lang.reflect.Type; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.net.SocketException; |
|
|
|
import java.net.SocketTimeoutException; |
|
|
|
import java.net.UnknownHostException; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
@ -118,7 +123,6 @@ public class FlowReportWorkActivity extends CommonFunctionActivity { |
|
|
|
private Map<String, List<String>> scanBarcodeListMap;//存放条码扫描明细
|
|
|
|
private boolean isSave = false; |
|
|
|
private String[] items = new String[]{}; |
|
|
|
private AnalysisBarBean barDataBean; |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void onCreate(Bundle savedInstanceState) { |
|
|
@ -422,7 +426,6 @@ public class FlowReportWorkActivity extends CommonFunctionActivity { |
|
|
|
|
|
|
|
break; |
|
|
|
case "PacketBarcode": |
|
|
|
barDataBean = null; |
|
|
|
if (TextUtils.isEmpty(value)) { |
|
|
|
setNextFocus("PacketBarcode"); |
|
|
|
showError(getString(R.string.The_packet_barcode_cannot_be_empty)); |
|
|
@ -465,12 +468,58 @@ public class FlowReportWorkActivity extends CommonFunctionActivity { |
|
|
|
break; |
|
|
|
//报工数量
|
|
|
|
case "GMNGA": |
|
|
|
DynamicFormBean PacketBarcodeItem = dynamicFormAdapter.getItemByFieldName("PacketBarcode");//包条码
|
|
|
|
String barcodeItemValue = PacketBarcodeItem.getValue(); |
|
|
|
if (TextUtils.isEmpty(barcodeItemValue)) { |
|
|
|
setNextFocus("PacketBarcode"); |
|
|
|
showError(getString(R.string.The_packet_barcode_cannot_be_empty)); |
|
|
|
return; |
|
|
|
} |
|
|
|
checkBarcode = BarAnalysisUtils.checkBarcodePresuffix(barcodeItemValue); |
|
|
|
if (!checkBarcode) { |
|
|
|
showError(getString(R.string.The_barcode_format_is_incorrect) + barcodeItemValue); |
|
|
|
for (int i = 0; i < dynamicFormBeans.size(); i++) { |
|
|
|
if (dynamicFormBeans.get(i).getFieldName().equals("AUFNR") || |
|
|
|
dynamicFormBeans.get(i).equals("ScanRule") || |
|
|
|
dynamicFormBeans.get(i).equals("FlowOrder")) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
dynamicFormBeans.get(i).setValue(""); |
|
|
|
} |
|
|
|
setNextFocus("PacketBarcode"); |
|
|
|
return; |
|
|
|
} |
|
|
|
//判断条码是否已经被扫描
|
|
|
|
if (isInBarcodeList(scanBarcodeListMap, barcodeItemValue)) { |
|
|
|
showError(getString(R.string.Do_not_scan_the_barcode_again)); |
|
|
|
for (int i = 0; i < dynamicFormBeans.size(); i++) { |
|
|
|
if (dynamicFormBeans.get(i).getFieldName().equals("AUFNR") || |
|
|
|
dynamicFormBeans.get(i).equals("ScanRule") || |
|
|
|
dynamicFormBeans.get(i).equals("FlowOrder")) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
dynamicFormBeans.get(i).setValue(""); |
|
|
|
} |
|
|
|
setNextFocus("PacketBarcode"); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
DynamicFormBean MATNRItem = dynamicFormAdapter.getItemByFieldName("MATNR");//物料号
|
|
|
|
if (TextUtils.isEmpty(MATNRItem.getValue())) { |
|
|
|
showError(getString(R.string.Please_scan_the_package_barcode_first)); |
|
|
|
setNextFocus("PacketBarcode"); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if (TextUtils.isEmpty(value)) { |
|
|
|
showError(getString(R.string.The_number_of_reports_cannot_be_empty)); |
|
|
|
setNextFocus("GMNGA"); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
AnalysisBarBean barBean = BarAnalysisUtils.analysisBarcode(PacketBarcodeItem.getValue()); |
|
|
|
barBean.setQuantity(value); |
|
|
|
|
|
|
|
LitePal |
|
|
|
.where("matnr = ?", MATNRItem.getValue()) |
|
|
|
.findAsync(FlowReportWorkProOrderBean.class) |
|
|
@ -481,7 +530,7 @@ public class FlowReportWorkActivity extends CommonFunctionActivity { |
|
|
|
dynamicFormAdapter.setFocusById(dynamicFormBean.getId()); |
|
|
|
return; |
|
|
|
} |
|
|
|
addDetailCheck(orderBeans.get(0), value); |
|
|
|
addDetailCheck(orderBeans.get(0), barBean); |
|
|
|
|
|
|
|
}); |
|
|
|
break; |
|
|
@ -525,10 +574,9 @@ public class FlowReportWorkActivity extends CommonFunctionActivity { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
barDataBean = barBean; |
|
|
|
//先根据条码物料信息比对工单产品信息
|
|
|
|
LitePal |
|
|
|
.where("matnr = ?", barDataBean.getMateriel()) |
|
|
|
.where("matnr = ?", barBean.getMateriel()) |
|
|
|
.findAsync(FlowReportWorkProOrderBean.class) |
|
|
|
.listen(orderBeans -> { |
|
|
|
if (orderBeans.size() == 0) { |
|
|
@ -541,19 +589,19 @@ public class FlowReportWorkActivity extends CommonFunctionActivity { |
|
|
|
for (DynamicFormBean d : dynamicFormBeans) { |
|
|
|
switch (d.getFieldName()) { |
|
|
|
case "MATNR"://物料号
|
|
|
|
d.setValue(barDataBean.getMateriel()); |
|
|
|
d.setValue(barBean.getMateriel()); |
|
|
|
d.setFocus(false); |
|
|
|
break; |
|
|
|
case "ZXTPC"://包装容器号 --箱号
|
|
|
|
d.setValue(barDataBean.getPackageNumber()); |
|
|
|
d.setValue(barBean.getPackageNumber()); |
|
|
|
d.setFocus(false); |
|
|
|
break; |
|
|
|
case "ZPC"://批次
|
|
|
|
d.setValue(barDataBean.getBatch()); |
|
|
|
d.setValue(barBean.getBatch()); |
|
|
|
d.setFocus(false); |
|
|
|
break; |
|
|
|
case "GMNGA"://报工数量
|
|
|
|
d.setValue(barDataBean.getQuantity()); |
|
|
|
d.setValue(barBean.getQuantity()); |
|
|
|
d.setFocus(false); |
|
|
|
break; |
|
|
|
default: |
|
|
@ -564,7 +612,7 @@ public class FlowReportWorkActivity extends CommonFunctionActivity { |
|
|
|
dynamicFormAdapter.setList(dynamicFormBeans); |
|
|
|
dynamicFormAdapter.notifyDataSetChanged(); |
|
|
|
|
|
|
|
new Handler().postDelayed(() -> addDetailCheck(orderBeans.get(0), barDataBean.getQuantity()), 300); |
|
|
|
new Handler().postDelayed(() -> addDetailCheck(orderBeans.get(0), barBean), 200); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
@ -573,25 +621,26 @@ public class FlowReportWorkActivity extends CommonFunctionActivity { |
|
|
|
/** |
|
|
|
* 加入明细前校验 |
|
|
|
*/ |
|
|
|
private void addDetailCheck(FlowReportWorkProOrderBean workProOrderBean, String quantity) { |
|
|
|
if (barDataBean == null) { |
|
|
|
private void addDetailCheck(FlowReportWorkProOrderBean workProOrderBean, AnalysisBarBean barBean) { |
|
|
|
if (barBean == null) { |
|
|
|
showError(getString(R.string.The_packet_barcode_cannot_be_empty)); |
|
|
|
setNextFocus("PacketBarcode"); |
|
|
|
return; |
|
|
|
} |
|
|
|
int count = LitePal.where("zxtpc =?", barDataBean.getPackageNumber()).count(FlowReportWorkDetailBean.class); |
|
|
|
int count = LitePal.where("zxtpc =?", barBean.getPackageNumber()).count(FlowReportWorkDetailBean.class); |
|
|
|
if (count > 0) { |
|
|
|
showError(getString(R.string.The_case_number_cannot_be_scanned_repeatedly)); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
String quantity = barBean.getQuantity(); |
|
|
|
if (TextUtils.isEmpty(quantity)) { |
|
|
|
showError(getString(R.string.The_number_of_reports_cannot_be_empty)); |
|
|
|
setNextFocus("GMNGA"); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if (Double.parseDouble(quantity) <= 0) { |
|
|
|
BigDecimal gmnga = new BigDecimal(quantity);//当前扫描的报工数量
|
|
|
|
if (gmnga.doubleValue() <= 0) { |
|
|
|
showError(getString(R.string.The_number_of_jobs_reported_cannot_be_0_or_smaller_than_0)); |
|
|
|
setNextFocus("GMNGA"); |
|
|
|
return; |
|
|
@ -613,7 +662,6 @@ public class FlowReportWorkActivity extends CommonFunctionActivity { |
|
|
|
BigDecimal psmngdecimal = new BigDecimal(psmng);//订单数量
|
|
|
|
BigDecimal gwemgdecimal = new BigDecimal(gwemg);//已交货数量
|
|
|
|
|
|
|
|
BigDecimal gmnga = new BigDecimal(quantity);//当前扫描的报工数量
|
|
|
|
|
|
|
|
//统计明细里已报工的数量
|
|
|
|
Double sum = LitePal.sum(FlowReportWorkDetailBean.class, "gmnga", double.class); |
|
|
@ -641,12 +689,12 @@ public class FlowReportWorkActivity extends CommonFunctionActivity { |
|
|
|
.addAction(getResources().getString(R.string.cancel_info), (dialog, index) -> dialog.dismiss()) |
|
|
|
.addAction(getResources().getString(R.string.confirm_info), (dialog, index) -> { |
|
|
|
dialog.dismiss(); |
|
|
|
addDetail(workProOrderBean); |
|
|
|
addDetail(workProOrderBean, gmnga.doubleValue()); |
|
|
|
}) |
|
|
|
.create(R.style.QMUI_Dialog); |
|
|
|
qmuiDialog.show(); |
|
|
|
} else { |
|
|
|
addDetail(workProOrderBean); |
|
|
|
addDetail(workProOrderBean, gmnga.doubleValue()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -654,12 +702,11 @@ public class FlowReportWorkActivity extends CommonFunctionActivity { |
|
|
|
/** |
|
|
|
* 加入明细列表 |
|
|
|
*/ |
|
|
|
private void addDetail(FlowReportWorkProOrderBean workProOrderBean) { |
|
|
|
private void addDetail(FlowReportWorkProOrderBean workProOrderBean, double quantity) { |
|
|
|
DynamicFormBean ScanRuleItem = dynamicFormAdapter.getItemByFieldName("ScanRule");//扫描规则
|
|
|
|
DynamicFormBean aufnrItem = dynamicFormAdapter.getItemByFieldName("AUFNR");//工单
|
|
|
|
DynamicFormBean flowOrderItem = dynamicFormAdapter.getItemByFieldName("FlowOrder");//流转单
|
|
|
|
DynamicFormBean PacketBarcodeItem = dynamicFormAdapter.getItemByFieldName("PacketBarcode");//包条码
|
|
|
|
DynamicFormBean gmngaItem = dynamicFormAdapter.getItemByFieldName("GMNGA");//报工数量
|
|
|
|
DynamicFormBean MATNRItem = dynamicFormAdapter.getItemByFieldName("MATNR");//物料号
|
|
|
|
DynamicFormBean ZXTPCItem = dynamicFormAdapter.getItemByFieldName("ZXTPC");//箱号
|
|
|
|
DynamicFormBean ZPCItem = dynamicFormAdapter.getItemByFieldName("ZPC");//批次
|
|
|
@ -706,7 +753,7 @@ public class FlowReportWorkActivity extends CommonFunctionActivity { |
|
|
|
bean.setFlowOrders(flowOrderItem.getValue()); |
|
|
|
bean.setFlowOrders(flowOrderSb.substring(0, flowOrderSb.length() - 1)); |
|
|
|
bean.setPacketBarcode(barcode); |
|
|
|
bean.setGmnga(gmngaItem.getValue()); |
|
|
|
bean.setGmnga(String.valueOf(quantity)); |
|
|
|
bean.setUeeto(workProOrderBean.getUeeto()); |
|
|
|
bean.setPsmng(workProOrderBean.getPsmng()); |
|
|
|
bean.setXmnga(""); |
|
|
@ -719,7 +766,6 @@ public class FlowReportWorkActivity extends CommonFunctionActivity { |
|
|
|
List<String> keyBarcodes = new ArrayList<>(); |
|
|
|
keyBarcodes.add(barcode); |
|
|
|
scanBarcodeListMap.put(gid, keyBarcodes); |
|
|
|
barDataBean = null; |
|
|
|
reInitUI(ScanRuleItem.getValue()); |
|
|
|
} else { |
|
|
|
showError(getString(R.string.Failed_to_join_details)); |
|
|
@ -745,7 +791,7 @@ public class FlowReportWorkActivity extends CommonFunctionActivity { |
|
|
|
bean.setMeinh(workProOrderBean.getAmein()); |
|
|
|
bean.setFlowOrders(flowOrderItem.getValue()); |
|
|
|
bean.setPacketBarcode(barcode); |
|
|
|
bean.setGmnga(gmngaItem.getValue()); |
|
|
|
bean.setGmnga(String.valueOf(quantity)); |
|
|
|
bean.setUeeto(workProOrderBean.getUeeto()); |
|
|
|
bean.setPsmng(workProOrderBean.getPsmng()); |
|
|
|
bean.setXmnga(""); |
|
|
@ -756,7 +802,6 @@ public class FlowReportWorkActivity extends CommonFunctionActivity { |
|
|
|
List<String> keyBarcodes = new ArrayList<>(); |
|
|
|
keyBarcodes.add(barcode); |
|
|
|
scanBarcodeListMap.put(gid, keyBarcodes); |
|
|
|
barDataBean = null; |
|
|
|
reInitUI(ScanRuleItem.getValue()); |
|
|
|
} else { |
|
|
|
showError(getString(R.string.Failed_to_join_details)); |
|
|
@ -982,7 +1027,11 @@ public class FlowReportWorkActivity extends CommonFunctionActivity { |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void onFailure(Throwable e) throws Exception { |
|
|
|
CustomErrorDialog(e, FlowReportWorkActivity.this); |
|
|
|
if (e instanceof SocketTimeoutException || e instanceof SocketException) { |
|
|
|
DialogUtil.showErrorInfoDialog(context, "响应超时,请联系管理员确认数据是否已在处理,在继续下一步操作!!!"); |
|
|
|
} else { |
|
|
|
CustomErrorDialog(e, FlowReportWorkActivity.this); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
@ -1120,15 +1169,21 @@ public class FlowReportWorkActivity extends CommonFunctionActivity { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public boolean onKeyDown(int keyCode, KeyEvent event) { |
|
|
|
if (keyCode == KeyEvent.KEYCODE_BACK) { |
|
|
|
finishActivity(); |
|
|
|
return true; |
|
|
|
} |
|
|
|
return super.onKeyDown(keyCode, event); |
|
|
|
protected void doOnBackPressed() { |
|
|
|
finishActivity(); |
|
|
|
} |
|
|
|
|
|
|
|
// @Override
|
|
|
|
// public boolean onKeyDown(int keyCode, KeyEvent event) {
|
|
|
|
// if (keyCode == KeyEvent.KEYCODE_BACK) {
|
|
|
|
// finishActivity();
|
|
|
|
// return true;
|
|
|
|
// }
|
|
|
|
// return super.onKeyDown(keyCode, event);
|
|
|
|
// }
|
|
|
|
|
|
|
|
/** |
|
|
|
* 判断界面是否填写数据 |
|
|
|
* |
|
|
|