电梯代码调整

This commit is contained in:
yang.lee
2023-12-15 09:50:54 +08:00
parent c23134729e
commit 838ad24660
5 changed files with 111 additions and 54 deletions

View File

@@ -115,20 +115,39 @@ namespace Tnb.WarehouseMgr
return Task.FromResult(_configuration["TestLocation"]);
}
public async Task<WmsElevatorH> GetElevatorByBillCode(ElevagorInfoQuery input)
[AllowAnonymous,HttpPost]
public async Task<WmsElevatorH> ElevatorByBillCode([FromBody]ElevagorInfoQuery input)
{
var whereExpable = Expressionable.Create<WmsElevatorH, WmsElevatorD, WmsDistaskH>()
.And((a, b, c) => a.enabled == 1);
if (!input.taskCode.IsNullOrEmpty())
{
whereExpable.AndIF(!SqlFunc.IsNullOrEmpty(input.taskCode), (a, b, c) => c.bill_code == input.taskCode);
}
if (!input.endlocation_id.IsNullOrEmpty())
{
whereExpable.AndIF(!SqlFunc.IsNullOrEmpty(input.endlocation_id), (a, b, c) => b.location_id == input.endlocation_id);
}
if (!input.startlocation_id.IsNullOrEmpty())
{
whereExpable.AndIF(!SqlFunc.IsNullOrEmpty(input.startlocation_id), (a, b, c) => b.location_id == input.startlocation_id);
}
var ele = await _db.CopyNew().Queryable<WmsElevatorH>().InnerJoin<WmsElevatorD>((a, b) => a.id == b.bill_id)
.InnerJoin<WmsDistaskH>((a, b, c) => b.location_code == c.endlocation_code)
.WhereIF(SqlFunc.IsNullOrEmpty(input.taskCode), (a, b, c) => c.bill_code == input.taskCode)
.WhereIF(SqlFunc.IsNullOrEmpty(input.endlocation_id), (a, b, c) => c.endlocation_id == input.endlocation_id)
.Select((a, b, c) => new WmsElevatorH { bill_code = c.bill_code, device_id = a.elevator_id }, true)
.InnerJoin<WmsDistaskH>((a, b, c) => b.location_code == c.endlocation_code || b.location_code == c.startlocation_code)
.Where(whereExpable.ToExpression())
.WhereIF(!SqlFunc.IsNullOrEmpty(input.sourceName) && SqlFunc.StartsWith("DT-R", input.sourceName), (a, b, c) => c.startpoint_code == input.sourceName)
.WhereIF(!SqlFunc.IsNullOrEmpty(input.sourceName) && SqlFunc.StartsWith("DT-C", input.sourceName), (a, b, c) => c.endpoint_code == input.sourceName)
.Select((a, b, c) => new WmsElevatorH
{
bill_code = c.bill_code,
device_id = a.elevator_id,
end_floor = c.end_floor
}, true)
.FirstAsync();
//_db.Aop.OnLogExecuting = (sql, args) =>
//{
// var q = sql;
// Console.WriteLine("sql stat:" + sql);
//};
return ele;
}
}
}