Przeglądaj źródła

优化上下线的时候的限制

callm 3 dni temu
rodzic
commit
2ac5839ed8

+ 31 - 0
UAS_MES_YDCY/.workbuddy/memory/2026-10-27.md

@@ -9,3 +9,34 @@
     `LoadGridData` select 加 `lm.lm_emname`(不 join SOPEMPLOYEEDETAIL,库里没有就显示空)。
 - 保留了:只扫工号不解析格式、批量勾选下线、全选按钮、自动互斥下线、回车 KeyPress 拦截。
 - 注意:历史记录(之前只记工号)该列为空属预期;`lm_emname` 列需可空(本次空值时不写该列)。
+
+# 2026-10-28
+
+## Make_Repair67F:完成维修时按产品 pr_isaoi 联动更新 ms_isaoi
+- 用户要求:`RepairComplete_Click`(完成维修回流)时,产品 `product.pr_isaoi=-1` 则同时更新 `makeserial.ms_isaoi=-1`,否则不更新。
+- 实现(+5/-3,只改 `RepairComplete_Click`):原 `getFieldsDataByCondition("makeserial",...)` 查询改为
+  `makeserial left join product on pr_code=ms_prodcode` 并取 `nvl(pr_isaoi,0) pr_isaoi`(nvl 防 null 拼串);
+  `string setIsaoi = pr_isaoi=="-1" ? ",ms_isaoi=-1" : ""`,两条回流 update(ms_ifrework==0 与返修分支)的
+  `ms_qccheck=-1` 后追加 `+ setIsaoi`。
+- 报废(Scrap_Click)未要求、未动。
+
+## 登录时从 employee 表取 em_ctcode 存入 User(2026-10-28)
+- 最终方案(用户中途改过一次:先说加到 SystemInf,后改口「从 employee 表取出来,加到 User 里面」):
+  - `Entity/User.cs` 新增 `public static string UserCtCode;`(em_ctcode)。
+  - `Login.cs` `SetInf()`:field 数组末尾加 `,em_ctcode`;赋值区加 `User.UserCtCode = UserInf.Rows[0]["em_ctcode"].ToString();`。
+  - `SystemInf.cs` 已还原零改动(git diff 确认)。
+- ⚠️ 限制:`SnCollectionBox` 的「切换人员」只刷 User.UserCode/UserName(公共控件不许改),切换后 UserCtCode 仍是原登录人的。
+- 自检脚本教训:剥字符串函数不识别 `@"..."` 原样字符串(结尾 `\"` 被误当转义),会报假阳性 MISMATCH;已修正为先判 `@"` 再按「双写引号不结束」解析。
+
+## Query_LoadMan:按登录人长线卡控上/下线扫码(2026-10-28)
+- 依赖上一条:`User.UserCtCode`(登录时取 employee.em_ctcode)。
+- `DoEmCode` 统一卡控(上/下线共用,放在 emcode 判空后、模式分支前):
+  1. 未选线别 → 「请先选择线别」(原上线专属判空提前,**下线模式现在也要求选线别**,属行为变化已向用户说明);
+  2. `User.UserCtCode == ""` → 「人员资料未维护线别,仅拉长可以扫码」(按用户原话文案);
+  3. `getFieldDataByCondition("line","count(1)","li_longline='ct' and li_code='线别' and li_statuscode='AUDITED'")=="0"` → 「线别xx不在xx长线范围内,不允许扫码」。
+- em_ctcode 语义 = 长线代码,对应 `line.li_longline`。
+- 追加(同日):下线扫码时,人员**在线记录上的 `lm_linecode`** 也必须在长线范围内,否则提示「当前在xx上线,该线别不在xx长线范围内,不允许下线」。
+  注意:批量勾选下线(`ConfirmDown_Click`)**尚未加此卡控**(用户只提扫码)。
+
+
+

+ 4 - 0
UAS_MES_YDCY/Entity/User.cs

@@ -61,5 +61,9 @@
         /// 默认不良组别
         /// </summary>
         public static string DefaultBadGroup;
+        /// <summary>
+        /// 员工表 Employee 的 em_ctcode
+        /// </summary>
+        public static string UserCtCode;
     }
 }

+ 5 - 3
UAS_MES_YDCY/FunctionCode/Make/Make_Repair67F.cs

@@ -611,12 +611,14 @@ namespace UAS_MES_NEW.Make
                     OperatResult.AppendText(">>回流工序不在回流工艺中\n", Color.Red);
                 else
                 {
-                    dt = dh.getFieldsDataByCondition("makeserial", new string[] { "nvl(ms_ifrework,0) ms_ifrework", "ms_paststep" }, "ms_sncode='" + ms_sncode.Text + "' and ms_makecode='" + macode + "'");
+                    dt = dh.getFieldsDataByCondition("makeserial left join product on pr_code=ms_prodcode", new string[] { "nvl(ms_ifrework,0) ms_ifrework", "ms_paststep", "nvl(pr_isaoi,0) pr_isaoi" }, "ms_sncode='" + ms_sncode.Text + "' and ms_makecode='" + macode + "'");
                     List<string> SQLS = new List<string>();
                     if (dt.Rows.Count > 0)
                     {
                         string ms_ifrework = dt.Rows[0]["ms_ifrework"].ToString();
                         string ms_paststep = dt.Rows[0]["ms_paststep"].ToString();
+                        //产品启用AOI检测(pr_isaoi=-1)时,完成维修同时更新 ms_isaoi=-1,否则不更新
+                        string setIsaoi = dt.Rows[0]["pr_isaoi"].ToString() == "-1" ? ",ms_isaoi=-1" : "";
                         //如果回流的执行过的工序为空
                         if (!ms_paststep.Contains(cd_stepcode.Text) && ms_paststep != "")
                         {
@@ -624,9 +626,9 @@ namespace UAS_MES_NEW.Make
                             return;
                         }
                         if (ms_ifrework == "0")
-                            SQLS.Add("update makeserial set ms_checkno='',ms_paststep = ms_paststep || case when instr(','||ms_paststep||',','" + User.CurrentStepCode + "')=0 then ','||'" + User.CurrentStepCode + "' end , ms_nextstepcode ='" + cd_stepcode.Text + "',ms_craftname='" + cr_name + "',ms_craftcode='" + cr_code.Text + "',ms_stepcode='" + User.CurrentStepCode + "',ms_status=1,ms_qccheck=-1 where ms_id='" + msid + "'");
+                            SQLS.Add("update makeserial set ms_checkno='',ms_paststep = ms_paststep || case when instr(','||ms_paststep||',','" + User.CurrentStepCode + "')=0 then ','||'" + User.CurrentStepCode + "' end , ms_nextstepcode ='" + cd_stepcode.Text + "',ms_craftname='" + cr_name + "',ms_craftcode='" + cr_code.Text + "',ms_stepcode='" + User.CurrentStepCode + "',ms_status=1,ms_qccheck=-1" + setIsaoi + " where ms_id='" + msid + "'");
                         else
-                            SQLS.Add("update makeserial set ms_checkno='',ms_paststep = ms_paststep || case when instr(','||ms_paststep||',','" + User.CurrentStepCode + "')=0 then ','||'" + User.CurrentStepCode + "' end , ms_nextstepcode ='" + cd_stepcode.Text + "',ms_craftname='" + cr_name + "',ms_craftcode='" + cr_code.Text + "',ms_stepcode='" + User.CurrentStepCode + "',ms_reworkstatus=1,ms_qccheck=-1 where ms_id='" + msid + "'");
+                            SQLS.Add("update makeserial set ms_checkno='',ms_paststep = ms_paststep || case when instr(','||ms_paststep||',','" + User.CurrentStepCode + "')=0 then ','||'" + User.CurrentStepCode + "' end , ms_nextstepcode ='" + cd_stepcode.Text + "',ms_craftname='" + cr_name + "',ms_craftcode='" + cr_code.Text + "',ms_stepcode='" + User.CurrentStepCode + "',ms_reworkstatus=1,ms_qccheck=-1" + setIsaoi + " where ms_id='" + msid + "'");
                     }
                     SQLS.Add("update makebad set mb_status=-1 where (mb_sncode='" + ms_sncode.Text + "' or mb_mscode='" + ms_sncode.Text + "') and mb_makecode='" + ms_makecode.Text + "'");
                     //取消最近拆解部件

+ 31 - 9
UAS_MES_YDCY/FunctionCode/Query/Query_LoadMan.cs

@@ -30,11 +30,10 @@ namespace UAS_MES_NEW.Query
             li_code.SelectField = "li_code # 线别编号,li_name # 线别名称";
             li_code.FormName = Name;
             li_code.SetValueField = new string[] { "li_code" };
-            li_code.Condition = "li_statuscode='AUDITED'";
+            li_code.Condition = "li_statuscode='AUDITED' and li_longline='"+User.UserCtCode+"'";
             li_code.DbChange += Li_code_DbChange;
             //初始提示
             OperateResult.AppendText(">>请选择线别,输入人员工号后回车执行" + (UpLoadMan.Checked ? "上线" : "下线") + ";下线也可勾选列表后点\"确认下线\"批量处理\n", Color.Black);
-            LoadGridData();
             em_code.Focus();
         }
 
@@ -113,14 +112,27 @@ namespace UAS_MES_NEW.Query
                 OperateResult.AppendText("<<人员工号不能为空\n", Color.Red, em_code);
                 return;
             }
+            //线别卡控(上/下线均适用):必须先选线别,且线别必须在登录人长线范围内
+            if (linecode == "")
+            {
+                OperateResult.AppendText("<<请先选择线别\n", Color.Red, li_code);
+                return;
+            }
+            //登录人资料未维护长线(em_ctcode为空)则不允许扫码
+            if (User.UserCtCode == "")
+            {
+                OperateResult.AppendText("<<人员资料未维护线别,仅拉长可以扫码\n", Color.Red, em_code);
+                return;
+            }
+            //所选线别必须属于登录人长线(line.li_longline)下的线别,否则上/下线都不允许
+            if (dh.getFieldDataByCondition("line", "count(1)",
+                "li_longline='" + User.UserCtCode + "' and li_code='" + linecode + "' and li_statuscode='AUDITED'").ToString() == "0")
+            {
+                OperateResult.AppendText("<<线别" + linecode + "不在" + User.UserCtCode + "范围内,不允许扫码\n", Color.Red, li_code);
+                return;
+            }
             if (UpLoadMan.Checked)
             {
-                //上线:必须选择线别
-                if (linecode == "")
-                {
-                    OperateResult.AppendText("<<请先选择线别\n", Color.Red, li_code);
-                    return;
-                }
                 //一个人只能同时一条线上线:若已在别的线体上线,先把原线体自动下线,再在新线体上线
                 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)
@@ -163,9 +175,19 @@ namespace UAS_MES_NEW.Query
                     em_code.Focus();
                     return;
                 }
+                //人员当前在线线体也必须在登录人长线范围内,否则不允许下线
+                string onLineCode = dtOn.Rows[0]["lm_linecode"].ToString();
+                if (dh.getFieldDataByCondition("line", "count(1)",
+                    "li_longline='" + User.UserCtCode + "' and li_code='" + onLineCode + "' and li_statuscode='AUDITED'").ToString() == "0")
+                {
+                    OperateResult.AppendText("<<" + emcode + "当前在" + onLineCode + "上线,该线别不在" + User.UserCtCode + "范围内,不允许下线\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 + " 已从"
-                    + dtOn.Rows[0]["lm_linecode"].ToString() + "下线\n", Color.Green, em_code);
+                    + onLineCode + "下线\n", Color.Green, em_code);
             }
             //数据变更后刷新
             LoadGridData();

+ 3 - 1
UAS_MES_YDCY/Login.cs

@@ -147,7 +147,7 @@ namespace UAS_MES_NEW
         private void SetInf()
         {
             //设置全局用户信息
-            string[] field = { "em_code,em_depart,em_type,em_name,em_position,em_professname,em_type,ug_code,ug_name" };
+            string[] field = { "em_code,em_depart,em_type,em_name,em_position,em_professname,em_type,ug_code,ug_name,em_ctcode" };
             UserInf = dh.getFieldsDataByCondition("Employee left join cs$userresource on ur_emcode=em_code left join cs$usergroup on ug_code=ur_groupcode", field, "upper(em_code)=:p0 or em_mobile=:p1", UserName.Text.ToUpper(), UserName.Text.ToUpper());
             DataTable dt = dh.getFieldsDataByCondition("source left join step on sc_stepcode=st_code left join line on sc_linecode=li_code", new string[] { "st_badgroupcode", "sc_wccode", "sc_code", "sc_stepcode", "sc_stepname", "sc_linecode", "LI_UPPERLINE" }, "upper(sc_code)=:p0", Source.Text.ToUpper());
             //存在岗位资源则要求添加
@@ -170,6 +170,8 @@ namespace UAS_MES_NEW
             User.UserAccountType = UserInf.Rows[0]["em_type"].ToString();
             User.UserGroupCode = UserInf.Rows[0]["ug_code"].ToString();
             User.UserGroup = UserInf.Rows[0]["ug_name"].ToString();
+            //登录员工的 em_ctcode 存到 User 全局
+            User.UserCtCode = UserInf.Rows[0]["em_ctcode"].ToString();
             //设置系统基础信息
             UserInf = (DataTable)dh.ExecuteSql("select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') as systime from dual", "select");
             SystemInf.LoginTime = UserInf.Rows[0]["systime"].ToString();