|
|
@@ -0,0 +1,42 @@
|
|
|
+# 2026-10-09
|
|
|
+
|
|
|
+## Query_LoadMan:跨线体上线时自动下线原线体
|
|
|
+
|
|
|
+需求:人员已上线到别的线体,再上线新线体时,把之前的线体自动下线。
|
|
|
+
|
|
|
+### 改动位置
|
|
|
+`FunctionCode/Query/Query_LoadMan.cs` → `em_code_KeyDown` 的上线分支(原行 86-94)。
|
|
|
+
|
|
|
+**改动前**:查到已有在线记录就直接拦截报错「已在 xx 上线,不允许重复上线」。
|
|
|
+
|
|
|
+**改动后**:分两种情况处理——
|
|
|
+- **同线重复上线** → 仍拦截报错(保留原保护,避免同一条线堆出多条记录)
|
|
|
+- **换了线体** → 先 `update loadman set lm_downtime=sysdate where lm_emcode=... and lm_downtime is null` 自动下线原记录,输出一条黑色提示「xx 已从原线体自动下线」,再执行新线体的 insert,最后输出绿色上线成功
|
|
|
+
|
|
|
+```csharp
|
|
|
+//一个人只能同时一条线上线:若已在别的线体上线,先把原线体自动下线,再在新线体上线
|
|
|
+DataTable dtOn = (DataTable)dh.ExecuteSql("select lm_linecode from loadman where lm_emcode='" + emcode + "' and lm_downtime is null", "select");
|
|
|
+if (dtOn.Rows.Count > 0)
|
|
|
+{
|
|
|
+ string oldLineCode = dtOn.Rows[0]["lm_linecode"].ToString();
|
|
|
+ //当前所在线体与新线体相同,提示已上线,不再重复插入
|
|
|
+ if (oldLineCode == linecode)
|
|
|
+ {
|
|
|
+ OperateResult.AppendText("<<" + emcode + "已在" + linecode + "上线,不允许重复上线\n", Color.Red, em_code);
|
|
|
+ em_code.Clear();
|
|
|
+ em_code.Focus();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //自动下线原线体
|
|
|
+ dh.ExecuteSql("update loadman set lm_downtime=sysdate where lm_emcode='" + emcode + "' and lm_downtime is null", "update");
|
|
|
+ OperateResult.AppendText(">>" + emcode + "已从" + oldLineCode + "自动下线\n", Color.Black);
|
|
|
+}
|
|
|
+```
|
|
|
+
|
|
|
+### 设计取舍
|
|
|
+- 下线 SQL 沿用「按 lm_emcode + lm_downtime is null」的条件(与手动下线分支一致),而不是按 `lm_linecode` 精确匹配 → 即使历史数据里同一人残留了多条未下线脏数据,也能一次全部关掉,避免「只关了一条还有残留,导致后面 insert 出多条在线」。
|
|
|
+- 保留了同线拦截:用户要的是「换线自动下线」,不是「允许重复上线补记录」。
|
|
|
+- 自动下线用的是 `sysdate`,与手动下线口径一致。
|
|
|
+
|
|
|
+### 验证
|
|
|
+`{}`/`()`/`[]` 平衡;**未本地编译**(沙箱拦 MSBuild/csc),需 VS 确认。
|