CommonAppService.cs 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Data.Entity;
  5. using System.Data.SqlClient;
  6. using System.Linq;
  7. using System.Linq.Dynamic.Core;
  8. using System.Net.Http.Headers;
  9. using System.Net.Mail;
  10. using System.Text.RegularExpressions;
  11. using System.Threading.Tasks;
  12. using System.Web.Mvc;
  13. using Abp.Application.Services;
  14. using Abp.Application.Services.Dto;
  15. using Abp.Auditing;
  16. using Abp.Domain.Repositories;
  17. using Abp.Domain.Uow;
  18. using Abp.Extensions;
  19. using Abp.Json;
  20. using Abp.Net.Mail;
  21. using Abp.Net.Mail.Smtp;
  22. using Abp.Runtime.Caching;
  23. using Abp.Runtime.Session;
  24. using Abp.Timing;
  25. using IwbZero.AppServiceBase;
  26. using IwbZero.Helper;
  27. using IwbZero.IdentityFramework;
  28. using IwbZero.Session;
  29. using MailKit;
  30. using Microsoft.AspNet.Identity;
  31. using Microsoft.AspNet.SignalR;
  32. using NPOI.SS.Formula.Functions;
  33. using ShwasherSys.Authorization.Users;
  34. using ShwasherSys.BaseSysInfo;
  35. using ShwasherSys.BaseSysInfo.States;
  36. using ShwasherSys.BaseSysInfo.SysAttachFiles.Dto;
  37. using ShwasherSys.BasicInfo;
  38. using ShwasherSys.Common.Dto;
  39. using ShwasherSys.Common.Dto.HomeChartDto;
  40. using ShwasherSys.CompanyInfo;
  41. using ShwasherSys.CompanyInfo.DeviceInfo.Dto;
  42. using ShwasherSys.CustomerInfo;
  43. using ShwasherSys.EntityFramework;
  44. using ShwasherSys.Hubs;
  45. using ShwasherSys.Inspection;
  46. using ShwasherSys.NotificationInfo;
  47. using ShwasherSys.Order;
  48. using ShwasherSys.Order.Dto;
  49. using ShwasherSys.OrderSendInfo;
  50. using ShwasherSys.PackageInfo;
  51. using ShwasherSys.PackageInfo.Dto;
  52. using ShwasherSys.ProductInfo;
  53. using ShwasherSys.ProductInfo.Dto;
  54. using ShwasherSys.ProductionOrderInfo;
  55. using ShwasherSys.ProductionOrderInfo.Dto;
  56. using ShwasherSys.ProductStoreInfo;
  57. using ShwasherSys.ProductStoreInfo.Dto;
  58. using ShwasherSys.SemiProductStoreInfo;
  59. namespace ShwasherSys.Common
  60. {
  61. [DisableAuditing]
  62. public class CommonAppService : ApplicationService,ICommonAppService
  63. {
  64. protected IRepository<ProductionOrder> ProductionOrderRepository { get; }
  65. protected IRepository<CustomerDisabledProduct> CdpRepository;
  66. protected IRepository<ShortMessage> ShortMsgRepository;
  67. protected IRepository<OrderHeader,string> OrderHeaderRepository;
  68. protected IRepository<ViewOrderSend> ViewOrderSendRepository;
  69. protected IRepository<ShortMsgDetail> ShortMsgDetailRepository;
  70. protected IRepository<SysUser,long> SysUserRepository;
  71. protected IRepository<SemiEnterStore> SemiEnterStoreRepository;
  72. protected IUnitOfWorkManager _UnitOfWorkManager;
  73. protected IRepository<SysAttachFile> SysAttachFileRepository;
  74. protected IRepository<Product,string> ProductRepository;
  75. protected IRepository<SemiProducts,string> SemiProductRepository;
  76. protected IRepository<ProductMapper> ProductMapperRepository;
  77. protected ISqlExecuter SqlExecuter;
  78. protected IEmailSender EmailSender;
  79. protected IRepository<CurrentProductStoreHouse> CurrentProductStoreHouseRepository { get; }
  80. protected IRepository<CurrentSemiStoreHouse> CurrentSemiStoreHouseRepository { get; }
  81. protected IRepository<StoreHouseLocation> StoreHouseLocationRepository { get; }
  82. protected IRepository<Customer,string> CustomerRepository { get; }
  83. protected IRepository<CustomerDisabledProduct> CustomerDisabledProductRepository { get; }
  84. protected IRepository<Department,string> DepartmentRepository { get; }
  85. public IHubContext IwbHub { get; }
  86. public EmailMsgSendHandler EmailMsgSendHandler { get; }
  87. public IStatesAppService StatesAppService { get; }
  88. public IRepository<Employee> EmployeeRepository { get; }
  89. public IRepository<ViewPackageApply> ViewPackageApplyRepository { get; }
  90. public IRepository<SemiProducts, string> SemiProductsRepository { get; }
  91. public IRepository<DeviceMgPlan> DeviceMgPlanRepository { get; }
  92. public IRepository<OrderBookStore,long> OrderBookStoreRepository { get; }
  93. protected IRepository<BusinessLog> BusinessLogRepository { get; }
  94. public CommonAppService(ICacheManager cacheManager, IRepository<ShortMsgDetail> shortMsgDetailRepository, IRepository<ShortMessage> shortMsgRepository, IRepository<SysUser, long> sysUserRepository, IUnitOfWorkManager unitOfWorkManager, IRepository<SysAttachFile> sysAttachFileRepository, IRepository<OrderHeader, string> orderHeaderRepository, IRepository<ViewOrderSend> viewOrderSendRepository, ISqlExecuter sqlExecuter, IEmailSender emailSender, IRepository<CurrentProductStoreHouse> currentProductStoreHouseRepository, IRepository<CurrentSemiStoreHouse> currentSemiStoreHouseRepository, IRepository<StoreHouseLocation> storeHouseLocationRepository, IRepository<CustomerDisabledProduct> cdpRepository, IRepository<ProductionOrder> productionOrderRepository, ISmtpEmailSenderConfiguration smtpEmailSenderConfiguration, IRepository<Customer, string> customerRepository, IRepository<CustomerDisabledProduct> customerDisabledProductRepository, IRepository<SemiEnterStore> semiEnterStoreRepository, IRepository<Department, string> departmentRepository, IRepository<SemiProducts, string> semiProductRepository, IRepository<Product, string> productRepository, IRepository<ProductMapper> productMapperRepository, EmailMsgSendHandler emailMsgSendHandler, IStatesAppService statesAppService, IRepository<Employee> employeeRepository,IRepository<ViewPackageApply> viewPackageApplyRepository, IRepository<SemiProducts, string> semiProductsRepository, IRepository<DeviceMgPlan> deviceMgPlanRepository, IRepository<OrderBookStore, long> orderBookStorerepository, IRepository<BusinessLog> businessLogRepository)
  95. {
  96. ShortMsgDetailRepository = shortMsgDetailRepository;
  97. ShortMsgRepository = shortMsgRepository;
  98. SysUserRepository = sysUserRepository;
  99. _UnitOfWorkManager = unitOfWorkManager;
  100. SysAttachFileRepository = sysAttachFileRepository;
  101. OrderHeaderRepository = orderHeaderRepository;
  102. ViewOrderSendRepository = viewOrderSendRepository;
  103. SqlExecuter = sqlExecuter;
  104. IwbHub = GlobalHost.ConnectionManager.GetHubContext<IwbHub>();
  105. EmailSender = emailSender;
  106. CurrentProductStoreHouseRepository = currentProductStoreHouseRepository;
  107. CurrentSemiStoreHouseRepository = currentSemiStoreHouseRepository;
  108. StoreHouseLocationRepository = storeHouseLocationRepository;
  109. CdpRepository = cdpRepository;
  110. ProductionOrderRepository = productionOrderRepository;
  111. SmtpEmailSenderConfiguration = smtpEmailSenderConfiguration;
  112. CustomerRepository = customerRepository;
  113. CustomerDisabledProductRepository = customerDisabledProductRepository;
  114. SemiEnterStoreRepository = semiEnterStoreRepository;
  115. DepartmentRepository = departmentRepository;
  116. SemiProductRepository = semiProductRepository;
  117. ProductMapperRepository = productMapperRepository;
  118. ProductRepository = productRepository;
  119. EmailMsgSendHandler = emailMsgSendHandler;
  120. StatesAppService = statesAppService;
  121. EmployeeRepository = employeeRepository;
  122. ViewPackageApplyRepository = viewPackageApplyRepository;
  123. SemiProductsRepository = semiProductsRepository;
  124. DeviceMgPlanRepository = deviceMgPlanRepository;
  125. OrderBookStoreRepository = orderBookStorerepository;
  126. BusinessLogRepository = businessLogRepository;
  127. }
  128. public string KeepClock()
  129. {
  130. return Clock.Now.ToString("yyyy-MM-dd HH:mm:ss");
  131. }
  132. private Action<ISqlExecuter,DateTime> CloseProductionOrder = (sqlExecuter, date) =>
  133. {
  134. //var list = repository.GetAllList(a => a.PlanProduceDate < date && a.ProductionOrderStatus != 5);
  135. //if (list.Any())
  136. //{
  137. // foreach (var l in list)
  138. // {
  139. // l.ProductionOrderStatus = 5;
  140. // repository.Update(l);
  141. // }
  142. //}
  143. string sql =
  144. $"UPDATE [dbo].[ProductionOrders] SET ProductionOrderStatus=5 WHERE EnterDate < '{date:yyyy-MM-dd}' AND ProductionOrderStatus=4 AND IsChecked=1 ";
  145. sqlExecuter.Execute(sql);
  146. };
  147. private readonly IRepository<ProductMapper, int> _productMapperRepository;
  148. /// <summary>
  149. /// 关闭三个月前的排产单
  150. /// </summary>
  151. public async Task CloseProductOrder()
  152. {
  153. var date = DateTime.Now.AddMonths(-3);
  154. date= new DateTime(date.Year,date.Month,date.Day);
  155. if (await ProductionOrderRepository.CountAsync(a=>a.IsChecked==1 && a.EnterDate<date && a.ProductionOrderStatus==4)>0)
  156. {
  157. string sql =
  158. $"update [dbo].[ProductionOrders] set ProductionOrderStatus=5 where PlanProduceDate < '{date:yyyy-MM-dd}'";
  159. await SqlExecuter.ExecuteAsync(sql);
  160. }
  161. }
  162. public async Task WriteShortMessageByDep(string sendman,string departments,string title="",string content="",bool isSendMail = true)
  163. {
  164. string lcRecieveIds = "";
  165. var loArr = departments.Split(',');
  166. var ds = DepartmentRepository.GetAllList(i => loArr.Contains(i.DepartmentName));
  167. var dsIds = ds.Select(i => i.Id);
  168. var users = SysUserRepository.GetAllList(i => dsIds.Contains(i.DepartmentID));
  169. if (users.Any())
  170. {
  171. lcRecieveIds = string.Join(",", users.Select(i => i.UserName).ToArray());
  172. await WriteShortMessage(sendman, lcRecieveIds, title, content, isSendMail);
  173. }
  174. }
  175. /// <summary>
  176. /// 写入短消息
  177. /// </summary>
  178. /// <param name="sendman">发送人</param>
  179. /// <param name="recieveIds">接收用户名 eg:shenjianfang,menghanming,jiangjingeng</param>
  180. /// <param name="title"></param>
  181. /// <param name="content"></param>
  182. public async Task WriteShortMessage(string sendman, string recieveIds, string title = "", string content = "", bool isSendMail = false)
  183. {
  184. ShortMessage shortMessage = new ShortMessage()
  185. {
  186. SendUserID = sendman,
  187. SendTime = Clock.Now,
  188. Title = title,
  189. Content = content,
  190. RecieveUserIds = recieveIds,
  191. IsDelete = "N"
  192. };
  193. var shortMsg = await ShortMsgRepository.InsertAsync(shortMessage);
  194. await CurrentUnitOfWork.SaveChangesAsync();
  195. IwbHub.Clients.All.getShortMsg(shortMessage.ToJsonString());
  196. if (!recieveIds.IsNullOrEmpty())
  197. {
  198. var loArr = recieveIds.Split(',');
  199. if (loArr.Any())
  200. {
  201. //MailMessage mail = new MailMessage();
  202. foreach (var u in loArr)
  203. {
  204. ShortMsgDetail shortMsgDetail = new ShortMsgDetail()
  205. {
  206. IsRead = "N",
  207. MsgID = shortMsg.Id,
  208. RecvUserID = u,
  209. };
  210. //var user = SysUserRepository.FirstOrDefault(i => i.UserName == u);
  211. //mail.To.Add(user.EmailAddress);
  212. //await EmailSender.SendAsync(user.EmailAddress, "系统订单变动", content);
  213. await ShortMsgDetailRepository.InsertAsync(shortMsgDetail);
  214. }
  215. }
  216. if (isSendMail)
  217. {
  218. WriteShortMessage2(sendman, recieveIds, title, content);
  219. }
  220. }
  221. }
  222. public void WriteShortMessage2(string sendman, string recieveIds, string title = "", string content = "")
  223. {
  224. if (!recieveIds.IsNullOrEmpty())
  225. {
  226. var loArr = recieveIds.Split(',');
  227. if (loArr.Any())
  228. {
  229. //MailMessage mail = new MailMessage();
  230. //foreach (var u in loArr)
  231. //{
  232. // var user = SysUserRepository.FirstOrDefault(i => i.UserName == u);
  233. // var emailPattern = @"^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$";
  234. // if (user != null && !string.IsNullOrEmpty(user.EmailAddress) && Regex.IsMatch(user.EmailAddress, emailPattern))
  235. // {
  236. // mail.To.Add(user.EmailAddress);
  237. // mail.Body = content;
  238. // mail.IsBodyHtml = true;
  239. // mail.Subject = title;
  240. // }
  241. //}
  242. //if (mail.To.Any())
  243. //{
  244. // await EmailSender.SendAsync(mail);
  245. //}
  246. List<string> receiveEmails = new List<string>();
  247. foreach (var u in loArr)
  248. {
  249. var user = SysUserRepository.FirstOrDefault(i => i.UserName == u);
  250. var emailPattern = @"^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$";
  251. if (user != null && !string.IsNullOrEmpty(user.EmailAddress) &&
  252. Regex.IsMatch(user.EmailAddress, emailPattern))
  253. {
  254. receiveEmails.Add(user.EmailAddress);
  255. }
  256. }
  257. if (receiveEmails.Count > 0)
  258. {
  259. EmailMsg mailMsg = new EmailMsg(true, receiveEmails:string.Join(",", receiveEmails) , title, content);
  260. EmailMsgSendHandler.SendEmailMsg(mailMsg);
  261. }
  262. }
  263. }
  264. }
  265. protected virtual void CheckErrors(IdentityResult identityResult)
  266. {
  267. identityResult.CheckErrors(LocalizationManager);
  268. }
  269. public List<SysAttachFile> GetAttachFile(QueryAttachDto input)
  270. {
  271. var query = SysAttachFileRepository.GetAll().Where(i =>
  272. i.TableName == input.TableName && i.ColumnName == input.ColName && i.SourceKey == input.Key);
  273. return query.ToList();
  274. }
  275. /// <summary>
  276. /// 判断订单是否有发货记录
  277. /// </summary>
  278. /// <param name="pcOrderNo"></param>
  279. /// <returns></returns>
  280. public async Task<bool> CheckOrderHasSend(string pcOrderNo)
  281. {
  282. var orderSends = await ViewOrderSendRepository.GetAllListAsync(i => i.OrderNo == pcOrderNo);
  283. return orderSends.Any();
  284. }
  285. /// <summary>
  286. /// 检查改批次产品能否发货给某客户
  287. /// </summary>
  288. /// <param name="productOrderNo"></param>
  289. /// <param name="customerNo"></param>
  290. /// <returns></returns>
  291. public async Task<bool> CheckProductCanSendToCustomer(string productOrderNo,string customerNo)
  292. {
  293. return await CdpRepository.CountAsync(a=>a.CustomerNo==customerNo&&a.ProductOrderNo==productOrderNo)>0;
  294. }
  295. /// <summary>
  296. /// 检查改批次产品能否发货给某客户
  297. /// </summary>
  298. /// <param name="productOrderNos"></param>
  299. /// <param name="customerNo"></param>
  300. /// <returns></returns>
  301. public async Task<bool> CheckProductCanSendToCustomer(List<string> productOrderNos,string customerNo)
  302. {
  303. return await CdpRepository.CountAsync(a=>a.CustomerNo==customerNo&&productOrderNos.Contains(a.ProductOrderNo))>0;
  304. }
  305. public Task PreMonth()
  306. {
  307. return SqlExecuter.ExecuteAsync("update CurrentProductStoreHouse set PreMonthQuantity = Quantity;update CurrentSemiStoreHouse set PreMonthQuantity = ActualQuantity;");
  308. }
  309. [UnitOfWork]
  310. [DisableAuditing]
  311. public int? GetAppGuid(AppGuidType type)
  312. {
  313. var sqlParms = new object[3];
  314. sqlParms[0] = new SqlParameter("@idtype", (int)type);
  315. sqlParms[1] = new SqlParameter("@nextid", SqlDbType.Int) { Direction = ParameterDirection.Output };
  316. sqlParms[2] = new SqlParameter("@maxid", SqlDbType.Int) { Direction = ParameterDirection.Output };
  317. SqlExecuter.Execute(@"exec [dbo].[Sp_AppGuid] @idtype,@nextid out,@maxid out", sqlParms);
  318. int guid = (int)((SqlParameter)sqlParms[2]).Value;
  319. return guid;
  320. }
  321. /// <summary>
  322. /// 检查库存记录是否可以更新
  323. /// </summary>
  324. /// <param name="houseType">仓库类型(1:成品 2:半成品)</param>
  325. /// <param name="houseStoreNo">库存记录编号</param>
  326. /// <returns></returns>
  327. [UnitOfWork]
  328. [DisableAuditing]
  329. public bool CheckStoreRecordCanUpdate(string houseStoreNo,int houseType=1)
  330. {
  331. if (houseType == 1)
  332. {
  333. var houseRecord =
  334. CurrentProductStoreHouseRepository.FirstOrDefault(i =>
  335. i.CurrentProductStoreHouseNo == houseStoreNo);
  336. if (houseRecord != null&&houseRecord.InventoryCheckState==2&&houseRecord.ReturnState==2)
  337. {
  338. return false;
  339. }
  340. }
  341. if (houseType == 2)
  342. {
  343. var houseRecord =
  344. CurrentSemiStoreHouseRepository.FirstOrDefault(i =>
  345. i.CurrentSemiStoreHouseNo == houseStoreNo);
  346. if (houseRecord != null && houseRecord.InventoryCheckState == 2 && houseRecord.ReturnState == 2)
  347. {
  348. return false;
  349. }
  350. }
  351. return true;
  352. }
  353. /// <summary>
  354. /// 检查库存记录是否可以更新
  355. /// </summary>
  356. /// <param name="houseType">仓库类型(1:成品 2:半成品)</param>
  357. /// <param name="locationNo">库位编号</param>
  358. /// <returns></returns>
  359. [UnitOfWork]
  360. [DisableAuditing]
  361. public bool CheckStoreCanUpdateByLocationNo(string locationNo,int houseType=1)
  362. {
  363. if (houseType == 1)
  364. {
  365. if (CurrentProductStoreHouseRepository.Count(a => a.StoreLocationNo == locationNo&& (a.InventoryCheckState==2 || a.ReturnState==2))>0)
  366. {
  367. return false;
  368. }
  369. }else if (houseType == 2)
  370. {
  371. if (CurrentSemiStoreHouseRepository.Count(a => a.StoreLocationNo == locationNo&& (a.InventoryCheckState==2 || a.ReturnState==2))>0)
  372. {
  373. return false;
  374. }
  375. }
  376. return true;
  377. }
  378. /// <summary>
  379. /// 查询库区/货架/排(排可以多选)
  380. /// </summary>
  381. /// <param name="storeId"></param>
  382. /// <param name="areaNo"></param>
  383. /// <param name="shelfNo"></param>
  384. /// <returns></returns>
  385. public List<SelectListItem> FilterLocationInfo(int storeId,string areaNo="",string shelfNo="", string levelNo = "")
  386. {
  387. var query = StoreHouseLocationRepository.GetAll().Where(i => i.StoreHouseId == storeId);
  388. if (areaNo.IsNullOrEmpty())
  389. {
  390. var result = query.Select(i => i.StoreAreaCode).Distinct();
  391. return result.Select(i=>new SelectListItem(){Text = i.ToString(),Value = i.ToString()}).ToList();
  392. }
  393. query = query.Where(i => i.StoreAreaCode == areaNo);
  394. if (shelfNo.IsNullOrEmpty())
  395. {
  396. var result = query.Select(i => i.ShelfNumber).Distinct();
  397. return result.Select(i => new SelectListItem() { Text = i.ToString(), Value = i.ToString() }).ToList();
  398. }
  399. query = query.Where(i => i.ShelfNumber == shelfNo);
  400. if (levelNo.IsNullOrEmpty())
  401. {
  402. var result = query.Select(i => i.ShelfLevel).Distinct();
  403. return result.Select(i => new SelectListItem() { Text = i.ToString(), Value = i.ToString() }).ToList();
  404. }
  405. query = query.Where(i => i.ShelfLevel == levelNo);
  406. return query.Select(i => i.SequenceNo).Distinct().Select(i => new SelectListItem() { Text = i.ToString(), Value = i.ToString() }).ToList();
  407. }
  408. public List<ProductionOrderDisCustomerDto> GetDisCustomerInfo(EntityDto<string> input)
  409. {
  410. return CustomerDisabledProductRepository.GetAll().Where(i => i.ProductOrderNo == input.Id).Join(CustomerRepository.GetAll(), p => p.CustomerNo, c => c.Id,
  411. (p, c) =>
  412. new ProductionOrderDisCustomerDto()
  413. {
  414. ProductionOrderNo = p.ProductOrderNo,
  415. CustomerName = c.CustomerName,
  416. CustomerId = p.CustomerNo
  417. }).ToList();
  418. }
  419. #region 发送邮件
  420. public ISmtpEmailSenderConfiguration SmtpEmailSenderConfiguration { get; }
  421. public void SendEmail(string toEmail,string title,string msg,bool isHtml)
  422. {
  423. //SmtpEmailSender emailSender = new SmtpEmailSender(SmtpEmailSenderConfiguration);
  424. //emailSender.Send("zhangwy@iwbnet.com",toEmail , title, msg,isHtml);
  425. //EmailSendHelper.SendEmail(toEmail,title,msg,"","",isHtml);
  426. EmailHelper.SendEmail(toEmail,title,msg,isHtml);
  427. }
  428. #endregion
  429. #region 创建排产单号
  430. public async Task<string> GetProductionOrderNo(string createType = "", string preOrderNo = "", int isOutsourcing = 0)
  431. {
  432. if (string.IsNullOrEmpty(createType))
  433. {
  434. return await NormalGetProductionOrderNo(isOutsourcing);
  435. }
  436. return await SpecialGetProductionOrderNo(createType, preOrderNo);
  437. }
  438. /// <summary>
  439. /// 常规获取批次号
  440. /// </summary>
  441. /// <param name="isOutsourcing">1是外购</param>
  442. /// <returns></returns>
  443. private async Task<string> NormalGetProductionOrderNo(int isOutsourcing)
  444. {
  445. string lcRetVal;
  446. DateTime loTiem = DateTime.Parse(DateTime.Now.Year + "-" + DateTime.Now.Month + "-01");
  447. //loTiem = loTiem.AddSeconds(-1);
  448. var orders = (await ProductionOrderRepository.GetAllListAsync(i => i.TimeCreated >= loTiem && i.ProcessingLevel == "1")).OrderByDescending(i => i.Id).ToList();
  449. var orderNo = orders.FirstOrDefault()?.ProductionOrderNo;
  450. if (!string.IsNullOrEmpty(orderNo))
  451. {
  452. var liTempNo = Convert.ToInt32(orderNo.Substring(3, 4));
  453. liTempNo++;
  454. lcRetVal = liTempNo.ToString();
  455. while (lcRetVal.Length < 4)
  456. {
  457. lcRetVal = "0" + lcRetVal;
  458. }
  459. }
  460. else
  461. {
  462. lcRetVal = "0001";
  463. }
  464. DateTime loDate = DateTime.Today;
  465. //string lcMonth = liMonth < 10 ? liMonth + "" : Convert.ToString(liMonth, 16);
  466. lcRetVal = loDate.Date.Year + GetMonthString(isOutsourcing) + lcRetVal;
  467. lcRetVal = lcRetVal.Substring(2, lcRetVal.Length - 2);
  468. return lcRetVal;
  469. }
  470. /// <summary>
  471. /// 转换月份
  472. /// </summary>
  473. /// <param name="isOutsourcing"></param>
  474. /// <returns></returns>
  475. private string GetMonthString(int isOutsourcing)
  476. {
  477. DateTime loDate = DateTime.Today;
  478. int liMonth = loDate.Date.Month;
  479. if (isOutsourcing == 0)
  480. {
  481. return liMonth < 10 ? liMonth + "" : Convert.ToString(liMonth, 16).ToUpper();
  482. }
  483. string[] scource = { "", "G", "H", "W", "J", "K", "L", "M", "N", "T", "P", "Q", "R" };
  484. return scource[liMonth];
  485. }
  486. private string GetLastFourChar(string preOrderNo)
  487. {
  488. if (!string.IsNullOrEmpty(preOrderNo) && preOrderNo.Length == 11)
  489. {
  490. return preOrderNo.Substring(7, 4);
  491. }
  492. return "";
  493. }
  494. private async Task<string> SpecialGetProductionOrderNo(string createType, string preOrderNo = "")
  495. {
  496. string lcRetVal;
  497. DateTime loTiem = DateTime.Parse(DateTime.Now.Year + "-" + DateTime.Now.Month + "-01");
  498. string reg = @"/^[A-Za-z0-9]{3}" + createType + @"\w{3,7}$/";
  499. string orderNo = "";
  500. if (createType == "T")
  501. {
  502. var orders = (await SemiEnterStoreRepository
  503. .GetAllListAsync(i => i.TimeCreated >= loTiem && Regex.IsMatch(i.ProductionOrderNo, @"/^[A-Za-z0-9]{3}T\w{3,7}$/"))).OrderByDescending(i => i.Id).ToList();
  504. orderNo = orders.FirstOrDefault()?.ProductionOrderNo;
  505. }else if (createType == "G")
  506. {
  507. var orders = (await ProductionOrderRepository
  508. .GetAllListAsync(i => i.TimeCreated >= loTiem && Regex.IsMatch(i.ProductionOrderNo, @"/^[A-Za-z0-9]{3}T\w{3,7}$/"))).OrderByDescending(i => i.Id).ToList();
  509. orderNo = orders.FirstOrDefault()?.ProductionOrderNo;
  510. }
  511. if (!string.IsNullOrEmpty(orderNo))
  512. {
  513. var liTempNo = Convert.ToInt32(orderNo.Substring(4, 3));
  514. liTempNo++;
  515. lcRetVal = liTempNo.ToString();
  516. while (lcRetVal.Length < 3)
  517. {
  518. lcRetVal = "0" + lcRetVal;
  519. }
  520. }
  521. else
  522. {
  523. lcRetVal = "T001";
  524. }
  525. DateTime loDate = DateTime.Today;
  526. //string lcMonth = liMonth < 10 ? liMonth + "" : Convert.ToString(liMonth, 16);
  527. lcRetVal = loDate.Date.Year + GetMonthString(0) + lcRetVal;
  528. lcRetVal = lcRetVal.Substring(2, lcRetVal.Length - 2);
  529. lcRetVal += GetLastFourChar(preOrderNo);
  530. return lcRetVal;
  531. }
  532. #endregion
  533. /// <summary>
  534. /// 根据对照表搜到新的成品编码
  535. /// </summary>
  536. /// <param name="productNo"></param>
  537. /// <returns></returns>
  538. public async Task<ProductDto> GetNewProductInfo(string productNo)
  539. {
  540. var productMapper =
  541. await ProductMapperRepository.FirstOrDefaultAsync(i =>
  542. i.PreProductNo == productNo && i.PreProductType == 1);
  543. if (productMapper != null)
  544. {
  545. productNo = productMapper.ProductNo;
  546. }
  547. var pEntity = ProductRepository.Get(productNo);
  548. return ObjectMapper.Map<ProductDto>(pEntity);
  549. }
  550. /// <summary>
  551. /// 根据对照表搜到新的半成品编码
  552. /// </summary>
  553. /// <param name="productNo"></param>
  554. /// <returns></returns>
  555. public async Task<SemiProductDto> GetNewSemiProductInfo(string productNo)
  556. {
  557. var productMapper =
  558. await ProductMapperRepository.FirstOrDefaultAsync(i =>
  559. i.PreProductNo == productNo && i.PreProductType == 2);
  560. if (productMapper != null)
  561. {
  562. //CheckErrors(new IdentityResult("未查询到替换信息!"));
  563. productNo = productMapper.ProductNo;
  564. }
  565. var pEntity = SemiProductRepository.Get(productNo);
  566. return ObjectMapper.Map<SemiProductDto>(pEntity);
  567. }
  568. #region 首页提示查询信息
  569. public async Task<List<IndexAlertSumDto>> GetIndexAlertSum()
  570. {
  571. List<IndexAlertSumDto> result = new List<IndexAlertSumDto>();
  572. var user = SysUserRepository.Get(AbpSession.UserId ?? 0);
  573. //销售部和超级管理员可以查看
  574. if (user.UserType == 1 || user.DepartmentID== "002")
  575. {
  576. int notCompleteStatus = OrderStatusEnum.Completed.ToInt();
  577. int deleteStatus = OrderStatusEnum.Delete.ToInt();
  578. var query = OrderHeaderRepository.GetAll().Where(i =>
  579. i.OrderStatusId != notCompleteStatus && i.OrderStatusId != deleteStatus);
  580. int c = await query.CountAsync();
  581. result.Add(new IndexAlertSumDto() { Quantity = c, SumName = "未完成的订单", SumType = "1", TipName = "订单" });
  582. }
  583. if (user.UserType == 1 || user.DepartmentID == "003")
  584. {
  585. int startStatus = ProductionOrderStatusEnum.Start.ToInt();
  586. int auditedStatus = ProductionOrderStatusEnum.Audited.ToInt();
  587. int productingStatus = ProductionOrderStatusEnum.Producting.ToInt();
  588. int storeingStatus = ProductionOrderStatusEnum.Storeing.ToInt();
  589. var query1 = ProductionOrderRepository.GetAll().Where(i =>
  590. i.ProductionOrderStatus == startStatus || i.ProductionOrderStatus == auditedStatus || i.ProductionOrderStatus == productingStatus || i.ProductionOrderStatus == storeingStatus);
  591. int c1 = await query1.CountAsync();
  592. result.Add(new IndexAlertSumDto() { Quantity = c1, SumName = "未完成的排查单", SumType = "2", TipName = "生产" });
  593. }
  594. if (user.UserType == 1 || user.DepartmentID == "005")
  595. {
  596. int applyStatus = PackageApplyStatusEnum.Applying.ToInt();
  597. var query2 = ViewPackageApplyRepository.GetAll().Where(i =>
  598. i.ApplyStatus == applyStatus + "");
  599. int c2 = await query2.CountAsync();
  600. result.Add(new IndexAlertSumDto() { Quantity = c2, SumName = "未审核的包装申请", SumType = "3", TipName = "包装" });
  601. }
  602. if (user.UserType == 1 )
  603. {
  604. var overAndComingSoon = await DeviceMgPlanRepository.GetAllListAsync(i => i.PlanType == 1
  605. && (
  606. i.NumberOfUsers >= i.MaintenanceCycle || (
  607. i.MaintenanceCycle > i.NumberOfUsers
  608. && ((i.MaintenanceCycle - i.NumberOfUsers) <= 10000))
  609. )
  610. );
  611. //var overDtos = ObjectMapper.Map<List<DeviceMgPlanDto>>(over);
  612. var overAndComingSoonDtos = ObjectMapper.Map<List<DeviceMgPlanDto>>(overAndComingSoon);
  613. result.Add(new IndexAlertSumDto() { Quantity = overAndComingSoonDtos.Count, SumName = "模具待维护计划", SumType = "4", TipName = "pro2" });
  614. }
  615. return result;
  616. }
  617. public async Task<List<OrderHeaderDto>> GetOrderHeaderForAlert()
  618. {
  619. int notCompleteStatus = OrderStatusEnum.Completed.ToInt();
  620. int deleteStatus = OrderStatusEnum.Delete.ToInt();
  621. var query = OrderHeaderRepository.GetAll().Where(i =>
  622. i.OrderStatusId != notCompleteStatus && i.OrderStatusId != deleteStatus);
  623. var employeeList = EmployeeRepository.GetAllList();
  624. query = query.OrderByDescending(i => i.TimeCreated);
  625. var entityList = await query.Take(20).ToListAsync();
  626. var r = entityList.Select(i => new OrderHeaderDto()
  627. {
  628. CustomerId = i.CustomerId,
  629. CustomerSendId = i.CustomerSendId,
  630. Fax = i.Fax,
  631. LinkName = i.LinkName,
  632. Id = i.Id,
  633. OrderDate = i.OrderDate,
  634. OrderStatusId = i.OrderStatusId,
  635. OrderStatusName =
  636. StatesAppService.GetDisplayValue("OrderHeader", "OrderStatusId", i.OrderStatusId + ""),
  637. StockNo = i.StockNo,
  638. Telephone = i.Telephone,
  639. TimeLastMod = i.TimeLastMod,
  640. UserIDLastMod = i.UserIDLastMod,
  641. TimeCreated = i.TimeCreated,
  642. SaleType = i.SaleType,
  643. SaleTypeName = StatesAppService.GetDisplayValue("OrderHeader", "SaleType", i.SaleType + ""),
  644. SaleMan = i.SaleMan,
  645. SaleManName = employeeList.FirstOrDefault(a => a.No == i.SaleMan)?.Name,
  646. IsLock = i.IsLock
  647. });
  648. return r.ToList();
  649. }
  650. public async Task<List<ProductionOrderDto>> GetProductionOrderForAlert()
  651. {
  652. int startStatus = ProductionOrderStatusEnum.Start.ToInt();
  653. int auditedStatus = ProductionOrderStatusEnum.Audited.ToInt();
  654. int productingStatus = ProductionOrderStatusEnum.Producting.ToInt();
  655. int storeingStatus = ProductionOrderStatusEnum.Storeing.ToInt();
  656. var query = ProductionOrderRepository.GetAll().Where(i =>
  657. i.ProductionOrderStatus == startStatus || i.ProductionOrderStatus == auditedStatus || i.ProductionOrderStatus == productingStatus || i.ProductionOrderStatus == storeingStatus);
  658. query = query.OrderByDescending(i => i.TimeCreated);
  659. var entityList = await query.Take(20).ToListAsync();
  660. return ObjectMapper.Map<List<ProductionOrderDto>>(entityList);
  661. }
  662. public async Task<List<ViewPackageApply>> GetPackageApplyForAlert()
  663. {
  664. int applyStatus = PackageApplyStatusEnum.Applying.ToInt();
  665. var query = ViewPackageApplyRepository.GetAll().Where(i =>
  666. i.ApplyStatus == applyStatus+"");
  667. query = query.OrderByDescending(i => i.TimeCreated);
  668. var entityList = await query.Take(20).ToListAsync();
  669. return entityList;
  670. }
  671. /// <summary>
  672. /// 首页查询图表
  673. /// </summary>
  674. /// <param name="ct">查询数据表 1:订单明细 2:排产单</param>
  675. /// <param name="qt">汇总分类 1:按季度 0:按年</param>
  676. /// <returns></returns>
  677. public List<StatusChartDto> GetHomeStatusCharts(int ct,int qt)
  678. {
  679. int deleteStatus = OrderItemStatusEnum.Delete.ToInt();
  680. DateTime dt = DateTime.Now;
  681. string startYear = dt.AddYears(-4).Year + "-01-01";
  682. DateTime startQuarter = dt.AddMonths(0 - (dt.Month - 1) % 3).AddDays(1 - dt.Day); //本季度初
  683. DateTime endQuarter = startQuarter.AddMonths(3);//.AddDays(-1); //本季度末
  684. string endTime = endQuarter.ToString("yyyy-MM-dd");
  685. var startTime = dt.AddYears(-2).Year + "-01-01";//startQuarter.AddMonths(-21).ToString("yyyy-MM-dd");
  686. string sqlStr = "";
  687. if (ct == 1)
  688. {
  689. sqlStr = $"select sum(1) as Count,OrderItemStatusId as StatusId,datename(year,TimeCreated) as Year from OrderItems where TimeCreated>='{startYear}' GROUP BY OrderItemStatusId,datename(year,TimeCreated) HAVING OrderItemStatusId<>{deleteStatus};";
  690. }else if (ct == 2)
  691. {
  692. sqlStr = $"select sum(1) as Count,ProductionOrderStatus as StatusId,datename(year,TimeCreated) as Year from ProductionOrders where TimeCreated >= '{startYear}' GROUP BY ProductionOrderStatus,datename(year,TimeCreated)";
  693. }
  694. //按季度,默认显示最近5个季度
  695. if (ct == 1&&qt == 1)
  696. {
  697. sqlStr =
  698. $"select sum(1) as Count,OrderItemStatusId as StatusId,datepart(qq,TimeCreated) as Quarterly,datename(year,TimeCreated) as Year from OrderItems where TimeCreated>='{startTime}' and TimeCreated<'{endTime}' GROUP BY OrderItemStatusId,datepart(qq,TimeCreated),datename(year,TimeCreated) HAVING OrderItemStatusId<>{deleteStatus};";
  699. }else if (ct == 2 && qt == 1)
  700. {
  701. sqlStr = $"select sum(1) as Count,ProductionOrderStatus as StatusId,datepart(qq,TimeCreated) as Quarterly,datename(year,TimeCreated) as Year from ProductionOrders where TimeCreated >= '{startTime}' and TimeCreated<'{endTime}' GROUP BY ProductionOrderStatus,datepart(qq,TimeCreated),datename(year,TimeCreated)";
  702. }
  703. var statusChartDtos = SqlExecuter.SqlQuery<StatusChartDto>(sqlStr);
  704. statusChartDtos = statusChartDtos.OrderBy(i => i.Year);
  705. if (qt == 1)
  706. {
  707. statusChartDtos = statusChartDtos.OrderBy(i => i.Year).ThenBy(i=>i.Quarterly);
  708. }
  709. return statusChartDtos.ToList();
  710. }
  711. public List<OrderStatusChartDto> GetOrderStatusCharts(int qt)
  712. {
  713. int deleteStatus = OrderItemStatusEnum.Delete.ToInt();
  714. DateTime dt = DateTime.Now;
  715. string startYear = dt.AddYears(-4).Year +"-01-01";
  716. string sqlStr =
  717. $"select sum(1) as Count,OrderItemStatusId,datename(year,TimeCreated) as Year from OrderItems where TimeCreated>='{startYear}' GROUP BY OrderItemStatusId,datename(year,TimeCreated) HAVING OrderItemStatusId<>{deleteStatus};";
  718. //按季度,默认显示最近5个季度
  719. if (qt==1)
  720. {
  721. DateTime startQuarter = dt.AddMonths(0 - (dt.Month - 1) % 3).AddDays(1 - dt.Day); //本季度初
  722. DateTime endQuarter = startQuarter.AddMonths(3);//.AddDays(-1); //本季度末
  723. string endTime = endQuarter.ToString("yyyy-MM-dd");
  724. var startTime = startQuarter.AddMonths(-12).ToString("yyyy-MM-dd");
  725. sqlStr =
  726. $"select sum(1) as Count,OrderItemStatusId,datepart(qq,TimeCreated) as Quarterly,datename(year,TimeCreated) as Year from OrderItems where TimeCreated>='{startTime}' and TimeCreated<'{endTime}' GROUP BY OrderItemStatusId,datepart(qq,TimeCreated),datename(year,TimeCreated) HAVING OrderItemStatusId<>{deleteStatus};";
  727. }
  728. var orderStatusChartDtos = SqlExecuter.SqlQuery<OrderStatusChartDto>(sqlStr);
  729. orderStatusChartDtos = orderStatusChartDtos.OrderBy(i => i.Year);
  730. return orderStatusChartDtos.ToList();
  731. }
  732. public List<ProductionOrderStatusChartDto> GetProductionOrderStatusCharts()
  733. {
  734. // int deleteStatus = OrderStatusEnum.Delete.ToInt();
  735. string startYear = DateTime.Now.AddYears(-4).Year + "-01-01";
  736. string sqlStr =
  737. $"select sum(1) as Count,ProductionOrderStatus,datename(year,TimeCreated) as Year from ProductionOrders where TimeCreated >= '{startYear}' GROUP BY ProductionOrderStatus,datename(year,TimeCreated)";
  738. var orderStatusChartDtos = SqlExecuter.SqlQuery<ProductionOrderStatusChartDto>(sqlStr);
  739. orderStatusChartDtos = orderStatusChartDtos.OrderBy(i => i.Year);
  740. return orderStatusChartDtos.ToList();
  741. }
  742. #endregion
  743. public async Task<List<CurrentProductStoreHouseDto>> GetProductStoreInfoByProductNo(string productNo)
  744. {
  745. var cs = await CurrentProductStoreHouseRepository.GetAllListAsync(i =>
  746. i.ProductNo == productNo && i.Quantity > 0);
  747. return ObjectMapper.Map<List<CurrentProductStoreHouseDto>>(cs);
  748. }
  749. /// <summary>
  750. /// 去除已被替换的产品
  751. /// </summary>
  752. /// <param name="input"></param>
  753. /// <returns></returns>
  754. public async Task<PagedResultDto<ProductDto>> GetProductNotContainOld(IwbPagedRequestDto input)
  755. {
  756. var productNoExts =
  757. (await ProductMapperRepository.GetAllListAsync(i =>i.PreProductType == 1)).Select(i=>i.PreProductNo);
  758. var query = ProductRepository.GetAll().Where(a => a.IsLock == "N"&& !productNoExts.Contains(a.Id));
  759. if (input.SearchList != null && input.SearchList.Count > 0)
  760. {
  761. List<LambdaObject> objList = new List<LambdaObject>();
  762. foreach (var o in input.SearchList)
  763. {
  764. if (o.KeyWords.IsNullOrEmpty())
  765. continue;
  766. object keyWords = o.KeyWords;
  767. objList.Add(new LambdaObject
  768. {
  769. FieldType = (LambdaFieldType)o.FieldType,
  770. FieldName = o.KeyField,
  771. FieldValue = keyWords,
  772. ExpType = (LambdaExpType)o.ExpType
  773. });
  774. }
  775. var exp = objList.GetExp<Product>();
  776. query = query.Where(exp);
  777. }
  778. var totalCount = await query.CountAsync();
  779. query = !input.Sorting.IsNullOrWhiteSpace() ? query.OrderBy(input.Sorting) : query.OrderByDescending(i => i.TimeCreated);
  780. query = query.Skip(input.SkipCount).Take(input.MaxResultCount);
  781. var entities = await query.ToListAsync();
  782. var dtos = new PagedResultDto<ProductDto>(
  783. totalCount,
  784. entities.Select(ObjectMapper.Map<ProductDto>).ToList()
  785. );
  786. return dtos;
  787. }
  788. /// <summary>
  789. /// 查询半成品信息
  790. /// </summary>
  791. /// <param name="input"></param>
  792. /// <returns></returns>
  793. public async Task<PagedResultDto<SemiProductDto>> GetSemiProductNotContainOld(IwbPagedRequestDto input)
  794. {
  795. var productNoExts =
  796. (await ProductMapperRepository.GetAllListAsync(i => i.PreProductType == 2)).Select(i => i.PreProductNo);
  797. var query = SemiProductRepository.GetAll().Where(a => a.IsLock == "N" && !productNoExts.Contains(a.Id));
  798. if (input.SearchList != null && input.SearchList.Count > 0)
  799. {
  800. List<LambdaObject> objList = new List<LambdaObject>();
  801. foreach (var o in input.SearchList)
  802. {
  803. if (o.KeyWords.IsNullOrEmpty())
  804. continue;
  805. object keyWords = o.KeyWords;
  806. //检查查询条件中带有规格且多个分割条件的
  807. ProductModelSearch.CheckModelGreaterOneFilter(o, ref keyWords);
  808. objList.Add(new LambdaObject
  809. {
  810. FieldType = (LambdaFieldType)o.FieldType,
  811. FieldName = o.KeyField,
  812. FieldValue = keyWords,
  813. ExpType = (LambdaExpType)o.ExpType
  814. });
  815. }
  816. var exp = objList.GetExp<SemiProducts>();
  817. query = exp!=null? query.Where(exp): query;
  818. }
  819. var totalCount = await query.CountAsync();
  820. query = query.OrderByDescending(i => i.TimeCreated);
  821. string pattern = ProductModelSearch.GetModelGreaterOneReg(input.SearchList);
  822. List<SemiProducts> entities;
  823. //检查查询条件中带有规格且多个分割条件的
  824. if (!pattern.IsNullOrEmpty())
  825. {
  826. var es = query.ToList();
  827. es = es.Where(f => f.Model != null && Regex.IsMatch(f.Model, pattern)).ToList();
  828. totalCount = es.Count;
  829. entities = es.Skip(input.SkipCount).Take(input.MaxResultCount).ToList();
  830. }
  831. else
  832. {
  833. query = query.Skip(input.SkipCount).Take(input.MaxResultCount);
  834. entities = await query.ToListAsync();
  835. }
  836. //query = query.Skip(input.SkipCount).Take(input.MaxResultCount);
  837. //var entities = await query.ToListAsync();
  838. var dtos = new PagedResultDto<SemiProductDto>(
  839. totalCount,
  840. entities.Select(ObjectMapper.Map<SemiProductDto>).ToList()
  841. );
  842. return dtos;
  843. }
  844. /**
  845. * 解除订单冻结的库存数量
  846. */
  847. public async Task UnLockOrderStore(OrderItem orderItem)
  848. {
  849. var orderBookStores = await OrderBookStoreRepository.GetAllListAsync(i => i.OrderItemId == orderItem.Id);
  850. foreach (var orderBookStore in orderBookStores)
  851. {
  852. var currentProductStore = await CurrentProductStoreHouseRepository.FirstOrDefaultAsync(i => i.CurrentProductStoreHouseNo ==
  853. orderBookStore.CurrentProductStoreHouseNo);
  854. if (currentProductStore.FreezeQuantity < (orderBookStore.Quantity ?? 0))
  855. {
  856. CheckErrors(IdentityResult.Failed("解除仓库冻结库存异常!解除冻结后结果小于0"));
  857. }
  858. currentProductStore.FreezeQuantity -= orderBookStore.Quantity ?? 0;
  859. currentProductStore.TimeLastMod = Clock.Now;
  860. currentProductStore.UserIDLastMod = AbpSession.UserId.ToString();
  861. await CurrentProductStoreHouseRepository.UpdateAsync(currentProductStore);
  862. //orderBookStore.Status = OrderBookStoreStatusEnum.UnLock.ToInt();
  863. //await OrderBookStoreRepository.UpdateAsync(orderBookStore);//先解锁库存
  864. await OrderBookStoreRepository.DeleteAsync(orderBookStore);//软删除掉锁定的记录
  865. }
  866. BusinessLogTypeEnum.OrderLog.WriteLog(BusinessLogRepository, "订单明细删除解除冻结仓库库存", $"仓库库存解除冻结成功!orderItem:{orderItem.Id},UserId:{AbpSession.UserId}", logExt1: $"{orderBookStores.ToJsonString()}");
  867. }
  868. }
  869. }