| | |
| | | using NewPdaSqlServer.service.@base; |
| | | using NewPdaSqlServer.util; |
| | | using SqlSugar; |
| | | using System.Text; |
| | | |
| | | namespace NewPdaSqlServer.service.Warehouse; |
| | | |
| | |
| | | // 返回成功信息 |
| | | return query; |
| | | } |
| | | |
| | | |
| | | public dynamic GetDepoptsInfo(dynamic unity) |
| | | { |
| | | |
| | | //// 使用参数化查询防止SQL注入 |
| | | var sqlParams = new List<SugarParameter> { new("@sectionCode", unity.sectionCode) }; |
| | | |
| | | var sql2 = @" SELECT TOP 1 B.depot_code + '('+B.depot_name+')' depotsInfo, |
| | | B.FSubsidiary, |
| | | C.FNumber + '('+C.NAME+')' orgInfo |
| | | FROM MES_DEPOT_SECTIONS A |
| | | LEFT JOIN |
| | | MES_DEPOTS B ON A.depot_guid = B.Guid |
| | | LEFT JOIN SYS_ORGANIZATION C ON C.FID = B.FSubsidiary |
| | | WHERE a.depot_section_code = @sectionCode;"; |
| | | |
| | | var XcslItem = Db.Ado.SqlQuery<dynamic>(sql2, sqlParams).FirstOrDefault(); |
| | | |
| | | // 检查结果有效性 |
| | | if (XcslItem == null) |
| | | { |
| | | throw new Exception($"库位 [{unity.sectionCode}] 不存在,或所属仓库状态异常(可能被禁用或删除)。"); |
| | | } |
| | | |
| | | return XcslItem; // 返回第一行数据,如果没有则返回 null |
| | | } |
| | | |
| | | |
| | | |
| | | public dynamic GetItemsList(dynamic unity) |
| | | { |
| | | var sqlParams = new List<SugarParameter> { new("@orgId", unity.orgId) }; |
| | | |
| | | var sql2 = new StringBuilder(@" |
| | | SELECT TOP 20 item_id, item_no, item_name, item_model,item_no+'---'+item_name AS wlInfo |
| | | FROM MES_ITEMS |
| | | WHERE FSubsidiary = @orgId"); |
| | | |
| | | if (!string.IsNullOrWhiteSpace(unity.selectKey?.ToString())) |
| | | { |
| | | sqlParams.Add(new("@selectKey", unity.selectKey)); |
| | | sql2.Append(@" |
| | | AND (item_no LIKE '%' + @selectKey + '%' |
| | | OR item_name LIKE '%' + @selectKey + '%' |
| | | OR item_model LIKE '%' + @selectKey + '%')"); |
| | | } |
| | | |
| | | var XcslItem = Db.Ado.SqlQuery<dynamic>(sql2.ToString(), sqlParams); |
| | | |
| | | if (XcslItem == null) |
| | | { |
| | | throw new Exception("该条件下无对应物料信息,请重新输入!"); |
| | | } |
| | | |
| | | return XcslItem; |
| | | } |
| | | } |