OptimizationTasks.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. // 优化任务
  2. import PageContent from '@/components/PageContent';
  3. import PageTitle from '@/components/PageTitle';
  4. import {
  5. queryMandate,
  6. queryMandateChildList,
  7. querySimulationProfit,
  8. queryUserList,
  9. } from '@/services/SmartOps';
  10. import { history, useLocation, useParams, useRequest } from '@umijs/max';
  11. import { Col, Row, Table } from 'antd';
  12. import dayjs from 'dayjs';
  13. import { useMemo } from 'react';
  14. import styles from './OptimizationTasks.less';
  15. const OptimizationTasks = (props) => {
  16. const { projectId } = useParams();
  17. const { score } = useLocation();
  18. const { data, run } = useRequest(queryMandate, {
  19. manual: true,
  20. });
  21. const { data: userList } = useRequest(queryUserList, {
  22. defaultParams: [{ projectId }],
  23. });
  24. const ResponsiblePeople = useMemo(() => {
  25. if (!data || !userList) return '-';
  26. let user = userList.find((item) => item.ID == data.ResponsiblePeople);
  27. return user?.CName || '-';
  28. }, [data, userList]);
  29. const status = { 0: '未处理', 2: '已完成', 4: '已忽略', 5: '已派遣' };
  30. return (
  31. <PageContent closeable={false}>
  32. <PageTitle returnable>优化任务</PageTitle>
  33. <div className={styles.pageCard}>
  34. <div style={{ padding: 20 }}>
  35. <Produce
  36. projectId={projectId}
  37. score={score}
  38. queryMandate={run}
  39. mandate={data}
  40. />
  41. <Cost projectId={projectId} />
  42. </div>
  43. {data && (
  44. <div className={styles.bottom}>
  45. <Row gutter={16}>
  46. <Col span={8}>
  47. <div className={styles.bottomText}>任务类型:系统发送</div>
  48. </Col>
  49. <Col span={8}>
  50. <div className={styles.bottomText}>
  51. 任务负责人:{ResponsiblePeople}
  52. </div>
  53. </Col>
  54. <Col span={8}>
  55. <div className={styles.bottomText}>
  56. 任务状态:{status[data?.Status]}
  57. </div>
  58. </Col>
  59. </Row>
  60. </div>
  61. )}
  62. </div>
  63. </PageContent>
  64. );
  65. };
  66. const Produce = ({ projectId, queryMandate }) => {
  67. const columns = [
  68. {
  69. title: '参数',
  70. dataIndex: 'Title',
  71. },
  72. {
  73. title: '调整内容',
  74. dataIndex: 'Content',
  75. },
  76. ];
  77. const { data } = useRequest(queryMandateChildList, {
  78. defaultParams: [
  79. {
  80. projectId,
  81. mandateClass: 1,
  82. },
  83. ],
  84. onSuccess(data) {
  85. if (data.length > 0) {
  86. queryMandate({
  87. mandate_id: data[0]?.MandateId,
  88. });
  89. }
  90. },
  91. });
  92. return (
  93. <div style={{ marginBottom: 20 }}>
  94. <h3 className={styles.title}>
  95. <i />
  96. 生产调度类
  97. </h3>
  98. {data?.length > 0 && (
  99. <>
  100. <div className={styles.orderIcon}>任务已发送</div>
  101. <div
  102. className={styles.content}
  103. style={{ backgroundColor: '#B1D2F3' }}
  104. >
  105. <h3 className={styles.left}>任务总结</h3>
  106. <div className={styles.desc}>
  107. 根据水质相关数艍.建议您调节以下参数,水厂运行可达较优状态
  108. </div>
  109. </div>
  110. <div
  111. className={styles.content}
  112. style={{ backgroundColor: '#EDF5FC' }}
  113. >
  114. <h3 className={styles.left}>任务内容</h3>
  115. <Table
  116. style={{ width: '100%' }}
  117. columns={columns}
  118. dataSource={data}
  119. />
  120. </div>
  121. </>
  122. )}
  123. {!data?.length && (
  124. <div className={styles.content} style={{ backgroundColor: '#B1D2F3' }}>
  125. <div className={styles.desc}>
  126. 当前进水数据稳定,产水数据稳定,暂无需调节任务,继续保持哦~
  127. </div>
  128. </div>
  129. )}
  130. </div>
  131. );
  132. };
  133. const Cost = ({ projectId }) => {
  134. const columns = [
  135. {
  136. title: '设备',
  137. dataIndex: 'Title',
  138. },
  139. {
  140. title: '调整内容',
  141. dataIndex: 'Content',
  142. },
  143. ];
  144. const { data: profit } = useRequest(querySimulationProfit, {
  145. defaultParams: [
  146. {
  147. project_id: projectId,
  148. s_time: dayjs().subtract(1, 'day').format('YYYY-MM-DD'),
  149. e_time: dayjs().format('YYYY-MM-DD'),
  150. },
  151. ],
  152. formatResult(data) {
  153. if (!data?.info) return '-';
  154. return Object.values(data.info).reduce(
  155. (total, currentValue) => total + currentValue,
  156. 0,
  157. );
  158. },
  159. });
  160. const { data } = useRequest(queryMandateChildList, {
  161. defaultParams: [
  162. {
  163. projectId,
  164. mandateClass: 2,
  165. },
  166. ],
  167. });
  168. return (
  169. <div>
  170. <h3 className={styles.title}>
  171. <i style={{ background: '#F5A623' }} />
  172. 成本节约类
  173. <div
  174. className={styles.btn}
  175. onClick={() => history.push(`/smart/simulate/${projectId}`)}
  176. >
  177. 模拟评估
  178. </div>
  179. </h3>
  180. {data?.length > 0 && (
  181. <>
  182. <div
  183. className={styles.content}
  184. style={{ backgroundColor: '#FBDEAE' }}
  185. >
  186. <h3 className={styles.left}>任务总结</h3>
  187. <div className={styles.desc}>
  188. 通过能耗/药耗数据模拟仿真预计未来一日可节省
  189. <span>{profit || '-'}</span>元
  190. </div>
  191. </div>
  192. <div
  193. className={styles.content}
  194. style={{ backgroundColor: 'rgba(245,166,35,0.04);' }}
  195. >
  196. <h3 className={styles.left}>任务内容</h3>
  197. <Table className="table2" columns={columns} dataSource={data} />
  198. </div>
  199. </>
  200. )}
  201. {!data?.length && (
  202. <div className={styles.content} style={{ backgroundColor: '#FBDEAE' }}>
  203. <h3 className={styles.left}>任务总结</h3>
  204. <div className={styles.desc}>暂无可降低成本,继续保持哦~</div>
  205. </div>
  206. )}
  207. </div>
  208. );
  209. };
  210. export default OptimizationTasks;