QueryAppService.cs 66 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data.Entity;
  4. using System.Globalization;
  5. using System.Linq;
  6. using System.Linq.Dynamic.Core;
  7. using System.Reflection;
  8. using System.Text.RegularExpressions;
  9. using System.Threading.Tasks;
  10. using System.Web.Http.Results;
  11. using System.Web.Mvc;
  12. using System.Web.UI.WebControls;
  13. using System.Xml;
  14. using Abp.Application.Services;
  15. using Abp.Application.Services.Dto;
  16. using Abp.Auditing;
  17. using Abp.Authorization;
  18. using Abp.Domain.Repositories;
  19. using Abp.Extensions;
  20. using Abp.Linq;
  21. using Abp.Linq.Extensions;
  22. using Abp.Runtime.Caching;
  23. using IwbZero.AppServiceBase;
  24. using IwbZero.IdentityFramework;
  25. using IwbZero.Setting;
  26. using Microsoft.AspNet.Identity;
  27. using NPOI.SS.Formula.Functions;
  28. using ShwasherSys.BasicInfo;
  29. using ShwasherSys.BasicInfo.OutFactory;
  30. using ShwasherSys.BasicInfo.OutFactory.Dto;
  31. using ShwasherSys.BasicInfo.StoreHouseLocations.Dto;
  32. using ShwasherSys.Common.Dto;
  33. using ShwasherSys.CompanyInfo;
  34. using ShwasherSys.CompanyInfo.DeviceInfo.Dto;
  35. using ShwasherSys.CompanyInfo.FixedAssetInfo.Dto;
  36. using ShwasherSys.CompanyInfo.MoldInfo.Dto;
  37. using ShwasherSys.CustomerInfo;
  38. using ShwasherSys.CustomerInfo.Dto;
  39. using ShwasherSys.Inspection;
  40. using ShwasherSys.Invoice;
  41. using ShwasherSys.Lambda;
  42. using ShwasherSys.NotificationInfo;
  43. using ShwasherSys.NotificationInfo.Dto;
  44. using ShwasherSys.Order;
  45. using ShwasherSys.OrderSendInfo;
  46. using ShwasherSys.PackageInfo;
  47. using ShwasherSys.ProductInfo;
  48. using ShwasherSys.ProductInfo.Dto;
  49. using ShwasherSys.ProductionOrderInfo;
  50. using ShwasherSys.ProductionOrderInfo.Dto;
  51. using ShwasherSys.ProductStoreInfo;
  52. using ShwasherSys.RmStore;
  53. using ShwasherSys.SemiProductStoreInfo;
  54. using TemplateInfo = ShwasherSys.Inspection.TemplateInfo;
  55. namespace ShwasherSys.Common
  56. {
  57. public interface IQueryAppService : IApplicationService
  58. {
  59. /// <summary>
  60. /// 查询外协厂商信息
  61. /// </summary>
  62. /// <param name="input"></param>
  63. /// <returns></returns>
  64. Task<PagedResultDto<OutFactoryDto>> GetOutFactory(IwbPagedRequestDto input);
  65. /// <summary>
  66. /// 查询客户信息
  67. /// </summary>
  68. /// <param name="input"></param>
  69. /// <returns></returns>
  70. Task<PagedResultDto<CustomerDto>> GetCustomer(IwbPagedRequestDto input);
  71. /// <summary>
  72. /// 查询半成品实时库存信息
  73. /// </summary>
  74. /// <param name="input"></param>
  75. /// <returns></returns>
  76. Task<PagedResultDto<ViewCurrentSemiStoreHouse>> GetCurrentSemiStore(IwbPagedRequestDto input);
  77. /// <summary>
  78. /// 查询半成品信息
  79. /// </summary>
  80. /// <param name="input"></param>
  81. /// <returns></returns>
  82. Task<PagedResultDto<SemiProductDto>> GetSemiProduct(IwbPagedRequestDto input);
  83. Task<string> GetSemiProductName(string id);
  84. Task<SemiProductDto> GetSingleSemiProduct(string input);
  85. /// <summary>
  86. /// 查询产品信息
  87. /// </summary>
  88. /// <param name="input"></param>
  89. /// <returns></returns>
  90. Task<PagedResultDto<ProductDto>> GetProduct(IwbPagedRequestDto input);
  91. Task<Product> GetProductById(EntityDto<string> input);
  92. Task<string> GetProductName(string id);
  93. /// <summary>
  94. /// 查询库位信息
  95. /// </summary>
  96. /// <param name="input"></param>
  97. /// <returns></returns>
  98. Task<PagedResultDto<StoreHouseLocationDto>> GetStoreHouseLocation(IwbPagedRequestDto input);
  99. Task<PagedResultDto<ProductionLogDto>> QueryProductionLog(IwbPagedRequestDto input);
  100. string GetDefualtProductByOrderNo(string orderNo);
  101. string GetDefaultProductByPartNo(string partNo,string orderNo);
  102. string QueryProductByCustomerAndPartNo(string partNo, string customerId) ;
  103. string GetDefualtProductByCustomerId(string customerId);
  104. Customer GetCustomerInfo(EntityDto<string> input);
  105. CustomerSend GetCustomerSendInfo(EntityDto<int> input);
  106. List<CustomerSendDto> GetCustomerSendDtoByCustomerId(CustomerSendDto customerId);
  107. List<SelectListItem> GetProductPropertyList(string pcPropertyName);
  108. List<CurrentProductStoreHouse> QueryStore(string productNo);
  109. List<CurrentProductStoreHouse> QueryStoreFilter(string productNo,string customerId);
  110. BulletinInfo GetBulletinInfo(EntityDto input);
  111. ShortMessage GetShortMsgDetailInfo(ShortMsgDetailDto input);
  112. Task<PagedResultDto<Product>> GetQueryCustomerDefaultProduct(IwbPagedRequestDto input);
  113. List<StoreHouse> QueryStoreHouse(int houseType=0);
  114. List<SelectListItem> QueryStoreHouseSelect(int houseType=0);
  115. string QueryStoreHouseSelectStr(int houseType = 0);
  116. List<ViewSemiEnterStore> QueryEnterStoresByPoNo(string productionOrderNo);
  117. Task<TemplateInfo> QueryTemplate(string tmpKey, int type);
  118. Task<List<Currency>> QueryAllCurrency();
  119. Task<List<CurrencyExchangeRate>> QueryCurrencyRate(string from,string to);
  120. Task<string> GetExpressNameById(int id);
  121. PagedResultDto<ViewEmployee> QueryEmployee(IwbPagedRequestDto input);
  122. Task<PagedResultDto<MoldDto>> QueryMold(IwbPagedRequestDto input);
  123. Task<PagedResultDto<FixedAssetDto>> QueryFixedAsset(IwbPagedRequestDto input);
  124. Task<PagedResultDto<ViewOrderSend>> QuerySendGood(IwbPagedRequestDto input);
  125. Task<PagedResultDto<ViewStickBill>> QueryInvoice(IwbPagedRequestDto input);
  126. Task<PagedResultDto<RmProduct>> GetRmProduct(IwbPagedRequestDto input);
  127. Task<PagedResultDto<ViewCurrentRmStoreHouse>> GetRmCurrentStore(IwbPagedRequestDto input);
  128. Task<PagedResultDto<ViewSemiEnterStore>> GetSemiEnterStoreCheckUnqualified(IwbPagedRequestDto input);
  129. Task<PagedResultDto<ProductPropertyDto>> GetProductProperty(IwbPagedRequestDto input);
  130. Task<string> CalcTaxPrice(int type, string input,string rate);
  131. Task<PagedResultDto<ViewOrderItems>> QueryOrderItem(IwbPagedRequestDto input);
  132. Task<OrderProductProcessDto> QueryOrderProductProcess(int orderItemId);
  133. #region 2023
  134. Task<PagedResultDto<ProductionOrderDto>> QueryProductionOrderDtoByProNo(PagedRequestDto input);
  135. Task<PagedResultDto<ViewCurrentProductStoreHouse>> QueryViewCurrentProductStoreHouseByProNo(
  136. PagedRequestDto input);
  137. Task<PagedResultDto<ViewCurrentSemiStoreHouse>> QueryViewCurrentSemiStoreHouseByProNo(PagedRequestDto input);
  138. #endregion
  139. #region 2024
  140. Task<Dictionary<int, List<DeviceMgPlanDto>>> QueryNeedMaintenanceMoldPlan();
  141. #endregion
  142. }
  143. [AbpAuthorize,DisableAuditing]
  144. public class QueryAppService : ApplicationService, IQueryAppService
  145. {
  146. protected ICacheManager CacheManager { get; set; }
  147. protected new IIwbSettingManager SettingManager { get; set; }
  148. public QueryAppService(
  149. IRepository<Customer,string> customerRepository,
  150. IRepository<ViewCurrentSemiStoreHouse> currentSemiRepository,
  151. IRepository<SemiProducts, string> semiProductRepository,
  152. IRepository<Product, string> productRepository,
  153. IRepository<StoreHouseLocation> shlRepository,
  154. IIwbSettingManager settingManager,
  155. ICacheManager cacheManager, IRepository<CustomerDefaultProduct> customerDefaultProductRepository, IRepository<CustomerSend> customerSendRepository, IRepository<OrderHeader, string> orderHeaderRepository, IRepository<CurrentProductStoreHouse> currentProductStoreHouseRepository, IRepository<BulletinInfo> bulletinInfoRepository, IRepository<ShortMessage> shortMessageRepository, IRepository<ShortMsgDetail> shortMsgDetailRepository, IRepository<StoreHouse> storeHouseRepository, IRepository<ViewSemiEnterStore> viewSemiEnterStoreRepository, IRepository<OutFactory, string> outFactoryRepository, IRepository<TemplateInfo> templateInfoRepository, IRepository<Currency, string> currencyRepository, IRepository<CurrencyExchangeRate> currencyExchangeRateRepository, IRepository<ViewEmployee> viewEmployeeRepository, IRepository<RmProduct, string> rmRepository, IRepository<ViewCurrentRmStoreHouse, string> viewCurrentRmStoreHouseRepository, IRepository<ProductionLog> productionLogRepository, IRepository<CustomerDisabledProduct> customerDisabledProductRepository, IRepository<ExpressLogistics> expressRepository, IRepository<Mold> moldRepository, IRepository<FixedAsset> fixedAssetRepository, IRepository<ViewOrderSend> viewOrderSendRepository, IRepository<ViewStickBill, string> viewStickBillRepository, IRepository<ProductProperty> productPropertyRepository, IRepository<ViewOrderItems> viewOrderItemsRepository, IRepository<OrderProduction> orderProductionRepository, IRepository<ProductionOrder> productionOrderRepository, IRepository<PackageApply> packageApplyRepository, IRepository<ViewCurrentProductStoreHouse> viewCurrentProductStoreHouseRepository, IRepository<ViewCurrentSemiStoreHouse> viewCurrentSemiStoreHouseRepository, IRepository<DeviceMgPlan> deviceMgPlanRepository)
  156. {
  157. CustomerRepository = customerRepository;
  158. CurrentSemiRepository = currentSemiRepository;
  159. SemiProductRepository = semiProductRepository;
  160. ProductRepository = productRepository;
  161. ShlRepository = shlRepository;
  162. CacheManager = cacheManager;
  163. CustomerDefaultProductRepository = customerDefaultProductRepository;
  164. CustomerSendRepository = customerSendRepository;
  165. OrderHeaderRepository = orderHeaderRepository;
  166. CurrentProductStoreHouseRepository = currentProductStoreHouseRepository;
  167. BulletinInfoRepository = bulletinInfoRepository;
  168. SettingManager = settingManager;
  169. ShortMessageRepository = shortMessageRepository;
  170. ShortMsgDetailRepository = shortMsgDetailRepository;
  171. StoreHouseRepository = storeHouseRepository;
  172. ViewSemiEnterStoreRepository = viewSemiEnterStoreRepository;
  173. OutFactoryRepository = outFactoryRepository;
  174. TemplateInfoRepository = templateInfoRepository;
  175. CurrencyRepository = currencyRepository;
  176. CurrencyExchangeRateRepository = currencyExchangeRateRepository;
  177. ViewEmployeeRepository = viewEmployeeRepository;
  178. RmRepository = rmRepository;
  179. ViewCurrentRmStoreHouseRepository = viewCurrentRmStoreHouseRepository;
  180. ProductionLogRepository = productionLogRepository;
  181. CustomerDisabledProductRepository = customerDisabledProductRepository;
  182. ExpressRepository = expressRepository;
  183. MoldRepository = moldRepository;
  184. FixedAssetRepository = fixedAssetRepository;
  185. ViewOrderSendRepository = viewOrderSendRepository;
  186. ViewStickBillRepository = viewStickBillRepository;
  187. ProductPropertyRepository = productPropertyRepository;
  188. ViewOrderItemsRepository = viewOrderItemsRepository;
  189. OrderProductionRepository = orderProductionRepository;
  190. ProductionOrderRepository = productionOrderRepository;
  191. PackageApplyRepository = packageApplyRepository;
  192. ViewCurrentProductStoreHouseRepository = viewCurrentProductStoreHouseRepository;
  193. ViewCurrentSemiStoreHouseRepository = viewCurrentSemiStoreHouseRepository;
  194. AsyncQueryableExecuter = NullAsyncQueryableExecuter.Instance;
  195. DeviceMgPlanRepository = deviceMgPlanRepository;
  196. }
  197. protected IRepository<FixedAsset> FixedAssetRepository { get; }
  198. protected IRepository<Mold> MoldRepository { get; }
  199. protected IRepository<ExpressLogistics> ExpressRepository { get; }
  200. protected IRepository<ProductionLog> ProductionLogRepository { get; }
  201. protected IRepository<OutFactory, string> OutFactoryRepository { get; }
  202. protected IRepository<Customer, string> CustomerRepository { get; }
  203. protected IRepository<ViewCurrentSemiStoreHouse> CurrentSemiRepository { get; }
  204. protected IRepository<SemiProducts, string> SemiProductRepository { get; }
  205. protected IRepository<Product, string> ProductRepository { get; }
  206. public IRepository<StoreHouseLocation> ShlRepository { get; }
  207. protected IRepository<CustomerDefaultProduct> CustomerDefaultProductRepository { get; }
  208. protected IRepository<CustomerSend> CustomerSendRepository { get; }
  209. protected IRepository<OrderHeader, string> OrderHeaderRepository { get; }
  210. protected IRepository<CurrentProductStoreHouse> CurrentProductStoreHouseRepository { get; }
  211. protected IRepository<BulletinInfo> BulletinInfoRepository { get; }
  212. protected IRepository<ShortMessage> ShortMessageRepository { get; }
  213. protected IRepository<ShortMsgDetail> ShortMsgDetailRepository { get; }
  214. protected IRepository<StoreHouse> StoreHouseRepository { get; }
  215. protected IRepository<ViewSemiEnterStore> ViewSemiEnterStoreRepository { get; }
  216. protected IRepository<TemplateInfo> TemplateInfoRepository { get; }
  217. protected IRepository<Currency,string> CurrencyRepository { get; }
  218. protected IRepository<CurrencyExchangeRate> CurrencyExchangeRateRepository { get; }
  219. protected IRepository<ViewEmployee> ViewEmployeeRepository { get; }
  220. protected IRepository<RmProduct,string> RmRepository { get; }
  221. protected IRepository<ViewCurrentRmStoreHouse, string> ViewCurrentRmStoreHouseRepository { get; }
  222. protected IRepository<CustomerDisabledProduct> CustomerDisabledProductRepository { get; }
  223. protected IRepository<ViewOrderSend> ViewOrderSendRepository { get; }
  224. public IAsyncQueryableExecuter AsyncQueryableExecuter { get; set; }
  225. protected IRepository<ProductProperty> ProductPropertyRepository { get; }
  226. protected IRepository<ViewOrderItems> ViewOrderItemsRepository { get; }
  227. protected IRepository<OrderProduction> OrderProductionRepository { get; }
  228. protected IRepository<ProductionOrder> ProductionOrderRepository { get; }
  229. protected IRepository<PackageApply> PackageApplyRepository { get; }
  230. protected IRepository<ViewCurrentProductStoreHouse> ViewCurrentProductStoreHouseRepository { get; }
  231. protected IRepository<ViewCurrentSemiStoreHouse> ViewCurrentSemiStoreHouseRepository { get; }
  232. protected IRepository<DeviceMgPlan> DeviceMgPlanRepository { get; }
  233. /// <summary>
  234. /// 查询快递名称
  235. /// </summary>
  236. /// <param name="id"></param>
  237. /// <returns></returns>
  238. public async Task<string> GetExpressNameById(int id)
  239. {
  240. var express = await ExpressRepository.FirstOrDefaultAsync(a => a.Id == id);
  241. return express?.ExpressName ?? "";
  242. }
  243. /// <summary>
  244. /// 查询外协厂商信息
  245. /// </summary>
  246. /// <param name="input"></param>
  247. /// <returns></returns>
  248. public async Task<PagedResultDto<OutFactoryDto>> GetOutFactory(IwbPagedRequestDto input)
  249. {
  250. var query = OutFactoryRepository.GetAll().Where(a => a.IsLock == "N");
  251. if (input.SearchList != null && input.SearchList.Count > 0)
  252. {
  253. List<LambdaObject> objList = new List<LambdaObject>();
  254. foreach (var o in input.SearchList)
  255. {
  256. if (o.KeyWords.IsNullOrEmpty())
  257. continue;
  258. object keyWords = o.KeyWords;
  259. objList.Add(new LambdaObject
  260. {
  261. FieldType = (LambdaFieldType)o.FieldType,
  262. FieldName = o.KeyField,
  263. FieldValue = keyWords,
  264. ExpType = (LambdaExpType)o.ExpType
  265. });
  266. }
  267. var exp = objList.GetExp<OutFactory>();
  268. query = query.Where(exp);
  269. }
  270. var totalCount = await query.CountAsync();
  271. query = query.OrderByDescending(i => i.TimeCreated);
  272. query = query.Skip(input.SkipCount).Take(input.MaxResultCount);
  273. var entities = await query.ToListAsync();
  274. var dtos = new PagedResultDto<OutFactoryDto>(
  275. totalCount,
  276. entities.Select(ObjectMapper.Map<OutFactoryDto>).ToList()
  277. );
  278. return dtos;
  279. }
  280. /// <summary>
  281. /// 查询客户信息
  282. /// </summary>
  283. /// <param name="input"></param>
  284. /// <returns></returns>
  285. public async Task<PagedResultDto<CustomerDto>> GetCustomer(IwbPagedRequestDto input)
  286. {
  287. var query = CustomerRepository.GetAll().Where(a => a.IsLock == "N");
  288. if (input.SearchList != null && input.SearchList.Count > 0)
  289. {
  290. List<LambdaObject> objList = new List<LambdaObject>();
  291. foreach (var o in input.SearchList)
  292. {
  293. if (o.KeyWords.IsNullOrEmpty())
  294. continue;
  295. object keyWords = o.KeyWords;
  296. objList.Add(new LambdaObject
  297. {
  298. FieldType = (LambdaFieldType)o.FieldType,
  299. FieldName = o.KeyField,
  300. FieldValue = keyWords,
  301. ExpType = (LambdaExpType)o.ExpType
  302. });
  303. }
  304. var exp = objList.GetExp<Customer>();
  305. query = query.Where(exp);
  306. }
  307. var totalCount = await query.CountAsync();
  308. query = query.OrderByDescending(i => i.TimeCreated);
  309. query = query.Skip(input.SkipCount).Take(input.MaxResultCount);
  310. var entities = await query.ToListAsync();
  311. var dtos = new PagedResultDto<CustomerDto>(
  312. totalCount,
  313. entities.Select(ObjectMapper.Map<CustomerDto>).ToList()
  314. );
  315. return dtos;
  316. }
  317. /// <summary>
  318. /// 查询半成品实时库存信息
  319. /// </summary>
  320. /// <param name="input"></param>
  321. /// <returns></returns>
  322. public async Task<PagedResultDto<ViewCurrentSemiStoreHouse>> GetCurrentSemiStore(IwbPagedRequestDto input)
  323. {
  324. var query = CurrentSemiRepository.GetAll();
  325. if (input.SearchList != null && input.SearchList.Count > 0)
  326. {
  327. List<LambdaObject> objList = new List<LambdaObject>();
  328. foreach (var o in input.SearchList)
  329. {
  330. if (o.KeyWords.IsNullOrEmpty())
  331. continue;
  332. object keyWords = o.KeyWords;
  333. objList.Add(new LambdaObject
  334. {
  335. FieldType = (LambdaFieldType)o.FieldType,
  336. FieldName = o.KeyField,
  337. FieldValue = keyWords,
  338. ExpType = (LambdaExpType)o.ExpType
  339. });
  340. }
  341. var exp = objList.GetExp<ViewCurrentSemiStoreHouse>();
  342. query = query.Where(exp);
  343. }
  344. query = query.Where(i => (i.ActualQuantity - i.FreezeQuantity) > 0);//过滤掉可用数量小于等于0
  345. var totalCount = await query.CountAsync();
  346. query = query.OrderByDescending(i => i.TimeCreated);
  347. query = query.Skip(input.SkipCount).Take(input.MaxResultCount);
  348. var entities = await query.ToListAsync();
  349. var dtos = new PagedResultDto<ViewCurrentSemiStoreHouse>(totalCount,entities);
  350. return dtos;
  351. }
  352. /// <summary>
  353. /// 查询半成品信息
  354. /// </summary>
  355. /// <param name="input"></param>
  356. /// <returns></returns>
  357. public async Task<PagedResultDto<SemiProductDto>> GetSemiProduct(IwbPagedRequestDto input)
  358. {
  359. var query = SemiProductRepository.GetAll().Where(a => a.IsLock == "N");
  360. if (input.SearchList != null && input.SearchList.Count > 0)
  361. {
  362. List<LambdaObject> objList = new List<LambdaObject>();
  363. foreach (var o in input.SearchList)
  364. {
  365. if (o.KeyWords.IsNullOrEmpty())
  366. continue;
  367. object keyWords = o.KeyWords;
  368. //检查查询条件中带有规格且多个分割条件的
  369. ProductModelSearch.CheckModelGreaterOneFilter(o, ref keyWords);
  370. objList.Add(new LambdaObject
  371. {
  372. FieldType = (LambdaFieldType)o.FieldType,
  373. FieldName = o.KeyField,
  374. FieldValue = keyWords,
  375. ExpType = (LambdaExpType)o.ExpType
  376. });
  377. }
  378. var exp = objList.GetExp<SemiProducts>();
  379. query = query.Where(exp);
  380. }
  381. var totalCount = await query.CountAsync();
  382. query = query.OrderByDescending(i => i.TimeCreated);
  383. //query = query.Skip(input.SkipCount).Take(input.MaxResultCount);
  384. //var entities = await query.ToListAsync();
  385. string pattern = ProductModelSearch.GetModelGreaterOneReg(input.SearchList);
  386. List<SemiProducts> entities;
  387. //检查查询条件中带有规格且多个分割条件的
  388. if (!pattern.IsNullOrEmpty())
  389. {
  390. var es = query.ToList();
  391. es = es.Where(f => f.Model != null && Regex.IsMatch(f.Model, pattern)).ToList();
  392. totalCount = es.Count;
  393. entities = es.Skip(input.SkipCount).Take(input.MaxResultCount).ToList();
  394. }
  395. else
  396. {
  397. query = query.Skip(input.SkipCount).Take(input.MaxResultCount);
  398. entities = await AsyncQueryableExecuter.ToListAsync(query);
  399. }
  400. var dtos = new PagedResultDto<SemiProductDto>(
  401. totalCount,
  402. entities.Select(ObjectMapper.Map<SemiProductDto>).ToList()
  403. );
  404. return dtos;
  405. }
  406. public async Task<SemiProductDto> GetSingleSemiProduct(string input)
  407. {
  408. var query = await SemiProductRepository.FirstOrDefaultAsync(i=>i.Id==input);
  409. return ObjectMapper.Map<SemiProductDto>(query);
  410. }
  411. public async Task<string> GetSemiProductName(string id)
  412. {
  413. var entity = await CacheManager.GetCache(ShwasherConsts.SemiProductCache)
  414. .GetAsync(id, () => SemiProductRepository.FirstOrDefaultAsync(i => i.Id == id));
  415. return entity?.SemiProductName ?? "";
  416. }
  417. public async Task<string> GetProductName(string id)
  418. {
  419. var entity = await CacheManager.GetCache(ShwasherConsts.FinshedProductCache)
  420. .GetAsync(id, () => ProductRepository.FirstOrDefaultAsync(i => i.Id == id));
  421. return entity?.ProductName ?? "";
  422. }
  423. /// <summary>
  424. /// 查询产品信息
  425. /// </summary>
  426. /// <param name="input"></param>
  427. /// <returns></returns>
  428. public async Task<PagedResultDto<ProductDto>> GetProduct(IwbPagedRequestDto input)
  429. {
  430. var query = ProductRepository.GetAll().Where(a => a.IsLock == "N");
  431. if (input.SearchList != null && input.SearchList.Count > 0)
  432. {
  433. List<LambdaObject> objList = new List<LambdaObject>();
  434. foreach (var o in input.SearchList)
  435. {
  436. if (o.KeyWords.IsNullOrEmpty())
  437. continue;
  438. object keyWords = o.KeyWords;
  439. //检查查询条件中带有规格且多个分割条件的
  440. ProductModelSearch.CheckModelGreaterOneFilter(o, ref keyWords);
  441. objList.Add(new LambdaObject
  442. {
  443. FieldType = (LambdaFieldType)o.FieldType,
  444. FieldName = o.KeyField,
  445. FieldValue = keyWords,
  446. ExpType = (LambdaExpType)o.ExpType
  447. });
  448. }
  449. var exp = objList.GetExp<Product>();
  450. query = query.Where(exp);
  451. }
  452. var totalCount = await query.CountAsync();
  453. query = !input.Sorting.IsNullOrWhiteSpace() ? query.OrderBy(input.Sorting) : query.OrderByDescending(i => i.TimeCreated);
  454. string pattern = ProductModelSearch.GetModelGreaterOneReg(input.SearchList);
  455. List<Product> entities;
  456. //检查查询条件中带有规格且多个分割条件的
  457. if (!pattern.IsNullOrEmpty())
  458. {
  459. var es = query.ToList();
  460. es = es.Where(f => f.Model != null && Regex.IsMatch(f.Model, pattern)).ToList();
  461. totalCount = es.Count;
  462. entities = es.Skip(input.SkipCount).Take(input.MaxResultCount).ToList();
  463. }
  464. else
  465. {
  466. query = query.Skip(input.SkipCount).Take(input.MaxResultCount);
  467. entities = await AsyncQueryableExecuter.ToListAsync(query);
  468. }
  469. //query = query.Skip(input.SkipCount).Take(input.MaxResultCount);
  470. //var entities = await query.ToListAsync();
  471. var dtos = new PagedResultDto<ProductDto>(
  472. totalCount,
  473. entities.Select(ObjectMapper.Map<ProductDto>).ToList()
  474. );
  475. return dtos;
  476. }
  477. public async Task<Product> GetProductById(EntityDto<string> input)
  478. {
  479. return await ProductRepository.FirstOrDefaultAsync(input.Id);
  480. }
  481. /// <summary>
  482. /// 查询库位信息
  483. /// </summary>
  484. /// <param name="input"></param>
  485. /// <returns></returns>
  486. public async Task<PagedResultDto<StoreHouseLocationDto>> GetStoreHouseLocation(IwbPagedRequestDto input)
  487. {
  488. var query = ShlRepository.GetAll();
  489. if (input.SearchList != null && input.SearchList.Count > 0)
  490. {
  491. List<LambdaObject> objList = new List<LambdaObject>();
  492. foreach (var o in input.SearchList)
  493. {
  494. if (o.KeyWords.IsNullOrEmpty())
  495. continue;
  496. object keyWords = o.KeyWords;
  497. objList.Add(new LambdaObject
  498. {
  499. FieldType = (LambdaFieldType)o.FieldType,
  500. FieldName = o.KeyField,
  501. FieldValue = keyWords,
  502. ExpType = (LambdaExpType)o.ExpType
  503. });
  504. }
  505. var exp = objList.GetExp<StoreHouseLocation>();
  506. query = query.Where(exp);
  507. }
  508. var totalCount = await query.CountAsync();
  509. query = query.OrderByDescending(i => i.CreationTime);
  510. query = query.Skip(input.SkipCount).Take(input.MaxResultCount);
  511. var entities = await query.ToListAsync();
  512. var dtos = new PagedResultDto<StoreHouseLocationDto>(
  513. totalCount,
  514. entities.Select(ObjectMapper.Map<StoreHouseLocationDto>).ToList()
  515. );
  516. return dtos;
  517. }
  518. /// <summary>
  519. /// 根据订单号查询当前客户默认的产品
  520. /// </summary>
  521. /// <param name="orderNo"></param>
  522. /// <returns></returns>
  523. public string GetDefualtProductByOrderNo(string orderNo)
  524. {
  525. var orderHeader = OrderHeaderRepository.Get(orderNo);
  526. return GetDefualtProductByCustomerId(orderHeader.CustomerId);
  527. }
  528. /// <summary>
  529. /// 根据订单号和零件号查询当前客户默认的产品
  530. /// </summary>
  531. /// <param name="partNo"></param>
  532. /// <param name="orderNo"></param>
  533. /// <returns></returns>
  534. public string GetDefaultProductByPartNo(string partNo,string orderNo)
  535. {
  536. var orderHeader = OrderHeaderRepository.Get(orderNo);
  537. var defaultProduct = CustomerDefaultProductRepository.FirstOrDefault(i => i.CustomerId == orderHeader.CustomerId&&i.PartNo== partNo);
  538. if (defaultProduct != null)
  539. {
  540. return defaultProduct.ProductNo;
  541. }
  542. return "";
  543. }
  544. /// <summary>
  545. /// 根据订单号和客户编码查询当前客户默认的产品
  546. /// </summary>
  547. /// <param name="partNo"></param>
  548. /// <param name="customerId"></param>
  549. /// <returns></returns>
  550. public string QueryProductByCustomerAndPartNo(string partNo, string customerId)
  551. {
  552. var defaultProduct = CustomerDefaultProductRepository.FirstOrDefault(i => i.CustomerId == customerId && i.PartNo == partNo);
  553. if (defaultProduct != null)
  554. {
  555. return defaultProduct.ProductNo;
  556. }
  557. return "";
  558. }
  559. /// <summary>
  560. /// 根据客户号查询当前客户默认的产品
  561. /// </summary>
  562. /// <param name="orderNo"></param>
  563. /// <returns></returns>
  564. public string GetDefualtProductByCustomerId(string customerId)
  565. {
  566. var defualtProducts = CustomerDefaultProductRepository.GetAll().Where(i => i.CustomerId == customerId);
  567. string lcRetval = "";
  568. foreach (var item in defualtProducts)
  569. {
  570. lcRetval += $"<option value=\"{item.ProductNo}\">{item.ProductNo}</option>";
  571. }
  572. return lcRetval;
  573. }
  574. public Customer GetCustomerInfo(EntityDto<string> input)
  575. {
  576. return CustomerRepository.FirstOrDefault(input.Id);
  577. }
  578. public CustomerSend GetCustomerSendInfo(EntityDto<int> input)
  579. {
  580. return CustomerSendRepository.FirstOrDefault(input.Id);
  581. }
  582. [DisableAuditing]
  583. public List<SelectListItem> GetProductPropertyList(string pcPropertyName)
  584. {
  585. var objList = new List<SelectListItem>();
  586. if (pcPropertyName.IsNullOrEmpty())
  587. {
  588. return objList;
  589. }
  590. var entitys = ProductRepository.GetAll().Where(i => i.IsLock == "N");
  591. var loPropertyInfo = typeof(Product).GetProperty(pcPropertyName,
  592. BindingFlags.GetProperty | BindingFlags.Instance | BindingFlags.Public);
  593. if (loPropertyInfo == null)
  594. {
  595. throw new ArgumentException($"{pcPropertyName} is not a property of type {typeof(Product)}.");
  596. }
  597. IQueryable<string> query = null;
  598. switch (pcPropertyName)
  599. {
  600. case "Material":
  601. query = entitys.Select(i => i.Material).Distinct();
  602. break;
  603. case "SurfaceColor":
  604. query = entitys.Select(i => i.SurfaceColor).Distinct();
  605. break;
  606. case "Rigidity":
  607. query = entitys.Select(i => i.Rigidity).Distinct();
  608. break;
  609. }
  610. if (query != null)
  611. {
  612. foreach (var product in query)
  613. {
  614. objList.Add(new SelectListItem()
  615. {
  616. Text = product,
  617. Value = product
  618. });
  619. }
  620. }
  621. return objList;
  622. }
  623. #region 库存记录查询
  624. public List<CurrentProductStoreHouse> QueryStore(string productNo)
  625. {
  626. if (string.IsNullOrEmpty(productNo))
  627. {
  628. CheckErrors(IwbIdentityResult.Failed("请求的产品编码不存在!"));
  629. }
  630. var entity = CurrentProductStoreHouseRepository.GetAll().Where(i => i.ProductNo == productNo && (i.Quantity > 0||i.ProductionOrderNo.StartsWith("VS"))).OrderByDescending(i => i.TimeLastMod);
  631. List<CurrentProductStoreHouse> productionOrder = new List<CurrentProductStoreHouse>();
  632. List<CurrentProductStoreHouse> hasProductionOrder = new List<CurrentProductStoreHouse>();
  633. if (entity.Any())
  634. {
  635. productionOrder = entity.Where(i => string.IsNullOrEmpty(i.ProductionOrderNo)).ToList();
  636. hasProductionOrder = entity.Where(i => !string.IsNullOrEmpty(i.ProductionOrderNo)).ToList();
  637. }
  638. productionOrder.AddRange(hasProductionOrder);
  639. return productionOrder;
  640. }
  641. public List<CurrentProductStoreHouse> QueryStoreFilter(string productNo,string customerId)
  642. {
  643. if (string.IsNullOrEmpty(productNo))
  644. {
  645. CheckErrors(IwbIdentityResult.Failed("请求的产品编码不存在!"));
  646. }
  647. var entity = CurrentProductStoreHouseRepository.GetAll().Where(i => i.ProductNo == productNo && (i.Quantity > 0 || i.ProductionOrderNo.StartsWith("VS"))&&i.InventoryCheckState!=2);
  648. var disabledOrderNo = CustomerDisabledProductRepository.GetAll().Where(i => i.CustomerNo == customerId)
  649. .Select(i => i.ProductOrderNo).Distinct();
  650. entity = entity.Where(i => !disabledOrderNo.Contains(i.ProductionOrderNo))
  651. .OrderByDescending(i => i.TimeLastMod);
  652. List<CurrentProductStoreHouse> productionOrder = new List<CurrentProductStoreHouse>();
  653. List<CurrentProductStoreHouse> hasProductionOrder = new List<CurrentProductStoreHouse>();
  654. if (entity.Any())
  655. {
  656. productionOrder = entity.Where(i => string.IsNullOrEmpty(i.ProductionOrderNo)&& i.Quantity>0).ToList();
  657. hasProductionOrder = entity.Where(i => !string.IsNullOrEmpty(i.ProductionOrderNo)&& i.Quantity>0).ToList();
  658. }
  659. productionOrder.AddRange(hasProductionOrder);
  660. return productionOrder;
  661. }
  662. #endregion
  663. public BulletinInfo GetBulletinInfo(EntityDto input)
  664. {
  665. var entity = BulletinInfoRepository.FirstOrDefault(i => i.Id == input.Id);
  666. return entity;
  667. }
  668. protected virtual void CheckErrors(IdentityResult identityResult)
  669. {
  670. identityResult.CheckErrors(LocalizationManager);
  671. }
  672. protected virtual void CheckErrors(String error)
  673. {
  674. var identityResult = IdentityResult.Failed(error);
  675. CheckErrors(identityResult);
  676. //identityResult.CheckErrors(LocalizationManager);
  677. }
  678. public ShortMessage GetShortMsgDetailInfo(ShortMsgDetailDto input)
  679. {
  680. var entity = ShortMessageRepository.FirstOrDefault(input.MsgID);
  681. var detailInfo = ShortMsgDetailRepository.FirstOrDefault(input.Id);
  682. detailInfo.IsRead = "Y";
  683. ShortMsgDetailRepository.UpdateAsync(detailInfo);
  684. return entity;
  685. }
  686. public List<CustomerSendDto> GetCustomerSendDtoByCustomerId(CustomerSendDto customerId)
  687. {
  688. var entities = CustomerSendRepository.GetAll().Where(i => i.CustomerId == customerId.CustomerId && i.IsLock == "N");
  689. return ObjectMapper.Map<List<CustomerSendDto>>(entities.ToList());
  690. }
  691. public async Task<PagedResultDto<Product>> GetQueryCustomerDefaultProduct(IwbPagedRequestDto input)
  692. {
  693. var query = ProductRepository.GetAll();
  694. query = query.Where(i => i.IsLock == "N");
  695. string lcCustomerId = "";
  696. if (input.SearchList != null && input.SearchList.Count > 0)
  697. {
  698. List<LambdaObject> objList = new List<LambdaObject>();
  699. foreach (var o in input.SearchList)
  700. {
  701. if (o.KeyWords.IsNullOrEmpty())
  702. continue;
  703. object keyWords = o.KeyWords;
  704. if (o.KeyField == "CustomerId" || o.KeyField == "customerId")
  705. {
  706. lcCustomerId = keyWords + "";
  707. continue;
  708. }
  709. objList.Add(new LambdaObject
  710. {
  711. FieldType = (LambdaFieldType)o.FieldType,
  712. FieldName = o.KeyField,
  713. FieldValue = keyWords,
  714. ExpType = (LambdaExpType)o.ExpType
  715. });
  716. }
  717. var exp = objList.GetExp<Product>();
  718. if (exp != null)
  719. {
  720. query = query.Where(exp);
  721. }
  722. }
  723. List<string> loNotContain = new List<string>();
  724. if (!lcCustomerId.IsNullOrEmpty())
  725. {
  726. var loDefualtProducts = CustomerDefaultProductRepository.GetAll().Where(i => i.CustomerId == lcCustomerId);
  727. foreach (CustomerDefaultProduct defaultProduct in loDefualtProducts)
  728. {
  729. loNotContain.Add(defaultProduct.ProductNo);
  730. }
  731. }
  732. if (loNotContain.Any())
  733. {
  734. query = query.Where(i => !loNotContain.Contains(i.Id));
  735. }
  736. var totalCount = query.Count();
  737. query = query.SortBy("Id");
  738. query = query.Skip(input.SkipCount).Take(input.MaxResultCount);
  739. var entities = query.ToList();
  740. var dtos = new PagedResultDto<Product>(
  741. totalCount,
  742. entities
  743. );
  744. return dtos;
  745. }
  746. public async Task<PagedResultDto<ProductionLogDto>> QueryProductionLog(IwbPagedRequestDto input)
  747. {
  748. var query = ProductionLogRepository.GetAllIncluding(a=>a.EmployeeInfo);
  749. query = ApplyFilter<ProductionLog>(query,input);
  750. var totalCount = await AsyncQueryableExecuter.CountAsync(query);
  751. query = query.OrderBy(a=>a.CreationTime);
  752. query = _ApplyPaging(query, input);
  753. var entities = await AsyncQueryableExecuter.ToListAsync(query);
  754. var dtoList = new PagedResultDto<ProductionLogDto>(totalCount, entities.Select(a=>new ProductionLogDto
  755. {
  756. Id = a.Id,
  757. ProductionNo = a.ProductionNo,
  758. ProductOrderNo = a.ProductOrderNo,
  759. EmployeeId = a.EmployeeId,
  760. EmployeeNo = a.EmployeeInfo.No,
  761. EmployeeName = a.EmployeeInfo.Name,
  762. CarNo = a.CarNo,
  763. QuantityWeight = a.QuantityWeight,
  764. QuantityPcs = a.QuantityPcs,
  765. KgWeight = a.KgWeight,
  766. CreationTime = a.CreationTime
  767. }).ToList());
  768. return dtoList;
  769. }
  770. public List<StoreHouse> QueryStoreHouse(int houseType=0)
  771. {
  772. /*List<StoreHouse> result = CacheManager.GetCache(ShwasherConsts.StoreHouseCache).Get("All",
  773. () => { return StoreHouseRepository.GetAllList(i => i.IsLock == "N"); });*/
  774. var query = StoreHouseRepository.GetAll().Where(i => i.IsLock == "N" );
  775. if (houseType > 0)
  776. {
  777. query = query.Where(i => i.StoreHouseTypeId == houseType);
  778. }
  779. return query.ToList();
  780. }
  781. public List<SelectListItem> QueryStoreHouseSelect(int houseType=0)
  782. {
  783. var query = StoreHouseRepository.GetAll().Where(i => i.IsLock == "N");
  784. if (houseType > 0)
  785. {
  786. query = query.Where(i => i.StoreHouseTypeId == houseType);
  787. }
  788. List<SelectListItem> resultList = new List<SelectListItem>()
  789. {
  790. new SelectListItem()
  791. {
  792. Text = @"请选择仓库...",
  793. Value = "",
  794. Selected = true
  795. }
  796. };
  797. foreach (var entityHouse in query)
  798. {
  799. SelectListItem item = new SelectListItem()
  800. {
  801. Text = entityHouse.StoreHouseName,
  802. Value = entityHouse.Id.ToString()
  803. };
  804. resultList.Add(item);
  805. }
  806. return resultList;
  807. }
  808. public string QueryStoreHouseSelectStr(int houseType=0)
  809. {
  810. var query = StoreHouseRepository.GetAll().Where(i => i.IsLock == "N");
  811. if (houseType > 0)
  812. {
  813. query = query.Where(i => i.StoreHouseTypeId == houseType);
  814. }
  815. string str = "";// "<option data-type=\"\" value=\"\">请选择仓库...</option>";
  816. foreach (var l in query)
  817. {
  818. str += $"<option data-type=\"{l.StoreHouseTypeId}\" value=\"{l.Id}\">{l.StoreHouseName}</option>";
  819. }
  820. return str;
  821. }
  822. public List<ViewSemiEnterStore> QueryEnterStoresByPoNo(string productionOrderNo)
  823. {
  824. var entities = ViewSemiEnterStoreRepository.GetAllList(i => i.ProductionOrderNo == productionOrderNo);
  825. return entities;
  826. }
  827. public async Task<TemplateInfo> QueryTemplate(string tmpKey, int type)
  828. {
  829. var tmps =await TemplateInfoRepository.FirstOrDefaultAsync(i => i.TempKey == tmpKey && i.Type == type);
  830. return tmps;
  831. }
  832. public async Task<List<Currency>> QueryAllCurrency()
  833. {
  834. return await CurrencyRepository.GetAllListAsync();
  835. }
  836. public async Task<List<CurrencyExchangeRate>> QueryCurrencyRate(string from="", string to="")
  837. {
  838. if (from.IsNullOrEmpty()&&!to.IsNullOrEmpty())
  839. {
  840. return await CurrencyExchangeRateRepository.GetAllListAsync(i => i.ToCurrencyId == to);
  841. }
  842. else if (!from.IsNullOrEmpty() && to.IsNullOrEmpty())
  843. {
  844. return await CurrencyExchangeRateRepository.GetAllListAsync(i => i.FromCurrencyId == from );
  845. }
  846. else
  847. {
  848. return await CurrencyExchangeRateRepository.GetAllListAsync(i => i.FromCurrencyId == from && i.ToCurrencyId == to);
  849. }
  850. }
  851. public PagedResultDto<ViewEmployee> QueryEmployee(IwbPagedRequestDto input)
  852. {
  853. var query = ViewEmployeeRepository.GetAll();
  854. if (input.SearchList != null && input.SearchList.Count > 0)
  855. {
  856. List<LambdaObject> objList = new List<LambdaObject>();
  857. foreach (var o in input.SearchList)
  858. {
  859. if (o.KeyWords.IsNullOrEmpty())
  860. continue;
  861. object keyWords = o.KeyWords;
  862. objList.Add(new LambdaObject
  863. {
  864. FieldType = (LambdaFieldType)o.FieldType,
  865. FieldName = o.KeyField,
  866. FieldValue = keyWords,
  867. ExpType = (LambdaExpType)o.ExpType
  868. });
  869. }
  870. var exp = objList.GetExp<ViewEmployee>();
  871. if (exp != null)
  872. {
  873. query = query.Where(exp);
  874. }
  875. }
  876. var totalCount = query.Count();
  877. query = query.SortBy("No");
  878. query = query.Skip(input.SkipCount).Take(input.MaxResultCount);
  879. var entities = query.ToList();
  880. var dtos = new PagedResultDto<ViewEmployee>(
  881. totalCount,
  882. entities
  883. );
  884. return dtos;
  885. }
  886. /// <summary>
  887. /// 查询模具信息
  888. /// </summary>
  889. /// <param name="input"></param>
  890. /// <returns></returns>
  891. public async Task<PagedResultDto<MoldDto>> QueryMold(IwbPagedRequestDto input)
  892. {
  893. var query = MoldRepository.GetAll();
  894. query = ApplyFilter(query,input);
  895. var totalCount = await AsyncQueryableExecuter.CountAsync(query);
  896. query = _ApplySorting(query, input);
  897. query = _ApplyPaging(query, input);
  898. var entities = await AsyncQueryableExecuter.ToListAsync(query);
  899. var dtoList = new PagedResultDto<MoldDto>(totalCount, entities.Select(ObjectMapper.Map<MoldDto>).ToList());
  900. return dtoList;
  901. }
  902. /// <summary>
  903. /// 查询模具信息
  904. /// </summary>
  905. /// <param name="input"></param>
  906. /// <returns></returns>
  907. public async Task<PagedResultDto<FixedAssetDto>> QueryFixedAsset(IwbPagedRequestDto input)
  908. {
  909. var query = FixedAssetRepository.GetAll();
  910. query = ApplyFilter(query,input);
  911. var totalCount = await AsyncQueryableExecuter.CountAsync(query);
  912. query = _ApplySorting(query, input);
  913. query = _ApplyPaging(query, input);
  914. var entities = await AsyncQueryableExecuter.ToListAsync(query);
  915. var dtoList = new PagedResultDto<FixedAssetDto>(totalCount, entities.Select(ObjectMapper.Map<FixedAssetDto>).ToList());
  916. return dtoList;
  917. }
  918. /// <summary>
  919. /// 查询发货明细信息
  920. /// </summary>
  921. /// <param name="input"></param>
  922. /// <returns></returns>
  923. public async Task<PagedResultDto<ViewOrderSend>> QuerySendGood(IwbPagedRequestDto input)
  924. {
  925. var query = ViewOrderSendRepository.GetAll().Where(a=>!string.IsNullOrEmpty(a.OrderSendBillNo));
  926. query = ApplyFilter(query,input);
  927. var totalCount = await AsyncQueryableExecuter.CountAsync(query);
  928. query = query.OrderByDescending(a=>a.OrderItemId);
  929. query = _ApplyPaging(query, input);
  930. var entities = await AsyncQueryableExecuter.ToListAsync(query);
  931. var dtoList = new PagedResultDto<ViewOrderSend>(totalCount, entities);
  932. return dtoList;
  933. }
  934. protected IRepository<ViewStickBill, string> ViewStickBillRepository { get; }
  935. /// <summary>
  936. /// 查询发票信息
  937. /// </summary>
  938. /// <param name="input"></param>
  939. /// <returns></returns>
  940. public async Task<PagedResultDto<ViewStickBill>> QueryInvoice(IwbPagedRequestDto input)
  941. {
  942. var query = ViewStickBillRepository.GetAll();
  943. query = ApplyFilter(query,input);
  944. var totalCount = await AsyncQueryableExecuter.CountAsync(query);
  945. query = query.OrderByDescending(a=>a.TimeCreated);
  946. query = _ApplyPaging(query, input);
  947. var entities = await AsyncQueryableExecuter.ToListAsync(query);
  948. var dtoList = new PagedResultDto<ViewStickBill>(totalCount, entities);
  949. return dtoList;
  950. }
  951. public async Task<PagedResultDto<RmProduct>> GetRmProduct(IwbPagedRequestDto input)
  952. {
  953. var query = RmRepository.GetAll();
  954. query = ApplyFilter<RmProduct>(query,input);
  955. var totalCount = await AsyncQueryableExecuter.CountAsync(query);
  956. query = _ApplySorting(query, input);
  957. query = _ApplyPaging(query, input);
  958. var entities = await AsyncQueryableExecuter.ToListAsync(query);
  959. var dtoList = new PagedResultDto<RmProduct>(totalCount, entities);
  960. return dtoList;
  961. }
  962. public async Task<PagedResultDto<ViewCurrentRmStoreHouse>> GetRmCurrentStore(IwbPagedRequestDto input)
  963. {
  964. var query = ViewCurrentRmStoreHouseRepository.GetAll();
  965. query = ApplyFilter<ViewCurrentRmStoreHouse>(query, input);
  966. var totalCount = await AsyncQueryableExecuter.CountAsync(query);
  967. query = _ApplySorting(query, input);
  968. query = _ApplyPaging(query, input);
  969. var entities = await AsyncQueryableExecuter.ToListAsync(query);
  970. var dtoList = new PagedResultDto<ViewCurrentRmStoreHouse>(totalCount, entities);
  971. return dtoList;
  972. }
  973. public async Task<PagedResultDto<ViewSemiEnterStore>> GetSemiEnterStoreCheckUnqualified(IwbPagedRequestDto input)
  974. {
  975. var checkState = EnterStoreApplyStatusEnum.UnChecked.ToInt() + "";
  976. var query = ViewSemiEnterStoreRepository.GetAll().Where(a => a.ApplyStatus == checkState);
  977. query = ApplyFilter<ViewSemiEnterStore>(query, input);
  978. var totalCount = query.Count();
  979. query = query.OrderByDescending(i => i.TimeCreated);
  980. query = query.Skip(input.SkipCount).Take(input.MaxResultCount);
  981. var entities = await AsyncQueryableExecuter.ToListAsync(query);
  982. var dots = new PagedResultDto<ViewSemiEnterStore>(
  983. totalCount, entities
  984. );
  985. return dots;
  986. }
  987. /// <summary>
  988. /// 查询产品属性
  989. /// </summary>
  990. /// <param name="input"></param>
  991. /// <returns></returns>
  992. public async Task<PagedResultDto<ProductPropertyDto>> GetProductProperty(IwbPagedRequestDto input)
  993. {
  994. var query = ProductPropertyRepository.GetAll();
  995. query = ApplyFilter(query, input);
  996. var totalCount = await AsyncQueryableExecuter.CountAsync(query);
  997. query = _ApplySorting(query, input);
  998. query = _ApplyPaging(query, input);
  999. var entities = await AsyncQueryableExecuter.ToListAsync(query);
  1000. var dtoList = new PagedResultDto<ProductPropertyDto>(totalCount, entities.Select(ObjectMapper.Map<ProductPropertyDto>).ToList());
  1001. return dtoList;
  1002. }
  1003. /// <summary>
  1004. /// 查询订单明细信息
  1005. /// </summary>
  1006. /// <param name="input"></param>
  1007. /// <returns></returns>
  1008. public async Task<PagedResultDto<ViewOrderItems>> QueryOrderItem(IwbPagedRequestDto input)
  1009. {
  1010. var query = ViewOrderItemsRepository.GetAll();
  1011. query = ApplyFilter(query, input);
  1012. var totalCount = await AsyncQueryableExecuter.CountAsync(query);
  1013. query = query.OrderByDescending(a => a.SendDate);
  1014. string pattern = ProductModelSearch.GetModelGreaterOneReg(input.SearchList);
  1015. List<ViewOrderItems> entities;
  1016. //检查查询条件中带有规格且多个分割条件的
  1017. if (!pattern.IsNullOrEmpty())
  1018. {
  1019. var es = query.ToList();
  1020. es = es.Where(f => f.Model != null && Regex.IsMatch(f.Model, pattern)).ToList();
  1021. totalCount = es.Count;
  1022. entities = es.Skip(input.SkipCount).Take(input.MaxResultCount).ToList();
  1023. }
  1024. else
  1025. {
  1026. query = query.Skip(input.SkipCount).Take(input.MaxResultCount);
  1027. entities = await AsyncQueryableExecuter.ToListAsync(query);
  1028. }
  1029. //query = _ApplyPaging(query, input);
  1030. //var entities = await AsyncQueryableExecuter.ToListAsync(query);
  1031. var dtoList = new PagedResultDto<ViewOrderItems>(totalCount, entities);
  1032. return dtoList;
  1033. }
  1034. public async Task<OrderProductProcessDto> QueryOrderProductProcess(int orderItemId)
  1035. {
  1036. OrderProductProcessDto result = new OrderProductProcessDto();
  1037. var rs = OrderProductionRepository.GetAllList(i => i.OrderItemId == orderItemId);
  1038. if (rs.Any())
  1039. {
  1040. var productionNoArr = rs.Select(i => i.ProductionOrderNo);
  1041. List<PackageApply> pas =
  1042. await PackageApplyRepository.GetAllListAsync(i => productionNoArr.Contains(i.ProductionOrderNo));
  1043. List<ProductionOrder> pos = await ProductionOrderRepository.GetAllListAsync(i => productionNoArr.Contains(i.ProductionOrderNo));
  1044. result.PackageApplyList = pas;
  1045. result.ProductionOrderList = pos;
  1046. }
  1047. return result;
  1048. }
  1049. protected IQueryable<T> ApplyFilter<T>(IQueryable<T> query, IwbPagedRequestDto input)
  1050. {
  1051. var pagedInput = input as IIwbPagedRequest;
  1052. if (pagedInput == null)
  1053. {
  1054. return query;
  1055. }
  1056. if (!string.IsNullOrEmpty(pagedInput.KeyWords))
  1057. {
  1058. object keyWords = pagedInput.KeyWords;
  1059. LambdaObject obj = new LambdaObject()
  1060. {
  1061. FieldType = (LambdaFieldType)pagedInput.FieldType,
  1062. FieldName = pagedInput.KeyField,
  1063. FieldValue = keyWords,
  1064. ExpType = (LambdaExpType)pagedInput.ExpType
  1065. };
  1066. var exp = obj.GetExp<T>();
  1067. query = exp != null ? query.Where(exp) : query;
  1068. }
  1069. if (pagedInput.SearchList != null && pagedInput.SearchList.Count > 0)
  1070. {
  1071. List<LambdaObject> objList = new List<LambdaObject>();
  1072. foreach (var o in pagedInput.SearchList)
  1073. {
  1074. if (string.IsNullOrEmpty(o.KeyWords))
  1075. continue;
  1076. object keyWords = o.KeyWords;
  1077. //检查查询条件中带有规格且多个分割条件的
  1078. ProductModelSearch.CheckModelGreaterOneFilter(o, ref keyWords);
  1079. objList.Add(new LambdaObject
  1080. {
  1081. FieldType = (LambdaFieldType)o.FieldType,
  1082. FieldName = o.KeyField,
  1083. FieldValue = keyWords,
  1084. ExpType = (LambdaExpType)o.ExpType
  1085. });
  1086. }
  1087. var exp = objList.GetExp<T>();
  1088. query = exp != null ? query.Where(exp) : query;
  1089. }
  1090. return query;
  1091. }
  1092. /// <summary>
  1093. /// 分页
  1094. /// </summary>
  1095. /// <param name="query">The query.</param>
  1096. /// <param name="input">The input.</param>
  1097. protected IQueryable<T> _ApplyPaging<T>(IQueryable<T> query, IwbPagedRequestDto input)
  1098. {
  1099. //Try to use paging if available
  1100. var pagedInput = input as IPagedResultRequest;
  1101. if (pagedInput != null)
  1102. {
  1103. return query.PageBy(pagedInput);
  1104. }
  1105. //Try to limit query result if available
  1106. var limitedInput = input as ILimitedResultRequest;
  1107. if (limitedInput != null)
  1108. {
  1109. return query.Take(limitedInput.MaxResultCount);
  1110. }
  1111. //No paging
  1112. return query;
  1113. }
  1114. /// <summary>
  1115. /// 排序
  1116. /// </summary>
  1117. /// <param name="query">The query.</param>
  1118. /// <param name="input">The input.</param>
  1119. protected IQueryable<T> _ApplySorting<T>(IQueryable<T> query, IwbPagedRequestDto input)
  1120. {
  1121. //Try to sort query if available
  1122. var sortInput = input as ISortedResultRequest;
  1123. if (sortInput != null)
  1124. {
  1125. if (!sortInput.Sorting.IsNullOrWhiteSpace())
  1126. {
  1127. return query.OrderBy(sortInput.Sorting);
  1128. }
  1129. }
  1130. //IQueryable.Task requires sorting, so we should sort if Take will be used.
  1131. if (input is ILimitedResultRequest)
  1132. {
  1133. return query.OrderBy("CreationTime DESC");
  1134. }
  1135. //No sorting
  1136. return query;
  1137. }
  1138. public async Task<string> CalcTaxPrice(int type, string input,string rate)
  1139. {
  1140. decimal result = 0;
  1141. try
  1142. {
  1143. decimal inputDec = Convert.ToDecimal(input);
  1144. decimal rateDec = Convert.ToDecimal(rate);
  1145. switch (type)
  1146. {
  1147. case 1:
  1148. result = inputDec / (1 + (rateDec / 100));
  1149. break;
  1150. case 2:
  1151. result = inputDec * (1 + (rateDec / 100));
  1152. break;
  1153. }
  1154. }
  1155. catch (Exception e)
  1156. {
  1157. result = 0;
  1158. }
  1159. return Convert.ToDouble(result).ToString("f3");
  1160. }
  1161. #region 2023
  1162. private void GetPropertiesNo(List<MultiSearchDto> searchList,ref string modelNo, ref string materialNo, ref string rigidityNo, ref string surfaceColorNo)
  1163. {
  1164. foreach (var o in searchList)
  1165. {
  1166. if (o.KeyWords.IsNullOrEmpty())
  1167. continue;
  1168. object keyWords = o.KeyWords;
  1169. if (o.KeyField?.ToLower() == "modelno")
  1170. {
  1171. modelNo = keyWords.ToString();
  1172. }
  1173. if (o.KeyField?.ToLower() == "materialno")
  1174. {
  1175. materialNo = keyWords.ToString();
  1176. }
  1177. if (o.KeyField?.ToLower() == "rigidityno")
  1178. {
  1179. rigidityNo = keyWords.ToString();
  1180. }
  1181. if (o.KeyField?.ToLower() == "surfacecolorno")
  1182. {
  1183. surfaceColorNo = keyWords.ToString();
  1184. }
  1185. }
  1186. }
  1187. public async Task<PagedResultDto<ProductionOrderDto>> QueryProductionOrderDtoByProNo(PagedRequestDto input)
  1188. {
  1189. var query = ProductionOrderRepository.GetAll();
  1190. var result = from u in query
  1191. join s in SemiProductRepository.GetAll() on u.SemiProductNo equals s.Id into l
  1192. from luq in l.DefaultIfEmpty()
  1193. select new ProductionOrderDto
  1194. {
  1195. Model = luq.Model ?? "",
  1196. CarNo = u.CarNo,
  1197. EnterQuantity = u.EnterQuantity,
  1198. Id = u.Id,
  1199. ProductionType = u.ProductionType,
  1200. OutsourcingFactory = u.OutsourcingFactory,
  1201. CreatorUserId = u.CreatorUserId,
  1202. IsChecked = u.IsChecked,
  1203. IsLock = u.IsLock,
  1204. Material = luq.Material ?? "",
  1205. PartNo = luq.PartNo ?? "",
  1206. PlanProduceDate = u.PlanProduceDate,
  1207. RawMaterials = u.RawMaterials,
  1208. SurfaceColor = luq.SurfaceColor ?? "",
  1209. Rigidity = luq.Rigidity ?? "",
  1210. Remark = u.Remark,
  1211. UserIDLastMod = u.UserIDLastMod,
  1212. TimeCreated = u.TimeCreated,
  1213. TimeLastMod = u.TimeLastMod,
  1214. Size = u.Size,
  1215. ProcessingType = u.ProcessingType,
  1216. ProcessingLevel = u.ProcessingLevel,
  1217. SourceProductionOrderNo = u.SourceProductionOrderNo,
  1218. StoveNo = u.StoveNo,
  1219. Quantity = u.Quantity,
  1220. ProductionOrderNo = u.ProductionOrderNo,
  1221. ProductionOrderStatus = u.ProductionOrderStatus,
  1222. SemiProductNo = u.SemiProductNo,
  1223. SemiProductName = luq.SemiProductName,
  1224. KgWeight = u.KgWeight,
  1225. EnterDate = u.EnterDate,
  1226. InspectDate = u.InspectDate,
  1227. HasExported = u.HasExported
  1228. };
  1229. var endState = ProductionOrderStatusEnum.End.ToInt();
  1230. result = result.Where(a => (a.ProductionOrderStatus != endState));
  1231. var searchList = input.SearchList;
  1232. if (searchList != null && searchList.Count > 0)
  1233. {
  1234. //List<LambdaObject> objList = new List<LambdaObject>();
  1235. string modelNo = "", materialNo = "", rigidityNo = "", surfaceColorNo = "";
  1236. GetPropertiesNo(searchList,ref modelNo, ref materialNo, ref rigidityNo, ref surfaceColorNo);
  1237. if (modelNo.IsNullOrEmpty())
  1238. {
  1239. CheckErrors("规格不能为空!");
  1240. }
  1241. //111,110,100,000
  1242. if ((materialNo.IsNullOrEmpty() && rigidityNo.IsNullOrEmpty() && surfaceColorNo.IsNullOrEmpty())||(!materialNo.IsNullOrEmpty() && !rigidityNo.IsNullOrEmpty() && !surfaceColorNo.IsNullOrEmpty())|| (!materialNo.IsNullOrEmpty() && !rigidityNo.IsNullOrEmpty() && surfaceColorNo.IsNullOrEmpty()) || (!materialNo.IsNullOrEmpty() && rigidityNo.IsNullOrEmpty() && surfaceColorNo.IsNullOrEmpty()))
  1243. {
  1244. result = result.Where(i => i.SemiProductNo.StartsWith("s" + modelNo + materialNo + rigidityNo + surfaceColorNo));
  1245. }//101,001,011
  1246. else if((!materialNo.IsNullOrEmpty() && rigidityNo.IsNullOrEmpty() && !surfaceColorNo.IsNullOrEmpty()) || (materialNo.IsNullOrEmpty() && rigidityNo.IsNullOrEmpty() && !surfaceColorNo.IsNullOrEmpty()) || (materialNo.IsNullOrEmpty() && !rigidityNo.IsNullOrEmpty() && !surfaceColorNo.IsNullOrEmpty()))
  1247. {
  1248. result = result.Where(i => i.SemiProductNo.StartsWith("s" + modelNo + materialNo) && i.SemiProductNo.Contains(rigidityNo + surfaceColorNo));
  1249. }//010
  1250. else if (materialNo.IsNullOrEmpty() && !rigidityNo.IsNullOrEmpty() && surfaceColorNo.IsNullOrEmpty())
  1251. {
  1252. result = result.Where(i => i.SemiProductNo.StartsWith("s" + modelNo));
  1253. result = result.Where(i => i.SemiProductNo.Contains( rigidityNo));
  1254. }
  1255. }
  1256. var totalCount = await AsyncQueryableExecuter.CountAsync(result);
  1257. result = result.OrderByDescending(i => i.TimeCreated);
  1258. result = result.Skip(input.SkipCount).Take(input.MaxResultCount);
  1259. var dtos = new PagedResultDto<ProductionOrderDto>(
  1260. totalCount,
  1261. result.ToList()
  1262. );
  1263. return dtos;
  1264. }
  1265. public async Task<PagedResultDto<ViewCurrentProductStoreHouse>> QueryViewCurrentProductStoreHouseByProNo(PagedRequestDto input)
  1266. {
  1267. var query = ViewCurrentProductStoreHouseRepository.GetAll();
  1268. var searchList = input.SearchList;
  1269. if (searchList != null && searchList.Count > 0)
  1270. {
  1271. //List<LambdaObject> objList = new List<LambdaObject>();
  1272. //foreach (var o in searchList)
  1273. //{
  1274. // if (o.KeyWords.IsNullOrEmpty())
  1275. // continue;
  1276. // object keyWords = o.KeyWords;
  1277. // if (o.KeyField?.ToLower() == "productno")
  1278. // {
  1279. // query = query.Where(a => a.ProductNo.StartsWith(o.KeyWords));
  1280. // }
  1281. //}
  1282. string modelNo = "", materialNo = "", rigidityNo = "", surfaceColorNo = "";
  1283. GetPropertiesNo(searchList, ref modelNo, ref materialNo, ref rigidityNo, ref surfaceColorNo);
  1284. if (modelNo.IsNullOrEmpty())
  1285. {
  1286. CheckErrors("规格不能为空!");
  1287. }
  1288. //111,110,100,000
  1289. if ((materialNo.IsNullOrEmpty() && rigidityNo.IsNullOrEmpty() && surfaceColorNo.IsNullOrEmpty()) || (!materialNo.IsNullOrEmpty() && !rigidityNo.IsNullOrEmpty() && !surfaceColorNo.IsNullOrEmpty()) || (!materialNo.IsNullOrEmpty() && !rigidityNo.IsNullOrEmpty() && surfaceColorNo.IsNullOrEmpty()) || (!materialNo.IsNullOrEmpty() && rigidityNo.IsNullOrEmpty() && surfaceColorNo.IsNullOrEmpty()))
  1290. {
  1291. query = query.Where(i => i.ProductNo.StartsWith("s" + modelNo + materialNo + rigidityNo + surfaceColorNo));
  1292. }//101,001,011
  1293. else if ((!materialNo.IsNullOrEmpty() && rigidityNo.IsNullOrEmpty() && !surfaceColorNo.IsNullOrEmpty()) || (materialNo.IsNullOrEmpty() && rigidityNo.IsNullOrEmpty() && !surfaceColorNo.IsNullOrEmpty()) || (materialNo.IsNullOrEmpty() && !rigidityNo.IsNullOrEmpty() && !surfaceColorNo.IsNullOrEmpty()))
  1294. {
  1295. query = query.Where(i => i.ProductNo.StartsWith("s" + modelNo + materialNo) && i.ProductNo.Contains(rigidityNo + surfaceColorNo));
  1296. //query = query.Where(i => i.ProductNo.EndsWith(rigidityNo + surfaceColorNo));
  1297. }//010
  1298. else if (materialNo.IsNullOrEmpty() && !rigidityNo.IsNullOrEmpty() && surfaceColorNo.IsNullOrEmpty())
  1299. {
  1300. query = query.Where(i => i.ProductNo.StartsWith("s" + modelNo));
  1301. query = query.Where(i => i.ProductNo.Contains(rigidityNo));
  1302. }
  1303. }
  1304. query = query.Where(i => i.ActualQuantity > 0);
  1305. var totalCount = await AsyncQueryableExecuter.CountAsync(query);
  1306. query = query.OrderByDescending(i => i.TimeCreated);
  1307. query = query.Skip(input.SkipCount).Take(input.MaxResultCount);
  1308. var dtos = new PagedResultDto<ViewCurrentProductStoreHouse>(
  1309. totalCount,
  1310. query.ToList()
  1311. );
  1312. return dtos;
  1313. }
  1314. public async Task<PagedResultDto<ViewCurrentSemiStoreHouse>> QueryViewCurrentSemiStoreHouseByProNo(PagedRequestDto input)
  1315. {
  1316. var query = ViewCurrentSemiStoreHouseRepository.GetAll();
  1317. var searchList = input.SearchList;
  1318. if (searchList != null && searchList.Count > 0)
  1319. {
  1320. //List<LambdaObject> objList = new List<LambdaObject>();
  1321. //foreach (var o in searchList)
  1322. //{
  1323. // if (o.KeyWords.IsNullOrEmpty())
  1324. // continue;
  1325. // object keyWords = o.KeyWords;
  1326. // if (o.KeyField?.ToLower() == "productno")
  1327. // {
  1328. // query = query.Where(a => a.SemiProductNo.StartsWith(o.KeyWords));
  1329. // }
  1330. //}
  1331. string modelNo = "", materialNo = "", rigidityNo = "", surfaceColorNo = "";
  1332. GetPropertiesNo(searchList, ref modelNo, ref materialNo, ref rigidityNo, ref surfaceColorNo);
  1333. if (modelNo.IsNullOrEmpty())
  1334. {
  1335. CheckErrors("规格不能为空!");
  1336. }
  1337. //111,110,100,000
  1338. if ((materialNo.IsNullOrEmpty() && rigidityNo.IsNullOrEmpty() && surfaceColorNo.IsNullOrEmpty()) || (!materialNo.IsNullOrEmpty() && !rigidityNo.IsNullOrEmpty() && !surfaceColorNo.IsNullOrEmpty()) || (!materialNo.IsNullOrEmpty() && !rigidityNo.IsNullOrEmpty() && surfaceColorNo.IsNullOrEmpty()) || (!materialNo.IsNullOrEmpty() && rigidityNo.IsNullOrEmpty() && surfaceColorNo.IsNullOrEmpty()))
  1339. {
  1340. query = query.Where(i => i.SemiProductNo.StartsWith("s" + modelNo + materialNo + rigidityNo + surfaceColorNo));
  1341. }//101,001,011
  1342. else if ((!materialNo.IsNullOrEmpty() && rigidityNo.IsNullOrEmpty() && !surfaceColorNo.IsNullOrEmpty()) || (materialNo.IsNullOrEmpty() && rigidityNo.IsNullOrEmpty() && !surfaceColorNo.IsNullOrEmpty()) || (materialNo.IsNullOrEmpty() && !rigidityNo.IsNullOrEmpty() && !surfaceColorNo.IsNullOrEmpty()))
  1343. {
  1344. query = query.Where(i => i.SemiProductNo.StartsWith("s" + modelNo + materialNo)&& i.SemiProductNo.Contains(rigidityNo + surfaceColorNo));
  1345. }//010
  1346. else if (materialNo.IsNullOrEmpty() && !rigidityNo.IsNullOrEmpty() && surfaceColorNo.IsNullOrEmpty())
  1347. {
  1348. query = query.Where(i => i.SemiProductNo.StartsWith("s" + modelNo));
  1349. query = query.Where(i => i.SemiProductNo.Contains(rigidityNo));
  1350. }
  1351. }
  1352. query = query.Where(i => i.ActualQuantity > 0);
  1353. var totalCount = await AsyncQueryableExecuter.CountAsync(query);
  1354. query = query.OrderByDescending(i => i.TimeCreated);
  1355. query = query.Skip(input.SkipCount).Take(input.MaxResultCount);
  1356. var dtos = new PagedResultDto<ViewCurrentSemiStoreHouse>(
  1357. totalCount,
  1358. query.ToList()
  1359. );
  1360. return dtos;
  1361. }
  1362. #endregion
  1363. #region 2024
  1364. public async Task<Dictionary<int, List<DeviceMgPlanDto>>> QueryNeedMaintenanceMoldPlan()
  1365. {
  1366. Dictionary<int, List<DeviceMgPlanDto>> result = new Dictionary<int, List<DeviceMgPlanDto>>();
  1367. var over =await DeviceMgPlanRepository.GetAllListAsync(i=>i.PlanType==1&&i.NumberOfUsers>=i.MaintenanceCycle );
  1368. var comingSoon = await DeviceMgPlanRepository.GetAllListAsync(i => i.PlanType == 1
  1369. && i.MaintenanceCycle > i.NumberOfUsers
  1370. && ((i.MaintenanceCycle -
  1371. i.NumberOfUsers) >= 10000));
  1372. var overDtos = ObjectMapper.Map<List<DeviceMgPlanDto>>(over);
  1373. var comingsoonDtos = ObjectMapper.Map<List<DeviceMgPlanDto>>(comingSoon);
  1374. result.Add(1,overDtos);
  1375. result.Add(2, comingsoonDtos);
  1376. return result;
  1377. }
  1378. #endregion
  1379. }
  1380. }