|
@@ -27,7 +27,9 @@ import springfox.documentation.annotations.ApiIgnore;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @author yangyj
|
|
@@ -64,6 +66,35 @@ public class WbsParamController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @PostMapping("/saveOrUpdateBatch")
|
|
|
+ @ApiOperationSupport(order = 1)
|
|
|
+ @ApiOperation(value = "批量保存或修改参数", notes = "批量保存或修改参数")
|
|
|
+ public R saveOrUpdateBatch(@RequestBody List<WbsParamBean> wps) {
|
|
|
+ if(CollectionUtil.isNotEmpty(wps)){
|
|
|
+ List<Long> ids= wps.stream().map(WbsParamBean::getId).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
+ if(CollectionUtil.isNotEmpty(ids)){
|
|
|
+ this.service.update(Wrappers.<WbsParam>update().lambda().set(WbsParam::getIsDeleted,1).notIn(WbsParam::getId,ids));
|
|
|
+ }
|
|
|
+ Map<Boolean,List<WbsParamBean>> map = wps.stream().collect(Collectors.partitioningBy(e->e.getId()!=null));
|
|
|
+ List<WbsParamBean> saveList = map.get(false);
|
|
|
+ List<WbsParamBean> updateList = map.get(true);
|
|
|
+ if(CollectionUtil.isNotEmpty(saveList)){
|
|
|
+ this.service.saveBatch(BeanUtil.copy(saveList,WbsParam.class));
|
|
|
+ }
|
|
|
+ if(CollectionUtil.isNotEmpty(updateList)){
|
|
|
+ List<WbsParam> ul = new ArrayList<>();
|
|
|
+ for(WbsParamBean b:updateList){
|
|
|
+ WbsParam old = this.service.getById(b.getId());
|
|
|
+ BeanUtils.copyProperties(b,old);
|
|
|
+ ul.add(old);
|
|
|
+ }
|
|
|
+ this.service.saveOrUpdateBatch(ul);
|
|
|
+ }
|
|
|
+ return R.status(true);
|
|
|
+ }
|
|
|
+ return R.status(false);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 删除
|
|
|
*/
|