@ -29,7 +29,6 @@ import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView ;
import androidx.recyclerview.widget.RecyclerView ;
import com.blankj.utilcode.util.KeyboardUtils ;
import com.blankj.utilcode.util.KeyboardUtils ;
import com.blankj.utilcode.util.SPUtils ;
import com.blankj.utilcode.util.StringUtils ;
import com.blankj.utilcode.util.StringUtils ;
import com.blankj.utilcode.util.ToastUtils ;
import com.blankj.utilcode.util.ToastUtils ;
import com.codbking.widget.DatePickDialog ;
import com.codbking.widget.DatePickDialog ;
@ -46,6 +45,7 @@ import com.techscan.wk.app.AppConst;
import com.techscan.wk.base.CommonFunctionActivity ;
import com.techscan.wk.base.CommonFunctionActivity ;
import com.techscan.wk.model.AnalysisBarBean ;
import com.techscan.wk.model.AnalysisBarBean ;
import com.techscan.wk.model.DynamicFormBean ;
import com.techscan.wk.model.DynamicFormBean ;
import com.techscan.wk.model.FlowReportWorkProOrderBean ;
import com.techscan.wk.model.ProReqDetailBean ;
import com.techscan.wk.model.ProReqDetailBean ;
import com.techscan.wk.model.ProReqOrdeTaskBean ;
import com.techscan.wk.model.ProReqOrdeTaskBean ;
import com.techscan.wk.model.ProReqOrderBean ;
import com.techscan.wk.model.ProReqOrderBean ;
@ -55,12 +55,12 @@ import com.techscan.wk.rxretrofit.BaseObserver;
import com.techscan.wk.rxretrofit.BaseResponseBean ;
import com.techscan.wk.rxretrofit.BaseResponseBean ;
import com.techscan.wk.rxretrofit.HttpMethods ;
import com.techscan.wk.rxretrofit.HttpMethods ;
import com.techscan.wk.ui.baseAct.LgortListActivity ;
import com.techscan.wk.ui.baseAct.LgortListActivity ;
import com.techscan.wk.ui.login.SettingActivity ;
import com.techscan.wk.ui.reportwork.ConfigSettingActivity ;
import com.techscan.wk.ui.reportwork.ConfigSettingActivity ;
import com.techscan.wk.ui.scan.CustomCaptureActivity ;
import com.techscan.wk.ui.scan.CustomCaptureActivity ;
import com.techscan.wk.utils.AntiShakeUtils ;
import com.techscan.wk.utils.AntiShakeUtils ;
import com.techscan.wk.utils.BarAnalysisUtils ;
import com.techscan.wk.utils.BarAnalysisUtils ;
import com.techscan.wk.utils.DateUtils ;
import com.techscan.wk.utils.DateUtils ;
import com.techscan.wk.utils.DialogUtil ;
import com.techscan.wk.utils.FindUtils ;
import com.techscan.wk.utils.FindUtils ;
import com.techscan.wk.utils.PreferencesUtil ;
import com.techscan.wk.utils.PreferencesUtil ;
import com.techscan.wk.utils.SoundUtils ;
import com.techscan.wk.utils.SoundUtils ;
@ -89,6 +89,7 @@ import q.rorbin.badgeview.QBadgeView;
/ * *
/ * *
* Description : 生产上料
* Description : 生产上料
* [ ) > @06 @QRPART @10V101010 @1P11002734 @3SX1000019400001 @1T20240724001 @Q20 @14D20240724 @ @
* @author MULEI
* @author MULEI
* @date 2024 / 9 / 11
* @date 2024 / 9 / 11
* /
* /
@ -123,6 +124,7 @@ public class ProReqActivity extends CommonFunctionActivity {
private Map < String , List < String > > scanBarcodeListMap ; //存放条码扫描明细
private Map < String , List < String > > scanBarcodeListMap ; //存放条码扫描明细
private ProReqOrderBean proReqOrderBean ;
private ProReqOrderBean proReqOrderBean ;
private boolean isSave = false ;
private boolean isSave = false ;
private AnalysisBarBean barDataBean ;
@Override
@Override
protected void onCreate ( Bundle savedInstanceState ) {
protected void onCreate ( Bundle savedInstanceState ) {
@ -317,14 +319,6 @@ public class ProReqActivity extends CommonFunctionActivity {
showError ( getString ( R . string . The_barcode_format_is_incorrect ) + value ) ;
showError ( getString ( R . string . The_barcode_format_is_incorrect ) + value ) ;
return ;
return ;
}
}
AnalysisBarBean analysisBarBean = BarAnalysisUtils . analysisBarcode ( value ) ;
String materiel = analysisBarBean . getMateriel ( ) ;
if ( TextUtils . isEmpty ( materiel ) ) {
dynamicFormAdapter . setFocusById ( dynamicFormBean . getId ( ) ) ;
showError ( getString ( R . string . There_is_no_aterial_information_in_the_barcode_please_confirm ) ) ;
return ;
}
// //判断条码是否已经被扫描
// //判断条码是否已经被扫描
// if (isInBarcodeList(scanBarcodeListMap, value)) {
// if (isInBarcodeList(scanBarcodeListMap, value)) {
// showError(getString(R.string.Do_not_scan_the_barcode_again));
// showError(getString(R.string.Do_not_scan_the_barcode_again));
@ -334,7 +328,7 @@ public class ProReqActivity extends CommonFunctionActivity {
getBarcodeInfo ( value ) ;
getBarcodeInfo ( value ) ;
break ;
break ;
case "quantity" :
case "quantity" :
addDetail ( ) ;
addDetailCheck ( value ) ;
break ;
break ;
default :
default :
break ;
break ;
@ -348,10 +342,16 @@ public class ProReqActivity extends CommonFunctionActivity {
* @param value 条码内容
* @param value 条码内容
* /
* /
private void getBarcodeInfo ( String value ) {
private void getBarcodeInfo ( String value ) {
AnalysisBarBean bean = BarAnalysisUtils . analysisBarcode ( value ) ;
barDataBean = BarAnalysisUtils . analysisBarcode ( value ) ;
String materiel = barDataBean . getMateriel ( ) ;
if ( TextUtils . isEmpty ( materiel ) ) {
setNextFocus ( "barcode" ) ;
showError ( getString ( R . string . There_is_no_aterial_information_in_the_barcode_please_confirm ) ) ;
return ;
}
LitePal
LitePal
//.where("matnr = ? and complete = ?", materiel, "0")
//.where("matnr = ? and complete = ?", materiel, "0")
. where ( "matnr = ?" , bean . getMateriel ( ) )
. where ( "matnr = ?" , barDataB ean . getMateriel ( ) )
. findAsync ( ProReqOrdeTaskBean . class )
. findAsync ( ProReqOrdeTaskBean . class )
. listen ( proReqOrdeTaskBeans - > {
. listen ( proReqOrdeTaskBeans - > {
if ( proReqOrdeTaskBeans . size ( ) = = 0 ) {
if ( proReqOrdeTaskBeans . size ( ) = = 0 ) {
@ -370,19 +370,19 @@ public class ProReqActivity extends CommonFunctionActivity {
d . setValue ( showValue ) ;
d . setValue ( showValue ) ;
break ;
break ;
case "MATNR" : //物料号
case "MATNR" : //物料号
d . setValue ( bean . getMateriel ( ) ) ;
d . setValue ( barDataB ean . getMateriel ( ) ) ;
d . setFocus ( false ) ;
d . setFocus ( false ) ;
break ;
break ;
case "ZXTPC" : //包装容器号 --箱号
case "ZXTPC" : //包装容器号 --箱号
d . setValue ( bean . getPackageNumber ( ) ) ;
d . setValue ( barDataB ean . getPackageNumber ( ) ) ;
d . setFocus ( false ) ;
d . setFocus ( false ) ;
break ;
break ;
case "ZPC" : //批次
case "ZPC" : //批次
d . setValue ( bean . getBatch ( ) ) ;
d . setValue ( barDataB ean . getBatch ( ) ) ;
d . setFocus ( false ) ;
d . setFocus ( false ) ;
break ;
break ;
case "quantity" : //数量
case "quantity" : //数量
d . setValue ( bean . getQuantity ( ) ) ;
d . setValue ( barDataB ean . getQuantity ( ) ) ;
d . setFocus ( true ) ;
d . setFocus ( true ) ;
break ;
break ;
case "erfme" : //单位
case "erfme" : //单位
@ -400,12 +400,7 @@ public class ProReqActivity extends CommonFunctionActivity {
//判断是否开启 扫描自动加入明细
//判断是否开启 扫描自动加入明细
boolean aBoolean = PreferencesUtil . getBoolean ( context , AppConst . SCAN_ADD_DETAIL , true ) ;
boolean aBoolean = PreferencesUtil . getBoolean ( context , AppConst . SCAN_ADD_DETAIL , true ) ;
if ( aBoolean ) {
if ( aBoolean ) {
new Handler ( ) . postDelayed ( new Runnable ( ) {
@Override
public void run ( ) {
addDetail ( ) ;
}
} , 300 ) ;
new Handler ( ) . postDelayed ( ( ) - > addDetailCheck ( barDataBean . getQuantity ( ) ) , 300 ) ;
}
}
} ) ;
} ) ;
@ -413,66 +408,75 @@ public class ProReqActivity extends CommonFunctionActivity {
}
}
/ * *
/ * *
* 根据工单获取工单物料信息
*
* @param id 工单号
* 加入明细前校验
* /
* /
private void query ( String id ) {
HttpMethods . getInstance ( ) . getOrderInfo ( id , new BaseObserver < ResponseBody > ( context ) {
@Override
protected void onSuccess ( ResponseBody body ) throws Exception {
String string = body . string ( ) ;
Type objectType = new TypeToken < BaseResponseBean < List < ProReqOrderBean > > > ( ) {
} . getType ( ) ;
BaseResponseBean < List < ProReqOrderBean > > baseResponseBean = gson . fromJson ( string , objectType ) ;
if ( baseResponseBean . getCode ( ) ! = 200 ) {
showError ( baseResponseBean . getMsg ( ) ) ;
setNextFocus ( "AUFNR" ) ;
showTaskDetailBadgeNum ( ) ;
return ;
}
List < ProReqOrderBean > data = baseResponseBean . getData ( ) ;
if ( data . size ( ) = = 0 ) {
showError ( getString ( R . string . No_data_was_obtained ) ) ;
setNextFocus ( "AUFNR" ) ;
showTaskDetailBadgeNum ( ) ;
return ;
}
private void addDetailCheck ( String quantity ) {
if ( LitePal . count ( ProReqOrdeTaskBean . class ) = = 0 ) {
showError ( getString ( R . string . Please_scan_the_ticket_number_first ) ) ;
setNextFocus ( "AUFNR" ) ;
return ;
}
if ( barDataBean = = null ) {
showError ( getString ( R . string . The_bar_code_cannot_be_blank ) ) ;
setNextFocus ( "barcode" ) ;
return ;
}
proReqOrderBean = data . get ( 0 ) ;
List < ProReqOrdeTaskBean > item = proReqOrderBean . getItem ( ) ;
if ( item . size ( ) = = 0 ) {
showError ( getString ( R . string . No_data_was_obtained ) ) ;
setNextFocus ( "AUFNR" ) ;
showTaskDetailBadgeNum ( ) ;
return ;
if ( TextUtils . isEmpty ( quantity ) ) {
setNextFocus ( "quantity" ) ;
showError ( getString ( R . string . The_quantity_cannot_be_empty ) ) ;
return ;
}
//当前加入明细的数量
double currenScanNum = Double . parseDouble ( quantity ) ;
if ( currenScanNum < = 0 ) {
showError ( getString ( R . string . The_number_of_scanned_codes_must_be_greater_than_0 ) ) ;
return ;
}
//条码数量
String barNum = barDataBean . getQuantity ( ) ;
String packageNumber = barDataBean . getPackageNumber ( ) ;
if ( ! TextUtils . isEmpty ( barNum ) & & checkNumber ( barNum ) ) {
//计算出当前箱号在明细中已扫描的数量
Double hisScanNum = LitePal . where ( "zboxid = ? " , packageNumber ) . sum ( ProReqDetailBean . class , "erfmg" , double . class ) ;
double finalHisScanNum = hisScanNum ;
double finalBarNum = Double . parseDouble ( barNum ) ;
double finalCurrenScanNum = currenScanNum ;
HttpMethods . getInstance ( ) . getByzboxid ( packageNumber , new BaseObserver < ResponseBody > ( context ) {
@Override
protected void onSuccess ( ResponseBody body ) throws Exception {
String string = body . string ( ) ;
Type objectType = new TypeToken < BaseResponseBean < Double > > ( ) {
} . getType ( ) ;
BaseResponseBean < Double > baseResponseBean = gson . fromJson ( string , objectType ) ;
if ( baseResponseBean . getCode ( ) ! = 200 ) {
showError ( baseResponseBean . getMsg ( ) ) ;
return ;
}
if ( baseResponseBean . getData ( ) ! = null ) {
//服务端返回该箱号已扫描数量
double data = baseResponseBean . getData ( ) ;
//当前扫描数量+本地历史扫描数量+服务扫描数量
double scanTotal = finalCurrenScanNum + finalHisScanNum + data ;
if ( scanTotal > finalBarNum ) {
DialogUtil . showErrorInfoDialog ( context , "当前数量" + quantity + ",历史已扫数量" + ( finalHisScanNum + data ) +
",已扫数量总和超过条码数量" + finalBarNum + ",请确认" ) ;
} else {
addDetail ( ) ;
}
}
}
}
QMUITipDialog qmuiTipDialog = new QMUITipDialog . Builder ( context ) . setIconType ( QMUITipDialog . Builder . ICON_TYPE_LOADING ) . create ( ) ;
qmuiTipDialog . setCancelable ( false ) ;
qmuiTipDialog . setCanceledOnTouchOutside ( false ) ;
qmuiTipDialog . show ( ) ;
for ( int i = 0 ; i < item . size ( ) ; i + + ) {
ProReqOrdeTaskBean taskBean = item . get ( i ) ;
taskBean . setRowid ( System . currentTimeMillis ( ) ) ;
taskBean . save ( ) ;
@Override
protected void onFailure ( Throwable e ) throws Exception {
CustomErrorDialog ( e , ProReqActivity . this ) ;
}
}
showTaskDetailBadgeNum ( ) ;
qmuiTipDialog . dismiss ( ) ;
setNextFocus ( "ZCJBM" ) ;
} ) ;
}
} else {
addDetail ( ) ;
}
@Override
protected void onFailure ( Throwable e ) throws Exception {
showTaskDetailBadgeNum ( ) ;
setNextFocus ( "AUFNR" ) ;
SoundUtils . playSound ( ProReqActivity . this , R . raw . warning ) ;
CustomErrorDialog ( e , ProReqActivity . this ) ;
}
} ) ;
}
}
/ * *
/ * *
@ -490,12 +494,6 @@ public class ProReqActivity extends CommonFunctionActivity {
DynamicFormBean quantityItem = dynamicFormAdapter . getItemByFieldName ( "quantity" ) ; //数量
DynamicFormBean quantityItem = dynamicFormAdapter . getItemByFieldName ( "quantity" ) ; //数量
DynamicFormBean erfmeItem = dynamicFormAdapter . getItemByFieldName ( "erfme" ) ; //单位
DynamicFormBean erfmeItem = dynamicFormAdapter . getItemByFieldName ( "erfme" ) ; //单位
if ( LitePal . count ( ProReqOrdeTaskBean . class ) = = 0 ) {
showError ( getString ( R . string . Please_scan_the_ticket_number_first ) ) ;
setNextFocus ( "AUFNR" ) ;
return ;
}
if ( TextUtils . isEmpty ( lgortItem . getValue ( ) ) ) {
if ( TextUtils . isEmpty ( lgortItem . getValue ( ) ) ) {
showError ( getString ( R . string . Please_select_a_stock_location ) ) ;
showError ( getString ( R . string . Please_select_a_stock_location ) ) ;
return ;
return ;
@ -508,17 +506,6 @@ public class ProReqActivity extends CommonFunctionActivity {
return ;
return ;
}
}
String value = quantityItem . getValue ( ) ;
if ( TextUtils . isEmpty ( value ) ) {
setNextFocus ( "quantity" ) ;
showError ( getString ( R . string . The_quantity_cannot_be_empty ) ) ;
return ;
}
double num = Double . parseDouble ( value ) ;
if ( Double . parseDouble ( value ) < = 0 ) {
showError ( getString ( R . string . The_number_of_scanned_codes_must_be_greater_than_0 ) ) ;
return ;
}
LitePal
LitePal
//.where("matnr = ? and complete = ?", MATNRItem.getValue(), "0")
//.where("matnr = ? and complete = ?", MATNRItem.getValue(), "0")
@ -530,8 +517,7 @@ public class ProReqActivity extends CommonFunctionActivity {
showError ( getString ( R . string . There_is_no_data_of_the_same_dimension_in_the_task_list ) ) ;
showError ( getString ( R . string . There_is_no_data_of_the_same_dimension_in_the_task_list ) ) ;
return ;
return ;
}
}
double scanQuantity = num ;
double scanQuantity = Double . parseDouble ( quantityItem . getValue ( ) ) ;
String gid = System . currentTimeMillis ( ) + "" ;
String gid = System . currentTimeMillis ( ) + "" ;
//加入明细,并且可以超量,每次只匹配任务一行
//加入明细,并且可以超量,每次只匹配任务一行
for ( ProReqOrdeTaskBean bean : proReqOrdeTaskBeans ) {
for ( ProReqOrdeTaskBean bean : proReqOrdeTaskBeans ) {
@ -546,6 +532,7 @@ public class ProReqActivity extends CommonFunctionActivity {
bean . save ( ) ;
bean . save ( ) ;
ProReqDetailBean detailBean = new ProReqDetailBean ( ) ;
ProReqDetailBean detailBean = new ProReqDetailBean ( ) ;
detailBean . setBarcode ( barDataBean . getBarcode ( ) ) ;
detailBean . setTaskRowId ( bean . getRowid ( ) ) ;
detailBean . setTaskRowId ( bean . getRowid ( ) ) ;
detailBean . setGid ( gid ) ;
detailBean . setGid ( gid ) ;
detailBean . setAufnr ( bean . getAufnr ( ) ) ;
detailBean . setAufnr ( bean . getAufnr ( ) ) ;
@ -580,6 +567,7 @@ public class ProReqActivity extends CommonFunctionActivity {
scanBarcodeListMap . put ( gid , keyBarcodes ) ;
scanBarcodeListMap . put ( gid , keyBarcodes ) ;
runOnUiThread ( ( ) - > {
runOnUiThread ( ( ) - > {
barDataBean = null ;
SoundUtils . playSound ( this , R . raw . ok ) ;
SoundUtils . playSound ( this , R . raw . ok ) ;
if ( KeyboardUtils . isSoftInputVisible ( context ) ) {
if ( KeyboardUtils . isSoftInputVisible ( context ) ) {
KeyboardUtils . hideSoftInput ( context ) ;
KeyboardUtils . hideSoftInput ( context ) ;
@ -603,6 +591,70 @@ public class ProReqActivity extends CommonFunctionActivity {
}
}
/ * *
* 根据工单获取工单物料信息
*
* @param id 工单号
* /
private void query ( String id ) {
HttpMethods . getInstance ( ) . getOrderInfo ( id , new BaseObserver < ResponseBody > ( context ) {
@Override
protected void onSuccess ( ResponseBody body ) throws Exception {
String string = body . string ( ) ;
Type objectType = new TypeToken < BaseResponseBean < List < ProReqOrderBean > > > ( ) {
} . getType ( ) ;
BaseResponseBean < List < ProReqOrderBean > > baseResponseBean = gson . fromJson ( string , objectType ) ;
if ( baseResponseBean . getCode ( ) ! = 200 ) {
showError ( baseResponseBean . getMsg ( ) ) ;
setNextFocus ( "AUFNR" ) ;
showTaskDetailBadgeNum ( ) ;
return ;
}
List < ProReqOrderBean > data = baseResponseBean . getData ( ) ;
if ( data . size ( ) = = 0 ) {
showError ( getString ( R . string . No_data_was_obtained ) ) ;
setNextFocus ( "AUFNR" ) ;
showTaskDetailBadgeNum ( ) ;
return ;
}
proReqOrderBean = data . get ( 0 ) ;
List < ProReqOrdeTaskBean > item = proReqOrderBean . getItem ( ) ;
if ( item . size ( ) = = 0 ) {
showError ( getString ( R . string . No_data_was_obtained ) ) ;
setNextFocus ( "AUFNR" ) ;
showTaskDetailBadgeNum ( ) ;
return ;
}
QMUITipDialog qmuiTipDialog = new QMUITipDialog . Builder ( context ) . setIconType ( QMUITipDialog . Builder . ICON_TYPE_LOADING ) . create ( ) ;
qmuiTipDialog . setCancelable ( false ) ;
qmuiTipDialog . setCanceledOnTouchOutside ( false ) ;
qmuiTipDialog . show ( ) ;
for ( int i = 0 ; i < item . size ( ) ; i + + ) {
ProReqOrdeTaskBean taskBean = item . get ( i ) ;
taskBean . setRowid ( System . currentTimeMillis ( ) ) ;
taskBean . save ( ) ;
}
showTaskDetailBadgeNum ( ) ;
qmuiTipDialog . dismiss ( ) ;
setNextFocus ( "ZCJBM" ) ;
}
@Override
protected void onFailure ( Throwable e ) throws Exception {
showTaskDetailBadgeNum ( ) ;
setNextFocus ( "AUFNR" ) ;
SoundUtils . playSound ( ProReqActivity . this , R . raw . warning ) ;
CustomErrorDialog ( e , ProReqActivity . this ) ;
}
} ) ;
}
/ * *
/ * *
* 显示任务和明细角标
* 显示任务和明细角标
* /
* /
@ -899,6 +951,15 @@ public class ProReqActivity extends CommonFunctionActivity {
}
}
//数字验证(包含小数点)
public static boolean checkNumber ( String str ) {
String regex = "-[0-9]+(.[0-9]+)?|[0-9]+(.[0-9]+)?" ;
if ( str = = null | | ! str . matches ( regex ) ) {
return false ;
}
return true ;
}
public void clearAllData ( ) {
public void clearAllData ( ) {
if ( LitePal . count ( ProReqDetailBean . class ) > 0 ) {
if ( LitePal . count ( ProReqDetailBean . class ) > 0 ) {
LitePal . deleteAll ( ProReqDetailBean . class ) ;
LitePal . deleteAll ( ProReqDetailBean . class ) ;