| | |
| | | using WIDESEA_Core; |
| | | using MailKit.Search; |
| | | using Masuit.Tools; |
| | | using Newtonsoft.Json; |
| | | using WIDESEA_Common; |
| | | using WIDESEA_Core; |
| | | using WIDESEA_Core.BaseRepository; |
| | | using WIDESEA_Core.BaseServices; |
| | | using WIDESEA_Core.Const; |
| | | using WIDESEA_Core.Helper; |
| | | using WIDESEA_IBusinessesRepository; |
| | | using WIDESEA_IOrderRepository; |
| | | using WIDESEA_IOrderServices; |
| | | using WIDESEA_IServices; |
| | | using WIDESEA_IStorageTaskRepository; |
| | | using WIDESEA_IStorageTaskServices; |
| | | using WIDESEA_Model.Models; |
| | |
| | | public class Dt_InboundOrderService : ServiceBase<Dt_InboundOrder, IDt_InboundOrderRepository>, IDt_InboundOrderService |
| | | { |
| | | private readonly IUnitOfWorkManage _unitOfWorkManage; |
| | | private readonly ISys_ConfigService _configService; |
| | | private readonly IDt_WareAreaInfoRepository _wareAreaInfoRepository; |
| | | |
| | | public Dt_InboundOrderService(IDt_InboundOrderRepository BaseDal, |
| | | IUnitOfWorkManage unitOfWorkManage) : base(BaseDal) |
| | | IUnitOfWorkManage unitOfWorkManage, |
| | | ISys_ConfigService configService, |
| | | IDt_WareAreaInfoRepository wareAreaInfoRepository) : base(BaseDal) |
| | | { |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | | _configService = configService; |
| | | _wareAreaInfoRepository = wareAreaInfoRepository; |
| | | } |
| | | |
| | | public override WebResponseContent UpdateData(SaveModel saveModel) |
| | | { |
| | | var quantity = saveModel.MainData["quantity"].ToString(); |
| | | var wareHouseId = saveModel.MainData["wareHouseId"].ToString(); |
| | | |
| | | Dt_WareAreaInfo? wareinfo = _wareAreaInfoRepository.QueryFirst(x => x.WareAreaCode == wareHouseId); |
| | | |
| | | if (wareinfo == null) |
| | | { |
| | | return WebResponseContent.Instance.Error("æªæ¾å°ä»åºä¿¡æ¯!"); |
| | | } |
| | | saveModel.MainData.Add("warehouseName", wareinfo.WareAreaName.ToString()); |
| | | return base.UpdateData(saveModel); |
| | | } |
| | | |
| | | public WebResponseContent GetInboundOrderInfo(string OrderNo) |
| | |
| | | return content.Error(ex.Message); |
| | | } |
| | | } |
| | | public WebResponseContent PrintOrder(int[] keys) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | List<Dt_InboundOrder> inboundOrders = new List<Dt_InboundOrder>(); |
| | | foreach (var item in keys) |
| | | { |
| | | var InboundOrder = BaseDal.QueryFirst(x => x.Id == item); |
| | | if(InboundOrder != null) |
| | | { |
| | | inboundOrders.Add(InboundOrder); |
| | | } |
| | | } |
| | | content=PrintInbound(inboundOrders); |
| | | return content; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return content.Error("æªç¥é误ï¼è¯·è系管çå"); |
| | | } |
| | | } |
| | | |
| | | public WebResponseContent SplitOrder(int id,int num) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | var originalOrder = BaseDal.QueryFirst(x => x.Id == id); |
| | | if (originalOrder == null) |
| | | { |
| | | return content.Error("æªæ¾å°è¯¥å
¥åºåä¿¡æ¯"); |
| | | } |
| | | if(originalOrder.Quantity < num || num <= 0) |
| | | { |
| | | return content.Error("æåæ°éä¸åæ³"); |
| | | } |
| | | Dt_InboundOrder orderNew = new Dt_InboundOrder() |
| | | { |
| | | OrderNo = GetOrderPintCode("OrderNoIn"), |
| | | UpperOrderNo = originalOrder.UpperOrderNo, |
| | | DemandClassification = originalOrder.DemandClassification, |
| | | OrderType = originalOrder.OrderType, |
| | | WarehouseName = originalOrder.WarehouseName, |
| | | Datetime = originalOrder.Datetime, |
| | | LineNumber = originalOrder.LineNumber, |
| | | ProductDrawingNumber = originalOrder.ProductDrawingNumber, |
| | | MaterialNo = originalOrder.MaterialNo, |
| | | MaterialName = originalOrder.MaterialName, |
| | | Weight = originalOrder.Weight, |
| | | WareHouseId = originalOrder.WareHouseId, |
| | | Specs = originalOrder.Specs, |
| | | Unit = originalOrder.Unit, |
| | | Texture = originalOrder.Texture, |
| | | Quantity = num, |
| | | OrderStatus = originalOrder.OrderStatus, |
| | | |
| | | }; |
| | | originalOrder.Quantity = originalOrder.Quantity - num; |
| | | |
| | | BaseDal.AddData(orderNew); |
| | | BaseDal.UpdateData(originalOrder); |
| | | return content.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return content.Error("æªç¥é误ï¼è¯·è系管çå"); |
| | | } |
| | | } |
| | | |
| | | public WebResponseContent PrintPalletCode(int num) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | List<string> PalletCodes = new List<string>(); |
| | | for (int i = 0; i < num; i++) |
| | | { |
| | | PalletCodes.Add(GetOrderPintCode("PalletCodes")); |
| | | } |
| | | content= PrintPallet(PalletCodes); |
| | | return content.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return content.Error("æªç¥é误ï¼è¯·è系管çå"); |
| | | } |
| | | } |
| | | public string GetOrderPintCode(string printCode) |
| | | { |
| | | string PrintCode = ""; |
| | | var PrintSetting = SqlSugarHelper.DbWMS.Queryable<Dt_PrintSetting>().Where(x => x.PrintCode == printCode).ToList().FirstOrDefault(); |
| | | |
| | | if (PrintSetting.Spare1 == DateTime.Now.ToString("yyyyMMdd")) |
| | | { |
| | | PrintCode = PrintSetting.Spare1 + PrintSetting.PrintNo.ToString().PadLeft(PrintSetting.Spare2, '0'); |
| | | PrintSetting.PrintNo = PrintSetting.PrintNo + 1; |
| | | } |
| | | else |
| | | { |
| | | PrintSetting.Spare1 = DateTime.Now.ToString("yyyyMMdd"); |
| | | PrintSetting.PrintNo = 2; |
| | | PrintCode = PrintSetting.Spare1 + 1.ToString().PadLeft(PrintSetting.Spare2, '0'); |
| | | } |
| | | SqlSugarHelper.DbWMS.Updateable(PrintSetting).ExecuteCommand(); |
| | | return PrintCode; |
| | | } |
| | | public WebResponseContent PrintPallet(List<string> palletCodes) |
| | | { |
| | | var configs = _configService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress); |
| | | var Base = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.PrintIPAddress)?.ConfigValue; |
| | | var ipAddress = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.PrintPalletCodes)?.ConfigValue; |
| | | if (Base == null || ipAddress == null) |
| | | { |
| | | throw new InvalidOperationException("WMS IP æªé
ç½®"); |
| | | } |
| | | var IpAddress = Base + ipAddress; |
| | | var result = HttpsClient.PostAsync(IpAddress, palletCodes.ToJsonString()).Result; |
| | | return JsonConvert.DeserializeObject<WebResponseContent>(result); |
| | | } |
| | | |
| | | public WebResponseContent PrintInbound(List<Dt_InboundOrder> orders) |
| | | { |
| | | var configs = _configService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress); |
| | | var Base = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.PrintIPAddress)?.ConfigValue; |
| | | var ipAddress = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.PrintInboundOrder)?.ConfigValue; |
| | | if (Base == null || ipAddress == null) |
| | | { |
| | | throw new InvalidOperationException("WMS IP æªé
ç½®"); |
| | | } |
| | | var IpAddress = Base + ipAddress; |
| | | var result = HttpsClient.PostAsync(IpAddress, orders.ToJsonString()).Result; |
| | | return JsonConvert.DeserializeObject<WebResponseContent>(result); |
| | | } |
| | | } |
| | | } |