# `Fun_GetMachineWorkWorkType` (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_GetMachineWorkWorkType`'`._

## Narrative

**Business context:** Machine shift-window classifier — given a press (`iPlcNo`), returns the literal string `'sOffWork'` when `NOW()` is in the day-shift window or `'sShiftsWork'` when in the night/off-hours window. The catalog header `获取当前机台属于什么班` summarises the intent.

**What it does:** Reads `elemachine.sOffWork` / `sShiftsWork` (default `8:00` / `17:30`); compares `NOW()` against today's `[sOffWork, sShiftsWork)` interval.

**Invocation:** Called by `Sp_bd_McPlanConter` — the machine-board shift-completion counter that needs to know which shift to attribute current output to. Sibling of `Fun_GetMachineWorkStartDate` (full window) and the orphan `Fun_GetMachineWorkEndDate`.

Note: declared return type is `datetime` but body returns a `varchar` literal — type mismatch is harmless but worth flagging.
