258 lines
5.7 KiB
JavaScript
258 lines
5.7 KiB
JavaScript
import request from '@/utils/request'
|
||
|
||
// 查询计划表列表
|
||
export function listPlan(query) {
|
||
return request({
|
||
url: '/production/plan/list',
|
||
method: 'get',
|
||
params: query
|
||
})
|
||
}
|
||
|
||
// 查询计划表详细
|
||
export function getPlan(id) {
|
||
return request({
|
||
url: '/production/plan/' + id,
|
||
method: 'get'
|
||
})
|
||
}
|
||
|
||
// 新增计划表
|
||
export function addPlan(data) {
|
||
return request({
|
||
url: '/production/plan',
|
||
method: 'post',
|
||
data: data
|
||
})
|
||
}
|
||
|
||
// 修改计划表
|
||
export function updatePlan(data) {
|
||
return request({
|
||
url: '/production/plan',
|
||
method: 'put',
|
||
data: data
|
||
})
|
||
}
|
||
|
||
// 删除计划表
|
||
export function delPlan(id) {
|
||
return request({
|
||
url: '/production/plan/' + id,
|
||
method: 'delete'
|
||
})
|
||
}
|
||
|
||
// 根据计划类型获取最新的计划数据
|
||
export function getLatestPlanByType(planType) {
|
||
return request({
|
||
url: '/production/plan/getLatestByType/' + planType,
|
||
method: 'get'
|
||
})
|
||
}
|
||
|
||
// ==================== 周/月计划相关接口 ====================
|
||
|
||
// 按周查询生产计划列表
|
||
export function listPlanByWeek(query) {
|
||
return request({
|
||
url: '/production/plan/week/list',
|
||
method: 'get',
|
||
params: query
|
||
})
|
||
}
|
||
|
||
// 按月查询生产计划列表
|
||
export function listPlanByMonth(query) {
|
||
return request({
|
||
url: '/production/plan/month/list',
|
||
method: 'get',
|
||
params: query
|
||
})
|
||
}
|
||
|
||
// 按日期范围查询生产计划列表(用于日历视图)
|
||
export function listPlanByDateRange(query) {
|
||
return request({
|
||
url: '/production/plan/dateRange/list',
|
||
method: 'get',
|
||
params: query
|
||
})
|
||
}
|
||
|
||
// 新增周计划
|
||
export function addWeekPlan(data) {
|
||
return request({
|
||
url: '/production/plan/week',
|
||
method: 'post',
|
||
data: data
|
||
})
|
||
}
|
||
|
||
// 新增月计划
|
||
export function addMonthPlan(data) {
|
||
return request({
|
||
url: '/production/plan/month',
|
||
method: 'post',
|
||
data: data
|
||
})
|
||
}
|
||
|
||
// 检查周计划是否存在
|
||
export function checkWeekPlanExists(planYear, weekNumber) {
|
||
return request({
|
||
url: '/production/plan/week/check',
|
||
method: 'get',
|
||
params: { planYear, weekNumber }
|
||
})
|
||
}
|
||
|
||
// 检查月计划是否存在
|
||
export function checkMonthPlanExists(planYear, monthNumber) {
|
||
return request({
|
||
url: '/production/plan/month/check',
|
||
method: 'get',
|
||
params: { planYear, monthNumber }
|
||
})
|
||
}
|
||
|
||
// 校准计划的完成产量
|
||
export function calibrateCompletedQuantity(id) {
|
||
return request({
|
||
url: '/production/plan/calibrate/' + id,
|
||
method: 'post'
|
||
})
|
||
}
|
||
|
||
// 获取产品信息(包含库存和BOM信息)
|
||
export function getProductInfo(materialId) {
|
||
return request({
|
||
url: '/production/plan/productInfo/' + materialId,
|
||
method: 'get'
|
||
})
|
||
}
|
||
|
||
// 获取计划关联的工单列表
|
||
export function getPlanWorkOrders(planId) {
|
||
console.log('========== API: getPlanWorkOrders ==========');
|
||
console.log('planId:', planId);
|
||
console.log('URL:', '/production/plan/workOrders/' + planId);
|
||
console.log('==========================================');
|
||
|
||
return request({
|
||
url: '/production/plan/workOrders/' + planId,
|
||
method: 'get'
|
||
})
|
||
}
|
||
|
||
// 计划分析
|
||
export function analyzePlan(data) {
|
||
return request({
|
||
url: '/production/plan/analyze',
|
||
method: 'post',
|
||
data: data
|
||
})
|
||
}
|
||
|
||
|
||
// 为库存生产计划自动创建销售订单
|
||
export function autoCreateSaleOrderForMTS(data) {
|
||
return request({
|
||
url: '/production/plan/autoCreateOrder',
|
||
method: 'post',
|
||
data: data
|
||
})
|
||
}
|
||
|
||
// 执行生产计划排产(支持传递工单时间数据)
|
||
export function schedulePlan(planId, scheduleData) {
|
||
return request({
|
||
url: '/production/plan/' + planId + '/schedule',
|
||
method: 'post',
|
||
data: scheduleData || {} // 如果有排产数据则传递,否则传空对象
|
||
})
|
||
}
|
||
|
||
// ==================== 计划分析相关接口 ====================
|
||
|
||
// 查询同产品的订单列表
|
||
export function getSameProductOrders(materialId, status = 'pending,producing') {
|
||
return request({
|
||
url: '/production/plan/analysis/orders/' + materialId,
|
||
method: 'get',
|
||
params: { status }
|
||
})
|
||
}
|
||
|
||
// 计算工序路线的生产时间
|
||
export function getRouteDuration(routeId, quantity) {
|
||
return request({
|
||
url: '/production/plan/analysis/route-duration/' + routeId,
|
||
method: 'get',
|
||
params: { quantity }
|
||
})
|
||
}
|
||
|
||
// 获取工序路线的设备信息(materialUnit:产品单位;materialId:物料ID,单位为空时后端按物料查单位)
|
||
export function getRouteEquipment(routeId, materialUnit, materialId) {
|
||
return request({
|
||
url: '/production/plan/analysis/route-equipment/' + routeId,
|
||
method: 'get',
|
||
params: { materialUnit, materialId }
|
||
})
|
||
}
|
||
|
||
// 获取产线的所有待生产订单(按优先级和交期排序)
|
||
export function getProductionLineOrders(routeId) {
|
||
return request({
|
||
url: '/production/plan/analysis/production-line-orders/' + routeId,
|
||
method: 'get'
|
||
})
|
||
}
|
||
|
||
// ==================== AI智能分析相关接口 ====================
|
||
|
||
// 获取计划分析数据
|
||
export function getPlanAnalysis(orderId) {
|
||
return request({
|
||
url: '/production/plan/analysis/' + orderId,
|
||
method: 'get'
|
||
})
|
||
}
|
||
|
||
// 请求AI智能分析
|
||
export function requestAIAnalysis(data) {
|
||
return request({
|
||
url: '/production/plan/ai-analysis',
|
||
method: 'post',
|
||
data: data
|
||
})
|
||
}
|
||
|
||
// ==================== 班次时间配置接口 ====================
|
||
|
||
// 获取班次时间配置列表
|
||
export function listShiftConfig() {
|
||
return request({
|
||
url: '/production/shift/config/list',
|
||
method: 'get'
|
||
})
|
||
}
|
||
|
||
// 保存/更新班次时间配置
|
||
export function updateShiftConfig(data) {
|
||
return request({
|
||
url: '/production/shift/config',
|
||
method: 'put',
|
||
data: data
|
||
})
|
||
}
|
||
|
||
// 重置为默认值
|
||
export function resetShiftConfig() {
|
||
return request({
|
||
url: '/production/shift/config/reset',
|
||
method: 'post'
|
||
})
|
||
}
|