206 lines
6.8 KiB
C#
206 lines
6.8 KiB
C#
|
|
using WcsMain.ApiServe.Controllers.Dto.WcsDto.Location;
|
|||
|
|
using WcsMain.Common;
|
|||
|
|
using WcsMain.DataBase.TableEntity;
|
|||
|
|
using WcsMain.Enum;
|
|||
|
|
using WcsMain.Enum.Location;
|
|||
|
|
using WcsMain.WcsAttribute.AutoFacAttribute;
|
|||
|
|
|
|||
|
|
namespace WcsMain.DataBase.Dao;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// tbl_app_location 的库操作
|
|||
|
|
/// </summary>
|
|||
|
|
[Component]
|
|||
|
|
public class AppLocationDao
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 增加一条记录
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="appLocation"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public int Insert(AppLocation appLocation)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
return CommonTool.DbServe.Insertable(appLocation).ExecuteCommand();
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
_ = ex;
|
|||
|
|
return 0;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 更新一条记录,根据主键,主键WcsLocation
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="appLocation"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public int Update(params AppLocation[] appLocation)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
var sqlFuc = CommonTool.DbServe.Updateable(appLocation).IgnoreColumns(ignoreAllNullColumns: true);
|
|||
|
|
return sqlFuc.ExecuteCommand();
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
_ = ex;
|
|||
|
|
return 0;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 删除一条记录,根据主键,主键WcsLocation
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="appLocation"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public int Delete(AppLocation appLocation)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
var sqlFuc = CommonTool.DbServe.Deleteable(appLocation);
|
|||
|
|
return sqlFuc.ExecuteCommand();
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
_ = ex;
|
|||
|
|
return 0;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 查找数据
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="appLocation"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
/// <remarks>
|
|||
|
|
/// 时间不在筛选行列
|
|||
|
|
/// </remarks>
|
|||
|
|
public List<AppLocation>? Select(AppLocation appLocation)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
var sqlFuc = CommonTool.DbServe.Queryable<AppLocation>()
|
|||
|
|
.WhereIF(!string.IsNullOrEmpty(appLocation.WcsLocation),
|
|||
|
|
w => w.WcsLocation == appLocation.WcsLocation)
|
|||
|
|
.WhereIF(!string.IsNullOrEmpty(appLocation.WmsLocation),
|
|||
|
|
w => w.WmsLocation == appLocation.WmsLocation)
|
|||
|
|
.WhereIF(appLocation.LocationType != null, w => w.LocationType == appLocation.LocationType)
|
|||
|
|
.WhereIF(appLocation.TunnelNo != null, w => w.TunnelNo == appLocation.TunnelNo)
|
|||
|
|
.WhereIF(appLocation.EquipmentId != null, w => w.EquipmentId == appLocation.EquipmentId)
|
|||
|
|
.WhereIF(appLocation.LocationStatus != null, w => w.LocationStatus == appLocation.LocationStatus)
|
|||
|
|
.WhereIF(appLocation.Queue != null, w => w.Queue == appLocation.Queue)
|
|||
|
|
.WhereIF(appLocation.Line != null, w => w.Line == appLocation.Line)
|
|||
|
|
.WhereIF(appLocation.Layer != null, w => w.Layer == appLocation.Layer)
|
|||
|
|
.WhereIF(appLocation.Depth != null, w => w.Depth == appLocation.Depth)
|
|||
|
|
.WhereIF(!string.IsNullOrEmpty(appLocation.VehicleNo), w => w.VehicleNo == appLocation.VehicleNo)
|
|||
|
|
.OrderBy(o => new { o.Queue, o.Line, o.Layer, o.Depth })
|
|||
|
|
.ToList();
|
|||
|
|
return sqlFuc;
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
_ = ex;
|
|||
|
|
return default;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 查找所有数据
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public List<AppLocation>? Select() => Select(new AppLocation());
|
|||
|
|
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 查询自起点索引后的多少条数据
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="request"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public (List<AppLocation>? locations, int totalRows) SelectPage(GetLocationWithPageRequest request)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
int totalRows = 0;
|
|||
|
|
var sqlFuc = CommonTool.DbServe.Queryable<AppLocation>()
|
|||
|
|
.WhereIF(!string.IsNullOrEmpty(request.SearchStr),
|
|||
|
|
w => w.WcsLocation!.Contains(request.SearchStr!)
|
|||
|
|
|| w.WmsLocation!.Contains(request.SearchStr!)
|
|||
|
|
|| w.VehicleNo!.Contains(request.SearchStr!)
|
|||
|
|
|| w.Remark!.Contains(request.SearchStr!));
|
|||
|
|
if (request.LocationStatus != default) // 查询任务类型
|
|||
|
|
{
|
|||
|
|
List<int?> locationStatus = [];
|
|||
|
|
foreach (var ls in request.LocationStatus)
|
|||
|
|
{
|
|||
|
|
if (ls == "空闲") { locationStatus.Add((int)LocationStatusEnum.empty); }
|
|||
|
|
if (ls == "锁定") { locationStatus.Add((int)LocationStatusEnum.locked); }
|
|||
|
|
if (ls == "占用") { locationStatus.Add((int)LocationStatusEnum.used); }
|
|||
|
|
if (ls == "禁用") { locationStatus.Add((int)LocationStatusEnum.forbidden); }
|
|||
|
|
if (ls == "特殊点位") { locationStatus.Add((int)LocationStatusEnum.special); }
|
|||
|
|
}
|
|||
|
|
sqlFuc.Where(w => locationStatus.Contains(w.LocationStatus));
|
|||
|
|
}
|
|||
|
|
sqlFuc.OrderBy(o => new { o.EquipmentId, o.Queue, o.Line, o.Layer, o.Depth });
|
|||
|
|
var queryResult = sqlFuc.ToPageList(request.Page!.PageIndex, request.Page!.PageSize, ref totalRows);
|
|||
|
|
return (queryResult, totalRows);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
_ = ex;
|
|||
|
|
return default;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 查询一个堆垛机可用的站台
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="stackerId"></param>
|
|||
|
|
/// <param name="standType"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public List<AppLocation>? QueryCanUseStand(int? stackerId, StandTypeEnum standType)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
var sqlFuc = CommonTool.DbServe.Queryable<AppLocation>()
|
|||
|
|
.WhereIF(stackerId != null, w => w.EquipmentId == stackerId)
|
|||
|
|
.Where(w => w.LocationType.ToString()!.Contains(standType.ToString()))
|
|||
|
|
.Where(w => w.LocationStatus == (int)LocationStatusEnum.empty)
|
|||
|
|
.OrderBy(o => new { o.Queue, o.Line, o.Layer, o.Depth });
|
|||
|
|
//var ss = sqlFuc.ToSql();
|
|||
|
|
return sqlFuc.ToList();
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
_ = ex;
|
|||
|
|
return default;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 查找所有的站台
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public List<AppLocation>? SelectStand()
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
var sqlFuc = CommonTool.DbServe.Queryable<AppLocation>()
|
|||
|
|
.Where(w => w.LocationType != (int)StandTypeEnum.storageLocation)
|
|||
|
|
.OrderBy(o => o.WcsLocation)
|
|||
|
|
.ToList();
|
|||
|
|
return sqlFuc;
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
_ = ex;
|
|||
|
|
return default;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|