From e2988c27cb7e250d8834e3097b4821c7dbff6b64 Mon Sep 17 00:00:00 2001 From: 啊鑫 <t2856754968@163.com> Date: 星期二, 31 十二月 2024 13:01:20 +0800 Subject: [PATCH] 1 --- service/Warehouse/WomdaaManager.cs | 196 ++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 177 insertions(+), 19 deletions(-) diff --git a/service/Warehouse/WomdaaManager.cs b/service/Warehouse/WomdaaManager.cs index 8485ed1..3174d1a 100644 --- a/service/Warehouse/WomdaaManager.cs +++ b/service/Warehouse/WomdaaManager.cs @@ -1,4 +1,7 @@ -锘縰sing NewPdaSqlServer.DB; +锘縰sing System.Data; +using System.Data.SqlClient; +using Masuit.Tools; +using NewPdaSqlServer.DB; using NewPdaSqlServer.Dto.service; using NewPdaSqlServer.entity; using SqlSugar; @@ -24,6 +27,135 @@ //鏍规嵁宸ュ崟鍙疯繑鍥炰骇鍝佸瀷鍙峰拰寰呴鐗╂枡 public ProductionPickDto GetItemsByDaa001(WarehouseQuery query) { + return getDaa001(query); + } + + public ProductionPickDto ScanCode(WarehouseQuery query) + { + var _strMsg = ""; + var _intSum = ""; + using (var conn = new SqlConnection(DbHelperSQL.strConn)) + { + if (query.userName.IsNullOrEmpty()) throw new Exception("鐢ㄦ埛鍚嶄笉鍏佽涓虹┖"); + if (query.daa001.IsNullOrEmpty()) throw new Exception("棰嗘枡鍗曞彿涓嶅厑璁镐负绌�"); + if (query.barcode.IsNullOrEmpty()) throw new Exception("鏉$爜涓嶅厑璁镐负绌�"); + + using (var cmd = new SqlCommand("[prc_pda_SCLL]", conn)) + { + try + { + conn.Open(); + cmd.CommandType = CommandType.StoredProcedure; + SqlParameter[] parameters = + { + new("@outMsg", SqlDbType.NVarChar, 300), + new("@outSum", SqlDbType.NVarChar, 300), + new("@barcode_num", SqlDbType.NVarChar, 300), + new("@split_num", SqlDbType.NVarChar, 300), + new("@c_User", query.userName), + new("@p_biLL_no", query.daa001), + new("@p_item_barcode", query.barcode) + }; + parameters[0].Direction = ParameterDirection.Output; + parameters[1].Direction = ParameterDirection.Output; + parameters[2].Direction = ParameterDirection.Output; + parameters[3].Direction = ParameterDirection.Output; + foreach (var parameter in parameters) + cmd.Parameters.Add(parameter); + cmd.ExecuteNonQuery(); + _strMsg = parameters[0].Value.ToString(); + _intSum = parameters[1].Value.ToString(); + + var barcodeNum = parameters[2].Value.ToString(); + var splitNum = parameters[3].Value.ToString(); + + var result = Convert.ToInt32(_intSum); + if (result <= 0) throw new Exception(_strMsg); + + var dto = new ProductionPickDto + { + daa001 = query.daa001, + barcodeNum = barcodeNum, + splitNum = splitNum, + barcode = query.barcode + }; + + return dto; + } + catch (Exception ex) + { + throw new Exception(ex.Message); + } + finally + { + conn.Close(); + } + } + } + } + + //prC_pda_SCLL_CF + public ProductionPickDto ScanCodeCF(WarehouseQuery query) + { + if (query.userName.IsNullOrEmpty()) throw new Exception("鐢ㄦ埛鍚嶄笉鍏佽涓虹┖"); + if (query.daa001.IsNullOrEmpty()) throw new Exception("棰嗘枡鍗曞彿涓嶅厑璁镐负绌�"); + if (query.barcode.IsNullOrEmpty()) throw new Exception("鏉$爜涓嶅厑璁镐负绌�"); + + if (query.Num is null or 0) throw new Exception("鏉$爜鎷嗗垎鏁颁笉鍏佽涓虹┖鎴栬�呬负0"); + + var _strMsg = ""; + var _intSum = ""; + using (var conn = new SqlConnection(DbHelperSQL.strConn)) + { + using (var cmd = new SqlCommand("[prc_pda_SCLL_CF]", conn)) + { + try + { + conn.Open(); + cmd.CommandType = CommandType.StoredProcedure; + SqlParameter[] parameters = + { + new("@outMsg", SqlDbType.NVarChar, 300), + new("@outSum", SqlDbType.NVarChar, 300), + new("@c_User", query.userName), + new("@p_biLL_no", query.daa001), + new("@p_item_barcode", query.barcode), + new("@num", query.Num) + }; + parameters[0].Direction = ParameterDirection.Output; + parameters[1].Direction = ParameterDirection.Output; + foreach (var parameter in parameters) + cmd.Parameters.Add(parameter); + cmd.ExecuteNonQuery(); + _strMsg = parameters[0].Value.ToString(); + _intSum = parameters[1].Value.ToString(); + + + var result = Convert.ToInt32(_intSum); + if (result <= 0) throw new Exception(_strMsg); + + var dto = new ProductionPickDto + { + daa001 = query.daa001, + barcode = query.barcode + }; + + return dto; + } + catch (Exception ex) + { + throw new Exception(ex.Message); + } + finally + { + conn.Close(); + } + } + } + } + + private ProductionPickDto getDaa001(WarehouseQuery query) + { if (string.IsNullOrEmpty(query.daa001)) throw new Exception("宸ュ崟鍙蜂负绌�"); var womdaa = Db.Queryable<Womdaa, MesItems>((a, i) => @@ -32,22 +164,24 @@ .Where((a, i) => a.Daa001 == query.daa001) .Select((a, i) => new { - i.ItemModel + a.Daa001, a.CaaGuid }).First(); - if (womdaa?.ItemModel == null) throw new Exception("宸ュ崟鍙蜂笉瀛樺湪"); - - var womdabs = Db.Queryable<Womdaa, Womdab, MesItems>((a, b, c) => - new JoinQueryInfos( - JoinType.Left, - a.Id == b.Pid, - JoinType.Inner, - c.Id.ToString() == - b.Dab003 - )) - .Where((a, b, c) => - a.Daa001 == query.daa001) - .Select((a, b, c) => new Womdab + if (womdaa?.Daa001 == null) throw new Exception("宸ュ崟鍙蜂笉瀛樺湪"); + + var womdabs = Db.Queryable<Womdaa, Womdab, MesItems, Womcab>( + (a, b, c, d) => + new JoinQueryInfos( + JoinType.Left, + a.Guid == b.DaaGuid, + JoinType.Inner, + c.Id.ToString() == + b.Dab003, + JoinType.Inner, b.Erpid == d.Erpid + )) + .Where((a, b, c, d) => + a.Daa001 == query.daa001 && d.IssueType == "1") + .Select((a, b, c, d) => new Womdab { Pid = b.Pid, Dab003 = b.Dab003, @@ -59,15 +193,39 @@ }) .ToList(); - var list = womdabs.Where(s=>s.wNum > 0).ToList(); + var list = womdabs.Where(s => s.wNum > 0).ToList(); + + var mesInvItemOutCDetailsList = Db + .Queryable<MesInvItemOutCDetails, MesItems, MesDepots> + ((a, b, c) => + new JoinQueryInfos( + JoinType.Inner, a.ItemId == b.Id, + JoinType.Inner, c.DepotId == a.DepotId + )) + .Where((a, b, c) => a.WorkNo == query.daa001) + .Select((a, b, c) => new MesInvItemOutCDetails + { + ItemName = b.ItemName, + ItemNo = b.ItemNo, + ItemId = a.ItemId, + DepotId = a.DepotId, + WorkNo = a.WorkNo, + DepotName = c.DepotName, + Quantity = a.Quantity + }) + .ToList(); + + var womcaa = Db.Queryable<Womcaa>().Where(s => s.Guid == womdaa.CaaGuid) + .First(); var dto = new ProductionPickDto { - ItemModel = womdaa.ItemModel, + daa001 = womdaa.Daa001, + PlanNo = womcaa.Caa020, totals = womdabs, - daisao = list + daisao = list, + yisao = mesInvItemOutCDetailsList }; - return dto; } -- Gitblit v1.9.3