理论能力1
公式:加工机器实际上班时间 * 3600 / 机器标准时间 * 标准夹具数
代码
CREATE FUNCTION [dbo].[udf_TheoreticalDutyOne]
(
@MachineId SMALLINT,
@OperatorDate DATETIME
)
RETURNS DECIMAL(18,6)
AS
BEGIN
DECLARE @ReturnValue DECIMAL(18,6)
--取得机器实际上班时间
DECLARE @WorkTime DECIMAL(18,6)
SELECT @WorkTime = (SELECT SUM([WorkTime]) FROM [dbo].[udf_WorkTicketData_1]() WHERE [MachineId] = @MachineId AND [OperatorDate] = @OperatorDate)
--从机器参数表,取得机器的标准时间和机器的标准夹具数
DECLARE @StandTime DECIMAL(18,6)
DECLARE @StandJigNumber TINYINT
SELECT @StandTime = [StandardTime],@StandJigNumber = [JigNumber] FROM [MachineParameter] WHERE [MachineId] = @MachineId AND (YEAR([MonthName])= YEAR(@OperatorDate)) AND (MONTH([MonthName]) = MONTH(@OperatorDate))
--计算机器的理论能力1
SELECT @ReturnValue=(CASE WHEN @StandTime = 0 THEN NULL WHEN @StandTime IS NULL THEN NULL WHEN @StandTime <> 0 THEN ((ISNULL(@WorkTime,0) * 3600) / @StandTime * ISNULL(@StandJigNumber,0)) END)
RETURN @ReturnValue
END
(
@MachineId SMALLINT,
@OperatorDate DATETIME
)
RETURNS DECIMAL(18,6)
AS
BEGIN
DECLARE @ReturnValue DECIMAL(18,6)
--取得机器实际上班时间
DECLARE @WorkTime DECIMAL(18,6)
SELECT @WorkTime = (SELECT SUM([WorkTime]) FROM [dbo].[udf_WorkTicketData_1]() WHERE [MachineId] = @MachineId AND [OperatorDate] = @OperatorDate)
--从机器参数表,取得机器的标准时间和机器的标准夹具数
DECLARE @StandTime DECIMAL(18,6)
DECLARE @StandJigNumber TINYINT
SELECT @StandTime = [StandardTime],@StandJigNumber = [JigNumber] FROM [MachineParameter] WHERE [MachineId] = @MachineId AND (YEAR([MonthName])= YEAR(@OperatorDate)) AND (MONTH([MonthName]) = MONTH(@OperatorDate))
--计算机器的理论能力1
SELECT @ReturnValue=(CASE WHEN @StandTime = 0 THEN NULL WHEN @StandTime IS NULL THEN NULL WHEN @StandTime <> 0 THEN ((ISNULL(@WorkTime,0) * 3600) / @StandTime * ISNULL(@StandJigNumber,0)) END)
RETURN @ReturnValue
END