@@ -33,7 +33,9 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList ;
import java.util.HashMap ;
import java.util.List ;
import java.util.Map ;
import java.util.stream.Collectors ;
@Service
@RequiredArgsConstructor
@@ -383,6 +385,17 @@ public class HandNewMaterialServiceImpl implements HandNewMaterialService {
mst_jo . put ( " syscompanyid " , deptId + " " ) ;
io_mst . insert ( mst_jo ) ;
//批量查询桶:
List < String > bucketuniqueCollenct = new ArrayList < > ( ) ;
for ( HashMap row : rows ) {
bucketuniqueCollenct . add ( String . valueOf ( row . get ( " bucketunique " ) ) ) ;
}
Map < String , JSONObject > buckqMap = bucket_wql . query ( " bucketunique in (' " + bucketuniqueCollenct . stream ( ) . collect ( Collectors . joining ( " ',' " ) ) + " ') " )
. getResultJSONArray ( 0 ) . stream ( ) . collect ( HashMap : : new , ( map , buckq ) - > {
JSONObject jo = ( JSONObject ) buckq ;
map . put ( " key_ " + jo . getString ( " bucketunique " ) + jo . getString ( " material_id " ) + jo . getString ( " pcsn " ) , jo ) ;
} , HashMap : : putAll ) ;
for ( int i = 0 ; i < rows . size ( ) ; i + + ) {
String iostorinvdtl_id = " " ;
String iostorinvdis_id = " " ;
@@ -391,47 +404,45 @@ public class HandNewMaterialServiceImpl implements HandNewMaterialService {
if ( flag . equals ( " 5 " ) & & row . containsKey ( " is_new " ) & & row . get ( " is_new " ) . equals ( " 0 " ) ) {
continue ;
}
JSONObject bucket_jo = buckqMap . get ( " key_ " + row . get ( " bucketunique " ) + row . get ( " material_id " ) + row . get ( " pcsn " ) ) ;
//校验桶状态
JSONObject bucket_jo = bucket_wql . query ( " bucketunique = ' " + row . get ( " bucketunique " ) + " ' AND material_id = ' " + row . get ( " material_id " ) + " ' AND pcsn = ' " + row . get ( " pcsn " ) + " ' " ) . uniqueResult ( 0 ) ;
if ( ObjectUtil . isEmpty ( bucket_jo ) ) {
throw new PdaRequestException ( " 桶号: " + row . get ( " bucketunique " ) + " 查不到对应物料批次记录! " ) ;
}
if ( ! ObjectUtil . isEmpty ( bucket_jo ) & & ! bucket_jo . getString ( " status " ) . equals ( " 01 " ) ) {
//如果为软废采购入库,判断是否为新加,不是新加的不需要判断是否组盘
if ( ! flag . equals ( " 5 " ) & & row . containsKey ( " is_new " ) & & row . get ( " is_new " ) . equals ( " 0 " ) ) {
throw new PdaRequestException ( " 桶 " + bucket_jo . getString ( " bucketunique " ) + " 已经组盘! " ) ;
check : { //校验桶状态
if ( ObjectUtil . isEmpty ( bucket_jo ) ) {
throw new PdaRequestException ( " 桶号: " + row . get ( " bucketunique " ) + " 查不到对应物料批次记录! " ) ;
}
}
if ( flag . equals ( " 1 " ) ) {
if ( StrUtil . isNotEmpty ( material_id ) & & StrUtil . isNotEmpty ( pcsn ) ) {
if ( ! row . get ( " material_id " ) . equals ( material_id ) | | ! pcsn . equals ( row . get ( " pcsn " ) ) ) {
throw new PdaRequestException ( " 存在不同物料、批次的明细 ! " ) ;
if ( ! ObjectUtil . isEmpty ( bucket_jo ) & & ! bucket_jo . getString ( " status " ) . equals ( " 0 1" ) ) {
//如果为软废采购入库,判断是否为新加,不是新加的不需要判断是否组盘
if ( ! flag . equals ( " 5 " ) & & row . containsKey ( " is_new " ) & & row . get ( " is_new " ) . equals ( " 0 " ) ) {
throw new PdaRequestException ( " 桶 " + bucket_jo . getString ( " bucketunique " ) + " 已经组盘 ! " ) ;
}
}
if ( flag . equals ( " 1 " ) ) {
if ( StrUtil . isNotEmpty ( material_id ) & & StrUtil . isNotEmpty ( pcsn ) ) {
if ( ! row . get ( " material_id " ) . equals ( material_id ) | | ! pcsn . equals ( row . get ( " pcsn " ) ) ) {
throw new PdaRequestException ( " 存在不同物料、批次的明细! " ) ;
}
}
}
//工序返工入库校验、零头粉入库
if ( flag . equals ( " 3 " ) | | flag . equals ( " 6 " ) ) {
//物料为PG粉
boolean is_pgf = materialbaseService . isAlongMaterType ( MaterOptTypeEnum . PGF . getCode ( ) , bucket_jo . getString ( " material_id " ) , null ) ;
//桶内物料必须为PG粉;
if ( ! is_pgf ) {
throw new PdaRequestException ( " 桶内物料不为PG粉! " ) ;
}
}
if ( flag . equals ( " 5 " ) | | flag . equals ( " 7 " ) ) {
//物料为软废
boolean is_rf = materialbaseService . isAlongMaterType ( MaterOptTypeEnum . RF . getCode ( ) , bucket_jo . getString ( " material_id " ) , null ) ;
//桶内物料必须为软废;
if ( ! is_rf ) {
throw new PdaRequestException ( " 桶内物料不为软废! " ) ;
}
}
}
//工序返工入库校验、零头粉入库
if ( flag . equals ( " 3 " ) | | flag . equals ( " 6 " ) ) {
//物料为PG粉
boolean is_pgf = materialbaseService . isAlongMaterType ( MaterOptTypeEnum . PGF . getCode ( ) , bucket_jo . getString ( " material_id " ) , null ) ;
//桶内物料必须为PG粉;
if ( ! is_pgf ) {
throw new PdaRequestException ( " 桶内物料不为PG粉! " ) ;
}
}
if ( flag . equals ( " 5 " ) | | flag . equals ( " 7 " ) ) {
//物料为软废
boolean is_rf = materialbaseService . isAlongMaterType ( MaterOptTypeEnum . RF . getCode ( ) , bucket_jo . getString ( " material_id " ) , null ) ;
//桶内物料必须为软废;
if ( ! is_rf ) {
throw new PdaRequestException ( " 桶内物料不为软废! " ) ;
}
}
//查询该桶记录是否存在
if ( ObjectUtil . isEmpty ( bucket_jo ) | | ! " 01,02,03 " . contains ( bucket_jo . getString ( " status " ) ) ) {
//插入一条桶记录
@@ -442,10 +453,8 @@ public class HandNewMaterialServiceImpl implements HandNewMaterialService {
row . put ( " flag " , flag ) ;
this . insertBucket ( row ) ;
}
//立库返工入库校验
if ( flag . equals ( " 4 " ) ) {
bucket_jo = bucket_wql . query ( " bucketunique = ' " + row . get ( " bucketunique " ) + " ' AND material_id = ' " + row . get ( " material_id " ) + " ' AND pcsn = ' " + row . get ( " pcsn " ) + " ' " ) . uniqueResult ( 0 ) ;
//物料为PG粉
boolean is_pgf = materialbaseService . isAlongMaterType ( MaterOptTypeEnum . PGF . getCode ( ) , bucket_jo . getString ( " material_id " ) , null ) ;
//桶内物料必须为PG粉;