From a5019b475f8620dba3b495da983f4db9e32f7ca8 Mon Sep 17 00:00:00 2001 From: 啊鑫 <t2856754968@163.com> Date: 星期四, 10 七月 2025 08:18:36 +0800 Subject: [PATCH] AOI --- MES.Service/service/Warehouse/OrganizeService.cs | 58 ++++++++++++++++------------------------------------------ 1 files changed, 16 insertions(+), 42 deletions(-) diff --git a/MES.Service/service/Warehouse/OrganizeService.cs b/MES.Service/service/Warehouse/OrganizeService.cs index 817525d..8929dd2 100644 --- a/MES.Service/service/Warehouse/OrganizeService.cs +++ b/MES.Service/service/Warehouse/OrganizeService.cs @@ -1,4 +1,5 @@ 锘縰sing System.Data; +using System.Dynamic; using MES.Service.DB; using MES.Service.Dto.service; using MES.Service.Modes; @@ -28,10 +29,7 @@ var printCommandResult = Db.Queryable<MesBarcodeType>() .Where(t => t.TypeCode == 108) .First(); - if (printCommandResult == null) - { - throw new Exception("妯$増ID涓虹┖锛岃璁剧疆鎵撳嵃鏍煎紡锛�"); - } + if (printCommandResult == null) throw new Exception("妯$増ID涓虹┖锛岃璁剧疆鎵撳嵃鏍煎紡锛�"); var cPrintCommand = printCommandResult.Mbtype; var cBid = printCommandResult.Id; @@ -41,40 +39,21 @@ s.ItemNo == query.ItemNo && s.Factory == "1000" && s.Company == "1000") .First(); - if (cMesItems == null) - { - throw new Exception("鐗╂枡淇℃伅涓嶅瓨鍦ㄨ鐗╂枡缂栫爜锛岃缁存姢锛�"); - } + if (cMesItems == null) throw new Exception("鐗╂枡淇℃伅涓嶅瓨鍦ㄨ鐗╂枡缂栫爜锛岃缁存姢锛�"); - if (string.IsNullOrEmpty(query.ItemNo)) - { - throw new Exception("璇峰綍鍏ョ墿鏂欑紪鐮�"); - } + if (string.IsNullOrEmpty(query.ItemNo)) throw new Exception("璇峰綍鍏ョ墿鏂欑紪鐮�"); if (string.IsNullOrEmpty(query.ItemModel)) - { throw new Exception("璇疯緭鍏ュ畬鐗╂枡缂栫爜鍚庯紝鐐瑰嚮纭鐢熸垚瑙勬牸锛�"); - } - if (string.IsNullOrEmpty(query.OrgName)) - { - throw new Exception("璇峰綍鍏ョ粍缁�"); - } + if (string.IsNullOrEmpty(query.OrgName)) throw new Exception("璇峰綍鍏ョ粍缁�"); - if (string.IsNullOrEmpty(query.OrgOwner)) - { - throw new Exception("璇峰綍鍏ヨ揣涓�"); - } + if (string.IsNullOrEmpty(query.OrgOwner)) throw new Exception("璇峰綍鍏ヨ揣涓�"); - if (string.IsNullOrEmpty(query.ItemNum)) - { - throw new Exception("璇峰綍鍏ョ墿鏂欐暟閲�"); - } + if (string.IsNullOrEmpty(query.ItemNum)) throw new Exception("璇峰綍鍏ョ墿鏂欐暟閲�"); if (string.IsNullOrEmpty(query.Printnumn)) - { throw new Exception("璇峰綍鍏ユ潯鐮佹暟閲�"); - } var cId = Db.Ado.GetInt( @@ -89,7 +68,7 @@ .Where(it => it.CreateDate < DateTime.Now.AddDays(-10)) .ExecuteCommand(); - for (int i = 1; i <= int.Parse(query.Printnumn); i++) + for (var i = 1; i <= int.Parse(query.Printnumn); i++) { var cIndate = DateTime.Now.ToString("yyyyMMdd"); @@ -104,12 +83,12 @@ query.ItemNo + cIndate, query.ItemNo + cIndate, 0); serial = barcodeResult.Value; poBarcodeComand = barcodeResult.Msg; - if (!string.IsNullOrEmpty(poBarcodeComand)) - { - return null; - } + if (!string.IsNullOrEmpty(poBarcodeComand)) return null; - cBarcode2 = "9" + serial.Substring(1); + if (string.IsNullOrEmpty(serial)) + cBarcode2 = "9"; + else + cBarcode2 = "9" + serial[1..]; itemBarcode = query.ItemNo + cIndate + cBarcode2; } else @@ -128,10 +107,7 @@ query.ItemNo + cIndate, query.ItemNo + cIndate, 0); serial = barcodeResult.Value; poBarcodeComand = barcodeResult.Msg; - if (!string.IsNullOrEmpty(poBarcodeComand)) - { - return null; - } + if (!string.IsNullOrEmpty(poBarcodeComand)) return null; cBarcode2 = "9" + serial.Substring(1); itemBarcode = query.ItemNo + cIndate + @@ -148,7 +124,6 @@ s.Company == "1000") .Count(); if (cCount == 0) - { // Insert new barcode Db.Insertable(new MesInvItemBarcodes { @@ -167,7 +142,6 @@ OrgName = query.OrgName, OrgOwner = query.OrgOwner }).ExecuteCommand(); - } // Insert record into MES_RF_PRNBARCODE Db.Insertable(new MesRfPrnbarcode @@ -189,7 +163,7 @@ Strp11 = poBarcode, Strp12 = query.ItemName ?? " ", Strp15 = query.OrgName ?? " ", - Strp16 = query.OrgOwner ?? " ", + Strp16 = query.OrgOwner ?? " " }).ExecuteCommand(); } @@ -247,7 +221,7 @@ var resultValue = outputResult.Value?.ToString(); var messageValue = outputMessage.Value?.ToString(); - dynamic m = new System.Dynamic.ExpandoObject(); + dynamic m = new ExpandoObject(); m.Value = resultValue; m.Msg = messageValue; -- Gitblit v1.9.3