index.tsx 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  1. import { PermissionButton } from '@/components';
  2. import useHistory from '@/hooks/route/useHistory';
  3. import { getMenuPathByCode, MENUS_CODE } from '@/utils/menu';
  4. import { Col, message, Row, Tooltip } from 'antd';
  5. import Body from '../components/Body';
  6. import BaseStatistics from '../components/BaseStatistics';
  7. import Steps from '../components/Steps';
  8. import { service } from '..';
  9. import { useEffect, useState } from 'react';
  10. import Statistics from '../components/Statistics';
  11. import { QuestionCircleOutlined } from '@ant-design/icons';
  12. import ProductChoose from '../components/ProductChoose';
  13. import DeviceChoose from '../components/DeviceChoose';
  14. import GuideHome from '../components/GuideHome';
  15. const Comprehensive = () => {
  16. const productPermission = PermissionButton.usePermission('device/Product').permission;
  17. const devicePermission = PermissionButton.usePermission('device/Instance').permission;
  18. const rulePermission = PermissionButton.usePermission('rule-engine/Instance').permission;
  19. const accessPermission = getMenuPathByCode(MENUS_CODE['link/AccessConfig']);
  20. const logPermission = getMenuPathByCode(MENUS_CODE['Log']);
  21. const linkPermission = getMenuPathByCode(MENUS_CODE['link/DashBoard']);
  22. const [productCount, setProductCount] = useState<number>(0);
  23. const [productMessage, setProductMessage] = useState<string>();
  24. const [deviceCount, setDeviceCount] = useState<number>(0);
  25. const [deviceMessage, setDeviceMessage] = useState<string>();
  26. const [productVisible, setProductVisible] = useState<boolean>(false);
  27. const [deviceVisible, setDeviceVisible] = useState<boolean>(false);
  28. // const [StatisticsList] = useState([
  29. // {
  30. // name: 'CPU使用率',
  31. // value: String(cpuValue) + '%',
  32. // children: <Pie value={cpuValue} />,
  33. // },
  34. // {
  35. // name: 'JVM内存',
  36. // value: String(jvmValue) + '%',
  37. // children: <Pie value={jvmValue} />,
  38. // },
  39. // ]);
  40. const getProductCount = async () => {
  41. const resp = await service.productCount({});
  42. if (resp.status === 200) {
  43. setProductCount(resp.result);
  44. }
  45. if (resp.status === 403) {
  46. setProductMessage('暂无权限');
  47. }
  48. };
  49. const getDeviceCount = async () => {
  50. const resp = await service.deviceCount();
  51. if (resp.status === 200) {
  52. setDeviceCount(resp.result);
  53. }
  54. if (resp.status === 403) {
  55. setDeviceMessage('暂无权限');
  56. }
  57. };
  58. useEffect(() => {
  59. getProductCount();
  60. getDeviceCount();
  61. }, []);
  62. const history = useHistory();
  63. // // 跳转
  64. const guideList = [
  65. {
  66. key: 'product',
  67. name: '创建产品',
  68. img: require('/public/images/home/guide-home1.png'),
  69. english: 'CREATE PRODUCT',
  70. auth: !!productPermission.add,
  71. url: getMenuPathByCode('device/Product'),
  72. param: {
  73. save: true,
  74. },
  75. },
  76. {
  77. key: 'device',
  78. name: '创建设备',
  79. english: 'CREATE DEVICE',
  80. img: require('/public/images/home/guide-home2.png'),
  81. auth: !!devicePermission.add,
  82. url: getMenuPathByCode('device/Instance'),
  83. param: {
  84. save: true,
  85. },
  86. },
  87. {
  88. key: 'rule-engine',
  89. name: '规则引擎',
  90. english: 'RULE ENGINE',
  91. img: require('/public/images/home/guide-home3.png'),
  92. auth: !!rulePermission.add,
  93. url: getMenuPathByCode('rule-engine/Instance'),
  94. param: {
  95. save: true,
  96. },
  97. },
  98. ];
  99. const guideOpsList = [
  100. {
  101. key: 'access',
  102. name: '设备接入配置',
  103. img: require('/public/images/home/guide-home4.png'),
  104. english: 'DEVICE ACCESS CONFIGURATION',
  105. auth: !!accessPermission,
  106. url: accessPermission,
  107. },
  108. {
  109. key: 'logger',
  110. name: '日志排查',
  111. english: 'LOG SCREEN',
  112. img: require('/public/images/home/guide-home5.png'),
  113. auth: !!logPermission,
  114. url: logPermission,
  115. param: {
  116. key: 'system',
  117. },
  118. },
  119. {
  120. key: 'realtime',
  121. name: '实时监控',
  122. img: require('/public/images/home/guide-home6.png'),
  123. english: 'REAL-TIME MONITORING',
  124. auth: !!linkPermission,
  125. url: linkPermission,
  126. param: {
  127. save: true,
  128. },
  129. },
  130. ];
  131. return (
  132. <Row gutter={24}>
  133. <Col span={6}>
  134. <GuideHome title="物联网引导" data={guideList} />
  135. <GuideHome title="运维引导" data={guideOpsList} />
  136. </Col>
  137. <Col span={18}>
  138. <Row gutter={24}>
  139. <Col span={12}>
  140. <Statistics
  141. data={[
  142. {
  143. name: '产品数量',
  144. value: productCount,
  145. children: require('/public/images/home/top-2.svg'),
  146. permission: productMessage,
  147. },
  148. {
  149. name: '设备数量',
  150. value: deviceCount,
  151. children: require('/public/images/home/top-1.svg'),
  152. permission: deviceMessage,
  153. },
  154. ]}
  155. title="设备统计"
  156. extra={
  157. <div style={{ fontSize: 14, fontWeight: 400 }}>
  158. <a
  159. onClick={() => {
  160. const url = getMenuPathByCode(MENUS_CODE['device/DashBoard']);
  161. if (!!url) {
  162. history.push(`${url}`);
  163. } else {
  164. message.warning('暂无权限,请联系管理员');
  165. }
  166. }}
  167. >
  168. 详情
  169. </a>
  170. </div>
  171. }
  172. />
  173. </Col>
  174. <Col span={12}>
  175. <BaseStatistics />
  176. </Col>
  177. </Row>
  178. <Row gutter={24}>
  179. <Col span={24} style={{ marginTop: 24 }}>
  180. <Body
  181. title={'平台架构图'}
  182. english={'PLATFORM ARCHITECTURE DIAGRAM'}
  183. url={require('/public/images/home/content1.png')}
  184. />
  185. </Col>
  186. </Row>
  187. </Col>
  188. <Col span={24}>
  189. <Steps
  190. title={
  191. <span>
  192. 设备接入推荐步骤
  193. <Tooltip title={'不同的设备因为通信协议的不同,存在接入步骤的差异'}>
  194. <QuestionCircleOutlined style={{ paddingLeft: 12 }} />
  195. </Tooltip>
  196. </span>
  197. }
  198. data={[
  199. {
  200. title: '创建产品',
  201. url: require('/public/images/home/bottom-4.png'),
  202. content:
  203. '产品是设备的集合,通常指一组具有相同功能的设备。物联设备必须通过产品进行接入方式配置。',
  204. onClick: () => {
  205. const path = getMenuPathByCode('device/Product');
  206. if (path && !!productPermission.add) {
  207. history.push(`${path}`, {
  208. save: true,
  209. });
  210. } else {
  211. message.warning('暂无权限,请联系管理员');
  212. }
  213. },
  214. },
  215. {
  216. title: '配置产品接入方式',
  217. url: require('/public/images/home/bottom-1.png'),
  218. content:
  219. '通过产品对同一类型的设备进行统一的接入方式配置。请参照设备铭牌说明选择匹配的接入方式。',
  220. onClick: () => {
  221. if (!!productPermission.update) {
  222. setProductVisible(true);
  223. } else {
  224. message.warning('暂无权限,请联系管理员');
  225. }
  226. },
  227. },
  228. {
  229. title: '添加测试设备',
  230. url: require('/public/images/home/bottom-5.png'),
  231. content: '添加单个设备,用于验证产品模型是否配置正确。',
  232. onClick: () => {
  233. const path = getMenuPathByCode('device/Instance');
  234. if (path && !!devicePermission.add) {
  235. history.push(`${path}`, {
  236. save: true,
  237. });
  238. } else {
  239. message.warning('暂无权限,请联系管理员');
  240. }
  241. },
  242. },
  243. {
  244. title: '功能调试',
  245. url: require('/public/images/home/bottom-2.png'),
  246. content: '对添加的测试设备进行功能调试,验证能否连接到平台,设备功能是否配置正确。',
  247. onClick: () => {
  248. if (!!devicePermission.update) {
  249. setDeviceVisible(true);
  250. } else {
  251. message.warning('暂无权限,请联系管理员');
  252. }
  253. },
  254. },
  255. {
  256. title: '批量添加设备',
  257. url: require('/public/images/home/bottom-3.png'),
  258. content: '批量添加同一产品下的设备',
  259. onClick: () => {
  260. const path = getMenuPathByCode('device/Instance');
  261. if (path && !!devicePermission.import) {
  262. history.push(`${path}`, {
  263. import: true,
  264. });
  265. } else {
  266. message.warning('暂无权限,请联系管理员');
  267. }
  268. },
  269. },
  270. ]}
  271. />
  272. </Col>
  273. <Col span={24} style={{ marginTop: 24 }}>
  274. <Steps
  275. title={
  276. <span>
  277. 运维管理推荐步骤
  278. <Tooltip title="请根据业务需要对下述步骤进行选择性操作。">
  279. <QuestionCircleOutlined style={{ paddingLeft: 12 }} />
  280. </Tooltip>
  281. </span>
  282. }
  283. data={[
  284. {
  285. title: '协议管理',
  286. url: require('/public/images/home/bottom-9.png'),
  287. content: '根据业务需求自定义开发对应的产品(设备模型)接入协议,并上传到平台。',
  288. onClick: () => {
  289. const url = getMenuPathByCode(MENUS_CODE['link/Protocol']);
  290. if (!!url) {
  291. history.push(url);
  292. } else {
  293. message.warning('暂无权限,请联系管理员');
  294. }
  295. },
  296. },
  297. {
  298. title: '证书管理',
  299. url: require('/public/images/home/bottom-9.png'),
  300. content: '统一维护平台内的证书,用于数据通信加密。',
  301. onClick: () => {
  302. const url = getMenuPathByCode(MENUS_CODE['link/Certificate']);
  303. if (!!url) {
  304. history.push(url);
  305. } else {
  306. message.warning('暂无权限,请联系管理员');
  307. }
  308. },
  309. },
  310. {
  311. title: '网络组件',
  312. content: '根据不同的传输类型配置平台底层网络组件相关参数。',
  313. url: require('/public/images/home/bottom-10.png'),
  314. onClick: () => {
  315. const url = getMenuPathByCode(MENUS_CODE['link/Type']);
  316. if (!!url) {
  317. history.push(url);
  318. } else {
  319. message.warning('暂无权限,请联系管理员');
  320. }
  321. },
  322. },
  323. {
  324. title: '设备接入网关',
  325. content: '根据不同的传输类型,关联消息协议,配置设备接入网关相关参数。',
  326. url: require('/public/images/home/bottom-11.png'),
  327. onClick: () => {
  328. const url = getMenuPathByCode(MENUS_CODE['link/AccessConfig']);
  329. if (!!url) {
  330. history.push(url);
  331. } else {
  332. message.warning('暂无权限,请联系管理员');
  333. }
  334. },
  335. },
  336. {
  337. title: '日志管理',
  338. content: '监控系统日志,及时处理系统异常。',
  339. url: require('/public/images/home/bottom-9.png'),
  340. onClick: () => {
  341. const url = getMenuPathByCode(MENUS_CODE['Log']);
  342. if (!!url) {
  343. history.push(url, {
  344. key: 'system',
  345. });
  346. } else {
  347. message.warning('暂无权限,请联系管理员');
  348. }
  349. },
  350. },
  351. ]}
  352. />
  353. </Col>
  354. <ProductChoose
  355. visible={productVisible}
  356. close={() => {
  357. setProductVisible(false);
  358. }}
  359. />
  360. <DeviceChoose
  361. visible={deviceVisible}
  362. onCancel={() => {
  363. setDeviceVisible(false);
  364. }}
  365. />
  366. </Row>
  367. );
  368. };
  369. export default Comprehensive;