using DS.Module.Core; using DS.Module.Core.Extensions; using DS.WMS.Core.OpenApiModule.Dtos; using DS.WMS.Core.OpenApiModule.Entity; using DS.WMS.Core.OpenApiModule.Interface; using Mapster; using Microsoft.Extensions.DependencyInjection; using NLog; using SqlSugar; namespace DS.WMS.Core.OpenApiModule.Method; public class PortOpenService : IPortOpenService { private readonly IServiceProvider _serviceProvider; private readonly ISqlSugarClient db; static readonly Logger Logger = LogManager.GetCurrentClassLogger(); /// /// /// /// public PortOpenService(IServiceProvider serviceProvider) { _serviceProvider = serviceProvider; db = _serviceProvider.GetRequiredService(); } public async Task> GetTruckInfoAsync(string truckNo) { // List truckList = new List(); // List stockinTruckList = await db.Ado.SqlQueryAsync( // @"select DISTINCT b.TRUCKNO , a.WMSPLANID,a.MBLNO, 1 AS Type,a.PLANTIME as PlanTime from OP_WMS_IN_PLAN a left join OP_WMS_IN_PLAN_GOODS b on a.WMSPLANID = b.WMSPLANID where b.TRUCKNO is not null and b.TRUCKNO<>'' and a.AuditStatus =1 and a.ISEND = 0 "); // // List stockoutTruckList = await db.Ado.SqlQueryAsync( // @"select DISTINCT b.TRUCKNO , a.WMSPLANID,a.MBLNO, 2 AS Type,a.PLANTIME as PlanTime from OP_WMS_OUT_PLAN a left join OP_WMS_OUT_PLAN_DETAIL b on a.WMSPLANID = b.WMSPLANID where b.TRUCKNO is not null and b.TRUCKNO<>'' and a.AuditStatus =1 and a.ISEND = 0 "); // // List clearanceTruckList = await db.Ado.SqlQueryAsync( // @"select DISTINCT b.TRUCKNO , a.WMSPLANID,a.MBLNO, 3 AS Type,a.PLANTIME as PlanTime from OP_WMS_CLEARANCE a left join OP_WMS_CLEARANCE_DETAIL b on a.WMSPLANID = b.WMSPLANID where b.TRUCKNO is not null and b.TRUCKNO<>'' and a.AuditStatus =1 and a.ISEND = 0 "); // // truckList.AddRange(stockinTruckList); // truckList.AddRange(stockoutTruckList); // truckList.AddRange(clearanceTruckList); // var truckInfo = truckList.Where(x => x.TRUCKNO == truckNo.Trim()).OrderBy(x => x.PlanTime).ToList(); var truckList = db.Queryable().Where(x => x.TRUCKNO == truckNo.Trim()).OrderBy(x => x.PlanTime) .Select() .Mapper(it => { it.IsInternalCar = false; }) .ToList(); if (truckList.Count == 0) { return DataResult.Failed("车辆信息不存在!"); } return DataResult.Success("获取数据成功", truckList.First()); } /// /// 记录车辆相关信息 /// /// /// public async Task RecordTruckInfoAsync(TruckRecordInput model) { var truckList = db.Queryable() .Where(x => x.TRUCKNO == model.TRUCKNO.Trim() && x.WMSPLANID == model.WMSPLANID).OrderBy(x => x.PlanTime) .ToList(); if (truckList.Count == 0) { return DataResult.Failed("车辆信息不存在!"); } var info = model.Adapt(); await db.Insertable(info).ExecuteCommandAsync(); return DataResult.Successed("车辆信息纪录成功!"); } }