@ -75,9 +75,10 @@ import butterknife.OnClick;
import io.reactivex.disposables.Disposable ;
import okhttp3.ResponseBody ;
import q.rorbin.badgeview.QBadgeView ;
/ * *
* 流转单报工
* Description : 流转单报工
* @author MULEI
* @date 2024 / 9 / 11
* /
public class FlowReportWorkActivity extends CommonFunctionActivity {
@ -122,7 +123,6 @@ public class FlowReportWorkActivity extends CommonFunctionActivity {
if ( savedInstanceState = = null ) {
clearAllData ( ) ;
}
StatusBarUtil . setStatusBarColor ( this , ContextCompat . getColor ( this , R . color . app_color_blue ) ) ;
ButterKnife . bind ( this ) ;
setBody ( true ) ;
scanBarcodeListMap = new HashMap < > ( ) ;
@ -286,17 +286,28 @@ public class FlowReportWorkActivity extends CommonFunctionActivity {
menuDialogBuilder . addItems ( items , new DialogInterface . OnClickListener ( ) {
@Override
public void onClick ( DialogInterface dialog , int which ) {
if ( finalSelectIndex ! = - 1 & & which ! = finalSelectIndex ) {
dialog . dismiss ( ) ;
int count = LitePal . count ( FlowOrderDetailBean . class ) ;
int detailCount = LitePal . count ( FlowReportWorkDetailBean . class ) ;
if ( rvUiHaveData ( ) | | count > 0 | | detailCount > 0 ) {
if ( which = = finalSelectIndex | | ( ! rvUiHaveData ( ) & & count = = 0 & & detailCount = = 0 ) ) {
dialog . dismiss ( ) ;
String item = items [ which ] ;
dynamicFormBean . setValue ( item ) ;
dynamicFormAdapter . setItemByFieldName ( dynamicFormBean . getFieldName ( ) , dynamicFormBean ) ;
dynamicFormAdapter . notifyDataSetChanged ( ) ;
if ( item . equals ( items [ 1 ] ) ) {
llflowOrderDetail . setVisibility ( View . VISIBLE ) ;
} else {
llflowOrderDetail . setVisibility ( View . GONE ) ;
}
return ;
}
dialog . dismiss ( ) ;
new QMUIDialog . MessageDialogBuilder ( context ) . setTitle ( getResources ( ) . getString ( R . string . tips_title ) )
. setCancelable ( false )
. setMessage ( getString ( R . string . Do_you_want_to_change_scan_rules_Switching_will_clear_the_interface_and_all_scan_details ) )
. addAction ( getResources ( ) . getString ( R . string . cancel_info ) , ( dialog1 , index ) - > dialog1 . dismiss ( ) )
. addAction ( getResources ( ) . getString ( R . string . confirm_info ) , ( dialog1 , index ) - > {
dialog1 . dismiss ( ) ;
initRvData ( ) ;
scanBarcodeListMap = new HashMap < > ( ) ;
LitePal . deleteAll ( FlowOrderDetailBean . class ) ;
@ -312,33 +323,11 @@ public class FlowReportWorkActivity extends CommonFunctionActivity {
} else {
llflowOrderDetail . setVisibility ( View . GONE ) ;
}
dialog1 . dismiss ( ) ;
} )
. create ( R . style . QMUI_Dialog ) . show ( ) ;
} else {
String item = items [ which ] ;
dynamicFormBean . setValue ( item ) ;
dynamicFormAdapter . setItemByFieldName ( dynamicFormBean . getFieldName ( ) , dynamicFormBean ) ;
dynamicFormAdapter . notifyDataSetChanged ( ) ;
if ( item . equals ( items [ 1 ] ) ) {
llflowOrderDetail . setVisibility ( View . VISIBLE ) ;
} else {
llflowOrderDetail . setVisibility ( View . GONE ) ;
}
}
} else {
dialog . dismiss ( ) ;
String item = items [ which ] ;
dynamicFormBean . setValue ( item ) ;
dynamicFormAdapter . setItemByFieldName ( dynamicFormBean . getFieldName ( ) , dynamicFormBean ) ;
dynamicFormAdapter . notifyDataSetChanged ( ) ;
if ( item . equals ( items [ 1 ] ) ) {
llflowOrderDetail . setVisibility ( View . VISIBLE ) ;
} else {
llflowOrderDetail . setVisibility ( View . GONE ) ;
}
}
}
} ) ;
menuDialogBuilder . setCheckedIndex ( selectIndex ) ;
@ -348,29 +337,10 @@ public class FlowReportWorkActivity extends CommonFunctionActivity {
dynamicFormAdapter . setOnFormItemViewActionListener ( ( dynamicFormBean , position ) - > {
String value = dynamicFormBean . getValue ( ) ;
switch ( dynamicFormBean . getFieldName ( ) ) {
case "AUFNR" :
// DynamicFormBean scanRuleItem = dynamicFormAdapter.getItemByFieldName("ScanRule");
//// String value1 = scanRuleItem.getValue();
//// if (TextUtils.isEmpty(value1)) {
//// dynamicFormAdapter.setFocusAndClearValueById(dynamicFormBean.getId());
//// showError(getString(R.string.Select_a_scan_rule_first));
//// return;
//// }
// if (TextUtils.isEmpty(value)) {
// showError(getString(R.string.The_work_order_number_cannot_be_empty));
// return;
// }
// dynamicFormBean.setCanChange(false);
// dynamicFormAdapter.notifyDataSetChanged();
// setNextFocus("FlowOrder");
break ;
case "FlowOrder" :
//工单栏目
DynamicFormBean AUFNRItem = dynamicFormAdapter . getItemByFieldName ( "AUFNR" ) ;
// if (TextUtils.isEmpty(AUFNRItem.getValue())) {
// showError(getString(R.string.The_work_order_number_cannot_be_empty));
// return;
// }
//扫描规则栏目
DynamicFormBean scanRuleItem = dynamicFormAdapter . getItemByFieldName ( "ScanRule" ) ;
if ( TextUtils . isEmpty ( scanRuleItem . getValue ( ) ) ) {
dynamicFormAdapter . setFocusAndClearValueById ( dynamicFormBean . getId ( ) ) ;
@ -389,23 +359,35 @@ public class FlowReportWorkActivity extends CommonFunctionActivity {
return ;
}
if ( value . startsWith ( "T" ) & & value . length ( ) > 9 ) {
if ( ! value . startsWith ( "T" ) ) {
ToastUtils . showLong ( R . string . The_flow_order_number_format_is_incorrect ) ;
dynamicFormAdapter . setFocusById ( dynamicFormBean . getId ( ) ) ;
return ;
}
if ( value . length ( ) < 9 ) {
ToastUtils . showLong ( R . string . The_flow_order_number_format_is_incorrect ) ;
dynamicFormAdapter . setFocusById ( dynamicFormBean . getId ( ) ) ;
return ;
}
//截取流程单号中的工单号
int t = value . indexOf ( "T" ) ;
String workOrder = value . substring ( t + 1 , 9 ) ;
String aufnrItemValue = AUFNRItem . getValue ( ) ;
//如果工单号为空,直接赋值到工单号
if ( TextUtils . isEmpty ( aufnrItemValue ) ) {
AUFNRItem . setValue ( workOrder ) ;
AUFNRItem . setCanChange ( false ) ;
LitePal . deleteAll ( FlowReportWorkProOrderBean . class ) ;
query ( workOrder , value , scanRuleItem , dynamicFormBean ) ;
dynamicFormAdapter . setItemByFieldName ( AUFNRItem . getFieldName ( ) , AUFNRItem ) ;
dynamicFormAdapter . notifyDataSetChanged ( ) ;
} else {
query ( workOrder , value , scanRuleItem , AUFNRItem , dynamicFormBean ) ;
return ;
}
//如果工单号不为空,判断扫描的工单号是否与上一次工单号一致。
//不一致提醒,不让继续操作
if ( ! workOrder . equals ( aufnrItemValue ) ) {
ToastUtils . showLong ( R . string . order_number_in_the_flow_order_is_inconsistent ) ;
dynamicFormAdapter . setFocusById ( dynamicFormBean . getId ( ) ) ;
return ;
} else {
}
//如果是多个流转单一个箱码
if ( scanRuleItem . getValue ( ) . equals ( items [ 1 ] ) ) {
LitePal
. where ( "flowOrder = ?" , value )
@ -426,20 +408,12 @@ public class FlowReportWorkActivity extends CommonFunctionActivity {
dynamicFormAdapter . setFocusAndClearValueById ( dynamicFormBean . getId ( ) ) ;
} ) ;
} else {
//否则是一个流转单多个箱码
dynamicFormBean . setCanChange ( false ) ;
dynamicFormAdapter . notifyDataSetChanged ( ) ;
setNextFocus ( "PacketBarcode" ) ;
}
}
}
} else {
ToastUtils . showLong ( R . string . The_flow_order_number_format_is_incorrect ) ;
dynamicFormAdapter . setFocusById ( dynamicFormBean . getId ( ) ) ;
return ;
}
break ;
case "PacketBarcode" :
if ( TextUtils . isEmpty ( value ) ) {
@ -448,6 +422,7 @@ public class FlowReportWorkActivity extends CommonFunctionActivity {
return ;
}
scanRuleItem = dynamicFormAdapter . getItemByFieldName ( "ScanRule" ) ;
//如果是多个流转单一个箱码
if ( scanRuleItem . getValue ( ) . equals ( items [ 1 ] ) ) {
int count = LitePal . count ( FlowOrderDetailBean . class ) ;
if ( count = = 0 ) {
@ -457,6 +432,7 @@ public class FlowReportWorkActivity extends CommonFunctionActivity {
return ;
}
} else {
//否则是一个流转单多个箱码
DynamicFormBean FlowOrderItem = dynamicFormAdapter . getItemByFieldName ( "FlowOrder" ) ;
if ( TextUtils . isEmpty ( FlowOrderItem . getValue ( ) ) ) {
dynamicFormBean . setValue ( "" ) ;
@ -490,10 +466,11 @@ public class FlowReportWorkActivity extends CommonFunctionActivity {
} ) ;
}
/ * *
* 加入明细列表
* /
private void addDetail ( ) {
DynamicFormBean ScanRuleItem = dynamicFormAdapter . getItemByFieldName ( "ScanRule" ) ; //扫描规则
String gid = System . currentTimeMillis ( ) + "" ;
DynamicFormBean aufnrItem = dynamicFormAdapter . getItemByFieldName ( "AUFNR" ) ; //工单
DynamicFormBean flowOrderItem = dynamicFormAdapter . getItemByFieldName ( "FlowOrder" ) ; //流转单
DynamicFormBean PacketBarcodeItem = dynamicFormAdapter . getItemByFieldName ( "PacketBarcode" ) ; //包条码
@ -501,6 +478,7 @@ public class FlowReportWorkActivity extends CommonFunctionActivity {
DynamicFormBean MATNRItem = dynamicFormAdapter . getItemByFieldName ( "MATNR" ) ; //物料号
DynamicFormBean ZXTPCItem = dynamicFormAdapter . getItemByFieldName ( "ZXTPC" ) ; //箱号
DynamicFormBean ZPCItem = dynamicFormAdapter . getItemByFieldName ( "ZPC" ) ; //批次
String gid = System . currentTimeMillis ( ) + "" ;
String barcode = PacketBarcodeItem . getValue ( ) ;
if ( TextUtils . isEmpty ( aufnrItem . getValue ( ) ) ) {
setNextFocus ( "AUFNR" ) ;
@ -550,6 +528,7 @@ public class FlowReportWorkActivity extends CommonFunctionActivity {
FlowReportWorkDetailBean bean = new FlowReportWorkDetailBean ( ) ;
bean . setGid ( gid ) ;
bean . setAufnr ( aufnrItem . getValue ( ) ) ;
bean . setMatnr ( MATNRItem . getValue ( ) ) ;
bean . setVornr ( "" ) ;
bean . setZxtpc ( ZXTPCItem . getValue ( ) ) ;
bean . setZpc ( ZPCItem . getValue ( ) ) ;
@ -576,6 +555,7 @@ public class FlowReportWorkActivity extends CommonFunctionActivity {
} ) ;
} else {
//如果规则是一个流转单多个箱码
if ( TextUtils . isEmpty ( flowOrderItem . getValue ( ) ) ) {
setNextFocus ( "FlowOrder" ) ;
showError ( getString ( R . string . Please_scan_the_transfer_slip_first ) ) ;
@ -585,6 +565,7 @@ public class FlowReportWorkActivity extends CommonFunctionActivity {
FlowReportWorkDetailBean bean = new FlowReportWorkDetailBean ( ) ;
bean . setGid ( gid ) ;
bean . setAufnr ( aufnrItem . getValue ( ) ) ;
bean . setMatnr ( MATNRItem . getValue ( ) ) ;
bean . setVornr ( "" ) ;
bean . setZxtpc ( ZXTPCItem . getValue ( ) ) ;
bean . setZpc ( ZPCItem . getValue ( ) ) ;
@ -609,8 +590,15 @@ public class FlowReportWorkActivity extends CommonFunctionActivity {
}
private void query ( String workOrder , String flowOrder , DynamicFormBean scanRuleItem , DynamicFormBean dynamicFormBean ) {
/ * *
* 根据工单获取产品信息
* @param workOrder 工单号
* @param flowOrder 流转单号
* @param scanRuleItem 扫描规则栏目
* @param AUFNRItem 工单号栏目
* @param dynamicFormBean 当前栏目 , 也就是流转单号栏目
* /
private void query ( String workOrder , String flowOrder , DynamicFormBean scanRuleItem , DynamicFormBean AUFNRItem , DynamicFormBean dynamicFormBean ) {
HttpMethods . getInstance ( ) . getOrderInfo ( workOrder , new BaseObserver < ResponseBody > ( context ) {
@Override
protected void onSuccess ( ResponseBody body ) throws Exception {
@ -618,9 +606,27 @@ public class FlowReportWorkActivity extends CommonFunctionActivity {
Type objectType = new TypeToken < BaseResponseBean < List < FlowReportWorkProOrderBean > > > ( ) {
} . getType ( ) ;
BaseResponseBean < List < FlowReportWorkProOrderBean > > baseResponseBean = gson . fromJson ( string , objectType ) ;
if ( baseResponseBean . getCode ( ) = = 200 ) {
if ( baseResponseBean . getCode ( ) ! = 200 ) {
showError ( baseResponseBean . getMsg ( ) ) ;
AUFNRItem . setValue ( "" ) ;
dynamicFormAdapter . setItemByFieldName ( AUFNRItem . getFieldName ( ) , AUFNRItem ) ;
setNextFocus ( "FlowOrder" ) ;
return ;
}
List < FlowReportWorkProOrderBean > data = baseResponseBean . getData ( ) ;
if ( data . size ( ) > 0 ) {
if ( data . size ( ) = = 0 ) {
showError ( getString ( R . string . No_material_information_was_obtained_for_the_workorder ) ) ;
AUFNRItem . setValue ( "" ) ;
dynamicFormAdapter . setItemByFieldName ( AUFNRItem . getFieldName ( ) , AUFNRItem ) ;
setNextFocus ( "FlowOrder" ) ;
return ;
}
AUFNRItem . setValue ( workOrder ) ;
dynamicFormAdapter . setItemByFieldName ( AUFNRItem . getFieldName ( ) , AUFNRItem ) ;
dynamicFormAdapter . notifyDataSetChanged ( ) ;
FlowReportWorkProOrderBean flowReportWorkProOrderBean = data . get ( 0 ) ;
flowReportWorkProOrderBean . save ( ) ;
if ( scanRuleItem . getValue ( ) . equals ( items [ 1 ] ) ) {
@ -647,35 +653,35 @@ public class FlowReportWorkActivity extends CommonFunctionActivity {
dynamicFormAdapter . notifyDataSetChanged ( ) ;
setNextFocus ( "PacketBarcode" ) ;
}
} else {
showError ( getString ( R . string . No_material_information_was_obtained_for_the_workorder ) ) ;
setNextFocus ( "FlowOrder" ) ;
}
} else {
showError ( baseResponseBean . getMsg ( ) ) ;
setNextFocus ( "FlowOrder" ) ;
}
}
@Override
protected void onFailure ( Throwable e ) throws Exception {
setNextFocus ( "FlowOrder" ) ;
SoundUtils . playSound ( FlowReportWorkActivity . this , R . raw . warning ) ;
CustomErrorDialog ( e , FlowReportWorkActivity . this ) ;
AUFNRItem . setValue ( "" ) ;
dynamicFormAdapter . setItemByFieldName ( AUFNRItem . getFieldName ( ) , AUFNRItem ) ;
setNextFocus ( "FlowOrder" ) ;
}
} ) ;
}
/ * *
* 解析条码信息 , 并比对工单产品信息
* @param value 条码内容
* @param dynamicFormBean 当前条码栏目
* /
private void getBarcodeInfo ( String value , DynamicFormBean dynamicFormBean ) {
AnalysisBarBean bean = BarAnalysisUtils . analysisBarcode ( value ) ;
//先根据条码物料信息比对工单产品信息
LitePal
. where ( "matnr = ?" , bean . getMateriel ( ) )
. findAsync ( FlowReportWorkProOrderBean . class )
. listen ( orderBeans - > {
if ( orderBeans . size ( ) = = 0 ) {
//未找到相同维度数据,报错
showError ( "工单物料与扫码物料不一致,请确认" ) ;
showError ( getString ( R . string . The_material_of_the_work_order_is_inconsistent_with_that_of_the_scanning_code ) ) ;
dynamicFormAdapter . setFocusById ( dynamicFormBean . getId ( ) ) ;
return ;
}
@ -717,6 +723,10 @@ public class FlowReportWorkActivity extends CommonFunctionActivity {
}
/ * *
* 设置光标跳转
* @param name
* /
private void setNextFocus ( String name ) {
if ( KeyboardUtils . isSoftInputVisible ( context ) ) {
KeyboardUtils . hideSoftInput ( context ) ;
@ -795,7 +805,9 @@ public class FlowReportWorkActivity extends CommonFunctionActivity {
}
}
/ * *
* 保存数据
* /
private void saveData ( ) {
LitePal . findAllAsync ( FlowReportWorkDetailBean . class ) . listen ( items - > {
if ( items . size ( ) = = 0 ) {
@ -923,6 +935,9 @@ public class FlowReportWorkActivity extends CommonFunctionActivity {
ToastUtil . showShortToastCenter ( context , msg ) ;
}
/ * *
* 清空所有明细和订单数据
* /
private void clearAllData ( ) {
if ( LitePal . count ( FlowReportWorkDetailBean . class ) > 0 ) {
LitePal . deleteAll ( FlowReportWorkDetailBean . class ) ;
@ -944,7 +959,10 @@ public class FlowReportWorkActivity extends CommonFunctionActivity {
return super . onKeyDown ( keyCode , event ) ;
}
/ * *
* 判断界面是否填写数据
* @return
* /
private boolean rvUiHaveData ( ) {
boolean isExist = false ;
for ( DynamicFormBean bean : dynamicFormBeans ) {