|
@@ -1,11 +1,15 @@
|
|
|
import { setallLampHttp, getStatusHttp } from '@/services/ant-design-pro/equipment';
|
|
|
-import { message } from 'antd';
|
|
|
+// import { message } from 'antd';
|
|
|
|
|
|
// 定时调用 查询指令接口
|
|
|
-export const checkChangeLightStatusSuccess = (paramsArr, result, fn) => {
|
|
|
+export const checkChangeLightStatusSuccess = (paramsArr, resultArr, fn) => {
|
|
|
let checkParams = paramsArr;
|
|
|
checkParams.forEach((item) => {
|
|
|
- item.orderSeqNum = result.orderSeqNum;
|
|
|
+ for (let i = 0; i < resultArr.length; i++) {
|
|
|
+ if ((item.id = resultArr[i].id)) {
|
|
|
+ item.orderSeqNum = resultArr[i].orderSeqNum;
|
|
|
+ }
|
|
|
+ }
|
|
|
});
|
|
|
getStatusHttp(checkParams).then((res) => {
|
|
|
judgeChangeResponeseSuccess(res, paramsArr, fn);
|
|
@@ -14,27 +18,49 @@ export const checkChangeLightStatusSuccess = (paramsArr, result, fn) => {
|
|
|
|
|
|
// 检查开关指令下发状态
|
|
|
export const judgeChangeResponeseSuccess = (response, paramsArr, fn) => {
|
|
|
- let result = response.content[0];
|
|
|
+ let resFlag = false;
|
|
|
+ let resultArr = JSON.parse(JSON.stringify(response.content));
|
|
|
+ resultArr &&
|
|
|
+ resultArr.forEach((item) => {
|
|
|
+ if (
|
|
|
+ (item.state === 200 && item.exeResult === 'processing:rcvd') ||
|
|
|
+ (item.state === 202 && !item.exeResult)
|
|
|
+ ) {
|
|
|
+ resFlag = true;
|
|
|
+ } else {
|
|
|
+ resultArr.splice(item, 1);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (resFlag) {
|
|
|
+ setTimeout(() => {
|
|
|
+ checkChangeLightStatusSuccess(paramsArr, resultArr, fn);
|
|
|
+ }, 500);
|
|
|
+ } else {
|
|
|
+ fn(); // 查询灯设备
|
|
|
+ }
|
|
|
+ /*
|
|
|
if (result.result === 'success') {
|
|
|
- if (result.state === 200 && result.exeResult === 'success') {
|
|
|
+ if (!resFlag && result.state === 200 && result.exeResult === 'success') {
|
|
|
console.log('成功了');
|
|
|
fn(); // 查询灯设备
|
|
|
} else if (
|
|
|
- (result.state === 200 && result.exeResult === 'processing:rcvd') ||
|
|
|
- (result.state === 202 && !result.exeResult)
|
|
|
+ (resFlag && result.state === 200 && result.exeResult === 'processing:rcvd') ||
|
|
|
+ (resFlag && result.state === 202 && !result.exeResult)
|
|
|
) {
|
|
|
setTimeout(() => {
|
|
|
- checkChangeLightStatusSuccess(paramsArr, result, fn);
|
|
|
+ checkChangeLightStatusSuccess(paramsArr, resultArr, fn);
|
|
|
}, 500);
|
|
|
- }else if (result.state === 200 && result.exeResult === 'fail:timeout') {
|
|
|
- message.error('网络超时,请重试');
|
|
|
+ } else if (result.state === 200 && result.exeResult === 'fail:timeout') {
|
|
|
+ message.error('网络超时,请重试');
|
|
|
} else {
|
|
|
message.error('操作失败,请重试');
|
|
|
}
|
|
|
} else {
|
|
|
message.error('操作失败,请重试');
|
|
|
}
|
|
|
+ */
|
|
|
};
|
|
|
+
|
|
|
// 开关
|
|
|
export const setallLamps = (paramsArr, fn) => {
|
|
|
setallLampHttp(paramsArr).then((res) => {
|