wzyyy 3 سال پیش
والد
کامیت
fff77cce11

+ 229 - 139
src/pages/device/DashBoard/index.tsx

@@ -244,150 +244,240 @@ const DeviceBoard = () => {
 
   const getEcharts = async () => {
     const data = ref.current!.getValues();
-    if (data && data.time.type !== 'today') {
-      const res = await service.dashboard([
-        {
-          dashboard: 'device',
-          object: 'message',
-          measurement: 'quantity',
-          dimension: 'agg',
-          group: 'device_msg',
-          params: {
-            time: '1d',
-            format: 'yyyy.MM.dd',
-            limit: Math.ceil((data.time.end - data.time.start) / (1 * 24 * 3600 * 1000) + 1),
-            // from: moment(data.time.start).format('yyyy-MM-DD HH:MM:SS'),
-            // to: moment(data.time.end).format('yyyy-MM-DD HH:MM:SS'),
-            from: data.time.start,
-            to: data.time.end,
-          },
+    let _time = '1h';
+    let format = 'HH';
+    let limit = 12;
+    const dt = data.time.end - data.time.start;
+    const hour = 60 * 60 * 1000;
+    const days = hour * 24;
+    const months = days * 30;
+    const year = 365 * days;
+    if (dt <= days) {
+      limit = Math.abs(Math.ceil(dt / hour));
+    } else if (dt > days && dt < year) {
+      limit = Math.abs(Math.ceil(dt / days)) + 1;
+      _time = '1d';
+      format = 'M月dd日';
+    } else if (dt >= year) {
+      limit = Math.abs(Math.floor(dt / months));
+      _time = '1M';
+      format = 'yyyy年-M月';
+    }
+    const res = await service.dashboard([
+      {
+        dashboard: 'device',
+        object: 'message',
+        measurement: 'quantity',
+        dimension: 'agg',
+        group: 'device_msg',
+        params: {
+          time: _time,
+          format: format,
+          limit: limit,
+          from: data.time.start,
+          to: data.time.end,
         },
-      ]);
-      if (res.status === 200) {
-        const x = res.result.map((item: any) => item.data.timeString).reverse();
-        const y = res.result.map((item: any) => item.data.value).reverse();
-        setOptions({
-          xAxis: {
-            type: 'category',
-            boundaryGap: false,
-            data: x,
-          },
-          yAxis: {
-            type: 'value',
-          },
-          tooltip: {
-            trigger: 'axis',
-            // axisPointer: {
-            //   type: 'shadow',
-            // },
-          },
-          grid: {
-            top: '2%',
-            bottom: '5%',
-            left: '50px',
-            right: '50px',
-          },
-          series: [
-            {
-              name: '消息量',
-              data: y,
-              type: 'line',
-              smooth: true,
-              color: '#685DEB',
-              areaStyle: {
-                color: {
-                  type: 'linear',
-                  x: 0,
-                  y: 0,
-                  x2: 0,
-                  y2: 1,
-                  colorStops: [
-                    {
-                      offset: 0,
-                      color: '#685DEB', // 100% 处的颜色
-                    },
-                    {
-                      offset: 1,
-                      color: '#FFFFFF', //   0% 处的颜色
-                    },
-                  ],
-                  global: false, // 缺省为 false
-                },
-              },
-            },
-          ],
-        });
-      }
-    } else {
-      const res = await service.dashboard([
-        {
-          dashboard: 'device',
-          object: 'message',
-          measurement: 'quantity',
-          dimension: 'agg',
-          group: 'device_msg',
-          params: {
-            time: '1h',
-            format: 'yyyy.MM.dd HH:MM:SS',
-            limit: 24,
-            from: data.time.start,
-            to: data.time.end,
-          },
+      },
+    ]);
+    if (res.status === 200) {
+      const x = res.result.map((item: any) => item.data.timeString).reverse();
+      const y = res.result.map((item: any) => item.data.value).reverse();
+      setOptions({
+        xAxis: {
+          type: 'category',
+          boundaryGap: false,
+          data: x,
         },
-      ]);
-      if (res.status === 200) {
-        const x = res.result.map((item: any) => item.data.timeString).reverse();
-        const y = res.result.map((item: any) => item.data.value).reverse();
-        setOptions({
-          xAxis: {
-            type: 'category',
-            boundaryGap: false,
-            data: x,
-          },
-          yAxis: {
-            type: 'value',
-          },
-          tooltip: {
-            trigger: 'axis',
-          },
-          grid: {
-            top: '2%',
-            bottom: '5%',
-            left: '2%',
-            right: '2%',
-          },
-          series: [
-            {
-              name: '消息量',
-              data: y,
-              type: 'line',
-              smooth: true,
-              color: '#685DEB',
-              areaStyle: {
-                color: {
-                  type: 'linear',
-                  x: 0,
-                  y: 0,
-                  x2: 0,
-                  y2: 1,
-                  colorStops: [
-                    {
-                      offset: 0,
-                      color: '#685DEB', // 100% 处的颜色
-                    },
-                    {
-                      offset: 1,
-                      color: '#FFFFFF', //   0% 处的颜色
-                    },
-                  ],
-                  global: false, // 缺省为 false
-                },
+        yAxis: {
+          type: 'value',
+        },
+        tooltip: {
+          trigger: 'axis',
+          // axisPointer: {
+          //   type: 'shadow',
+          // },
+        },
+        grid: {
+          top: '2%',
+          bottom: '5%',
+          left: '50px',
+          right: '50px',
+        },
+        series: [
+          {
+            name: '消息量',
+            data: y,
+            type: 'line',
+            smooth: true,
+            color: '#685DEB',
+            areaStyle: {
+              color: {
+                type: 'linear',
+                x: 0,
+                y: 0,
+                x2: 0,
+                y2: 1,
+                colorStops: [
+                  {
+                    offset: 0,
+                    color: '#685DEB', // 100% 处的颜色
+                  },
+                  {
+                    offset: 1,
+                    color: '#FFFFFF', //   0% 处的颜色
+                  },
+                ],
+                global: false, // 缺省为 false
               },
             },
-          ],
-        });
-      }
+          },
+        ],
+      });
     }
+    // if (data && data.time.type !== 'today') {
+    //   const res = await service.dashboard([
+    //     {
+    //       dashboard: 'device',
+    //       object: 'message',
+    //       measurement: 'quantity',
+    //       dimension: 'agg',
+    //       group: 'device_msg',
+    //       params: {
+    //         time: '1d',
+    //         format: 'yyyy.MM.dd',
+    //         limit: Math.ceil((data.time.end - data.time.start) / (1 * 24 * 3600 * 1000) + 1),
+    //         // from: moment(data.time.start).format('yyyy-MM-DD HH:MM:SS'),
+    //         // to: moment(data.time.end).format('yyyy-MM-DD HH:MM:SS'),
+    //         from: data.time.start,
+    //         to: data.time.end,
+    //       },
+    //     },
+    //   ]);
+    //   if (res.status === 200) {
+    //     const x = res.result.map((item: any) => item.data.timeString).reverse();
+    //     const y = res.result.map((item: any) => item.data.value).reverse();
+    //     setOptions({
+    //       xAxis: {
+    //         type: 'category',
+    //         boundaryGap: false,
+    //         data: x,
+    //       },
+    //       yAxis: {
+    //         type: 'value',
+    //       },
+    //       tooltip: {
+    //         trigger: 'axis',
+    //         // axisPointer: {
+    //         //   type: 'shadow',
+    //         // },
+    //       },
+    //       grid: {
+    //         top: '2%',
+    //         bottom: '5%',
+    //         left: '50px',
+    //         right: '50px',
+    //       },
+    //       series: [
+    //         {
+    //           name: '消息量',
+    //           data: y,
+    //           type: 'line',
+    //           smooth: true,
+    //           color: '#685DEB',
+    //           areaStyle: {
+    //             color: {
+    //               type: 'linear',
+    //               x: 0,
+    //               y: 0,
+    //               x2: 0,
+    //               y2: 1,
+    //               colorStops: [
+    //                 {
+    //                   offset: 0,
+    //                   color: '#685DEB', // 100% 处的颜色
+    //                 },
+    //                 {
+    //                   offset: 1,
+    //                   color: '#FFFFFF', //   0% 处的颜色
+    //                 },
+    //               ],
+    //               global: false, // 缺省为 false
+    //             },
+    //           },
+    //         },
+    //       ],
+    //     });
+    //   }
+    // } else {
+    //   const res = await service.dashboard([
+    //     {
+    //       dashboard: 'device',
+    //       object: 'message',
+    //       measurement: 'quantity',
+    //       dimension: 'agg',
+    //       group: 'device_msg',
+    //       params: {
+    //         time: '1h',
+    //         format: 'yyyy.MM.dd HH:MM:SS',
+    //         limit: 24,
+    //         from: data.time.start,
+    //         to: data.time.end,
+    //       },
+    //     },
+    //   ]);
+    //   if (res.status === 200) {
+    //     const x = res.result.map((item: any) => item.data.timeString).reverse();
+    //     const y = res.result.map((item: any) => item.data.value).reverse();
+    //     setOptions({
+    //       xAxis: {
+    //         type: 'category',
+    //         boundaryGap: false,
+    //         data: x,
+    //       },
+    //       yAxis: {
+    //         type: 'value',
+    //       },
+    //       tooltip: {
+    //         trigger: 'axis',
+    //       },
+    //       grid: {
+    //         top: '2%',
+    //         bottom: '5%',
+    //         left: '2%',
+    //         right: '2%',
+    //       },
+    //       series: [
+    //         {
+    //           name: '消息量',
+    //           data: y,
+    //           type: 'line',
+    //           smooth: true,
+    //           color: '#685DEB',
+    //           areaStyle: {
+    //             color: {
+    //               type: 'linear',
+    //               x: 0,
+    //               y: 0,
+    //               x2: 0,
+    //               y2: 1,
+    //               colorStops: [
+    //                 {
+    //                   offset: 0,
+    //                   color: '#685DEB', // 100% 处的颜色
+    //                 },
+    //                 {
+    //                   offset: 1,
+    //                   color: '#FFFFFF', //   0% 处的颜色
+    //                 },
+    //               ],
+    //               global: false, // 缺省为 false
+    //             },
+    //           },
+    //         },
+    //       ],
+    //     });
+    //   }
+    // }
   };
   //地图数据
   const geo = async (data?: any) => {

+ 1 - 0
src/pages/link/DashBoard/index.tsx

@@ -713,6 +713,7 @@ export default () => {
             timeToolOptions={timeToolOptions}
             height={400}
             closeInitialParams={true}
+            showTime
             showTimeTool={true}
             extraParams={{
               key: 'type',

+ 3 - 2
src/pages/link/Type/Detail/index.tsx

@@ -887,8 +887,9 @@ const Save = observer(() => {
             },
             'x-decorator-props': {
               gridSpan: 2,
-              tooltip:
-                '共享配置:集群下所有节点共用同一配置\r\n' + '独立配置:集群下不同节点使用不同配置',
+              tooltip: isNoCommunity
+                ? '共享配置:集群下所有节点共用同一配置\r\n' + '独立配置:集群下不同节点使用不同配置'
+                : '',
             },
           },
           configuration: {

+ 36 - 15
src/pages/media/DashBoard/index.tsx

@@ -68,21 +68,40 @@ export default () => {
     }
   };
 
-  const getInterval = (type: string) => {
-    switch (type) {
-      case 'year':
-        return '30d';
-      case 'month':
-      case 'week':
-        return '1d';
-      case 'hour':
-        return '1m';
-      default:
-        return '1h';
-    }
-  };
+  // const getInterval = (type: string) => {
+  //   switch (type) {
+  //     case 'year':
+  //       return '30d';
+  //     case 'month':
+  //     case 'week':
+  //       return '1d';
+  //     case 'hour':
+  //       return '1m';
+  //     default:
+  //       return '1h';
+  //   }
+  // };
 
   const getEcharts = async (params: any) => {
+    let _time = '1h';
+    let format = 'HH';
+    let limit = 12;
+    const dt = params.time.end - params.time.start;
+    const hour = 60 * 60 * 1000;
+    const day = hour * 24;
+    const month = day * 30;
+    const year = 365 * day;
+    if (dt <= day) {
+      limit = Math.abs(Math.ceil(dt / hour));
+    } else if (dt > day && dt < year) {
+      limit = Math.abs(Math.ceil(dt / day)) + 1;
+      _time = '1d';
+      format = 'M月dd日';
+    } else if (dt >= year) {
+      limit = Math.abs(Math.floor(dt / month));
+      _time = '1M';
+      format = 'yyyy年-M月';
+    }
     const resp = await service.getMulti([
       {
         dashboard: 'media_stream',
@@ -91,10 +110,11 @@ export default () => {
         dimension: 'agg',
         group: 'playCount',
         params: {
-          time: getInterval(params.time.type),
+          time: _time, // getInterval(params.time.type),
           from: moment(params.time.start).format('YYYY-MM-DD HH:mm:ss'),
           to: moment(params.time.end).format('YYYY-MM-DD HH:mm:ss'),
-          limit: 30,
+          limit: limit,
+          format: format,
         },
       },
     ]);
@@ -245,6 +265,7 @@ export default () => {
         </DashBoardTopCard>
         <DashBoard
           showTimeTool={true}
+          showTime
           className={'media-dash-board-body'}
           title={'播放数量(人次)'}
           options={options}

+ 115 - 30
src/pages/rule-engine/DashBoard/index.tsx

@@ -193,12 +193,31 @@ const Dashboard = observer(() => {
   }, []);
 
   const getEcharts = async (params: any) => {
+    // let time = '1h';
+    // let format = 'HH';
+    // if (params.time.type === 'week' || params.time.type === 'month') {
+    //   time = '1d';
+    //   format = 'M月dd日';
+    // } else if (params.time.type === 'year') {
+    //   time = '1M';
+    //   format = 'yyyy年-M月';
+    // }
     let time = '1h';
     let format = 'HH';
-    if (params.time.type === 'week' || params.time.type === 'month') {
+    let limit = 12;
+    const dt = params.time.end - params.time.start;
+    const hour = 60 * 60 * 1000;
+    const day = hour * 24;
+    const month = day * 30;
+    const year = 365 * day;
+    if (dt <= day) {
+      limit = Math.abs(Math.ceil(dt / hour));
+    } else if (dt > day && dt < year) {
+      limit = Math.abs(Math.ceil(dt / day)) + 1;
       time = '1d';
       format = 'M月dd日';
-    } else if (params.time.type === 'year') {
+    } else if (dt >= year) {
+      limit = Math.abs(Math.floor(dt / month));
       time = '1M';
       format = 'yyyy年-M月';
     }
@@ -216,7 +235,7 @@ const Dashboard = observer(() => {
         time: time,
         // from: 'now-1y', // now-1d、now-1w、now-1M、now-1y
         // to: 'now',
-        limit: 12,
+        limit: limit, // 12
         // time: params.time.type === 'today' ? '1h' : '1d',
         from: moment(params.time.start).format('YYYY-MM-DD HH:mm:ss'),
         to: moment(params.time.end).format('YYYY-MM-DD HH:mm:ss'),
@@ -262,47 +281,112 @@ const Dashboard = observer(() => {
           xData.push(item.data.timeString);
           sData.push(item.data.value);
         });
+      // setOptions({
+      //   tooltip: {
+      //     trigger: 'axis',
+      //     // axisPointer: {
+      //     //   type: 'shadow',
+      //     // },
+      //   },
+      //   grid: {
+      //     left: 0,
+      //     right: '1%',
+      //     bottom: 0,
+      //     top: '2%',
+      //     containLabel: true,
+      //   },
+      //   xAxis: [
+      //     {
+      //       type: 'category',
+      //       data: xData.reverse(),
+      //       axisTick: {
+      //         alignWithLabel: true,
+      //       },
+      //     },
+      //   ],
+      //   yAxis: [
+      //     {
+      //       type: 'value',
+      //     },
+      //   ],
+      //   color: ['#979AFF'],
+      //   series: [
+      //     {
+      //       name: tip,
+      //       type: 'line',
+      //       // barWidth: '30%',
+      //       // itemStyle: {
+      //       //   color: '#2F54EB',
+      //       // },
+      //       areaStyle: {
+      //         color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
+      //           {
+      //             offset: 1,
+      //             color: 'rgba(151, 154, 255, 0)'
+      //           },
+      //           {
+      //             offset: 0,
+      //             color: 'rgba(151, 154, 255, .24)'
+      //           }
+      //         ])
+      //       },
+      //       smooth: true,
+      //       data: sData.reverse(),
+      //     },
+      //   ],
+      // });
+
       setOptions({
+        xAxis: {
+          type: 'category',
+          boundaryGap: false,
+          data: xData.reverse(),
+        },
+        yAxis: {
+          type: 'value',
+        },
         tooltip: {
           trigger: 'axis',
-          axisPointer: {
-            type: 'shadow',
-          },
+          // axisPointer: {
+          //   type: 'shadow',
+          // },
         },
         grid: {
-          left: 0,
-          right: '1%',
-          bottom: 0,
           top: '2%',
-          containLabel: true,
+          bottom: '5%',
+          left: '50px',
+          right: '50px',
         },
-        xAxis: [
-          {
-            type: 'category',
-            data: xData.reverse(),
-            axisTick: {
-              alignWithLabel: true,
-            },
-          },
-        ],
-        yAxis: [
-          {
-            type: 'value',
-          },
-        ],
         series: [
           {
             name: tip,
-            type: 'bar',
-            barWidth: '30%',
-            itemStyle: {
-              color: '#2F54EB',
-            },
             data: sData.reverse(),
+            type: 'line',
+            smooth: true,
+            color: '#685DEB',
+            areaStyle: {
+              color: {
+                type: 'linear',
+                x: 0,
+                y: 0,
+                x2: 0,
+                y2: 1,
+                colorStops: [
+                  {
+                    offset: 0,
+                    color: '#685DEB', // 100% 处的颜色
+                  },
+                  {
+                    offset: 1,
+                    color: '#FFFFFF', //   0% 处的颜色
+                  },
+                ],
+                global: false, // 缺省为 false
+              },
+            },
           },
         ],
       });
-
       state.ranking = resp.result
         ?.filter((item: any) => item.group === 'alarmRank')
         .map((d: { data: { value: any } }) => d.data?.value)
@@ -401,6 +485,7 @@ const Dashboard = observer(() => {
           title="告警统计"
           height={600}
           showTimeTool={true}
+          showTime
           options={options}
           initialValues={{
             targetType: 'device',

+ 5 - 0
src/utils/menu/router.ts

@@ -198,6 +198,7 @@ export const CommunityCodeList = [
   'system/Menu/Detail',
   'system/Menu/Setting',
   'system/Permission',
+  'system/Relationship',
   'home',
   'rule-engine/DashBoard',
   'rule-engine/Alarm/Configuration',
@@ -219,4 +220,8 @@ export const CommunityCodeList = [
   'link/Certificate/Detail',
   'rule-engine/Scene',
   'rule-engine/Scene/Save',
+  'notice/Config',
+  'notice/Config/Detail',
+  'notice/Template',
+  'notice/Template/Detail',
 ];