huang
8 天以前 f13ba9e05f653bc3083c4d17fe8658e67054131e
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
// src/api/temperingGlass.ts
import request from '@/utils/request'
 
export interface TemperingGlassItem {
  // 定义你的数据项接口属性
    deviceId: number;
    glassId: number;
    engineerId: number;
    temperingLayoutId: number;
  id: number;
  width: number;
  height: number;
  angle: number;
  xcoordinate: number;
  ycoordinate: number;
  process_id: string;
  project_no: string;
  sort: string;
}
export interface TemperingGlassGroup {
  groupName: string;
  items: TemperingGlassItem[];
}
// 点击查询钢化版图
export const fetchTemperingGlassData = async (engineerId: string): Promise<TemperingGlassGroup[]> => {
  try {
    const response = await request.get('/temperingGlass/temperingGlassQueueInfo/queryTempLayoutByEngineerId?engineerId='+engineerId);
    if (response.code === 200 && response.data) {
      // 处理返回的数据,将每组数据转换为包含组名和项的对象数组
      return Object.entries(response.data).map(([groupName, items]) => ({
        groupName,
        items: items.map(item => ({
          ...item,
          x_axis: 0,
          y_axis: 0
        }))
      }));
    }
    throw new Error(response.message || 'Unknown error');
  } catch (error) {
    console.error('API请求失败:', error);
    throw error;
  }
};
// 调用钢化前中后版图
export const fetchAllMessage = async () => {
  try {
    const response = await request.post('/temperingGlass/TempJob/queryAllMessage', {
      deviceId: 1
    });
    if (response.code === 200 && response.data) {
         return {
        data: response.data
      };
    }
    throw new Error(response.message || 'Unknown error');
  } catch (error) {
    throw error;
  }
};
// 洛阳钢化前中版图
export const fetchLyBeMessage = async () => {
  try {
    const response = await request.post('/temperingGlass/TempJob/queryAllMessage', {
      deviceId: 1,
      temperingStage: 1
    });
    if (response.code === 200 && response.data) {
         return {
        data: response.data
      };
    }
    throw new Error(response.message || 'Unknown error');
  } catch (error) {
    throw error;
  }
};
// 洛阳钢化后版图
export const fetchLyMessage = async () => {
  try {
    const response = await request.post('/temperingGlass/TempJob/queryAllMessage', {
      deviceId: 1,
      temperingStage: 3
    });
    if (response.code === 200 && response.data) {
         return {
        data: response.data
      };
    }
    throw new Error(response.message || 'Unknown error');
  } catch (error) {
    throw error;
  }
};
export const updateTempQueueState = async (id: string | number, state: number) => {
  try {
    const response = await request.post('/temperingGlass/temperingGlassQueueInfo/updateTempQueueState', {
      id,
      state
    });
    if (response.code !== 200) {
      throw new Error(response.message || '更新队列状态失败');
    }
    return response.data;
  } catch (error) {
      console.error('更新队列状态API请求失败:', error);
      throw error;
  }
};
// 洛阳钢化破损
export const updateState = async (deviceId: string | number, glassId: number, engineerId: number, temperingLayoutId: number) => {
    try {
        const response = await request.post('/temperingGlass/temperingGlassQueueInfo/updateTempQueueState', {
            deviceId,
            glassId,
            engineerId,
            temperingLayoutId,
            state: 8
        });
        if (response.code !== 200) {
            throw new Error(response.message || '更新队列状态失败');
        }
        return response.data;
    } catch (error) {
        console.error('更新队列状态API请求失败:', error);
        throw error;
    }
};
// 洛阳下片完成
export const confirmPieceComplete = async (engineerId: string | number, temperingLayoutId: number) => {
    try {
        const response = await request.post('/temperingGlass/temperingGlassQueueInfo/updateTempQueueState', {
            deviceId: 1,
            state: 4,
            engineerId,
            temperingLayoutId
        });
        if (response.code !== 200) {
            throw new Error(response.message || '更新队列状态失败');
        }
        return response.data;
  } catch (error) {
    console.error('更新队列状态API请求失败:', error);
    throw error;
  }
};