| | |
| | | using System.Net.NetworkInformation; |
| | | using Tiger.Model.MES.Yada; |
| | | using static Microsoft.CodeAnalysis.CSharp.SyntaxTokenParser; |
| | | using Tiger.Model.Minsun; |
| | | |
| | | namespace Tiger.Business.MES |
| | | { |
| | |
| | | /// </summary> |
| | | /// <param name="wo"></param> |
| | | /// <returns></returns> |
| | | public async Task<ApiAction> GetShipList(string wo, string orgCode) |
| | | public async Task<ApiAction<ShippingOutput>> GetShipList(ShippingInput input) |
| | | { |
| | | var result = new ApiAction(); |
| | | var result = new ApiAction<ShippingOutput>(); |
| | | try |
| | | { |
| | | DbClient db = Biz.DataSource["YadaU9C"].Client; |
| | | var org = await Biz.Db.Queryable<SYS_ORGANIZATION>().Where(q=>q.ORG_CODE == orgCode).FirstAsync(); |
| | | var shipList = db.Queryable<mes_ShipList>().Where(q => q.MoDoc.Equals(wo) && SqlFunc.DateIsSame(q.BusinessDate, DateTime.Now) && q.Status == 2 && q.Org == org.ID.ToInt64()).ToList(); |
| | | if (shipList.Any()) |
| | | var org = await Biz.Db.Queryable<SYS_ORGANIZATION>().Where(q => q.ORG_CODE == input.orgCode).FirstAsync(); |
| | | string wo = input.wo; |
| | | if (!input.SN.IsNullOrEmpty() && input.wo.IsNullOrEmpty()) { |
| | | var woSn = Biz.Db.Queryable<BIZ_MES_WO_SN>().Where(q => q.SN == input.SN || q.FLOW_SN == input.SN).First(); |
| | | if (!woSn.IsNullOrEmpty()) { |
| | | wo = woSn.WORK_ORDER; |
| | | } |
| | | } |
| | | var ship = db.Queryable<mes_ShipList>().Where(q => q.MoDoc.Equals(wo) && q.Org == org.ID.ToInt64()).First(); |
| | | if (!ship.IsNullOrEmpty()) |
| | | { |
| | | result.Data = shipList[0].ShipQty; |
| | | result.Data = ship.BusinessDate.Date == DateTime.Now.Date ? new() |
| | | { |
| | | ShipDoc = ship.ShipDoc, |
| | | ShippingQty = ship.ShipQty, |
| | | Tag = "Customer" |
| | | } : new() |
| | | { |
| | | ShipDoc = ship.ShipDoc, |
| | | ShippingQty = ship.ShipQty, |
| | | Tag = "InStoreLabel" |
| | | }; |
| | | result.LocaleMsg = new($"出货信息存在!"); |
| | | } |
| | | else |
| | | { |
| | | result.Data = "InStoreLabel"; |
| | | result.Data = new() |
| | | { |
| | | ShipDoc = "", |
| | | ShippingQty = 0, |
| | | Tag = "InStoreLabel" |
| | | }; |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 生成入库获取条码工单信息及包装信息 |
| | | /// </summary> |
| | | /// <param name="code"></param> |
| | | /// <returns></returns> |
| | | public async Task<ApiAction<InStoreInfo>> GetErpProdInBth(string code) |
| | | { |
| | | var result = new ApiAction<InStoreInfo>(); |
| | | try |
| | | { |
| | | //得到工单条码记录 |
| | | var woSns = await Biz.Db.Queryable<BIZ_MES_WO_SN>().Where(q => q.OUTER_SN == code).ToListAsync(); |
| | | if (woSns.Count == 0) |
| | | { |
| | | result.IsSuccessed = false; |
| | | result.LocaleMsg = new($"条码不存在!"); |
| | | return result; |
| | | } |
| | | var wo = await Biz.Db.Queryable<BIZ_MES_WO>().Where(q => q.ORDER_NO == woSns[0].WORK_ORDER ).IncludesAllFirstLayer().FirstAsync(); |
| | | if (wo == null) |
| | | { |
| | | result.IsSuccessed = false; |
| | | result.LocaleMsg = new($"条码对应的工单不存在"); |
| | | return result; |
| | | } |
| | | InStoreInfo inStoreInfo = new() { |
| | | ErpProdInBth= new() { |
| | | WORK_ORDER = wo.ORDER_NO, |
| | | BATCH_NO = woSns[0].BATCH_NO, |
| | | ITEM_CODE = wo.ITEM_CODE, |
| | | ITEM_NAME = wo.ItemInfo?.ITEM_NAME, |
| | | SCAN_QTY = woSns.Count |
| | | }, |
| | | ProdInBatch = new() |
| | | { |
| | | WORK_ORDER = wo.ORDER_NO, |
| | | BATCH_NO = woSns[0].BATCH_NO, |
| | | ITEM_CODE = wo.ITEM_CODE, |
| | | ITEM_NAME = wo.ItemInfo?.ITEM_NAME, |
| | | PLAN_QTY = wo.PLAN_QTY, |
| | | SCAN_QTY = woSns.Count |
| | | }, |
| | | InStoreScanInfo = new() { |
| | | SN = code, |
| | | WORK_ORDER = wo.ORDER_NO, |
| | | BATCH_NO = woSns[0].BATCH_NO, |
| | | SCAN_QTY = woSns.Count |
| | | } |
| | | }; |
| | | result.Data = inStoreInfo; |
| | | result.LocaleMsg = new($"获取条码[{code}]工单信息及包装信息成功"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | result.CatchExceptionWithLog(ex, $"获取条码[{code}]工单信息及包装信息异常"); |
| | | } |
| | | return result; |
| | | } |
| | | } |
| | | } |