| | |
| | | using System.Data; |
| | | using System.Data.SqlClient; |
| | | 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 |
| | | { |
| | | a.Daa001, a.RwdGuid |
| | | }).First(); |
| | | |
| | | 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 |
| | | { |
| | | 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 |
| | | { |
| | | 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<ProductionOrder>() |
| | | .Where(s => s.Guid == wwgd.RwdGuid) |
| | | .First(); |
| | | |
| | | var dto = new ProductionPickDto |
| | | var orgId = RequestInfo.OrgId; |
| | | var parameters = new List<SugarParameter> |
| | | { |
| | | daa001 = wwgd.Daa001, |
| | | PlanNo = womcaa.ErpProductionOrderNo, |
| | | totals1 = womdabs, |
| | | daisao1 = list, |
| | | yisao = mesInvItemOutCDetailsList |
| | | 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; |
| | | } |
| | | |
| | | return dto; |
| | | /// <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}"); |
| | | } |
| | | } |
| | | |
| | | #region 委外退料 |
| | |
| | | |
| | | // 创建 插入日志 |
| | | var logService = new LogService(); |
| | | var LogMsg = "委外退料。条码【" + query.barcode + "】 退料单号【" + c_bill_no + "】"; |
| | | var LogMsg = "[PDA]委外退料。条码【" + query.barcode + "】 退料单号【" + c_bill_no + "】"; |
| | | logService.CreateLog(db, query.userName, wwgd.Id.ToString(), "WW_GD", LogMsg, wwgd.Daa001); |
| | | |
| | | return totalResult; |
| | |
| | | // 获取补料单明细并校验 |
| | | var blDetail = Db.Queryable<MesItemBlDetail>() |
| | | .Where(b => |
| | | b.Mid == mesItemBl.Id && b.Bld012 == stockBarcode.ItemId) |
| | | b.Mid == mesItemBl.Id && b.Bld012 == stockBarcode.ItemId && b.Bld007 > b.Bld008) |
| | | .First(); |
| | | |
| | | if (blDetail == null) |
| | |
| | | ErpAutoid = womdab.Erpid, |
| | | PbillNo = query.billNo, |
| | | ItemId = blDetail.Bld012, |
| | | DepotId = stockBarcode.DepotsId.ToString(), |
| | | ItemDabid = womdab.Id, |
| | | DepotId = stockBarcode.DepotId.ToString(), |
| | | ItemDabid = blDetail.Id, |
| | | //AboutGuid = womdab.Id |
| | | // Unit = blDetail.Bld009, |
| | | // DepotId = (int)stockBarcode.DepotsId |
| | | }).IgnoreColumns(true).ExecuteCommand(); |
| | |
| | | PbillNo = query.billNo, |
| | | ItemId = blDetail.Bld012, |
| | | Unit = blDetail.Bld009, |
| | | DepotId = (int)stockBarcode.DepotsId, |
| | | DepotId = (int)stockBarcode.DepotId, |
| | | EbelnK3id = womdab.Eid, |
| | | LineK3id = womdab.Erpid |
| | | }).IgnoreColumns(true).ExecuteCommand(); |
| | |
| | | |
| | | // 创建 插入日志 |
| | | var logService = new LogService(); |
| | | var LogMsg = query.Type + "。条码【" +query.barcode+"】 补料单号【"+ outNo +"】"; |
| | | var LogMsg = "[PDA]"+query.Type + "。条码【" +query.barcode+"】 数量【"+ stockBarcode.Quantity.ToString() + "】 出库单号【"+ outNo +"】"; |
| | | logService.CreateLog(db,query.userName,wwgd.Id.ToString(), "WW_GD", LogMsg,wwgd.Daa001); |
| | | |
| | | return 1; |