@ -143,7 +143,7 @@ public class BmsSupplierController {
@PostMapping ( "/relateSuppliers" )
@PreAuthorize ( "hasRole('bms:supplier:update')" )
public R < ? > relateSuppliers ( @RequestBody @Valid SysRelateSuppliersParam param ) {
List < Lo ng> supplierIds = param . getSupplierIds ( ) ;
List < Stri ng> supplierIds = param . getSupplierIds ( ) ;
String userId = param . getUserId ( ) ;
List < BmsSupplier > list = bmsSupplierService . listByIds ( supplierIds ) ;
for ( BmsSupplier supplier : list ) {
@ -173,6 +173,7 @@ public class BmsSupplierController {
supplierParam . setOtherUserIds ( otherUserIds . toArray ( new String [ otherUserIds . size ( ) ] ) ) ;
bmsSupplierService . updateById ( supplierParam ) ;
}
initSupplierOtherInfo ( supplierIds ) ;
return R . ok ( ) ;
}
@ -191,6 +192,7 @@ public class BmsSupplierController {
bmsSupplier . setId ( param . getSupplierId ( ) . toString ( ) ) ;
bmsSupplier . setOtherUserIds ( param . getUserIds ( ) = = null ? new String [ ] { } : uids . toArray ( new String [ uids . size ( ) ] ) ) ;
bmsSupplierService . updateById ( bmsSupplier ) ;
initSupplierOtherInfo ( Arrays . asList ( supplier . getId ( ) ) ) ;
return R . ok ( ) ;
}
@ -202,7 +204,7 @@ public class BmsSupplierController {
@PostMapping ( "/relateRemove" )
@PreAuthorize ( "hasRole('bms:supplier:update')" )
public R < ? > relateRemove ( @RequestBody SysRelateSuppliersParam param ) {
List < Lo ng> supplierIds = param . getSupplierIds ( ) ;
List < Stri ng> supplierIds = param . getSupplierIds ( ) ;
String userId = param . getUserId ( ) ;
List < BmsSupplier > list = bmsSupplierService . listByIds ( supplierIds ) ;
for ( BmsSupplier supplier : list ) {
@ -224,6 +226,7 @@ public class BmsSupplierController {
bmsSupplierService . updateById ( supplierParam ) ;
}
}
initSupplierOtherInfo ( supplierIds ) ;
return R . ok ( ) ;
}
@ -244,7 +247,7 @@ public class BmsSupplierController {
if ( CollectionUtil . isNotEmpty ( supplier . getOtherUserIds ( ) ) ) {
List < String > otherUserIds = new ArrayList < > ( ) ;
for ( String otherUserId : supplier . getOtherUserIds ( ) ) {
if ( ! Arrays . asList ( userIds ) . contains ( otherUserId ) ) {
if ( ! userIds . contains ( otherUserId ) ) {
otherUserIds . add ( otherUserId ) ;
}
}
@ -253,9 +256,12 @@ public class BmsSupplierController {
supplier1 . setOtherUserIds ( otherUserIds . toArray ( new String [ otherUserIds . size ( ) ] ) ) ;
bmsSupplierService . updateById ( supplier1 ) ;
}
initSupplierOtherInfo ( Arrays . asList ( supplier . getId ( ) ) ) ;
return R . ok ( ) ;
}
/ * *
* 设置主要负责人
* @param supplierId
@ -286,6 +292,7 @@ public class BmsSupplierController {
supplierParam . setOtherUserIds ( otherArr ) ;
}
bmsSupplierService . updateById ( supplierParam ) ;
initSupplierOtherInfo ( Arrays . asList ( supplier . getId ( ) ) ) ;
return R . ok ( ) ;
}
@ -313,6 +320,7 @@ public class BmsSupplierController {
bmsSupplier . setId ( supplier . getId ( ) ) ;
bmsSupplier . setOtherUserIds ( otherArr ) ;
bmsSupplierService . updateById ( bmsSupplier ) ;
initSupplierOtherInfo ( Arrays . asList ( supplierId . toString ( ) ) ) ;
return R . ok ( ) ;
}
@ -444,7 +452,7 @@ public class BmsSupplierController {
regionList = bmsRegionService . listByIds ( regionIds ) ;
}
for ( BmsSupplier supplier : list ) {
String regionId = supplier . getRegionThird ( ) ;
String regionId = supplier . getRegionLast ( ) ;
if ( regionId ! = null & & CollectionUtil . isNotEmpty ( regionList ) ) {
for ( BmsRegion region : regionList ) {
if ( region . getId ( ) . equals ( regionId ) ) {
@ -460,13 +468,14 @@ public class BmsSupplierController {
. map ( BmsSupplier : : getRegion2Last ) . collect ( Collectors . toList ( ) ) ;
List < BmsRegion2 > region2List = null ;
if ( CollectionUtil . isNotEmpty ( region2Ids ) ) {
region2List = bmsRegion2Service . listByIds ( regionIds ) ;
region2List = bmsRegion2Service . listByIds ( region2 Ids ) ;
}
for ( BmsSupplier supplier : list ) {
String region2Id = supplier . getRegion2Third ( ) ;
String region2Id = supplier . getRegion2Last ( ) ;
if ( region2Id ! = null & & CollectionUtil . isNotEmpty ( region2List ) ) {
for ( BmsRegion2 region : region2List ) {
if ( region . getId ( ) . equals ( region2Id ) ) {
String regionId = region . getId ( ) ;
if ( regionId . equals ( region2Id ) ) {
supplier . setRegion2Label ( region . getName ( ) ) ;
break ;
}
@ -487,5 +496,35 @@ public class BmsSupplierController {
}
}
/ * *
* 初始化其它信息
* @param supplierIds
* /
private void initSupplierOtherInfo ( List < String > supplierIds ) {
List < BmsSupplier > suppliers = bmsSupplierService . listByIds ( supplierIds ) ;
List < BmsSupplier > updParams = new ArrayList < > ( ) ;
for ( BmsSupplier supplier : suppliers ) {
if ( CollectionUtil . isNotEmpty ( supplier . getOtherUserIds ( ) ) ) {
List < String > otherUserIds = Arrays . asList ( supplier . getOtherUserIds ( ) ) ;
BmsSupplier param = new BmsSupplier ( ) ;
param . setId ( supplier . getId ( ) ) ;
if ( otherUserIds . size ( ) > 0 ) {
List < SysUser > userList = sysUserService . listByIds ( otherUserIds ) ;
String codes = userList . stream ( ) . map ( SysUser : : getCode ) . collect ( Collectors . joining ( "," ) ) ;
String names = userList . stream ( ) . map ( SysUser : : getName ) . collect ( Collectors . joining ( "," ) ) ;
param . setOtherUserCodes ( codes ) ;
param . setOtherUserNames ( names ) ;
} else {
param . setOtherUserCodes ( "" ) ;
param . setOtherUserNames ( "" ) ;
}
updParams . add ( param ) ;
}
}
if ( CollectionUtil . isNotEmpty ( updParams ) ) {
bmsSupplierService . updateBatchById ( updParams ) ;
}
}
}