TprdProductRepository.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  1. using Ropin.Inspection.Model;
  2. using Ropin.Inspection.Model.Entities;
  3. using Ropin.Inspection.Model.ViewModel;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Linq.Expressions;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. namespace Ropin.Inspection.Repository
  11. {
  12. public class TprdProductRepository : RepositoryBase<TPRD_Product, Guid>, ITprdProductRepository
  13. {
  14. public TprdProductRepository(InspectionDbContext dbContext) : base(dbContext)
  15. {
  16. }
  17. public Task<IEnumerable<AllProductWithDevViewModel>> GetProductWithDataByAsync(TprdProductWithDataSearchModel searchModel)
  18. {
  19. MySqlConnector.MySqlParameter[] parameters = new[] { new MySqlConnector.MySqlParameter("StoreCode", searchModel.C_StoreCode), new MySqlConnector.MySqlParameter("AreaCode", searchModel.C_AreaCode) };
  20. string sql = @"SELECT A.*,D.C_Name AS DevDataConfigName,C.C_Value AS DevDataValue,C.D_CreateOn AS DevDataTime,B.C_Name AS DevName,B.C_MachineCode AS DevMachineCode
  21. FROM TPRD_Product A
  22. LEFT JOIN TDEV_Device B ON B.C_Code = A.C_DeviceCode
  23. INNER JOIN TDEV_DevData C ON C.C_DeviceCode = B.C_Code
  24. INNER JOIN TDEV_DevDataConfig D ON D.C_Code = C.C_ConfigCode
  25. WHERE B.C_Status = '1' AND DATE_FORMAT(C.D_CreateOn,'%Y-%m-%d') = DATE_SUB(curdate(),INTERVAL 0 DAY) GROUP BY D.C_Code AND A.C_StoreCode =@StoreCode ";
  26. sql = @"SELECT A.*,C.DevDataConfigName,C.C_Value AS DevDataValue,C.D_CreateOn AS DevDataTime,B.C_Name AS DevName,B.C_MachineCode AS DevMachineCode
  27. FROM TPRD_Product A
  28. LEFT JOIN TDEV_Device B ON B.C_Code = A.C_DeviceCode
  29. LEFT JOIN (
  30. SELECT C.*,D.C_Name AS DevDataConfigName ,D.C_Code AS DevDataConfigCode FROM TDEV_DevDataConfig D
  31. LEFT JOIN TDEV_DevData C ON D.C_Code = C.C_ConfigCode AND DATE_FORMAT(C.D_CreateOn,'%Y-%m-%d') = DATE_SUB(curdate(),INTERVAL 0 DAY) GROUP BY C.C_DeviceCode , C.C_ConfigCode ORDER BY C.D_CreateOn desc
  32. )C ON A.C_DeviceCode = C.C_DeviceCode
  33. WHERE B.C_Status = '1' "; //AND A.C_StoreCode =@StoreCode
  34. //if (!string.IsNullOrEmpty(searchModel.C_AreaCode))
  35. //{
  36. // sql += " AND A.C_AreaCode =@AreaCode";
  37. //}
  38. sql = @"SELECT A.*,C.DevDataConfigName,C.C_Value AS DevDataValue,C.D_CreateOn AS DevDataTime,B.C_Name AS DevName,B.C_MachineCode AS DevMachineCode, D.DevAlertConfigName,D.C_Value AS DevAlertValue,D.D_CreateOn AS DevAlertTime
  39. FROM TPRD_Product A
  40. LEFT JOIN TDEV_Device B ON B.C_Code = A.C_DeviceCode AND B.C_Status = '1'
  41. LEFT JOIN (
  42. SELECT C.*,D.C_Name AS DevDataConfigName ,D.C_Code AS DevDataConfigCode FROM TDEV_DevDataConfig D
  43. LEFT JOIN TDEV_DevData C ON D.C_Code = C.C_ConfigCode AND DATE_FORMAT(C.D_CreateOn,'%Y-%m-%d') = DATE_SUB(curdate(),INTERVAL 0 DAY) GROUP BY C.C_DeviceCode , C.C_ConfigCode ORDER BY C.D_CreateOn desc
  44. )C ON A.C_DeviceCode = C.C_DeviceCode
  45. LEFT JOIN (
  46. SELECT C.*,D.C_Name AS DevAlertConfigName ,D.C_Code AS DevAlertConfigCode FROM TDEV_DevAlertConfig D
  47. LEFT JOIN TDEV_DevAlert C ON D.C_Code = C.C_ConfigCode AND DATE_FORMAT(C.D_CreateOn,'%Y-%m-%d') = DATE_SUB(curdate(),INTERVAL 0 DAY) GROUP BY C.C_DeviceCode , C.C_ConfigCode ORDER BY C.D_CreateOn desc
  48. )D ON A.C_DeviceCode = D.C_DeviceCode";
  49. sql = @"SELECT A.*,C.DevDataConfigName,C.C_Value AS DevDataValue,C.D_CreateOn AS DevDataTime,B.C_Name AS DevName,B.C_MachineCode AS DevMachineCode, D.DevAlertConfigName,D.C_Value AS DevAlertValue,D.D_CreateOn AS DevAlertTime,
  50. E.C_Name,
  51. E.C_Spec,
  52. E.C_Brand,
  53. E.C_Vender,
  54. E.C_ProdArea
  55. FROM TPRD_Product A
  56. LEFT JOIN TDEV_Device B ON B.C_Code = A.C_DeviceCode AND B.C_Status = '1'
  57. LEFT JOIN (
  58. SELECT C.*,D.C_Name AS DevDataConfigName ,D.C_Code AS DevDataConfigCode FROM TDEV_DevDataConfig D
  59. LEFT JOIN TDEV_DevData C ON D.C_Code = C.C_ConfigCode AND DATE_FORMAT(C.D_CreateOn,'%Y-%m-%d') = DATE_SUB(curdate(),INTERVAL 0 DAY) GROUP BY C.C_DeviceCode , C.C_ConfigCode ORDER BY C.D_CreateOn desc
  60. )C ON A.C_DeviceCode = C.C_DeviceCode
  61. LEFT JOIN (
  62. SELECT C.*,D.C_Name AS DevAlertConfigName ,D.C_Code AS DevAlertConfigCode FROM TDEV_DevAlertConfig D
  63. LEFT JOIN TDEV_DevAlert C ON D.C_Code = C.C_ConfigCode AND DATE_FORMAT(C.D_CreateOn,'%Y-%m-%d') = DATE_SUB(curdate(),INTERVAL 0 DAY) GROUP BY C.C_DeviceCode , C.C_ConfigCode ORDER BY C.D_CreateOn desc
  64. )D ON A.C_DeviceCode = D.C_DeviceCode
  65. LEFT JOIN TPRD_ProdSKU E
  66. ON E.C_SKUCode = A.C_SKUCode";
  67. IEnumerable<TprdProductWithDataViewModel> productRecordlist;
  68. if (!searchModel.IsPagination)
  69. {
  70. if (!string.IsNullOrEmpty(searchModel.C_AreaCode))
  71. {
  72. productRecordlist = EntityFrameworkCoreExtensions.GetList<TprdProductWithDataViewModel>(DbContext.Database, sql, null).Where(c => c.C_StoreCode == searchModel.C_StoreCode && c.C_AreaCode == searchModel.C_AreaCode);
  73. }
  74. else
  75. {
  76. productRecordlist = EntityFrameworkCoreExtensions.GetList<TprdProductWithDataViewModel>(DbContext.Database, sql, null).Where(c => c.C_StoreCode == searchModel.C_StoreCode);
  77. }
  78. }
  79. else
  80. {
  81. if (!string.IsNullOrEmpty(searchModel.C_AreaCode))
  82. {
  83. productRecordlist = EntityFrameworkCoreExtensions.GetList<TprdProductWithDataViewModel>(DbContext.Database, sql, null, searchModel.PageSize, searchModel.PageIndex).Where(c => c.C_StoreCode == searchModel.C_StoreCode && c.C_AreaCode == searchModel.C_AreaCode);
  84. }
  85. else
  86. {
  87. productRecordlist = EntityFrameworkCoreExtensions.GetList<TprdProductWithDataViewModel>(DbContext.Database, sql, null, searchModel.PageSize, searchModel.PageIndex).Where(c => c.C_StoreCode == searchModel.C_StoreCode);
  88. }
  89. }
  90. if (null == productRecordlist || !productRecordlist.Any())
  91. {
  92. IEnumerable<AllProductWithDevViewModel> recordItemDetail = null;
  93. return Task.FromResult(recordItemDetail);
  94. }
  95. var q = from b in productRecordlist
  96. group b by b.C_Code into g
  97. select new AllProductWithDevViewModel
  98. {
  99. C_Code = g.First().C_Code,
  100. C_StoreCode = g.First().C_StoreCode,
  101. C_AreaCode = g.First().C_AreaCode,
  102. F_Map_X = g.First().F_Map_X,
  103. F_Map_Y = g.First().F_Map_Y,
  104. C_SKUCode = g.First().C_StoreCode,
  105. C_DeviceCode = g.First().C_DeviceCode,
  106. C_SpotCode = g.First().C_SpotCode,
  107. D_ProdDate = g.First().D_ProdDate,
  108. D_ValiDate = g.First().D_ValiDate,
  109. C_ImageUrl = g.First().C_ImageUrl,
  110. D_LastISP = g.First().D_LastISP,
  111. I_IsAlarm = g.First().I_IsAlarm,
  112. C_AlarmMsg = g.First().C_AlarmMsg,
  113. I_Sort = g.First().I_Sort,
  114. C_QRCode = g.First().C_QRCode,
  115. C_Remark = g.First().C_Remark,
  116. C_CreateBy = g.First().C_CreateBy,
  117. D_CreateOn = g.First().D_CreateOn,
  118. C_LastUpdatedBy = g.First().C_LastUpdatedBy,
  119. D_LastUpdatedOn = g.First().D_LastUpdatedOn,
  120. I_Status = g.First().I_Status,
  121. C_Name = g.First().C_Name,
  122. C_Spec = g.First().C_Spec,
  123. C_Brand = g.First().C_Brand,
  124. C_Vender = g.First().C_Vender,
  125. C_ProdArea = g.First().C_ProdArea,
  126. DevDatas = (from c in g
  127. select new DevData
  128. {
  129. DevDataConfigName = c.DevDataConfigName,
  130. DevDataValue = c.DevDataValue,
  131. DevDataTime = c.DevDataTime,
  132. DevName = c.DevName,
  133. DevMachineCode = c.DevMachineCode,
  134. DevAlertConfigName = c.DevAlertConfigName,
  135. DevAlertValue = c.DevAlertValue,
  136. DevAlertTime = c.DevAlertTime,
  137. }),
  138. };
  139. return Task.FromResult(q);
  140. }
  141. public Task<IEnumerable<TprdProductViewModel>> GetAlertProductsByAsync(string storeCode)
  142. {
  143. Expression<Func<TPRD_Product, bool>> ex = i => (i.I_Status == 2 || i.I_Status == 1) && i.D_ValiDate != null && i.D_ValiDate > DateTime.Now && i.C_StoreCode == storeCode;
  144. var query = from a in DbContext.TPRD_Product
  145. join b in DbContext.TPRD_ProdSKU
  146. on a.C_SKUCode equals b.C_SKUCode
  147. join c in DbContext.TPNT_Store
  148. on a.C_StoreCode equals c.C_Code
  149. join d in DbContext.TDEV_Device
  150. on a.C_DeviceCode equals d.C_Code
  151. join e in DbContext.TISP_Spot
  152. on a.C_SpotCode equals e.C_Code
  153. join f in DbContext.TPNT_Area
  154. on a.C_AreaCode equals f.C_Code
  155. where a.C_StoreCode == storeCode && (a.I_Status == 2 || a.I_Status == 1) && a.D_ValiDate != null && a.D_ValiDate > DateTime.Now
  156. select new TprdProductViewModel
  157. {
  158. C_Code = a.C_Code,
  159. C_QRCode = a.C_QRCode,
  160. C_SKUCode = a.C_SKUCode,
  161. C_StoreCode = a.C_StoreCode,
  162. C_DeviceCode = a.C_DeviceCode,
  163. C_SpotCode = a.C_SpotCode,
  164. C_AreaCode = a.C_AreaCode,
  165. F_Map_X = a.F_Map_X,
  166. F_Map_Y = a.F_Map_Y,
  167. D_ProdDate = a.D_ProdDate,
  168. D_ValiDate = a.D_ValiDate,
  169. C_ImageUrl = a.C_ImageUrl,
  170. D_LastISP = a.D_LastISP,
  171. I_IsAlarm = a.I_IsAlarm,
  172. C_AlarmMsg = a.C_AlarmMsg,
  173. I_Sort = a.I_Sort,
  174. C_Remark = a.C_Remark,
  175. C_CreateBy = a.C_CreateBy,
  176. D_CreateOn = a.D_CreateOn,
  177. C_LastUpdatedBy = a.C_LastUpdatedBy,
  178. D_LastUpdatedOn = a.D_LastUpdatedOn,
  179. I_Status = a.I_Status,
  180. SpotName = e.C_Name,
  181. AreaName = f.C_Name,
  182. StoreName = c.C_Name,
  183. DeviceName = d.C_Name,
  184. SKUName = b.C_Name,
  185. };
  186. return Task.FromResult(query.AsEnumerable());
  187. }
  188. public Task<TprdProductViewModel> GetAlertProductByCodeAsync(Guid code)
  189. {
  190. var query = from a in DbContext.TPRD_Product
  191. join b in DbContext.TPRD_ProdSKU
  192. on a.C_SKUCode equals b.C_SKUCode
  193. join c in DbContext.TPNT_Store
  194. on a.C_StoreCode equals c.C_Code
  195. join d in DbContext.TDEV_Device
  196. on a.C_DeviceCode equals d.C_Code
  197. join e in DbContext.TISP_Spot
  198. on a.C_SpotCode equals e.C_Code
  199. join f in DbContext.TPNT_Area
  200. on a.C_AreaCode equals f.C_Code
  201. where a.C_Code == code
  202. select new TprdProductViewModel
  203. {
  204. C_Code = a.C_Code,
  205. C_QRCode = a.C_QRCode,
  206. C_SKUCode = a.C_SKUCode,
  207. C_StoreCode = a.C_StoreCode,
  208. C_DeviceCode = a.C_DeviceCode,
  209. C_SpotCode = a.C_SpotCode,
  210. C_AreaCode = a.C_AreaCode,
  211. F_Map_X = a.F_Map_X,
  212. F_Map_Y = a.F_Map_Y,
  213. D_ProdDate = a.D_ProdDate,
  214. D_ValiDate = a.D_ValiDate,
  215. C_ImageUrl = a.C_ImageUrl,
  216. D_LastISP = a.D_LastISP,
  217. I_IsAlarm = a.I_IsAlarm,
  218. C_AlarmMsg = a.C_AlarmMsg,
  219. I_Sort = a.I_Sort,
  220. C_Remark = a.C_Remark,
  221. C_CreateBy = a.C_CreateBy,
  222. D_CreateOn = a.D_CreateOn,
  223. C_LastUpdatedBy = a.C_LastUpdatedBy,
  224. D_LastUpdatedOn = a.D_LastUpdatedOn,
  225. I_Status = a.I_Status,
  226. SpotName = e.C_Name,
  227. AreaName = f.C_Name,
  228. StoreName = c.C_Name,
  229. DeviceName = d.C_Name,
  230. SKUName = b.C_Name,
  231. };
  232. return Task.FromResult(query.FirstOrDefault());
  233. }
  234. public Task<IEnumerable<TprdProductViewModel>> GetValiDateProductsByAsync(string storeCode)
  235. {
  236. Expression<Func<TPRD_Product, bool>> ex = i => (i.I_Status == 2 || i.I_Status == 1) && i.I_IsAlarm == 0 && i.C_StoreCode == storeCode;
  237. var query = from a in DbContext.TPRD_Product
  238. join b in DbContext.TPRD_ProdSKU
  239. on a.C_SKUCode equals b.C_SKUCode
  240. join c in DbContext.TPNT_Store
  241. on a.C_StoreCode equals c.C_Code
  242. join d in DbContext.TDEV_Device
  243. on a.C_DeviceCode equals d.C_Code
  244. join e in DbContext.TISP_Spot
  245. on a.C_SpotCode equals e.C_Code
  246. join f in DbContext.TPNT_Area
  247. on a.C_AreaCode equals f.C_Code
  248. where a.C_StoreCode == storeCode && (a.I_Status == 2 || a.I_Status == 1) && a.I_IsAlarm == 0
  249. select new TprdProductViewModel
  250. {
  251. C_Code = a.C_Code,
  252. C_QRCode = a.C_QRCode,
  253. C_SKUCode = a.C_SKUCode,
  254. C_StoreCode = a.C_StoreCode,
  255. C_DeviceCode = a.C_DeviceCode,
  256. C_SpotCode = a.C_SpotCode,
  257. C_AreaCode = a.C_AreaCode,
  258. F_Map_X = a.F_Map_X,
  259. F_Map_Y = a.F_Map_Y,
  260. D_ProdDate = a.D_ProdDate,
  261. D_ValiDate = a.D_ValiDate,
  262. C_ImageUrl = a.C_ImageUrl,
  263. D_LastISP = a.D_LastISP,
  264. I_IsAlarm = a.I_IsAlarm,
  265. C_AlarmMsg = a.C_AlarmMsg,
  266. I_Sort = a.I_Sort,
  267. C_Remark = a.C_Remark,
  268. C_CreateBy = a.C_CreateBy,
  269. D_CreateOn = a.D_CreateOn,
  270. C_LastUpdatedBy = a.C_LastUpdatedBy,
  271. D_LastUpdatedOn = a.D_LastUpdatedOn,
  272. I_Status = a.I_Status,
  273. SpotName = e.C_Name,
  274. AreaName = f.C_Name,
  275. StoreName = c.C_Name,
  276. DeviceName = d.C_Name,
  277. SKUName = b.C_Name,
  278. };
  279. return Task.FromResult(query.AsEnumerable());
  280. }
  281. public Task<TprdProductViewModel> GetValiDateProductByCodeAsync(Guid code)
  282. {
  283. var query = from a in DbContext.TPRD_Product
  284. join b in DbContext.TPRD_ProdSKU
  285. on a.C_SKUCode equals b.C_SKUCode
  286. join c in DbContext.TPNT_Store
  287. on a.C_StoreCode equals c.C_Code
  288. join d in DbContext.TDEV_Device
  289. on a.C_DeviceCode equals d.C_Code
  290. join e in DbContext.TISP_Spot
  291. on a.C_SpotCode equals e.C_Code
  292. join f in DbContext.TPNT_Area
  293. on a.C_AreaCode equals f.C_Code
  294. where a.C_Code == code
  295. select new TprdProductViewModel
  296. {
  297. C_Code = a.C_Code,
  298. C_QRCode = a.C_QRCode,
  299. C_SKUCode = a.C_SKUCode,
  300. C_StoreCode = a.C_StoreCode,
  301. C_DeviceCode = a.C_DeviceCode,
  302. C_SpotCode = a.C_SpotCode,
  303. C_AreaCode = a.C_AreaCode,
  304. F_Map_X = a.F_Map_X,
  305. F_Map_Y = a.F_Map_Y,
  306. D_ProdDate = a.D_ProdDate,
  307. D_ValiDate = a.D_ValiDate,
  308. C_ImageUrl = a.C_ImageUrl,
  309. D_LastISP = a.D_LastISP,
  310. I_IsAlarm = a.I_IsAlarm,
  311. C_AlarmMsg = a.C_AlarmMsg,
  312. I_Sort = a.I_Sort,
  313. C_Remark = a.C_Remark,
  314. C_CreateBy = a.C_CreateBy,
  315. D_CreateOn = a.D_CreateOn,
  316. C_LastUpdatedBy = a.C_LastUpdatedBy,
  317. D_LastUpdatedOn = a.D_LastUpdatedOn,
  318. I_Status = a.I_Status,
  319. SpotName = e.C_Name,
  320. AreaName = f.C_Name,
  321. StoreName = c.C_Name,
  322. DeviceName = d.C_Name,
  323. SKUName = b.C_Name,
  324. };
  325. return Task.FromResult(query.FirstOrDefault());
  326. }
  327. public IEnumerable<TprdDeviceByAreaViewModel> GetDeviceByAreaCode(TprdDeviceByAreaSearchModel searchModel)
  328. {
  329. var query = from b in DbContext.TDEV_Device
  330. join a in DbContext.TPRD_Product
  331. on b.C_Code equals a.C_DeviceCode
  332. where a.C_StoreCode == searchModel.C_StoreCode && (string.IsNullOrEmpty(searchModel.C_AreaCode) ? 1 == 1 : a.C_AreaCode == searchModel.C_AreaCode)
  333. //group a by a.C_DeviceCode into g
  334. select new TprdDeviceByAreaViewModel
  335. {
  336. DeviceCode = a.C_DeviceCode,
  337. I_Status = a.I_Status,
  338. DeviceName = b.C_Name,
  339. DeviceMachineCode = b.C_MachineCode,
  340. DeviceStatus = b.C_Status,
  341. }
  342. ;
  343. //var q = from a in query
  344. // group a by a.DeviceCode into g
  345. // select new TprdDeviceByAreaViewModel
  346. // {
  347. // DeviceCode = g.First().DeviceCode,
  348. // I_Status = g.First().I_Status,
  349. // DeviceName = g.First().DeviceName,
  350. // DeviceMachineCode = g.First().DeviceMachineCode,
  351. // DeviceStatus = g.First().DeviceStatus,
  352. // };
  353. var list = query.ToList().GroupBy(c => c.DeviceCode);
  354. return query.ToList().GroupBy(c=>c.DeviceCode).Select(h=>
  355. new TprdDeviceByAreaViewModel
  356. {
  357. DeviceCode = h.First().DeviceCode,
  358. I_Status = h.First().I_Status,
  359. DeviceName = h.First().DeviceName,
  360. DeviceMachineCode = h.First().DeviceMachineCode,
  361. DeviceStatus = h.First().DeviceStatus,
  362. }
  363. ).AsEnumerable();
  364. }
  365. public Task<TprdProductViewModel> GetProductByQRCodeAsync(string QRCode, string storeCode)
  366. {
  367. var query = from a in DbContext.TPRD_Product
  368. join b in DbContext.TPRD_ProdSKU
  369. on a.C_SKUCode equals b.C_SKUCode
  370. join c in DbContext.TPNT_Store
  371. on a.C_StoreCode equals c.C_Code
  372. join d in DbContext.TDEV_Device
  373. on a.C_DeviceCode equals d.C_Code into temp
  374. from tt in temp.DefaultIfEmpty()
  375. join e in DbContext.TISP_Spot
  376. on a.C_SpotCode equals e.C_Code
  377. join f in DbContext.TPNT_Area
  378. on a.C_AreaCode equals f.C_Code
  379. where a.C_QRCode == QRCode && a.C_StoreCode == storeCode
  380. select new TprdProductViewModel
  381. {
  382. C_Code = a.C_Code,
  383. C_QRCode = a.C_QRCode,
  384. C_SKUCode = a.C_SKUCode,
  385. C_StoreCode = a.C_StoreCode,
  386. C_DeviceCode = a.C_DeviceCode,
  387. C_SpotCode = a.C_SpotCode,
  388. C_AreaCode = a.C_AreaCode,
  389. F_Map_X = a.F_Map_X,
  390. F_Map_Y = a.F_Map_Y,
  391. D_ProdDate = a.D_ProdDate,
  392. D_ValiDate = a.D_ValiDate,
  393. C_ImageUrl = a.C_ImageUrl,
  394. D_LastISP = a.D_LastISP,
  395. I_IsAlarm = a.I_IsAlarm,
  396. C_AlarmMsg = a.C_AlarmMsg,
  397. I_Sort = a.I_Sort,
  398. C_Remark = a.C_Remark,
  399. C_CreateBy = a.C_CreateBy,
  400. D_CreateOn = a.D_CreateOn,
  401. C_LastUpdatedBy = a.C_LastUpdatedBy,
  402. D_LastUpdatedOn = a.D_LastUpdatedOn,
  403. I_Status = a.I_Status,
  404. SpotName = e.C_Name,
  405. AreaName = f.C_Name,
  406. StoreName = c.C_Name,
  407. DeviceName = tt == null ? "" : tt.C_Name,
  408. SKUName = b.C_Name,
  409. };
  410. return Task.FromResult(query.FirstOrDefault());
  411. }
  412. }
  413. }