191 lines
6.7 KiB
TypeScript
191 lines
6.7 KiB
TypeScript
import httpService from '@/utils/request'
|
|
import API from './config'
|
|
import Taro from '@tarojs/taro'
|
|
import { useRootUserStore } from '@/store/index'
|
|
/** 设备相关接口---------------------------------------- */
|
|
|
|
// 设备列表
|
|
export function allDeviceList(params) {
|
|
return httpService.get(API.DEVICE.LIST_ALL(), {params})
|
|
}
|
|
// 设备详情
|
|
export function deviceInfo(data){
|
|
const store = useRootUserStore();
|
|
const userId = store.getRootUserId || Taro.getStorageSync('UserId');
|
|
return httpService.post(`${API.DEVICE.INFO()}?rootUserId=${userId}`, {data})
|
|
}
|
|
// 解除绑定
|
|
export function deviceUnbind(data){
|
|
const store = useRootUserStore();
|
|
const userId = store.getRootUserId || Taro.getStorageSync('UserId');
|
|
return httpService.post(`${API.DEVICE.UNBIND()}?rootUserId=${userId}`, {data})
|
|
}
|
|
// 将设备及开关绑定到塘口
|
|
export function bandDeviceToPond(data){
|
|
return httpService.put(API.POND.BIND_DEVICE(), {data})
|
|
}
|
|
// 设备图表数据
|
|
export function deviceHistory(params){
|
|
return httpService.get(API.DEVICE.HISTORY(), {params})
|
|
}
|
|
// 修改设备名称
|
|
export function deviceUpdateName(data){
|
|
const store = useRootUserStore();
|
|
const userId = store.getRootUserId || Taro.getStorageSync('UserId');
|
|
return httpService.put(`${API.DEVICE.UPDATE_NAME()}?rootUserId=${userId}`, {data})
|
|
}
|
|
// 修改设备关联塘口
|
|
export function deviceUpdatePond(data){
|
|
const store = useRootUserStore();
|
|
const userId = store.getRootUserId || Taro.getStorageSync('UserId');
|
|
return httpService.put(`${API.DEVICE.UPDATE_POND()}?rootUserId=${userId}`, {data})
|
|
}
|
|
// 修改设备接电方式
|
|
export function deviceUpdateV(data){
|
|
return httpService.put(API.DEVICE.UPDATE_VOLTAGE(), {data})
|
|
}
|
|
// 删除设备
|
|
export function deviceDel(data){
|
|
// 后端需要 /{ids} 路径参数,传入 ID 数组
|
|
return httpService.delete(`${API.DEVICE.DELETE()}/${data.id}`)
|
|
}
|
|
// 扫描设备编码
|
|
export function deviceScan(params){
|
|
return httpService.get(API.DEVICE.SCAN(), {params})
|
|
}
|
|
// 检测设备是否在线
|
|
export function checkDeviceStatus(params){
|
|
return httpService.get(API.DEVICE.CHECK_STATUS(), {params})
|
|
}
|
|
// 盐度设置
|
|
export function setSal(data){
|
|
return httpService.post(API.DEVICE.SET_SALINITY(), {data})
|
|
}
|
|
// 设备校准
|
|
export function deviceCalibration(data){
|
|
return httpService.post(API.DEVICE.CALIBRATE(), {data})
|
|
}
|
|
/** 水质检测仪------------------------------------------------ */
|
|
// 添加-水质检测仪
|
|
export function addDeviceDetector(data) {
|
|
return httpService.post(API.DEVICE.ADD_DETECTOR(), {data})
|
|
}
|
|
// 设置溶解氧/水温告警
|
|
export function setWarnCall(data){
|
|
const store = useRootUserStore();
|
|
const userId = store.getRootUserId || Taro.getStorageSync('UserId');
|
|
return httpService.post(`${API.DEVICE.SET_WARN_CALL()}?rootUserId=${userId}`, {data})
|
|
}
|
|
// 设置溶解氧上下限
|
|
export function setOxyWarn(data){
|
|
const store = useRootUserStore();
|
|
const userId = store.getRootUserId || Taro.getStorageSync('UserId');
|
|
return httpService.put(`${API.DEVICE.SET_OXY_WARN()}?rootUserId=${userId}`, {data})
|
|
}
|
|
// 设置温度上下限
|
|
export function setTempWarn(data){
|
|
const store = useRootUserStore();
|
|
const userId = store.getRootUserId || Taro.getStorageSync('UserId');
|
|
return httpService.put(`${API.DEVICE.SET_TEMP_WARN()}?rootUserId=${userId}`, {data})
|
|
}
|
|
// 溶解氧饱和度
|
|
export function getSaturability(data){
|
|
return httpService.post(API.DEVICE.GET_SATURABILITY(), {data})
|
|
}
|
|
/** 控制一体机------------------------------------------------ */
|
|
// 添加-控制一体机
|
|
export function addDeviceController(data) {
|
|
return httpService.post(API.DEVICE.ADD_CONTROLLER(), {data})
|
|
}
|
|
// 启停溶解氧
|
|
export function setOxyOpen(data){
|
|
const store = useRootUserStore();
|
|
const userId = store.getRootUserId || Taro.getStorageSync('UserId');
|
|
return httpService.put(`${API.DEVICE.SET_OXY_OPEN()}?rootUserId=${userId}`, {data})
|
|
}
|
|
/** 联动控制------------------------------------- */
|
|
// 设备控制器列表
|
|
export function linkerCtrlList(data){
|
|
return httpService.post(API.LINKED_CTRL.LIST(), {data})
|
|
}
|
|
// 添加联动控制
|
|
export function addLinkerCtrl(data){
|
|
return httpService.post(API.LINKED_CTRL.ADD(), {data})
|
|
}
|
|
// 修改联动控制
|
|
export function updateLinkerCtrl(data){
|
|
return httpService.put(API.LINKED_CTRL.UPDATE(), {data})
|
|
}
|
|
// 删除联动控制
|
|
export function delLinkerCtrl(data){
|
|
const store = useRootUserStore();
|
|
const userId = store.getRootUserId || Taro.getStorageSync('UserId');
|
|
// 后端需要 /{ids} 路径参数
|
|
return httpService.delete(`${API.LINKED_CTRL.DELETE()}/${data.id}?rootUserId=${userId}`)
|
|
}
|
|
// 设置联动控制上下限开关
|
|
export function setLinkOpen(data){
|
|
return httpService.put(API.LINKED_CTRL.SET_OPEN(), {data})
|
|
}
|
|
/** 开关------------------------------------------------ */
|
|
// 开关列表
|
|
export function pondSwitchList(data){
|
|
return httpService.post(API.SWITCH.POND_LIST(), {data})
|
|
}
|
|
// 开关详情
|
|
export function switchInfo(data){
|
|
return httpService.post(API.SWITCH.INFO(), {data})
|
|
}
|
|
// 修改开关名称
|
|
export function updateSwitchName(data){
|
|
return httpService.put(API.SWITCH.UPDATE_NAME(), {data})
|
|
}
|
|
// 修改关联塘口
|
|
export function updateSwitchPond(data){
|
|
return httpService.put(API.SWITCH.UPDATE_POND(), {data})
|
|
}
|
|
// 修改接线方式
|
|
export function updateSwitchType(data){
|
|
return httpService.put(API.SWITCH.UPDATE_VOLTAGE(), {data})
|
|
}
|
|
// 单个开关 启停
|
|
export function turnSwitch(data){
|
|
return httpService.put(API.SWITCH.TURN(), {data})
|
|
}
|
|
// 所有开关 启停
|
|
export function turnPondSwitch(data){
|
|
return httpService.put(API.SWITCH.TURN_POND(), {data})
|
|
}
|
|
|
|
// 电压告警开关 开启或关闭
|
|
export function voltageCheckOpen(data){
|
|
const store = useRootUserStore();
|
|
const userId = store.getRootUserId || Taro.getStorageSync('UserId');
|
|
return httpService.put(`${API.DEVICE.VOLTAGE_CHECK()}?rootUserId=${userId}`, {data})
|
|
}
|
|
// 电流告警开关 开启或关闭
|
|
export function electricCheckOpen(data){
|
|
return httpService.put(API.SWITCH.ELECTRIC_CHECK(), {data})
|
|
}
|
|
// 电流告警开关 开启或关闭
|
|
export function electricSet(data){
|
|
return httpService.put(API.SWITCH.ELECTRIC_SET(), {data})
|
|
}
|
|
|
|
// 定时开关列表
|
|
export function timeCtrlList(data){
|
|
return httpService.put(API.TIME_CTRL.LIST(), {data})
|
|
}
|
|
export function addTimeCtrl(data){
|
|
return httpService.post(API.TIME_CTRL.ADD(), {data})
|
|
}
|
|
export function delTimeCtrl(data){
|
|
return httpService.delete(API.TIME_CTRL.DELETE(), {data})
|
|
}
|
|
export function setTimeCtrlOpen(data){
|
|
return httpService.post(API.TIME_CTRL.UPDATE(), {data})
|
|
}
|
|
// 夜间防误触
|
|
export function setNightProtect(data){
|
|
return httpService.put(API.POND.KEEP_NIGHT_OPEN(), {data})
|
|
} |