| | |
| | | "Bash(SET NODE_OPTIONS=--openssl-legacy-provider)", |
| | | "Bash(export NODE_OPTIONS=--openssl-legacy-provider:*)", |
| | | "Bash(node:*)", |
| | | "Bash(npm --version:*)" |
| | | "Bash(npm --version:*)", |
| | | "Bash(npm run build)", |
| | | "Bash(npx:*)" |
| | | ] |
| | | } |
| | | } |
| | |
| | | }, |
| | | "devDependencies": { |
| | | "@babel/plugin-syntax-dynamic-import": "^7.8.3", |
| | | "@vue/cli-plugin-babel": "~4.5.0", |
| | | "@vue/cli-plugin-babel": "^4.5.19", |
| | | "@vue/cli-plugin-eslint": "~4.5.0", |
| | | "@vue/cli-plugin-router": "~4.5.0", |
| | | "@vue/cli-plugin-unit-mocha": "~4.5.0", |
| | |
| | | }, |
| | | handleOpenBatchPicking() { |
| | | this.$router.push({ |
| | | path: "/outbound/batchpicking", |
| | | path: "/outbound/outPicking", |
| | | query: { orderId: this.row.id, orderNo: this.row.orderNo }, |
| | | }); |
| | | }, |
| | |
| | | render(null, mountNode); |
| | | document.body.removeChild(mountNode); |
| | | }) |
| | | // .catch(() => { |
| | | // ElMessage.error("请æ±å¤±è´¥ï¼è¯·ç¨åéè¯"); |
| | | // }); |
| | | // .catch(() => { |
| | | // ElMessage.error("请æ±å¤±è´¥ï¼è¯·ç¨åéè¯"); |
| | | // }); |
| | | }, |
| | | style: { |
| | | borderRadius: "4px", |
| | |
| | | |
| | | const keys = this.selection.map((item) => item.id); |
| | | const requestParams = { |
| | | orderDetailId: keys[0], |
| | | outboundPlatform: formData.selectedPlatform, |
| | | batchQuantity: formData.outboundDecimal, |
| | | detailIds: keys, |
| | | outboundTargetLocation: formData.selectedPlatform, |
| | | outboundQuantity: formData.outboundDecimal, |
| | | operator: "", |
| | | orderNo: this.row.orderNo, |
| | | }; |
| | | |
| | | this.http |
| | | .post( |
| | | "api/Task/GenerateOutboundBatchTasks", |
| | | "api/Outbound/ProcessPickingOutbound", |
| | | requestParams, |
| | | "æ°æ®å¤çä¸" |
| | | ) |
| | |
| | | using WIDESEA_IBasicService; |
| | | using SqlSugar; |
| | | using WIDESEA_Core.Attributes; |
| | | using WIDESEA_Core.BaseRepository; |
| | | using WIDESEA_Core.CodeConfigEnum; |
| | | using WIDESEA_Core.DB; |
| | | using WIDESEA_Core.Helper; |
| | | using WIDESEA_Core.Seed; |
| | | using WIDESEA_DTO.Base; |
| | | using WIDESEA_IBasicService; |
| | | using WIDESEA_Model.Models; |
| | | using WIDESEA_Model.Models.Basic; |
| | | |
| | | namespace WIDESEA_BasicService |
| | | { |
| | | public class BasicService : IBasicService |
| | | { |
| | | private readonly IUnitOfWorkManage _unitOfWorkManage; |
| | | |
| | | public IPalletCodeInfoService PalletCodeInfoService { get; } |
| | | |
| | | public ILocationInfoService LocationInfoService { get; } |
| | |
| | | |
| | | public IMaterielCodeInfoService MaterielCodeInfoService { get; } |
| | | |
| | | public BasicService(ILocationInfoService locationInfoService, IMaterielInfoService materielInfoService, IWarehouseService warehouseService, IPalletCodeInfoService palletCodeInfoService, IMaterielCodeInfoService materielCodeInfoService) |
| | | public IMaterialUnitService MaterialUnitService { get; } |
| | | |
| | | public BasicService(IUnitOfWorkManage unitOfWorkManage, ILocationInfoService locationInfoService, IMaterielInfoService materielInfoService, IWarehouseService warehouseService, IPalletCodeInfoService palletCodeInfoService, IMaterielCodeInfoService materielCodeInfoService, IMaterialUnitService materialUnitService) |
| | | { |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | | LocationInfoService = locationInfoService; |
| | | MaterielInfoService = materielInfoService; |
| | | WarehouseService = warehouseService; |
| | | PalletCodeInfoService = palletCodeInfoService; |
| | | MaterielCodeInfoService = materielCodeInfoService; |
| | | MaterialUnitService = materialUnitService; |
| | | } |
| | | |
| | | #region |
| | | public string CreateCodeByRule(string ruleCode) |
| | | { |
| | | string code = string.Empty; |
| | | DateTime dataTime = DateTime.Now; |
| | | DateTime now = DateTime.Now; |
| | | |
| | | try |
| | | { |
| | | Dt_CodeRuleConfig ruleConfig = _unitOfWorkManage.Db.Queryable<Dt_CodeRuleConfig>().Where(x => x.RuleCode == ruleCode).First(); |
| | | if (ruleConfig.ModifyDate != null) |
| | | { |
| | | dataTime = ruleConfig.ModifyDate.Value; |
| | | } |
| | | else |
| | | { |
| | | dataTime = ruleConfig.CreateDate; |
| | | } |
| | | |
| | | if (now.Year == dataTime.Year && now.Month == dataTime.Month && now.Day == dataTime.Day) |
| | | { |
| | | now = dataTime; |
| | | ruleConfig.CurrentVal = Convert.ToInt32(ruleConfig.CurrentVal) + 1; |
| | | } |
| | | else |
| | | { |
| | | ruleConfig.CurrentVal = 1; |
| | | } |
| | | |
| | | ruleConfig.ModifyDate = DateTime.Now; |
| | | |
| | | code = ruleConfig.Format; |
| | | code = code.Replace($"[{CodeFormatTypeEnum.YYYY}]", now.Year.ToString().PadLeft(4, '0')); |
| | | code = code.Replace($"[{CodeFormatTypeEnum.MM}]", now.Month.ToString().PadLeft(2, '0')); |
| | | code = code.Replace($"[{CodeFormatTypeEnum.DD}]", now.Day.ToString().PadLeft(2, '0')); |
| | | code = code.Replace($"[{CodeFormatTypeEnum.ST}]", ruleConfig.StartStr.ToString()); |
| | | code = code.Replace($"[{CodeFormatTypeEnum.NUM}]", ruleConfig.CurrentVal.ToString().PadLeft(ruleConfig.Length, '0')); |
| | | |
| | | _unitOfWorkManage.Db.Updateable(ruleConfig).ExecuteCommand(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | |
| | | } |
| | | return code; |
| | | } |
| | | #endregion |
| | | |
| | | #region åä½è½¬æ¢ |
| | | /// <summary> |
| | | /// åä½è½¬æ¢ |
| | | /// </summary> |
| | | /// <param name="materialCode"></param> |
| | | /// <param name="fromUnit"></param> |
| | | /// <param name="toUnit"></param> |
| | | /// <param name="quantity"></param> |
| | | /// <returns></returns> |
| | | /// <exception cref="Exception"></exception> |
| | | public UnitConvertResultDTO UnitQuantityConvert(string materialCode, string fromUnit, string toUnit, decimal quantity) |
| | | { |
| | | if (string.IsNullOrEmpty(fromUnit)) |
| | | { |
| | | throw new Exception($"转æ¢ååä½ä¸è½ä¸ºç©º"); |
| | | } |
| | | |
| | | if (string.IsNullOrEmpty(toUnit)) |
| | | { |
| | | throw new Exception($"转æ¢ååä½ä¸è½ä¸ºç©º"); |
| | | } |
| | | |
| | | decimal ratio = 0; |
| | | |
| | | if (fromUnit.Trim().ToLower() == toUnit.Trim().ToLower()) |
| | | { |
| | | return new UnitConvertResultDTO(materialCode, fromUnit, toUnit, quantity, ratio); |
| | | } |
| | | |
| | | Dt_MaterialUnit materialUnit = MaterialUnitService.Repository.QueryFirst(x => x.ItemNo == materialCode && x.FromUom == fromUnit && x.ToUom == toUnit); |
| | | if (materialUnit != null) |
| | | { |
| | | ratio = materialUnit.Ratio; |
| | | return new UnitConvertResultDTO(materialCode, fromUnit, toUnit, quantity, ratio); |
| | | } |
| | | else |
| | | { |
| | | materialUnit = MaterialUnitService.Repository.QueryFirst(x => x.ItemNo == materialCode && x.FromUom == toUnit && x.ToUom == fromUnit); |
| | | if (materialUnit == null) |
| | | { |
| | | throw new Exception($"æªæ¾å°åä½è½¬æ¢å
³ç³»ï¼ç©æç¼å·ï¼{materialCode}ï¼è½¬æ¢ååä½ï¼{fromUnit}ï¼è½¬æ¢ååä½ï¼{toUnit}"); |
| | | } |
| | | ratio = materialUnit.Ratio; |
| | | return new UnitConvertResultDTO(materialCode, fromUnit, toUnit, quantity, ratio); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// åä½è½¬æ¢ï¼é¢æè½¬éè´ |
| | | /// </summary> |
| | | /// <param name="materialCode"></param> |
| | | /// <param name="quantity"></param> |
| | | /// <returns></returns> |
| | | /// <exception cref="Exception"></exception> |
| | | public UnitConvertResultDTO UnitUsageToPurchase(string materialCode, decimal quantity) |
| | | { |
| | | if (string.IsNullOrEmpty(materialCode)) |
| | | { |
| | | throw new Exception($"ç©æç¼å·ä¸è½ä¸ºç©º"); |
| | | } |
| | | |
| | | Dt_MaterielInfo materielInfo = MaterielInfoService.Repository.QueryFirst(x => x.MaterielCode == materialCode); |
| | | if (materielInfo == null) |
| | | { |
| | | throw new Exception($"æªæ¾å°ç©æä¿¡æ¯{materialCode}"); |
| | | } |
| | | |
| | | return UnitQuantityConvert(materialCode, materielInfo.usageUOM, materielInfo.purchaseUOM, quantity); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// åä½è½¬æ¢ï¼é¢æè½¬åºå |
| | | /// </summary> |
| | | /// <param name="materialCode"></param> |
| | | /// <param name="quantity"></param> |
| | | /// <returns></returns> |
| | | /// <exception cref="Exception"></exception> |
| | | public UnitConvertResultDTO UnitUsageToInventory(string materialCode, decimal quantity) |
| | | { |
| | | if (string.IsNullOrEmpty(materialCode)) |
| | | { |
| | | throw new Exception($"ç©æç¼å·ä¸è½ä¸ºç©º"); |
| | | } |
| | | |
| | | Dt_MaterielInfo materielInfo = MaterielInfoService.Repository.QueryFirst(x => x.MaterielCode == materialCode); |
| | | if (materielInfo == null) |
| | | { |
| | | throw new Exception($"æªæ¾å°ç©æä¿¡æ¯{materialCode}"); |
| | | } |
| | | |
| | | return UnitQuantityConvert(materialCode, materielInfo.usageUOM, materielInfo.inventoryUOM, quantity); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// åä½è½¬æ¢ï¼éè´è½¬åºå |
| | | /// </summary> |
| | | /// <param name="materialCode"></param> |
| | | /// <param name="quantity"></param> |
| | | /// <returns></returns> |
| | | /// <exception cref="Exception"></exception> |
| | | public UnitConvertResultDTO UnitPurchaseToInventory(string materialCode, decimal quantity) |
| | | { |
| | | if (string.IsNullOrEmpty(materialCode)) |
| | | { |
| | | throw new Exception($"ç©æç¼å·ä¸è½ä¸ºç©º"); |
| | | } |
| | | |
| | | Dt_MaterielInfo materielInfo = MaterielInfoService.Repository.QueryFirst(x => x.MaterielCode == materialCode); |
| | | if (materielInfo == null) |
| | | { |
| | | throw new Exception($"æªæ¾å°ç©æä¿¡æ¯{materialCode}"); |
| | | } |
| | | |
| | | return UnitQuantityConvert(materialCode, materielInfo.purchaseUOM, materielInfo.inventoryUOM, quantity); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// åä½è½¬æ¢ï¼éè´è½¬é¢æ |
| | | /// </summary> |
| | | /// <param name="materialCode"></param> |
| | | /// <param name="quantity"></param> |
| | | /// <returns></returns> |
| | | /// <exception cref="Exception"></exception> |
| | | public UnitConvertResultDTO UnitPurchaseToUsage(string materialCode, decimal quantity) |
| | | { |
| | | if (string.IsNullOrEmpty(materialCode)) |
| | | { |
| | | throw new Exception($"ç©æç¼å·ä¸è½ä¸ºç©º"); |
| | | } |
| | | |
| | | Dt_MaterielInfo materielInfo = MaterielInfoService.Repository.QueryFirst(x => x.MaterielCode == materialCode); |
| | | if (materielInfo == null) |
| | | { |
| | | throw new Exception($"æªæ¾å°ç©æä¿¡æ¯{materialCode}"); |
| | | } |
| | | |
| | | return UnitQuantityConvert(materialCode, materielInfo.purchaseUOM, materielInfo.usageUOM, quantity); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// åä½è½¬æ¢ï¼åºåè½¬é¢æ |
| | | /// </summary> |
| | | /// <param name="materialCode"></param> |
| | | /// <param name="quantity"></param> |
| | | /// <returns></returns> |
| | | /// <exception cref="Exception"></exception> |
| | | public UnitConvertResultDTO UnitInventoryToUsage(string materialCode, decimal quantity) |
| | | { |
| | | if (string.IsNullOrEmpty(materialCode)) |
| | | { |
| | | throw new Exception($"ç©æç¼å·ä¸è½ä¸ºç©º"); |
| | | } |
| | | |
| | | Dt_MaterielInfo materielInfo = MaterielInfoService.Repository.QueryFirst(x => x.MaterielCode == materialCode); |
| | | if (materielInfo == null) |
| | | { |
| | | throw new Exception($"æªæ¾å°ç©æä¿¡æ¯{materialCode}"); |
| | | } |
| | | |
| | | return UnitQuantityConvert(materialCode, materielInfo.inventoryUOM, materielInfo.usageUOM, quantity); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// åä½è½¬æ¢ï¼åºå转éè´ |
| | | /// </summary> |
| | | /// <param name="materialCode"></param> |
| | | /// <param name="quantity"></param> |
| | | /// <returns></returns> |
| | | /// <exception cref="Exception"></exception> |
| | | public UnitConvertResultDTO UnitInventoryToPurchase(string materialCode, decimal quantity) |
| | | { |
| | | if (string.IsNullOrEmpty(materialCode)) |
| | | { |
| | | throw new Exception($"ç©æç¼å·ä¸è½ä¸ºç©º"); |
| | | } |
| | | |
| | | Dt_MaterielInfo materielInfo = MaterielInfoService.Repository.QueryFirst(x => x.MaterielCode == materialCode); |
| | | if (materielInfo == null) |
| | | { |
| | | throw new Exception($"æªæ¾å°ç©æä¿¡æ¯{materialCode}"); |
| | | } |
| | | |
| | | return UnitQuantityConvert(materialCode, materielInfo.inventoryUOM, materielInfo.purchaseUOM, quantity); |
| | | } |
| | | #endregion |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using Newtonsoft.Json; |
| | | using WIDESEA_Core; |
| | | using WIDESEA_Core.BaseRepository; |
| | | using WIDESEA_Core.Helper; |
| | | using WIDESEA_Core.HttpContextUser; |
| | | using WIDESEA_Core.Util; |
| | | using WIDESEA_DTO.Base; |
| | | using WIDESEA_DTO.ReturnMES; |
| | | using WIDESEA_IBasicService; |
| | | using WIDESEA_Model.Models; |
| | | |
| | | namespace WIDESEA_BasicService.MESOperation |
| | | { |
| | | public class FeedbackMesService : IFeedbackMesService |
| | | { |
| | | private readonly IUnitOfWorkManage _unitOfWorkManage; |
| | | private readonly HttpClientHelper _httpClientHelper; |
| | | private readonly IRepository<Dt_OutboundOrder> _outboundOrderRepository; |
| | | private readonly IBasicService _basicService; |
| | | |
| | | public FeedbackMesService(IUnitOfWorkManage unitOfWorkManage, HttpClientHelper httpClientHelper, IRepository<Dt_OutboundOrder> outboundOrderRepository, IBasicService basicService) |
| | | { |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | | _httpClientHelper = httpClientHelper; |
| | | _outboundOrderRepository = outboundOrderRepository; |
| | | _basicService = basicService; |
| | | } |
| | | |
| | | public void MaterialOutboundFeedback(string orderNo) |
| | | { |
| | | try |
| | | { |
| | | Dt_OutboundOrder outboundOrder = _outboundOrderRepository.Db.Queryable<Dt_OutboundOrder>().Where(x => x.OrderNo == orderNo).Includes(x => x.Details).First(); |
| | | if (outboundOrder == null) |
| | | { |
| | | // todo è®°å½æ¥å¿ï¼æªæ¾å°å¯¹åºçåºåºå |
| | | |
| | | return; |
| | | } |
| | | |
| | | MaterialOutboundReturnDTO? returnDTO = BuildOutboundFeedbackData(outboundOrder); |
| | | if (returnDTO != null) |
| | | { |
| | | string apiUrl = ""; |
| | | |
| | | HttpResponseResult<MesResponseDTO> httpResponseResult = _httpClientHelper.Post<MesResponseDTO>(apiUrl, returnDTO.Serialize()); |
| | | |
| | | bool isSuccess = httpResponseResult.IsSuccess && httpResponseResult.Data != null && httpResponseResult.Data.Code == "200"; |
| | | string message = ""; |
| | | if (!isSuccess) |
| | | { |
| | | if (httpResponseResult.IsSuccess) |
| | | { |
| | | message = $"MESæ¥å£è¿åé误ï¼HTTP代ç ï¼{httpResponseResult.StatusCode}ï¼ä¿¡æ¯ï¼{httpResponseResult.ErrorMessage}"; |
| | | } |
| | | else if (httpResponseResult.Data.Code != "200") |
| | | { |
| | | message = $"è°ç¨MESæ¥å£å¤±è´¥ï¼ä»£ç ï¼{httpResponseResult.Data.Code}ï¼ä¿¡æ¯ï¼{httpResponseResult.Data.Message}"; |
| | | } |
| | | } |
| | | |
| | | Dt_MesReturnRecord mesReturnRecord = new Dt_MesReturnRecord() |
| | | { |
| | | ApiUrl = apiUrl, |
| | | InterfaceType = 1, |
| | | OrderId = outboundOrder.Id, |
| | | OrderNo = outboundOrder.OrderNo, |
| | | OrderType = outboundOrder.OrderType, |
| | | RequestCode = returnDTO.ReqCode, |
| | | RequestData = returnDTO.Serialize(), |
| | | FailureReason = message, |
| | | LastReturnTime = DateTime.Now, |
| | | HttpStatusCode = httpResponseResult.StatusCode.ObjToInt(), |
| | | ResponseData = httpResponseResult.Content, |
| | | ReturnType = 0, |
| | | ReturnCount = 1, |
| | | ReturnStatus = httpResponseResult.IsSuccess ? 1 : 2, |
| | | SuccessTime = httpResponseResult.IsSuccess ? DateTime.Now : null |
| | | }; |
| | | |
| | | _unitOfWorkManage.BeginTran(); |
| | | _unitOfWorkManage.Db.Insertable(mesReturnRecord).ExecuteCommand(); |
| | | List<string> lineNos = returnDTO.Details.Select(x => x.LineNo).ToList(); |
| | | |
| | | List<Dt_OutboundOrderDetail> outboundOrderDetails = outboundOrder.Details.Where(x => lineNos.Contains(x.lineNo)).ToList(); |
| | | outboundOrderDetails.ForEach(x => |
| | | { |
| | | if (x.OverOutQuantity == x.OrderQuantity - x.MoveQty) |
| | | { |
| | | x.ReturnToMESStatus = isSuccess ? 1 : 2; |
| | | } |
| | | else |
| | | { |
| | | x.ReturnToMESStatus = isSuccess ? 3 : 4; |
| | | } |
| | | x.CurrentDeliveryQty = 0; |
| | | x.ReturnJsonData = ""; |
| | | }); |
| | | |
| | | _outboundOrderRepository.Db.Updateable(outboundOrderDetails).ExecuteCommand(); |
| | | |
| | | _unitOfWorkManage.CommitTran(); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw new Exception(ex.Message); |
| | | } |
| | | |
| | | } |
| | | |
| | | public MaterialOutboundReturnDTO? BuildOutboundFeedbackData(Dt_OutboundOrder outboundOrder) |
| | | { |
| | | try |
| | | { |
| | | List<Dt_OutboundOrderDetail> details = outboundOrder.Details; |
| | | |
| | | List<MaterialOutboundDetail> returnDetails = new List<MaterialOutboundDetail>(); |
| | | |
| | | foreach (var detail in details) |
| | | { |
| | | List<Barcodes>? barcodes = JsonConvert.DeserializeObject<List<Barcodes>>(detail.ReturnJsonData); |
| | | if (barcodes != null && barcodes.Any()) |
| | | { |
| | | UnitConvertResultDTO currentResult = _basicService.UnitQuantityConvert(detail.MaterielCode, detail.Unit, detail.BarcodeUnit, detail.CurrentDeliveryQty); |
| | | UnitConvertResultDTO totalResult = _basicService.UnitQuantityConvert(detail.MaterielCode, detail.Unit, detail.BarcodeUnit, detail.OrderQuantity); |
| | | |
| | | returnDetails.Add(new MaterialOutboundDetail |
| | | { |
| | | Barcodes = barcodes, |
| | | CurrentDeliveryQty = currentResult.ToQuantity, |
| | | LineNo = detail.lineNo, |
| | | MaterialCode = detail.MaterielCode, |
| | | Qty = totalResult.ToQuantity, |
| | | WarehouseCode = detail.WarehouseCode, |
| | | Unit = detail.BarcodeUnit |
| | | }); |
| | | } |
| | | } |
| | | |
| | | MaterialOutboundReturnDTO outboundReturnDTO = new MaterialOutboundReturnDTO() |
| | | { |
| | | Business_type = outboundOrder.BusinessType, |
| | | Details = returnDetails, |
| | | DocumentsNO = "", |
| | | FactoryArea = outboundOrder.FactoryArea, |
| | | OperationType = 1, |
| | | Operator = App.User.UserName, |
| | | OrderNo = outboundOrder.OrderNo, |
| | | Status = 1 |
| | | }; |
| | | |
| | | return outboundReturnDTO; |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return null; |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | { |
| | | public interface IUnitOfWorkManage |
| | | { |
| | | SqlSugarClient Db { get; } |
| | | SqlSugarClient GetDbClient(); |
| | | int TranCount { get; } |
| | | |
| | |
| | | _tranCount = 0; |
| | | } |
| | | |
| | | public SqlSugarClient Db => GetDbClient(); |
| | | |
| | | /// <summary> |
| | | /// è·åDBï¼ä¿è¯å¯ä¸æ§ |
| | | /// </summary> |
| | |
| | | /// è°æ¨åå·ç¼ç è§å |
| | | /// </summary> |
| | | [Description("è°æ¨åå·ç¼ç è§å")] |
| | | AllocateOrderCodeRule |
| | | AllocateOrderCodeRule, |
| | | |
| | | NewBarcodeRule |
| | | } |
| | | } |
| | |
| | | using Microsoft.Extensions.DependencyInjection; |
| | | using System; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using Microsoft.Extensions.DependencyInjection; |
| | | using WIDESEA_Core.Helper; |
| | | using WIDESEA_Core.Seed; |
| | | using WIDESEA_Core.Util; |
| | | |
| | | namespace WIDESEA_Core |
| | | { |
| | |
| | | public static void AddDbSetup(this IServiceCollection services) |
| | | { |
| | | if (services == null) throw new ArgumentNullException(nameof(services)); |
| | | |
| | | |
| | | services.AddScoped<DBSeed>(); |
| | | services.AddScoped<DBContext>(); |
| | | // 注åIHttpClientFactory |
| | | services.AddHttpClient(); |
| | | // 注åHttpHelper |
| | | services.AddScoped<HttpClientHelper>(); |
| | | |
| | | |
| | | } |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Net.Http; |
| | | using System.Net.Http.Headers; |
| | | using System.Reflection.Metadata; |
| | | using System.Text; |
| | | using System.Text.Json; |
| | | using System.Threading.Tasks; |
| | | using Microsoft.Extensions.Configuration; |
| | | using Microsoft.Extensions.Logging; |
| | | using WIDESEA_Core.Helper; |
| | | |
| | | namespace WIDESEA_Core.Util |
| | | { |
| | | public class HttpClientHelper |
| | | { |
| | | private readonly IHttpClientFactory _httpClientFactory; |
| | | |
| | | public HttpClientHelper(IHttpClientFactory httpClientFactory, IConfiguration configuration = null) |
| | | { |
| | | _httpClientFactory = httpClientFactory ?? throw new ArgumentNullException(nameof(httpClientFactory)); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// POSTè¯·æ± |
| | | /// </summary> |
| | | /// <param name="url">请æ±URL</param> |
| | | /// <param name="content">请æ±å
容</param> |
| | | /// <param name="mediaType">åªä½ç±»å</param> |
| | | /// <param name="config">请æ±é
ç½®</param> |
| | | /// <returns></returns> |
| | | public HttpResponseResult Post(string url, string content, string contentType = "application/json", HttpRequestConfig? config = null) |
| | | { |
| | | HttpResponseResult httpResponseResult = ExecuteAsync(async (client) => |
| | | { |
| | | var request = new HttpRequestMessage(HttpMethod.Post, url); |
| | | request.Content = new StringContent(content ?? string.Empty, Encoding.UTF8, contentType); |
| | | SetRequestHeaders(request, config?.Headers); |
| | | return await client.SendAsync(request); |
| | | }, config, $"POST {url}").Result; |
| | | |
| | | return httpResponseResult; |
| | | } |
| | | |
| | | public HttpResponseResult Get(string url, HttpRequestConfig? config = null) |
| | | { |
| | | HttpResponseResult httpResponseResult = ExecuteAsync(async (client) => |
| | | { |
| | | var request = new HttpRequestMessage(HttpMethod.Get, url); |
| | | SetRequestHeaders(request, config?.Headers); |
| | | return await client.SendAsync(request); |
| | | }, config, $"GET {url}").Result; |
| | | |
| | | return httpResponseResult; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// POSTè¯·æ± |
| | | /// </summary> |
| | | /// <param name="url">请æ±URL</param> |
| | | /// <param name="content">请æ±å
容</param> |
| | | /// <param name="mediaType">åªä½ç±»å</param> |
| | | /// <param name="config">请æ±é
ç½®</param> |
| | | /// <returns></returns> |
| | | public HttpResponseResult<TResponse> Post<TResponse>(string url, string content, string contentType = "application/json", HttpRequestConfig? config = null) |
| | | { |
| | | |
| | | HttpResponseResult httpResponseResult = Post(url, content, contentType, config); |
| | | |
| | | HttpResponseResult<TResponse> result = new HttpResponseResult<TResponse> |
| | | { |
| | | IsSuccess = httpResponseResult.IsSuccess, |
| | | StatusCode = httpResponseResult.StatusCode, |
| | | Content = httpResponseResult.Content, |
| | | Headers = httpResponseResult.Headers, |
| | | Duration = httpResponseResult.Duration, |
| | | ErrorMessage = httpResponseResult.ErrorMessage, |
| | | Exception = httpResponseResult.Exception |
| | | }; |
| | | |
| | | if (result.IsSuccess && !string.IsNullOrEmpty(result.Content)) |
| | | { |
| | | try |
| | | { |
| | | TResponse? response = JsonSerializer.Deserialize<TResponse>(result.Content, new JsonSerializerOptions |
| | | { |
| | | PropertyNameCaseInsensitive = true |
| | | }); |
| | | if (response != null) |
| | | { |
| | | result.Data = response; |
| | | } |
| | | else |
| | | { |
| | | result.IsSuccess = false; |
| | | result.ErrorMessage = "ååºååç»æä¸ºnull"; |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | result.IsSuccess = false; |
| | | result.ErrorMessage = $"ååºåå失败: {ex.Message}"; |
| | | result.Exception = ex; |
| | | } |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | public HttpResponseResult<TResponse> Get<TResponse>(string url, HttpRequestConfig? config = null) |
| | | { |
| | | HttpResponseResult httpResponseResult = Get(url, config); |
| | | |
| | | HttpResponseResult<TResponse> result = new HttpResponseResult<TResponse> |
| | | { |
| | | IsSuccess = httpResponseResult.IsSuccess, |
| | | StatusCode = httpResponseResult.StatusCode, |
| | | Content = httpResponseResult.Content, |
| | | Headers = httpResponseResult.Headers, |
| | | Duration = httpResponseResult.Duration, |
| | | ErrorMessage = httpResponseResult.ErrorMessage, |
| | | Exception = httpResponseResult.Exception |
| | | }; |
| | | |
| | | if (result.IsSuccess && !string.IsNullOrEmpty(result.Content)) |
| | | { |
| | | try |
| | | { |
| | | TResponse? response = JsonSerializer.Deserialize<TResponse>(result.Content, new JsonSerializerOptions |
| | | { |
| | | PropertyNameCaseInsensitive = true |
| | | }); |
| | | if (response != null) |
| | | { |
| | | result.Data = response; |
| | | } |
| | | else |
| | | { |
| | | result.IsSuccess = false; |
| | | result.ErrorMessage = "ååºååç»æä¸ºnull"; |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | result.IsSuccess = false; |
| | | result.ErrorMessage = $"ååºåå失败: {ex.Message}"; |
| | | result.Exception = ex; |
| | | } |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ§è¡HTTPè¯·æ± |
| | | /// </summary> |
| | | private async Task<HttpResponseResult> ExecuteAsync(Func<HttpClient, Task<HttpResponseMessage>> requestFunc, HttpRequestConfig? config, string requestInfo) |
| | | { |
| | | var result = new HttpResponseResult(); |
| | | var stopwatch = System.Diagnostics.Stopwatch.StartNew(); |
| | | config ??= new HttpRequestConfig(); |
| | | |
| | | try |
| | | { |
| | | using var client = CreateHttpClient(config); |
| | | HttpResponseMessage? response = null; |
| | | Exception? lastException = null; |
| | | |
| | | // éè¯æºå¶ |
| | | for (int retry = 0; retry <= config.MaxRetryCount; retry++) |
| | | { |
| | | try |
| | | { |
| | | response = await requestFunc(client); |
| | | break; |
| | | } |
| | | catch (Exception ex) when (retry < config.MaxRetryCount) |
| | | { |
| | | lastException = ex; |
| | | if (config.EnableLogging) |
| | | { |
| | | // TODOï¼æ¥å¿è®°å½ |
| | | } |
| | | await Task.Delay(config.RetryIntervalMs, default); |
| | | } |
| | | } |
| | | |
| | | if (response == null) |
| | | { |
| | | throw lastException ?? new HttpRequestException("请æ±å¤±è´¥"); |
| | | } |
| | | |
| | | result.StatusCode = response.StatusCode; |
| | | result.IsSuccess = response.IsSuccessStatusCode; |
| | | |
| | | // 读åååºå
容 |
| | | result.Content = await response.Content.ReadAsStringAsync(); |
| | | |
| | | // è·åååºå¤´ |
| | | result.Headers = new Dictionary<string, IEnumerable<string>>(); |
| | | foreach (var header in response.Headers) |
| | | { |
| | | result.Headers[header.Key] = header.Value; |
| | | } |
| | | foreach (var header in response.Content.Headers) |
| | | { |
| | | result.Headers[header.Key] = header.Value; |
| | | } |
| | | |
| | | if (config.EnableLogging) |
| | | { |
| | | // TODOï¼æ¥å¿è®°å½ |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | result.IsSuccess = false; |
| | | result.ErrorMessage = ex.Message; |
| | | result.Exception = ex; |
| | | |
| | | if (config.EnableLogging) |
| | | { |
| | | // TODOï¼æ¥å¿è®°å½ |
| | | } |
| | | } |
| | | finally |
| | | { |
| | | stopwatch.Stop(); |
| | | result.Duration = stopwatch.ElapsedMilliseconds; |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å建HttpClient |
| | | /// </summary> |
| | | private HttpClient CreateHttpClient(HttpRequestConfig config) |
| | | { |
| | | var client = _httpClientFactory.CreateClient(); |
| | | client.Timeout = TimeSpan.FromMilliseconds(config.TimeoutMs); |
| | | |
| | | // 设置é»è®¤è¯·æ±å¤´ |
| | | client.DefaultRequestHeaders.Clear(); |
| | | client.DefaultRequestHeaders.Accept.Clear(); |
| | | client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); |
| | | |
| | | return client; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 设置请æ±å¤´ |
| | | /// </summary> |
| | | private void SetRequestHeaders(HttpRequestMessage request, Dictionary<string, string>? headers) |
| | | { |
| | | if (headers != null) |
| | | { |
| | | foreach (var header in headers) |
| | | { |
| | | if (!request.Headers.Contains(header.Key)) |
| | | { |
| | | request.Headers.Add(header.Key, header.Value); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | |
| | | namespace WIDESEA_Core.Util |
| | | { |
| | | /// <summary> |
| | | /// HTTP请æ±é
ç½® |
| | | /// </summary> |
| | | public class HttpRequestConfig |
| | | { |
| | | /// <summary> |
| | | /// è¶
æ¶æ¶é´ï¼æ¯«ç§ï¼ |
| | | /// </summary> |
| | | public int TimeoutMs { get; set; } = 30000; |
| | | |
| | | /// <summary> |
| | | /// æå¤§éè¯æ¬¡æ° |
| | | /// </summary> |
| | | public int MaxRetryCount { get; set; } = 3; |
| | | |
| | | /// <summary> |
| | | /// éè¯é´éï¼æ¯«ç§ï¼ |
| | | /// </summary> |
| | | public int RetryIntervalMs { get; set; } = 1000; |
| | | |
| | | /// <summary> |
| | | /// 请æ±å¤´ |
| | | /// </summary> |
| | | public Dictionary<string, string> Headers { get; set; } = new Dictionary<string, string>(); |
| | | |
| | | /// <summary> |
| | | /// æ¯å¦å¯ç¨æ¥å¿ |
| | | /// </summary> |
| | | public bool EnableLogging { get; set; } = true; |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Net; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | |
| | | namespace WIDESEA_Core.Util |
| | | { |
| | | /// <summary> |
| | | /// HTTPååºç»æ |
| | | /// </summary> |
| | | public class HttpResponseResult |
| | | { |
| | | /// <summary> |
| | | /// æ¯å¦æå |
| | | /// </summary> |
| | | public bool IsSuccess { get; set; } |
| | | |
| | | /// <summary> |
| | | /// HTTPç¶æç |
| | | /// </summary> |
| | | public HttpStatusCode StatusCode { get; set; } |
| | | |
| | | /// <summary> |
| | | /// ååºå
容 |
| | | /// </summary> |
| | | public string Content { get; set; } |
| | | |
| | | /// <summary> |
| | | /// ååºå¤´ |
| | | /// </summary> |
| | | public Dictionary<string, IEnumerable<string>> Headers { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 请æ±èæ¶ï¼æ¯«ç§ï¼ |
| | | /// </summary> |
| | | public long Duration { get; set; } |
| | | |
| | | /// <summary> |
| | | /// éè¯¯ä¿¡æ¯ |
| | | /// </summary> |
| | | public string ErrorMessage { get; set; } |
| | | |
| | | /// <summary> |
| | | /// å¼å¸¸ä¿¡æ¯ |
| | | /// </summary> |
| | | public Exception Exception { get; set; } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// HTTPååºç»æï¼æ³åï¼ |
| | | /// </summary> |
| | | public class HttpResponseResult<T> : HttpResponseResult |
| | | { |
| | | /// <summary> |
| | | /// ååºåååçæ°æ® |
| | | /// </summary> |
| | | public T Data { get; set; } |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | |
| | | namespace WIDESEA_DTO.Base |
| | | { |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public class UnitConvertResultDTO |
| | | { |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public string MaterialCode { get; set; } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public string FromUnit { get; set; } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public string ToUnit { get; set; } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public decimal FromQuantity { get; set; } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public decimal ToQuantity { get; } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public decimal UnitRatio { get; set; } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <param name="materialCode"></param> |
| | | /// <param name="fromUnit"></param> |
| | | /// <param name="toUnit"></param> |
| | | /// <param name="fromQuantity"></param> |
| | | /// <param name="unitRatio"></param> |
| | | public UnitConvertResultDTO(string materialCode, string fromUnit, string toUnit, decimal fromQuantity, decimal unitRatio) |
| | | { |
| | | MaterialCode = materialCode; |
| | | FromUnit = fromUnit; |
| | | ToUnit = toUnit; |
| | | FromQuantity = fromQuantity; |
| | | ToQuantity = fromQuantity * unitRatio; |
| | | UnitRatio = unitRatio; |
| | | } |
| | | } |
| | | } |
| | |
| | | /// ååº |
| | | /// </summary> |
| | | public string FactoryArea { get; set; } |
| | | |
| | | /// <summary> |
| | | /// æ¯å¦å¤æç»åºåº |
| | | /// </summary> |
| | | public bool IsMultiDetail { get; set; } |
| | | |
| | | } |
| | | } |
| | |
| | | /// åºåºç®æ ä½ç½® |
| | | /// </summary> |
| | | public string OutboundTargetLocation { get; set; } |
| | | |
| | | /// <summary> |
| | | /// æ¯å¦å¤æç»åºåºï¼éè¿DetailIdsæ°é夿ï¼ä¹å¯æå¨æå®ï¼ |
| | | /// </summary> |
| | | public bool IsMultiDetail => DetailIds?.Count > 1; |
| | | |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | |
| | | namespace WIDESEA_DTO.ReturnMES |
| | | { |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public class BaseReturnDTO |
| | | { |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public string ReqCode { get; set; } = Guid.NewGuid().ToString(); |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public string ReqTime { get; set; } = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | |
| | | namespace WIDESEA_DTO.ReturnMES |
| | | { |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public class MaterialOutboundReturnDTO : BaseReturnDTO |
| | | { |
| | | /// <summary> |
| | | /// åå· |
| | | /// </summary> |
| | | public string OrderNo { get; set; } |
| | | |
| | | /// <summary> |
| | | /// ç¶æ |
| | | /// </summary> |
| | | public int Status { get; set; } |
| | | |
| | | /// <summary> |
| | | /// ååº |
| | | /// </summary> |
| | | public string FactoryArea { get; set; } |
| | | |
| | | /// <summary> |
| | | /// ä¸å¡ç±»å |
| | | /// </summary> |
| | | public string Business_type { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 1æ°å¢2ä¿®æ¹3å é¤ |
| | | /// </summary> |
| | | public int OperationType { get; set; } |
| | | |
| | | /// <summary> |
| | | /// æä½äºº |
| | | /// </summary> |
| | | public string Operator { get; set; } |
| | | |
| | | /// <summary> |
| | | /// åæå |
| | | /// </summary> |
| | | public string DocumentsNO { get; set; } |
| | | |
| | | /// <summary> |
| | | /// æç» |
| | | /// </summary> |
| | | public List<MaterialOutboundDetail> Details { get; set; } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æç» |
| | | /// </summary> |
| | | public class MaterialOutboundDetail |
| | | { |
| | | /// <summary> |
| | | /// ç©æç¼ç |
| | | /// </summary> |
| | | public string MaterialCode { get; set; } |
| | | |
| | | /// <summary> |
| | | /// è¡å· |
| | | /// </summary> |
| | | public string LineNo { get; set; } |
| | | |
| | | /// <summary> |
| | | /// æ°é |
| | | /// </summary> |
| | | public decimal Qty { get; set; } |
| | | |
| | | /// <summary> |
| | | /// æ¬æ¬¡å·²åæ° |
| | | /// </summary> |
| | | public decimal CurrentDeliveryQty { get; set; } |
| | | |
| | | /// <summary> |
| | | /// ä»åº |
| | | /// </summary> |
| | | public string WarehouseCode { get; set; } |
| | | |
| | | /// <summary> |
| | | /// åä½ |
| | | /// </summary> |
| | | public string Unit { get; set; } |
| | | |
| | | /// <summary> |
| | | /// æ¡ç ä¿¡æ¯ |
| | | /// </summary> |
| | | public List<Barcodes> Barcodes { get; set; } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ¡ç ä¿¡æ¯ |
| | | /// </summary> |
| | | public class Barcodes |
| | | { |
| | | /// <summary> |
| | | /// æ¡ç |
| | | /// </summary> |
| | | public string Barcode { get; set; } |
| | | |
| | | /// <summary> |
| | | /// æ°é |
| | | /// </summary> |
| | | public decimal Qty { get; set; } |
| | | |
| | | /// <summary> |
| | | /// ä¾åºå |
| | | /// </summary> |
| | | public string SupplyCode { get; set; } |
| | | |
| | | /// <summary> |
| | | /// æ¹æ¬¡ |
| | | /// </summary> |
| | | public string BatchNo { get; set; } |
| | | |
| | | /// <summary> |
| | | /// åä½ |
| | | /// </summary> |
| | | public string Unit { get; set; } |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | |
| | | namespace WIDESEA_DTO.ReturnMES |
| | | { |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public class MesResponseDTO |
| | | { |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public string Code { get; set; } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public string Message { get; set; } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public object Data { get; set; } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public string ResponseTime { get; set; } |
| | | } |
| | | } |
| | |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Core; |
| | | using WIDESEA_DTO.Base; |
| | | |
| | | namespace WIDESEA_IBasicService |
| | | { |
| | | public interface IBasicService: IDependency |
| | | public interface IBasicService : IDependency |
| | | { |
| | | /// <summary> |
| | | /// è´§ä½ä¸å¡å± |
| | |
| | | IPalletCodeInfoService PalletCodeInfoService { get; } |
| | | |
| | | IMaterielCodeInfoService MaterielCodeInfoService { get; } |
| | | |
| | | IMaterialUnitService MaterialUnitService { get; } |
| | | |
| | | #region |
| | | string CreateCodeByRule(string ruleCode); |
| | | #endregion |
| | | |
| | | #region åä½è½¬æ¢ |
| | | /// <summary> |
| | | /// åä½è½¬æ¢ |
| | | /// </summary> |
| | | /// <param name="materialCode"></param> |
| | | /// <param name="fromUnit"></param> |
| | | /// <param name="toUnit"></param> |
| | | /// <param name="quantity"></param> |
| | | /// <returns></returns> |
| | | /// <exception cref="Exception"></exception> |
| | | public UnitConvertResultDTO UnitQuantityConvert(string materialCode, string fromUnit, string toUnit, decimal quantity); |
| | | |
| | | /// <summary> |
| | | /// åä½è½¬æ¢ï¼é¢æè½¬éè´ |
| | | /// </summary> |
| | | /// <param name="materialCode"></param> |
| | | /// <param name="quantity"></param> |
| | | /// <returns></returns> |
| | | /// <exception cref="Exception"></exception> |
| | | public UnitConvertResultDTO UnitUsageToPurchase(string materialCode, decimal quantity); |
| | | |
| | | /// <summary> |
| | | /// åä½è½¬æ¢ï¼é¢æè½¬åºå |
| | | /// </summary> |
| | | /// <param name="materialCode"></param> |
| | | /// <param name="quantity"></param> |
| | | /// <returns></returns> |
| | | /// <exception cref="Exception"></exception> |
| | | public UnitConvertResultDTO UnitUsageToInventory(string materialCode, decimal quantity); |
| | | |
| | | /// <summary> |
| | | /// åä½è½¬æ¢ï¼éè´è½¬åºå |
| | | /// </summary> |
| | | /// <param name="materialCode"></param> |
| | | /// <param name="quantity"></param> |
| | | /// <returns></returns> |
| | | /// <exception cref="Exception"></exception> |
| | | public UnitConvertResultDTO UnitPurchaseToInventory(string materialCode, decimal quantity); |
| | | |
| | | /// <summary> |
| | | /// åä½è½¬æ¢ï¼éè´è½¬é¢æ |
| | | /// </summary> |
| | | /// <param name="materialCode"></param> |
| | | /// <param name="quantity"></param> |
| | | /// <returns></returns> |
| | | /// <exception cref="Exception"></exception> |
| | | public UnitConvertResultDTO UnitPurchaseToUsage(string materialCode, decimal quantity); |
| | | |
| | | /// <summary> |
| | | /// åä½è½¬æ¢ï¼åºåè½¬é¢æ |
| | | /// </summary> |
| | | /// <param name="materialCode"></param> |
| | | /// <param name="quantity"></param> |
| | | /// <returns></returns> |
| | | /// <exception cref="Exception"></exception> |
| | | public UnitConvertResultDTO UnitInventoryToUsage(string materialCode, decimal quantity); |
| | | |
| | | /// <summary> |
| | | /// åä½è½¬æ¢ï¼åºå转éè´ |
| | | /// </summary> |
| | | /// <param name="materialCode"></param> |
| | | /// <param name="quantity"></param> |
| | | /// <returns></returns> |
| | | /// <exception cref="Exception"></exception> |
| | | public UnitConvertResultDTO UnitInventoryToPurchase(string materialCode, decimal quantity); |
| | | #endregion |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Core; |
| | | |
| | | namespace WIDESEA_IBasicService |
| | | { |
| | | public interface IFeedbackMesService : IDependency |
| | | { |
| | | void MaterialOutboundFeedback(string orderNo); |
| | | } |
| | | } |
| | |
| | | /// è¡å· |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = false, ColumnDescription = "è¡å·", DefaultValue = "0")] |
| | | public int RowNo { get; set; } |
| | | public int RowNo { get; set; } |
| | | |
| | | /// <summary> |
| | | /// åæ®æ°é |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = false, ColumnDescription = "åæ®æ°é")] |
| | | [SugarColumn(IsNullable = false, ColumnDescription = "åæ®æ°é")] |
| | | public decimal OrderQuantity { get; set; } |
| | | |
| | | /// <summary> |
| | | /// é宿°é |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = false, ColumnDescription = "é宿°é", DefaultValue = "0")] |
| | | [SugarColumn(IsNullable = false, ColumnDescription = "é宿°é", DefaultValue = "0")] |
| | | public decimal LockQuantity { get; set; } |
| | | |
| | | /// <summary> |
| | | /// å·²åºæ°é |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = false, ColumnDescription = "å·²åºæ°é", DefaultValue = "0")] |
| | | [SugarColumn(IsNullable = false, ColumnDescription = "å·²åºæ°é", DefaultValue = "0")] |
| | | public decimal OverOutQuantity { get; set; } |
| | | |
| | | /// <summary> |
| | |
| | | /// è¡å· |
| | | /// é»è®¤å¼: |
| | | ///</summary> |
| | | [SugarColumn(ColumnName = "lineNo", ColumnDescription = "è¡å·", DefaultValue= "0")] |
| | | [SugarColumn(ColumnName = "lineNo", ColumnDescription = "è¡å·", DefaultValue = "0")] |
| | | public string? lineNo { get; set; } |
| | | |
| | | /// <summary> |
| | | /// æªææ°é |
| | | /// é»è®¤å¼: |
| | | ///</summary> |
| | | [SugarColumn(ColumnName = "MoveQty", ColumnDescription = "æªææ°é",IsNullable = true)] |
| | | [SugarColumn(ColumnName = "MoveQty", ColumnDescription = "æªææ°é", IsNullable = true)] |
| | | public decimal MoveQty { get; set; } |
| | | |
| | | /// <summary> |
| | |
| | | /// åä½ |
| | | /// é»è®¤å¼: |
| | | ///</summary> |
| | | [SugarColumn(ColumnName = "barcodeUnit", ColumnDescription = "åä½", IsNullable = true )] |
| | | [SugarColumn(ColumnName = "barcodeUnit", ColumnDescription = "åä½", IsNullable = true)] |
| | | public string BarcodeUnit { get; set; } = null!; |
| | | |
| | | |
| | |
| | | /// |
| | | /// é»è®¤å¼: |
| | | ///</summary> |
| | | [SugarColumn(ColumnName = "barcodemoveQty", ColumnDescription = "æ°é" , DefaultValue = "0", IsNullable = true)] |
| | | public decimal BarcodeMoveQty { get; set; } |
| | | [SugarColumn(ColumnName = "barcodemoveQty", ColumnDescription = "æ°é", DefaultValue = "0", IsNullable = true)] |
| | | public decimal BarcodeMoveQty { get; set; } |
| | | /// <summary> |
| | | /// ä»åº |
| | | /// é»è®¤å¼: |
| | |
| | | [SugarColumn(IsNullable = true, ColumnDescription = "èæåºå
¥åºæ°é")] |
| | | public decimal NoStockOutQty { get; set; } |
| | | |
| | | |
| | | // æ°å¢å段 |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = true, ColumnDescription = "åä¼ MESæ°æ®")] |
| | | public string ReturnJsonData { get; set; } |
| | | |
| | | [SugarColumn(IsNullable = true)] |
| | | public decimal CurrentDeliveryQty { get; set; } |
| | | |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using SqlSugar; |
| | | using System; |
| | | using WIDESEA_Core.DB.Models; |
| | | |
| | | namespace WIDESEA_Model.Models |
| | | { |
| | | /// <summary> |
| | | /// MESåä¼ è®°å½è¡¨ |
| | | /// </summary> |
| | | [SugarTable("Dt_MesReturnRecord")] |
| | | public class Dt_MesReturnRecord : BaseEntity |
| | | { |
| | | /// <summary> |
| | | /// ä¸»é® |
| | | /// </summary> |
| | | [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] |
| | | public int Id { get; set; } |
| | | |
| | | /// <summary> |
| | | /// åæ®ç±»å |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = false)] |
| | | public int OrderType { get; set; } |
| | | |
| | | /// <summary> |
| | | /// åæ®ä¸»è¡¨ID |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = false)] |
| | | public int OrderId { get; set; } |
| | | |
| | | /// <summary> |
| | | /// åæ®ç¼å· |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = false, Length = 50)] |
| | | public string OrderNo { get; set; } |
| | | |
| | | /// <summary> |
| | | /// åä¼ ç±»åï¼1=æ´åï¼2=åæ¹ |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = false)] |
| | | public int ReturnType { get; set; } |
| | | |
| | | /// <summary> |
| | | /// åä¼ æ¥å£ç±»åï¼1=åºåºï¼2=å
¥åºï¼3=è°æ¨ |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = false)] |
| | | public int InterfaceType { get; set; } |
| | | |
| | | /// <summary> |
| | | /// åä¼ æ°æ®ï¼JSONæ ¼å¼ï¼å
å«å®æ´çåä¼ æ°æ®ï¼ |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = false, Length = int.MaxValue)] |
| | | public string RequestData { get; set; } |
| | | |
| | | /// <summary> |
| | | /// APIå°å |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = false, Length = 200)] |
| | | public string ApiUrl { get; set; } |
| | | |
| | | /// <summary> |
| | | /// è¿åæ¥æï¼JSONæ ¼å¼ï¼ |
| | | /// </summary> |
| | | [SugarColumn(Length = int.MaxValue, IsNullable = true)] |
| | | public string ResponseData { get; set; } |
| | | |
| | | /// <summary> |
| | | /// HTTPç¶æç |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = true)] |
| | | public int? HttpStatusCode { get; set; } |
| | | |
| | | /// <summary> |
| | | /// åä¼ æ¬¡æ° |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = false)] |
| | | public int ReturnCount { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 请æ±ä»£ç ï¼éè¯æ¶ä¿æä¸åï¼ |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = false, Length = 50)] |
| | | public string RequestCode { get; set; } |
| | | |
| | | /// <summary> |
| | | /// åä¼ ç¶æï¼1=åä¼ æåï¼2=åä¼ å¤±è´¥ |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = false)] |
| | | public int ReturnStatus { get; set; } |
| | | |
| | | /// <summary> |
| | | /// æååä¼ æ¶é´ |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = true)] |
| | | public DateTime? LastReturnTime { get; set; } |
| | | |
| | | /// <summary> |
| | | /// åä¼ æåæ¶é´ |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = true)] |
| | | public DateTime? SuccessTime { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 失败åå |
| | | /// </summary> |
| | | [SugarColumn(Length = 500, IsNullable = true)] |
| | | public string FailureReason { get; set; } |
| | | } |
| | | } |
| | |
| | | |
| | | private readonly IOutStockLockInfoService _outStockLockInfoService; |
| | | private readonly ILocationInfoService _locationInfoService; |
| | | private readonly IBasicService _basicService; |
| | | private readonly IRecordService _recordService; |
| | | private readonly IOutboundOrderService _outboundOrderService; |
| | | private readonly ILocationStatusChangeRecordService _locationStatusChangeRecordService; |
| | | private readonly ILogger<OutboundOrderDetailService> _logger; |
| | | public OutboundOrderDetailService(IRepository<Dt_OutboundOrderDetail> BaseDal, IUnitOfWorkManage unitOfWorkManage, IStockService stockService, IOutStockLockInfoService outStockLockInfoService, IBasicService basicService, IRecordService recordService, ILocationInfoService locationInfoService, ILocationStatusChangeRecordService locationStatusChangeRecordService, IOutboundOrderService outboundOrderService, ILogger<OutboundOrderDetailService> logger) : base(BaseDal) |
| | | public OutboundOrderDetailService(IRepository<Dt_OutboundOrderDetail> BaseDal, IUnitOfWorkManage unitOfWorkManage, IStockService stockService, IOutStockLockInfoService outStockLockInfoService, IRecordService recordService, ILocationInfoService locationInfoService, ILocationStatusChangeRecordService locationStatusChangeRecordService, IOutboundOrderService outboundOrderService, ILogger<OutboundOrderDetailService> logger) : base(BaseDal) |
| | | { |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | | _stockService = stockService; |
| | | _outStockLockInfoService = outStockLockInfoService; |
| | | _basicService = basicService; |
| | | _recordService = recordService; |
| | | _locationInfoService = locationInfoService; |
| | | _locationStatusChangeRecordService = locationStatusChangeRecordService; |
| | |
| | | |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// åé
åºåºåºå æå
è¿å
åºåååé
|
| | | /// </summary> |
| | | public (List<Dt_StockInfo>, List<Dt_OutboundOrderDetail>, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) |
| | |
| | | |
| | | // æç©æåæ¹æ¬¡åç»å¤ç |
| | | var groupDetails = outboundOrderDetails |
| | | .GroupBy(x => new { x.MaterielCode, x.BatchNo, x.SupplyCode,x.WarehouseCode }) |
| | | .GroupBy(x => new { x.MaterielCode, x.BatchNo, x.SupplyCode, x.WarehouseCode }) |
| | | .Select(x => new |
| | | { |
| | | MaterielCode = x.Key.MaterielCode, |
| | | BatchNo = x.Key.BatchNo, |
| | | SupplyCode = x.Key.SupplyCode, |
| | | Details = x.ToList(), |
| | | WarehouseCode=x.Key.WarehouseCode, |
| | | WarehouseCode = x.Key.WarehouseCode, |
| | | TotalNeedQuantity = CalculateReassignNeedQuantity(x.ToList()) |
| | | }) |
| | | .Where(x => x.TotalNeedQuantity > 0) |
| | |
| | | foreach (var item in groupDetails) |
| | | { |
| | | var needQuantity = item.TotalNeedQuantity; |
| | | |
| | | |
| | | // è·åå¯ç¨åºåï¼æå
è¿å
åºæåºï¼ |
| | | List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.GetUseableStocks(item.MaterielCode, item.BatchNo, item.SupplyCode,item.WarehouseCode, outboundOrder.FactoryArea); |
| | | List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.GetUseableStocks(item.MaterielCode, item.BatchNo, item.SupplyCode, item.WarehouseCode, outboundOrder.FactoryArea); |
| | | |
| | | if (!stockInfos.Any()) |
| | | { |
| | |
| | | |
| | | |
| | | // æ´æ°åºååæçç¶æ |
| | | UpdateNormalStocksAndPalletsStatus(autoAssignStocks, stockAllocations); |
| | | UpdateNormalStocksAndPalletsStatus(autoAssignStocks, stockAllocations); |
| | | } |
| | | |
| | | if (outStocks.Any()) |
| | |
| | | if (stockAllocations.TryGetValue(stockDetail.Id, out decimal allocatedQty) && allocatedQty > 0) |
| | | { |
| | | |
| | | _stockService.StockInfoService.Db.Updateable<Dt_StockInfo>() |
| | | .SetColumns(x => new Dt_StockInfo |
| | | { |
| | | StockStatus = (int)StockStatusEmun.åºåºéå®, |
| | | }) |
| | | .Where(x => x.Id == stock.Id) |
| | | .ExecuteCommand(); |
| | | _stockService.StockInfoService.Db.Updateable<Dt_StockInfo>() |
| | | .SetColumns(x => new Dt_StockInfo |
| | | { |
| | | StockStatus = (int)StockStatusEmun.åºåºéå®, |
| | | }) |
| | | .Where(x => x.Id == stock.Id) |
| | | .ExecuteCommand(); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | // æç©æåæ¹æ¬¡åç»å¤çï¼è¿éåªæä¸ä¸ªæç»ï¼ |
| | | var groupDetails = new List<Dt_OutboundOrderDetail> { orderDetail } |
| | | .GroupBy(x => new { x.MaterielCode, x.BatchNo, x.SupplyCode ,x.WarehouseCode}) |
| | | .GroupBy(x => new { x.MaterielCode, x.BatchNo, x.SupplyCode, x.WarehouseCode }) |
| | | .Select(x => new |
| | | { |
| | | MaterielCode = x.Key.MaterielCode, |
| | | BatchNo = x.Key.BatchNo, |
| | | SupplyCode = x.Key.SupplyCode, |
| | | WarehouseCode=x.Key.WarehouseCode, |
| | | WarehouseCode = x.Key.WarehouseCode, |
| | | Details = x.ToList(), |
| | | TotalNeedQuantity = batchQuantity // 使ç¨åæ¹æ°é |
| | | }) |
| | |
| | | var needQuantity = item.TotalNeedQuantity; |
| | | |
| | | // è·åå¯ç¨åºåï¼æå
è¿å
åºæåºï¼ |
| | | List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.GetUseableStocks(item.MaterielCode, item.BatchNo, item.SupplyCode,item.WarehouseCode,outboundOrder.FactoryArea); |
| | | List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.GetUseableStocks(item.MaterielCode, item.BatchNo, item.SupplyCode, item.WarehouseCode, outboundOrder.FactoryArea); |
| | | if (!stockInfos.Any()) |
| | | { |
| | | throw new Exception($"ç©æ[{item.MaterielCode}]æ¹æ¬¡[{item.BatchNo}]æªæ¾å°å¯åé
åºå"); |
| | |
| | | var stockDetail = stock.Details.First(); |
| | | if (stockAllocations.TryGetValue(stockDetail.Id, out decimal allocatedQty) && allocatedQty > 0) |
| | | { |
| | | |
| | | |
| | | await _stockService.StockInfoService.Db.Updateable<Dt_StockInfo>() |
| | | .SetColumns(x => new Dt_StockInfo |
| | | { |
| | | StockStatus = (int)StockStatusEmun.åºåºéå®, |
| | | StockStatus = (int)StockStatusEmun.åºåºéå®, |
| | | }) |
| | | .Where(x => x.Id == stock.Id) |
| | | .ExecuteCommandAsync(); |
| | |
| | | SearchParameters? searchParameters = searchParametersList.FirstOrDefault(x => x.Name == nameof(Dt_InboundOrderDetail.OrderId).FirstLetterToLower()); |
| | | if (searchParameters != null) |
| | | { |
| | | sugarQueryable1 = sugarQueryable1.Where(x => x.OrderId == searchParameters.Value.ObjToInt()); |
| | | var dataList = sugarQueryable1.ToPageList(options.Page, options.Rows, ref totalCount); |
| | | return new PageGridData<Dt_OutboundOrderDetail>(totalCount, dataList); |
| | | Dt_OutboundOrder outboundOrder = _outboundOrderService.Repository.QueryFirst(x => x.Id == searchParameters.Value.ObjToInt()); |
| | | if (outboundOrder != null) |
| | | { |
| | | if (outboundOrder.IsBatch == 0) |
| | | { |
| | | sugarQueryable1 = sugarQueryable1.Where(x => x.OrderId == searchParameters.Value.ObjToInt()); |
| | | var dataList = sugarQueryable1.ToPageList(options.Page, options.Rows, ref totalCount); |
| | | return new PageGridData<Dt_OutboundOrderDetail>(totalCount, dataList); |
| | | } |
| | | else |
| | | { |
| | | sugarQueryable1 = sugarQueryable1.Where(x => x.OrderId == searchParameters.Value.ObjToInt()); |
| | | sugarQueryable1.GroupBy(x => new { x.MaterielCode, x.MaterielName, x.BatchNo, x.SupplyCode, x.WarehouseCode }).Select(s => new Dt_OutboundOrderDetail |
| | | { |
| | | WarehouseCode = s.WarehouseCode, |
| | | SupplyCode = s.SupplyCode, |
| | | BatchNo = s.BatchNo, |
| | | MaterielName = s.MaterielName, |
| | | MaterielCode = s.MaterielCode, |
| | | AllocatedQuantity = SqlFunc.AggregateSum(s.AllocatedQuantity), |
| | | OrderQuantity = SqlFunc.AggregateSum(s.OrderQuantity), |
| | | PickedQty = SqlFunc.AggregateSum(s.PickedQty), |
| | | OverOutQuantity = SqlFunc.AggregateSum(s.OverOutQuantity), |
| | | MoveQty = SqlFunc.AggregateSum(s.MoveQty), |
| | | NoStockOutQty = SqlFunc.AggregateSum(s.NoStockOutQty), |
| | | LockQuantity = SqlFunc.AggregateSum(s.LockQuantity), |
| | | BarcodeMoveQty = SqlFunc.AggregateSum(s.BarcodeMoveQty), |
| | | BarcodeQty =SqlFunc.AggregateMin( s.BarcodeQty), |
| | | BarcodeUnit = SqlFunc.AggregateMin(s.BarcodeUnit), |
| | | BatchAllocateStatus = SqlFunc.AggregateMin(s.BatchAllocateStatus), |
| | | CreateDate = SqlFunc.AggregateMin(s.CreateDate), |
| | | Creater = SqlFunc.AggregateMin(s.Creater), |
| | | documentsNO = SqlFunc.AggregateMin(s.documentsNO), |
| | | Id = SqlFunc.AggregateMin(s.Id), |
| | | lineNo = SqlFunc.AggregateMin(s.lineNo), |
| | | Modifier = SqlFunc.AggregateMin(s.Modifier), |
| | | ModifyDate = SqlFunc.AggregateMin(s.ModifyDate), |
| | | OrderDetailStatus = SqlFunc.AggregateMin(s.OrderDetailStatus), |
| | | OrderId = SqlFunc.AggregateMin(s.OrderId), |
| | | Remark = SqlFunc.AggregateMin(s.Remark), |
| | | ReturnJsonData = SqlFunc.AggregateMin(s.ReturnJsonData), |
| | | ReturnToMESStatus = SqlFunc.AggregateMin(s.ReturnToMESStatus), |
| | | RowNo = SqlFunc.AggregateMin(s.RowNo), |
| | | Unit = SqlFunc.AggregateMin(s.Unit) |
| | | }); |
| | | var dataList = sugarQueryable1.ToPageList(options.Page, options.Rows, ref totalCount); |
| | | return new PageGridData<Dt_OutboundOrderDetail>(totalCount, dataList); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | public (List<Dt_StockInfo>, Dt_OutboundOrderDetail, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>)AssignStockOutbound(Dt_OutboundOrderDetail outboundOrderDetail, List<StockSelectViewDTO> stockSelectViews) |
| | | public (List<Dt_StockInfo>, Dt_OutboundOrderDetail, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) AssignStockOutbound(Dt_OutboundOrderDetail outboundOrderDetail, List<StockSelectViewDTO> stockSelectViews) |
| | | { |
| | | // éªè¯ç¨æ·éæ© |
| | | (bool, string) checkResult = CheckSelectStockDeital(outboundOrderDetail, stockSelectViews); |
| | |
| | | } |
| | | |
| | | // å¦æç¨æ·éæ©çåºåä¸å¤ï¼èªå¨åé
å©ä½é¨å |
| | | |
| | | |
| | | if (remainingNeedQuantity > 0) |
| | | { |
| | | |
| | | |
| | | } |
| | | |
| | | // æ´æ°é宿°é |
| | |
| | | .Where(d => d.MaterielCode == detail.MaterielCode && |
| | | (d.StockQuantity - d.OutboundQuantity) > 0 && |
| | | d.Barcode == barcode); // åªåé
æå®æ¡ç |
| | | |
| | | |
| | | query = query.Where(x => x.WarehouseCode == detail.WarehouseCode); |
| | | |
| | | if (!string.IsNullOrEmpty(detail.BatchNo)) |
| | |
| | | var query = stock.Details.AsQueryable() |
| | | .Where(d => d.MaterielCode == detail.MaterielCode && |
| | | (d.StockQuantity - d.OutboundQuantity) > 0); |
| | | // .OrderBy(d => d.CreateDate); |
| | | // .OrderBy(d => d.CreateDate); |
| | | |
| | | if (!string.IsNullOrEmpty(detail.BatchNo)) |
| | | { |
| | |
| | | { |
| | | query = query.Where(d => d.SupplyCode == detail.SupplyCode); |
| | | } |
| | | var sortedDetails= query.ToList().OrderBy(d => d.CreateDate); |
| | | var sortedDetails = query.ToList().OrderBy(d => d.CreateDate); |
| | | |
| | | |
| | | foreach (var stockDetail in sortedDetails) |
| | |
| | | } |
| | | |
| | | private Dt_OutStockLockInfo CreateOutStockLockInfo(Dt_OutboundOrder outboundOrder, Dt_OutboundOrderDetail detail, |
| | | Dt_StockInfo stock, decimal quantity,string barcode="") |
| | | Dt_StockInfo stock, decimal quantity, string barcode = "") |
| | | { |
| | | |
| | | |
| | | |
| | | return _outStockLockInfoService.GetOutStockLockInfo(outboundOrder, detail, stock, quantity, barcode); |
| | | } |
| | |
| | | } |
| | | |
| | | var available = CalculateAvailableQuantityByBarcode(stock, outboundOrderDetail.MaterielCode, |
| | | outboundOrderDetail.BatchNo, outboundOrderDetail.SupplyCode,selection.Barcode); |
| | | outboundOrderDetail.BatchNo, outboundOrderDetail.SupplyCode, selection.Barcode); |
| | | |
| | | if (available <= 0) |
| | | { |
| | |
| | | { |
| | | try |
| | | { |
| | | List<Dt_OutStockLockInfo> outStockLockInfos = _outboundLockInfoService.Repository.QueryData(x => x.PalletCode == palletCode && x.OrderNo == orderNo); |
| | | List<Dt_OutStockLockInfo> outStockLockInfos = _outboundLockInfoRepository.QueryData(x => x.PalletCode == palletCode && x.OrderNo == orderNo); |
| | | return WebResponseContent.Instance.OK(data: outStockLockInfos); |
| | | } |
| | | catch (Exception ex) |
| | |
| | | try |
| | | { |
| | | // æå»ºæ¥è¯¢æ¡ä»¶ |
| | | var query = _stockChangeService.Repository.Db |
| | | var query = _stockChangeRepository.Db |
| | | .Queryable<Dt_StockQuantityChangeRecord>() |
| | | .LeftJoin<Dt_OutboundOrder>((r, o) => r.OrderNo == o.OrderNo) |
| | | .Where((r, o) => r.ChangeType == (int)StockChangeTypeEnum.Outbound) |
| | |
| | | using SqlSugar; |
| | | using Newtonsoft.Json; |
| | | using Newtonsoft.Json.Serialization; |
| | | using SqlSugar; |
| | | using WIDESEA_Common.LocationEnum; |
| | | using WIDESEA_Common.OrderEnum; |
| | | using WIDESEA_Common.StockEnum; |
| | | using WIDESEA_Common.TaskEnum; |
| | | using WIDESEA_Core; |
| | | using WIDESEA_Core.BaseRepository; |
| | | using WIDESEA_Core.CodeConfigEnum; |
| | | using WIDESEA_Core.Helper; |
| | | using WIDESEA_DTO.CalcOut; |
| | | using WIDESEA_DTO.ReturnMES; |
| | | using WIDESEA_IBasicService; |
| | | using WIDESEA_IOutboundService; |
| | | using WIDESEA_IRecordService; |
| | |
| | | public IOutStockLockInfoService OutboundStockLockInfoService { get; } |
| | | |
| | | private readonly ISqlSugarClient Db; |
| | | private readonly IOutboundOrderDetailService _detailService; |
| | | private readonly IOutboundOrderService _outboundOrderService; |
| | | private readonly IOutStockLockInfoService _outboundLockInfoService; |
| | | private readonly IStockInfoService _stockInfoService; |
| | | private readonly IStockInfoDetailService _stockDetailService; |
| | | private readonly ILocationInfoService _locationInfoService; |
| | | private readonly IStockQuantityChangeRecordService _stockChangeService; |
| | | private readonly IStockInfoDetail_HtyService _stockDetailHistoryService; |
| | | private readonly IBasicService _basicService; |
| | | |
| | | public OutboundService(IUnitOfWorkManage unitOfWorkManage, IOutboundOrderDetailService outboundOrderDetailService, IOutboundOrderService outboundOrderService, IOutStockLockInfoService outboundStockLockInfoService, IStockInfoService stockInfoService, IStockInfoDetailService stockDetailService, ILocationInfoService locationInfoService, IStockQuantityChangeRecordService stockQuantityChangeRecordService, IStockInfoDetail_HtyService stockDetailHistoryService) |
| | | |
| | | private readonly IRepository<Dt_OutboundOrderDetail> _detailRepository; |
| | | private readonly IRepository<Dt_OutboundOrder> _outboundRepository; |
| | | private readonly IRepository<Dt_OutStockLockInfo> _outboundLockInfoRepository; |
| | | private readonly IRepository<Dt_StockInfo> _stockInfoRepository; |
| | | private readonly IRepository<Dt_StockInfoDetail> _stockDetailRepository; |
| | | private readonly IRepository<Dt_LocationInfo> _locationInfoRepository; |
| | | private readonly IRepository<Dt_StockQuantityChangeRecord> _stockChangeRepository; |
| | | private readonly IRepository<Dt_StockInfoDetail_Hty> _stockDetailHistoryRepository; |
| | | |
| | | public OutboundService(IUnitOfWorkManage unitOfWorkManage, IRepository<Dt_OutboundOrderDetail> detailRepository, IRepository<Dt_OutboundOrder> outboundRepository, IRepository<Dt_OutStockLockInfo> outboundLockInfoRepository, IRepository<Dt_StockInfo> stockInfoRepository, IRepository<Dt_StockInfoDetail> stockDetailRepository, IRepository<Dt_StockQuantityChangeRecord> stockChangeRepository, IRepository<Dt_StockInfoDetail_Hty> stockDetailHistoryRepository, IBasicService basicService, IOutboundOrderDetailService outboundOrderDetailService, IOutboundOrderService outboundOrderService, IOutStockLockInfoService outboundStockLockInfoService) |
| | | { |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | | Db = _unitOfWorkManage.GetDbClient(); |
| | | OutboundOrderDetailService = outboundOrderDetailService; |
| | | OutboundOrderService = outboundOrderService; |
| | | OutboundStockLockInfoService = outboundStockLockInfoService; |
| | | _detailService = outboundOrderDetailService; |
| | | _outboundOrderService = outboundOrderService; |
| | | _outboundLockInfoService = outboundStockLockInfoService; |
| | | _stockInfoService = stockInfoService; |
| | | _stockDetailService = stockDetailService; |
| | | _locationInfoService = locationInfoService; |
| | | _stockChangeService = stockQuantityChangeRecordService; |
| | | _stockDetailHistoryService = stockDetailHistoryService; |
| | | _detailRepository = detailRepository; |
| | | _outboundRepository = outboundRepository; |
| | | _outboundLockInfoRepository = outboundLockInfoRepository; |
| | | _stockInfoRepository = stockInfoRepository; |
| | | _stockDetailRepository = stockDetailRepository; |
| | | _locationInfoRepository = basicService.LocationInfoService.Repository; |
| | | _stockChangeRepository = stockChangeRepository; |
| | | _stockDetailHistoryRepository = stockDetailHistoryRepository; |
| | | _basicService = basicService; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | foreach (var detail in materielCalc.Details) |
| | | { |
| | | decimal lockQuantity = (detail.OrderQuantity - detail.OverOutQuantity); |
| | | detail.LockQuantity += lockQuantity; // å¢å é宿°é 䏿´æ° OverOutQuantity å OrderDetailStatusï¼å ä¸ºè¿æ²¡æå®é
åºåº |
| | | |
| | | outboundOrderDetails.Add(detail); |
| | | if (lockQuantity < materielCalc.UnallocatedQuantity) |
| | | { |
| | | detail.LockQuantity += lockQuantity; // å¢å é宿°é 䏿´æ° OverOutQuantity å OrderDetailStatusï¼å ä¸ºè¿æ²¡æå®é
åºåº |
| | | outboundOrderDetails.Add(detail); |
| | | } |
| | | else |
| | | { |
| | | detail.LockQuantity += materielCalc.UnallocatedQuantity; |
| | | outboundOrderDetails.Add(detail); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | UpdateOutboundOrderStatus(request.OrderNo, (int)OutOrderStatusEnum.åºåºä¸); |
| | | |
| | | // 4. æ´æ°åºåºåæç»é宿°é |
| | | _detailService.Repository.UpdateData(outboundOrderDetails); |
| | | _detailRepository.UpdateData(outboundOrderDetails); |
| | | |
| | | // 5. æ´æ°åºåç¶æ |
| | | UpdateStockStatus(pickedDetails.Select(x => x.PalletCode).ToList(), StockStatusEmun.åºåºéå®.ObjToInt()); |
| | |
| | | |
| | | try |
| | | { |
| | | Dt_OutboundOrder outboundOrder = _outboundOrderService.Repository.QueryFirst(x => x.OrderNo == request.OrderNo); |
| | | Dt_OutboundOrder outboundOrder = _outboundRepository.QueryFirst(x => x.OrderNo == request.OrderNo); |
| | | if (outboundOrder == null) |
| | | { |
| | | result.CanOutbound = false; |
| | |
| | | } |
| | | |
| | | result.FactoryArea = outboundOrder.FactoryArea; |
| | | result.IsMultiDetail = request.IsMultiDetail; |
| | | |
| | | // è·åéæ©çåºåºæç» |
| | | List<Dt_OutboundOrderDetail> selectedDetails = _detailService.Repository.QueryData(x => x.OrderId == outboundOrder.Id && request.DetailIds.Contains(x.Id)); |
| | | List<Dt_OutboundOrderDetail> selectedDetails = _detailRepository.QueryData(x => x.OrderId == outboundOrder.Id && request.DetailIds.Contains(x.Id)); |
| | | |
| | | if (outboundOrder.IsBatch == 1) |
| | | { |
| | | selectedDetails = _detailRepository.QueryData(x => x.WarehouseCode == selectedDetails.First().WarehouseCode && x.MaterielCode == selectedDetails.First().MaterielCode && x.BatchNo == selectedDetails.First().BatchNo && x.SupplyCode == selectedDetails.First().SupplyCode); |
| | | } |
| | | |
| | | |
| | | if (!selectedDetails.Any()) |
| | | { |
| | |
| | | result.ErrorMessage = $"æªæ¾å°éæ©çåºåºæç»ä¿¡æ¯"; |
| | | return result; |
| | | } |
| | | |
| | | if (selectedDetails.Any(x => x.LockQuantity > x.OrderQuantity - x.MoveQty || x.OverOutQuantity > x.OrderQuantity - x.MoveQty)) |
| | | { |
| | | List<int> selectDetailIds = selectedDetails.Where(x => x.LockQuantity > x.OrderQuantity - x.MoveQty || x.OverOutQuantity > x.OrderQuantity - x.MoveQty).Select(x => x.Id).ToList(); |
| | |
| | | result.OutboundOrder = outboundOrder; |
| | | result.SelectedDetails = selectedDetails; |
| | | |
| | | if (request.IsMultiDetail) |
| | | if (outboundOrder.IsBatch == 0) |
| | | { |
| | | // 夿ç»åºåºï¼æç©æåç»å¤ç |
| | | result.MaterielCalculations = CalcMaterielOutboundQuantities(outboundOrder, selectedDetails.ToList()); |
| | |
| | | return result; |
| | | } |
| | | |
| | | decimal lockQuantity = selectedDetails.Sum(x => x.LockQuantity); |
| | | decimal orderQuantity = selectedDetails.Sum(x => x.OrderQuantity); |
| | | decimal moveQuantity = selectedDetails.Sum(x => x.MoveQty); |
| | | decimal overQuantity = selectedDetails.Sum(x => x.OverOutQuantity); |
| | | |
| | | Dt_OutboundOrderDetail? singleDetail = selectedDetails.First(); |
| | | |
| | | //夿å¯åºåºæ°é |
| | | if (singleDetail.OrderQuantity - singleDetail.LockQuantity - singleDetail.MoveQty <= 0) |
| | | if (orderQuantity - lockQuantity - moveQuantity < request.OutboundQuantity.Value || orderQuantity - overQuantity - moveQuantity < request.OutboundQuantity.Value) |
| | | { |
| | | result.CanOutbound = false; |
| | | result.ErrorMessage = $"æ¬æ¬¡åºåºæ°é {request.OutboundQuantity.Value} è¶
è¿å¯åºåºæ°é {singleDetail.OrderQuantity - singleDetail.LockQuantity - singleDetail.MoveQty}"; |
| | | result.ErrorMessage = $"æ¬æ¬¡åºåºæ°é {request.OutboundQuantity.Value} è¶
è¿å¯åºåºæ°é {orderQuantity - lockQuantity - moveQuantity}"; |
| | | return result; |
| | | } |
| | | |
| | | result.MaterielCalculations = new List<MaterielOutboundCalculationDTO>() |
| | | { |
| | | new MaterielOutboundCalculationDTO |
| | |
| | | BatchNo = singleDetail.BatchNo, |
| | | SupplyCode = singleDetail.SupplyCode, |
| | | WarehouseCode = singleDetail.WarehouseCode, |
| | | TotalOrderQuantity = singleDetail.OrderQuantity - singleDetail.MoveQty, |
| | | TotalOverOutQuantity = singleDetail.OverOutQuantity, |
| | | AssignedQuantity = singleDetail.LockQuantity, |
| | | UnallocatedQuantity = singleDetail.OrderQuantity - singleDetail.LockQuantity - singleDetail.MoveQty, |
| | | MovedQuantity = singleDetail.MoveQty, |
| | | Details = new List<Dt_OutboundOrderDetail>() { singleDetail } |
| | | TotalOrderQuantity = orderQuantity - moveQuantity, |
| | | TotalOverOutQuantity = overQuantity, |
| | | AssignedQuantity = lockQuantity, |
| | | UnallocatedQuantity = request.OutboundQuantity.Value, |
| | | MovedQuantity = moveQuantity, |
| | | Details = selectedDetails |
| | | } |
| | | }; |
| | | } |
| | |
| | | UnallocatedQuantity = g.Sum(x => x.OrderQuantity - x.LockQuantity - x.MoveQty), |
| | | MovedQuantity = g.Sum(x => x.MoveQty), |
| | | Details = g.ToList(), |
| | | OutStockLockInfos = _outboundLockInfoService.Repository.QueryData(x => x.MaterielCode == g.Key.MaterielCode && x.BatchNo == g.Key.BatchNo && x.OrderType == (int)outboundOrder.OrderType && x.OrderNo == outboundOrder.OrderNo) |
| | | OutStockLockInfos = _outboundLockInfoRepository.QueryData(x => x.MaterielCode == g.Key.MaterielCode && x.BatchNo == g.Key.BatchNo && x.OrderType == (int)outboundOrder.OrderType && x.OrderNo == outboundOrder.OrderNo) |
| | | }) |
| | | .ToList(); |
| | | |
| | |
| | | private List<Dt_StockInfo> BuildStockQueryWithInfo(MaterielOutboundCalculationDTO materielCalc, string factoryArea) |
| | | { |
| | | // åºç¡æ¥è¯¢æ¡ä»¶ï¼ç©æç¼å·ãæ¹æ¬¡å·ï¼å¦ææä¾ï¼ãåºåæ°é>0 |
| | | ISugarQueryable<Dt_StockInfoDetail> stockDetails = _stockDetailService.Repository.Db.Queryable<Dt_StockInfoDetail>().Where(x => x.MaterielCode == materielCalc.MaterielCode && x.StockQuantity > 0); |
| | | ISugarQueryable<Dt_StockInfoDetail> stockDetails = _stockDetailRepository.Db.Queryable<Dt_StockInfoDetail>().Where(x => x.MaterielCode == materielCalc.MaterielCode && x.StockQuantity > 0); |
| | | |
| | | // æ ¹æ®æ¡ä»¶æ·»å ä¾åºåç¼å·å¹é
ï¼ä¸ä¸ºç©ºæ¶æéè¦å¹é
ï¼ |
| | | if (!string.IsNullOrEmpty(materielCalc.SupplyCode)) |
| | |
| | | List<Dt_StockInfoDetail> stockDetailList = stockDetails.ToList(); |
| | | |
| | | // è·åå¯ç¨è´§ä½ç¼å· |
| | | List<string> locationCodes = _locationInfoService.Repository.QueryData(x => (x.LocationStatus == LocationStatusEnum.InStock.ObjToInt() /*|| x.LocationStatus == LocationStatusEnum.Lock.ObjToInt()*/) && x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()).Select(x => x.LocationCode).ToList(); |
| | | List<string> locationCodes = _locationInfoRepository.QueryData(x => (x.LocationStatus == LocationStatusEnum.InStock.ObjToInt() /*|| x.LocationStatus == LocationStatusEnum.Lock.ObjToInt()*/) && x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()).Select(x => x.LocationCode).ToList(); |
| | | |
| | | // è·åææç¸å
³çåºåä¿¡æ¯ |
| | | List<int> stockIds = stockDetailList.GroupBy(x => x.StockId).Select(x => x.Key).ToList(); |
| | | List<Dt_StockInfo> stockInfos = _stockInfoService.Repository.QueryData(x => stockIds.Contains(x.Id) && (x.StockStatus == StockStatusEmun.å
¥åºå®æ.ObjToInt() /*|| x.StockStatus == StockStatusEmun.åºåºéå®.ObjToInt()*/) && !string.IsNullOrEmpty(x.LocationCode) && locationCodes.Contains(x.LocationCode)); |
| | | List<Dt_StockInfo> stockInfos = _stockInfoRepository.QueryData(x => stockIds.Contains(x.Id) && (x.StockStatus == StockStatusEmun.å
¥åºå®æ.ObjToInt() /*|| x.StockStatus == StockStatusEmun.åºåºéå®.ObjToInt()*/) && !string.IsNullOrEmpty(x.LocationCode) && locationCodes.Contains(x.LocationCode)); |
| | | |
| | | // å¨å
åä¸å
³èæ°æ® |
| | | foreach (var stockInfo in stockInfos) |
| | |
| | | private decimal CalcTotalAllocatedQuantity(List<Dt_OutStockLockInfo> lockInfos, int stockId, string materielCode) |
| | | { |
| | | // æ¥è¯¢è¯¥æçè¯¥ç©æå¨ææéå®è®°å½ä¸çæå¤§å·²åé
æ°é |
| | | List<Dt_OutStockLockInfo> lockRecords = _outboundLockInfoService.Repository.QueryData(x => |
| | | List<Dt_OutStockLockInfo> lockRecords = _outboundLockInfoRepository.QueryData(x => |
| | | x.StockId == stockId && |
| | | x.MaterielCode == materielCode); |
| | | |
| | |
| | | { |
| | | try |
| | | { |
| | | Dt_OutboundOrder outboundOrder = _outboundOrderService.Repository.QueryFirst(x => x.OrderNo == orderNo); |
| | | Dt_OutboundOrder outboundOrder = _outboundRepository.QueryFirst(x => x.OrderNo == orderNo); |
| | | if (outboundOrder == null) return false; |
| | | |
| | | outboundOrder.OrderStatus = status; |
| | | _outboundOrderService.Repository.UpdateData(outboundOrder); |
| | | _outboundRepository.UpdateData(outboundOrder); |
| | | return true; |
| | | } |
| | | catch |
| | |
| | | { |
| | | try |
| | | { |
| | | List<Dt_StockInfo> stockInfos = _stockInfoService.Repository.QueryData(x => palletCodes.Contains(x.PalletCode)); |
| | | List<Dt_StockInfo> stockInfos = _stockInfoRepository.QueryData(x => palletCodes.Contains(x.PalletCode)); |
| | | stockInfos.ForEach(stockInfo => |
| | | { |
| | | stockInfo.StockStatus = status; |
| | | }); |
| | | |
| | | _stockInfoService.Repository.UpdateData(stockInfos); |
| | | _stockInfoRepository.UpdateData(stockInfos); |
| | | return true; |
| | | } |
| | | catch |
| | |
| | | { |
| | | try |
| | | { |
| | | List<Dt_LocationInfo> locationInfos = _locationInfoService.Repository.QueryData(x => locationCodes.Contains(x.LocationCode)); |
| | | List<Dt_LocationInfo> locationInfos = _locationInfoRepository.QueryData(x => locationCodes.Contains(x.LocationCode)); |
| | | locationInfos.ForEach(x => |
| | | { |
| | | x.LocationStatus = status; |
| | | }); |
| | | |
| | | _locationInfoService.Repository.UpdateData(locationInfos); |
| | | _locationInfoRepository.UpdateData(locationInfos); |
| | | return true; |
| | | } |
| | | catch |
| | |
| | | try |
| | | { |
| | | List<Dt_OutStockLockInfo> updateData = outStockLockInfos.Where(x => x.Id > 0).ToList(); |
| | | _outboundLockInfoService.Repository.UpdateData(updateData); |
| | | _outboundLockInfoRepository.UpdateData(updateData); |
| | | |
| | | List<Dt_OutStockLockInfo> addData = outStockLockInfos.Where(x => x.Id <= 0).ToList(); |
| | | _outboundLockInfoService.Repository.AddData(addData); |
| | | _outboundLockInfoRepository.AddData(addData); |
| | | |
| | | return true; |
| | | } |
| | |
| | | try |
| | | { |
| | | // 1. æ ¹æ®æçå·æ¥æ¾åºåä¿¡æ¯ |
| | | Dt_StockInfo stockInfo = _stockInfoService.Repository.QueryFirst(x => x.PalletCode == request.PalletCode); |
| | | Dt_StockInfo stockInfo = _stockInfoRepository.QueryFirst(x => x.PalletCode == request.PalletCode); |
| | | if (stockInfo == null) |
| | | { |
| | | response.Success = false; |
| | |
| | | } |
| | | |
| | | // 2. æ ¹æ®æ¡ç æ¥æ¾åºåæç» |
| | | Dt_StockInfoDetail stockDetail = _stockDetailService.Repository.QueryFirst(x => x.Barcode == request.Barcode); |
| | | Dt_StockInfoDetail stockDetail = _stockDetailRepository.QueryFirst(x => x.Barcode == request.Barcode); |
| | | if (stockDetail == null) |
| | | { |
| | | response.Success = false; |
| | |
| | | } |
| | | |
| | | // 4. æ¥æ¾åºåºåä¿¡æ¯ |
| | | Dt_OutboundOrder outboundOrder = _outboundOrderService.Repository.QueryFirst(o => o.OrderNo == request.OrderNo); |
| | | Dt_OutboundOrder outboundOrder = _outboundRepository.QueryFirst(o => o.OrderNo == request.OrderNo); |
| | | if (outboundOrder == null) |
| | | { |
| | | response.Success = false; |
| | |
| | | } |
| | | |
| | | // 5. æ¥æ¾éå®è®°å½ |
| | | Dt_OutStockLockInfo lockInfo = _outboundLockInfoService.Repository.QueryFirst(x => |
| | | Dt_OutStockLockInfo lockInfo = _outboundLockInfoRepository.QueryFirst(x => |
| | | x.OrderNo == request.OrderNo && |
| | | x.StockId == stockInfo.Id && |
| | | x.MaterielCode == stockDetail.MaterielCode && |
| | |
| | | { |
| | | if (allocatedQuantity <= 0) break; |
| | | |
| | | if (item.OrderQuantity - item.MoveQty - item.OverOutQuantity >= allocatedQuantity) |
| | | |
| | | //if (item.OrderQuantity - item.MoveQty - item.OverOutQuantity >= allocatedQuantity) |
| | | //{ |
| | | // item.OverOutQuantity += allocatedQuantity; |
| | | // allocatedQuantity = 0; |
| | | //} |
| | | //else |
| | | //{ |
| | | // allocatedQuantity -= (item.OrderQuantity - item.MoveQty - item.OverOutQuantity); |
| | | // item.OverOutQuantity = item.OrderQuantity - item.MoveQty; |
| | | //} |
| | | |
| | | if (item.LockQuantity - item.OverOutQuantity >= allocatedQuantity) |
| | | { |
| | | item.OverOutQuantity += allocatedQuantity; |
| | | item.CurrentDeliveryQty += allocatedQuantity; |
| | | allocatedQuantity = 0; |
| | | } |
| | | else |
| | | { |
| | | allocatedQuantity -= (item.OrderQuantity - item.MoveQty - item.OverOutQuantity); |
| | | item.OverOutQuantity = item.OrderQuantity - item.MoveQty; |
| | | allocatedQuantity -= (item.LockQuantity - item.OverOutQuantity); |
| | | item.OverOutQuantity = item.LockQuantity; |
| | | item.CurrentDeliveryQty = item.LockQuantity; |
| | | } |
| | | |
| | | updateDetails.Add(item); |
| | | |
| | | List<Barcodes> barcodesList = new List<Barcodes>(); |
| | | Barcodes barcodes = new Barcodes |
| | | { |
| | | Barcode = request.Barcode, |
| | | Qty = actualOutboundQuantity, |
| | | SupplyCode = stockDetail?.SupplyCode ?? "", |
| | | BatchNo = stockDetail?.BatchNo ?? "", |
| | | Unit = stockDetail?.Unit ?? "" |
| | | }; |
| | | if (!string.IsNullOrEmpty(item.ReturnJsonData)) |
| | | { |
| | | barcodesList = JsonConvert.DeserializeObject<List<Barcodes>>(item.ReturnJsonData) ?? new List<Barcodes>(); |
| | | } |
| | | barcodesList.Add(barcodes); |
| | | JsonSerializerSettings settings = new JsonSerializerSettings |
| | | { |
| | | ContractResolver = new CamelCasePropertyNamesContractResolver() |
| | | }; |
| | | item.ReturnJsonData = JsonConvert.SerializeObject(barcodesList, settings); |
| | | } |
| | | |
| | | lockInfo.SortedQuantity = lockInfo.SortedQuantity + actualOutboundQuantity; |
| | | |
| | | if (lockInfo.SortedQuantity == lockInfo.AssignQuantity) |
| | | { |
| | | _outboundLockInfoService.Repository.DeleteAndMoveIntoHty(lockInfo, WIDESEA_Core.Enums.OperateTypeEnum.èªå¨å®æ); |
| | | _outboundLockInfoRepository.DeleteAndMoveIntoHty(lockInfo, WIDESEA_Core.Enums.OperateTypeEnum.èªå¨å®æ); |
| | | } |
| | | else |
| | | { |
| | | // æ´æ°éå®è®°å½ |
| | | _outboundLockInfoService.Repository.UpdateData(lockInfo); |
| | | _outboundLockInfoRepository.UpdateData(lockInfo); |
| | | } |
| | | |
| | | // æ´æ°åºåºåæç»çå·²åºåºæ°é |
| | | _detailService.Repository.UpdateData(updateDetails); |
| | | _detailRepository.UpdateData(updateDetails); |
| | | |
| | | // æ´æ°éå®è®°å½ç累计已åºåºæ°éï¼éè¦æ´æ°è¯¥æçè¯¥ç©æçææç¸å
³è®°å½ï¼ |
| | | //UpdateLockInfoAllocatedQuantity(stockInfo.Id, stockDetail.MaterielCode, stockDetail.BatchNo, actualOutboundQuantity); |
| | |
| | | /// <returns></returns> |
| | | private List<Dt_OutboundOrderDetail> FindMatchingOutboundDetails(int orderId, Dt_StockInfoDetail stockDetail, List<int> detailIds) |
| | | { |
| | | List<Dt_OutboundOrderDetail> details = _detailService.Repository.QueryData(x => |
| | | List<Dt_OutboundOrderDetail> details = _detailRepository.QueryData(x => |
| | | x.OrderId == orderId && |
| | | x.MaterielCode == stockDetail.MaterielCode && x.OrderQuantity - x.MoveQty > x.OverOutQuantity && detailIds.Contains(x.Id)); |
| | | |
| | |
| | | Math.Min(availableOutboundQuantity, detailRemainingQuantity), |
| | | stockDetail.StockQuantity); |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// æ§è¡æå
æä½ |
| | |
| | | WarehouseCode = stockDetail.WarehouseCode, |
| | | Remark = $"æå
ååå§è®°å½ï¼åæ¡ç ï¼{request.Barcode}ï¼åæ°éï¼{stockDetail.StockQuantity}ï¼åºåºæ°éï¼{actualOutboundQuantity}ï¼æä½è
ï¼{request.Operator}" |
| | | }; |
| | | _stockDetailHistoryService.Repository.AddData(originalHistoryRecord); |
| | | _stockDetailHistoryRepository.AddData(originalHistoryRecord); |
| | | |
| | | // ä¿åå©ä½é¨åå°åå²è®°å½ |
| | | decimal remainingQuantity = stockDetail.StockQuantity - actualOutboundQuantity; |
| | |
| | | stockDetail.StockQuantity = remainingQuantity; |
| | | //stockDetail.Barcode = newBarcode; |
| | | stockDetail.Remark = $"æå
åæ´æ°ï¼åæ¡ç ï¼{request.Barcode}ï¼æ°æ°éï¼{remainingQuantity}ï¼æä½è
ï¼{request.Operator}"; |
| | | _stockDetailService.Repository.UpdateData(stockDetail); |
| | | _stockDetailRepository.UpdateData(stockDetail); |
| | | } |
| | | |
| | | // è®°å½æå
åå¨ |
| | |
| | | WarehouseCode = stockDetail.WarehouseCode, |
| | | Remark = $"æå
åºåºï¼åæ¡ç ï¼{request.Barcode}ï¼æ°æ¡ç ï¼{newBarcode}ï¼åºåºæ°éï¼{actualOutboundQuantity}ï¼å©ä½ï¼{remainingQuantity}ï¼æä½è
ï¼{request.Operator}" |
| | | }; |
| | | _stockChangeService.Repository.AddData(unpackChangeRecord); |
| | | _stockChangeRepository.AddData(unpackChangeRecord); |
| | | |
| | | return newBarcode; |
| | | } |
| | |
| | | WarehouseCode = stockDetail.WarehouseCode, |
| | | Remark = $"åºåºå®æå é¤ï¼æ¡ç ï¼{request.Barcode}ï¼åæ°éï¼{stockDetail.StockQuantity}ï¼åºåºæ°éï¼{actualOutboundQuantity}ï¼æä½è
ï¼{request.Operator}" |
| | | }; |
| | | _stockDetailHistoryService.Repository.AddData(historyRecord); |
| | | _stockDetailHistoryRepository.AddData(historyRecord); |
| | | |
| | | // å é¤åºåæç»è®°å½ |
| | | _stockDetailService.Repository.DeleteData(stockDetail); |
| | | _stockDetailRepository.DeleteData(stockDetail); |
| | | |
| | | // è®°å½åºååå¨ |
| | | Dt_StockQuantityChangeRecord changeRecord = new Dt_StockQuantityChangeRecord |
| | |
| | | WarehouseCode = stockDetail.WarehouseCode, |
| | | Remark = $"åºåºå®æå é¤åºåæç»ï¼æ¡ç ï¼{request.Barcode}ï¼åºåºæ°éï¼{actualOutboundQuantity}ï¼æä½è
ï¼{request.Operator}" |
| | | }; |
| | | _stockChangeService.Repository.AddData(changeRecord); |
| | | _stockChangeRepository.AddData(changeRecord); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | // ä½¿ç¨æ¶é´æ³åéæºæ°çæå¯ä¸æ¡ç |
| | | string newBarcode = string.Empty; |
| | | |
| | | //todo éæ°çææ¡ç é»è¾ |
| | | newBarcode = _basicService.CreateCodeByRule(RuleCodeEnum.NewBarcodeRule.ToString()); |
| | | |
| | | return newBarcode; |
| | | } |
| | |
| | | private void UpdateLockInfoAllocatedQuantity(int stockId, string materielCode, string batchNo, decimal actualOutboundQuantity) |
| | | { |
| | | // æ¥è¯¢è¯¥æçè¯¥ç©æçææéå®è®°å½ |
| | | List<Dt_OutStockLockInfo> lockRecords = _outboundLockInfoService.Repository.QueryData(x => |
| | | List<Dt_OutStockLockInfo> lockRecords = _outboundLockInfoRepository.QueryData(x => |
| | | x.StockId == stockId && |
| | | x.MaterielCode == materielCode && |
| | | x.BatchNo == batchNo); |
| | |
| | | } |
| | | |
| | | // æ¹éæ´æ° |
| | | _outboundLockInfoService.Repository.UpdateData(lockRecords); |
| | | _outboundLockInfoRepository.UpdateData(lockRecords); |
| | | } |
| | | } |
| | | |
| | |
| | | /// </summary> |
| | | public bool CheckOutboundOrderCompleted(string orderNo) |
| | | { |
| | | Dt_OutboundOrder outboundOrder = _outboundOrderService.Repository.QueryFirst(x => x.OrderNo == orderNo); |
| | | Dt_OutboundOrder outboundOrder = _outboundRepository.QueryFirst(x => x.OrderNo == orderNo); |
| | | if (outboundOrder == null) return false; |
| | | |
| | | List<Dt_OutboundOrderDetail> details = _detailService.Repository.QueryData(x => x.OrderId == outboundOrder.Id); |
| | | List<Dt_OutboundOrderDetail> details = _detailRepository.QueryData(x => x.OrderId == outboundOrder.Id); |
| | | |
| | | // æ£æ¥æææç»çå·²åºæ°éæ¯å¦é½çäºåæ®æ°é |
| | | return details.All(x => x.OverOutQuantity >= x.OrderQuantity); |
| | | return details.All(x => x.OverOutQuantity >= x.OrderQuantity - x.MoveQty); |
| | | } |
| | | } |
| | | } |