|
|
@ -81,19 +81,42 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
|
public async Task<ResultModel<BarcodeLockDto>> GetBarcodeLockQuery(string barCodeNo, string wipNo, string lockStatus |
|
|
|
, string itemNo, string date_Str = null, string date_End = null, int page = 0, int limit = 10) |
|
|
|
{ |
|
|
|
IQueryable<BarcodeLock> q = _context.BarcodeLocks; |
|
|
|
IQueryable<BarcodeLockDto> q = from s in _context.BarcodeLocks |
|
|
|
join q2 in _context.UserInfoes on s.LockUserID equals q2.UserID into cp2 |
|
|
|
from q2 in cp2.DefaultIfEmpty() |
|
|
|
join q3 in _context.UserInfoes on s.UnLockUserID equals q3.UserID into cp3 |
|
|
|
from q3 in cp3.DefaultIfEmpty() |
|
|
|
select new BarcodeLockDto |
|
|
|
{ |
|
|
|
BarCodeLockID = s.BarcodeLockID, |
|
|
|
BarCodeNo = s.GetBarcodeInfo.BarcodeNo, |
|
|
|
WipNO = s.GetBarcodeInfo.GetWipInfo.WipNO, |
|
|
|
ItemNO = s.GetBarcodeInfo.GetWipInfo.GetWipAtt.ItemNO, |
|
|
|
LockDate = s.LockDate, |
|
|
|
UnLockDate = s.UnLockDate, |
|
|
|
LockUserID = s.LockUserID, |
|
|
|
LockUserName = q2.UserName, |
|
|
|
LockReason = s.LockReason, |
|
|
|
LockStatus = s.LockStatus == 0 ? "鎖定" : "解鎖", |
|
|
|
UnLockUserID = s.UnLockUserID, |
|
|
|
UnLockUserName = q3.UserName, |
|
|
|
UnLockReason = s.UnLockReason |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(barCodeNo)) |
|
|
|
q = q.Where(w => w.GetBarcodeInfo.BarcodeNo == barCodeNo); |
|
|
|
q = q.Where(w => w.BarCodeNo == barCodeNo); |
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(wipNo)) |
|
|
|
q = q.Where(w => w.GetBarcodeInfo.GetWipInfo.WipNO == wipNo); |
|
|
|
q = q.Where(w => w.WipNO == wipNo); |
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(lockStatus)) |
|
|
|
q = q.Where(w => w.LockStatus == int.Parse(lockStatus)); |
|
|
|
|
|
|
|
{ |
|
|
|
var LockStatusName = lockStatus == "0" ? "鎖定" : "解鎖"; |
|
|
|
q = q.Where(w => w.LockStatus == LockStatusName); |
|
|
|
} |
|
|
|
if (!string.IsNullOrWhiteSpace(itemNo)) |
|
|
|
q = q.Where(w => w.GetBarcodeInfo.GetWipInfo.GetWipAtt.ItemNO == itemNo); |
|
|
|
q = q.Where(w => w.ItemNO == itemNo); |
|
|
|
|
|
|
|
if (DateTime.TryParse(date_Str, out _)) |
|
|
|
{ |
|
|
@ -116,21 +139,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
|
q = q.Skip((page - 1) * limit).Take(limit); |
|
|
|
} |
|
|
|
|
|
|
|
result.Data = await q.Select(s => new BarcodeLockDto |
|
|
|
{ |
|
|
|
BarCodeLockID = s.BarcodeLockID, |
|
|
|
BarCodeNo = s.GetBarcodeInfo.BarcodeNo, |
|
|
|
WipNO = s.GetBarcodeInfo.GetWipInfo.WipNO, |
|
|
|
ItemNO = s.GetBarcodeInfo.GetWipInfo.GetWipAtt.ItemNO, |
|
|
|
LockDate = s.LockDate, |
|
|
|
UnLockDate = s.UnLockDate, |
|
|
|
LockUserID = s.LockUserID, |
|
|
|
LockReason = s.LockReason, |
|
|
|
LockStatus = s.LockStatus == 0 ? "鎖定" : "解鎖", |
|
|
|
UnLockUserID = s.UnLockUserID, |
|
|
|
UnLockReason = s.UnLockReason |
|
|
|
}).ToListAsync(); |
|
|
|
|
|
|
|
result.Data = await q.ToListAsync(); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|