Sp_CalcPlan_dHour.md 1.92 KB

Sp_CalcPlan_dHour (procedure)

@author:钱豹 根据排成Id计算dHour

  • Type: PROCEDURE
  • Deterministic: NO
  • SQL data access: CONTAINS SQL

Parameters

# Mode Name Type
1 IN sPlanId varchar(50)
2 IN p_sMakePerson varchar(50)
3 IN sBrId varchar(50)
4 IN sSuId varchar(50)
5 OUT p_dHour decimal(18,6)
6 OUT sReturn varchar(1000)
7 OUT sCode int

Body

Body is not pre-cached. To inspect: mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE PROCEDURESpCalcPlan_dHour'._

Narrative

Business context: 生产管理 / 排程 — per-plan-row machine-hour calculator (作者: 钱豹). Given one mftproductionplanslave.sId, derives the slave row's planned hours and machine-changeover (调机) hours using the machine's adjustable formula (elemachine.sPlanCapacityId / sAdjustableFormulaId), so the scheduler shows realistic time on each plan row.

What it does: Reads the slave's product/process/machine context from mftproductionplanslave joined to EleMachine. When an adjustable formula is configured, builds the formula's input tuple (billSlave,billControl,billProcedure,billMaster,baseProduct over mftproductionplanslave,mftworkordercontrol,mftworkorderprocess,eleprocessparam,eleProduct,mftworkorderslave) and calls Sp_System_ReplaceField_Detail to evaluate it, capturing the raw hour, an annotated sAdjustHour (formula trace), and a fallback message when the formula errors. Writes back to mftproductionplanslave.dCalcHour1 and sAdjustHour. Returns the cumulative p_dHour to the caller.

Invocation: Called by procedure Sp_Manufacture_InsertMftPlanSlave (when a plan slave is inserted/refreshed) and Sp_Manufacture_SetTime (when plan times are re-derived). No direct Java caller and no form-master binding — strictly a helper inside the scheduling proc family.