| | |
| | | try |
| | | { |
| | | // 更新货位和库存信息 |
| | | (DtStockInfo updateStock, DtLocationInfo locationInf) = UpdateStockLocation(stock, task.NextAddress); |
| | | (DtStockInfo updateStock, DtLocationInfo locationInForm, DtLocationInfo locationInfoTo) = UpdateStockLocation(stock, task); |
| | | var taskHty = CreateHistoricalTask(task); |
| | | LogFactory.GetLog("任务完成").InfoFormat(true, "移库任务完成", $"货位地址:{task.TargetAddress},修改后库存数据:{JsonConvert.SerializeObject(updateStock)},原先货位数据:{locationInf}"); |
| | | LogFactory.GetLog("任务完成").InfoFormat(true, "移库任务完成", $"货位地址:{task.TargetAddress},修改后库存数据:{JsonConvert.SerializeObject(updateStock)},原先货位数据:{locationInForm}"); |
| | | |
| | | // 执行数据库事务 |
| | | bool isResult = await ExecuteTransaction(updateStock, taskHty, locationInf, task.TaskId); |
| | | bool isResult = await ExecuteTransaction(updateStock, taskHty, locationInForm, locationInfoTo, task.TaskId); |
| | | if (isResult) |
| | | content.OK("移库任务完成成功"); |
| | | else |
| | |
| | | LogFactory.GetLog("任务完成").InfoFormat(true, "出库任务", ""); |
| | | return await CompleteStackTaskAsync(task, stock); |
| | | |
| | | case (int)TaskRelocationTypeEnum.Relocation: |
| | | return await CompleteTransferTaskAsync(task, stock); |
| | | default: |
| | | return content.Error("任务类型不存在"); |
| | | } |
| | |
| | | /// <param name="areaCode">区域编码</param> |
| | | /// <param name="roadways">巷道编码集合</param> |
| | | /// <returns>返回结果集</returns> |
| | | public async Task<WebResponseContent> RequestTrayOutTaskAsync(string position, int tag, string areaCode, List<string> roadways) |
| | | public async Task<WebResponseContent> RequestTrayOutTaskAsync(string position, int tag, string areaCode, string productionLine) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | // 根据托盘类型查询库存信息 |
| | | DtStockInfo stockInfo = tag == (int)TaskOutboundTypeEnum.Outbound |
| | | ? QueryStockInfoForRealTrayAsync(areaCode, roadways).Result |
| | | : QueryStockInfoForEmptyTrayAsync(areaCode, roadways).Result; |
| | | ? QueryStockInfoForRealTrayAsync(areaCode, productionLine).Result |
| | | : QueryStockInfoForEmptyTrayAsync(areaCode).Result; |
| | | |
| | | if (stockInfo == null) |
| | | { |
| | |
| | | /// <summary> |
| | | /// 查询实盘库存信息 |
| | | /// </summary> |
| | | private async Task<DtStockInfo> QueryStockInfoForRealTrayAsync(string areaCode, List<string> roadways) |
| | | private async Task<DtStockInfo> QueryStockInfoForRealTrayAsync(string areaCode, string productionLine) |
| | | { |
| | | var area = await _areaInfoRepository.QueryFirstAsync(x => x.AreaCode == areaCode); |
| | | |
| | |
| | | .Includes(x => x.LocationInfo) // 预加载LocationInfo |
| | | .Includes(x => x.StockInfoDetails) // 预加载StockInfoDetails |
| | | .Where(x => x.AreaCode == areaCode && x.OutboundTime < DateTime.Now && x.IsFull == true) // 过滤条件 |
| | | .WhereIF(!productionLine.IsNullOrEmpty(), x => x.ProductionLine == productionLine) |
| | | .Where(x => x.LocationInfo.LocationStatus == (int)LocationEnum.InStock && x.LocationInfo.AreaId == area.AreaID) // 过滤条件 |
| | | .OrderBy(x => x.OutboundTime) // 排序 |
| | | .FirstAsync(); // 获取第一个元素 |
| | |
| | | /// <summary> |
| | | /// 查询空盘库存信息 |
| | | /// </summary> |
| | | private async Task<DtStockInfo> QueryStockInfoForEmptyTrayAsync(string areaCode, List<string> roadways) |
| | | private async Task<DtStockInfo> QueryStockInfoForEmptyTrayAsync(string areaCode) |
| | | { |
| | | var area = await _areaInfoRepository.QueryFirstAsync(x => x.AreaCode == areaCode); |
| | | |
| | |
| | | /// <param name="stock">库存对象</param> |
| | | /// <param name="toLocation">目标位置</param> |
| | | // 更新库存和位置信息 |
| | | private (DtStockInfo, DtLocationInfo) UpdateStockLocation(DtStockInfo stock, string toLocation) |
| | | private (DtStockInfo, DtLocationInfo, DtLocationInfo) UpdateStockLocation(DtStockInfo stock, Dt_Task task) |
| | | { |
| | | // 获取库存信息 |
| | | var locationInfo = _locationRepository.QueryFirst(x => x.LocationCode == stock.LocationCode); |
| | | // 将库存状态设置为在库 |
| | | locationInfo.LocationStatus = LocationEnum.InStock.ObjToInt(); |
| | | //修改来源库位和 目标库位状态 |
| | | var fromLocation = _locationRepository.QueryFirst(x => x.LocationCode == task.SourceAddress && x.RoadwayNo == task.Roadway); |
| | | fromLocation.LocationStatus = LocationEnum.Free.ObjToInt(); |
| | | var toLocation = _locationRepository.QueryFirst(x => x.LocationCode == task.SourceAddress && x.RoadwayNo == task.Roadway); |
| | | toLocation.LocationStatus = LocationEnum.InStock.ObjToInt(); |
| | | |
| | | // 将库存位置设置为目标位置 |
| | | stock.LocationCode = toLocation; |
| | | // 将库存状态设置为在库 |
| | | stock.LocationInfo.LocationStatus = LocationEnum.InStock.ObjToInt(); |
| | | stock.LocationCode = task.TargetAddress; |
| | | |
| | | // 返回更新后的库存和位置信息 |
| | | return (stock, locationInfo); |
| | | return (stock, fromLocation, toLocation); |
| | | } |
| | | |
| | | /// <summary> |