From 0bd21a03299ffc8a1943bec8833848e2f88e6862 Mon Sep 17 00:00:00 2001 From: 18942506660 <18942506660@A18942506660> Date: Thu, 9 Nov 2023 10:06:36 +0800 Subject: [PATCH 1/9] =?UTF-8?q?erp=E5=AE=A2=E6=88=B7=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vs/WMS.Web/DesignTimeBuild/.dtbcache.v2 | Bin 228751 -> 228751 bytes .../Dto/Erp/Customer/ErpCustomerDto.cs | 27 +++++++ .../Public/IErpBasicDataExtendService.cs | 10 ++- .../IService/Public/IErpService.cs | 7 +- .../Public/ErpBasicDataExtendService.cs | 14 ++++ .../Services/Public/ErpService.cs | 70 ++++++++++++++++++ src/WMS.Web.Domain/Values/Erp/FormIdParam.cs | 6 +- .../OutStockRepositories.cs | 26 ++++++- .../OutStockTaskRepositories.cs | 37 +++++++-- 9 files changed, 184 insertions(+), 13 deletions(-) create mode 100644 src/WMS.Web.Core/Dto/Erp/Customer/ErpCustomerDto.cs diff --git a/.vs/WMS.Web/DesignTimeBuild/.dtbcache.v2 b/.vs/WMS.Web/DesignTimeBuild/.dtbcache.v2 index 1aca7bb9113962059a0399364a486e45ddfa334a..cc7ffb654b373020ae2b0b276c534ded952952b1 100644 GIT binary patch delta 5110 zcmc&%dvFv*9^UDmo+JnaV+ctMkOU%#Ja&_PB%Vl!M1mq<>3M&cD&6b@Q->HsQ1P_{ zmGf~PlDo36w5;<~M1l|yae@elpn`{Ydfut0B7{f)c}+7w2qEUao}JAQz$)*~s@uxf z{r%?qdZxF#_xGDD>g>0uvmbFKEhf_@6jp`2k#M-UurL}8MSKBwiLc7zEeU)5K~Iq< z><{{jg5lzbC*tw=ii%5u-e{mW>W+Fsp`g!S<*i@z*dk@^B62fJ&%Y^BTOFJ=ZSI{_ zk=p4sk=kHggn!0JYnj*Yt8!OG3rhk4pEnfr_`JT7aGirk@+ zV8mVMFLVd0f}Us~S`w)W6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W`DdVou(%YCv&Z~r);Ur{yO&A8YbUxly)RT&Ns@ za+Jwq7b?wAjx%Xqs7NR$?9~7L%-_jm@)t<{gT=%=8u-@*K%fBRh#h&f=YT~FDI9MT zUKJ3$FL)V1@J3*_gVYMzhYsoXwGyEVZ2{>ge$g3wB5GaZM*VwbBFRn zWI#+FMthPknYeurEzC+49Wj3py=3qiRD?F*EN~9kjf%AoI1Dra$$GSV5FJ6zGts|* z=8>#5x7+!~d>?JinN-7_n*9QoH9S>iL2;-v_8}Lzwih{g z$_A=z$qrI5=;{WbG>;1d6_57%u>0S zo0*o}OK^TKir~xYe(HbJxpE1=5s*tcT6~Vxa`_6E%ebt=eQ_f|Ad2XSNeA7$22?wbL42t94VV29M{YYa}>f+(nKgV%N(wr{0@Dt_N>`sEMDjC zY9nCP@8pQ&M0a~lw!^#J@NPRiuECj5?tATcnk(ODhojx}{XoZXmL1M?&9gg(k9G`$ ZOwA+U-s%ZkecZkF1~%46Os3sB{Sz^b%ZmU2 diff --git a/src/WMS.Web.Core/Dto/Erp/Customer/ErpCustomerDto.cs b/src/WMS.Web.Core/Dto/Erp/Customer/ErpCustomerDto.cs new file mode 100644 index 00000000..5e05f3e0 --- /dev/null +++ b/src/WMS.Web.Core/Dto/Erp/Customer/ErpCustomerDto.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace WMS.Web.Core.Dto.Erp.Customer +{ + /// + /// 客户 + /// + public class ErpCustomerDto + { + /// + /// ID + /// + public int Id { get; set; } + + /// + /// 编码 + /// + public string Number { get; set; } + + /// + /// 名称 + /// + public string Name { get; set; } + } +} diff --git a/src/WMS.Web.Domain/IService/Public/IErpBasicDataExtendService.cs b/src/WMS.Web.Domain/IService/Public/IErpBasicDataExtendService.cs index de5a657d..ae09e909 100644 --- a/src/WMS.Web.Domain/IService/Public/IErpBasicDataExtendService.cs +++ b/src/WMS.Web.Domain/IService/Public/IErpBasicDataExtendService.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Text; using WMS.Web.Core.Dto.Erp; +using WMS.Web.Core.Dto.Erp.Customer; using WMS.Web.Core.Dto.Erp.Org; using WMS.Web.Core.Dto.Erp.Supplier; @@ -58,7 +59,14 @@ namespace WMS.Web.Domain.IService.Public /// /// string GetSupplierName(List erpSuppliers, int supplierId); - + /// + /// 获取客户名称 + /// + /// + /// + /// + string GetCustomerName(List erpCustomers, int customerId); + /// /// 获取仓库名称 /// diff --git a/src/WMS.Web.Domain/IService/Public/IErpService.cs b/src/WMS.Web.Domain/IService/Public/IErpService.cs index b31974da..d09b81b9 100644 --- a/src/WMS.Web.Domain/IService/Public/IErpService.cs +++ b/src/WMS.Web.Domain/IService/Public/IErpService.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Text; using System.Threading.Tasks; using WMS.Web.Core.Dto.Erp; +using WMS.Web.Core.Dto.Erp.Customer; using WMS.Web.Core.Dto.Erp.Org; using WMS.Web.Core.Dto.Erp.OutStock; using WMS.Web.Core.Dto.Erp.Purchase; @@ -66,7 +67,11 @@ namespace WMS.Web.Domain.IService.Public /// /// Task> BillQueryForSupplier(); - + /// + /// 客户 + /// + /// + Task> BillQueryForCustomer(); /// /// 获取仓库信息 /// diff --git a/src/WMS.Web.Domain/Services/Public/ErpBasicDataExtendService.cs b/src/WMS.Web.Domain/Services/Public/ErpBasicDataExtendService.cs index 4f9a5a7b..a836efc4 100644 --- a/src/WMS.Web.Domain/Services/Public/ErpBasicDataExtendService.cs +++ b/src/WMS.Web.Domain/Services/Public/ErpBasicDataExtendService.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using WMS.Web.Core.Dto.Erp; +using WMS.Web.Core.Dto.Erp.Customer; using WMS.Web.Core.Dto.Erp.Org; using WMS.Web.Core.Dto.Erp.Supplier; using WMS.Web.Domain.Infrastructure; @@ -100,6 +101,17 @@ namespace WMS.Web.Domain.Services.Public var supplier = erpSuppliers.Where(x => x.Id == supplierId).FirstOrDefault(); return supplier == null ? "" : supplier.Name; } + /// + /// 获取客户名称 + /// + /// + /// + /// + public string GetCustomerName(List erpCustomers, int customerId) + { + var supplier = erpCustomers.Where(x => x.Id == customerId).FirstOrDefault(); + return supplier == null ? "" : supplier.Name; + } /// /// 获取仓库名称 @@ -136,5 +148,7 @@ namespace WMS.Web.Domain.Services.Public var stock = erpStocks.Where(x => x.Id == stockId).FirstOrDefault(); return stock == null ? "" : stock.Code; } + + } } diff --git a/src/WMS.Web.Domain/Services/Public/ErpService.cs b/src/WMS.Web.Domain/Services/Public/ErpService.cs index 1f5329d7..35f86e58 100644 --- a/src/WMS.Web.Domain/Services/Public/ErpService.cs +++ b/src/WMS.Web.Domain/Services/Public/ErpService.cs @@ -12,6 +12,7 @@ using System.ServiceModel; using System.Text; using System.Threading.Tasks; using WMS.Web.Core.Dto.Erp; +using WMS.Web.Core.Dto.Erp.Customer; using WMS.Web.Core.Dto.Erp.Org; using WMS.Web.Core.Dto.Erp.OutStock; using WMS.Web.Core.Dto.Erp.Purchase; @@ -397,7 +398,74 @@ namespace WMS.Web.Domain.Services.Public return ResultList.ReFailure(ResultCodes.ErpSupplierError); } } + /// + /// 客户 + /// + /// + public async Task> BillQueryForCustomer() + { + try + { + //1.获取缓存中的供应商数据; + var cache_key = "erp_customer_list"; + var customers = _memoryCache.Get>(cache_key); + if (customers == null || customers.Count == 0) + { + //2.先登录金蝶-拿到token + var token_result = await this.Init(); + if (!token_result.IsSuccess) + return ResultList.ReFailure(token_result); + + //3.获取金蝶供应商:拼接参数和条件 + var query = new ErpBillQueryDto(token_result.Data); + var param = new ErpBillQueryParamDto(FormIdParam.BD_Customer.ToString()); + param.FieldKeys = "FCUSTID,FNumber,FName"; + param.Limit = 10000; + //查询条件:备注其中的条件值以金蝶的值为准!!! + param.FilterString = ""; + + //备注:因为供应商数据不是很多,就不能和获取物料一样循环获取;组织这里就获取10000条数据就行了 + var beginTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); + _logger.LogInformation($"供应商拉取-开始时间:{beginTime}"); + //4.参数json化 + query.Data = JsonConvert.SerializeObject(param); + var json = JsonConvert.SerializeObject(query); + + //5.请求查询接口并返回数据 + var result_json = await _client.ExecuteBillQueryAsync(json); + var result = JsonConvert.DeserializeObject>>(result_json); + + var endTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); + _logger.LogInformation($"供应商拉取-结束时间:{endTime}"); + //6.拼装 + var list = new List(); + foreach (var item in result) + { + var lis = new ErpCustomerDto(); + lis.Id = int.Parse(item[0]); + lis.Number = item[1]; + lis.Name = item[2]; + list.Add(lis); + + } + //5.供应商集合进行缓存 + _memoryCache.Set(cache_key, list, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromHours(12))); + _logger.LogInformation($"供应商拉取-总条数:{list.Count}"); + return ResultList.ReSuccess(list); + + } + else + { + return ResultList.ReSuccess(customers); + } + + } + catch (Exception) + { + return ResultList.ReFailure(ResultCodes.ErpSupplierError); + } + } /// /// erp:仓库 /// @@ -1006,6 +1074,8 @@ namespace WMS.Web.Domain.Services.Public } } + + #endregion } } diff --git a/src/WMS.Web.Domain/Values/Erp/FormIdParam.cs b/src/WMS.Web.Domain/Values/Erp/FormIdParam.cs index 9221849a..ad225a75 100644 --- a/src/WMS.Web.Domain/Values/Erp/FormIdParam.cs +++ b/src/WMS.Web.Domain/Values/Erp/FormIdParam.cs @@ -68,6 +68,10 @@ namespace WMS.Web.Domain.Values.Erp /// /// 分布式调出单 /// - STK_TRANSFEROUT=15 + STK_TRANSFEROUT=15, + /// + /// 客户 + /// + BD_Customer=16 } } diff --git a/src/WMS.Web.Repositories/OutStockRepositories.cs b/src/WMS.Web.Repositories/OutStockRepositories.cs index 30b15a6f..4b422fae 100644 --- a/src/WMS.Web.Repositories/OutStockRepositories.cs +++ b/src/WMS.Web.Repositories/OutStockRepositories.cs @@ -88,7 +88,7 @@ namespace WMS.Web.Repositories var staffList = await _basicsRepositories.GetStaffListAsync(_loginRepositories.CompanyId); ids = staffList.Where(w => EF.Functions.Like(w.Name, "%" + dto.Creator + "%")).Select(s => s.Id).ToList(); } - + #region erp基础资料 List mIds = new List(); var materials_result = await _erpService.BillQueryForMaterial(); if (!materials_result.IsSuccess) @@ -100,6 +100,24 @@ namespace WMS.Web.Repositories mIds = materials.Where(w => EF.Functions.Like(w.MaterialNumber, "%" + dto.MaterialNumber + "%")).Select(s => s.MaterialId).ToList(); } + //取组织 + var org_result = await _erpService.BillQueryForOrg(); + if (!org_result.IsSuccess) + return (new List(), 0); + var orgs = org_result.Data.ToList(); + + List cIds = new List(); + var customer_result = await _erpService.BillQueryForCustomer(); + if (!customer_result.IsSuccess) + return (new List(), 0); + var customers = customer_result.Data.ToList(); + //物料集合;模糊查询后的物料集合 + if (!string.IsNullOrEmpty(dto.ReceiptCustomer)) + { + cIds = customers.Where(w => EF.Functions.Like(w.Name, "%" + dto.ReceiptCustomer + "%")).Select(s => s.MaterialId).ToList(); + } + #endregion + var query = _context.OutStockDetails .GroupJoin(_context.OutStock, detail => detail.Fid, order => order.Id, (detail, orders) => new { detail, orders }) .SelectMany(x => x.orders.DefaultIfEmpty(), (p, order) => new { p.detail, order }) @@ -139,8 +157,10 @@ namespace WMS.Web.Repositories Stock = _singleDataService.GetSingleData(SingleAction.Stocks, _loginRepositories.CompanyId, s.detail.StockId), SourceBillNo = s.order.SourceBillNo, SaleBillNo = s.detail.SaleBillNo, - DeliveryOrg = "", - ReceiptCustomer = "", + DeliveryOrg = _erpBasicDataExtendService.GetOrgName(orgs, s.order.DeliveryOrgId), + ReceiptCustomer = s.order.Type == OutStockType.Sal + ? _erpBasicDataExtendService.GetCustomerName(customers, s.order.ReceiptCustomerId) + : _erpBasicDataExtendService.GetOrgName(orgs, s.order.DeliveryOrgId), MaterialName = _erpBasicDataExtendService.GetMaterialName(materials, s.detail.MaterialId), MaterialNumber = _erpBasicDataExtendService.GetMaterialNumber(materials, s.detail.MaterialId), Specifications = _erpBasicDataExtendService.GetMaterialSpecifications(materials, s.detail.MaterialId), diff --git a/src/WMS.Web.Repositories/OutStockTaskRepositories.cs b/src/WMS.Web.Repositories/OutStockTaskRepositories.cs index 6d9c5fd7..2d2dae1f 100644 --- a/src/WMS.Web.Repositories/OutStockTaskRepositories.cs +++ b/src/WMS.Web.Repositories/OutStockTaskRepositories.cs @@ -214,6 +214,7 @@ namespace WMS.Web.Repositories /// public async Task<(List list, int total)> GetListAsync(OutStockTaskQueryRequest dto) { + #region erp基础资料 List mIds = new List(); var materials_result = await _erpService.BillQueryForMaterial(); if (!materials_result.IsSuccess) @@ -224,14 +225,34 @@ namespace WMS.Web.Repositories { mIds = materials.Where(w => EF.Functions.Like(w.MaterialNumber, "%" + dto.MaterialNumber + "%")).Select(s => s.MaterialId).ToList(); } + + //取组织 + var org_result = await _erpService.BillQueryForOrg(); + if (!org_result.IsSuccess) + return (new List(), 0); + var orgs = org_result.Data.ToList(); + + List cIds = new List(); + var customer_result = await _erpService.BillQueryForCustomer(); + if (!customer_result.IsSuccess) + return (new List(), 0); + var customers = customer_result.Data.ToList(); + //物料集合;模糊查询后的物料集合 + if (!string.IsNullOrEmpty(dto.ReceiptCustomer)) + { + cIds = customers.Where(w => EF.Functions.Like(w.Name, "%" + dto.ReceiptCustomer + "%")).Select(s => s.MaterialId).ToList(); + } + #endregion + var query = _context.OutStockTaskDetails .GroupJoin(_context.OutStockTask, detail => detail.Fid, order => order.Id, (detail, orders) => new { detail, orders }) .SelectMany(x => x.orders.DefaultIfEmpty(), (p, order) => new { p.detail, order }) .OrderByDescending(o => o.order.Id) .Where(adv => 1 == 1); - //if (!string.IsNullOrEmpty(dto.ReceiptCustomer)) - if (mIds.Count()!=0) + if (cIds.Count() != 0) + query = query.Where(w => cIds.Contains(w.order.ReceiptCustomerId)); + if (mIds.Count() != 0) query = query.Where(w => mIds.Contains(w.detail.MaterialId)); if (dto.Ids.Count() > 0) query = query.Where(w => dto.Ids.Contains(w.detail.Id)); @@ -255,18 +276,20 @@ namespace WMS.Web.Repositories { #region dto组装 Id = s.order.Id, - DetailId=s.detail.Id, - BillNo =s.order.BillNo, + DetailId = s.detail.Id, + BillNo = s.order.BillNo, Status = s.order.Status.GetRemark(), Type = s.order.Type.GetRemark(), CreateTime = s.order.OperateTime.DateToStringSeconds(), - OutStockBeginTime= s.detail.OutStockBeginTime.DateToStringSeconds(), + OutStockBeginTime = s.detail.OutStockBeginTime.DateToStringSeconds(), OutStockEndTime = s.detail.OutStockEndTime.DateToStringSeconds(), Stock = _singleDataService.GetSingleData(SingleAction.Stocks, _loginRepositories.CompanyId, s.detail.StockId), SourceBillNo = s.order.SourceBillNo, SaleBillNo = s.detail.SaleBillNo, - DeliveryOrg = "", - ReceiptCustomer = "", + DeliveryOrg = _erpBasicDataExtendService.GetOrgName(orgs, s.order.DeliveryOrgId), + ReceiptCustomer = s.order.Type == OutStockType.Sal + ? _erpBasicDataExtendService.GetCustomerName(customers, s.order.ReceiptCustomerId) + : _erpBasicDataExtendService.GetOrgName(orgs, s.order.DeliveryOrgId), MaterialName = _erpBasicDataExtendService.GetMaterialName(materials, s.detail.MaterialId), MaterialNumber = _erpBasicDataExtendService.GetMaterialNumber(materials, s.detail.MaterialId), Specifications = _erpBasicDataExtendService.GetMaterialSpecifications(materials, s.detail.MaterialId), From 87f914dcdb2568ff61eb07358ba5c2d7e5824c6f Mon Sep 17 00:00:00 2001 From: 18942506660 <18942506660@A18942506660> Date: Thu, 9 Nov 2023 10:25:59 +0800 Subject: [PATCH 2/9] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=87=BA=E5=BA=93?= =?UTF-8?q?=E5=8D=95=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/SysConfigController.cs | 37 ++++++ src/WMS.Web.Api/wwwroot/WMS.Web.Api.xml | 6 + src/WMS.Web.Api/wwwroot/WMS.Web.Core.xml | 59 +++++++-- src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml | 116 +++++++++++++++++- .../Dto/Erp/PullDownStrResponse.cs | 25 ++++ src/WMS.Web.Domain/Entitys/OutStock.cs | 8 +- .../Services/OutStockService.cs | 2 +- .../OutStockRepositories.cs | 16 ++- .../OutStockTaskRepositories.cs | 15 ++- 9 files changed, 263 insertions(+), 21 deletions(-) create mode 100644 src/WMS.Web.Core/Dto/Erp/PullDownStrResponse.cs diff --git a/src/WMS.Web.Api/Controllers/SysConfigController.cs b/src/WMS.Web.Api/Controllers/SysConfigController.cs index 47b1e9d1..ea665c6a 100644 --- a/src/WMS.Web.Api/Controllers/SysConfigController.cs +++ b/src/WMS.Web.Api/Controllers/SysConfigController.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Threading.Tasks; using WMS.Web.Core; using WMS.Web.Core.Dto; +using WMS.Web.Core.Dto.Erp; using WMS.Web.Core.Dto.SingleData; using WMS.Web.Core.Internal.Results; using WMS.Web.Domain.Infrastructure; @@ -148,6 +149,42 @@ namespace WMS.Web.Api.Controllers return Result>.ReSuccess(list); } + /// + /// 获取出库单客户下拉列表 + /// + /// + [HttpGet] + [Route("GetCustomers")] + public async Task>> GetCustomers() + { + var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]); + if (loginInfo == null || loginInfo.UserInfo == null) + return Result>.ReFailure(ResultCodes.Token_Invalid_Error); + var customers = await _erpService.BillQueryForCustomer(); + var orgs = await _erpService.BillQueryForOrg(); + List pullList = new List(); + foreach (var c in customers.Data) + { + pullList.Add(new PullDownStrResponse() + { + Id = "c_" + c.Id, + Name = c.Name, + Code = c.Number + }); + } + foreach (var o in orgs.Data) + { + pullList.Add(new PullDownStrResponse() + { + Id = "o_" + o.Id, + Name = o.Name, + Code = o.Number + }); + } + + return Result>.ReSuccess(pullList); + } + /// /// 获取仓位:模糊名称 /// diff --git a/src/WMS.Web.Api/wwwroot/WMS.Web.Api.xml b/src/WMS.Web.Api/wwwroot/WMS.Web.Api.xml index 7756dacf..cb12ba2a 100644 --- a/src/WMS.Web.Api/wwwroot/WMS.Web.Api.xml +++ b/src/WMS.Web.Api/wwwroot/WMS.Web.Api.xml @@ -290,6 +290,12 @@ 仓库id + + + 获取出库单客户下拉列表 + + + 获取仓位:模糊名称 diff --git a/src/WMS.Web.Api/wwwroot/WMS.Web.Core.xml b/src/WMS.Web.Api/wwwroot/WMS.Web.Core.xml index c7466844..1ed35a82 100644 --- a/src/WMS.Web.Api/wwwroot/WMS.Web.Core.xml +++ b/src/WMS.Web.Api/wwwroot/WMS.Web.Core.xml @@ -465,6 +465,26 @@ 单据类型 + + + 客户 + + + + + ID + + + + + 编码 + + + + + 名称 + + ERP:单据查询-dto @@ -775,6 +795,26 @@ 含税单价 取对应发货通知单对应物料编码行的 含税单价 + + + key为string 下拉列表对象 + + + + + id + + + + + 编码 + + + + + 名字 + + erp-采购入库-返回数据源 @@ -1572,7 +1612,7 @@ - 仓库ID + 仓库编码 @@ -2350,12 +2390,7 @@ 完成装箱时间 - - - 箱子的创建时间 - - - + 箱子创建用户 @@ -2365,7 +2400,7 @@ 创建时间(对应老OPS的创建时间) - + 明细 @@ -2375,14 +2410,14 @@ 序列号 - + - 条码生成时间 + 序列号生成时间 - + - 条码生成用户 + 序列号生成用户 diff --git a/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml b/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml index 30a6bd65..8de1a8a6 100644 --- a/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml +++ b/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml @@ -110,6 +110,16 @@ 组织Id + + + 完成装箱时间 + + + + + 箱子创建用户 + + 创建时间(对应老OPS的创建时间) @@ -741,7 +751,7 @@ 明细 - + 创建 @@ -938,6 +948,56 @@ 出库结束时间 + + + 序列号操作记录表 + + + + + ID + + + + + 序列号 + + + + + 序列号操作类型 + + + + + 供应商Id + + + + + 组织Id + + + + + 仓库Id + + + + + 操作时间 + + + + + 操作人 + + + + + 备注 + + wms盘点单 @@ -1393,6 +1453,14 @@ 删除实体集合 + + + 批量添加 + + + + + 批量添加 @@ -1570,6 +1638,14 @@ + + + 获取客户名称 + + + + + 获取仓库名称 @@ -1654,6 +1730,12 @@ + + + 客户 + + + 获取仓库信息 @@ -2199,6 +2281,14 @@ 箱服务信息 + + + 序列号操作记录日志 + + + + + 改箱 移箱服务 @@ -2440,6 +2530,14 @@ + + + 获取客户名称 + + + + + 获取仓库名称 @@ -2499,6 +2597,12 @@ + + + 客户 + + + erp:仓库 @@ -3039,6 +3143,11 @@ 分布式调出单 + + + 客户 + + 入库状态 @@ -3259,6 +3368,11 @@ 数据操作失败 + + + 序列号操作类型 + + 对接单点的接口方法-枚举 diff --git a/src/WMS.Web.Core/Dto/Erp/PullDownStrResponse.cs b/src/WMS.Web.Core/Dto/Erp/PullDownStrResponse.cs new file mode 100644 index 00000000..2965f375 --- /dev/null +++ b/src/WMS.Web.Core/Dto/Erp/PullDownStrResponse.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace WMS.Web.Core.Dto.Erp +{ + /// + /// key为string 下拉列表对象 + /// + public class PullDownStrResponse + { + /// + /// id + /// + public string Id { get; set; } + /// + /// 编码 + /// + public string Code { get; set; } + /// + /// 名字 + /// + public string Name { get; set; } + } +} diff --git a/src/WMS.Web.Domain/Entitys/OutStock.cs b/src/WMS.Web.Domain/Entitys/OutStock.cs index 20e5cde5..e9a7d6ef 100644 --- a/src/WMS.Web.Domain/Entitys/OutStock.cs +++ b/src/WMS.Web.Domain/Entitys/OutStock.cs @@ -73,10 +73,12 @@ namespace WMS.Web.Domain.Entitys /// 创建 /// /// - public void Create(int creatorId,int taskId, OutStockType type) + public void Create(int creatorId, OutStockTask task) { - this.TaskId = taskId; - this.Type = type; + this.TaskId = task.Id; + this.Type = task.Type; + this.DeliveryOrgId = task.DeliveryOrgId; + this.ReceiptCustomerId = task.ReceiptCustomerId; this.CreatorId = creatorId; this.CreateTime = DateTime.Now; } diff --git a/src/WMS.Web.Domain/Services/OutStockService.cs b/src/WMS.Web.Domain/Services/OutStockService.cs index 3962eccc..2a23e59b 100644 --- a/src/WMS.Web.Domain/Services/OutStockService.cs +++ b/src/WMS.Web.Domain/Services/OutStockService.cs @@ -50,7 +50,7 @@ namespace WMS.Web.Domain.Services //OutStock entity = await _outStockRepositories.GetByTaskId(dto.TaskId); OutStock entity = new OutStock(); - entity.Create(loginInfo.UserInfo.StaffId, outStockTask.Id, outStockTask.Type); + entity.Create(loginInfo.UserInfo.StaffId, outStockTask); foreach (var d in dto.Details) { //任务单明细 diff --git a/src/WMS.Web.Repositories/OutStockRepositories.cs b/src/WMS.Web.Repositories/OutStockRepositories.cs index 4b422fae..a31fa873 100644 --- a/src/WMS.Web.Repositories/OutStockRepositories.cs +++ b/src/WMS.Web.Repositories/OutStockRepositories.cs @@ -114,7 +114,12 @@ namespace WMS.Web.Repositories //物料集合;模糊查询后的物料集合 if (!string.IsNullOrEmpty(dto.ReceiptCustomer)) { - cIds = customers.Where(w => EF.Functions.Like(w.Name, "%" + dto.ReceiptCustomer + "%")).Select(s => s.MaterialId).ToList(); + var q = dto.ReceiptCustomer.Substring(0, 1); + var h = dto.ReceiptCustomer.Substring(2, dto.ReceiptCustomer.Length - 1); + if (q.Equals("c")) + cIds = customers.Where(w => EF.Functions.Like(w.Name, "%" + dto.ReceiptCustomer + "%")).Select(s => s.Id).ToList(); + else + cIds = orgs.Where(w => EF.Functions.Like(w.Name, "%" + dto.ReceiptCustomer + "%")).Select(s => s.Id).ToList(); } #endregion @@ -124,7 +129,14 @@ namespace WMS.Web.Repositories .OrderByDescending(o => o.order.Id) .Where(adv => 1 == 1); - //if (!string.IsNullOrEmpty(dto.ReceiptCustomer)) + if (cIds.Count() != 0) + { + var q = dto.ReceiptCustomer.Substring(0, 1); + if (q.Equals("c"))//差销售出库单(客户) + query = query.Where(w => cIds.Contains(w.order.ReceiptCustomerId) && w.order.Type == OutStockType.Sal); + else//查其他单据(组织) + query = query.Where(w => cIds.Contains(w.order.ReceiptCustomerId) && w.order.Type != OutStockType.Sal); + } if (mIds.Count() != 0) query = query.Where(w => mIds.Contains(w.detail.MaterialId)); if (ids.Count() > 0) diff --git a/src/WMS.Web.Repositories/OutStockTaskRepositories.cs b/src/WMS.Web.Repositories/OutStockTaskRepositories.cs index 2d2dae1f..aaec8a5f 100644 --- a/src/WMS.Web.Repositories/OutStockTaskRepositories.cs +++ b/src/WMS.Web.Repositories/OutStockTaskRepositories.cs @@ -240,7 +240,12 @@ namespace WMS.Web.Repositories //物料集合;模糊查询后的物料集合 if (!string.IsNullOrEmpty(dto.ReceiptCustomer)) { - cIds = customers.Where(w => EF.Functions.Like(w.Name, "%" + dto.ReceiptCustomer + "%")).Select(s => s.MaterialId).ToList(); + var q = dto.ReceiptCustomer.Substring(0, 1); + var h = dto.ReceiptCustomer.Substring(2, dto.ReceiptCustomer.Length - 1); + if (q.Equals("c")) + cIds = customers.Where(w => EF.Functions.Like(w.Name, "%" + dto.ReceiptCustomer + "%")).Select(s => s.Id).ToList(); + else + cIds = orgs.Where(w => EF.Functions.Like(w.Name, "%" + dto.ReceiptCustomer + "%")).Select(s => s.Id).ToList(); } #endregion @@ -251,7 +256,13 @@ namespace WMS.Web.Repositories .Where(adv => 1 == 1); if (cIds.Count() != 0) - query = query.Where(w => cIds.Contains(w.order.ReceiptCustomerId)); + { + var q = dto.ReceiptCustomer.Substring(0, 1); + if (q.Equals("c"))//差销售出库单(客户) + query = query.Where(w => cIds.Contains(w.order.ReceiptCustomerId) && w.order.Type == OutStockType.Sal); + else//查其他单据(组织) + query = query.Where(w => cIds.Contains(w.order.ReceiptCustomerId) && w.order.Type != OutStockType.Sal); + } if (mIds.Count() != 0) query = query.Where(w => mIds.Contains(w.detail.MaterialId)); if (dto.Ids.Count() > 0) From 3687bbb7d1232565b410a8206cb6f987226c6771 Mon Sep 17 00:00:00 2001 From: 18942506660 <18942506660@A18942506660> Date: Thu, 9 Nov 2023 10:32:09 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E8=B0=83=E6=95=B4bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../OutStockRepositories.cs | 25 +++++++------------ .../OutStockTaskRepositories.cs | 25 +++++++------------ 2 files changed, 18 insertions(+), 32 deletions(-) diff --git a/src/WMS.Web.Repositories/OutStockRepositories.cs b/src/WMS.Web.Repositories/OutStockRepositories.cs index a31fa873..9cb83af9 100644 --- a/src/WMS.Web.Repositories/OutStockRepositories.cs +++ b/src/WMS.Web.Repositories/OutStockRepositories.cs @@ -106,21 +106,12 @@ namespace WMS.Web.Repositories return (new List(), 0); var orgs = org_result.Data.ToList(); - List cIds = new List(); + //取客户 var customer_result = await _erpService.BillQueryForCustomer(); if (!customer_result.IsSuccess) return (new List(), 0); var customers = customer_result.Data.ToList(); - //物料集合;模糊查询后的物料集合 - if (!string.IsNullOrEmpty(dto.ReceiptCustomer)) - { - var q = dto.ReceiptCustomer.Substring(0, 1); - var h = dto.ReceiptCustomer.Substring(2, dto.ReceiptCustomer.Length - 1); - if (q.Equals("c")) - cIds = customers.Where(w => EF.Functions.Like(w.Name, "%" + dto.ReceiptCustomer + "%")).Select(s => s.Id).ToList(); - else - cIds = orgs.Where(w => EF.Functions.Like(w.Name, "%" + dto.ReceiptCustomer + "%")).Select(s => s.Id).ToList(); - } + #endregion var query = _context.OutStockDetails @@ -129,13 +120,15 @@ namespace WMS.Web.Repositories .OrderByDescending(o => o.order.Id) .Where(adv => 1 == 1); - if (cIds.Count() != 0) + if (!string.IsNullOrEmpty(dto.ReceiptCustomer)) { - var q = dto.ReceiptCustomer.Substring(0, 1); - if (q.Equals("c"))//差销售出库单(客户) - query = query.Where(w => cIds.Contains(w.order.ReceiptCustomerId) && w.order.Type == OutStockType.Sal); + var rec_type = dto.ReceiptCustomer.Substring(0, 1); + var rec_id = Convert.ToInt32(dto.ReceiptCustomer.Substring(2, dto.ReceiptCustomer.Length - 1)); + + if (rec_type.Equals("c"))//差销售出库单(客户) + query = query.Where(w => rec_id == w.order.ReceiptCustomerId && w.order.Type == OutStockType.Sal); else//查其他单据(组织) - query = query.Where(w => cIds.Contains(w.order.ReceiptCustomerId) && w.order.Type != OutStockType.Sal); + query = query.Where(w => rec_id == w.order.ReceiptCustomerId && w.order.Type != OutStockType.Sal); } if (mIds.Count() != 0) query = query.Where(w => mIds.Contains(w.detail.MaterialId)); diff --git a/src/WMS.Web.Repositories/OutStockTaskRepositories.cs b/src/WMS.Web.Repositories/OutStockTaskRepositories.cs index aaec8a5f..a9439152 100644 --- a/src/WMS.Web.Repositories/OutStockTaskRepositories.cs +++ b/src/WMS.Web.Repositories/OutStockTaskRepositories.cs @@ -232,21 +232,12 @@ namespace WMS.Web.Repositories return (new List(), 0); var orgs = org_result.Data.ToList(); - List cIds = new List(); + //取客户 var customer_result = await _erpService.BillQueryForCustomer(); if (!customer_result.IsSuccess) return (new List(), 0); var customers = customer_result.Data.ToList(); - //物料集合;模糊查询后的物料集合 - if (!string.IsNullOrEmpty(dto.ReceiptCustomer)) - { - var q = dto.ReceiptCustomer.Substring(0, 1); - var h = dto.ReceiptCustomer.Substring(2, dto.ReceiptCustomer.Length - 1); - if (q.Equals("c")) - cIds = customers.Where(w => EF.Functions.Like(w.Name, "%" + dto.ReceiptCustomer + "%")).Select(s => s.Id).ToList(); - else - cIds = orgs.Where(w => EF.Functions.Like(w.Name, "%" + dto.ReceiptCustomer + "%")).Select(s => s.Id).ToList(); - } + #endregion var query = _context.OutStockTaskDetails @@ -255,13 +246,15 @@ namespace WMS.Web.Repositories .OrderByDescending(o => o.order.Id) .Where(adv => 1 == 1); - if (cIds.Count() != 0) + if (!string.IsNullOrEmpty(dto.ReceiptCustomer)) { - var q = dto.ReceiptCustomer.Substring(0, 1); - if (q.Equals("c"))//差销售出库单(客户) - query = query.Where(w => cIds.Contains(w.order.ReceiptCustomerId) && w.order.Type == OutStockType.Sal); + var rec_type = dto.ReceiptCustomer.Substring(0, 1); + var rec_id = Convert.ToInt32(dto.ReceiptCustomer.Substring(2, dto.ReceiptCustomer.Length - 1)); + + if (rec_type.Equals("c"))//差销售出库单(客户) + query = query.Where(w => rec_id == w.order.ReceiptCustomerId && w.order.Type == OutStockType.Sal); else//查其他单据(组织) - query = query.Where(w => cIds.Contains(w.order.ReceiptCustomerId) && w.order.Type != OutStockType.Sal); + query = query.Where(w => rec_id == w.order.ReceiptCustomerId && w.order.Type != OutStockType.Sal); } if (mIds.Count() != 0) query = query.Where(w => mIds.Contains(w.detail.MaterialId)); From bb77363dada56af383cc6ce82af9c3358be989ef Mon Sep 17 00:00:00 2001 From: 18942506660 <18942506660@A18942506660> Date: Thu, 9 Nov 2023 11:14:40 +0800 Subject: [PATCH 4/9] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml | 18 +++- .../IService/Public/IOutStockTaskService.cs | 8 +- .../QuartzJob/OutStockOrderQuartzJob.cs | 21 +--- .../Services/OutStockService.cs | 11 ++- .../Services/OutStockTaskService.cs | 98 ++++++++++++++++++- 5 files changed, 130 insertions(+), 26 deletions(-) diff --git a/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml b/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml index 8de1a8a6..ee88f33b 100644 --- a/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml +++ b/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml @@ -1823,7 +1823,7 @@ 出库任务 - + 采购发货通知单 @@ -1854,6 +1854,13 @@ + + + 同步金蝶数据 不传源订单号则更新所有 + + + + 单点数据返回服务接口 @@ -2438,7 +2445,7 @@ - + 发货通知单同步数据 @@ -2477,6 +2484,13 @@ + + + 同步金蝶数据 不传源订单号则更新所有 + + + + erp基础数据:扩展服务 diff --git a/src/WMS.Web.Domain/IService/Public/IOutStockTaskService.cs b/src/WMS.Web.Domain/IService/Public/IOutStockTaskService.cs index 4df6006e..14efef7a 100644 --- a/src/WMS.Web.Domain/IService/Public/IOutStockTaskService.cs +++ b/src/WMS.Web.Domain/IService/Public/IOutStockTaskService.cs @@ -19,7 +19,7 @@ namespace WMS.Web.Domain.IService.Public /// /// /// - Task SsynDeliveryNoticeOutStock(bool isTransaction,List sourceBillNos = null); + Task BillQueryForDeliveryNoticeOutStock(bool isTransaction,List sourceBillNos = null); /// /// erp:单据查询-直接调拨出库 /// @@ -44,5 +44,11 @@ namespace WMS.Web.Domain.IService.Public Task Repeal(OperateRequest dto, LoginInDto loginInfo); //出库任务作废 Task merge(OperateRequest dto, LoginInDto loginInfo); + /// + /// 同步金蝶数据 不传源订单号则更新所有 + /// + /// + /// + Task Ssyn(List sourceBillNos = null); } } diff --git a/src/WMS.Web.Domain/QuartzJob/OutStockOrderQuartzJob.cs b/src/WMS.Web.Domain/QuartzJob/OutStockOrderQuartzJob.cs index a8f6a448..d2cec87c 100644 --- a/src/WMS.Web.Domain/QuartzJob/OutStockOrderQuartzJob.cs +++ b/src/WMS.Web.Domain/QuartzJob/OutStockOrderQuartzJob.cs @@ -14,7 +14,7 @@ using WMS.Web.Domain.Options; namespace WMS.Web.Domain.QuartzJob { - public class OutStockOrderQuartzJob : IJob + public class OutStockOrderQuartzJob : IJob { private readonly ILogger _logger; private readonly IServiceScopeFactory _serviceScopeFactory; @@ -44,28 +44,11 @@ namespace WMS.Web.Domain.QuartzJob { try { - //1.事务 - IDbContextTransaction _transaction = _transactionRepositories.GetTransaction(); - bool isRollback = false; - bool isTransaction = false; //2.记录:开始时间 var begindatetime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); _logger.LogInformation($"出库单-同步金蝶入库单数据:执行开始时间->{begindatetime}"); //3.同步数据 - var result = await _outStockTaskService.SsynDeliveryNoticeOutStock(isTransaction); - if (!result.IsSuccess) isRollback = true; - result = await _outStockTaskService.BillQueryForTransferDirectOutStock(isTransaction); - if (!result.IsSuccess) isRollback = true; - result = await _outStockTaskService.BillQueryForTransferOutOutStock(isTransaction); - if (!result.IsSuccess) isRollback = true; - result = await _outStockTaskService.BillQueryForMisDeliveryOutStock(isTransaction); - if (!result.IsSuccess) isRollback = true; - result = await _outStockTaskService.BillQueryForAssembledAppOutStock(isTransaction); - if (!result.IsSuccess) isRollback = true; - - //4.提交事务 - var isSuccess = _transactionRepositories.CommitTransaction(isRollback, _transaction); - + var result = await _outStockTaskService.Ssyn(null); //5.记录:结束时间 var enddatetime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); _logger.LogInformation($"出库单-同步金蝶入库单数据:执行结束时间->{begindatetime}"); diff --git a/src/WMS.Web.Domain/Services/OutStockService.cs b/src/WMS.Web.Domain/Services/OutStockService.cs index 2a23e59b..18ac6157 100644 --- a/src/WMS.Web.Domain/Services/OutStockService.cs +++ b/src/WMS.Web.Domain/Services/OutStockService.cs @@ -28,15 +28,17 @@ namespace WMS.Web.Domain.Services public readonly IBasicsRepositories _transactionRepositories; private readonly IOutStockRepositories _outStockRepositories; private readonly IOutStockTaskRepositories _outStockTaskRepositories; + private readonly IOutStockTaskService _outStockTaskService; public OutStockService(IMapper mapper, ILoginService loginService, IBasicsRepositories transactionRepositories, - IOutStockRepositories outStockRepositories, IOutStockTaskRepositories outStockTaskRepositories) + IOutStockRepositories outStockRepositories, IOutStockTaskRepositories outStockTaskRepositories, IOutStockTaskService outStockTaskService) { _mapper = mapper; _loginService = loginService; _transactionRepositories = transactionRepositories; _outStockRepositories = outStockRepositories; _outStockTaskRepositories = outStockTaskRepositories; + _outStockTaskService = outStockTaskService; } /// /// 出库单 @@ -48,6 +50,11 @@ namespace WMS.Web.Domain.Services { var outStockTask = await _outStockTaskRepositories.Get(dto.TaskId); //OutStock entity = await _outStockRepositories.GetByTaskId(dto.TaskId); + //同步该订单最新数据到wms系统 + List nos = new List(); + nos.Add(outStockTask.SourceBillNo); + var res = await _outStockTaskService.Ssyn(nos); + if (!res.IsSuccess) return Result.ReSuccess(); OutStock entity = new OutStock(); entity.Create(loginInfo.UserInfo.StaffId, outStockTask); @@ -56,7 +63,7 @@ namespace WMS.Web.Domain.Services //任务单明细 var tDetail = outStockTask.Details.FirstOrDefault(f => f.MaterialId == d.MaterialId); if (tDetail == null) continue; - var res = outStockTask.OutStock(d.MaterialId, d.Qty); + res = outStockTask.OutStock(d.MaterialId, d.Qty); if (!res.IsSuccess) return res; var outd = _mapper.Map(tDetail); diff --git a/src/WMS.Web.Domain/Services/OutStockTaskService.cs b/src/WMS.Web.Domain/Services/OutStockTaskService.cs index cf232675..9f67e015 100644 --- a/src/WMS.Web.Domain/Services/OutStockTaskService.cs +++ b/src/WMS.Web.Domain/Services/OutStockTaskService.cs @@ -158,7 +158,7 @@ namespace WMS.Web.Domain.Services /// /// /// - public async Task SsynDeliveryNoticeOutStock(bool isTransaction, List sourceBillNos = null) + public async Task BillQueryForDeliveryNoticeOutStock(bool isTransaction, List sourceBillNos = null) { //1.获取金蝶数据:采购订单数据 var erp_result = await _erpService.BillQueryForDeliveryNoticeOutStock(sourceBillNos); @@ -204,7 +204,7 @@ namespace WMS.Web.Domain.Services public async Task BillQueryForAssembledAppOutStock(bool isTransaction, List sourceBillNos = null) { List list = new List(); - + var erp_result = await _erpService.BillQueryForAssembledAppOutStock_Dassembly(sourceBillNos); if (!erp_result.IsSuccess) return Result.ReFailure(erp_result.Message, erp_result.Status); @@ -231,5 +231,99 @@ namespace WMS.Web.Domain.Services return await this.SsynDate(erp_result.Data.ToList(), isTransaction); } + /// + /// 同步金蝶数据 不传源订单号则更新所有 + /// + /// + /// + public async Task Ssyn(List sourceBillNos = null) + { + //1.事务 + IDbContextTransaction _transaction = _transactionRepositories.GetTransaction(); + bool isRollback = false; + bool isSuccess = true; + Result result; + //定时任务更新 + if (sourceBillNos == null) + { + + //更新时间范围内所有 + result= await BillQueryForDeliveryNoticeOutStock(false, null); + if (!result.IsSuccess) isRollback = true; + result = await BillQueryForTransferDirectOutStock(false, null); + if (!result.IsSuccess) isRollback = true; + result = await BillQueryForTransferOutOutStock(false, null); + if (!result.IsSuccess) isRollback = true; + result = await BillQueryForAssembledAppOutStock(false, null); + if (!result.IsSuccess) isRollback = true; + result = await BillQueryForMisDeliveryOutStock(false, null); + if (!result.IsSuccess) isRollback = true; + + //同步成功后 更新定时开始时间 + if (!isRollback) + { + } + + //4.提交事务 + isSuccess = _transactionRepositories.CommitTransaction(isRollback, _transaction); + if (!isSuccess) + return Result.ReFailure(ResultCodes.DateWriteError); + + return Result.ReSuccess(); + } + + //根据指定单号更新 + List DeliveryNotice_Nos = new List(); + List TransferDirect_Nos = new List(); + List TransferOut_Nos = new List(); + List AssembledApp_Nos = new List(); + List MisDeliveryOut_Nos = new List(); + var taskList = await _outStockTaskRepositories.GetListBySourceBillNo(sourceBillNos); + foreach (var entity in taskList) + { + if (entity.Type == OutStockType.Sal) + DeliveryNotice_Nos.Add(entity.SourceBillNo); + else if (entity.Type == OutStockType.Stkdirecttransfers) + TransferDirect_Nos.Add(entity.SourceBillNo); + else if (entity.Type == OutStockType.StktransferInst) + TransferOut_Nos.Add(entity.SourceBillNo); + else if (entity.Type == OutStockType.Assembled) + AssembledApp_Nos.Add(entity.SourceBillNo); + else if (entity.Type == OutStockType.Miscellaneous) + MisDeliveryOut_Nos.Add(entity.SourceBillNo); + } + + if (DeliveryNotice_Nos.Count() > 0) + { + result= await BillQueryForDeliveryNoticeOutStock(false, DeliveryNotice_Nos); + if (!result.IsSuccess) isRollback = true; + } + if (TransferDirect_Nos.Count() > 0) + { + result = await BillQueryForDeliveryNoticeOutStock(false, TransferDirect_Nos); + if (!result.IsSuccess) isRollback = true; + } + if (TransferOut_Nos.Count() > 0) + { + result = await BillQueryForDeliveryNoticeOutStock(false, TransferOut_Nos); + if (!result.IsSuccess) isRollback = true; + } + if (AssembledApp_Nos.Count() > 0) + { + result = await BillQueryForDeliveryNoticeOutStock(false, AssembledApp_Nos); + if (!result.IsSuccess) isRollback = true; + } + if (MisDeliveryOut_Nos.Count() > 0) + { + result = await BillQueryForDeliveryNoticeOutStock(false, MisDeliveryOut_Nos); + if (!result.IsSuccess) isRollback = true; + } + + //4.提交事务 + isSuccess = _transactionRepositories.CommitTransaction(isRollback, _transaction); + if (!isSuccess) + return Result.ReFailure(ResultCodes.DateWriteError); + return Result.ReSuccess(); + } } } From 5a0388ce093e5b3286f95449dbf251432b54f7d7 Mon Sep 17 00:00:00 2001 From: 18942506660 <18942506660@A18942506660> Date: Thu, 9 Nov 2023 11:24:29 +0800 Subject: [PATCH 5/9] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=AD=90=E4=BB=93?= =?UTF-8?q?=E5=BA=93=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/WMS.Web.Api/Controllers/SysConfigController.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/WMS.Web.Api/Controllers/SysConfigController.cs b/src/WMS.Web.Api/Controllers/SysConfigController.cs index ea665c6a..54996575 100644 --- a/src/WMS.Web.Api/Controllers/SysConfigController.cs +++ b/src/WMS.Web.Api/Controllers/SysConfigController.cs @@ -1,5 +1,6 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; using Newtonsoft.Json; using System; using System.Collections.Generic; @@ -121,10 +122,11 @@ namespace WMS.Web.Api.Controllers /// 根据仓库获取金蝶子仓库 /// /// 仓库id + /// 模糊匹配 /// [HttpGet] [Route("GetErp_SubUcStock/{id}")] - public async Task>> GetErp_SubUcStock([FromRoute] int id) + public async Task>> GetErp_SubUcStock([FromRoute] int id, [FromQuery] string name) { var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]); if (loginInfo == null || loginInfo.UserInfo == null) @@ -135,7 +137,7 @@ namespace WMS.Web.Api.Controllers if (code.Substring(0, 2).Equals("HD") || code.Substring(0, 2).Equals("GD")) { var subs = await _erpService.BillQueryForSubStock(code); - foreach (var s in subs.Data) + foreach (var s in subs.Data.Where(w=> EF.Functions.Like(w.Name, "%" + name + "%"))) { list.Add(new UcStockResponse() { From f6d82bc1dfa985b3d874f9c318853b6985d19f86 Mon Sep 17 00:00:00 2001 From: 18942506660 <18942506660@A18942506660> Date: Thu, 9 Nov 2023 11:31:36 +0800 Subject: [PATCH 6/9] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/WMS.Web.Api/wwwroot/WMS.Web.Api.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/WMS.Web.Api/wwwroot/WMS.Web.Api.xml b/src/WMS.Web.Api/wwwroot/WMS.Web.Api.xml index cb12ba2a..0b8c7f74 100644 --- a/src/WMS.Web.Api/wwwroot/WMS.Web.Api.xml +++ b/src/WMS.Web.Api/wwwroot/WMS.Web.Api.xml @@ -283,11 +283,12 @@ 仓库id - + 根据仓库获取金蝶子仓库 仓库id + 模糊匹配 From 0c605f61d515bfcbf2c2916a123639eff0ebdd70 Mon Sep 17 00:00:00 2001 From: 18942506660 <18942506660@A18942506660> Date: Thu, 9 Nov 2023 11:45:16 +0800 Subject: [PATCH 7/9] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/WMS.Web.Api/Controllers/SysConfigController.cs | 11 +++++------ src/WMS.Web.Api/wwwroot/WMS.Web.Api.xml | 4 ++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/WMS.Web.Api/Controllers/SysConfigController.cs b/src/WMS.Web.Api/Controllers/SysConfigController.cs index 54996575..361b1d25 100644 --- a/src/WMS.Web.Api/Controllers/SysConfigController.cs +++ b/src/WMS.Web.Api/Controllers/SysConfigController.cs @@ -121,22 +121,21 @@ namespace WMS.Web.Api.Controllers /// /// 根据仓库获取金蝶子仓库 /// - /// 仓库id + /// 仓库id /// 模糊匹配 /// [HttpGet] - [Route("GetErp_SubUcStock/{id}")] - public async Task>> GetErp_SubUcStock([FromRoute] int id, [FromQuery] string name) + [Route("GetErp_SubUcStock/{number}")] + public async Task>> GetErp_SubUcStock([FromRoute] string number, [FromQuery] string name) { var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]); if (loginInfo == null || loginInfo.UserInfo == null) return Result>.ReFailure(ResultCodes.Token_Invalid_Error); List list = new List(); - var code = _singleDataService.GetSingleDataCode(SingleAction.Stocks, loginInfo.UserInfo.CompanyId, id); - if (code.Substring(0, 2).Equals("HD") || code.Substring(0, 2).Equals("GD")) + if (number.Substring(0, 2).Equals("HD") || number.Substring(0, 2).Equals("GD")) { - var subs = await _erpService.BillQueryForSubStock(code); + var subs = await _erpService.BillQueryForSubStock(number); foreach (var s in subs.Data.Where(w=> EF.Functions.Like(w.Name, "%" + name + "%"))) { list.Add(new UcStockResponse() diff --git a/src/WMS.Web.Api/wwwroot/WMS.Web.Api.xml b/src/WMS.Web.Api/wwwroot/WMS.Web.Api.xml index 0b8c7f74..152834a5 100644 --- a/src/WMS.Web.Api/wwwroot/WMS.Web.Api.xml +++ b/src/WMS.Web.Api/wwwroot/WMS.Web.Api.xml @@ -283,11 +283,11 @@ 仓库id - + 根据仓库获取金蝶子仓库 - 仓库id + 仓库id 模糊匹配 From 8ac80270cd1f15621b0702687e0a087889a4b0ef Mon Sep 17 00:00:00 2001 From: 18942506660 <18942506660@A18942506660> Date: Thu, 9 Nov 2023 11:59:36 +0800 Subject: [PATCH 8/9] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/WMS.Web.Api/Controllers/SysConfigController.cs | 2 +- src/WMS.Web.Api/wwwroot/WMS.Web.Api.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/WMS.Web.Api/Controllers/SysConfigController.cs b/src/WMS.Web.Api/Controllers/SysConfigController.cs index 361b1d25..fb4922d6 100644 --- a/src/WMS.Web.Api/Controllers/SysConfigController.cs +++ b/src/WMS.Web.Api/Controllers/SysConfigController.cs @@ -121,7 +121,7 @@ namespace WMS.Web.Api.Controllers /// /// 根据仓库获取金蝶子仓库 /// - /// 仓库id + /// 仓库编码 /// 模糊匹配 /// [HttpGet] diff --git a/src/WMS.Web.Api/wwwroot/WMS.Web.Api.xml b/src/WMS.Web.Api/wwwroot/WMS.Web.Api.xml index 152834a5..56c675f6 100644 --- a/src/WMS.Web.Api/wwwroot/WMS.Web.Api.xml +++ b/src/WMS.Web.Api/wwwroot/WMS.Web.Api.xml @@ -287,7 +287,7 @@ 根据仓库获取金蝶子仓库 - 仓库id + 仓库编码 模糊匹配 From 15f786ff466d8d860ab4415e2d58a0087f34fc82 Mon Sep 17 00:00:00 2001 From: 18942506660 <18942506660@A18942506660> Date: Thu, 9 Nov 2023 14:01:20 +0800 Subject: [PATCH 9/9] =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=A7=BB=E7=AE=B1?= =?UTF-8?q?=E6=94=B9=E7=AE=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SaveChangeBoxRecordRequest.cs | 1 - .../IService/IChangeMoveBoxService.cs | 2 +- .../Services/ChangeMoveBoxService.cs | 36 ++++++++++++------- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/WMS.Web.Core/Dto/ChangeBoxRecord/SaveChangeBoxRecordRequest.cs b/src/WMS.Web.Core/Dto/ChangeBoxRecord/SaveChangeBoxRecordRequest.cs index ef24724b..5f2ceb76 100644 --- a/src/WMS.Web.Core/Dto/ChangeBoxRecord/SaveChangeBoxRecordRequest.cs +++ b/src/WMS.Web.Core/Dto/ChangeBoxRecord/SaveChangeBoxRecordRequest.cs @@ -13,7 +13,6 @@ namespace WMS.Web.Core.Dto.ChangeBoxRecord /// /// 原箱子ID /// - [Required(ErrorMessage = "原箱子不能为空")] public int SrcBoxId { get; set; } /// /// 目标箱子ID diff --git a/src/WMS.Web.Domain/IService/IChangeMoveBoxService.cs b/src/WMS.Web.Domain/IService/IChangeMoveBoxService.cs index 68fb92ea..db52e99c 100644 --- a/src/WMS.Web.Domain/IService/IChangeMoveBoxService.cs +++ b/src/WMS.Web.Domain/IService/IChangeMoveBoxService.cs @@ -17,7 +17,7 @@ namespace WMS.Web.Domain.IService public interface IChangeMoveBoxService { //改箱保存 - Task ChangeBoxSave(SaveChangeBoxRecordRequest dto, LoginInDto loginInfo); + Task ChangeBoxSave(SaveChangeBoxRecordRequest dto, LoginInDto loginInfo, bool isTransaction=true); //移箱保存 Task MoveBoxSave(SaveMoveBoxRecordRequest dto, LoginInDto loginInfo); diff --git a/src/WMS.Web.Domain/Services/ChangeMoveBoxService.cs b/src/WMS.Web.Domain/Services/ChangeMoveBoxService.cs index a7f8b403..44fb65cb 100644 --- a/src/WMS.Web.Domain/Services/ChangeMoveBoxService.cs +++ b/src/WMS.Web.Domain/Services/ChangeMoveBoxService.cs @@ -43,23 +43,29 @@ namespace WMS.Web.Domain.Services /// /// /// - public async Task ChangeBoxSave(SaveChangeBoxRecordRequest dto, LoginInDto loginInfo) + public async Task ChangeBoxSave(SaveChangeBoxRecordRequest dto, LoginInDto loginInfo, bool isTransaction = false) { List boxList = new List(); + //原箱有可能没有 var srcBox = await _boxRepositories.Get(dto.SrcBoxId); var destBox = await _boxRepositories.Get(dto.DestBoxId); - if (srcBox == null) return Result.ReFailure(ResultCodes.BoxNoData); + //if (srcBox == null) return Result.ReFailure(ResultCodes.BoxNoData); if (destBox == null) return Result.ReFailure(ResultCodes.BoxNoData); var l = dto.Details.Select(s => (s.MaterialId, s.Qty, s.SerialNumbers)).ToList(); //原箱移出 - var res = srcBox.Out(l); - if (!res.IsSuccess) return res; + Result res; + if (srcBox != null) + { + res = srcBox.Out(l); + if (!res.IsSuccess) return res; + } //目标箱移入 res = destBox.In(l); if (!res.IsSuccess) return res; - - boxList.Add(srcBox); - boxList.Add(destBox); + if (srcBox != null) + boxList.Add(srcBox); + if (destBox != null) + boxList.Add(destBox); //var entity = _mapper.Map(dto);\ List list = new List(); @@ -72,8 +78,9 @@ namespace WMS.Web.Domain.Services //需要填写序列号 //需要修改库存 - - IDbContextTransaction _transaction = _transactionRepositories.GetTransaction(); + IDbContextTransaction _transaction = null; + if (isTransaction) + _transaction = _transactionRepositories.GetTransaction(); bool isRollback = false; bool isSuccess = true; isSuccess = await _changeBoxRecordRepositories.AddRange(list, false); @@ -81,12 +88,15 @@ namespace WMS.Web.Domain.Services isSuccess = await _boxRepositories.EditEntityList(boxList, false); if (!isSuccess) isRollback = true; - + //提交事务 - isSuccess = _transactionRepositories.CommitTransaction(isRollback, _transaction); - if (!isSuccess) - return Result.ReFailure(ResultCodes.DateWriteError); + if (isTransaction) + { + isSuccess = _transactionRepositories.CommitTransaction(isRollback, _transaction); + if (!isSuccess) + return Result.ReFailure(ResultCodes.DateWriteError); + } return Result.ReSuccess(); }