using Gs.Entity.BaseInfo; using Gs.Entity.QC; using Gs.Toolbox; using Gs.Toolbox.ApiCore.Abstract.Mvc; using Gs.Toolbox.ApiCore.Common.Mvc; using Gs.Toolbox.ApiCore.Group; using Gs.Warehouse.Models; using Microsoft.AspNetCore.Http; using Newtonsoft.Json.Linq; using SqlSugar; namespace Gs.Warehouse.Services; [ApiGroup(ApiGroupNames.PerMission)] //采购到货单明细表 public class MesInvItemArnDetailManager : Repository, IRomteService { private readonly IHttpContextAccessor _http; private readonly string _userCode,_userGuid,_orgFids; public MesInvItemArnDetailManager(IHttpContextAccessor httpContextAccessor) { _http = httpContextAccessor; (_userCode, _userGuid, _orgFids) = UtilityHelper.GetUserGuidAndOrgGuid(_http); } /// /// 根据用户选择的采购明细guid,读取需要作入库到货单的明细 /// /// /// [RequestMethod(RequestMethods.POST)] public ReturnDto> GetListPageByCgmxGuid( JArray guidList) { var intArray = guidList.ToObject(); var _lst = new List(); var mesRohInDatas = Db.Queryable((a, b) => new object[] { JoinType.Left, a.ItemId == b.Id.ToString(), }).Select((a, b) => new MesRohInData() { itemModel = b.ItemModel, itemNo = b.ItemNo, itemName = b.ItemName, }, true).In("a.Guid", intArray).ToList(); try { foreach (var _ddd in mesRohInDatas) //把采购单的数据,附加给采购到货单 //需要这些:采购时间,采购单号,采购单行号,物料编码,物料名称,物料规格,采购订单数量,本次应收数量,本次实收数量 ,采购单位,库存单位,采购订单id,采购订单行id, _lst.Add(new MesInvItemArnDetail { Guid = null, ParentGuid = null, AboutGuid = _ddd.Guid, Ebeln = _ddd.BillNo, //EbelnLine = string.IsNullOrEmpty(_ddd.OrderLineId) ? 0 : int.Parse(_ddd.OrderLineId), // ItemNo = _ddd.ItemId, ItemId = int.Parse(_ddd.ItemId), EbelnQty = _ddd.PurchaseQty, SubQty = _ddd.RemainingReceivedQty, EbelnK3id = _ddd.EbelnK3id, EbelnLine = null, Quantity = 0, CreateBy = null, CreateDate = null, LastupdateBy = null, LastupdateDate = null, Factory = null, Company = null, LineK3id = null, MarginQty = null, WorkNo = null, UrgentFlag = false, Memo = null, CheckRes = null, CheckStates = null, QuantityM = null, SubMqty = null, CheckDate = null, Ischeck = null, OkQty = null, OkMqty = null, BoardStyle = null, WorkLine = null, FType = null, IsdepsIn = false, Dha001 = null, OkRkqty = null, CbillNo = null, CgRkqty = null, ReturnFlag = 0, States = null, itemModel = _ddd.itemModel, itemName = _ddd.itemName, ItemNo = _ddd.itemNo, }); } catch (Exception ex) { LogHelper.Debug(ToString(), ex.Message); } return ReturnDto>.QuickReturn(_lst, ReturnCode.Success, "读取成功"); } }