|
@@ -3,12 +3,15 @@ package com.kuyuntech.vrv.coreservice.service.core.impl;
|
|
|
|
|
|
import com.kuyuntech.vrv.coreapi.service.core.DeviceAlarmRecordService;
|
|
|
import com.kuyuntech.vrv.coreservice.dao.core.DeviceAlarmRecordDao;
|
|
|
+import org.hibernate.criterion.MatchMode;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import com.kuyuntech.vrv.coreapi.bean.core.DeviceAlarmRecordBean;
|
|
|
import com.kuyuntech.vrv.coreservice.domain.core.DeviceAlarmRecord;
|
|
|
import com.wbspool.fastboot.core.common.bean.PagerBean;
|
|
|
+
|
|
|
import java.util.List;
|
|
|
+
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -16,38 +19,36 @@ import org.springframework.beans.BeanUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.hibernate.criterion.DetachedCriteria;
|
|
|
import org.hibernate.criterion.Restrictions;
|
|
|
+
|
|
|
import java.util.ArrayList;
|
|
|
+
|
|
|
import org.hibernate.criterion.Order;
|
|
|
import com.wbspool.fastboot.core.jpa.service.AbstractFastbootService;
|
|
|
import org.springframework.util.Assert;
|
|
|
-import static com.wbspool.fastboot.core.jpa.constant.DataValidTypes.*;
|
|
|
-
|
|
|
-
|
|
|
|
|
|
+import static com.wbspool.fastboot.core.jpa.constant.DataValidTypes.*;
|
|
|
|
|
|
|
|
|
/**
|
|
|
-* DeviceAlarmRecordService
|
|
|
-*
|
|
|
-*/
|
|
|
+ * DeviceAlarmRecordService
|
|
|
+ */
|
|
|
@Service("deviceAlarmRecordService")
|
|
|
-@Transactional(rollbackFor = Exception.class,transactionManager = "vrvCoreServiceTransactionManager")
|
|
|
-public class DeviceAlarmRecordServiceImpl extends AbstractFastbootService<DeviceAlarmRecord,DeviceAlarmRecordBean> implements DeviceAlarmRecordService {
|
|
|
+@Transactional(rollbackFor = Exception.class, transactionManager = "vrvCoreServiceTransactionManager")
|
|
|
+public class DeviceAlarmRecordServiceImpl extends AbstractFastbootService<DeviceAlarmRecord, DeviceAlarmRecordBean> implements DeviceAlarmRecordService {
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(DeviceAlarmRecordServiceImpl.class);
|
|
|
|
|
|
@Autowired
|
|
|
DeviceAlarmRecordDao deviceAlarmRecordDao;
|
|
|
|
|
|
-
|
|
|
|
|
|
@Override
|
|
|
public DeviceAlarmRecordBean add(DeviceAlarmRecordBean deviceAlarmRecordBean) {
|
|
|
|
|
|
DeviceAlarmRecord deviceAlarmRecord = new DeviceAlarmRecord();
|
|
|
- beanToDomain(deviceAlarmRecordBean,deviceAlarmRecord,"id");
|
|
|
+ beanToDomain(deviceAlarmRecordBean, deviceAlarmRecord, "id");
|
|
|
deviceAlarmRecordDao.save(deviceAlarmRecord);
|
|
|
- domainToBean(deviceAlarmRecord,deviceAlarmRecordBean);
|
|
|
+ domainToBean(deviceAlarmRecord, deviceAlarmRecordBean);
|
|
|
return deviceAlarmRecordBean;
|
|
|
|
|
|
}
|
|
@@ -55,23 +56,23 @@ public class DeviceAlarmRecordServiceImpl extends AbstractFastbootService<Device
|
|
|
@Override
|
|
|
public DeviceAlarmRecordBean update(DeviceAlarmRecordBean deviceAlarmRecordBean) {
|
|
|
|
|
|
- if(deviceAlarmRecordBean == null ){
|
|
|
- return null ;
|
|
|
+ if (deviceAlarmRecordBean == null) {
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- DeviceAlarmRecord deviceAlarmRecord = deviceAlarmRecordDao.findByCodeAndValid(deviceAlarmRecordBean.getCode(),VALID);
|
|
|
-
|
|
|
|
|
|
- if(deviceAlarmRecord == null){
|
|
|
+ DeviceAlarmRecord deviceAlarmRecord = deviceAlarmRecordDao.findByCodeAndValid(deviceAlarmRecordBean.getCode(), VALID);
|
|
|
+
|
|
|
+
|
|
|
+ if (deviceAlarmRecord == null) {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- beanToDomain(deviceAlarmRecordBean,deviceAlarmRecord,"id","code","version","createTime","updateTime","valid");
|
|
|
+ beanToDomain(deviceAlarmRecordBean, deviceAlarmRecord, "id", "code", "version", "createTime", "updateTime", "valid");
|
|
|
|
|
|
deviceAlarmRecordDao.save(deviceAlarmRecord);
|
|
|
|
|
|
- domainToBean(deviceAlarmRecord,deviceAlarmRecordBean);
|
|
|
+ domainToBean(deviceAlarmRecord, deviceAlarmRecordBean);
|
|
|
|
|
|
return deviceAlarmRecordBean;
|
|
|
}
|
|
@@ -79,60 +80,58 @@ public class DeviceAlarmRecordServiceImpl extends AbstractFastbootService<Device
|
|
|
@Override
|
|
|
public DeviceAlarmRecordBean delete(DeviceAlarmRecordBean deviceAlarmRecordBean) {
|
|
|
|
|
|
- if(deviceAlarmRecordBean == null){
|
|
|
- return null ;
|
|
|
+ if (deviceAlarmRecordBean == null) {
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- DeviceAlarmRecord deviceAlarmRecord = deviceAlarmRecordDao.findByCodeAndValid(deviceAlarmRecordBean.getCode(),VALID);
|
|
|
-
|
|
|
|
|
|
+ DeviceAlarmRecord deviceAlarmRecord = deviceAlarmRecordDao.findByCodeAndValid(deviceAlarmRecordBean.getCode(), VALID);
|
|
|
|
|
|
- if(deviceAlarmRecord == null){
|
|
|
+
|
|
|
+ if (deviceAlarmRecord == null) {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
deviceAlarmRecord.setValid(INVALID);
|
|
|
deviceAlarmRecordDao.save(deviceAlarmRecord);
|
|
|
-
|
|
|
|
|
|
- domainToBean(deviceAlarmRecord,deviceAlarmRecordBean);
|
|
|
+
|
|
|
+ domainToBean(deviceAlarmRecord, deviceAlarmRecordBean);
|
|
|
|
|
|
return deviceAlarmRecordBean;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public DeviceAlarmRecordBean find(DeviceAlarmRecordBean deviceAlarmRecordBean) {
|
|
|
- if(deviceAlarmRecordBean == null){
|
|
|
- return null ;
|
|
|
+ if (deviceAlarmRecordBean == null) {
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- DeviceAlarmRecord deviceAlarmRecord = deviceAlarmRecordDao.findByCodeAndValid(deviceAlarmRecordBean.getCode(),VALID);
|
|
|
-
|
|
|
+
|
|
|
+ DeviceAlarmRecord deviceAlarmRecord = deviceAlarmRecordDao.findByCodeAndValid(deviceAlarmRecordBean.getCode(), VALID);
|
|
|
|
|
|
|
|
|
- if(deviceAlarmRecord == null){
|
|
|
- return null ;
|
|
|
+ if (deviceAlarmRecord == null) {
|
|
|
+ return null;
|
|
|
}
|
|
|
- BeanUtils.copyProperties(deviceAlarmRecord,deviceAlarmRecordBean);
|
|
|
+ BeanUtils.copyProperties(deviceAlarmRecord, deviceAlarmRecordBean);
|
|
|
return deviceAlarmRecordBean;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public DeviceAlarmRecordBean find(String code) {
|
|
|
- return this.find(DeviceAlarmRecordBean.builder().code(code).build());
|
|
|
+ return this.find(DeviceAlarmRecordBean.builder().code(code).build());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<DeviceAlarmRecordBean> findAll(DeviceAlarmRecordBean deviceAlarmRecordBean, PagerBean pagerBean) {
|
|
|
List<DeviceAlarmRecordBean> deviceAlarmRecordBeans = new ArrayList<>();
|
|
|
DetachedCriteria detachedCriteria = createListCriteria(deviceAlarmRecordBean);
|
|
|
- List<DeviceAlarmRecord> deviceAlarmRecords = deviceAlarmRecordDao.findAll(detachedCriteria,pagerBean);
|
|
|
+ List<DeviceAlarmRecord> deviceAlarmRecords = deviceAlarmRecordDao.findAll(detachedCriteria, pagerBean);
|
|
|
for (DeviceAlarmRecord deviceAlarmRecord : deviceAlarmRecords) {
|
|
|
DeviceAlarmRecordBean deviceAlarmRecordBeanTemp = new DeviceAlarmRecordBean();
|
|
|
- domainToBean(deviceAlarmRecord,deviceAlarmRecordBeanTemp);
|
|
|
+ domainToBean(deviceAlarmRecord, deviceAlarmRecordBeanTemp);
|
|
|
deviceAlarmRecordBeans.add(deviceAlarmRecordBeanTemp);
|
|
|
}
|
|
|
return deviceAlarmRecordBeans;
|
|
@@ -140,17 +139,17 @@ public class DeviceAlarmRecordServiceImpl extends AbstractFastbootService<Device
|
|
|
|
|
|
@Override
|
|
|
public List<DeviceAlarmRecordBean> findAll(DeviceAlarmRecordBean deviceAlarmRecordBean) {
|
|
|
- return this.findAll(deviceAlarmRecordBean,null);
|
|
|
+ return this.findAll(deviceAlarmRecordBean, null);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Long countAll(DeviceAlarmRecordBean deviceAlarmRecordBean) {
|
|
|
+ public Long countAll(DeviceAlarmRecordBean deviceAlarmRecordBean) {
|
|
|
DetachedCriteria detachedCriteria = createListCriteria(deviceAlarmRecordBean);
|
|
|
return deviceAlarmRecordDao.countAll(detachedCriteria);
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public PagerBean<DeviceAlarmRecordBean> findPager(DeviceAlarmRecordBean deviceAlarmRecordBean, PagerBean pagerBean) {
|
|
|
+ @Override
|
|
|
+ public PagerBean<DeviceAlarmRecordBean> findPager(DeviceAlarmRecordBean deviceAlarmRecordBean, PagerBean pagerBean) {
|
|
|
List<DeviceAlarmRecordBean> deviceAlarmRecordBeans = this.findAll(deviceAlarmRecordBean, pagerBean);
|
|
|
Long count = this.countAll(deviceAlarmRecordBean);
|
|
|
PagerBean<DeviceAlarmRecordBean> deviceAlarmRecordPageBean = new PagerBean<>();
|
|
@@ -158,30 +157,50 @@ public class DeviceAlarmRecordServiceImpl extends AbstractFastbootService<Device
|
|
|
deviceAlarmRecordPageBean.setItemCount(count.intValue());
|
|
|
deviceAlarmRecordPageBean.init();
|
|
|
deviceAlarmRecordPageBean.setItems(deviceAlarmRecordBeans);
|
|
|
- return deviceAlarmRecordPageBean ;
|
|
|
- }
|
|
|
+ return deviceAlarmRecordPageBean;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 创建列表查询条件
|
|
|
+ *
|
|
|
+ * @param deviceAlarmRecordBean 查询参数
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private static DetachedCriteria createListCriteria(DeviceAlarmRecordBean deviceAlarmRecordBean) {
|
|
|
+ DetachedCriteria detachedCriteria = DetachedCriteria.forClass(DeviceAlarmRecord.class);
|
|
|
+
|
|
|
+ if (deviceAlarmRecordBean != null) {
|
|
|
+ if (StringUtils.isNotBlank(deviceAlarmRecordBean.getSn())) {
|
|
|
+ detachedCriteria.add(Restrictions.like("sn", deviceAlarmRecordBean.getSn(), MatchMode.ANYWHERE));
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(deviceAlarmRecordBean.getAlarmName())) {
|
|
|
+ detachedCriteria.add(Restrictions.like("alarmName", deviceAlarmRecordBean.getAlarmName(), MatchMode.ANYWHERE));
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(deviceAlarmRecordBean.getVariableId())) {
|
|
|
+ detachedCriteria.add(Restrictions.like("variableId", deviceAlarmRecordBean.getVariableId(), MatchMode.ANYWHERE));
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(deviceAlarmRecordBean.getAlarmType())) {
|
|
|
+ detachedCriteria.add(Restrictions.eq("alarmType", deviceAlarmRecordBean.getAlarmType()));
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(deviceAlarmRecordBean.getRecordCondition())) {
|
|
|
+ detachedCriteria.add(Restrictions.like("recordCondition", deviceAlarmRecordBean.getRecordCondition(), MatchMode.ANYWHERE));
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- /**
|
|
|
- * 创建列表查询条件
|
|
|
- * @param deviceAlarmRecordBean 查询参数
|
|
|
- * @return
|
|
|
- */
|
|
|
- private static DetachedCriteria createListCriteria(DeviceAlarmRecordBean deviceAlarmRecordBean){
|
|
|
- DetachedCriteria detachedCriteria = DetachedCriteria.forClass(DeviceAlarmRecord.class);
|
|
|
- detachedCriteria.add(Restrictions.eq("valid",VALID));
|
|
|
- return detachedCriteria;
|
|
|
- }
|
|
|
|
|
|
+ detachedCriteria.add(Restrictions.eq("valid", VALID));
|
|
|
+ return detachedCriteria;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
@Override
|
|
|
public void batchDelete(List<DeviceAlarmRecordBean> deviceAlarmRecordBean) {
|
|
|
- if(deviceAlarmRecordBean.isEmpty()){
|
|
|
- return ;
|
|
|
+ if (deviceAlarmRecordBean.isEmpty()) {
|
|
|
+ return;
|
|
|
}
|
|
|
List<String> codes = new ArrayList<>();
|
|
|
- deviceAlarmRecordBean.forEach((e) ->{
|
|
|
- codes.add(e.getCode());
|
|
|
+ deviceAlarmRecordBean.forEach((e) -> {
|
|
|
+ codes.add(e.getCode());
|
|
|
});
|
|
|
batchDeleteByCodes(codes);
|
|
|
|
|
@@ -191,17 +210,15 @@ public class DeviceAlarmRecordServiceImpl extends AbstractFastbootService<Device
|
|
|
@Override
|
|
|
public void batchDeleteByCodes(List<String> codes) {
|
|
|
|
|
|
- if(codes.isEmpty()){
|
|
|
- return ;
|
|
|
+ if (codes.isEmpty()) {
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
for (String code : codes) {
|
|
|
- Assert.notNull(this.delete(DeviceAlarmRecordBean.builder().code(code).build()),"batch delete by codes error! ");
|
|
|
+ Assert.notNull(this.delete(DeviceAlarmRecordBean.builder().code(code).build()), "batch delete by codes error! ");
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
|
|
|
}
|