@@ -29,8 +29,8 @@ public class SapToLmsServiceImpl implements SapToLmsService {
@Override
public JSONObject getReCutInfo ( JSONObject jo ) {
log . info ( " getReCutInfo的输入参数为: ------------------------ " + jo . toString ( ) ) ;
public JSONObject getReCutInfo ( JSONObject json ) {
log . info ( " getReCutInfo的输入参数为: ------------------------ " + json . toString ( ) ) ;
JSONObject jsonMst = new JSONObject ( ) ;
@@ -38,7 +38,8 @@ public class SapToLmsServiceImpl implements SapToLmsService {
String msg = " 改切出库单据推送成功! " ;
try {
String LGORT = jo . getString ( " LGORT " ) ;
JSONArray dtl_ja = json . getJSONArray ( " ITEM " ) ;
String LGORT = dtl_ja . getJSONObject ( 0 ) . getString ( " LGORT " ) ;
JSONObject stor_jo = WQLObject . getWQLObject ( " ST_IVT_BSRealStorAttr " ) . query ( " ext_id = ' " + LGORT + " ' " ) . uniqueResult ( 0 ) ;
if ( ObjectUtil . isEmpty ( stor_jo ) ) {
result . put ( " RTYPE " , " E " ) ;
@@ -51,7 +52,7 @@ public class SapToLmsServiceImpl implements SapToLmsService {
jsonMst . put ( " stor_id " , stor_jo . getString ( " stor_id " ) ) ;
jsonMst . put ( " stor_code " , stor_jo . getString ( " stor_code " ) ) ;
jsonMst . put ( " stor_name " , stor_jo . getString ( " stor_name " ) ) ;
jsonMst . put ( " detail_count " , " 1 " ) ;
jsonMst . put ( " detail_count " , dtl_ja . size ( ) ) ;
jsonMst . put ( " bill_status " , " 10 " ) ;
jsonMst . put ( " create_mode " , " 03 " ) ;
jsonMst . put ( " bill_type " , " 1003 " ) ;
@@ -59,49 +60,55 @@ public class SapToLmsServiceImpl implements SapToLmsService {
jsonMst . put ( " user " , " sap " ) ;
JSONArray dtls = new JSONArray ( ) ;
Str ing sap_pcsn = jo . getString ( " CHARG " ) ;
if ( StrUtil . isEmpty ( " sap_pcsn " ) ) {
throw new BadRequestException ( " 请求参数SAP批次不能为空! " ) ;
}
JSONObject sub_jo = WQLObject . getWQLObject ( " PDM_BI_SubPackageRelation " ) . query ( " sap_pcsn = ' " + sap_pcsn + " ' " ) . uniqueResult ( 0 ) ;
if ( ObjectUtil . isEmpty ( sub_jo ) ) {
throw new BadRequestException ( " LMS中不存在SAP批次为【 " + sap_pcsn + " 】的包装关系 " ) ;
}
String container_name = sub_jo . getString ( " container_name " ) ;
JSONObject struct_ivt = WQLObject . getWQLObject ( " st_ivt_structivt " ) . query ( " pcsn = ' " + container_name + " ' " ) . uniqueResult ( 0 ) ;
if ( ObjectUtil . isEmpty ( struct_ivt ) ) {
throw new BadRequestException ( " SAP批次为【 " + sap_pcsn + " 】的成品卷不存在或已经出库! " ) ;
} else {
if ( struct_ivt . getDoubleValue ( " frozen_qty " ) > 0 ) {
msg = " SAP批次为【 " + sap_pcsn + " 】的成品卷已经被分配或出库中 " ;
} else {
JSONObject dtl = new JSONObject ( ) ;
//查询该物料
JSONObject mater_jo = WQLObject . getWQLObject ( " md_me_materialbase " ) . query ( " material_code = ' " + sub_jo . getString ( " product_name " ) + " ' " ) . uniqueResult ( 0 ) ;
if ( ObjectUtil . isEmpty ( mater_jo ) ) {
throw new BadRequestException ( " 未查询到物料: " + sub_jo . getString ( " product_name " ) + " ,信息! " ) ;
}
dtl . put ( " material_id " , mater_jo . getString ( " material_id " ) ) ;
dtl . put ( " pcsn " , container_name ) ;
dtl . put ( " box_no " , sub_jo . getString ( " package_box_sn " ) ) ;
JSONObject unit = WQLObject . getWQLObject ( " md_pb_measureunit " ) . query ( " measure_unit_id = ' " + mater_jo . getString ( " base_unit_id " ) + " ' " ) . uniqueResult ( 0 ) ;
if ( ObjectUtil . isEmpty ( unit ) ) {
throw new BadRequestException ( " 未查询到物料计量单位: " + mater_jo . getString ( " base_unit_id " ) + " ,信息! " ) ;
}
dtl . put ( " qty_unit_id " , unit . getString ( " measure_unit_id " ) ) ;
dtl . put ( " qty_unit_name " , unit . getString ( " unit_name " ) ) ;
dtl . put ( " plan_qty " , sub_jo . getString ( " net_weight " ) ) ;
dtls . add ( dtl ) ;
jsonMst . put ( " tableData " , dtls ) ;
String iostorinv_id = checkOutBillService . insertDtl ( jsonMst ) ;
//调用自动分配
JSONObject out_jo = new JSONObject ( ) ;
out_jo . put ( " iostorinv_id " , iostorinv_id ) ;
checkOutBillService . allDiv ( out_jo ) ;
for ( int i = 0 ; i < dtl_ja . size ( ) ; i + + ) {
JSONObject jo = dtl_ja . getJSONObject ( i ) ;
String sap_pcsn = jo . getString ( " CHARG " ) ;
if ( StrUtil . isEmpty ( " sap_pcsn " ) ) {
throw new BadRequestException ( " 请求参数SAP批次不能为空! " ) ;
}
JSONObject sub_jo = WQLObject . getWQLObject ( " PDM_BI_SubPackageRelation " ) . query ( " sap_pcsn = ' " + sap_pcsn + " ' " ) . uniqueResult ( 0 ) ;
if ( ObjectUtil . isEmpty ( sub_jo ) ) {
throw new BadRequestException ( " LMS中不存在SAP批次为【 " + sap_pcsn + " 】的包装关系 " ) ;
}
String container_name = sub_jo . getString ( " container_name " ) ;
JSONObject struct_ivt = WQLObject . getWQLObject ( " st_ivt_structivt " ) . query ( " pcsn = ' " + container_name + " ' " ) . uniqueResult ( 0 ) ;
if ( ObjectUtil . isEmpty ( struct_ivt ) ) {
throw new BadRequestException ( " SAP批次为【 " + sap_pcsn + " 】的成品卷不存在或已经出库! " ) ;
} else {
if ( struct_ivt . getDoubleValue ( " frozen_qty " ) > 0 ) {
msg = " SAP批次为【 " + sap_pcsn + " 】的成品卷已经被分配或出库中 " ;
} else {
JSONObject dtl = new JSONObject ( ) ;
//查询该物料
JSONObject mater_jo = WQLObject . getWQLObject ( " md_me_materialbase " ) . query ( " material_code = ' " + sub_jo . getString ( " product_name " ) + " ' " ) . uniqueResult ( 0 ) ;
if ( ObjectUtil . isEmpty ( mater_jo ) ) {
throw new BadRequestException ( " 未查询到物料: " + sub_jo . getString ( " product_name " ) + " ,信息! " ) ;
}
dtl . put ( " material_id " , mater_jo . getString ( " material_id " ) ) ;
dtl . put ( " pcsn " , container_name ) ;
dtl . put ( " box_no " , sub_jo . getString ( " package_box_sn " ) ) ;
JSONObject unit = WQLObject . getWQLObject ( " md_pb_measureunit " ) . query ( " measure_unit_id = ' " + mater_jo . getString ( " base_unit_id " ) + " ' " ) . uniqueResult ( 0 ) ;
if ( ObjectUtil . isEmpty ( unit ) ) {
throw new BadRequestException ( " 未查询到物料计量单位: " + mater_jo . getString ( " base_unit_id " ) + " ,信息! " ) ;
}
dtl . put ( " qty_unit_id " , unit . getString ( " measure_unit_id " ) ) ;
dtl . put ( " qty_unit_name " , unit . getString ( " unit_name " ) ) ;
dtl . put ( " plan_qty " , sub_jo . getString ( " net_weight " ) ) ;
dtls . add ( dtl ) ;
}
}
}
if ( ! dtls . isEmpty ( ) ) {
jsonMst . put ( " tableData " , dtls ) ;
String iostorinv_id = checkOutBillService . insertDtl ( jsonMst ) ;
//调用自动分配
JSONObject out_jo = new JSONObject ( ) ;
out_jo . put ( " iostorinv_id " , iostorinv_id ) ;
checkOutBillService . allDiv ( out_jo ) ;
} else {
throw new BadRequestException ( " 推送失败! SAP推送的子卷明细不符合出库状态! " ) ;
}
} catch ( Exception exception ) {
result . put ( " TYPE " , " E " ) ;
@@ -498,10 +505,12 @@ public class SapToLmsServiceImpl implements SapToLmsService {
JSONObject jsonDtl = new JSONObject ( ) ;
JSONObject jsonMater = materTab . query ( " material_code = ' " + jsonObject . getString ( " MATNR " ) + " ' " ) . uniqueResult ( 0 ) ;
if ( ObjectUtil . isEmpty ( jsonMater ) ) throw new BadRequestException ( " 此物料不存在 " + jsonObject . getString ( " MATNR " ) ) ;
if ( ObjectUtil . isEmpty ( jsonMater ) )
throw new BadRequestException ( " 此物料不存在 " + jsonObject . getString ( " MATNR " ) ) ;
JSONObject jsonUnit = unitTab . query ( " measure_unit_id = ' " + jsonMater . getString ( " base_unit_id " ) + " ' " ) . uniqueResult ( 0 ) ;
if ( ObjectUtil . isEmpty ( jsonObject . getString ( " KALAB " ) ) ) throw new BadRequestException ( " 调拨数量不能为空! " ) ;
if ( ObjectUtil . isEmpty ( jsonObject . getString ( " KALAB " ) ) )
throw new BadRequestException ( " 调拨数量不能为空! " ) ;
if ( ObjectUtil . isEmpty ( jsonObject . getString ( " ZVBELN " ) ) ) throw new BadRequestException ( " 订单不能为空! " ) ;
jsonDtl . put ( " material_id " , jsonMater . getString ( " material_id " ) ) ;