123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225 |
- // 优化任务
- import PageContent from '@/components/PageContent';
- import PageTitle from '@/components/PageTitle';
- import {
- queryMandate,
- queryMandateChildList,
- querySimulationProfit,
- } from '@/services/SmartOps';
- import { UnityAction } from '@/utils/utils';
- import { useParams, useRequest } from '@umijs/max';
- import { Table } from 'antd';
- import dayjs from 'dayjs';
- import { useState } from 'react';
- import styles from './OptimizationTasks.less';
- const OptimizationTasks = (props) => {
- const { projectId } = useParams();
- const { data, run } = useRequest(queryMandate, {
- manual: true,
- });
- return (
- <PageContent closeable={false}>
- <PageTitle returnable>
- <div className={styles.navigateTitle}>
- <div>优化任务</div>
- </div>
- </PageTitle>
- <div className={styles.titleTime}>{dayjs().format('MM月DD日 HH:mm')}</div>
- <div className="content-title">
- <div>
- <Produce projectId={projectId} />
- <Cost projectId={projectId} />
- </div>
- </div>
- </PageContent>
- );
- };
- const Produce = ({ projectId }) => {
- const columns = [
- {
- title: '参数',
- dataIndex: 'Title',
- },
- {
- title: '调整内容',
- dataIndex: 'Content',
- },
- ];
- const [mandateID, setMandateID] = useState();
- const { data } = useRequest(queryMandateChildList, {
- defaultParams: [
- {
- projectId,
- mandateClass: 1,
- },
- ],
- onSuccess: (data) => {
- setMandateID(data[0].MandateId);
- },
- });
- const openDetail = () => {
- // send message to unity with mandate_id
- if (!mandateID) {
- return;
- }
- UnityAction.sendMsg('OpenTaskModal', `mandate_id=${mandateID}`);
- };
- return (
- <div className={styles.pageCard}>
- <h3 className={styles.title} style={{ justifyContent: 'space-between' }}>
- <div>
- <i />
- 生产调度类
- </div>
- {mandateID && (
- <div className={styles.btnBlue} onClick={openDetail}>
- 查看任务
- </div>
- )}
- </h3>
- {data?.length > 0 && (
- <>
- <div
- className={styles.content}
- style={{ backgroundColor: '#B1D2F3' }}
- >
- <h3 className={styles.left}>任务总结</h3>
- <div className={styles.desc}>
- 根据水质相关数据.建议您调节以下参数,水厂运行可达较优状态
- </div>
- </div>
- <div
- className={styles.content}
- style={{ backgroundColor: '#EDF5FC' }}
- >
- <h3 className={styles.left}>任务内容</h3>
- <Table
- className={styles.taskTable}
- style={{ width: '100%' }}
- columns={columns}
- dataSource={data}
- pagination={false}
- />
- </div>
- </>
- )}
- {!data?.length && (
- <div className={styles.content} style={{ backgroundColor: '#B1D2F3' }}>
- <div className={styles.desc}>
- 当前进水数据稳定,产水数据稳定,暂无调节任务,继续保持哦~
- </div>
- </div>
- )}
- </div>
- );
- };
- const Cost = ({ projectId }) => {
- const columns = [
- {
- title: '设备',
- dataIndex: 'Title',
- },
- {
- title: '调整内容',
- dataIndex: 'Content',
- },
- ];
- const [mandateID, setMandateID] = useState();
- const { data: profit } = useRequest(querySimulationProfit, {
- defaultParams: [
- {
- project_id: projectId,
- s_time: dayjs().subtract(1, 'day').format('YYYY-MM-DD'),
- e_time: dayjs().format('YYYY-MM-DD'),
- },
- ],
- formatResult(data) {
- if (!data?.info) return '-';
- return Object.values(data.info).reduce(
- (total, currentValue) => total + currentValue,
- 0,
- );
- },
- });
- const { data } = useRequest(queryMandateChildList, {
- defaultParams: [
- {
- projectId,
- mandateClass: 2,
- },
- ],
- onSuccess: (data) => {
- setMandateID(data[0].MandateId);
- },
- });
- const openDetail = () => {
- // send message to unity
- if (!mandateID) {
- return;
- }
- UnityAction.sendMsg('OpenTaskModal', `mandate_id=${mandateID}`);
- };
- return (
- <div className={styles.pageCard}>
- <h3 className={styles.title} style={{ justifyContent: 'space-between' }}>
- <div>
- <i style={{ background: '#F5A623' }} />
- 成本节约类
- </div>
- {mandateID && (
- <div className={styles.btnOrange} onClick={openDetail}>
- 查看任务
- </div>
- )}
- </h3>
- {data?.length > 0 && (
- <>
- <div
- className={styles.content}
- style={{ backgroundColor: '#FBDEAE' }}
- >
- <h3 className={styles.left}>任务总结</h3>
- <div className={styles.desc}>
- 通过能耗/药耗数据模拟仿真预计未来一日可节省
- <span>{profit || '-'}</span>元
- </div>
- </div>
- <div
- className={styles.content}
- style={{ backgroundColor: 'rgba(245,166,35,0.04);' }}
- >
- <h3 className={styles.left}>任务内容</h3>
- <Table
- className={styles.taskTable}
- columns={columns}
- dataSource={data}
- pagination={false}
- />
- </div>
- </>
- )}
- {!data?.length && (
- <div className={styles.content} style={{ backgroundColor: '#FBDEAE' }}>
- <h3 className={styles.left}>任务总结</h3>
- <div className={styles.desc}>暂无可降低成本,继续保持哦~</div>
- </div>
- )}
- </div>
- );
- };
- export default OptimizationTasks;
|