|
@@ -4,11 +4,14 @@ package com.kuyuntech.vrv.coreservice.service.core.impl;
|
|
import com.kuyuntech.vrv.coreapi.service.core.DeviceAlarmConfigService;
|
|
import com.kuyuntech.vrv.coreapi.service.core.DeviceAlarmConfigService;
|
|
import com.kuyuntech.vrv.coreservice.dao.core.*;
|
|
import com.kuyuntech.vrv.coreservice.dao.core.*;
|
|
import com.kuyuntech.vrv.coreservice.domain.core.*;
|
|
import com.kuyuntech.vrv.coreservice.domain.core.*;
|
|
|
|
+import org.apache.commons.lang3.Validate;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import com.kuyuntech.vrv.coreapi.bean.core.DeviceAlarmConfigBean;
|
|
import com.kuyuntech.vrv.coreapi.bean.core.DeviceAlarmConfigBean;
|
|
import com.wbspool.fastboot.core.common.bean.PagerBean;
|
|
import com.wbspool.fastboot.core.common.bean.PagerBean;
|
|
|
|
+
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -16,23 +19,22 @@ import org.springframework.beans.BeanUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.hibernate.criterion.DetachedCriteria;
|
|
import org.hibernate.criterion.DetachedCriteria;
|
|
import org.hibernate.criterion.Restrictions;
|
|
import org.hibernate.criterion.Restrictions;
|
|
|
|
+
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
+
|
|
import org.hibernate.criterion.Order;
|
|
import org.hibernate.criterion.Order;
|
|
import com.wbspool.fastboot.core.jpa.service.AbstractFastbootService;
|
|
import com.wbspool.fastboot.core.jpa.service.AbstractFastbootService;
|
|
import org.springframework.util.Assert;
|
|
import org.springframework.util.Assert;
|
|
-import static com.wbspool.fastboot.core.jpa.constant.DataValidTypes.*;
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
+import static com.wbspool.fastboot.core.jpa.constant.DataValidTypes.*;
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
-* DeviceAlarmConfigService
|
|
|
|
-*
|
|
|
|
-*/
|
|
|
|
|
|
+ * DeviceAlarmConfigService
|
|
|
|
+ */
|
|
@Service("deviceAlarmConfigService")
|
|
@Service("deviceAlarmConfigService")
|
|
-@Transactional(rollbackFor = Exception.class,transactionManager = "vrvCoreServiceTransactionManager")
|
|
|
|
-public class DeviceAlarmConfigServiceImpl extends AbstractFastbootService<DeviceAlarmConfig,DeviceAlarmConfigBean> implements DeviceAlarmConfigService {
|
|
|
|
|
|
+@Transactional(rollbackFor = Exception.class, transactionManager = "vrvCoreServiceTransactionManager")
|
|
|
|
+public class DeviceAlarmConfigServiceImpl extends AbstractFastbootService<DeviceAlarmConfig, DeviceAlarmConfigBean> implements DeviceAlarmConfigService {
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(DeviceAlarmConfigServiceImpl.class);
|
|
private static final Logger logger = LoggerFactory.getLogger(DeviceAlarmConfigServiceImpl.class);
|
|
|
|
|
|
@@ -52,7 +54,7 @@ public class DeviceAlarmConfigServiceImpl extends AbstractFastbootService<Device
|
|
public DeviceAlarmConfigBean add(DeviceAlarmConfigBean deviceAlarmConfigBean) {
|
|
public DeviceAlarmConfigBean add(DeviceAlarmConfigBean deviceAlarmConfigBean) {
|
|
|
|
|
|
DeviceAlarmConfig deviceAlarmConfig = new DeviceAlarmConfig();
|
|
DeviceAlarmConfig deviceAlarmConfig = new DeviceAlarmConfig();
|
|
- beanToDomain(deviceAlarmConfigBean,deviceAlarmConfig,"id");
|
|
|
|
|
|
+ beanToDomain(deviceAlarmConfigBean, deviceAlarmConfig, "id");
|
|
|
|
|
|
|
|
|
|
String operatorNumber = deviceAlarmConfigBean.getOperatorNumber();
|
|
String operatorNumber = deviceAlarmConfigBean.getOperatorNumber();
|
|
@@ -75,7 +77,7 @@ public class DeviceAlarmConfigServiceImpl extends AbstractFastbootService<Device
|
|
Operator operator = operatorDao.findByNumberAndValid(operatorNumber, VALID);
|
|
Operator operator = operatorDao.findByNumberAndValid(operatorNumber, VALID);
|
|
Project project = projectDao.findByNumberAndValid(projectNumber, VALID);
|
|
Project project = projectDao.findByNumberAndValid(projectNumber, VALID);
|
|
Gateway gateway = gatewayDao.findByNumberAndValid(gatewayNumber, VALID);
|
|
Gateway gateway = gatewayDao.findByNumberAndValid(gatewayNumber, VALID);
|
|
- Device device = deviceDao.findBySnAndValid(sn,VALID);
|
|
|
|
|
|
+ Device device = deviceDao.findBySnAndValid(sn, VALID);
|
|
|
|
|
|
deviceAlarmConfig.setOperatorCode(operator.getCode());
|
|
deviceAlarmConfig.setOperatorCode(operator.getCode());
|
|
deviceAlarmConfig.setProjectCode(project.getCode());
|
|
deviceAlarmConfig.setProjectCode(project.getCode());
|
|
@@ -93,23 +95,23 @@ public class DeviceAlarmConfigServiceImpl extends AbstractFastbootService<Device
|
|
@Override
|
|
@Override
|
|
public DeviceAlarmConfigBean update(DeviceAlarmConfigBean deviceAlarmConfigBean) {
|
|
public DeviceAlarmConfigBean update(DeviceAlarmConfigBean deviceAlarmConfigBean) {
|
|
|
|
|
|
- if(deviceAlarmConfigBean == null ){
|
|
|
|
- return null ;
|
|
|
|
|
|
+ if (deviceAlarmConfigBean == null) {
|
|
|
|
+ return null;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
- DeviceAlarmConfig deviceAlarmConfig = deviceAlarmConfigDao.findByCodeAndValid(deviceAlarmConfigBean.getCode(),VALID);
|
|
|
|
-
|
|
|
|
|
|
|
|
- if(deviceAlarmConfig == null){
|
|
|
|
|
|
+ DeviceAlarmConfig deviceAlarmConfig = deviceAlarmConfigDao.findByCodeAndValid(deviceAlarmConfigBean.getCode(), VALID);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if (deviceAlarmConfig == null) {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
- beanToDomain(deviceAlarmConfigBean,deviceAlarmConfig,"id","code","version","createTime","updateTime","valid");
|
|
|
|
|
|
+ beanToDomain(deviceAlarmConfigBean, deviceAlarmConfig, "id", "code", "version", "createTime", "updateTime", "valid");
|
|
|
|
|
|
deviceAlarmConfigDao.save(deviceAlarmConfig);
|
|
deviceAlarmConfigDao.save(deviceAlarmConfig);
|
|
|
|
|
|
- domainToBean(deviceAlarmConfig,deviceAlarmConfigBean);
|
|
|
|
|
|
+ domainToBean(deviceAlarmConfig, deviceAlarmConfigBean);
|
|
|
|
|
|
return deviceAlarmConfigBean;
|
|
return deviceAlarmConfigBean;
|
|
}
|
|
}
|
|
@@ -117,60 +119,58 @@ public class DeviceAlarmConfigServiceImpl extends AbstractFastbootService<Device
|
|
@Override
|
|
@Override
|
|
public DeviceAlarmConfigBean delete(DeviceAlarmConfigBean deviceAlarmConfigBean) {
|
|
public DeviceAlarmConfigBean delete(DeviceAlarmConfigBean deviceAlarmConfigBean) {
|
|
|
|
|
|
- if(deviceAlarmConfigBean == null){
|
|
|
|
- return null ;
|
|
|
|
|
|
+ if (deviceAlarmConfigBean == null) {
|
|
|
|
+ return null;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
- DeviceAlarmConfig deviceAlarmConfig = deviceAlarmConfigDao.findByCodeAndValid(deviceAlarmConfigBean.getCode(),VALID);
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ DeviceAlarmConfig deviceAlarmConfig = deviceAlarmConfigDao.findByCodeAndValid(deviceAlarmConfigBean.getCode(), VALID);
|
|
|
|
|
|
|
|
|
|
- if(deviceAlarmConfig == null){
|
|
|
|
|
|
+ if (deviceAlarmConfig == null) {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
|
|
+
|
|
deviceAlarmConfig.setValid(INVALID);
|
|
deviceAlarmConfig.setValid(INVALID);
|
|
deviceAlarmConfigDao.save(deviceAlarmConfig);
|
|
deviceAlarmConfigDao.save(deviceAlarmConfig);
|
|
-
|
|
|
|
|
|
|
|
- domainToBean(deviceAlarmConfig,deviceAlarmConfigBean);
|
|
|
|
|
|
+
|
|
|
|
+ domainToBean(deviceAlarmConfig, deviceAlarmConfigBean);
|
|
|
|
|
|
return deviceAlarmConfigBean;
|
|
return deviceAlarmConfigBean;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public DeviceAlarmConfigBean find(DeviceAlarmConfigBean deviceAlarmConfigBean) {
|
|
public DeviceAlarmConfigBean find(DeviceAlarmConfigBean deviceAlarmConfigBean) {
|
|
- if(deviceAlarmConfigBean == null){
|
|
|
|
- return null ;
|
|
|
|
|
|
+ if (deviceAlarmConfigBean == null) {
|
|
|
|
+ return null;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
- DeviceAlarmConfig deviceAlarmConfig = deviceAlarmConfigDao.findByCodeAndValid(deviceAlarmConfigBean.getCode(),VALID);
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ DeviceAlarmConfig deviceAlarmConfig = deviceAlarmConfigDao.findByCodeAndValid(deviceAlarmConfigBean.getCode(), VALID);
|
|
|
|
|
|
|
|
|
|
- if(deviceAlarmConfig == null){
|
|
|
|
- return null ;
|
|
|
|
|
|
+ if (deviceAlarmConfig == null) {
|
|
|
|
+ return null;
|
|
}
|
|
}
|
|
- BeanUtils.copyProperties(deviceAlarmConfig,deviceAlarmConfigBean);
|
|
|
|
|
|
+ BeanUtils.copyProperties(deviceAlarmConfig, deviceAlarmConfigBean);
|
|
return deviceAlarmConfigBean;
|
|
return deviceAlarmConfigBean;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public DeviceAlarmConfigBean find(String code) {
|
|
public DeviceAlarmConfigBean find(String code) {
|
|
- return this.find(DeviceAlarmConfigBean.builder().code(code).build());
|
|
|
|
|
|
+ return this.find(DeviceAlarmConfigBean.builder().code(code).build());
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public List<DeviceAlarmConfigBean> findAll(DeviceAlarmConfigBean deviceAlarmConfigBean, PagerBean pagerBean) {
|
|
public List<DeviceAlarmConfigBean> findAll(DeviceAlarmConfigBean deviceAlarmConfigBean, PagerBean pagerBean) {
|
|
List<DeviceAlarmConfigBean> deviceAlarmConfigBeans = new ArrayList<>();
|
|
List<DeviceAlarmConfigBean> deviceAlarmConfigBeans = new ArrayList<>();
|
|
DetachedCriteria detachedCriteria = createListCriteria(deviceAlarmConfigBean);
|
|
DetachedCriteria detachedCriteria = createListCriteria(deviceAlarmConfigBean);
|
|
- List<DeviceAlarmConfig> deviceAlarmConfigs = deviceAlarmConfigDao.findAll(detachedCriteria,pagerBean);
|
|
|
|
|
|
+ List<DeviceAlarmConfig> deviceAlarmConfigs = deviceAlarmConfigDao.findAll(detachedCriteria, pagerBean);
|
|
for (DeviceAlarmConfig deviceAlarmConfig : deviceAlarmConfigs) {
|
|
for (DeviceAlarmConfig deviceAlarmConfig : deviceAlarmConfigs) {
|
|
DeviceAlarmConfigBean deviceAlarmConfigBeanTemp = new DeviceAlarmConfigBean();
|
|
DeviceAlarmConfigBean deviceAlarmConfigBeanTemp = new DeviceAlarmConfigBean();
|
|
- domainToBean(deviceAlarmConfig,deviceAlarmConfigBeanTemp);
|
|
|
|
|
|
+ domainToBean(deviceAlarmConfig, deviceAlarmConfigBeanTemp);
|
|
deviceAlarmConfigBeans.add(deviceAlarmConfigBeanTemp);
|
|
deviceAlarmConfigBeans.add(deviceAlarmConfigBeanTemp);
|
|
}
|
|
}
|
|
return deviceAlarmConfigBeans;
|
|
return deviceAlarmConfigBeans;
|
|
@@ -178,17 +178,17 @@ public class DeviceAlarmConfigServiceImpl extends AbstractFastbootService<Device
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public List<DeviceAlarmConfigBean> findAll(DeviceAlarmConfigBean deviceAlarmConfigBean) {
|
|
public List<DeviceAlarmConfigBean> findAll(DeviceAlarmConfigBean deviceAlarmConfigBean) {
|
|
- return this.findAll(deviceAlarmConfigBean,null);
|
|
|
|
|
|
+ return this.findAll(deviceAlarmConfigBean, null);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public Long countAll(DeviceAlarmConfigBean deviceAlarmConfigBean) {
|
|
|
|
|
|
+ public Long countAll(DeviceAlarmConfigBean deviceAlarmConfigBean) {
|
|
DetachedCriteria detachedCriteria = createListCriteria(deviceAlarmConfigBean);
|
|
DetachedCriteria detachedCriteria = createListCriteria(deviceAlarmConfigBean);
|
|
return deviceAlarmConfigDao.countAll(detachedCriteria);
|
|
return deviceAlarmConfigDao.countAll(detachedCriteria);
|
|
}
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
|
- public PagerBean<DeviceAlarmConfigBean> findPager(DeviceAlarmConfigBean deviceAlarmConfigBean, PagerBean pagerBean) {
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public PagerBean<DeviceAlarmConfigBean> findPager(DeviceAlarmConfigBean deviceAlarmConfigBean, PagerBean pagerBean) {
|
|
List<DeviceAlarmConfigBean> deviceAlarmConfigBeans = this.findAll(deviceAlarmConfigBean, pagerBean);
|
|
List<DeviceAlarmConfigBean> deviceAlarmConfigBeans = this.findAll(deviceAlarmConfigBean, pagerBean);
|
|
Long count = this.countAll(deviceAlarmConfigBean);
|
|
Long count = this.countAll(deviceAlarmConfigBean);
|
|
PagerBean<DeviceAlarmConfigBean> deviceAlarmConfigPageBean = new PagerBean<>();
|
|
PagerBean<DeviceAlarmConfigBean> deviceAlarmConfigPageBean = new PagerBean<>();
|
|
@@ -196,30 +196,30 @@ public class DeviceAlarmConfigServiceImpl extends AbstractFastbootService<Device
|
|
deviceAlarmConfigPageBean.setItemCount(count.intValue());
|
|
deviceAlarmConfigPageBean.setItemCount(count.intValue());
|
|
deviceAlarmConfigPageBean.init();
|
|
deviceAlarmConfigPageBean.init();
|
|
deviceAlarmConfigPageBean.setItems(deviceAlarmConfigBeans);
|
|
deviceAlarmConfigPageBean.setItems(deviceAlarmConfigBeans);
|
|
- return deviceAlarmConfigPageBean ;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 创建列表查询条件
|
|
|
|
- * @param deviceAlarmConfigBean 查询参数
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- private static DetachedCriteria createListCriteria(DeviceAlarmConfigBean deviceAlarmConfigBean){
|
|
|
|
- DetachedCriteria detachedCriteria = DetachedCriteria.forClass(DeviceAlarmConfig.class);
|
|
|
|
- detachedCriteria.add(Restrictions.eq("valid",VALID));
|
|
|
|
- return detachedCriteria;
|
|
|
|
- }
|
|
|
|
|
|
+ return deviceAlarmConfigPageBean;
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 创建列表查询条件
|
|
|
|
+ *
|
|
|
|
+ * @param deviceAlarmConfigBean 查询参数
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ private static DetachedCriteria createListCriteria(DeviceAlarmConfigBean deviceAlarmConfigBean) {
|
|
|
|
+ DetachedCriteria detachedCriteria = DetachedCriteria.forClass(DeviceAlarmConfig.class);
|
|
|
|
+ detachedCriteria.add(Restrictions.eq("valid", VALID));
|
|
|
|
+ return detachedCriteria;
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void batchDelete(List<DeviceAlarmConfigBean> deviceAlarmConfigBean) {
|
|
public void batchDelete(List<DeviceAlarmConfigBean> deviceAlarmConfigBean) {
|
|
- if(deviceAlarmConfigBean.isEmpty()){
|
|
|
|
- return ;
|
|
|
|
|
|
+ if (deviceAlarmConfigBean.isEmpty()) {
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
List<String> codes = new ArrayList<>();
|
|
List<String> codes = new ArrayList<>();
|
|
- deviceAlarmConfigBean.forEach((e) ->{
|
|
|
|
- codes.add(e.getCode());
|
|
|
|
|
|
+ deviceAlarmConfigBean.forEach((e) -> {
|
|
|
|
+ codes.add(e.getCode());
|
|
});
|
|
});
|
|
batchDeleteByCodes(codes);
|
|
batchDeleteByCodes(codes);
|
|
|
|
|
|
@@ -229,17 +229,25 @@ public class DeviceAlarmConfigServiceImpl extends AbstractFastbootService<Device
|
|
@Override
|
|
@Override
|
|
public void batchDeleteByCodes(List<String> codes) {
|
|
public void batchDeleteByCodes(List<String> codes) {
|
|
|
|
|
|
- if(codes.isEmpty()){
|
|
|
|
- return ;
|
|
|
|
|
|
+ if (codes.isEmpty()) {
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
|
|
|
|
for (String code : codes) {
|
|
for (String code : codes) {
|
|
- Assert.notNull(this.delete(DeviceAlarmConfigBean.builder().code(code).build()),"batch delete by codes error! ");
|
|
|
|
|
|
+ Assert.notNull(this.delete(DeviceAlarmConfigBean.builder().code(code).build()), "batch delete by codes error! ");
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public DeviceAlarmConfigBean findByName(String name) {
|
|
|
|
+ DeviceAlarmConfigBean deviceAlarmConfigBean = new DeviceAlarmConfigBean();
|
|
|
|
+ DeviceAlarmConfig deviceAlarmConfig = deviceAlarmConfigDao.findByVariableIdAndValid(name, VALID);
|
|
|
|
+
|
|
|
|
+ domainToBean(deviceAlarmConfig, deviceAlarmConfigBean);
|
|
|
|
+
|
|
|
|
+ return deviceAlarmConfigBean;
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|