|
@@ -336,9 +336,9 @@ public class ProjectService {
|
|
|
|
|
|
|
|
@Transactional
|
|
@Transactional
|
|
|
public HttpResult deviceBind(BindDevice bindDevice, HttpServletRequest request) {
|
|
public HttpResult deviceBind(BindDevice bindDevice, HttpServletRequest request) {
|
|
|
-// if (org.apache.commons.lang3.StringUtils.isBlank(bindDevice.getInstallTime())) {
|
|
|
|
|
-// return HttpResult.error("安装设备时间不能为空");
|
|
|
|
|
-// }
|
|
|
|
|
|
|
+ if (org.apache.commons.lang3.StringUtils.isBlank(bindDevice.getInstallTime())) {
|
|
|
|
|
+ return HttpResult.error("安装设备时间不能为空");
|
|
|
|
|
+ }
|
|
|
HeaderData headerData = commonService.getHeaderData(request);
|
|
HeaderData headerData = commonService.getHeaderData(request);
|
|
|
Long projectId = Long.parseLong(bindDevice.getProjectId());
|
|
Long projectId = Long.parseLong(bindDevice.getProjectId());
|
|
|
KwsProject project = projectMapper.selectOne(new LambdaQueryWrapper<KwsProject>().eq(KwsProject::getId, projectId));
|
|
KwsProject project = projectMapper.selectOne(new LambdaQueryWrapper<KwsProject>().eq(KwsProject::getId, projectId));
|
|
@@ -428,7 +428,7 @@ public class ProjectService {
|
|
|
deviceMapper.update(null, new LambdaUpdateWrapper<KwsDevice>()
|
|
deviceMapper.update(null, new LambdaUpdateWrapper<KwsDevice>()
|
|
|
.eq(KwsDevice::getId, id)
|
|
.eq(KwsDevice::getId, id)
|
|
|
.set(KwsDevice::getRelevanceLevel, level)
|
|
.set(KwsDevice::getRelevanceLevel, level)
|
|
|
- .set(KwsDevice::getInstallTime,localDateTime)
|
|
|
|
|
|
|
+ .set(KwsDevice::getInstallTime, localDateTime)
|
|
|
.set(KwsDevice::getStatus, DeviceEnum.BE_CHECKING.getCode())
|
|
.set(KwsDevice::getStatus, DeviceEnum.BE_CHECKING.getCode())
|
|
|
.set(KwsDevice::getOnline, 1)
|
|
.set(KwsDevice::getOnline, 1)
|
|
|
.set(KwsDevice::getAlias, bindDevice.getAlias() == null ? kwsDevice.getName() : bindDevice.getAlias())
|
|
.set(KwsDevice::getAlias, bindDevice.getAlias() == null ? kwsDevice.getName() : bindDevice.getAlias())
|
|
@@ -1358,23 +1358,38 @@ public class ProjectService {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
KwsAlarmDetailMapper alarmDetailMapper;
|
|
KwsAlarmDetailMapper alarmDetailMapper;
|
|
|
|
|
|
|
|
- public HttpResult dataScreening(String projectId) {
|
|
|
|
|
|
|
+ public HttpResult dataScreening(String projectId, String companyId) {
|
|
|
DataScreeningVO vo = new DataScreeningVO();
|
|
DataScreeningVO vo = new DataScreeningVO();
|
|
|
LambdaQueryWrapper<KwsProject> wrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<KwsProject> wrapper = new LambdaQueryWrapper<>();
|
|
|
- LambdaQueryWrapper<KwsProjectArea> wrapperProjectArea = new LambdaQueryWrapper<>();
|
|
|
|
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(projectId)) {
|
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(projectId)) {
|
|
|
wrapper.eq(KwsProject::getId, Long.parseLong(projectId));
|
|
wrapper.eq(KwsProject::getId, Long.parseLong(projectId));
|
|
|
}
|
|
}
|
|
|
|
|
+ if (org.apache.commons.lang3.StringUtils.isNotBlank(companyId)) {
|
|
|
|
|
+ wrapper.eq(KwsProject::getCompanyId, Long.parseLong(companyId));
|
|
|
|
|
+ }
|
|
|
long count = projectMapper.selectList(wrapper.eq(KwsProject::getDelFlag, 0)).stream().count();
|
|
long count = projectMapper.selectList(wrapper.eq(KwsProject::getDelFlag, 0)).stream().count();
|
|
|
vo.setProjectTotal(count);
|
|
vo.setProjectTotal(count);
|
|
|
- int deviceCount = deviceMapper.selectCountByProject(projectId);
|
|
|
|
|
|
|
+ int deviceCount = deviceMapper.selectCountByProject(projectId, companyId);
|
|
|
vo.setDeviceTotal(deviceCount);
|
|
vo.setDeviceTotal(deviceCount);
|
|
|
|
|
+ List<KwsProject> projectList = projectMapper.selectList(new LambdaQueryWrapper<KwsProject>()
|
|
|
|
|
+ .eq(org.apache.commons.lang3.StringUtils.isNotBlank(projectId), KwsProject::getId, Long.parseLong(projectId))
|
|
|
|
|
+ .eq(org.apache.commons.lang3.StringUtils.isNotBlank(companyId), KwsProject::getCompanyId, Long.parseLong(companyId))
|
|
|
|
|
+ );
|
|
|
|
|
+ List<Long> projectIdList = new ArrayList<>();
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(projectList)) {
|
|
|
|
|
+ projectIdList = projectList.stream().map(KwsProject::getId).distinct().collect(Collectors.toList());
|
|
|
|
|
+ }
|
|
|
//统计全部面积
|
|
//统计全部面积
|
|
|
- BigDecimal area = projectAreaMapper.selectList(wrapperProjectArea.eq(KwsProjectArea::getDelFlag, 0)).stream().map(KwsProjectArea::getArea).reduce(BigDecimal.ZERO,
|
|
|
|
|
|
|
+ LambdaQueryWrapper<KwsProjectArea> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ queryWrapper.eq(KwsProjectArea::getDelFlag, 0);
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(projectIdList) && projectIdList.size() > 0) {
|
|
|
|
|
+ queryWrapper.in(KwsProjectArea::getProjectId, projectIdList);
|
|
|
|
|
+ }
|
|
|
|
|
+ BigDecimal area = projectAreaMapper.selectList(queryWrapper).stream().map(KwsProjectArea::getArea).reduce(BigDecimal.ZERO,
|
|
|
BigDecimal::add);
|
|
BigDecimal::add);
|
|
|
vo.setProjectTotalArea(area);
|
|
vo.setProjectTotalArea(area);
|
|
|
/**仅统计设备在线的数据*/
|
|
/**仅统计设备在线的数据*/
|
|
|
- int deviceOnline = deviceMapper.selectDeviceOnlineRateCountByProject(projectId);
|
|
|
|
|
|
|
+ int deviceOnline = deviceMapper.selectDeviceOnlineRateCountByProject(projectId, companyId);
|
|
|
BigDecimal deviceOnlineRate = new BigDecimal("0.00");
|
|
BigDecimal deviceOnlineRate = new BigDecimal("0.00");
|
|
|
if (deviceOnline != 0) {
|
|
if (deviceOnline != 0) {
|
|
|
deviceOnlineRate = new BigDecimal(deviceOnline).divide(new BigDecimal(deviceCount), 2, RoundingMode.HALF_UP).multiply(new BigDecimal("100.00"));
|
|
deviceOnlineRate = new BigDecimal(deviceOnline).divide(new BigDecimal(deviceCount), 2, RoundingMode.HALF_UP).multiply(new BigDecimal("100.00"));
|
|
@@ -1393,6 +1408,7 @@ public class ProjectService {
|
|
|
}
|
|
}
|
|
|
List<KwsAlarm> kwsAlarmsCount = alarmMapper.selectList(new LambdaQueryWrapper<KwsAlarm>()
|
|
List<KwsAlarm> kwsAlarmsCount = alarmMapper.selectList(new LambdaQueryWrapper<KwsAlarm>()
|
|
|
.eq(org.apache.commons.lang3.StringUtils.isNotBlank(mountainId), KwsAlarm::getMountainId, mountainId)
|
|
.eq(org.apache.commons.lang3.StringUtils.isNotBlank(mountainId), KwsAlarm::getMountainId, mountainId)
|
|
|
|
|
+ .eq(org.apache.commons.lang3.StringUtils.isNotBlank(companyId), KwsAlarm::getCompanyId, companyId)
|
|
|
.eq(KwsAlarm::getStatus, 0)
|
|
.eq(KwsAlarm::getStatus, 0)
|
|
|
.eq(KwsAlarm::getDelFlag, 0)
|
|
.eq(KwsAlarm::getDelFlag, 0)
|
|
|
);
|
|
);
|
|
@@ -1404,12 +1420,14 @@ public class ProjectService {
|
|
|
vo.setAlarmTotal(alarmTotal);
|
|
vo.setAlarmTotal(alarmTotal);
|
|
|
List<KwsAlarmDetail> unreadKwsAlarms = alarmDetailMapper.selectList(new LambdaQueryWrapper<KwsAlarmDetail>()
|
|
List<KwsAlarmDetail> unreadKwsAlarms = alarmDetailMapper.selectList(new LambdaQueryWrapper<KwsAlarmDetail>()
|
|
|
.eq(org.apache.commons.lang3.StringUtils.isNotBlank(mountainId), KwsAlarmDetail::getMountainId, mountainId)
|
|
.eq(org.apache.commons.lang3.StringUtils.isNotBlank(mountainId), KwsAlarmDetail::getMountainId, mountainId)
|
|
|
|
|
+ .eq(org.apache.commons.lang3.StringUtils.isNotBlank(companyId), KwsAlarmDetail::getCompanyId, companyId)
|
|
|
.eq(KwsAlarmDetail::getStatus, 0)
|
|
.eq(KwsAlarmDetail::getStatus, 0)
|
|
|
.eq(KwsAlarmDetail::getDelFlag, 0)
|
|
.eq(KwsAlarmDetail::getDelFlag, 0)
|
|
|
);
|
|
);
|
|
|
vo.setUnreadAlarmTotal(CollectionUtils.isEmpty(unreadKwsAlarms) ? 0 : unreadKwsAlarms.size());
|
|
vo.setUnreadAlarmTotal(CollectionUtils.isEmpty(unreadKwsAlarms) ? 0 : unreadKwsAlarms.size());
|
|
|
List<KwsAlarm> oneThresholdAlarm = alarmMapper.selectList(new LambdaQueryWrapper<KwsAlarm>()
|
|
List<KwsAlarm> oneThresholdAlarm = alarmMapper.selectList(new LambdaQueryWrapper<KwsAlarm>()
|
|
|
.eq(org.apache.commons.lang3.StringUtils.isNotBlank(mountainId), KwsAlarm::getMountainId, mountainId)
|
|
.eq(org.apache.commons.lang3.StringUtils.isNotBlank(mountainId), KwsAlarm::getMountainId, mountainId)
|
|
|
|
|
+ .eq(org.apache.commons.lang3.StringUtils.isNotBlank(companyId), KwsAlarm::getCompanyId, companyId)
|
|
|
.eq(KwsAlarm::getLevel, NumberConstant.ONE)
|
|
.eq(KwsAlarm::getLevel, NumberConstant.ONE)
|
|
|
);
|
|
);
|
|
|
int oneAlarmTotal = 0;
|
|
int oneAlarmTotal = 0;
|
|
@@ -1420,6 +1438,7 @@ public class ProjectService {
|
|
|
vo.setOneAlarmTotal(oneAlarmTotal);
|
|
vo.setOneAlarmTotal(oneAlarmTotal);
|
|
|
List<KwsAlarmDetail> kwsAlarms = alarmDetailMapper.selectList(new LambdaQueryWrapper<KwsAlarmDetail>()
|
|
List<KwsAlarmDetail> kwsAlarms = alarmDetailMapper.selectList(new LambdaQueryWrapper<KwsAlarmDetail>()
|
|
|
.eq(org.apache.commons.lang3.StringUtils.isNotBlank(mountainId), KwsAlarmDetail::getMountainId, mountainId)
|
|
.eq(org.apache.commons.lang3.StringUtils.isNotBlank(mountainId), KwsAlarmDetail::getMountainId, mountainId)
|
|
|
|
|
+ .eq(org.apache.commons.lang3.StringUtils.isNotBlank(companyId), KwsAlarmDetail::getCompanyId, companyId)
|
|
|
.eq(KwsAlarmDetail::getDelFlag, 0)
|
|
.eq(KwsAlarmDetail::getDelFlag, 0)
|
|
|
.gt(KwsAlarmDetail::getCreateTime, localDateTimeStart).lt(KwsAlarmDetail::getCreateTime, localDateTimeEnd)
|
|
.gt(KwsAlarmDetail::getCreateTime, localDateTimeStart).lt(KwsAlarmDetail::getCreateTime, localDateTimeEnd)
|
|
|
);
|
|
);
|
|
@@ -1581,9 +1600,9 @@ public class ProjectService {
|
|
|
|
|
|
|
|
@Transactional
|
|
@Transactional
|
|
|
public HttpResult updateDeviceBind(BindDevice bindDevice, HttpServletRequest request) {
|
|
public HttpResult updateDeviceBind(BindDevice bindDevice, HttpServletRequest request) {
|
|
|
-// if (org.apache.commons.lang3.StringUtils.isBlank(bindDevice.getInstallTime())) {
|
|
|
|
|
-// return HttpResult.error("安装设备时间不能为空");
|
|
|
|
|
-// }
|
|
|
|
|
|
|
+ if (org.apache.commons.lang3.StringUtils.isBlank(bindDevice.getInstallTime())) {
|
|
|
|
|
+ return HttpResult.error("安装设备时间不能为空");
|
|
|
|
|
+ }
|
|
|
String deviceRelationId = bindDevice.getDeviceRelationId();
|
|
String deviceRelationId = bindDevice.getDeviceRelationId();
|
|
|
if (StringUtils.isBlank(deviceRelationId)) {
|
|
if (StringUtils.isBlank(deviceRelationId)) {
|
|
|
return HttpResult.error("关联主键id不能为空");
|
|
return HttpResult.error("关联主键id不能为空");
|
|
@@ -1591,6 +1610,13 @@ public class ProjectService {
|
|
|
String bindDeviceId = bindDevice.getBindDeviceId();
|
|
String bindDeviceId = bindDevice.getBindDeviceId();
|
|
|
String deviceIds = bindDevice.getDeviceIds();
|
|
String deviceIds = bindDevice.getDeviceIds();
|
|
|
String alias = bindDevice.getAlias();
|
|
String alias = bindDevice.getAlias();
|
|
|
|
|
+ KwsDeviceRelation kwsDeviceRelation = deviceRelationMapper.selectOne(new LambdaQueryWrapper<KwsDeviceRelation>()
|
|
|
|
|
+ .eq(KwsDeviceRelation::getId, Long.parseLong(bindDeviceId))
|
|
|
|
|
+ .eq(KwsDeviceRelation::getDelFlag, NumberConstant.ZERO)
|
|
|
|
|
+ );
|
|
|
|
|
+ if (kwsDeviceRelation == null) {
|
|
|
|
|
+ return HttpResult.error("修改id传递错误");
|
|
|
|
|
+ }
|
|
|
HeaderData headerData = commonService.getHeaderData(request);
|
|
HeaderData headerData = commonService.getHeaderData(request);
|
|
|
/**验证主设备是否存在子设备*/
|
|
/**验证主设备是否存在子设备*/
|
|
|
// List<KwsDeviceRelation> deviceRelations = deviceRelationMapper.selectList(
|
|
// List<KwsDeviceRelation> deviceRelations = deviceRelationMapper.selectList(
|