import request from '@/utils/request'
import { method } from 'lodash-es'

const baseUrl = import.meta.env.VITE_APP_PRODUCTION_API

/**
 * 获取 生产批次 列表
 * @param {*} data
 * @returns
 */
export function listDaywork(query) {
	return request({
		url: baseUrl + '/business/productionDaywork/list',
		method: 'get',
		params: query
	})
}




export function listDayworkAuxiliaryItem(query) {
	return request({
		url: baseUrl + '/business/productionDaywork/listDayworkAuxiliaryItem',
		method: 'get',
		params: query
	})
}

export function listForOutsource(query) {
	return request({
		url: baseUrl + '/business/productionDaywork/listForOutsource',
		method: 'get',
		params: query
	})
}
export function listForInnerOutsource(query) {
	return request({
		url: baseUrl + '/business/productionDaywork/listForInnerOutsource',
		method: 'get',
		params: query
	})
}

export function processesForOutsource(query) {
	return request({
		url: baseUrl + '/business/productionDaywork/processesForOutsource',
		method: 'get',
		params: query
	})
}

export function processesForOutsourceByFirst(query) {
	return request({
		url: baseUrl + '/business/productionDaywork/processesForOutsourceByFirst',
		method: 'get',
		params: query
	})
}

/**
 * 查询当前报工工序
 * 此方法在非本序废品页面使用
 * @param {*} query 
 * @returns 
 */
export function listDayworkLot(query) {
	return request({
		url: baseUrl + '/business/productionDaywork/listDayworkLot',
		method: 'get',
		params: query
	})
}


export function carrierForOutsource(query) {
	return request({
		url: baseUrl + '/business/productionDaywork/carrierForOutsource',
		method: 'get',
		params: query
	})
}

// 查询工序管理
export function getDayworkProcessList(query) {
	return request({
		url: baseUrl + '/business/productionDaywork/getDayworkProcessList',
		method: 'get',
		params: query
	})
}
/**
 * 获取 计划查询的工段列表
 * @param {*} data
 * @returns
 */
/**
 * 获取 计划查询 列表
 * @param {*} data
 * @returns
 */
export function getDayworkInfo(query) {
	return request({
		url: baseUrl + '/business/productionDaywork/getDayworkInfo',
		method: 'get',
		params: query
	})
}
/**
 * 获取 计划查询的工段列表
 * @param {*} data
 * @returns
 */
export function getDeptInfo(query) {
	return request({
		url: baseUrl + '/business/productionDaywork/getDeptInfo',
		method: 'get',
		params: query
	})
}
/**
 * 获取 已生产批次 列表
 * @param {*} data
 * @returns
 */
export function getProducedLot(query) {
	return request({
		url: baseUrl + '/business/productionDaywork/getProducedLot',
		method: 'get',
		params: query
	})
}
export function getLotPosition(query) {
	return request({
		url: baseUrl + '/business/productionDaywork/getLotPosition',
		method: 'get',
		params: query
	})
}
export function getItemProcess(query) {
	return request({
		url: baseUrl + '/business/productionDaywork/getItemProcess',
		method: 'get',
		params: query
	})
}
export function getDayworkList(query) {
	return request({
		url: baseUrl + '/business/productionDaywork/getDayworkList',
		method: 'get',
		params: query
	})
}
/**
 * 获取 报工记录的工段
 * @param {*} data
 * @returns
 */
export function getDeptList(query) {
	return request({
		url: baseUrl + '/business/productionDaywork/getDeptList',
		method: 'get',
		params: query
	})
}

/**
 * 获取用户工段
 */
export function getDeptListForUser() {
	return request({
		url: baseUrl + '/business/productionDaywork/getDeptListForUser',
		method: 'get'
	})
}

/** 查询批次信息 */
export function getDayworkItemProcess(id) {
	return request({
		url: baseUrl + '/business/productionDaywork/getDayworkItemProcess/' + id,
		method: 'get'
	})
}

/**
 * 获取 生产批次报工 列表
 * @param {*} data
 * @returns
 */
export function listDayworkItem(query) {
	return request({
		url: baseUrl + '/business/productionDaywork/listItem',
		method: 'get',
		params: query
	})
}
export function listOriginalDayworkItem(query) {
	return request({
		url: baseUrl + '/business/productionDaywork/listOriginalItem',
		method: 'get',
		params: query
	})
}
//修改批次炉号信息
export function updateDayworkFurnace(data) {
	return request({
		url: baseUrl + '/business/productionDaywork/updateDayworkFurnace',
		method: 'post',
		data: data
	})
}
/**
 * 批次日报
 * @param {*} query 
 * @returns 
 */
export function listReportItem(query) {
	return request({
		url: baseUrl + '/business/productionDaywork/listReportItem',
		method: 'get',
		params: query
	})
}
/**
 * 获取 生产批次报工 列表
 * @param {*} data
 * @returns
 */
export function checkUseEquipment(data) {
	return request({
		url: baseUrl + '/business/productionDaywork/checkUseEquipment',
		method: 'post',
		data: data
	})
}

/**
 * 修改 生产批次报工 列表
 * @param {*} data
 * @returns
 */
export function updateItem(data) {
	return request({
		url: baseUrl + '/business/productionDaywork/updateItem',
		method: 'post',
		data: data
	})
}

/**
 * 查询是否为首序
 */
export function getIsFirstOrder(dayworkId) {
	return request({
		url: baseUrl + '/business/productionDaywork/getIsFirstOrder/' + dayworkId,
		method: 'get'
	})
}

/**
 * 获取报工批次工序列表
 * @param {*} data
 * @returns
 */
export function getProcessList(query) {
	return request({
		url: baseUrl + '/business/productionDaywork/getProcessList',
		method: 'get',
		params: query
	})
}

// 查询工段资源组能够选择的设备
export function getEquipmentInfo(query) {
	return request({
		url: baseUrl + '/business/detail/equipmentInfo',
		method: 'get',
		params: query
	})
}
export function equipmentInfoInDaywork(query) {
	return request({
		url: baseUrl + '/business/detail/equipmentInfoInDaywork',
		method: 'get',
		params: query
	})
}
//查询工艺路线计划单
export function getProcessDetail(data) {
	return request({
		url: baseUrl + '/business/productionDaywork/getProcessDetail',
		method: 'post',
		data: data
	})
}

export function getEquipmentList(data) {
	return request({
		url: baseUrl + '/business/detail/getEquipmentList',
		method: 'post',
		data: data
	})
}

/**
 * 获取报工批次废弃信息
 * @param {*} data
 * @returns
 */
export function getDayworkItemRejectList(query) {
	return request({
		url: baseUrl + '/business/productionDaywork/getDayworkItemRejectList',
		method: 'get',
		params: query
	})
}
//普通报工
export function getDayworkItemOriginalRejectList(query) {
	return request({
		url: baseUrl + '/business/productionDaywork/getOriginalDayworkItemRejectList',
		method: 'get',
		params: query
	})
}
//特殊报工
export function getDayworkItemAuxiliaryRejectList(query) {
	return request({
		url: baseUrl + '/business/productionDaywork/getAuxiliaryDayworkItemRejectList',
		method: 'get',
		params: query
	})
}

/**
 * 修改 生产批次报工 列表
 * @param {*} data
 * @returns
 */
export function updateDayworkItemInfo(data) {
	return request({
		url: baseUrl + '/business/productionDaywork/updateDayworkItemInfo',
		method: 'post',
		data: data
	})
}

/**
 * 修改 生产批次报工列表中的数量
 * @param {*} data 
 * @returns 
 */
export function updateDayworkItemInfoForNum(data) {
	return request({
		url: baseUrl + '/business/productionDaywork/updateDayworkItemInfoForNum',
		method: 'post',
		data: data
	})
}
/**
 * 修改生产批次报工列表中周转报工的信息
 * @param {*} data 
 */
export function updateDayworkItemInfoForTurnover(data) {
	return request({
		url: baseUrl + '/business/productionDaywork/updateDayworkItemInfoForTurnover',
		method: 'post',
		data: data
	})
}

export function updateDayworkItemInfoMax(data) {
	return request({
		url: baseUrl + '/business/productionDaywork/updateDayworkItemInfoMax',
		method: 'post',
		data: data
	})
}

export function addDaywork(data) {
	return request({
		url: baseUrl + '/business/daywork',
		method: 'post',
		data: data
	})
}

export function getDaywork(id) {
	return request({
		url: baseUrl + '/business/daywork/' + id,
		method: 'get'
	})
}
export function getDayworkItemDetail(data) {
	return request({
		url: baseUrl + '/business/productionDaywork/getDayworkItemDetail',
		method: 'post',
		data: data
	})
}

export function updateDaywork(data) {
	return request({
		url: baseUrl + '/business/daywork',
		method: 'put',
		data: data
	})
}

export function delDaywork(id) {
	return request({
		url: baseUrl + '/business/daywork/' + id,
		method: 'delete'
	})
}
export function delDayworkItem(ids) {
	return request({
		url: baseUrl + '/business/productionDaywork/' + ids,
		method: 'delete'
	})
}

export function lotList(query) {
	return request({
		url: baseUrl + '/business/productionDaywork/lotList',
		method: 'get',
		params: query
	})
}

export function getAllWorkShop(query) {
	return request({
		url: baseUrl + '/business/productionDaywork/getAllWorkShop',
		method: 'get',
		params: query
	})
}
