Commit 910ea282 authored by 赵啸非's avatar 赵啸非

修改报表查询

parent e3d8a49b
......@@ -56,3 +56,17 @@ INSERT INTO `mortals_xhx_resource` VALUES (null, '设备日志-菜单管理-维
-- ----------------------------
INSERT INTO `mortals_xhx_resource` VALUES (null, '设备统计-菜单管理-查看', '/device/stat/list,/device/stat/view,/device/stat/info,/device/stat/export,/device/stat/exportExcel,/device/stat/downloadTemplate,/device/stat/download', 3, 0, NULL, NULL, NULL, 0);
INSERT INTO `mortals_xhx_resource` VALUES (null, '设备统计-菜单管理-维护', '/device/stat/add,/device/stat/edit,/device/stat/delete,/device/stat/logicDelete,/device/stat/save,/device/stat/importData', 3, 0, NULL, NULL, NULL, 0);
INSERT INTO `mortals_xhx_resource` VALUES (null, '设备告警日志-菜单管理-查看', '/device/alarm/info/list,/device/alarm/info/view,/device/alarm/info/info,/device/alarm/info/export,/device/alarm/info/exportExcel,/device/alarm/info/downloadTemplate,/device/alarm/info/download', 3, 0, NULL, NULL, NULL, 0);
INSERT INTO `mortals_xhx_resource` VALUES (null, '设备告警日志-菜单管理-维护', '/device/alarm/info/add,/device/alarm/info/edit,/device/alarm/info/delete,/device/alarm/info/logicDelete,/device/alarm/info/save,/device/alarm/info/importData', 3, 0, NULL, NULL, NULL, 0);
INSERT INTO `mortals_xhx_resource` VALUES (null, '设备告警配置-菜单管理-查看', '/alarm/config/list,/alarm/config/view,/alarm/config/info,/alarm/config/export,/alarm/config/exportExcel,/alarm/config/downloadTemplate,/alarm/config/download', 3, 0, NULL, NULL, NULL, 0);
INSERT INTO `mortals_xhx_resource` VALUES (null, '设备告警配置-菜单管理-维护', '/alarm/config/add,/alarm/config/edit,/alarm/config/delete,/alarm/config/logicDelete,/alarm/config/save,/alarm/config/importData', 3, 0, NULL, NULL, NULL, 0);
INSERT INTO `mortals_xhx_resource` VALUES (null, '设备模块信息-菜单管理-查看', '/device/module/list,/device/module/view,/device/module/info,/device/module/export,/device/module/exportExcel,/device/module/downloadTemplate,/device/module/download', 3, 0, NULL, NULL, NULL, 0);
INSERT INTO `mortals_xhx_resource` VALUES (null, '设备模块信息-菜单管理-维护', '/device/module/add,/device/module/edit,/device/module/delete,/device/module/logicDelete,/device/module/save,/device/module/importData', 3, 0, NULL, NULL, NULL, 0);
INSERT INTO `mortals_xhx_resource` VALUES (null, '短信发送记录-菜单管理-查看', '/alarm/sms/send/list,/alarm/sms/send/view,/alarm/sms/send/info,/alarm/sms/send/export,/alarm/sms/send/exportExcel,/alarm/sms/send/downloadTemplate,/alarm/sms/send/download', 3, 0, NULL, NULL, NULL, 0);
INSERT INTO `mortals_xhx_resource` VALUES (null, '短信发送记录-菜单管理-维护', '/alarm/sms/send/add,/alarm/sms/send/edit,/alarm/sms/send/delete,/alarm/sms/send/logicDelete,/alarm/sms/send/save,/alarm/sms/send/importData', 3, 0, NULL, NULL, NULL, 0);
\ No newline at end of file
......@@ -84,4 +84,13 @@ INSERT INTO `mortals_xhx_param` VALUES (null, '告警级别,', 'AlarmConfig', 'a
INSERT INTO `mortals_xhx_param` VALUES (null, '推送方式,', 'AlarmConfig', 'alarmPusW1ay', '0', '不推送', 1, 4, 0, 'alarmPusW1ay', NULL, NULL, NULL);
INSERT INTO `mortals_xhx_param` VALUES (null, '推送方式,', 'AlarmConfig', 'alarmPusW1ay', '1', '短信', 1, 4, 0, 'alarmPusW1ay', NULL, NULL, NULL);
INSERT INTO `mortals_xhx_param` VALUES (null, '是否启用', 'AlarmConfig', 'enabled', '0', '不启用', 1, 4, 0, 'enabled', NULL, NULL, NULL);
INSERT INTO `mortals_xhx_param` VALUES (null, '是否启用', 'AlarmConfig', 'enabled', '1', '启用', 1, 4, 0, 'enabled', NULL, NULL, NULL);
\ No newline at end of file
INSERT INTO `mortals_xhx_param` VALUES (null, '是否启用', 'AlarmConfig', 'enabled', '1', '启用', 1, 4, 0, 'enabled', NULL, NULL, NULL);
INSERT INTO `mortals_xhx_param` VALUES (null, '告警类型,', 'DeviceAlarmInfo', 'alarmType', '0', '离线', 1, 4, 0, 'alarmType', NULL, NULL, NULL);
INSERT INTO `mortals_xhx_param` VALUES (null, '告警级别', 'DeviceAlarmInfo', 'alarmLevel', '0', '危险', 1, 4, 0, 'alarmLevel', NULL, NULL, NULL);
INSERT INTO `mortals_xhx_param` VALUES (null, '告警级别', 'DeviceAlarmInfo', 'alarmLevel', '1', '次要', 1, 4, 0, 'alarmLevel', NULL, NULL, NULL);
INSERT INTO `mortals_xhx_param` VALUES (null, '告警级别', 'DeviceAlarmInfo', 'alarmLevel', '2', '一般', 1, 4, 0, 'alarmLevel', NULL, NULL, NULL);
INSERT INTO `mortals_xhx_param` VALUES (null, '告警状态,来自工单系统', 'DeviceAlarmInfo', 'alarmStatus', '0', '未清除', 1, 4, 0, 'alarmStatus', NULL, NULL, NULL);
INSERT INTO `mortals_xhx_param` VALUES (null, '告警状态,来自工单系统', 'DeviceAlarmInfo', 'alarmStatus', '1', '清除未确认', 1, 4, 0, 'alarmStatus', NULL, NULL, NULL);
INSERT INTO `mortals_xhx_param` VALUES (null, '告警状态,来自工单系统', 'DeviceAlarmInfo', 'alarmStatus', '2', '清除已确认', 1, 4, 0, 'alarmStatus', NULL, NULL, NULL);
\ No newline at end of file
......@@ -10,6 +10,7 @@ import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.xhx.common.code.AlarmLevelEnum;
import com.mortals.xhx.common.code.AlarmTypeEnum;
import com.mortals.xhx.common.code.DeviceSrcEnum;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.common.pdu.RespData;
import com.mortals.xhx.common.pdu.site.SitePdu;
import com.mortals.xhx.feign.site.ISiteFeign;
......@@ -54,11 +55,13 @@ public class DeviceAlarmInfoServiceImpl extends AbstractCRUDServiceImpl<DeviceAl
@Override
public Rest<DeviceAlarmInfoEntity> alarmStats(DeviceAlarmInfoEntity deviceAlarmInfo, Context context) {
try {
Rest<RespData<List<SitePdu>>> rest = siteFeign.list(new SitePdu());
Map<Long, SitePdu> siteMap = rest.getData().getData().stream().collect(Collectors.toMap(x -> x.getId(), y -> y, (o, n) -> n));
if (ObjectUtils.isEmpty(siteMap)) {
Rest<List<SitePdu>> rest = siteFeign.getFlatSitesBySiteId(new SitePdu().id(deviceAlarmInfo.getSiteId()));
// Rest<RespData<List<SitePdu>>> rest = siteFeign.list(new SitePdu());
if (rest.getCode() == YesNoEnum.NO.getValue()) {
return Rest.fail("获取站点列表异常!");
}
Map<Long, SitePdu> siteMap = rest.getData().stream().collect(Collectors.toMap(x -> x.getId(), y -> y, (o, n) -> n));
Map<Long, FirmEntity> FirmMap = firmService.findToMap(new FirmEntity(), context);
Long siteId = deviceAlarmInfo.getSiteId();
......@@ -81,7 +84,7 @@ public class DeviceAlarmInfoServiceImpl extends AbstractCRUDServiceImpl<DeviceAl
Integer deviceTotalCount = deviceList.size();
deviceAlarmInfo.setDeviceTotalCount(deviceTotalCount);
//监控站点数量
int siteSize = rest.getData().getData().size();
int siteSize = rest.getData().size();
deviceAlarmInfo.setSiteSize(siteSize);
//分站点统计设备数量
......@@ -96,8 +99,8 @@ public class DeviceAlarmInfoServiceImpl extends AbstractCRUDServiceImpl<DeviceAl
//设备类型分布
Map<String, String> deviceConnTypeCollect = deviceList.
parallelStream().collect(groupingBy(x -> DeviceSrcEnum.getByValue(x.getDeviceSrc()).getDesc(), Collectors.collectingAndThen(counting(), y ->
NumberUtil.div(y, deviceTotalCount).multiply(new BigDecimal(100)).setScale(2, ROUND_HALF_DOWN).toString()
)));
NumberUtil.div(y, deviceTotalCount).multiply(new BigDecimal(100)).setScale(2, ROUND_HALF_DOWN).toString()
)));
deviceAlarmInfo.setDeviceConnTypeCollect(deviceConnTypeCollect);
//设备厂商分布
......
......@@ -471,7 +471,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
deviceStatEntity.setDeviceOnlineCount(deviceOnlineCount.intValue());
//在线率=在线设备/所有激活设备
if (deviceActiveCount > 0) {
deviceStatEntity.setDeviceOnlineRatio(new BigDecimal(deviceOnlineCount).divide(new BigDecimal(deviceActiveCount), 2, ROUND_HALF_DOWN));
deviceStatEntity.setDeviceOnlineRatio(new BigDecimal(deviceOnlineCount).divide(new BigDecimal(deviceActiveCount), 4, ROUND_HALF_DOWN));
}
//离线数量
......@@ -482,7 +482,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
.count();
deviceStatEntity.setDeviceOfflineCount(deviceOfflineCount.intValue());
if (deviceActiveCount > 0) {
deviceStatEntity.setDeviceOfflineRatio(new BigDecimal(deviceOfflineCount).divide(new BigDecimal(deviceActiveCount), 2, ROUND_HALF_DOWN));
deviceStatEntity.setDeviceOfflineRatio(new BigDecimal(deviceOfflineCount).divide(new BigDecimal(deviceActiveCount), 4, ROUND_HALF_DOWN));
}
//停用数量
Long deviceStopCount = deviceList.parallelStream()
......@@ -491,13 +491,13 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
.count();
deviceStatEntity.setDeviceStopCount(deviceStopCount.intValue());
if (deviceActiveCount > 0) {
deviceStatEntity.setDeviceStopRatio(new BigDecimal(deviceStopCount).divide(new BigDecimal(deviceActiveCount), 2, ROUND_HALF_DOWN));
deviceStatEntity.setDeviceStopRatio(new BigDecimal(deviceStopCount).divide(new BigDecimal(deviceActiveCount), 4, ROUND_HALF_DOWN));
}
deviceStatEntity.setDeviceUnActiveCount(deviceUnActiveCount.intValue());
if (deviceActiveCount > 0) {
deviceStatEntity.setDeviceUnActiveRatio(new BigDecimal(deviceUnActiveCount).divide(new BigDecimal(deviceActiveCount), 2, ROUND_HALF_DOWN));
deviceStatEntity.setDeviceUnActiveRatio(new BigDecimal(deviceUnActiveCount).divide(new BigDecimal(deviceActiveCount), 4, ROUND_HALF_DOWN));
}
//今日告警数量
......@@ -811,6 +811,12 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
System.out.println(bigDecimal1.toString());
BigDecimal divide = new BigDecimal(deviceOnlineCount).divide(new BigDecimal(deviceActiveCount), 4, ROUND_HALF_DOWN);
System.out.println(divide.toString());
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment