# `FUN_GET_CALC_DATE` (function)

> 时间后移动计算


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `p_sWorkType` | `varchar(1)` |
| 2 | IN | `p_sShiftsWork` | `varchar(50)` |
| 3 | IN | `p_date` | `datetime` |
| 4 | IN | `p_dMinute` | `decimal(18,6)` |

## Body

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

## Narrative

**Business context:** Production-planning shift-rollover helper — when a job under day-shift mode overruns the shift's clock-out time, this function nudges the timestamp forward by one off-shift window so the next work segment starts on the following shift. Header comment is `时间后移动计算` ("forward time-shift calc"). Companion to [`FUN_GET_CALC_DATE_END`](FUN_GET_CALC_DATE_END.md).

**What it does:** for day-shift (`sWorkType='1'`), if `p_date` is past the day's `sShiftsWork` boundary, returns `DATE_ADD(p_date, INTERVAL (1440 - p_dMinute) MINUTE)`. Otherwise returns `p_date` unchanged. Read-only.

**Invocation:** referenced in the source file shipped with the unified-planning calc bundle (`script/标版/30100101/schedule/settime算休息时间/`). The corresponding callers (`Sp_unifiedPlanning_BtnCalculation_workorder`, `..._calc`) currently have the call commented out — see the surviving call to `FUN_GET_CALC_DATE_END` in the same blocks. Status: live in DB, paths to invoke it currently disabled — verify before relying on it.
