|
@ -7,6 +7,7 @@ using System; |
|
|
using System.Collections.Generic; |
|
|
using System.Collections.Generic; |
|
|
using System.Linq; |
|
|
using System.Linq; |
|
|
using System.Threading.Tasks; |
|
|
using System.Threading.Tasks; |
|
|
|
|
|
using AMESCoreStudio.WebApi.Models.SYS; |
|
|
|
|
|
|
|
|
namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
{ |
|
|
{ |
|
@ -162,6 +163,81 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 根據料號批量鎖定工單
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="itemNo">料號</param>
|
|
|
|
|
|
/// <param name="lockReason">鎖定原因</param>
|
|
|
|
|
|
/// <param name="lockUserNo">鎖定人員</param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[Route("[action]")]
|
|
|
|
|
|
[HttpPost] |
|
|
|
|
|
public async Task<ResultModel<WipLock>> PostWipLockByItemNo(string itemNo,string lockReason,string lockUserNo) |
|
|
|
|
|
{ |
|
|
|
|
|
ResultModel<WipLock> result = new ResultModel<WipLock>(); |
|
|
|
|
|
Helper helper = new Helper(_context); |
|
|
|
|
|
|
|
|
|
|
|
IQueryable<UserInfo> q1 = _context.UserInfoes; |
|
|
|
|
|
q1 = q1.Where(w => w.UserNo == lockUserNo); |
|
|
|
|
|
|
|
|
|
|
|
var user = await q1.ToListAsync(); |
|
|
|
|
|
|
|
|
|
|
|
if (user.Count == 0) |
|
|
|
|
|
{ |
|
|
|
|
|
result.Success = false; |
|
|
|
|
|
result.Msg = "查無鎖定人員"; |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
var q = from a in _context.WipInfos |
|
|
|
|
|
join b in _context.WipAtts on a.WipNO equals b.WipNO |
|
|
|
|
|
select new |
|
|
|
|
|
{ |
|
|
|
|
|
a.WipNO, |
|
|
|
|
|
a.StatusNO, |
|
|
|
|
|
b.ItemNO |
|
|
|
|
|
}; |
|
|
|
|
|
q = q.Where(w => w.StatusNO.Equals("A")); |
|
|
|
|
|
|
|
|
|
|
|
if (itemNo != null) |
|
|
|
|
|
{ |
|
|
|
|
|
if (itemNo != "*") |
|
|
|
|
|
{ |
|
|
|
|
|
q = q.Where(w => w.ItemNO == itemNo); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
var wip_att = await q.ToListAsync(); |
|
|
|
|
|
|
|
|
|
|
|
foreach (var data in wip_att) |
|
|
|
|
|
{ |
|
|
|
|
|
WipLock wiplock = new WipLock(); |
|
|
|
|
|
|
|
|
|
|
|
wiplock.WipLockID = helper.GetIDKey("WIP_LOCK_ID").Result; |
|
|
|
|
|
wiplock.WipNO = data.WipNO; |
|
|
|
|
|
wiplock.LockReason = lockReason; |
|
|
|
|
|
wiplock.LockUserID = user[0].UserID; |
|
|
|
|
|
wiplock.UnLockUserID = 0; |
|
|
|
|
|
|
|
|
|
|
|
_context.WipLocks.Add(wiplock); |
|
|
|
|
|
|
|
|
|
|
|
try |
|
|
|
|
|
{ |
|
|
|
|
|
await _context.SaveChangesAsync(); |
|
|
|
|
|
result.Success = true; |
|
|
|
|
|
result.Msg = "OK"; |
|
|
|
|
|
} |
|
|
|
|
|
catch (Exception ex) |
|
|
|
|
|
{ |
|
|
|
|
|
result.Success = false; |
|
|
|
|
|
result.Msg = ex.InnerException.Message; |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
return result; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// 新增工單鎖定資料檔
|
|
|
/// 新增工單鎖定資料檔
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|