# `FUN_GET_CALC_DATE_END` (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_date` | `datetime` |
| 3 | IN | `p_dHour` | `decimal(18,6)` |
| 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_END`'`._

## Narrative

**Business context:** Production-planning time-arithmetic helper — given a job's start date, its duration in minutes, and the machine's shift type, returns the calendar end timestamp. Used by the unified-planning recalc path to roll forecast end times forward when work is rescheduled. Header comment is `时间后移动计算(不考虑双休日之类的)` ("forward time-shift calc, ignores weekends etc.").

**What it does:** coalesces defaults (`p_sWorkType=2`, `p_date=NOW()`, hour/minute=0), then `DATE_ADD(p_date, INTERVAL <minutes> MINUTE)` where the minute count is `p_dHour` for two-shift mode (`sWorkType=2`) and `FLOOR(p_dHour/p_dMinute)*(1440-p_dMinute) + p_dHour` for day-shift mode (`sWorkType=1`) — the latter inflates by a full off-shift window each time the day-shift cap is crossed.

**Invocation:** called by `Sp_unifiedPlanning_BtnCalculation_workorder` and `Sp_unifiedPlanning_BtnCalculation_workorder_calc` — the work-order recalc step of unified production planning (生产管理 → 生产运营报表 family). No form-master, gdsmodule-hook, or Java caller.
