更新货位变动信息记录,WCS堆垛机入库执行中下一步
| | |
| | | } |
| | | else if (task.TaskState == (int)TaskInStatusEnum.SC_InFinish) |
| | | { |
| | | if (App.User.UserId > 0) |
| | | { |
| | | content = StackCraneTaskCompleted(task.TaskNum); |
| | | return content; |
| | | } |
| | | |
| | | |
| | | task.ModifyDate = DateTime.Now; |
| | | task.Modifier = "System"; |
| | | |
| | |
| | | // icon: 'el-icon-printer', |
| | | type: 'primary', |
| | | // plain: true, |
| | | color: '#529b2e', |
| | | // color: '#529b2e', |
| | | value: 'TaskHandComplete', |
| | | onClick: function () { |
| | | |
| | |
| | | // icon: 'el-icon-printer', |
| | | type: 'primary', |
| | | // plain: true, |
| | | color: '#529b2e', |
| | | // color: '#529b2e', |
| | | value: 'OutBound', |
| | | onClick: function () { |
| | | |
| | | } |
| | | },{ |
| | | name: '初始化库位', |
| | | type: 'primary', |
| | | // color: '#529b2e', |
| | | value: 'initializeLocation', |
| | | onClick: function () { |
| | | |
| | | } |
| | | } |
| | | ] |
| | | |
| | |
| | | // this.$Message.success('点击了按钮'); |
| | | // } |
| | | // }); |
| | | var btninitializeLocation = this.buttons.find(x => x.value == "initializeLocation"); |
| | | if (btninitializeLocation != null) { |
| | | btninitializeLocation.onClick = () => { |
| | | let rows = this.$refs.table.getSelected(); |
| | | if (rows.length == 0) return this.$error("请选择数据!"); |
| | | this.http |
| | | .post("api/LocationInfo/initializeLocation?locationID="+rows[0].id, "","数据处理中...") |
| | | .then((x) => { |
| | | if (x.status) { |
| | | this.$Message.success('成功.'); |
| | | this.refresh(); |
| | | } else { |
| | | return this.$error(x.message); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | |
| | | var btnEnableLocation = this.buttons.find(x => x.value == "EnableLocation"); |
| | | if (btnEnableLocation != null) { |
| | | btnEnableLocation.onClick = () => { |
| | |
| | | /// <param name="changeRecordDto">数据模型</param> |
| | | /// <returns></returns> |
| | | bool AddStatusChangeRecord(LocationChangeRecordDto changeRecordDto); |
| | | |
| | | void AddLocationStatusChangeRecord(DtLocationInfo locationInfo, int lastStatus, int changeType, int? taskNum); |
| | | |
| | | void AddLocationStatusChangeRecord(List<DtLocationInfo> locationInfos, int newStatus, int changeType, List<int>? taskNums); |
| | | } |
| | |
| | | /// <returns>任务对象</returns> |
| | | Task<Dt_Task> TransferCheckAsync(int taskNum); |
| | | |
| | | Task<WebResponseContent> initializeLocation(int locationID); |
| | | |
| | | WebResponseContent CreateLocation(int x, int y, int z, int locType, int areaId); |
| | | } |
| | |
| | | using WIDESEA_DTO; |
| | | using WIDESEA_Core; |
| | | using WIDESEA_DTO; |
| | | using WIDESEA_Model.Models; |
| | | |
| | | namespace WIDESEA_StorageBasicRepository |
| | | { |
| | |
| | | }; |
| | | return AddData(dtLocationStatusChangeRecord) > 0; |
| | | } |
| | | /// <summary> |
| | | /// 添加货位变动记录 |
| | | /// </summary> |
| | | /// <param name="locationInfo">更新实体</param> |
| | | /// <param name="lastStatus">变动前状态</param> |
| | | /// <param name="changeType">变动类型</param> |
| | | /// <param name="taskNum">任务号</param> |
| | | /// <exception cref="Exception"></exception> |
| | | public void AddLocationStatusChangeRecord(DtLocationInfo locationInfo, int lastStatus, int changeType, int? taskNum) |
| | | { |
| | | try |
| | | { |
| | | DtLocationStatusChangeRecord locationStatusChangeRecord = new DtLocationStatusChangeRecord() |
| | | { |
| | | AfterStatus = locationInfo.LocationStatus, |
| | | BeforeStatus = lastStatus, |
| | | ChangeType = changeType, |
| | | LocationCode = locationInfo.LocationCode, |
| | | LocationId = locationInfo.Id, |
| | | TaskNum = taskNum, |
| | | Creater = "System", |
| | | CreateDate = DateTime.Now, |
| | | }; |
| | | |
| | | base.AddData(locationStatusChangeRecord); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw new Exception($"{ex.Message}"); |
| | | } |
| | | } |
| | | |
| | | public void AddLocationStatusChangeRecord(List<DtLocationInfo> locationInfos, int newStatus, int changeType, List<int>? taskNums) |
| | | { |
| | | try |
| | | { |
| | | List<DtLocationStatusChangeRecord> records = new List<DtLocationStatusChangeRecord>(); |
| | | for (int i = 0; i < locationInfos.Count; i++) |
| | | { |
| | | DtLocationInfo locationInfo = locationInfos[i]; |
| | | int? taskNum = (taskNums != null && taskNums.Count > 0 && taskNums.Count == locationInfos.Count) ? taskNums[i] : null; |
| | | DtLocationStatusChangeRecord locationStatusChangeRecord = new DtLocationStatusChangeRecord() |
| | | { |
| | | AfterStatus = newStatus, |
| | | BeforeStatus = locationInfo.LocationStatus, |
| | | ChangeType = changeType, |
| | | LocationCode = locationInfo.LocationCode, |
| | | LocationId = locationInfo.Id, |
| | | TaskNum = taskNum, |
| | | }; |
| | | records.Add(locationStatusChangeRecord); |
| | | } |
| | | AddData(records); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw new Exception($"{ex.Message}"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | using WIDESEA_Common; |
| | | using AngleSharp.Dom; |
| | | using Mapster; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Common; |
| | | using WIDESEA_Core; |
| | | using WIDESEA_DTO; |
| | | using WIDESEA_Model.Models; |
| | | |
| | | namespace WIDESEA_StorageBasicService; |
| | | |
| | |
| | | private readonly LogFactory LogFactory = new LogFactory(); |
| | | private readonly IUnitOfWorkManage _unitOfWorkManage; |
| | | private readonly IDt_TaskRepository _taskRepository; |
| | | private readonly IDt_TaskService _taskService; |
| | | private readonly IStockInfoRepository _stockInfoRepository; |
| | | private readonly IStockInfoDetailRepository _stockInfoDetailRepository; |
| | | private readonly IDt_WareAreaInfoRepository _wareAreaInfoRepository; |
| | | private readonly IPointStackerRelationRepository _pointStackerRelationRepository; |
| | | private readonly ITaskExecuteDetailRepository _taskExecuteDetailRepository; |
| | | private readonly ILocationStatusChangeRecordRepository _locationStatusChangeRecordRepository; |
| | | private readonly IMapper _mapper; |
| | | |
| | | public LocationInfoService(ILocationInfoRepository BaseDal, |
| | | IUnitOfWorkManage unitOfWorkManage, |
| | |
| | | IDt_WareAreaInfoRepository wareAreaInfoRepository, |
| | | IPointStackerRelationRepository pointStackerRelationRepository, |
| | | ITaskExecuteDetailRepository taskExecuteDetailRepository, |
| | | ILocationStatusChangeRecordRepository locationStatusChangeRecordRepository) : base(BaseDal) |
| | | ILocationStatusChangeRecordRepository locationStatusChangeRecordRepository, |
| | | IStockInfoDetailRepository stockInfoDetailRepository, |
| | | IMapper mapper, |
| | | IDt_TaskService taskService) : base(BaseDal) |
| | | { |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | | _taskRepository = taskRepository; |
| | |
| | | _pointStackerRelationRepository = pointStackerRelationRepository; |
| | | _taskExecuteDetailRepository = taskExecuteDetailRepository; |
| | | _locationStatusChangeRecordRepository = locationStatusChangeRecordRepository; |
| | | _stockInfoDetailRepository = stockInfoDetailRepository; |
| | | _mapper = mapper; |
| | | _taskService = taskService; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | |
| | | return base.UpdateData(saveModel); |
| | | } |
| | | #region 初始化库位 |
| | | public async Task<WebResponseContent> initializeLocation(int locationID) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | DtLocationInfo? location = BaseDal.QueryData(x => x.Id == locationID).FirstOrDefault(); |
| | | int LastStatus = location.LocationStatus; |
| | | if (location == null) |
| | | { |
| | | return content.Error("未找到货位信息!"); |
| | | } |
| | | DtStockInfo stock = _stockInfoRepository.QueryFirst(x => x.LocationId == location.Id); |
| | | if(stock == null) |
| | | { |
| | | location.LocationStatus= (int)LocationEnum.Lock; |
| | | BaseDal.UpdateData(location); |
| | | } |
| | | else |
| | | { |
| | | _unitOfWorkManage.BeginTran(); |
| | | DtStockInfo_Hty stockInfo_Hty = stock.Adapt<DtStockInfo_Hty>(); |
| | | stockInfo_Hty.ModifyDate = DateTime.Now; |
| | | await DeleteStockInfoAsync(stock.Id); |
| | | List<DtStockInfoDetail> detail = _stockInfoDetailRepository.QueryData(x => x.StockId == stock.Id).ToList(); |
| | | if (detail != null && detail.Count() > 0) |
| | | { |
| | | await DeleteStockInfoDetailsAsync(detail); |
| | | } |
| | | await AddStockInfoHtyAsync(stockInfo_Hty); |
| | | |
| | | location.LocationStatus = (int)LocationEnum.Lock; |
| | | BaseDal.UpdateData(location); |
| | | |
| | | _locationStatusChangeRecordRepository.AddLocationStatusChangeRecord(location, LastStatus, (int)StatusChangeTypeEnum.ManualOperation, 0); |
| | | _unitOfWorkManage.CommitTran(); |
| | | } |
| | | return content.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return content.Error(ex.Message); |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 创建原始货位数据 |
| | | |
| | |
| | | |
| | | #endregion 创建初始货位方法 |
| | | |
| | | #region 库存移入历史 |
| | | private async Task DeleteStockInfoAsync(int stockId) |
| | | { |
| | | var isStockUpdated = await _stockInfoRepository.DeleteDataByIdAsync(stockId); |
| | | if (!isStockUpdated) |
| | | { |
| | | throw new Exception("库存信息更新失败"); |
| | | } |
| | | } |
| | | |
| | | private async Task AddStockInfoHtyAsync(DtStockInfo_Hty dtStock) |
| | | { |
| | | var isStockAdd = await SqlSugarHelper.Db.InsertNav(dtStock).IncludesAllFirstLayer().ExecuteCommandAsync(); |
| | | if (!isStockAdd) |
| | | { |
| | | throw new Exception("库存历史信息添加失败"); |
| | | } |
| | | } |
| | | |
| | | private async Task DeleteStockInfoDetailsAsync(IEnumerable<DtStockInfoDetail> details) |
| | | { |
| | | var ids = details.Select(x => (object)x.Id).ToArray(); |
| | | var isStockDetailUpdated = await _stockInfoDetailRepository.DeleteDataByIdsAsync(ids); |
| | | if (!isStockDetailUpdated) |
| | | { |
| | | throw new Exception("库存详情信息更新失败"); |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #endregion 内部方法 |
| | | } |
| | |
| | | using AngleSharp.Dom; |
| | | using log4net.Core; |
| | | using Mapster; |
| | | using Masuit.Tools; |
| | | using SixLabors.Fonts.Tables.AdvancedTypographic; |
| | |
| | | using WIDESEA_DTO.WMS; |
| | | using WIDESEA_IServices; |
| | | using WIDESEA_IStoragIntegrationServices; |
| | | using WIDESEA_StorageBasicRepository; |
| | | using WIDESEA_StoragIntegrationServices; |
| | | using WIDESEAWCS_BasicInfoRepository; |
| | | |
| | |
| | | { |
| | | var location = _locationRepository.QueryFirst(x => x.LocationCode == task.SourceAddress && x.RoadwayNo == task.Roadway); |
| | | //var details = _stockInfoDetailRepository.QueryData(x => x.StockId == stock.Id); |
| | | |
| | | int lastStatus = location.LocationStatus; |
| | | location.LocationStatus = (int)LocationEnum.Free; |
| | | task.TaskState = (int)TaskOutStatusEnum.OutFinish; |
| | | //task.CurrentAddress = task.NextAddress; |
| | | //task.NextAddress = task.TargetAddress; |
| | | |
| | | _locationStatusChangeRecordRepository.AddLocationStatusChangeRecord(location, lastStatus, (int)StatusChangeTypeEnum.AutomaticDelivery,task.TaskNum); |
| | | |
| | | LogFactory.GetLog("任务完成").Info(true, "更新库存状态与任务状态"); |
| | | return (location, task); |
| | |
| | | try |
| | | { |
| | | // 更新货位和库存信息 |
| | | (DtStockInfo updateStock, DtLocationInfo locationInForm, DtLocationInfo locationInfoTo) = UpdateStockLocation(stock, task); |
| | | (DtStockInfo updateStock, DtLocationInfo locationInForm, DtLocationInfo locationInfoTo) = UpdateStockLocation(stock, task); |
| | | var taskHty = CreateHistoricalTask(task); |
| | | LogFactory.GetLog("任务完成").InfoFormat(true, "移库任务完成", $"货位地址:{task.TargetAddress},修改后库存数据:{JsonConvert.SerializeObject(updateStock)},原先货位数据:{locationInForm}"); |
| | | |
| | |
| | | var boxing = await _boxingInfoRepository.QueryFirstNavAsync(x => x.PalletCode == task.PalletCode); |
| | | var locationInf = await _locationRepository.QueryFirstAsync(x => x.LocationCode == task.TargetAddress && x.RoadwayNo == task.Roadway); |
| | | |
| | | int lastStatus = locationInf.LocationStatus; |
| | | // 更新目标位置状态为库存中 |
| | | locationInf.LocationStatus = (int)LocationEnum.InStock; |
| | | |
| | |
| | | await _locationRepository.UpdateDataAsync(locationInf); |
| | | await _task_HtyRepository.AddDataAsync(taskHty); |
| | | await BaseDal.DeleteDataAsync(task); |
| | | |
| | | //记录货位变动信息 |
| | | _locationStatusChangeRecordRepository.AddLocationStatusChangeRecord(locationInf, lastStatus, (int)StatusChangeTypeEnum.AutomaticStorage, task.TaskNum); |
| | | |
| | | return content.OK("入库任务完成成功"); |
| | | } |
| | | // 根据是否有组盘信息创建库存实例模型 |
| | |
| | | bool isResult = await ExecuteTransaction(stock, taskHty, locationInf, task.TaskId, boxing); |
| | | if (isResult) |
| | | { |
| | | _locationStatusChangeRecordRepository.AddLocationStatusChangeRecord(locationInf, lastStatus, (int)StatusChangeTypeEnum.AutomaticStorage, task.TaskNum); |
| | | content.OK("入库任务完成成功"); |
| | | } |
| | | else |
| | |
| | | TaskNum = await BaseDal.GetTaskNo(), |
| | | Creater = "Systeam" |
| | | }; |
| | | ConsoleHelper.WriteSuccessLine($"修改前:" + locationInfo.LocationStatus.ToString()); |
| | | int lastStatus = locationInfo.LocationStatus; |
| | | ConsoleHelper.WriteSuccessLine($"修改前:" + lastStatus.ToString()); |
| | | locationInfo.LocationStatus = (int)LocationEnum.FreeDisable; |
| | | ConsoleHelper.WriteSuccessLine($"修改后:" + locationInfo.LocationStatus.ToString()); |
| | | await UpdateLocationAsync(locationInfo); |
| | | |
| | | _locationStatusChangeRecordRepository.AddLocationStatusChangeRecord(locationInfo, lastStatus, (int)StatusChangeTypeEnum.AutomaticStorage, task.TaskNum); |
| | | |
| | | return task; |
| | | } |
| | |
| | | |
| | | var isBox = await _boxingInfoRepository.AddDataNavAsync(boxing); |
| | | |
| | | ConsoleHelper.WriteSuccessLine($"修改前:" + locationInfo.LocationStatus.ToString()); |
| | | int lastStatus = locationInfo.LocationStatus; |
| | | |
| | | ConsoleHelper.WriteSuccessLine($"修改前:" + lastStatus.ToString()); |
| | | locationInfo.LocationStatus = (int)LocationEnum.FreeDisable; |
| | | ConsoleHelper.WriteSuccessLine($"修改后:" + locationInfo.LocationStatus.ToString()); |
| | | await UpdateLocationAsync(locationInfo); |
| | | |
| | | _locationStatusChangeRecordRepository.AddLocationStatusChangeRecord(locationInfo, lastStatus, (int)StatusChangeTypeEnum.AutomaticStorage, task.TaskNum); |
| | | |
| | | return task; |
| | | } |
| | | catch (Exception ex) |
| | |
| | | var content = JsonConvert.DeserializeObject<WebResponseContent>(result); |
| | | if (content.Status) |
| | | { |
| | | int lastStatus = item.LocationInfo.LocationStatus; |
| | | await BaseDal.AddDataAsync(task); |
| | | // 更新库存位置状态为不可用 |
| | | item.LocationInfo.LocationStatus = (int)LocationEnum.InStockDisable; |
| | | await _locationRepository.UpdateDataAsync(item.LocationInfo); |
| | | |
| | | _locationStatusChangeRecordRepository.AddLocationStatusChangeRecord(item.LocationInfo, lastStatus, (int)StatusChangeTypeEnum.AutomaticDelivery, task.TaskNum); |
| | | } |
| | | } |
| | | } |
| | |
| | | WMSTaskDTO wmsTask = CreateTaskDTO(task); |
| | | |
| | | // 更新库存位置状态为不可用 |
| | | int lastStatus = location.LocationStatus; |
| | | stockInfo.LocationInfo.LocationStatus = (int)LocationEnum.InStockDisable; |
| | | location.LocationStatus = (int)LocationEnum.Distribute; |
| | | await _unitOfWorkManage.UseTranAsync(async () => |
| | |
| | | await _locationRepository.UpdateDataAsync(stockInfo.LocationInfo); |
| | | await _locationRepository.UpdateDataAsync(location); |
| | | }); |
| | | |
| | | _locationStatusChangeRecordRepository.AddLocationStatusChangeRecord(location, lastStatus, (int)StatusChangeTypeEnum.AutomaticDelivery, task.TaskNum); |
| | | |
| | | // 返回成功响应 |
| | | return content.OK(data: wmsTask); |
| | |
| | | |
| | | WMSTaskDTO taskDTO = CreateTaskDTO(task); |
| | | |
| | | int lastStatus = locationInfo.LocationStatus; |
| | | |
| | | BaseDal.AddData(task); |
| | | stockInfo.LocationInfo.LocationStatus = (int)LocationEnum.InStockDisable; |
| | | _locationRepository.UpdateData(stockInfo.LocationInfo); |
| | | |
| | | _locationStatusChangeRecordRepository.AddLocationStatusChangeRecord(stockInfo.LocationInfo, lastStatus, (int)StatusChangeTypeEnum.AutomaticDelivery, task.TaskNum); |
| | | |
| | | return content.OK(data: taskDTO); |
| | | } |
| | | catch (Exception ex) |
| | |
| | | using WIDESEA_DTO; |
| | | using Masuit.Tools.Models; |
| | | using WIDESEA_DTO; |
| | | |
| | | namespace WIDESEA_WMSServer.Controllers; |
| | | |
| | |
| | | { |
| | | return Service.CreateLocation(x, y, z, locType, areaId); |
| | | } |
| | | [HttpPost, AllowAnonymous, Route("initializeLocation")] |
| | | public async Task<WebResponseContent> initializeLocation(int locationID) |
| | | { |
| | | return await Service.initializeLocation(locationID); |
| | | } |
| | | } |