|
@@ -710,44 +710,38 @@ public class AlarmConfigService extends AlarmBaseService {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * @description: 批量创建报警定义
|
|
|
|
- * @param: configModels
|
|
|
|
- * @return: com.persagy.common.web.MapResponse
|
|
|
|
- * @exception:
|
|
|
|
- * @author: lixing
|
|
|
|
- * @company: Persagy Technology Co.,Ltd
|
|
|
|
- * @since: 2020/12/4 6:45 下午
|
|
|
|
- * @version: V1.0
|
|
|
|
|
|
+ * 批量创建报警定义
|
|
|
|
+ *
|
|
|
|
+ * @param configModels 报警定义列表
|
|
|
|
+ * @return 报警定义id列表
|
|
|
|
+ * @author lixing
|
|
|
|
+ * @version V1.0 2021/10/11 8:08 下午
|
|
*/
|
|
*/
|
|
- @Transactional
|
|
|
|
public MapResponse batchCreate(List<AlarmConfigModel> configModels) {
|
|
public MapResponse batchCreate(List<AlarmConfigModel> configModels) {
|
|
MapResponse response = new MapResponse();
|
|
MapResponse response = new MapResponse();
|
|
if (configModels == null) {
|
|
if (configModels == null) {
|
|
response.setFail("请传入要创建的报警定义!");
|
|
response.setFail("请传入要创建的报警定义!");
|
|
return response;
|
|
return response;
|
|
}
|
|
}
|
|
- // 一次最多更新200条数据
|
|
|
|
- if (configModels.size() > 200) {
|
|
|
|
- response.setFail("一次最多创建200条数据");
|
|
|
|
- return response;
|
|
|
|
- }
|
|
|
|
|
|
|
|
AlarmParam alarmParam = prepareParam(response);
|
|
AlarmParam alarmParam = prepareParam(response);
|
|
if (alarmParam == null) {
|
|
if (alarmParam == null) {
|
|
return response;
|
|
return response;
|
|
}
|
|
}
|
|
Date date = new Date();
|
|
Date date = new Date();
|
|
- List<String> ids = new ArrayList<>();
|
|
|
|
|
|
+ List<AlarmConfig> configs = new ArrayList<>(configModels.size());
|
|
for (AlarmConfigModel configModel : configModels) {
|
|
for (AlarmConfigModel configModel : configModels) {
|
|
AlarmConfig entity = initAlarmConfigEntity(configModel, alarmParam, response);
|
|
AlarmConfig entity = initAlarmConfigEntity(configModel, alarmParam, response);
|
|
if (entity == null) {
|
|
if (entity == null) {
|
|
|
|
+ response.setFail("批量创建报警条件失败,参数中存在null对象");
|
|
return response;
|
|
return response;
|
|
}
|
|
}
|
|
- alarmConfigRepository.save(entity);
|
|
|
|
- ids.add(entity.getId());
|
|
|
|
- DmpMessage msg = generateMessage(Lists.newArrayList(entity), null);
|
|
|
|
- messageProcesser.convertAndSend(msg);
|
|
|
|
|
|
+ configs.add(entity);
|
|
}
|
|
}
|
|
|
|
+ configs = alarmConfigRepository.saveAll(configs);
|
|
|
|
+ DmpMessage msg = generateMessage(configs, null);
|
|
|
|
+ messageProcesser.convertAndSend(msg);
|
|
|
|
+ List<String> ids = configs.stream().map(AlarmConfig::getId).collect(Collectors.toList());
|
|
Date date1 = new Date();
|
|
Date date1 = new Date();
|
|
System.out.println("执行时间:" + (date1.getTime() - date.getTime()));
|
|
System.out.println("执行时间:" + (date1.getTime() - date.getTime()));
|
|
response.add("ids", ids);
|
|
response.add("ids", ids);
|