From 9c806a573d5d34a3ebe4bfaec2580770de813e80 Mon Sep 17 00:00:00 2001
From: schangxiang@126.com <schangxiang@126.com>
Date: 周四, 27 6月 2024 17:28:57 +0800
Subject: [PATCH] 222
---
iWara.SCADA.Code/iWare.Wms.Application/Service/Pda/PdaService.cs | 98 +++++++++++++++++++++++++++++++++++++++---------
1 files changed, 79 insertions(+), 19 deletions(-)
diff --git a/iWara.SCADA.Code/iWare.Wms.Application/Service/Pda/PdaService.cs b/iWara.SCADA.Code/iWare.Wms.Application/Service/Pda/PdaService.cs
index 44b8d03..a9919ec 100644
--- a/iWara.SCADA.Code/iWare.Wms.Application/Service/Pda/PdaService.cs
+++ b/iWara.SCADA.Code/iWare.Wms.Application/Service/Pda/PdaService.cs
@@ -18,6 +18,7 @@
//[Route("api")]
[ApiDescriptionSettings("Pda鐩稿叧鎺ュ彛", Name = "PdaService", Order = 100)]
[Route("api/[Controller]")]
+ [DisableOpLog]
public class PdaService : IDynamicApiController, ITransient
{
private readonly IRepository<EquipmentBaseInfo, MasterDbContextLocator> _equipmentBaseInfoRep;
@@ -66,7 +67,7 @@
/// </summary>
/// <returns></returns>
[HttpGet("getOneWorkPiece")]
- public async Task<WorkPieceInfoOutput> getOneWorkPiece([FromQuery] WorkPieceProcessPdaSearch input)
+ public async Task<WorkPieceInfoOutput> getOneWorkPiece([FromQuery] WorkPieceProcessPdaSearch input)
{
if (string.IsNullOrEmpty(input.WorkPieceID))
{
@@ -97,8 +98,8 @@
WorkPieceCurrentPosition = s.c.a.WorkPieceCurrentPosition,
WorkPieceinitOnlineTime = s.c.a.WorkPieceinitOnlineTime,
WorkPieceLastOfflineTime = s.c.a.WorkPieceLastOfflineTime,
- WorkingProcedureCompleted= s.c.a.WorkingProcedureCompleted,
- OP80NewCode=s.c.a.OP80NewCode,
+ WorkingProcedureCompleted = s.c.a.WorkingProcedureCompleted,
+ OP80NewCode = s.c.a.OP80NewCode,
})
.ProjectToType<WorkPieceInfoOutput>().FirstOrDefaultAsync();
if (workPieceInfo == null)
@@ -122,7 +123,7 @@
// //.Where(x => (x.g.Code.Equals("equipment_state")))
.Where(u => u.a.QualityState != (int)EnumQualityState.OK)
.Where(u => u.a.IsDeleted == false)
- .Where(o => o.a.WorkPieceID.Contains(queryStr ?? "")|| o.a.QualityErrorInfo.Contains(queryStr ?? ""))
+ .Where(o => o.a.WorkPieceID.Contains(queryStr ?? "") || o.a.QualityErrorInfo.Contains(queryStr ?? ""))
//.Where(o => (o.a.QualityStateUpdateTime.HasValue ? o.a.QualityStateUpdateTime.Value : DateTime.MinValue) > DateTime.Now.AddDays(-7))
.Where(o => !string.IsNullOrEmpty(o.a.WorkPieceID))
.Select(s => new WorkPieceInfoOutput
@@ -137,8 +138,8 @@
WorkingProcedureCompleted = s.a.WorkingProcedureCompleted,
WorkPieceinitOnlineTime = s.a.WorkPieceinitOnlineTime,
QualityState = s.a.QualityState,
- QualityErrorInfo= s.a.QualityErrorInfo,
- QualityStateUpdateTime=(s.a.QualityStateUpdateTime.HasValue? s.a.QualityStateUpdateTime.Value:DateTime.MinValue),
+ QualityErrorInfo = s.a.QualityErrorInfo,
+ QualityStateUpdateTime = (s.a.QualityStateUpdateTime.HasValue ? s.a.QualityStateUpdateTime.Value : DateTime.MinValue),
EquipmentID = s.a.EquipmentID,
EquipmentName = s.b.EquipmentName,
//EquipmentCurrentState = s.d.EquipmentCurrentState,
@@ -221,6 +222,7 @@
/// <param name="input"></param>
/// <returns></returns>
[HttpGet("getWorkPieceProcess")]
+ [DisableOpLog]
public async Task<WorkPieceProcessPdaOutput> getWorkPieceProcess([FromQuery] WorkPieceProcessPdaSearch input)
{
var workPieceProcesss = await _workPieceProcessRep.DetachedEntities
@@ -287,7 +289,7 @@
throw Oops.Oh($"淇敼宸ヤ欢璐ㄩ噺鐘舵�佸け璐ワ細宸ヤ欢{item}涓嶅瓨鍦紒");
}
- if(int.Parse(input.QualityState)==(int)EnumQualityState.OK)
+ if (int.Parse(input.QualityState) == (int)EnumQualityState.OK)
{
workPieceInfo.QualityErrorInfo = "";
}
@@ -321,7 +323,7 @@
[HttpPost("updateWorkPieceInfo")]
public async Task<string> updateWorkPieceInfo([FromBody] UpdateQualityStateInput input)
{
- if (input == null || input.WorkPieceIDList.Count == 0 || input.Password == null)
+ if (input == null || input.WorkPieceIDList.Count == 0 || input.Password == null)
{
throw Oops.Oh("淇敼宸ヤ欢淇℃伅澶辫触锛氫紶鍙備笉鑳戒负绌猴紒");
}
@@ -341,7 +343,7 @@
{
throw Oops.Oh($"淇敼宸ヤ欢淇℃伅澶辫触锛氫紶鍏ュ伐浠剁姸鎬乕{input.WorkPieceState}]涓嶅锛�");
}
- if (input.WorkingProcedure.Length!=4|| !input.WorkingProcedure.Contains("OP"))
+ if (input.WorkingProcedure.Length != 4 || !input.WorkingProcedure.Contains("OP"))
{
throw Oops.Oh($"淇敼宸ヤ欢淇℃伅澶辫触锛氫紶鍏ュ伐搴廩{input.WorkingProcedure}]涓嶅锛�");
}
@@ -358,7 +360,7 @@
throw Oops.Oh($"淇敼宸ヤ欢璐ㄩ噺鐘舵�佸け璐ワ細宸ヤ欢{item}涓嶅瓨鍦紒");
}
string LogAddRemark = "";
- if (workPieceInfo.QualityState!= int.Parse(input.QualityState))
+ if (workPieceInfo.QualityState != int.Parse(input.QualityState))
{
LogAddRemark += $"璐ㄩ噺淇℃伅[{workPieceInfo.QualityState ?? 0}]鍒癧{input.QualityState}]";
workPieceInfo.QualityState = int.Parse(input.QualityState);
@@ -383,7 +385,7 @@
{
LogAddRemark += $"宸ヤ欢鐘舵�� [{workPieceInfo.WorkPieceState}]鍒癧{input.WorkPieceState}]";
workPieceInfo.WorkPieceState = int.Parse(input.WorkPieceState);
- if(workPieceInfo.WorkPieceState==(int)EnumWorkPieceState.FinishedProducts)
+ if (workPieceInfo.WorkPieceState == (int)EnumWorkPieceState.FinishedProducts)
{
workPieceInfo.WorkPieceLastOfflineTime = DateTime.Now;
}
@@ -411,16 +413,21 @@
/// </summary>
/// <returns></returns>
[HttpGet("getWorkPieceByOP80NewCode")]
+ [DisableOpLog]
public async Task<WorkPieceInfoOutput> getWorkPieceByOP80NewCode([FromQuery] WorkPieceByOP80NewCodeInputSearch input)
{
if (string.IsNullOrEmpty(input.OP80NewCode))
{
- throw Oops.Oh($"璇疯緭鍏P80鎵撳嵃鎴愬搧鐮佹垨浜岀淮鐮侊紒");
+ throw Oops.Oh($"璇疯緭鍏ユ垚鍝佺爜鎴栧伐浠剁爜锛�");
+ }
+ if (input.OP80NewCode.Length > 22)
+ {
+ throw Oops.Oh($"宸ヤ欢鐮佹垨鎴愬搧鐮亄input.OP80NewCode}闀垮害涓嶆纭紒");
}
string OP80NewCode = input.OP80NewCode.Trim();
var workPieceInfo = await _workPieceInfoRep.DetachedEntities
- .Where(!string.IsNullOrEmpty(OP80NewCode), u => u.OP80NewCode == OP80NewCode||u.WorkPieceID== OP80NewCode)
+ .Where(!string.IsNullOrEmpty(OP80NewCode), u => u.OP80NewCode == OP80NewCode || u.WorkPieceID == OP80NewCode)
.Select(s => new WorkPieceInfoOutput
{
Id = s.Id,
@@ -440,8 +447,23 @@
}).FirstOrDefaultAsync();
if (workPieceInfo == null)
{
- throw Oops.Oh($"OP80鎵撳嵃鎴愬搧鐮佹垨宸ヤ欢浜岀淮鐮併�恵OP80NewCode}銆戞病鏈夋壘鍒扮浉鍏冲伐浠朵俊鎭紒");
+ //throw Oops.Oh($"OP80鎵撳嵃鎴愬搧鐮佹垨宸ヤ欢浜岀淮鐮併�恵OP80NewCode}銆戞病鏈夋壘鍒扮浉鍏冲伐浠朵俊鎭紒");
+ workPieceInfo = new WorkPieceInfoOutput
+ {
+ WorkPieceID = OP80NewCode,
+ OP80NewCode = OP80NewCode,
+ };
}
+
+ //鍒ゆ柇鏄惁宸茬粡鍑哄簱
+ List<WorkPieceOutbound> db_itemModelList = await _workPieceOutboundRep.DetachedEntities.Where(w => (w.WorkPieceID == OP80NewCode || w.OP80NewCode == OP80NewCode) && w.IsDeleted == false).ToListAsync();
+ if (db_itemModelList != null && db_itemModelList.Count > 0)
+ {
+ var itemModel = db_itemModelList.First();
+ var createitme = itemModel.CreatedTime == null ? "" : (((DateTimeOffset)itemModel.CreatedTime).UtcDateTime.ToString("yyyy-MM-dd HH:mm:ss"));
+ throw Oops.Oh($"宸ヤ欢{itemModel.WorkPieceID}宸插嚭搴擄紝鍑哄簱鏃堕棿:{createitme}");
+ }
+
return workPieceInfo;
}
@@ -451,6 +473,8 @@
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("outBoundWorkPiece")]
+ [DisableOpLog]
+ [UnitOfWork]
public async Task<string> outBoundWorkPiece([FromBody] OutBoundInput input)
{
@@ -467,13 +491,21 @@
var addOutBoundList = new List<WorkPieceOutbound>();
+ var queryWorkPieceIDList = WorkPieceInfoLst.Select(x => x.WorkPieceID).ToList();
+ List<WorkPieceOutbound> db_itemModelList = await _workPieceOutboundRep.Where(w => queryWorkPieceIDList.Contains(w.WorkPieceID) && w.IsDeleted == false).ToListAsync();
+
+ List<WorkPieceInfo> db_WorkPieceInfoList = await _workPieceInfoRep.Where(w => queryWorkPieceIDList.Contains(w.WorkPieceID) && w.IsDeleted == false).ToListAsync();
+
foreach (var item in WorkPieceInfoLst)
{
- WorkPieceOutbound itemModel=await _workPieceOutboundRep.FirstOrDefaultAsync(w=>w.WorkPieceID==item.WorkPieceID);
- if (itemModel != null) {
- itemModel.IsDeleted = true;
- itemModel.Remark = itemModel.Remark ?? "" + "浜屾鍙戣揣鑷姩鎾ら攢鍙戣揣";
- await _workPieceOutboundRep.UpdateAsync(itemModel);
+ var itemModel = db_itemModelList.FirstOrDefault(w => w.WorkPieceID == item.WorkPieceID);
+ if (itemModel != null)
+ {
+ //itemModel.IsDeleted = true;
+ //itemModel.Remark = itemModel.Remark ?? "" + "浜屾鍙戣揣鑷姩鎾ら攢鍙戣揣";
+ //await _workPieceOutboundRep.UpdateAsync(itemModel);
+ var createitme = itemModel.CreatedTime == null ? "" : (((DateTimeOffset)itemModel.CreatedTime).UtcDateTime.ToString("yyyy-MM-dd HH:mm:ss"));
+ throw Oops.Oh($"宸ヤ欢{itemModel.WorkPieceID}宸插嚭搴擄紝鍑哄簱鏃堕棿:{createitme}");
}
var outBoundLog = new WorkPieceOutbound
{
@@ -486,10 +518,38 @@
CreatedUserName = CurrentUserInfo.Name,
};
addOutBoundList.Add(outBoundLog);
+
+ var workPiece = db_WorkPieceInfoList.FirstOrDefault(w => w.WorkPieceID == item.WorkPieceID);
+ if (workPiece != null)
+ {
+ workPiece.OutPerson = CurrentUserInfo.Name;
+ workPiece.OutRemark = "鎾ら攢宸ヤ欢鍑哄簱";
+ workPiece.OutTime = DateTime.Now;
+ workPiece.IsOut = false;
+
+ await _workPieceInfoRep.UpdateAsync(workPiece);
+ }
}
await _workPieceOutboundRep.InsertAsync(addOutBoundList);
return "鍑哄簱鎴愬姛";
}
+ /// <summary>
+ /// 鍑哄簱缁熻
+ /// </summary>
+ /// <param name="input"></param>
+ /// <returns></returns>
+ [HttpPost("getOutBoundWorkPieceInfoCount")]
+ [DisableOpLog]
+ public async Task<string> GetOutBoundWorkPieceInfoCount()
+ {
+ DateTimeOffset now = DateTimeOffset.Now; // 鑾峰彇褰撳墠鏃堕棿锛屽寘鎷椂鍖哄亸绉婚噺
+ DateTimeOffset startOfDay = new DateTimeOffset(now.Year, now.Month, now.Day, 0, 0, 0, now.Offset); // 褰撳ぉ寮�濮嬫椂闂�
+ DateTimeOffset endOfDay = new DateTimeOffset(now.Year, now.Month, now.Day, 23, 59, 59, now.Offset); // 褰撳ぉ缁撴潫鏃堕棿
+ List<WorkPieceOutbound> db_itemModelList = await _workPieceOutboundRep.Where(w => w.CreatedTime >= startOfDay && w.CreatedTime <= endOfDay && w.IsDeleted == false).ToListAsync();
+
+ return db_itemModelList.Count().ToString();
+ }
+
}
}
--
Gitblit v1.9.3