# `Fun_GetMachineWorkEndDate` (function)

> 获取当前机台时间（包含上一班）


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sPlcNo` | `int` |
| 2 | IN | `sBrId` | `varchar(255)` |
| 3 | IN | `sSuId` | `varchar(255)` |

## Body

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

## Narrative

**Business context:** Machine shift-window helper — given a press (`iPlcNo`), returns the **end** of the current shift based on the machine's `elemachine.sOffWork` / `sShiftsWork` clock settings (default `8:00` / `17:30`). Counterpart to `Fun_GetMachineWorkStartDate` and `Fun_GetMachineWorkWorkType`.

**What it does:** Reads the machine's day-shift boundaries from `elemachine`, classifies `NOW()` as day or night side, then returns the corresponding `'sOffWork'`/`'sShiftsWork'` datetime on today's date.

**Invocation:** Status: appears orphaned. No caller found in any channel (form-master, gdsmodule hooks, other routines, xly-src grep beyond the routine's own deployment SQL) — candidate for maintainer audit. The sibling `Fun_GetMachineWorkStartDate` and `Fun_GetMachineWorkWorkType` are reachable via `Sp_bd_MachinePlanStatus`/`Sp_bd_McPlanConter`/`Sp_bd_McPlanRate`; the End variant has no current consumer.
