# `FUN_GET_DATE_BC_ADDTIME` (function)

> 根据传入时间获取时间


- **Type:** FUNCTION
- **Returns:** `datetime`
- **Deterministic:** NO
- **SQL data access:** CONTAINS SQL

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `p_Date` | `datetime` |
| 2 | IN | `p_sWorkType` | `varchar(1)` |
| 3 | IN | `p_sShiftsWork` | `varchar(200)` |
| 4 | IN | `p_sWorkOff` | `varchar(200)` |
| 5 | IN | `p_dMinute` | `int` |

## Body

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

## Narrative

**Business context:** Production-planning time-addition helper. Adds `p_dMinute` to a base datetime, but for day-shift mode (`sWorkType='1'`) routes any overrun past the shift's end (`sShiftsWork`) to start counting again from the next day's clock-on (`sWorkOff`). Header comment is `根据传入时间获取时间` ("get date based on input date").

**What it does:** for `sWorkType=1`, computes `p_sDqbcsy = TIMESTAMPDIFF(MINUTE, p_Date, today_at_sShiftsWork)`. If the requested minute increment exceeds that remaining-in-shift window, returns `next_day_at_sWorkOff + (p_dMinute - p_sDqbcsy) MINUTE`. Otherwise (and for `sWorkType` ≠ 1) returns plain `DATE_ADD(p_Date, INTERVAL p_dMinute MINUTE)`.

**Invocation:** called by [`FUN_GET_CALCPLAN_DATE_END`](FUN_GET_CALCPLAN_DATE_END.md) and `Sp_Manufacture_SetTime_BB` (manufacturing time-setter for production-plan rows). Production-scheduling subsystem, 生产管理.
