You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
86 lines
3.6 KiB
C#
86 lines
3.6 KiB
C#
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();
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="serviceProvider"></param>
|
|
public PortOpenService(IServiceProvider serviceProvider)
|
|
{
|
|
_serviceProvider = serviceProvider;
|
|
db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
|
|
}
|
|
|
|
|
|
public async Task<DataResult<TruckInfoViewModel>> GetTruckInfoAsync(string truckNo)
|
|
{
|
|
// List<TruckInfoViewModel> truckList = new List<TruckInfoViewModel>();
|
|
// List<TruckInfoViewModel> stockinTruckList = await db.Ado.SqlQueryAsync<TruckInfoViewModel>(
|
|
// @"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<TruckInfoViewModel> stockoutTruckList = await db.Ado.SqlQueryAsync<TruckInfoViewModel>(
|
|
// @"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<TruckInfoViewModel> clearanceTruckList = await db.Ado.SqlQueryAsync<TruckInfoViewModel>(
|
|
// @"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<VW_TruckList>().Where(x => x.TRUCKNO == truckNo.Trim()).OrderBy(x => x.PlanTime)
|
|
.Select<TruckInfoViewModel>()
|
|
.Mapper(it =>
|
|
{
|
|
it.IsInternalCar = false;
|
|
})
|
|
.ToList();
|
|
|
|
if (truckList.Count == 0)
|
|
{
|
|
return DataResult<TruckInfoViewModel>.Failed("车辆信息不存在!");
|
|
}
|
|
|
|
return DataResult<TruckInfoViewModel>.Success("获取数据成功", truckList.First());
|
|
}
|
|
|
|
/// <summary>
|
|
/// 记录车辆相关信息
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <returns></returns>
|
|
public async Task<DataResult> RecordTruckInfoAsync(TruckRecordInput model)
|
|
{
|
|
var truckList = db.Queryable<VW_TruckList>()
|
|
.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<tb_TruckRecord>();
|
|
|
|
await db.Insertable(info).ExecuteCommandAsync();
|
|
|
|
return DataResult.Successed("车辆信息纪录成功!");
|
|
}
|
|
} |