| | |
| | | using System.Data; |
| | | using System.Data.SqlClient; |
| | | using System.Threading.Tasks.Dataflow; |
| | | using Masuit.Tools; |
| | | using Masuit.Tools; |
| | | using NewPdaSqlServer.DB; |
| | | using NewPdaSqlServer.Dto.service; |
| | | using NewPdaSqlServer.entity; |
| | | using NewPdaSqlServer.entity.Base; |
| | | using NewPdaSqlServer.util; |
| | | using SqlSugar; |
| | | using System.Data; |
| | | using System.Data.SqlClient; |
| | | using System.Threading.Tasks.Dataflow; |
| | | |
| | | namespace NewPdaSqlServer.service.Wom; |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | public ProductionPickDto GetItemsByDaa001(WarehouseQuery query) |
| | | |
| | | /// <summary> |
| | | /// 获取库位信息 |
| | | /// </summary> |
| | | /// <param name="unity"></param> |
| | | /// <returns></returns> |
| | | /// <exception cref="Exception"></exception> |
| | | public dynamic GetBarKwByItem(dynamic unity) |
| | | { |
| | | return getDaa001(query); |
| | | if (unity == null) |
| | | throw new ArgumentNullException(nameof(unity), "参数对象不能为null"); |
| | | |
| | | if (string.IsNullOrEmpty(unity.itemId?.ToString())) |
| | | throw new ArgumentException("物料ID不能为空", nameof(unity.itemId)); |
| | | |
| | | try |
| | | { |
| | | var parameters = new List<SugarParameter> |
| | | { |
| | | new SugarParameter("@itemId",unity.itemId) |
| | | }; |
| | | |
| | | return Db.Ado.SqlQuery<dynamic>("EXEC prc_pda_scll_selBarMx @itemId", parameters); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw new Exception($"获取条码信息失败:{ex.Message}"); |
| | | } |
| | | |
| | | private ProductionPickDto getDaa001(WarehouseQuery query) |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 选取列表 |
| | | /// </summary> |
| | | /// <param name="unity"></param> |
| | | /// <param name="RequestInfo"></param> |
| | | /// <returns></returns> |
| | | public dynamic GetXcslDaa(dynamic unity, dynamic RequestInfo) |
| | | { |
| | | if (string.IsNullOrEmpty(query.daa001)) throw new Exception("工单号为空"); |
| | | |
| | | var wwgd = Db.Queryable<WwGd, MesItems>((a, i) => |
| | | new JoinQueryInfos(JoinType.Left, |
| | | a.Daa003 == i.ItemId)) |
| | | .Where((a, i) => a.Daa001 == query.daa001 && (a.PcSh ?? 0) == 1) |
| | | .Select((a, i) => new |
| | | var orgId = RequestInfo.OrgId; |
| | | var parameters = new List<SugarParameter> |
| | | { |
| | | a.Daa001, a.RwdGuid |
| | | }).First(); |
| | | new SugarParameter("@selectKey", unity.selectKey), |
| | | new SugarParameter("@inP1", orgId), // 可选参数 |
| | | new SugarParameter("@inP2", unity.selDaaType), // 可选参数 |
| | | new SugarParameter("@inP3", null), // 可选参数 |
| | | new SugarParameter("@inP4", null), // 可选参数 |
| | | // ...其他可选参数 |
| | | }; |
| | | var result = Db.Ado.SqlQuery<dynamic>("EXEC prc_pda_wwll_list @selectKey, @inP1, @inP2, @inP3, @inP4", parameters); |
| | | return result; |
| | | } |
| | | |
| | | if (wwgd?.Daa001 == null) throw new Exception("工单号不存在"); |
| | | |
| | | var womdabs = Db |
| | | .Queryable<WwGd, WwGdDetail, MesItems, ProductionOrderSub>( |
| | | (a, b, c, d) => |
| | | new JoinQueryInfos( |
| | | JoinType.Left, |
| | | a.Id == b.Pid, |
| | | JoinType.Inner, |
| | | c.Id == b.Dab003, |
| | | JoinType.Inner, b.Erpid.ToString() == d.ErpId |
| | | )) |
| | | .Where((a, b, c, d) => |
| | | a.Daa001 == query.daa001 && d.IssuingMethod == "1") |
| | | .Select((a, b, c, d) => new WwGdDetail |
| | | |
| | | /// <summary> |
| | | /// 选取列表 |
| | | /// </summary> |
| | | /// <param name="unity"></param> |
| | | /// <param name="RequestInfo"></param> |
| | | /// <returns></returns> |
| | | public dynamic GetWWCKsq(dynamic unity, dynamic RequestInfo) |
| | | { |
| | | Pid = b.Pid, |
| | | Dab003 = b.Dab003, |
| | | Dab006 = b.Dab006, |
| | | Dab007 = b.Dab007, |
| | | wNum = b.Dab006 - b.Dab007, // 计算字段 W_NUM |
| | | ItemName = c.ItemName, // 动态字段 ITEM_NAME |
| | | ItemNo = c.ItemNo // 动态字段 ITEM_NO |
| | | }) |
| | | .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 |
| | | var orgId = RequestInfo.OrgId; |
| | | var parameters = new List<SugarParameter> |
| | | { |
| | | ItemName = b.ItemName, |
| | | ItemNo = b.ItemNo, |
| | | ItemId = a.ItemId, |
| | | DepotId = a.DepotId, |
| | | WorkNo = a.WorkNo, |
| | | DepotName = c.DepotName, |
| | | Quantity = a.Quantity |
| | | }) |
| | | .ToList(); |
| | | new SugarParameter("@pi_selectKey", unity.selectKey), |
| | | new SugarParameter("@pi_type", unity.type), // 可选参数 |
| | | new SugarParameter("@pi_orgId", orgId), // 可选参数 |
| | | new SugarParameter("@inP1", null), // 可选参数 |
| | | new SugarParameter("@inP2", null), // 可选参数 |
| | | new SugarParameter("@inP3", null), // 可选参数 |
| | | new SugarParameter("@inP4", null), // 可选参数 |
| | | // ...其他可选参数 |
| | | }; |
| | | var result = Db.Ado.SqlQuery<dynamic>("EXEC prc_pda_wwcksq_list @pi_selectKey, @pi_type, @pi_orgId , @inP1, @inP2, @inP3, @inP4", parameters); |
| | | return result; |
| | | } |
| | | |
| | | var womcaa = Db.Queryable<ProductionOrder>() |
| | | .Where(s => s.Guid == wwgd.RwdGuid) |
| | | .First(); |
| | | |
| | | /// <summary> |
| | | /// 列表明细 |
| | | /// </summary> |
| | | /// <param name="query"></param> |
| | | /// <param name="RequestInfo"></param> |
| | | /// <returns></returns> |
| | | public dynamic GetItemsByDaa001(WarehouseQuery query, dynamic RequestInfo) |
| | | { |
| | | return getDaa001(query, RequestInfo); |
| | | } |
| | | |
| | | private dynamic getDaa001(WarehouseQuery query, dynamic RequestInfo) |
| | | { |
| | | if (string.IsNullOrEmpty(query.daa001)) throw new Exception("请选工单号!"); |
| | | if (query == null) |
| | | throw new ArgumentNullException(nameof(query), "参数对象不能为null"); |
| | | if (string.IsNullOrEmpty(query.daa001?.ToString())) |
| | | throw new ArgumentException("工单号不存在", nameof(query.daa001)); |
| | | |
| | | var orgId = RequestInfo.OrgId; |
| | | if (orgId == null) |
| | | throw new Exception("组织不存在!"); |
| | | |
| | | var parameters = new[] |
| | | { |
| | | new SugarParameter("@daa001", query.daa001), |
| | | new SugarParameter("@pi_orgId", orgId), |
| | | new SugarParameter("@inP1", null), |
| | | new SugarParameter("@inP2", null), |
| | | new SugarParameter("@inP3", null), |
| | | new SugarParameter("@inP4", null) |
| | | }; |
| | | try |
| | | { |
| | | List<dynamic>? blDetails = Db.Ado.SqlQuery<dynamic>( |
| | | "EXEC prc_pda_wwll_detailList @daa001,@pi_orgId,@inP1,@inP2,@inP3,@inP4", parameters); |
| | | var items = blDetails.Where(x => x.DSQty > 0).ToList(); // 待扫物料 |
| | | var ysitems = blDetails.Where(x => x.SQty > 0).ToList(); // 已扫物料 |
| | | var planNo = blDetails.FirstOrDefault()?.ErpProductionOrderNo?.ToString();// 获取工单计划号 |
| | | return new |
| | | { |
| | | daa001 = query.daa001, |
| | | PlanNo = planNo, |
| | | items = items, |
| | | ysitems = ysitems |
| | | }; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw new Exception($"{ex.Message}"); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 委外出库申请单号获取明细 |
| | | /// </summary> |
| | | /// <param name="query"></param> |
| | | /// <param name="RequestInfo"></param> |
| | | /// <returns></returns> |
| | | /// <exception cref="Exception"></exception> |
| | | /// <exception cref="ArgumentNullException"></exception> |
| | | /// <exception cref="ArgumentException"></exception> |
| | | public dynamic GetItemsByWwckNo(WarehouseQuery query, dynamic RequestInfo) |
| | | { |
| | | if (string.IsNullOrEmpty(query.daa001)) throw new Exception("请选工单号!"); |
| | | if (query == null) |
| | | throw new ArgumentNullException(nameof(query), "参数对象不能为null"); |
| | | if (string.IsNullOrEmpty(query.daa001?.ToString())) |
| | | throw new ArgumentException("工单号不存在", nameof(query.daa001)); |
| | | |
| | | var orgId = RequestInfo.OrgId; |
| | | if (orgId == null) |
| | | throw new Exception("组织不存在!"); |
| | | |
| | | var parameters = new[] |
| | | { |
| | | new SugarParameter("@daa001", query.daa001), |
| | | new SugarParameter("@pi_orgId", orgId), |
| | | new SugarParameter("@inP1", null), |
| | | new SugarParameter("@inP2", null), |
| | | new SugarParameter("@inP3", null), |
| | | new SugarParameter("@inP4", null) |
| | | }; |
| | | try |
| | | { |
| | | List<dynamic>? blDetails = Db.Ado.SqlQuery<dynamic>( |
| | | "EXEC prc_pda_wwcksq_detailList @daa001,@pi_orgId,@inP1,@inP2,@inP3,@inP4", parameters); |
| | | var items = blDetails.Where(x => x.DSQty > 0).ToList(); // 待扫物料 |
| | | var ysitems = blDetails.Where(x => x.SQty > 0).ToList(); // 已扫物料 |
| | | var planNo = blDetails.FirstOrDefault()?.ErpProductionOrderNo?.ToString();// 获取工单计划号 |
| | | return new |
| | | { |
| | | daa001 = query.daa001, |
| | | PlanNo = planNo, |
| | | items = items, |
| | | ysitems = ysitems, |
| | | allList = blDetails |
| | | }; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw new Exception($"{ex.Message}"); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// w委外出库 |
| | | /// </summary> |
| | | /// <param name="query"></param> |
| | | /// <returns></returns> |
| | | /// <exception cref="Exception"></exception> |
| | | public ProductionPickDto WwckScanCode(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_WWCK_SCAN]", 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) |
| | | //}; |
| | | |
| | | var parameters = new SqlParameter[] |
| | | { |
| | | new SqlParameter("@C_USER", SqlDbType.NVarChar, 100) { Value = query.userName ?? string.Empty }, |
| | | new SqlParameter("@P_BILL_NO", SqlDbType.NVarChar, 50) { Value = query.billNo ?? string.Empty }, |
| | | new SqlParameter("@P_ITEM_BARCODE", SqlDbType.NVarChar, 100) { Value = query.barcode ?? string.Empty }, |
| | | new SqlParameter("@P_BL_NO", SqlDbType.NVarChar, 100) { Value = query.blNo ?? string.Empty }, |
| | | new SqlParameter("@P_TYPE", SqlDbType.NVarChar, 20) { Value = query.Type ?? string.Empty }, |
| | | new SqlParameter("@OUT_MSG", SqlDbType.NVarChar, 2000) { Direction = ParameterDirection.Output }, |
| | | new SqlParameter("@OUT_SUM", SqlDbType.Int) { Direction = ParameterDirection.Output }, |
| | | new SqlParameter("@BARCODE_NUM", SqlDbType.Decimal) { |
| | | Direction = ParameterDirection.Output, |
| | | Precision = 18, |
| | | Scale = 10 |
| | | }, |
| | | new SqlParameter("@SPLIT_NUM", SqlDbType.Decimal) { |
| | | Direction = ParameterDirection.Output, |
| | | Precision = 18, |
| | | Scale = 10 |
| | | } |
| | | }; |
| | | |
| | | parameters[5].Direction = ParameterDirection.Output; |
| | | parameters[6].Direction = ParameterDirection.Output; |
| | | parameters[7].Direction = ParameterDirection.Output; |
| | | parameters[8].Direction = ParameterDirection.Output; |
| | | foreach (var parameter in parameters) |
| | | cmd.Parameters.Add(parameter); |
| | | cmd.ExecuteNonQuery(); |
| | | _strMsg = parameters[5].Value.ToString(); |
| | | _intSum = parameters[6].Value.ToString(); |
| | | |
| | | var barcodeNum = parameters[7].Value.ToString(); |
| | | var splitNum = parameters[8].Value.ToString(); |
| | | |
| | | var result = Convert.ToInt32(_intSum); |
| | | if (result <= 0) throw new Exception(_strMsg); |
| | | |
| | | var dto = new ProductionPickDto |
| | | { |
| | | daa001 = wwgd.Daa001, |
| | | PlanNo = womcaa.ErpProductionOrderNo, |
| | | totals1 = womdabs, |
| | | daisao1 = list, |
| | | yisao = mesInvItemOutCDetailsList |
| | | daa001 = query.daa001, |
| | | barcodeNum = barcodeNum, |
| | | splitNum = splitNum, |
| | | barcode = query.barcode, |
| | | strMsg = _strMsg, |
| | | result = _intSum |
| | | }; |
| | | |
| | | return dto; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw new Exception(ex.Message); |
| | | } |
| | | finally |
| | | { |
| | | conn.Close(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 委外拆分出库拆分 |
| | | /// </summary> |
| | | /// <param name="query"></param> |
| | | /// <returns></returns> |
| | | /// <exception cref="Exception"></exception> |
| | | public ProductionPickDto WwckScanCodeCF(WarehouseQuery query) |
| | | { |
| | | // Validate input parameters |
| | | if (string.IsNullOrEmpty(query.userName)) |
| | | throw new Exception("用户名不能为空!"); |
| | | |
| | | if (string.IsNullOrEmpty(query.barcode)) |
| | | throw new Exception("请扫描条码!"); |
| | | |
| | | if ((query.Num ?? 0) <= 0) |
| | | throw new Exception("请输入正确的发料数量!"); |
| | | |
| | | if (string.IsNullOrEmpty(query.blNo)) |
| | | throw new Exception("补料单号不能为空!"); |
| | | |
| | | // Prepare parameters for the stored procedure |
| | | var parameters = new List<SugarParameter> |
| | | { |
| | | new SugarParameter("@C_USER", query.userName), |
| | | new SugarParameter("@P_BILL_NO", query.billNo), |
| | | new SugarParameter("@P_ITEM_BARCODE", query.barcode), |
| | | new SugarParameter("@P_BL_NO", query.blNo), |
| | | new SugarParameter("@P_TYPE", query.Type), |
| | | new SugarParameter("@NUM", query.Num), |
| | | new SugarParameter("@OUT_MSG", "", System.Data.DbType.String, ParameterDirection.Output), |
| | | new SugarParameter("@OUT_SUM", 0, System.Data.DbType.Int32, ParameterDirection.Output), |
| | | new SugarParameter("@OUT_CF_BAR", "", System.Data.DbType.String, ParameterDirection.Output) |
| | | }; |
| | | |
| | | // Execute the stored procedure |
| | | Db.Ado.UseStoredProcedure().ExecuteCommand("PRC_PDA_WWCK_SCAN_CF", parameters); |
| | | |
| | | // Get output parameters |
| | | var outMsg = parameters.FirstOrDefault(p => p.ParameterName == "@OUT_MSG")?.Value?.ToString(); |
| | | var outSum = Convert.ToInt32(parameters.FirstOrDefault(p => p.ParameterName == "@OUT_SUM")?.Value ?? -1); |
| | | var outCfBar = parameters.FirstOrDefault(p => p.ParameterName == "@OUT_CF_BAR")?.Value?.ToString(); |
| | | |
| | | // Handle the result |
| | | if (outSum == -1) |
| | | { |
| | | throw new Exception(outMsg ?? "操作失败"); |
| | | } |
| | | |
| | | |
| | | var dto = new ProductionPickDto |
| | | { |
| | | daa001 = query.billNo, |
| | | barcode = query.barcode,//原条码 |
| | | cfBarcode = outCfBar//拆分后条码 |
| | | }; |
| | | |
| | | return dto; |