Junjie
2024-07-25 d429ad29975fa99ff3c4b7b7df9309e677a8c77d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
import React, { useState, useRef, useEffect } from 'react';
import { Card, Form, Input, Row, Switch, Slider, message, Drawer, Space, Button, InputNumber, Select } from 'antd';
import { FormattedMessage, useIntl, useModel } from '@umijs/max';
import { createStyles } from 'antd-style';
import Http from '@/utils/http';
import { log } from 'three/examples/jsm/nodes/Nodes.js';
 
const useStyles = createStyles(({ token, css }) => {
 
})
 
const ShuttleHandle = (props) => {
    const intl = useIntl();
    const { styles } = useStyles();
 
    const { shuttleNo } = props;
 
    const [sourceLoc, setSourceLoc] = useState(null);
    const [targetLoc, setTargetLoc] = useState(null);
    const [xStart, setXStart] = useState(null);
    const [xTarget, setXTarget] = useState(null);
    const [yStart, setYStart] = useState(null);
    const [yTarget, setYTarget] = useState(null);
    const [moveLocType, setMoveLocType] = useState(1);
 
    useEffect(() => {
 
    }, []);
 
    const handleCancel = () => {
        props.onClose();
    }
 
    const shuttleOperator = async (type) => {
        if (type == 'moveLoc') {
            if (!targetLoc) {
                message.warning('请输入目标位置');
                return;
            }
        }
        if (type == 'takeMove') {
            if (!sourceLoc) {
                message.warning('请输入起始位置');
                return;
            }
            if (!targetLoc) {
                message.warning('请输入目标位置');
                return;
            }
        }
 
        try {
            const resp = await Http.doPost('api/basShuttle/operator/shuttle', {
                shuttleNo: shuttleNo,
                shuttleTaskMode: type,
                sourceLocNo: sourceLoc,
                targetLocNo: targetLoc,
            });
            if (resp.code === 200) {
                message.success("请求成功");
                return true;
            } else {
                message.warning(resp.msg);
                return false;
            }
        } catch (error) {
            message.warning("请求失败");
            return false;
        }
    }
 
    const shuttleMoveLoc = async () => {
        if (!xStart || !xTarget || !yStart || !yTarget) {
            message.warning('请输入参数');
            return;
        }
 
        try {
            const resp = await Http.doPost('api/basShuttle/moveLoc', {
                shuttleNo: shuttleNo,
                moveType: moveLocType,
                startX: xStart,
                targetX: xTarget,
                startY: yStart,
                targetY: yTarget,
            });
            if (resp.code === 200) {
                message.success("请求成功");
                return true;
            } else {
                message.warning(resp.msg);
                return false;
            }
        } catch (error) {
            message.warning("请求失败");
            return false;
        }
    }
 
    const shuttleMoveLocClose = async () => {
        try {
            const resp = await Http.doPost('api/basShuttle/moveLocClose', {
                shuttleNo: currentData.shuttleNo,
            });
            if (resp.code === 200) {
                message.success("请求成功");
                return true;
            } else {
                message.warning(resp.msg);
                return false;
            }
        } catch (error) {
            message.warning("请求失败");
            return false;
        }
    }
 
    return (
        <>
            <Drawer
                title={intl.formatMessage({ id: 'map.command', defaultMessage: '命令' })}
                width={420}
                closable={false}
                open={props.open}
                getContainer={props.refCurr}
                rootStyle={{ position: "absolute" }}
                onClose={handleCancel}
                extra={
                    <Space>
                        <Button onClick={handleCancel}>
                            <FormattedMessage id='common.cancel' defaultMessage='取消' />
                        </Button>
                    </Space>
                }
            >
 
                <h2 style={{ marginBottom: '15px' }}>{shuttleNo}号四向车</h2>
                <div style={{ marginBottom: '15px' }}>
                    <Card title="移动指令">
                        <p>
                            <Input addonBefore="起始位置" value={sourceLoc} onChange={e => setSourceLoc(e.target.value)} />
                        </p>
                        <p>
                            <Input addonBefore="目标位置" value={targetLoc} onChange={e => setTargetLoc(e.target.value)} />
                        </p>
                        <p>
                            <Button onClick={() => shuttleOperator('moveLoc')}>移动到目标位置</Button>
                            <Button onClick={() => shuttleOperator('takeMove')} style={{ marginLeft: '30px' }}>取放货作业</Button>
                        </p>
                    </Card>
                </div>
 
                <div style={{ marginBottom: '15px' }}>
                    <Card title="相关指令" >
                        <div className="commandItem">
                            <Button onClick={() => shuttleOperator('palletLift')}>托盘顶升</Button>
                            <Button onClick={() => shuttleOperator('palletDown')}>托盘下降</Button>
                            <Button onClick={() => shuttleOperator('chargeOpen')}>充电开</Button>
                            <Button onClick={() => shuttleOperator('chargeClose')}>充电关</Button>
                            <Button onClick={() => shuttleOperator('reset')}>复位</Button>
                        </div>
                    </Card>
                </div>
 
                <div style={{ marginBottom: '15px' }}>
                    <Card title="跑库系统" >
                        <div className="commandItem">
                            <div><Input addonBefore="X起点" defaultValue="1" value={xStart} onChange={e => setXStart(e.target.value)} /></div>
                            <div><Input addonBefore="X终点" defaultValue="1" value={xTarget} onChange={e => setXTarget(e.target.value)} /></div>
                            <div><Input addonBefore="Y起点" defaultValue="1" value={yStart} onChange={e => setYStart(e.target.value)} /></div>
                            <div><Input addonBefore="Y终点" defaultValue="1" value={yTarget} onChange={e => setYTarget(e.target.value)} /></div>
                            <div>
                                <Select
                                    defaultValue="0"
                                    onChange={setMoveLocType}
                                    style={{ width: 120 }}
                                    options={[
                                        { value: '0', label: '跑轨道' },
                                        { value: '1', label: '跑库位' },
                                        { value: '2', label: '母轨道循环跑' },
                                        { value: '3', label: '子轨道循环跑' },
                                        { value: '4', label: '取放货' }
                                    ]}
                                />
                            </div>
                            <Button onClick={() => shuttleMoveLoc()}>跑库</Button>
                            <Button onClick={() => shuttleMoveLocClose()}>跑库关闭</Button>
                        </div>
                    </Card>
                </div>
 
            </Drawer>
        </>
    )
 
}
 
export default ShuttleHandle