| | |
| | | import { request } from '@/common/utils' |
| | | import type { TasksResponse } from './task' |
| | | import type { CraftParamsResponse, TasksGroupByChannel } from './task' |
| | | import type { PLCResponse } from './plc' |
| | | import type { Devices } from './device' |
| | | import type { CraftModel } from './craftModel' |
| | | import type { Problem } from './problem' |
| | | import type { ReportingRecord } from './reporting' |
| | | |
| | | export interface BaseResponse<T = any> { |
| | | code: number |
| | |
| | | msg: string |
| | | } |
| | | |
| | | export interface ListResponse<T = any> { |
| | | code: number |
| | | data: T |
| | | msg: string |
| | | total: number |
| | | } |
| | | |
| | | export interface TaskListParams { |
| | | /** 1未完成2今天未完成3已完成 */ |
| | | type: 1 | 2 | 3 |
| | | /** 通道号 不传查所有通道的 */ |
| | | channel?: number |
| | | /** 从第几个开始查,从0开始 */ |
| | | offset: number |
| | | /** 查多少条 */ |
| | | limit: number |
| | | } |
| | | |
| | | /** |
| | | * 获取任务列表 |
| | | * @param taskMode 1: 待生产的任务 2: 看板各通道当前展示的任务 |
| | | * @param params |
| | | */ |
| | | export function getTaskList(taskMode: 1 | 2) { |
| | | return request<BaseResponse<TasksResponse>>({ |
| | | url: '/v1/task/get', |
| | | export function getTaskList(params: TaskListParams) { |
| | | return request<BaseResponse<TasksGroupByChannel>>({ |
| | | url: '/v1/task/list', |
| | | method: 'get', |
| | | params: { |
| | | taskMode |
| | | } |
| | | params |
| | | }) |
| | | } |
| | | |
| | | export interface ProductProgressParams { |
| | | channel: number |
| | | procedureId?: number |
| | | } |
| | | |
| | | /** |
| | | * 获取PLC运行数据 |
| | | * @param params |
| | | */ |
| | | export function getProductProgress(params: ProductProgressParams) { |
| | | return request<BaseResponse<PLCResponse>>({ |
| | | url: '/v1/plc/productProgress', |
| | | method: 'post', |
| | | data: params |
| | | }) |
| | | } |
| | | export interface CraftParamsParams { |
| | | id: number |
| | | } |
| | | |
| | | /** |
| | | * 获取工艺参数 |
| | | * @param params |
| | | */ |
| | | export function getCraftParams(params: CraftParamsParams) { |
| | | return request<BaseResponse<CraftParamsResponse>>({ |
| | | url: `v1/task/start/${params.id}`, |
| | | method: 'get', |
| | | data: params |
| | | }) |
| | | } |
| | | |
| | | export interface SendProcessParamsParams { |
| | | procedureId: number |
| | | } |
| | | |
| | | /** |
| | | * 下发工艺参数 |
| | | * @param params |
| | | */ |
| | | export function sendProcessParams(params: SendProcessParamsParams) { |
| | | return request<BaseResponse>({ |
| | | url: `v1/task/sendProcessParams`, |
| | | method: 'post', |
| | | data: params |
| | | }) |
| | | } |
| | | |
| | | export interface FinishTaskParams { |
| | | id: number |
| | | } |
| | | |
| | | /** |
| | | * 结束任务 |
| | | * @param params |
| | | */ |
| | | export function finishTask(params: FinishTaskParams) { |
| | | return request<BaseResponse>({ |
| | | url: `v1/task/finish/${params.id}`, |
| | | method: 'put', |
| | | data: params |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * 获取当前面板绑定的设备列表 |
| | | */ |
| | | export function getDeviceList() { |
| | | return request<BaseResponse<Devices>>({ |
| | | url: `/v1/device/list`, |
| | | method: 'get' |
| | | }) |
| | | } |
| | | |
| | | export interface SetCurrentDeviceParams { |
| | | currentDeviceID: string |
| | | } |
| | | |
| | | /** |
| | | * 设定当前设备 |
| | | */ |
| | | export function apiSetCurrentDevice(data: SetCurrentDeviceParams) { |
| | | return request<BaseResponse>({ |
| | | url: `/v1/device/setCurrentDeviceId`, |
| | | method: 'post', |
| | | data |
| | | }) |
| | | } |
| | | |
| | | export interface SetCurrentDeviceConfigParams { |
| | | needSetProcessParams: boolean |
| | | } |
| | | |
| | | /** |
| | | * 设定当前设备配置 |
| | | */ |
| | | export function apiSetCurrentDeviceConfig(data: SetCurrentDeviceConfigParams) { |
| | | return request<BaseResponse>({ |
| | | url: `/v1/device/config`, |
| | | method: 'post', |
| | | data |
| | | }) |
| | | } |
| | | |
| | | export interface CraftModelListParams { |
| | | procedureId: number |
| | | page: number |
| | | pageSize: number |
| | | } |
| | | |
| | | /** |
| | | * 获取工艺模型列表 |
| | | * @param params |
| | | */ |
| | | export function apiGetCraftModelList(params: CraftModelListParams) { |
| | | return request<ListResponse<CraftModel[]>>({ |
| | | url: '/v1/processModel/list', |
| | | method: 'get', |
| | | params |
| | | }) |
| | | } |
| | | |
| | | export interface UpdateCraftPrams { |
| | | procedureId: number |
| | | } |
| | | |
| | | /** |
| | | * 更新工艺模型 |
| | | * @param params |
| | | */ |
| | | export function updateCraftParams(params: UpdateCraftPrams) { |
| | | return request<BaseResponse>({ |
| | | url: '/v1/task/updateProcessParams', |
| | | method: 'post', |
| | | data: params |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * 获取问题诊断问题列表 |
| | | */ |
| | | export function apiGetProblemList() { |
| | | return request<BaseResponse<Problem[]>>({ |
| | | url: '/v1/system/problemList', |
| | | method: 'get' |
| | | }) |
| | | } |
| | | |
| | | export interface ReportingRecordListParams { |
| | | page?: number |
| | | pageSize?: number |
| | | procedureId: number |
| | | } |
| | | |
| | | /** |
| | | * 获取报工记录列表 |
| | | */ |
| | | export function apiGetReportingRecordList(params: ReportingRecordListParams) { |
| | | return request<ListResponse<ReportingRecord[]>>({ |
| | | url: '/v1/reportWork/list', |
| | | method: 'get', |
| | | params |
| | | }) |
| | | } |
| | | |
| | | export interface ReportWorkParams { |
| | | procedureId: number |
| | | reportAmount: number |
| | | workerID: string |
| | | } |
| | | |
| | | /** |
| | | * 报工 |
| | | */ |
| | | export function apiReportWork(params: ReportWorkParams) { |
| | | return request<BaseResponse>({ |
| | | url: '/v1/reportWork/report', |
| | | method: 'post', |
| | | data: params |
| | | }) |
| | | } |