# `FUN_GET_DATE_BC` (function)

> 根据传入时间获取时间


- **Type:** FUNCTION
- **Returns:** `varchar(255)`
- **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)` |

## Body

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

## Narrative

**Business context:** Returns the shift-label string (`YYYY-MM-DD 白班` / `YYYY-MM-DD 晚班`) that a given timestamp belongs to. This is the value stored in `mftproductionplanslave.sDivRow` and friends — production reports, BI rollups, and the schedule grid all bucket by this string. The two shift names are pulled from the const table (`dayShift` / `nightShift` via `Fun_Sis_GetConst`), so multi-tenant overrides keep their own labels.

**What it does:** for `sWorkType='1'` (day-shift only), returns today's `dayShift` label. Otherwise, if `p_Date` is inside today's `sWorkOff` → `sShiftsWork` window returns today's `dayShift` label; if not, returns `nightShift`. When the time is before `sWorkOff` on the date (i.e. early-morning continuation of the prior night shift), the date is rolled back one day.

**Invocation:** central helper for the production-scheduling and reporting chain. Called by ~25 procs spanning BI workshop rollups, equipment-output reports, manufacturing time-set / time-trace, production-plan lock/unlock buttons (`Sp_productionPlan_BtnEventLock*`, `Sp_productionPlan_BtnEventunLock*`), unified-planning calc, and `Sp_Manufacture_BtnEventCopyPlanSlave`. A private same-named method in `WorkOrderPlanServiceImpl` reimplements the same logic in Java but doesn't invoke the SQL function.
