Przeglądaj źródła

添加备品出货逻辑

callm 2 dni temu
rodzic
commit
aa5923221f

+ 24 - 0
UAS_MES_YDCY/.workbuddy/memory/2026-10-29.md

@@ -0,0 +1,24 @@
+# 2026-10-29
+
+## Warehouse_FinishedProductOutSumNEW:新增「备品出货」选项
+- 需求:不动原有任何逻辑;新增备品出货单选,扫一个序列号记一个,料号取明细中点选的行,只卡控扫描数量。
+- Designer(+16):`spareBtn`(RadioButton,"备品出货",(330,923),12F,Click+=serBtn_Click),与 palletBtn/bigboxBtn 同在 Form 级容器 → 三者互斥。
+- .cs(+45):
+  1. `serBtn_Click` 加 spareBtn 提示分支;
+  2. `input_KeyDown` 备货分支(`!cancel.Checked` 内)的 else 前插 `else if (spareBtn.Checked)`——不影响 pallet/bigbox/cancel 任何分支。
+- 备品分支逻辑:
+  - 必须已选出货单(pi_inoutno)且已在 `Prodiodetail_CellClick` 点选明细行(复用成员变量 `PDID`/`pdprodcode`/`custpo`/`custpodetno`/`pdcustprodcode`,PDID=="0" 视为未点选);
+  - 判重:`prodiomac count where pim_inoutno=单号 and pim_mac=SN` !=0 → 已采集拦截;
+  - 数量卡控:`pd_outqty`(按 `pd_id=PDID`)vs 该明细已扫数 `(select count(1) from prodiomac where pim_pdid=PDID)`,已扫 >= 出货数 → 拦截;
+  - 落库:insert `prodiomac`,**pim_type='SN'**(新类型,区别于 PALLET/BOX),pim_outboxcode 空串,pim_class='出货',pim_inorout='OUT',带 pim_pdid/pim_custpo/pim_custdetno/pim_custprodcode;
+  - `update makeserial set ms_outno=单号 where ms_sncode=SN and ms_outno is null`(SN 不在系统内影响 0 行,不拦截记录);
+  - DoCommandLog + 绿字提示。
+- ⚠️ 遗留说明(已告知用户):备品 SN 的单独「取消备货」入口未做(用户未要求);`Clean_Click`(清除全部明细)会连带清掉 SN 记录。
+- Load 事件被用户改动过(LoadGridData() 调用已不在 Load 里),勿按旧记忆还原。
+
+## 追加:取消备货里补「取消备品」分支
+- 取消备货(`cancel.Checked`)分支原只有 栈板/箱 两个 else-if,备品 SN 扫进去会落到「未选择录入数据类型」。
+- 新增 `else if (spareBtn.Checked)`:按 `pim_inoutno + pim_mac + pim_type='SN' + pim_inorout='OUT' + pim_class='出货'` 查 prodiomac,查不到拦「不在备货数据中」;查到则 delete 该记录 + `update makeserial set ms_outno='' where ms_sncode=SN and ms_outno=单号`(影响 0 行不拦)+ DoCommandLog + 黑字提示含料号(取自查到的 pim_prodcode)。
+- 取消备品**不要求点选明细料号行**(与采集不同),不需要 PDID;已出库拦截沿用外层公共判断。
+- `serBtn_Click` 的 spareBtn 提示按 `cancel.Checked` 区分:取消模式提示「请扫描需取消的备品序列号」。
+- 自检:括号平衡 209/209、925/925、272/272 ✅。

+ 16 - 0
UAS_MES_YDCY/FunctionCode/Warehouse/Warehouse_FinishedProductOutSumNEW.Designer.cs

@@ -52,6 +52,7 @@
             this.Combine = new System.Windows.Forms.RadioButton();
             this.palletBtn = new System.Windows.Forms.RadioButton();
             this.bigboxBtn = new System.Windows.Forms.RadioButton();
+            this.spareBtn = new System.Windows.Forms.RadioButton();
             this.pi_id = new System.Windows.Forms.Label();
             this.pi_type = new System.Windows.Forms.Label();
             this.bindingSource = new System.Windows.Forms.BindingSource(this.components);
@@ -379,6 +380,19 @@
             this.bigboxBtn.Text = "箱号";
             this.bigboxBtn.UseVisualStyleBackColor = true;
             this.bigboxBtn.Click += new System.EventHandler(this.serBtn_Click);
+            //
+            // spareBtn
+            //
+            this.spareBtn.AutoSize = true;
+            this.spareBtn.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.spareBtn.Location = new System.Drawing.Point(330, 923);
+            this.spareBtn.Margin = new System.Windows.Forms.Padding(4);
+            this.spareBtn.Name = "spareBtn";
+            this.spareBtn.Size = new System.Drawing.Size(155, 45);
+            this.spareBtn.TabIndex = 275;
+            this.spareBtn.Text = "备品出货";
+            this.spareBtn.UseVisualStyleBackColor = true;
+            this.spareBtn.Click += new System.EventHandler(this.serBtn_Click);
             // 
             // pi_id
             // 
@@ -1133,6 +1147,7 @@
             this.Controls.Add(this.cancel);
             this.Controls.Add(this.input);
             this.Controls.Add(this.bigboxBtn);
+            this.Controls.Add(this.spareBtn);
             this.Controls.Add(this.palletBtn);
             this.Controls.Add(this.InOutDetailDGV);
             this.Controls.Add(this.panel1);
@@ -1171,6 +1186,7 @@
         private CustomControl.DataGrid_View.DataGridViewWithSerialNum InOutDetailDGV;
         private System.Windows.Forms.RadioButton palletBtn;
         private System.Windows.Forms.RadioButton bigboxBtn;
+        private System.Windows.Forms.RadioButton spareBtn;
         private CustomControl.TextBoxWithIcon.SnCollectionBox input;
         private CustomControl.CustomCheckBox.CustomCheckBox cancel;
         private CustomControl.ButtonUtil.NormalButton Clean;

+ 62 - 0
UAS_MES_YDCY/FunctionCode/Warehouse/Warehouse_FinishedProductOutSumNEW.cs

@@ -811,6 +811,46 @@ namespace UAS_MES_NEW.Warehouse
                                 LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, pa_makecode, User.UserLineCode, User.UserSourceCode, "箱号" + input.Text + "出货备货", "箱号" + input.Text + "出货备货成功", input.Text, "");
                             }
                         }
+                        else if (spareBtn.Checked)
+                        {
+                            //备品出货:扫一个序列号记一个,料号取明细中点选的行,只卡控数量
+                            if (pi_inoutno.Text == "")
+                            {
+                                OperateResult.AppendText("请先选择出货单\n", Color.Red, input);
+                                return;
+                            }
+                            if (PDID == "0" || pdprodcode == "")
+                            {
+                                OperateResult.AppendText("请先在出货明细中点选备品对应的料号行\n", Color.Red, input);
+                                return;
+                            }
+                            //同一出货单下不重复采集
+                            if (dh.getFieldDataByCondition("prodiomac", "count(1)", "pim_inoutno='" + pi_inoutno.Text + "' and pim_mac='" + input.Text + "'").ToString() != "0")
+                            {
+                                OperateResult.AppendText("序列号" + input.Text + "已采集过,不允许重复采集\n", Color.Red, input);
+                                return;
+                            }
+                            //数量卡控:该明细行已扫数达到出货数则不允许继续扫
+                            sql.Clear();
+                            sql.Append("select nvl(pd_outqty,0)pd_outqty,(select count(1) from prodiomac where pim_inoutno='" + pi_inoutno.Text + "' and pim_pdid='" + PDID + "')getqty from prodiodetail where pd_id='" + PDID + "'");
+                            dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
+                            if (dt.Rows.Count == 0)
+                            {
+                                OperateResult.AppendText("所选明细已被清除,请重新点选料号行\n", Color.Red, input);
+                                return;
+                            }
+                            if (int.Parse(dt.Rows[0]["getqty"].ToString()) >= int.Parse(dt.Rows[0]["pd_outqty"].ToString()))
+                            {
+                                OperateResult.AppendText("料号" + pdprodcode + "已扫" + dt.Rows[0]["getqty"].ToString() + ",达到出货数" + dt.Rows[0]["pd_outqty"].ToString() + ",不允许继续采集\n", Color.Red, input);
+                                return;
+                            }
+                            dh.ExecuteSql("insert into prodiomac(pim_id,pim_inoutno,pim_piid,pim_prodcode,pim_mac,pim_indate,pim_inman,pim_type,pim_outboxcode,pim_inorout,pim_class,pim_custpo,pim_custdetno,pim_pdid,pim_custprodcode)" +
+                                "values(prodiomac_seq.nextval,'" + pi_inoutno.Text + "','" + pi_id.Text + "','" + pdprodcode + "','" + input.Text + "',sysdate,'" + User.UserCode + "','SN','','OUT','出货','" + custpo + "','" + custpodetno + "','" + PDID + "','" + pdcustprodcode + "')", "insert");
+                            //序列号在系统内则记出货单号,不在也不影响记录
+                            dh.ExecuteSql("update makeserial set ms_outno='" + pi_inoutno.Text + "' where ms_sncode='" + input.Text + "' and ms_outno is null", "update");
+                            LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, "", User.UserLineCode, User.UserSourceCode, "备品序列号" + input.Text + "出货备货", "备品序列号" + input.Text + "出货备货成功,料号" + pdprodcode, input.Text, "");
+                            OperateResult.AppendText("序列号" + input.Text + "备品出货采集成功,料号" + pdprodcode + "\n", Color.Green, input);
+                        }
                         else
                         {
                             OperateResult.AppendText("未选择录入数据类型\n", Color.Red, input);
@@ -948,6 +988,20 @@ namespace UAS_MES_NEW.Warehouse
                                 return;
                             }
                         }
+                        else if (spareBtn.Checked)
+                        {
+                            //取消备品:按序列号删除该出货单下的备品采集记录
+                            DataTable dtSpare = (DataTable)dh.ExecuteSql("select pim_prodcode from prodiomac where pim_inoutno='" + pi_inoutno.Text + "' and pim_mac='" + input.Text + "' and pim_type='SN' and pim_inorout='OUT' and pim_class='出货'", "select");
+                            if (dtSpare.Rows.Count == 0)
+                            {
+                                OperateResult.AppendText("序列号" + input.Text + "不在出货单" + pi_inoutno.Text + "的备货数据中,无法取消\n", Color.Red, input);
+                                return;
+                            }
+                            dh.ExecuteSql("delete from prodiomac where pim_inoutno='" + pi_inoutno.Text + "' and pim_mac='" + input.Text + "' and pim_type='SN' and pim_inorout='OUT' and pim_class='出货'", "delete");
+                            //序列号在系统内则清掉出货单号,不在也不影响
+                            OperateResult.AppendText("序列号" + input.Text + "取消备货成功,料号" + dtSpare.Rows[0]["pim_prodcode"].ToString() + "\n", Color.Black, input);
+                            LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, "", User.UserLineCode, User.UserSourceCode, "备品序列号" + input.Text + "取消出货备货", "备品序列号" + input.Text + "取消出货备货成功,料号" + dtSpare.Rows[0]["pim_prodcode"].ToString(), input.Text, "");
+                        }
                         else
                         {
                             OperateResult.AppendText("未选择录入数据类型\n", Color.Red, input);
@@ -1107,6 +1161,14 @@ namespace UAS_MES_NEW.Warehouse
                     input.Focus();
                     OperateResult.AppendText("请输入栈板进行采集\n", Color.Black, input);
                 }
+                else if (((RadioButton)sender).Name == "spareBtn")
+                {
+                    input.Focus();
+                    if (cancel.Checked)
+                        OperateResult.AppendText("请扫描需取消的备品序列号\n", Color.Black, input);
+                    else
+                        OperateResult.AppendText("请先在出货明细中点选备品料号行,再扫描序列号采集\n", Color.Black, input);
+                }
             }
         }