# `Sp_Manufacture_SetTime_tDate` (procedure)

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


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `p_dWeek` | `varchar(50)` |
| 2 | IN | `p_dWorkTimesum` | `int` |
| 3 | IN | `p_tCStartTime` | `varchar(50)` |
| 4 | IN | `p_sShiftsWork` | `varchar(50)` |
| 5 | IN | `p_sWorkOff` | `varchar(10)` |
| 6 | IN | `p_sWorkType` | `varchar(10)` |
| 7 | OUT | `tDate` | `datetime` |
| 8 | OUT | `sDayxx` | `int` |

## Body

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

## Narrative

**Business context:** 生产管理 → 机台作业任务执行 — calendar helper inside the SetTime family. Given a candidate start instant `p_tCStartTime`, a daily work-minutes budget `p_dWorkTimesum`, the shift/off-shift boundaries `p_sShiftsWork / p_sWorkOff`, and the shift-style flag `p_sWorkType` (1=single 白班, 2=double 白/晚), it snaps the start to the next valid working window and returns the adjusted datetime in `tDate` plus the "skipped minutes" gap in `sDayxx`.

**What it does:** Pure compute, no DML. Inspects the `%H:%i` part of `p_tCStartTime`, classifies it as `sShiftsWork` (off-shift gap) or `sOffWork` (on-shift), and for two-shift mode (`p_sWorkType=2`) shifts the start forward to the next shift opening; for single-shift mode advances by a day when past the off-time. The minute gap to the next opening is returned in `sDayxx` so the caller can add it to the row's `dHour`.

**Invocation:** No direct caller found in any channel — neither in gdsmodule, form-master, other routines (no `CALL Sp_Manufacture_SetTime_tDate` in the DB), nor xly-src. Status: appears orphaned. The `_tDate` name and comment header place it firmly in the `Sp_Manufacture_SetTime*` family; likely an in-progress calendar helper for the (封存) re-scheduler that was inlined into the production scheduler before this helper was wired up. Candidate for maintainer audit.
