123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224 |
- // 优化任务
- import PageContent from '@/components/PageContent';
- import PageTitle from '@/components/PageTitle';
- import {
- queryMandate,
- queryMandateChildList,
- querySimulationProfit,
- queryUserList,
- } from '@/services/SmartOps';
- import { history, useLocation, useParams, useRequest } from '@umijs/max';
- import { Col, Row, Table } from 'antd';
- import dayjs from 'dayjs';
- import { useMemo } from 'react';
- import styles from './OptimizationTasks.less';
- const OptimizationTasks = (props) => {
- const { projectId } = useParams();
- const { score } = useLocation();
- const { data, run } = useRequest(queryMandate, {
- manual: true,
- });
- const { data: userList } = useRequest(queryUserList, {
- defaultParams: [{ projectId }],
- });
- const ResponsiblePeople = useMemo(() => {
- if (!data || !userList) return '-';
- let user = userList.find((item) => item.ID == data.ResponsiblePeople);
- return user?.CName || '-';
- }, [data, userList]);
- const status = { 0: '未处理', 2: '已完成', 4: '已忽略', 5: '已派遣' };
- return (
- <PageContent closeable={false}>
- <PageTitle returnable>优化任务</PageTitle>
- <div className={styles.pageCard}>
- <div style={{ padding: 20 }}>
- <Produce
- projectId={projectId}
- score={score}
- queryMandate={run}
- mandate={data}
- />
- <Cost projectId={projectId} />
- </div>
- {data && (
- <div className={styles.bottom}>
- <Row gutter={16}>
- <Col span={8}>
- <div className={styles.bottomText}>任务类型:系统发送</div>
- </Col>
- <Col span={8}>
- <div className={styles.bottomText}>
- 任务负责人:{ResponsiblePeople}
- </div>
- </Col>
- <Col span={8}>
- <div className={styles.bottomText}>
- 任务状态:{status[data?.Status]}
- </div>
- </Col>
- </Row>
- </div>
- )}
- </div>
- </PageContent>
- );
- };
- const Produce = ({ projectId, queryMandate }) => {
- const columns = [
- {
- title: '参数',
- dataIndex: 'Title',
- },
- {
- title: '调整内容',
- dataIndex: 'Content',
- },
- ];
- const { data } = useRequest(queryMandateChildList, {
- defaultParams: [
- {
- projectId,
- mandateClass: 1,
- },
- ],
- onSuccess(data) {
- if (data.length > 0) {
- queryMandate({
- mandate_id: data[0]?.MandateId,
- });
- }
- },
- });
- return (
- <div style={{ marginBottom: 20 }}>
- <h3 className={styles.title}>
- <i />
- 生产调度类
- </h3>
- {data?.length > 0 && (
- <>
- <div className={styles.orderIcon}>任务已发送</div>
- <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
- style={{ width: '100%' }}
- columns={columns}
- dataSource={data}
- />
- </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 { 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,
- },
- ],
- });
- return (
- <div>
- <h3 className={styles.title}>
- <i style={{ background: '#F5A623' }} />
- 成本节约类
- <div
- className={styles.btn}
- onClick={() => history.push(`/smart/simulate/${projectId}`)}
- >
- 模拟评估
- </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="table2" columns={columns} dataSource={data} />
- </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;
|