From c5238c1b78e8e7a066d6a82e4bbd5118de6b6efb Mon Sep 17 00:00:00 2001
From: hutongqing <hutongqing@hnkhzn.com>
Date: 星期一, 16 十二月 2024 21:23:02 +0800
Subject: [PATCH] 1
---
代码管理/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs | 155 +++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 141 insertions(+), 14 deletions(-)
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
index 7198373..ba3138c 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
@@ -16,6 +16,7 @@
#endregion << 鐗� 鏈� 娉� 閲� >>
using AutoMapper;
+using HslCommunication.WebSocket;
using MailKit.Search;
using Newtonsoft.Json;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
@@ -31,12 +32,15 @@
using System.Reflection.Metadata;
using System.Text;
using System.Threading.Tasks;
+using WIDESEA_Common.CommonEnum;
+using WIDESEA_Common.LocationEnum;
+using WIDESEA_Common.StockEnum;
+using WIDESEA_Common.TaskEnum;
using WIDESEA_Core;
using WIDESEA_Core.BaseRepository;
using WIDESEA_Core.BaseServices;
using WIDESEA_Core.Enums;
using WIDESEA_Core.Helper;
-using WIDESEA_Core.Log;
using WIDESEA_DTO.Inbound;
using WIDESEA_DTO.Stock;
using WIDESEA_IBasicRepository;
@@ -58,30 +62,153 @@
{
private readonly IMapper _mapper;
private readonly IUnitOfWorkManage _unitOfWorkManage;
-
+ private readonly IStockRepository _stockRepository;
private readonly IBasicService _basicService;
- private readonly IOutboundService _outboundService;
- private readonly IInboundService _inboundService;
private readonly IRecordService _recordService;
- private readonly IStockService _stockService;
- private readonly ITask_HtyService _taskHtyService;
- private readonly ILocationInfoService _locationInfoService;
public ITaskRepository Repository => BaseDal;
- public TaskService(ITaskRepository BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IBasicService basicService, IOutboundService outboundService, IInboundService inboundService, IRecordService recordService, IStockService stockService, ITask_HtyService taskHtyService, ILocationInfoService locationInfoService) : base(BaseDal)
+ public TaskService(ITaskRepository BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IStockRepository stockRepository, IBasicService basicService, IRecordService recordService) : base(BaseDal)
{
_mapper = mapper;
_unitOfWorkManage = unitOfWorkManage;
+ _stockRepository = stockRepository;
_basicService = basicService;
- _outboundService = outboundService;
- _inboundService = inboundService;
_recordService = recordService;
- _stockService = stockService;
- _taskHtyService = taskHtyService;
- _locationInfoService = locationInfoService;
}
-
+ public WebResponseContent RequestInboundTask(string palletCode, string stationCode)
+ {
+ try
+ {
+ Dt_Task task = Repository.QueryFirst(x => x.PalletCode == palletCode);
+ if (task != null)
+ {
+ return WebResponseContent.Instance.Error($"璇ユ墭鐩樺凡鐢熸垚浠诲姟");
+ }
+
+ Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == palletCode);
+ if (stockInfo == null)
+ {
+ return WebResponseContent.Instance.Error($"鏈壘鍒扮粍鐩樹俊鎭�");
+ }
+ if (stockInfo.StockStatus != StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt())
+ {
+ return WebResponseContent.Instance.Error($"璇ユ墭鐩樼姸鎬佷笉姝g‘,涓嶅彲鐢宠鍏ュ簱");
+ }
+ if (!string.IsNullOrEmpty(stockInfo.LocationCode))
+ {
+ return WebResponseContent.Instance.Error($"璇ユ墭鐩樺凡缁戝畾璐т綅");
+ }
+
+ //todo 閫氳繃绔欏彴鍙锋壘宸烽亾鍙�
+ string roadwayNo = "RSC01";
+
+ PalletTypeEnum palletType = PalletTypeEnum.SmallPallet;
+
+ Dt_LocationInfo? locationInfo = _basicService.LocationInfoService.AssignLocation(roadwayNo, palletType);
+ if (locationInfo == null)
+ {
+ return WebResponseContent.Instance.Error($"璐т綅鍒嗛厤澶辫触,鏈壘鍒板彲鍒嗛厤璐т綅");
+ }
+ Dt_Task newTask = new Dt_Task()
+ {
+ CurrentAddress = stationCode,
+ Grade = 0,
+ NextAddress = "",
+ PalletCode = palletCode,
+ Roadway = roadwayNo,
+ SourceAddress = stationCode,
+ TargetAddress = locationInfo.LocationCode,
+ TaskType = TaskTypeEnum.Inbound.ObjToInt(),
+ TaskStatus = InTaskStatusEnum.InNew.ObjToInt(),
+ };
+
+ LocationStatusEnum lastStatus = (LocationStatusEnum)locationInfo.LocationStatus;
+
+ stockInfo.StockStatus = StockStatusEmun.鍏ュ簱纭.ObjToInt();
+
+ _unitOfWorkManage.BeginTran();
+ int taskId = BaseDal.AddData(newTask);
+ newTask.TaskId = taskId;
+ _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, lastStatus, LocationChangeType.InboundAssignLocation);
+ _basicService.LocationInfoService.UpdateLocationStatus(locationInfo, palletType, LocationStatusEnum.Lock);
+ _stockRepository.StockInfoRepository.UpdateData(stockInfo);
+ _unitOfWorkManage.CommitTran();
+
+ return WebResponseContent.Instance.OK(data: newTask);
+ }
+ catch (Exception ex)
+ {
+ _unitOfWorkManage.RollbackTran();
+ return WebResponseContent.Instance.Error(ex.Message);
+ }
+ }
+
+ public WebResponseContent InboundTaskCompleted(int taskNum)
+ {
+ try
+ {
+ Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum);
+ if (task == null)
+ {
+ return WebResponseContent.Instance.Error($"鏈壘鍒拌浠诲姟淇℃伅");
+ }
+
+ if (task.TaskType != TaskTypeEnum.Inbound.ObjToInt())
+ {
+ return WebResponseContent.Instance.Error($"浠诲姟绫诲瀷閿欒");
+ }
+
+ Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletCode == task.PalletCode).Includes(x => x.Details).First();
+ if (stockInfo == null)
+ {
+ return WebResponseContent.Instance.Error($"鏈壘鍒版墭鐩樺搴旂殑缁勭洏淇℃伅");
+ }
+
+ if (!string.IsNullOrEmpty(stockInfo.LocationCode))
+ {
+ return WebResponseContent.Instance.Error($"璇ユ墭鐩樺凡缁戝畾璐т綅");
+ }
+
+ if (stockInfo.Details == null || stockInfo.Details.Count == 0)
+ {
+ return WebResponseContent.Instance.Error($"鏈壘鍒拌鎵樼洏搴撳瓨鏄庣粏淇℃伅");
+ }
+
+ Dt_LocationInfo locationInfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress);
+ if (locationInfo == null)
+ {
+ return WebResponseContent.Instance.Error($"鏈壘鍒扮洰鏍囪揣浣嶄俊鎭�");
+ }
+
+ if (locationInfo.LocationStatus == LocationStatusEnum.InStock.ObjToInt())
+ {
+ return WebResponseContent.Instance.Error($"璐т綅鐘舵�佷笉姝g‘");
+ }
+
+ LocationStatusEnum lastStatus = (LocationStatusEnum)locationInfo.LocationStatus;
+ locationInfo.LocationStatus = LocationStatusEnum.InStock.ObjToInt();
+
+ stockInfo.StockStatus = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt();
+ stockInfo.LocationCode = locationInfo.LocationCode;
+
+ _unitOfWorkManage.BeginTran();
+ BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? OperateTypeEnum.浜哄伐瀹屾垚 : OperateTypeEnum.鑷姩瀹屾垚);
+
+ _basicService.LocationInfoService.Repository.UpdateData(locationInfo);
+
+ _stockRepository.StockInfoRepository.UpdateData(stockInfo);
+
+ _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, lastStatus, LocationChangeType.InboundCompleted);
+ _unitOfWorkManage.CommitTran();
+ return WebResponseContent.Instance.OK();
+ }
+ catch (Exception ex)
+ {
+ _unitOfWorkManage.RollbackTran();
+ return WebResponseContent.Instance.Error(ex.Message);
+ }
+ }
}
}
--
Gitblit v1.9.3