QueryAppService.cs 69 KB

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