# `Sp_Manufacture_SetTime` (procedure)

> @author:钱豹
							@date:20210530 封存
							@describe: 按当前机台的排单次序,重算开始时间，耗时，结束时间，考虑因素有 单双休，工作时间
							条件为： 已排程 或 已下达 的未撤单记录


- **Type:** PROCEDURE
- **Deterministic:** NO
- **SQL data access:** CONTAINS SQL

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sProInParam` | `varchar(10000)` |
| 2 | IN | `sMakePerson` | `varchar(100)` |
| 3 | IN | `sBrId` | `varchar(100)` |
| 4 | IN | `sSuId` | `varchar(100)` |
| 5 | OUT | `sReturn` | `varchar(1000)` |
| 6 | OUT | `sCode` | `int` |

## Body

_Body is not pre-cached. To inspect: `mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE PROCEDURE `Sp_Manufacture_SetTime`'`._

## Narrative

**Business context:** 生产管理 → 机台作业任务执行 — scheduling-side recompute for the per-machine 排单 sequence. After a user re-sorts or re-targets work-order rows on a machine, this proc walks the machine's pending 排程/已下达 (未撤单) rows in `mftproductionplanslave`, recomputes each row's `tCStartTime / dHour / tCEndTime` taking single/double-shift, working hours and off-time into account, and back-writes the new schedule.

**What it does:** Reads `sMachineId / iOrder / tCStartTime / sWorkCenterId` from `$.params[0].value[0]` of `sProInParam`. Per row it calls `Sp_CalcPlan_dHour` to get the per-row duration, then `UPDATE mftproductionplanslave` with new start/end/hour; iterates downstream rows in `iOrder` order, propagating end-time → next-row start-time. Also `update elemachine` for the machine's current state and `CALL Sp_productionPlan_BtnEventAutoOrderSettime` plus `Sp_Sis_GetConst` for localised error text. Author 钱豹, marked 封存 (frozen) 2021-05-30.

**Invocation:** Dispatched dynamically by Java `WorkOrderPlanServiceImpl.doSetTime(...)` via `procedureService.getDoProMap("Sp_Manufacture_SetTime", setTime)` + `getCallProByMap(setTime, "Sp_Manufacture_SetTime")` — the 机台排程 calculation entry-point declared in `BtnCalculationService` ("机台、统一规划 调用 Sp_unifiedPlanning_BtnCalculation，Sp_Manufacture_SetTime时候执行"). Also called from `Sp_unifiedPlanning_BtnCalculation`, `Sp_BtnCalculation_Machine_time_byMachineType`, `Sp_productionPlan_BtnEventAutoOrder10`, `Sp_productionPlan_BtnEventCnl`, and the per-employee variant `Sp_Manufacture_SetTime_Employ`. No gdsmodule or form-master binding — purely Java/proc-chain dispatched.
