index.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. import { getComparisonData } from '@/services/OperationManagement';
  2. import { queryConditionSnapshot } from '@/services/SmartOps';
  3. import { getToken, UnityAction } from '@/utils/utils';
  4. import { LoadingOutlined } from '@ant-design/icons';
  5. import { connect, useParams, useRequest } from '@umijs/max';
  6. import dayjs from 'dayjs';
  7. import { useEffect } from 'react';
  8. import CircleScore from '../Smart/components/CircleScore';
  9. import styles from './index.less';
  10. const HomePage = (props) => {
  11. const { projectId } = useParams();
  12. const { data } = useRequest(queryConditionSnapshot, {
  13. defaultParams: [{ project_id: projectId }],
  14. });
  15. return (
  16. <div className={styles.content}>
  17. <LeftContent data={data} />
  18. <CenterContent />
  19. <RightContent data={data} />
  20. </div>
  21. );
  22. };
  23. const LeftContent = (props) => {
  24. const { data } = props;
  25. return (
  26. <div className={styles.left}>
  27. <SmartWork data={data} />
  28. <WaterAmt data={data} />
  29. <WaterQuality data={data} />
  30. </div>
  31. );
  32. };
  33. const CenterContent = () => {
  34. return (
  35. <div className={styles.centerBox}>
  36. <Scada />
  37. </div>
  38. );
  39. };
  40. const RightContent = (props) => {
  41. const { data } = props;
  42. return (
  43. <div className={styles.right}>
  44. <SelfInspection />
  45. <Electric data={data} />
  46. <Medicine />
  47. </div>
  48. );
  49. };
  50. // 水厂工况
  51. const SmartWork = (props) => {
  52. const { data } = props;
  53. return (
  54. <Box
  55. title="水厂工况"
  56. onClick={() => UnityAction.sendMsg('menuItem', '工况管理')}
  57. >
  58. <div className={styles.scoreBox}>
  59. <CircleScore>
  60. {data?.score}
  61. <div className={styles.grade}>{data?.grade}</div>
  62. </CircleScore>
  63. <div className={styles.scoreTitle}>
  64. 当前运行{data?.grade},可继续优化
  65. </div>
  66. <div className={styles.time}>
  67. {dayjs(data?.clac_time).format('YYYY-MM-DD HH:mm')}
  68. </div>
  69. </div>
  70. </Box>
  71. );
  72. };
  73. // 水量监测
  74. const WaterAmt = (props) => {
  75. const { data } = props;
  76. const { projectId } = useParams();
  77. return (
  78. <Box
  79. title="水量监测"
  80. onClick={() => UnityAction.sendMsg('menuItem', '水量监测')}
  81. >
  82. <ul>
  83. <li>
  84. <div className={styles.value}>{data?.fwa}</div>
  85. <div className={styles.name}>进水量</div>
  86. </li>
  87. <li>
  88. <div className={styles.value}>{data?.dwa}</div>
  89. <div className={styles.name}>产水量</div>
  90. </li>
  91. </ul>
  92. </Box>
  93. );
  94. };
  95. // 水质监测
  96. const WaterQuality = (props) => {
  97. const { data } = props;
  98. const { projectId } = useParams();
  99. return (
  100. <Box
  101. title="水质监测"
  102. onClick={() => UnityAction.sendMsg('menuItem', '水质监测')}
  103. >
  104. <ul>
  105. <li>
  106. <div className={styles.value}>{data?.dsan}</div>
  107. <div className={styles.name}>出水余氯</div>
  108. </li>
  109. <li>
  110. <div className={styles.value}>{data?.dtur}</div>
  111. <div className={styles.name}>出水浊度</div>
  112. </li>
  113. </ul>
  114. </Box>
  115. );
  116. };
  117. // 系统自检
  118. const SelfInspection = connect(({ eqSelfInspection, loading }) => ({
  119. autoReport: eqSelfInspection.autoReport,
  120. loading: loading.models['eqSelfInspection'],
  121. }))((props) => {
  122. const { autoReport, dispatch, loading } = props;
  123. const { projectId } = useParams();
  124. const renderStatus = () => {
  125. if (loading) return <LoadingOutlined />;
  126. if (autoReport.Status > 0) {
  127. return <span style={{ color: '#FE5850' }}>异常</span>;
  128. }
  129. return <span style={{ color: '#F5A623' }}>正常</span>;
  130. };
  131. useEffect(() => {
  132. dispatch({
  133. type: 'eqSelfInspection/getAutoPatrol',
  134. payload: {
  135. projectId,
  136. },
  137. });
  138. }, []);
  139. return (
  140. <Box
  141. title="系统自检"
  142. onClick={() => UnityAction.sendMsg('menuItem', '系统自检')}
  143. >
  144. <div className={styles.insTag}>自检中</div>
  145. <div className={styles.insStatus}>{renderStatus()}</div>
  146. <div className={styles.time} style={{ marginBottom: 30 }}>
  147. {dayjs(autoReport.CreatedTime).format('YYYY-MM-DD HH:mm')}
  148. </div>
  149. </Box>
  150. );
  151. });
  152. // 能耗监测
  153. const Electric = (props) => {
  154. const { data } = props;
  155. const { projectId } = useParams();
  156. return (
  157. <Box
  158. title="能耗监测"
  159. onClick={() => UnityAction.sendMsg('menuItem', '能耗监测')}
  160. >
  161. <ul>
  162. <li>
  163. <div className={styles.value}>{data?.elec}</div>
  164. <div className={styles.name}>用电量</div>
  165. </li>
  166. </ul>
  167. </Box>
  168. );
  169. };
  170. // 药耗监测
  171. const Medicine = () => {
  172. const { projectId } = useParams();
  173. const time = dayjs().format('YYYY-MM');
  174. const { data } = useRequest(getComparisonData, {
  175. defaultParams: [
  176. {
  177. project_id: projectId,
  178. start: time,
  179. end: time,
  180. type: 1,
  181. flag: 1,
  182. },
  183. ],
  184. formatResult(res) {
  185. return res[0];
  186. },
  187. });
  188. return (
  189. <Box
  190. title="药耗监测"
  191. onClick={() => UnityAction.sendMsg('menuItem', '药耗监测')}
  192. >
  193. <ul>
  194. <li>
  195. <div className={styles.value}>{data?.value?.toFixed(2) || '-'}元</div>
  196. <div className={styles.name}>当月吨水药成本</div>
  197. </li>
  198. </ul>
  199. </Box>
  200. );
  201. };
  202. // 工艺监控
  203. const Scada = () => {
  204. const { projectId } = useParams();
  205. const token = getToken();
  206. let domain =
  207. process.env.NODE_ENV === 'production'
  208. ? 'http://120.55.44.4:8900/'
  209. : 'http://47.96.12.136:8788/';
  210. const src = `${domain}smart-water/scada/index.html#/3dview/${projectId}/267?JWT-TOKEN=${token}&hideTitle=true`;
  211. return (
  212. <Box
  213. title="工艺监控"
  214. onClick={() => UnityAction.sendMsg('menuItem', '工艺监控')}
  215. >
  216. <div className={styles.scadaContent}>
  217. <iframe
  218. style={{
  219. width: '100%',
  220. height: '100%',
  221. border: 'none',
  222. pointerEvents: 'none',
  223. }}
  224. src={src}
  225. />
  226. </div>
  227. </Box>
  228. );
  229. };
  230. const Box = ({ title, children, onClick }) => {
  231. return (
  232. <div className={styles.box} onClick={onClick}>
  233. <div className={styles.boxTitle}>{title}</div>
  234. {children}
  235. </div>
  236. );
  237. };
  238. export default HomePage;