|
|
@@ -1,10 +1,14 @@
|
|
|
package com.lc.ibps.components.pv.provider;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
+import com.lc.ibps.form.dao.ExperimentalMapperDao;
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
@@ -12,7 +16,6 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import com.lc.ibps.api.base.constants.StateEnum;
|
|
|
import com.lc.ibps.api.base.query.QueryFilter;
|
|
|
import com.lc.ibps.base.core.constants.StringPool;
|
|
|
-import com.lc.ibps.base.core.util.BeanUtils;
|
|
|
import com.lc.ibps.cloud.entity.APIPageList;
|
|
|
import com.lc.ibps.cloud.entity.APIRequest;
|
|
|
import com.lc.ibps.cloud.entity.APIResult;
|
|
|
@@ -44,6 +47,9 @@ public class ExperimentalConfigProvider extends GenericProvider implements IExpe
|
|
|
@Resource
|
|
|
private ExperimentalConfigRepository experimentalConfigRepository;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ExperimentalMapperDao experimentalDao;
|
|
|
+
|
|
|
@ApiOperation(value = "性能验证配置信息列表(分页条件查询)数据", notes = "性能验证配置信息列表(分页条件查询)数据")
|
|
|
@Override
|
|
|
public APIResult<APIPageList<ExperimentalConfigPo>> query(
|
|
|
@@ -119,5 +125,42 @@ public class ExperimentalConfigProvider extends GenericProvider implements IExpe
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public APIResult<Void> batchSave(@RequestBody List<ExperimentalConfigPo> requestList) {
|
|
|
+ APIResult<Void> result = new APIResult<Void>();
|
|
|
+ try{
|
|
|
+ if(CollectionUtils.isNotEmpty(requestList)){
|
|
|
+ for(ExperimentalConfigPo po:requestList){
|
|
|
+ //遍历前端传入的数据数据,如果id为空则创建,否则更新
|
|
|
+ List<String> allConfigIds = experimentalDao.getAllConfigIds();
|
|
|
+ if(StringUtils.isNotEmpty(po.getId())){
|
|
|
+ //更新
|
|
|
+ experimentalDao.updateConfigforTarget(po.getId(),po.getTarget(),po.getTargetKey());
|
|
|
+ }else {
|
|
|
+ //创建
|
|
|
+ //该创建只插入target_ 和 target_key_ ,其它内容在配置页面去填写后在更新
|
|
|
+ experimentalDao.createConfigforTarget(po.getTarget(),po.getTargetKey());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //删除操作
|
|
|
+ //查询出t_xnyzpzxx表的所有主键,和传入的id对比,如果在传入id种不存在,则删除操作
|
|
|
+ List<String> allIdList = experimentalDao.getAllConfigIds();
|
|
|
+ List<String> requestIdList = requestList.stream().map(ExperimentalConfigPo::getId).collect(Collectors.toList());
|
|
|
+ List<String> deleteIdList = allIdList.stream().filter(element -> !requestIdList.contains(element)).collect(Collectors.toList());
|
|
|
+ if(CollectionUtils.isNotEmpty(deleteIdList)){
|
|
|
+ String[] deleteIds = deleteIdList.toArray(new String[deleteIdList.size()]);
|
|
|
+ this.remove(deleteIds);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ result.setMessage("批量保存性能验证配置成功");
|
|
|
+ }catch (Exception e){
|
|
|
+ setExceptionResult(result, StateEnum.ERROR.getCode(), StateEnum.ERROR.getText(), e);
|
|
|
+ logger.error("",e);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
}
|