| | |
| | | using MailKit.Search; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.Text; |
| | | using Org.BouncyCastle.Asn1.X509; |
| | | using Org.BouncyCastle.Bcpg; |
| | | using SixLabors.ImageSharp; |
| | | using SqlSugar; |
| | | using System; |
| | |
| | | using System.Collections.Generic; |
| | | using System.Data; |
| | | using System.Linq; |
| | | using System.Net; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Common.AllocateEnum; |
| | |
| | | using WIDESEA_Core.Utilities; |
| | | using WIDESEA_DTO.Allocate; |
| | | using WIDESEA_DTO.Inbound; |
| | | using WIDESEA_DTO.Mes; |
| | | using WIDESEA_DTO.ReturnMES; |
| | | using WIDESEA_IBasicService; |
| | | using WIDESEA_IInboundService; |
| | | using WIDESEA_IStockService; |
| | | using WIDESEA_Model.Models; |
| | | using WIDESEA_Model.Models.Basic; |
| | | using WIDESEA_Model.Models.Check; |
| | | |
| | | namespace WIDESEA_InboundService |
| | | { |
| | |
| | | private readonly IRepository<Dt_AllocateMaterialInfo> _allocateMaterialInfo; |
| | | private readonly HttpClientHelper _httpClientHelper; |
| | | private readonly IRepository<Dt_MesReturnRecord> _mesReturnRecord; |
| | | public InboundService(IUnitOfWorkManage unitOfWorkManage, IInboundOrderDetailService inboundOrderDetailService, IInboundOrderService inbounOrderService, IRepository<Dt_InboundOrder> inboundOrderRepository, IRepository<Dt_WarehouseArea> warehouseAreaRepository, IRepository<Dt_LocationType> locationTypeRepository, IRepository<Dt_StockInfo> stockInfoRepository, IRepository<Dt_InboundOrderDetail> inboundOrderDetailRepository, IStockService stockService, IRepository<Dt_Task> taskRepository,IRepository<Dt_AllocateMaterialInfo> allocateMaterialInfo, HttpClientHelper httpClientHelper, IRepository<Dt_MesReturnRecord> mesReturnRecord) |
| | | private readonly ILocationInfoService _locationInfoService; |
| | | private readonly IRepository<Dt_TakeStockOrder> _takeStockOrder; |
| | | private readonly IRepository<Dt_StockInfoDetail> _stockInfoDetailRepository; |
| | | public InboundService(IUnitOfWorkManage unitOfWorkManage, IInboundOrderDetailService inboundOrderDetailService, IInboundOrderService inbounOrderService, IRepository<Dt_InboundOrder> inboundOrderRepository, IRepository<Dt_WarehouseArea> warehouseAreaRepository, IRepository<Dt_LocationType> locationTypeRepository, IRepository<Dt_StockInfo> stockInfoRepository, IRepository<Dt_InboundOrderDetail> inboundOrderDetailRepository, IStockService stockService, IRepository<Dt_Task> taskRepository,IRepository<Dt_AllocateMaterialInfo> allocateMaterialInfo, HttpClientHelper httpClientHelper, IRepository<Dt_MesReturnRecord> mesReturnRecord,ILocationInfoService locationInfoService,IRepository<Dt_TakeStockOrder> takeStockOrder,IRepository<Dt_StockInfoDetail> stockInfoDetailRepository) |
| | | { |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | | InboundOrderDetailService = inboundOrderDetailService; |
| | |
| | | _allocateMaterialInfo = allocateMaterialInfo; |
| | | _httpClientHelper = httpClientHelper; |
| | | _mesReturnRecord = mesReturnRecord; |
| | | _locationInfoService = locationInfoService; |
| | | _takeStockOrder = takeStockOrder; |
| | | _stockInfoDetailRepository = stockInfoDetailRepository; |
| | | } |
| | | |
| | | public async Task<WebResponseContent> GroupPallet(GroupPalletDto palletDto) |
| | |
| | | } |
| | | |
| | | Dt_InboundOrder inboundOrder = new Dt_InboundOrder(); |
| | | |
| | | var details = _inboundOrderDetailRepository.QueryData(x => (x.OutBoxbarcodes == palletDto.Barcode|| x.Barcode == palletDto.Barcode) && x.OrderDetailStatus == (int)InOrderStatusEnum.æªå¼å§); |
| | | |
| | | if (details.Count() <= 0) |
| | | { |
| | | return content.Error("æªæ¾å°è¯¥æ¡ç åæ®ä¿¡æ¯è¯·ç¡®è®¤æ¯å¦å·²ç»ç»ç宿"); |
| | | var inbounddetail =_inboundOrderDetailRepository.QueryFirst(x => x.Barcode == palletDto.Barcode || x.OutBoxbarcodes == palletDto.Barcode); |
| | | if(inbounddetail == null) |
| | | { |
| | | return content.Error($"æ¡ç {palletDto.Barcode}ä¸åå¨"); |
| | | } |
| | | var inbound = _inboundOrderRepository.Db.Queryable<Dt_InboundOrder>().Where(x => x.Id == inbounddetail.OrderId).First(); |
| | | if (inbound == null) |
| | | { |
| | | return content.Error("åæ®ä¸è½ä¸ºç©º"); |
| | | } |
| | | |
| | | var detail = _inboundOrderDetailRepository.Db.Queryable<Dt_InboundOrderDetail>().LeftJoin<Dt_InboundOrder>((d,o)=>d.OrderId==o.Id).Where((d, o) => d.OrderId == inbound.Id |
| | | && d.ReceiptQuantity != 0 |
| | | && d.OverInQuantity == 0).Select((d, o) => new |
| | | { |
| | | orderNo=o.InboundOrderNo, |
| | | d.Barcode, |
| | | d.MaterielCode, |
| | | d.BatchNo, |
| | | d.ReceiptQuantity, |
| | | d.Unit, |
| | | d.SupplyCode, |
| | | d.WarehouseCode |
| | | }).ToList(); |
| | | var palletId = _stockInfoDetailRepository.QueryFirst(x => x.Barcode == palletDto.Barcode); |
| | | if (palletId == null) |
| | | { |
| | | return content.Error($"æ¡ç æ¡ç {palletDto.Barcode}ä¸åå¨"); |
| | | } |
| | | var pallet =_stockInfoRepository.QueryFirst(x => x.Id == palletId.StockId); |
| | | return content.Error($"æ¡ç {palletDto.Barcode}å·²ç»ç»å°{pallet.PalletCode}",detail); |
| | | } |
| | | inboundOrder = _inboundOrderRepository.Db.Queryable<Dt_InboundOrder>().Includes(x=>x.Details).Where(x => x.Id == details.First().OrderId).First(); |
| | | |
| | |
| | | { |
| | | return content.Error("æªæ¾å°è¯¥æ¡ç 主åä¿¡æ¯"); |
| | | } |
| | | if(inboundOrder.OrderStatus == (int)InOrderStatusEnum.æå¨å
³é) |
| | | { |
| | | return content.Error("è¯¥åæ®çç¶æä¸è½ç»ç"); |
| | | } |
| | | var warehouse =_warehouseAreaRepository.QueryFirst(x => x.Code == palletDto.WarehouseType); |
| | | if(inboundOrder.BusinessType=="11" && inboundOrder.FactoryArea != warehouse.FactoryArea) |
| | | { |
| | | return content.Error($"å½åååºä¸ä¸è´"); |
| | | } |
| | | |
| | | if(inboundOrder.BusinessType != "11"&& inboundOrder.Details.FirstOrDefault().WarehouseCode != palletDto.WarehouseType) |
| | | { |
| | | return content.Error($"该æ¡ç æå±ä»åºä¸º{inboundOrder.Details.FirstOrDefault().WarehouseCode}ä¸å½åä»åº{palletDto.WarehouseType}ä¸ä¸è´ï¼ä¸å
许ç»ç"); |
| | | } |
| | | |
| | | Dt_StockInfo? stockInfo = await _stockInfoRepository.Db.Queryable<Dt_StockInfo>().Includes(x => x.Details).Where(x => x.PalletCode == palletDto.PalletCode).FirstAsync(); |
| | | |
| | | List<string?> materielCodes = details.GroupBy(x => x.Barcode).Select(x => x.Key).ToList(); |
| | |
| | | stockInfo.Details = new List<Dt_StockInfoDetail>(); |
| | | } |
| | | |
| | | if (stockInfo != null && stockInfo.Details.Count>0 && stockInfo.Details.FirstOrDefault()?.WarehouseCode != palletDto.WarehouseType) |
| | | if (inboundOrder.BusinessType != MESDocumentType.PurchaseInbound.ToString() && stockInfo != null && stockInfo.Details.Count > 0 && stockInfo.Details.FirstOrDefault()?.WarehouseCode != palletDto.WarehouseType) |
| | | { |
| | | return content.Error($"该æçç»çä»åºä¸º{stockInfo.Details.FirstOrDefault()?.WarehouseCode}ä¸å½åä»åº{palletDto.WarehouseType}ä¸ä¸è´ï¼ä¸å
许ç»ç"); |
| | | } |
| | | |
| | | if (!_locationInfoService.QueryLocationCount(Convert.ToInt32(palletDto.locationType))) |
| | | { |
| | | return content.Error($"该åºåº{palletDto.locationType}ä¸åå¨ç©ºé²åºä½"); |
| | | } |
| | | |
| | | foreach (var item in details) |
| | | { |
| | | var datevaliDate = _inboundOrderRepository.Db.Queryable<Dt_MaterialExpirationDate>().Where(x=>x.MaterialCode.Contains(item.MaterielCode.Substring(0,6))).First(); |
| | | |
| | | var datevaliDate = _inboundOrderRepository.Db.Queryable<Dt_MaterialExpirationDate>().Where(x => x.MaterialCode.Contains(item.MaterielCode.Substring(0, 6))).First(); |
| | | if (datevaliDate == null) |
| | | { |
| | | return content.Error($"è¯¥ç©æ{item.MaterielCode}æªæ¾å°MESæ¨éçææææ°æ®ï¼è¯·å
æ·»å è¯¥ç©æçæææåç»çå
¥åº"); |
| | | } |
| | | stockInfo.Details.Add(new Dt_StockInfoDetail |
| | | { |
| | | StockId = stockInfo == null ? 0 : stockInfo.Id, |
| | |
| | | .Where(x => x.OrderId == inboundOrder.Id && x.OrderDetailStatus==(int)OrderDetailStatusEnum.Over && x.ReturnToMESStatus == 0) |
| | | .ToList(); |
| | | |
| | | var stocks = _stockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.StockStatus == 6) |
| | | var stocks = _stockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.StockStatus == (int)StockStatusEmun.å
¥åºå®æ) |
| | | .Where(it => SqlFunc.Subqueryable<Dt_StockInfoDetail>().Where(s => s.StockId == it.Id && s.OrderNo == inboundOrder.InboundOrderNo).Any()) |
| | | .ToList(); |
| | | |
| | |
| | | |
| | | if (allocatefeedmodel.Details.Count <= 0) |
| | | { |
| | | throw new Exception("æªæ¾å°éè¦åä¼ çæ°æ®"); |
| | | if (returnRecords.Count() == returnRecords.Count(x => x.ReturnStatus == 1)) |
| | | { |
| | | inboundOrder.ReturnToMESStatus = 1; |
| | | } |
| | | else if (returnRecords.Count(x => x.ReturnStatus == 2) > 0) |
| | | { |
| | | inboundOrder.ReturnToMESStatus = 4; |
| | | } |
| | | else if (returnRecords.Count() == returnRecords.Count(x => x.ReturnStatus == 2)) |
| | | { |
| | | inboundOrder.ReturnToMESStatus = 2; |
| | | } |
| | | _inboundOrderRepository.UpdateData(inboundOrder); |
| | | return WebResponseContent.Instance.OK($"è¯¥åæ®æ²¡æéè¦åä¼ æç»ï¼å¤±è´¥æ°æ®åä¼ {returnRecords.Count()}æ¡ï¼åä¼ æå{returnRecords.Count(x => x.ReturnStatus == 1)}æ¡ï¼åä¼ å¤±è´¥{returnRecords.Count(x => x.ReturnStatus == 2)}æ¡"); |
| | | } |
| | | |
| | | var response = responseModel(inboundOrder, 3, null, allocatefeedmodel); |
| | |
| | | |
| | | if (feedmodel.details.Count<=0) |
| | | { |
| | | throw new Exception("æªæ¾å°éè¦åä¼ çæ°æ®"); |
| | | if (returnRecords.Count() == returnRecords.Count(x => x.ReturnStatus == 1)) |
| | | { |
| | | inboundOrder.ReturnToMESStatus = 1; |
| | | } |
| | | else if (returnRecords.Count(x => x.ReturnStatus == 2) > 0) |
| | | { |
| | | inboundOrder.ReturnToMESStatus = 4; |
| | | } |
| | | else if (returnRecords.Count() == returnRecords.Count(x => x.ReturnStatus == 2)) |
| | | { |
| | | inboundOrder.ReturnToMESStatus = 2; |
| | | } |
| | | _inboundOrderRepository.UpdateData(inboundOrder); |
| | | return WebResponseContent.Instance.OK($"è¯¥åæ®æ²¡æéè¦åä¼ æç»ï¼å¤±è´¥æ°æ®åä¼ {returnRecords.Count()}æ¡ï¼åä¼ æå{returnRecords.Count(x => x.ReturnStatus == 1)}æ¡ï¼åä¼ å¤±è´¥{returnRecords.Count(x => x.ReturnStatus == 2)}æ¡"); |
| | | } |
| | | var response = responseModel(inboundOrder, 3, feedmodel); |
| | | |
| | |
| | | |
| | | return httpResponseResult; |
| | | } |
| | | |
| | | public async Task<WebResponseContent> StockTakeGroupPallet(GroupPalletDto palletDto) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | (bool, string, object?) result2 = ModelValidate.ValidateModelData(palletDto); |
| | | if (!result2.Item1) return content.Error(result2.Item2); |
| | | |
| | | // éªè¯ä»åºç¼å·æ¯å¦åå¨ |
| | | var code = _warehouseAreaRepository.Db.Queryable<Dt_WarehouseArea>() |
| | | .Where(x => x.Code == palletDto.WarehouseType) |
| | | .Select(x => x.Code) |
| | | .First(); |
| | | if (string.IsNullOrEmpty(code)) |
| | | { |
| | | return content.Error($"ä»åºä¸æ²¡æè¯¥{palletDto.WarehouseType}ç¼å·ã"); |
| | | } |
| | | |
| | | // æ¥è¯¢å½åæççåºåä¿¡æ¯ |
| | | Dt_StockInfo? stockInfo = await _stockInfoRepository.Db.Queryable<Dt_StockInfo>() |
| | | .Includes(x => x.Details) |
| | | .Where(x => x.PalletCode == palletDto.PalletCode) |
| | | .FirstAsync(); |
| | | |
| | | // éªè¯æçæ¯å¦å·²çæä»»å¡ |
| | | if (_taskRepository.QueryFirst(x => x.PalletCode == palletDto.PalletCode) != null) |
| | | { |
| | | return content.Error($"该æçå·²çæä»»å¡"); |
| | | } |
| | | |
| | | // éªè¯æçæ¯å¦å·²ä¸æ¶ï¼å·²ä¸æ¶ä¸è½ç»çï¼ |
| | | if (stockInfo != null && !string.IsNullOrEmpty(stockInfo.LocationCode) && stockInfo.StockStatus != (int)StockStatusEmun.ç»çæå) |
| | | { |
| | | return content.Error("已䏿¶çæçä¸è½å次ç»ç"); |
| | | } |
| | | |
| | | Dt_StockInfoDetail stockInfoDetail = _stockService.StockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>() |
| | | .Where(x => x.Barcode == palletDto.Barcode && x.StockId == 0) |
| | | .First(); |
| | | if (stockInfoDetail == null) |
| | | { |
| | | return content.Error($"{palletDto.Barcode} æ¡ç å·²å
³èå
¶ä»æçï¼æ æ³ç»ç"); |
| | | } |
| | | |
| | | Dt_TakeStockOrder takeStockOrder = _takeStockOrder.Db.Queryable<Dt_TakeStockOrder>() |
| | | .Where(x => x.OrderNo == stockInfoDetail.OrderNo) |
| | | .First(); |
| | | if (takeStockOrder == null) |
| | | { |
| | | return content.Error($"{palletDto.Barcode} ä¸å±äºçç¹åæ®ä¸çæ¡ç ï¼ä¸å
许çäºç»ç"); |
| | | } |
| | | if (stockInfo == null) |
| | | { |
| | | stockInfo = new Dt_StockInfo() |
| | | { |
| | | PalletType = (int)PalletTypeEnum.None, |
| | | LocationType = Convert.ToInt32(palletDto.locationType), |
| | | PalletCode = palletDto.PalletCode, |
| | | StockStatus = (int)StockStatusEmun.ç»çæå, |
| | | Details = new List<Dt_StockInfoDetail>() |
| | | }; |
| | | } |
| | | |
| | | if (stockInfo.Details.Count > 0 && stockInfo.Details.FirstOrDefault()?.WarehouseCode != palletDto.WarehouseType) |
| | | { |
| | | return content.Error($"该æçç»çä»åºä¸º{stockInfo.Details.FirstOrDefault()?.WarehouseCode}ä¸å½åä»åº{palletDto.WarehouseType}ä¸ä¸è´ï¼ä¸å
许ç»ç"); |
| | | } |
| | | |
| | | _unitOfWorkManage.BeginTran(); |
| | | |
| | | try |
| | | { |
| | | if (stockInfo.Id == 0) |
| | | { |
| | | int newStockId = await _stockInfoRepository.Db.Insertable(stockInfo).ExecuteReturnIdentityAsync(); |
| | | stockInfo.Id = newStockId; |
| | | } |
| | | |
| | | stockInfoDetail.StockId = stockInfo.Id; |
| | | |
| | | await _stockService.StockInfoDetailService.Db.Updateable(stockInfoDetail) |
| | | .Where(x => x.Id == stockInfoDetail.Id) |
| | | .ExecuteCommandAsync(); |
| | | |
| | | if (stockInfo.Id != 0 && stockInfo.Details != null && !stockInfo.Details.Contains(stockInfoDetail)) |
| | | { |
| | | stockInfo.Details.Add(stockInfoDetail); |
| | | |
| | | await _stockInfoRepository.Db.Updateable(stockInfo) |
| | | .IgnoreColumns(x => x.Details) |
| | | .ExecuteCommandAsync(); |
| | | } |
| | | |
| | | // æäº¤äºå¡ |
| | | _unitOfWorkManage.CommitTran(); |
| | | } |
| | | catch (Exception) |
| | | { |
| | | // äºå¡åæ» |
| | | _unitOfWorkManage.RollbackTran(); |
| | | throw; // æç»å¤å±catchå¤çæ¥å¿ |
| | | } |
| | | |
| | | // æ¥è¯¢ææ°çåºåä¿¡æ¯ï¼å
å«å
³èçæç»ï¼ |
| | | Dt_StockInfo? NewstockInfo = await _stockInfoRepository.Db.Queryable<Dt_StockInfo>() |
| | | .Includes(x => x.Details) |
| | | .Where(x => x.PalletCode == palletDto.PalletCode) |
| | | .FirstAsync(); |
| | | |
| | | return WebResponseContent.Instance.OK(data: NewstockInfo.Details.OrderByDescending(x => x.Id)); |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | LogFactory.GetLog($"ç»çä¿¡æ¯").Info(true, $"ãå¼å¸¸ãï¼ã{ex.Message}ã{Environment.NewLine}ã{ex.StackTrace}ã{Environment.NewLine}{Environment.NewLine}"); |
| | | return content.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | public async Task<WebResponseContent> ReCheckGroupPallet(GroupPalletDto palletDto) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | (bool, string, object?) result2 = ModelValidate.ValidateModelData(palletDto); |
| | | if (!result2.Item1) return content.Error(result2.Item2); |
| | | |
| | | var code = _warehouseAreaRepository.Db.Queryable<Dt_WarehouseArea>().Where(x => x.Code == palletDto.WarehouseType).Select(x => x.Code).First(); |
| | | if (string.IsNullOrEmpty(code)) |
| | | { |
| | | return content.Error($"ä»åºä¸æ²¡æè¯¥{palletDto.WarehouseType}ç¼å·ã"); |
| | | } |
| | | |
| | | Dt_StockInfo? stockInfo = await _stockInfoRepository.Db.Queryable<Dt_StockInfo>().Includes(x => x.Details).Where(x => x.PalletCode == palletDto.PalletCode).FirstAsync(); |
| | | |
| | | if (_taskRepository.QueryFirst(x => x.PalletCode == palletDto.PalletCode) != null) |
| | | { |
| | | return content.Error($"该æçå·²çæä»»å¡"); |
| | | } |
| | | if (stockInfo != null && !string.IsNullOrEmpty(stockInfo.LocationCode) && stockInfo.StockStatus != (int)StockStatusEmun.ç»çæå) |
| | | { |
| | | return content.Error("已䏿¶çæçä¸è½å次ç»ç"); |
| | | } |
| | | |
| | | if (stockInfo == null) |
| | | { |
| | | stockInfo = new Dt_StockInfo() { PalletType = (int)PalletTypeEnum.None, LocationType = Convert.ToInt32(palletDto.locationType) }; |
| | | stockInfo.Details = new List<Dt_StockInfoDetail>(); |
| | | } |
| | | |
| | | if (stockInfo != null && stockInfo.Details.Count > 0 && stockInfo.Details.FirstOrDefault()?.WarehouseCode != palletDto.WarehouseType) |
| | | { |
| | | return content.Error($"该æçç»çä»åºä¸º{stockInfo.Details.FirstOrDefault()?.WarehouseCode}ä¸å½åä»åº{palletDto.WarehouseType}ä¸ä¸è´ï¼ä¸å
许ç»ç"); |
| | | } |
| | | Dt_StockInfoDetail stockInfoDetail = _stockInfoRepository.Db.Queryable<Dt_StockInfoDetail>().Where(x => x.Barcode == palletDto.Barcode && x.Status == StockStatusEmun.鿣ä¸.ObjToInt()).First(); |
| | | if(stockInfoDetail == null) |
| | | { |
| | | return content.Error("æªæ¾å°åºåä¸éæ£å»ç»çæ¡ç "); |
| | | } |
| | | Dt_ReCheckOrder reCheckOrder = _stockInfoRepository.Db.Queryable<Dt_ReCheckOrder>().Where(x => x.MaterielCode == stockInfoDetail.MaterielCode && x.BatchNo == stockInfoDetail.BatchNo && x.OrderNo == stockInfoDetail.OrderNo && (x.Result == 1 || x.Result == 2 )).First(); |
| | | if(reCheckOrder == null) |
| | | { |
| | | return content.Error($"è¯¥éæ£æ¡ç çæ¹æ¬¡å¨éæ£å䏿ªæ¿å°éæ£ç»æï¼è¯·æ£æ¥éæ£åä¸ç©æ{stockInfoDetail.MaterielCode}å{stockInfoDetail.BatchNo}ç©ææ¹æ¬¡ç¶æ"); |
| | | } |
| | | |
| | | int newStatus = reCheckOrder.Result == 1 ? StockStatusEmun.å
¥åºå®æ.ObjToInt(): StockStatusEmun.æå¨å»ç».ObjToInt(); |
| | | |
| | | stockInfo.Details.Add(new Dt_StockInfoDetail |
| | | { |
| | | StockId = stockInfo == null ? 0 : stockInfo.Id, |
| | | Barcode = stockInfoDetail.Barcode, |
| | | MaterielCode = stockInfoDetail.MaterielCode, |
| | | MaterielName = stockInfoDetail.MaterielName, |
| | | BatchNo = stockInfoDetail.BatchNo, |
| | | Unit = stockInfoDetail.Unit, |
| | | SupplyCode = stockInfoDetail.SupplyCode, |
| | | WarehouseCode = stockInfoDetail.WarehouseCode, |
| | | StockQuantity = stockInfoDetail.StockQuantity, |
| | | BarcodeQty = stockInfoDetail.BarcodeQty, |
| | | BarcodeUnit = stockInfoDetail.BarcodeUnit, |
| | | FactoryArea = stockInfoDetail.FactoryArea, |
| | | Status = newStatus, |
| | | OrderNo = stockInfoDetail.OrderNo, |
| | | BusinessType = "30", |
| | | ValidDate = stockInfoDetail.ValidDate |
| | | }); |
| | | _stockInfoRepository.Db.Deleteable<Dt_StockInfoDetail>().Where(x => x.Barcode == stockInfoDetail.Barcode).ExecuteCommand(); |
| | | if (stockInfo.Id == 0) |
| | | { |
| | | stockInfo.PalletCode = palletDto.PalletCode; |
| | | stockInfo.StockStatus = (int)StockStatusEmun.鿣åºå宿; |
| | | } |
| | | stockInfo.PalletType = (int)PalletTypeEnum.None; |
| | | _unitOfWorkManage.BeginTran(); |
| | | _stockService.StockInfoService.AddMaterielGroup(stockInfo); |
| | | _unitOfWorkManage.CommitTran(); |
| | | |
| | | Dt_StockInfo oldStockInfo = _stockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.Id == stockInfoDetail.StockId).Includes(x=>x.Details).First(); |
| | | if (oldStockInfo.Details.Count <= 0) |
| | | { |
| | | oldStockInfo.PalletType = (int)PalletTypeEnum.Empty; |
| | | } |
| | | _stockInfoRepository.UpdateData(oldStockInfo); |
| | | |
| | | Dt_StockInfo? NewstockInfo = await _stockInfoRepository.Db.Queryable<Dt_StockInfo>().Includes(x => x.Details).Where(x => x.PalletCode == palletDto.PalletCode).FirstAsync(); |
| | | |
| | | return WebResponseContent.Instance.OK(data: NewstockInfo.Details.OrderByDescending(x => x.Id)); |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | LogFactory.GetLog($"ç»çä¿¡æ¯").Info(true, $"ãå¼å¸¸ãï¼ã{ex.Message}ã{Environment.NewLine}ã{ex.StackTrace}ã{Environment.NewLine}{Environment.NewLine}"); |
| | | return content.Error(ex.Message); |
| | | } |
| | | } |
| | | } |
| | | } |