From 0d5d4a8c55b562090f1a1ac48cda7fcab943979b Mon Sep 17 00:00:00 2001
From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com>
Date: 星期三, 15 十月 2025 15:48:40 +0800
Subject: [PATCH] 更新二进制文件及新增异步POST方法
---
CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs | 286 +++++++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 239 insertions(+), 47 deletions(-)
diff --git a/CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs b/CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs
index 58f94ff..41f4e30 100644
--- a/CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs
+++ b/CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs
@@ -2,7 +2,9 @@
using Masuit.Tools;
using SixLabors.Fonts.Tables.AdvancedTypographic;
using SqlSugar;
+using System.Linq.Expressions;
using System.Text.RegularExpressions;
+using System.Threading.Tasks;
using WIDESEA_Cache;
using WIDESEA_Core;
using WIDESEA_Core.Const;
@@ -11,6 +13,7 @@
using WIDESEA_IServices;
using WIDESEA_IStoragIntegrationServices;
using WIDESEA_Model.Models;
+using WIDESEA_Repository;
using WIDESEAWCS_BasicInfoRepository;
using WIDESEAWCS_QuartzJob.Models;
@@ -34,6 +37,7 @@
private readonly IAgingInOrOutInputService _agingInOrOutInputService; //闈欑疆\闄堝寲
private readonly IDt_StationManagerRepository _stationManagerRepository;
private readonly ISys_ConfigService _configService;
+ private readonly IDt_ChangeoversRepository _dt_ChangeoversRepository;
private readonly ISimpleCacheService _simpleCacheService;
public Dt_TaskService(IDt_TaskRepository BaseDal,
@@ -53,6 +57,7 @@
IStockInfoDetailRepository stockInfoDetailRepository,
IDt_StationManagerRepository stationManagerRepository,
ISys_ConfigService configService,
+ IDt_ChangeoversRepository dt_ChangeoversRepository,
ISimpleCacheService simpleCacheService) : base(BaseDal)
{
_unitOfWorkManage = unitOfWorkManage;
@@ -70,6 +75,7 @@
_stockInfoDetailRepository = stockInfoDetailRepository;
_stationManagerRepository = stationManagerRepository;
_configService = configService;
+ _dt_ChangeoversRepository = dt_ChangeoversRepository;
_simpleCacheService = simpleCacheService;
}
@@ -352,7 +358,7 @@
WebResponseContent content = new WebResponseContent();
try
{
- if (task.TaskType == (int)TaskInboundTypeEnum.InNG || task.TaskType == (int)TaskInboundTypeEnum.InQuality)
+ if (task.TaskType == (int)TaskInboundTypeEnum.InNG)
{
task.TaskState = (int)TaskInStatusEnum.SC_InFinish;
// 鍒涘缓鍘嗗彶浠诲姟瀹炰緥妯″瀷
@@ -419,6 +425,9 @@
Console.WriteLine(err.Message.ToString());
LogFactory.GetLog("浠诲姟瀹屾垚").Error(true, err);
content.Error(err.Message);
+ task.ErrorMessage = err.Message;
+ task.TaskState = (int)TaskInStatusEnum.SC_InExecuting;
+ await BaseDal.Update(task);
}
return content;
}
@@ -604,13 +613,13 @@
}
LogFactory.GetLog("浠诲姟瀹屾垚").InfoFormat(true, "楠岃瘉浠诲姟鏄惁瀛樺湪", JsonConvert.SerializeObject(task));
- if (task.TaskType == (int)TaskOutboundTypeEnum.InToOut)
- {
- return await CompleteInToOutTaskAsync(task);
- }
+
// 楠岃瘉搴撳瓨鏄惁瀛樺湪
var stock = await _stockInfoRepository.QueryFirstNavAsync(x => x.PalletCode == task.PalletCode);
-
+ if (task.TaskType == (int)TaskOutboundTypeEnum.InToOut)
+ {
+ return await CompleteInToOutTaskAsync(task,stock);
+ }
// 鏍规嵁浠诲姟绫诲瀷璋冪敤鐩稿簲鐨勫畬鎴愪换鍔℃柟娉�
switch (task.TaskType)
{
@@ -661,6 +670,11 @@
var stock = await QueryStockInfo(input.PalletCode);
if (stock != null)
{
+ List<string> strings = new List<string>() { "GW", "CW", "FR" };
+ if (stock.AreaCode.Contains(strings))
+ {
+ return content.Error($"鎵樼洏銆恵stock.PalletCode}銆戝瓨鍦ㄥ簱瀛樹笉鍏佽鍏ュ簱");
+ }
Dt_Task taskNew = new Dt_Task
{
Grade = 1,
@@ -744,11 +758,13 @@
else
{
// 澶勭悊寮傚父鐢佃姱鎯呭喌
- var serialNosError = result.SerialNos.Where(x => x.SerialNoStatus != 1 && x.SerialNoStatus != 4).ToList();
- if (serialNosError.Count > 0)
- {
- return await HandleErrorCells(input, area, serialNosError);
- }
+ #region 鐢佃姱鍒嗙粨鏋滃紓甯镐笉闇�瑕佹垜浠鐞�
+ //var serialNosError = result.SerialNos.Where(x => x.SerialNoStatus != 1 && x.SerialNoStatus != 4).ToList();
+ //if (serialNosError.Count > 0)
+ //{
+ // return await HandleErrorCells(input, area, serialNosError);
+ //}
+ #endregion
var boxing = CreateBoxingInfo(result, input.PalletCode);
if (boxing == null) return content.Error("缁勭洏澶辫触");
@@ -859,21 +875,46 @@
// 鑾峰彇缁勭洏淇℃伅
private DtBoxingInfo CreateBoxingInfo(ResultTrayCellsStatus result, string palletCode)
{
- return new DtBoxingInfo
+ var boxing = _boxingInfoRepository.QueryFirst(x => x.PalletCode == palletCode);
+ if (boxing == null)
{
- PalletCode = palletCode,
- IsFull = true,
- ProcessCode = result.ProcessCode,
- ProductionLine = result.ProductionLine,
- BoxingInfoDetails = result.SerialNos.Select(serialNoObj => new DtBoxingInfoDetail
+ return new DtBoxingInfo
{
- SerialNumber = serialNoObj.SerialNo,
- OrderNo = serialNoObj.PositionNo.ToString(),
- Status = serialNoObj.SerialNoStatus,
- MaterielCode = result.BindCode,
- Remark = result.TrayBarcodePropertys.ToJsonString(),
- }).ToList()
- };
+ PalletCode = palletCode,
+ IsFull = true,
+ ProcessCode = result.ProcessCode,
+ ProductionLine = result.ProductionLine,
+ BoxingInfoDetails = result.SerialNos.Select(serialNoObj => new DtBoxingInfoDetail
+ {
+ SerialNumber = serialNoObj.SerialNo,
+ OrderNo = serialNoObj.PositionNo.ToString(),
+ Status = serialNoObj.SerialNoStatus,
+ MaterielCode = result.BindCode,
+ Remark = result.TrayBarcodePropertys.ToJsonString(),
+ }).ToList()
+ };
+ }
+ else
+ {
+ _boxingInfoRepository.Db.DeleteNav<DtBoxingInfo>(x => x.Id == boxing.Id)
+ .Include(x => x.BoxingInfoDetails)
+ .ExecuteCommandAsync();
+ return new DtBoxingInfo
+ {
+ PalletCode = palletCode,
+ IsFull = true,
+ ProcessCode = result.ProcessCode,
+ ProductionLine = result.ProductionLine,
+ BoxingInfoDetails = result.SerialNos.Select(seriaINoObj => new DtBoxingInfoDetail
+ {
+ SerialNumber = seriaINoObj.SerialNo,
+ OrderNo = seriaINoObj.PositionNo.ToString(),
+ Status = seriaINoObj.SerialNoStatus,
+ MaterielCode = result.BindCode,
+ Remark = result.TrayBarcodePropertys.ToJsonString(),
+ }).ToList()
+ };
+ }
}
// 鑾峰彇宸ヨ壓鐢宠
@@ -973,7 +1014,9 @@
return null;
}
- var outBoundMateriel = AppSettings.app<OutBoundMateriel>("OutBoundMateriel");
+ //var outBoundMateriel = AppSettings.app<OutBoundMateriel>("OutBoundMateriel");
+
+ var outBoundMateriel = _dt_ChangeoversRepository.QueryData(x => x.Status == "1").ToList();
List<string>? materielCodes = outBoundMateriel.Count != 0
? outBoundMateriel.Where(x => x.ProductionLine == productionLine && x.ProcessCode == area.AreaCode)
.Select(x => x.MaterielCode)
@@ -1026,7 +1069,9 @@
// materielCodes = outBoundMateriel.Where(x => x.ProductionLine == productionLine && x.ProcessCode == areaCodes[0]).Select(x => x.MaterielCode).ToList();
//}
- var outBoundMateriel = AppSettings.app<OutBoundMateriel>("OutBoundMateriel");
+ //var outBoundMateriel = AppSettings.app<OutBoundMateriel>("OutBoundMateriel");
+
+ var outBoundMateriel = _dt_ChangeoversRepository.QueryData(x => x.Status == "1").ToList();
List<string>? materielCodes = outBoundMateriel.Count != 0
? outBoundMateriel.Where(x => x.ProductionLine == productionLine && x.ProcessCode == areaCodes[0])
.Select(x => x.MaterielCode)
@@ -1082,11 +1127,11 @@
.ToList().Select(x => x.DeviceCode).ToList();
var result = await _stockInfoRepository.Db.Queryable<DtStockInfo>()
- .Where(x => x.ProductionLine == station.productLine)
+ .WhereIF(!station.Roadway.Contains("JZSC"), x => x.ProductionLine == station.productLine)
.Where(x => x.AreaCode == areaCode && x.IsFull == false)
- .Includes(x=>x.StockInfoDetails)
+ .Includes(x => x.StockInfoDetails)
.Where(x => x.StockInfoDetails.Any(y => y.MaterielCode == "绌烘墭鐩�"))
- .Includes(x=>x.LocationInfo)
+ .Includes(x => x.LocationInfo)
.WhereIF(!deviceCode.IsNullOrEmpty(), x => deviceCode.Contains(x.LocationInfo.RoadwayNo))
.Where(x => x.LocationInfo.LocationStatus == (int)LocationEnum.InStock && x.LocationInfo.AreaId == area.AreaID && x.LocationInfo.EnalbeStatus == (int)EnableEnum.Enable) // 杩囨护鏉′欢
.OrderBy(x => x.CreateDate) // 鎺掑簭
@@ -1111,7 +1156,7 @@
{
return new Dt_Task
{
- Grade = tag == 104 ? (stockInfo.LocationInfo.RoadwayNo.Contains("CWSC") ? 1 : 2) : (stockInfo.LocationInfo.RoadwayNo.Contains("CWSC") ? 2 : 1),
+ Grade = tag == 104 ? (stockInfo.LocationInfo.RoadwayNo.Contains("CWSC")|| stockInfo.LocationInfo.RoadwayNo.Contains("JZSC") ? 1 : 2) : (stockInfo.LocationInfo.RoadwayNo.Contains("CWSC") || stockInfo.LocationInfo.RoadwayNo.Contains("JZSC") ? 2 : 1),
Roadway = stockInfo.LocationInfo.RoadwayNo,
TargetAddress = position,
Dispatchertime = DateTime.Now,
@@ -1646,6 +1691,28 @@
#endregion
+ #region 鏌ヨ闈欑疆绌洪棽搴撲綅
+ public WebResponseContent QueryLocationFreeJZ(string RoadwayNo)
+ {
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+ var result = _locationRepository.QueryData(x => x.EnalbeStatus != (int)EnableEnum.Disable && x.LocationStatus == (int)LocationEnum.Free && x.RoadwayNo.Contains("JZSC"));
+ LogFactory.GetLog($"闈欑疆{RoadwayNo}鏌ヨ绌洪棽搴撲綅").Info(true, $"{JsonConvert.SerializeObject(result)}");
+ if (result.Count > 5)
+ {
+ return content.OK();
+ }
+ return content.Error("搴撲綅宸叉弧");
+ }
+ catch (Exception ex)
+ {
+ return content.Error(ex.Message);
+ }
+ }
+
+ #endregion
+
#region 澶у睆鎺ュ彛
/// <summary>
@@ -1709,11 +1776,130 @@
return content.Error(ex.Message);
}
}
+ /// <summary>
+ /// 鑾峰彇璐т綅鐘舵��
+ /// </summary>
+ /// <returns></returns>
+ public WebResponseContent GetStockQuantity()
+ {
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+ var location = _locationRepository.Db.Queryable<DtLocationInfo>().ToList();
+ return content.OK(data: location);
+ }
+ catch (Exception ex)
+ {
+ return content.Error(ex.Message);
+ }
+ }
+ public WebResponseContent Getproductionvolume()
+ {
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+ var now = DateTime.Now;
+ var startOfDay = new DateTime(now.Year, now.Month, now.Day);
+ var endOfDay1 = startOfDay.AddDays(-7);
+ var taskHty = _task_HtyRepository.Db.Queryable<Dt_Task_Hty>().Where(it => it.CreateDate > endOfDay1).ToList();
+ return content.OK(data: taskHty);
+ }
+ catch (Exception ex)
+ {
+ return content.Error(ex.Message);
+ }
+ }
+
+ public WebResponseContent Getoutput()
+ {
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+ var now = DateTime.Now;
+ var firstDayOfYear = new DateTime(now.Year, 1, 1);
+ var taskHty = _task_HtyRepository.Db.Queryable<Dt_Task_Hty>().Where(it => it.CreateDate > firstDayOfYear&&it.TaskType==100).ToList();
+ return content.OK(data: taskHty);
+ }
+ catch (Exception ex)
+ {
+ return content.Error(ex.Message);
+ }
+
+ }
#endregion
+ public WebResponseContent GetTimeout()
+ {
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+ var now = DateTime.Now;
+ // 浣跨敤Subtract鏂规硶
+ var threeHoursAgo = now.Subtract(TimeSpan.FromHours(3));
+ List<DtStockInfo> dtStocks = _stockInfoRepository.Db.Queryable<DtStockInfo>()
+ .Where(x => x.OutboundTime < threeHoursAgo).ToList();
+ return content.OK1(total1: dtStocks.Count, data: dtStocks);
+ }
+ catch (Exception ex)
+ {
+ return content.Error(ex.Message);
+ }
+
+ }
+
+ public WebResponseContent Getproductionstatistics()
+ {
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+ var now = DateTime.Now;
+ var thirtyDaysAgo = now.AddDays(-30);
+ var roadwayMappings = new Dictionary<string, string> {
+ { "JZ", "闈欑疆搴�" },
+ { "CH", "闄堝寲搴�" },
+ { "FR", "鍒嗗搴�" },
+ { "GW", "楂樻俯搴�" },
+ { "CW", "甯告俯搴�" }
+ };
+
+ var roadwayKeys = roadwayMappings.Keys.ToArray();
+
+ var taskHty = _task_HtyRepository.Db.Queryable<Dt_Task_Hty>()
+ .Where(it =>
+ it.CreateDate >= thirtyDaysAgo &&
+ it.CreateDate <= now &&
+ it.TaskType == 100 &&
+ roadwayKeys.Any(rk => it.Roadway.Contains(rk)))
+ .ToList()
+ .Select(t => new {
+ OriginalRoadway = t.Roadway,
+ MatchedKey = roadwayKeys.FirstOrDefault(rk => t.Roadway.Contains(rk)),
+ CreateDate = t.CreateDate
+ })
+ .Where(t => t.MatchedKey != null)
+ .GroupBy(t => new {
+ RoadwayKey = t.MatchedKey,
+ Date = t.CreateDate.Date,
+ Hour = t.CreateDate.Hour
+ })
+ .OrderByDescending(group => group.Key.Date)
+ .ThenByDescending(group => group.Key.Hour)
+ .Select(group => new {
+ Hour = $"{group.Key.Date:yyyy/M/d} {group.Key.Hour}:00",
+ Count = group.Count(),
+ Roadway = roadwayMappings[group.Key.RoadwayKey] // 鏄犲皠涓轰腑鏂囧悕绉�
+ })
+ .ToList();
+ return content.OK1(total1: taskHty.Count, data: taskHty);
+ }
+ catch (Exception ex)
+ {
+ return content.Error(ex.Message);
+ }
+ }
#endregion 澶栭儴鎺ュ彛鏂规硶
#region 鍐呴儴璋冪敤鏂规硶
@@ -1764,20 +1950,23 @@
// 鍒涘缓鍘嗗彶浠诲姟瀹炰緥妯″瀷
try
{
- Dt_Task task = BaseDal.QueryFirst(x => x.TaskId == Convert.ToInt32(key[0]));
- if (task == null)
+ foreach (var item in key)
{
- return content.Error("鏈壘鍒颁换鍔′俊鎭�!");
+ Dt_Task task = BaseDal.QueryFirst(x => x.TaskId == Convert.ToInt32(key));
+ if (task == null)
+ {
+ return content.Error("鏈壘鍒颁换鍔′俊鎭�!");
+ }
+ var taskHtyNG = CreateHistoricalTask(task, true);
+
+ // 鎵ц鏁版嵁搴撲簨鍔�
+
+ // 娣诲姞鍘嗗彶浠诲姟
+ var isTaskHtyAdd = _task_HtyRepository.AddData(taskHtyNG) > 0;
+
+ // 鍒犻櫎浠诲姟鏁版嵁
+ var isTaskDelete = BaseDal.Delete(task.TaskId);
}
- var taskHtyNG = CreateHistoricalTask(task, true);
-
- // 鎵ц鏁版嵁搴撲簨鍔�
-
- // 娣诲姞鍘嗗彶浠诲姟
- var isTaskHtyAdd = _task_HtyRepository.AddData(taskHtyNG) > 0;
-
- // 鍒犻櫎浠诲姟鏁版嵁
- var isTaskDelete = BaseDal.Delete(task.TaskId);
return content.OK("鍒犻櫎鎴愬姛!");
}
@@ -2089,10 +2278,10 @@
// 鑾峰彇鐩爣鍦板潃鍜屾洿鏂颁换鍔$姸鎬�
input.Position = Regex.Replace(input.Position, @"-(\d+)", "");
- if (Convert.ToInt32(input.Position) > 1999)
- {
- input.Position = (Convert.ToInt32(input.Position) - 1000).ToString();
- }
+ //if (Convert.ToInt32(input.Position) > 1999)
+ //{
+ // input.Position = (Convert.ToInt32(input.Position) - 1000).ToString();
+ //}
if (task.TaskType == (int)TaskInboundTypeEnum.InNG)
{
@@ -2207,7 +2396,10 @@
ToAddress = await GetRoadWayAsync(process);
else
ToAddress = process[0];
-
+ if (string.IsNullOrEmpty(ToAddress))
+ {
+ return content.Error("鏃犳硶鑾峰彇鐩爣鍦板潃");
+ }
// 鍒涘缓鏂颁换鍔″疄渚�
var task = new Dt_Task
{
--
Gitblit v1.9.3