QueryAppService.cs 69 KB

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