StatusShowBll.cs 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188
  1. using Cksoft.Data;
  2. using Cksoft.Data.Repository;
  3. using Cksoft.Unity;
  4. using DllEapDal;
  5. using DllEapEntity;
  6. using DllEapEntity.Dtos;
  7. using DllEapEntity.Rms;
  8. using DllHsms;
  9. using DllStatusShowDal;
  10. using Newtonsoft.Json;
  11. using RabbitMQ.Client;
  12. using System;
  13. using System.Collections;
  14. using System.Collections.Generic;
  15. using System.Data;
  16. using System.Linq;
  17. namespace DllStatusShowBll
  18. {
  19. public class StatusShowBll : IDisposable
  20. {
  21. private string CurrDbCode = "sqlconn";
  22. private IDatabase CurrDb = null;
  23. public StatusShowBll(string dbcode)
  24. {
  25. CurrDbCode = dbcode;
  26. CurrDb = DbFactory.Base(CurrDbCode);
  27. }
  28. public StatusShowBll()
  29. {
  30. }
  31. public void Dispose()
  32. {
  33. if (CurrDb != null)
  34. CurrDb.Close();
  35. }
  36. public Hashtable IUTLcd(Hashtable imputds, ref string errorinfo, ref int error)
  37. {
  38. try
  39. {
  40. if (imputds == null)
  41. {
  42. errorinfo = "传入数据不能为空,请确认";
  43. error = 1;
  44. return null;
  45. }
  46. ConstOrder order = JsonConvert.DeserializeObject<ConstOrder>((string)imputds[nameof(ConstOrder)]);
  47. TLcd entity = JsonConvert.DeserializeObject<TLcd>((string)imputds[nameof(TLcd)]);
  48. string usercode = order.usercode;
  49. CurrDb.BeginTrans();
  50. TLcdDal tempdal = new TLcdDal(CurrDb);
  51. entity = tempdal.IUTLcd(entity, order.usercode, ref errorinfo);
  52. if (entity == null)
  53. {
  54. CurrDb.Rollback();
  55. return null;
  56. }
  57. Hashtable reds = new Hashtable();
  58. reds.Add(nameof(TLcd), JsonConvert.SerializeObject(entity));
  59. CurrDb.Commit();
  60. return reds;
  61. }
  62. catch (Exception ex)
  63. {
  64. errorinfo = ex.Message.ToString();
  65. error = 1;
  66. CurrDb.Rollback();
  67. return null;
  68. }
  69. finally
  70. {
  71. if (CurrDb != null)
  72. {
  73. CurrDb.Close();
  74. }
  75. }
  76. }
  77. public Hashtable DelTLcd(Hashtable imputds, ref string errorinfo, ref int error)
  78. {
  79. try
  80. {
  81. if (imputds == null)
  82. {
  83. errorinfo = "传入数据不能为空,请确认";
  84. error = 1;
  85. return null;
  86. }
  87. ConstOrder order = JsonConvert.DeserializeObject<ConstOrder>((string)imputds[nameof(ConstOrder)]);
  88. List<TLcd> entity = JsonConvert.DeserializeObject<List<TLcd>>((string)imputds[nameof(TLcd)]);
  89. string usercode = order.usercode;
  90. CurrDb.BeginTrans();
  91. TLcdDal tempdal = new TLcdDal(CurrDb);
  92. TLcd result = tempdal.DelTLcd(entity, order.usercode, ref errorinfo);
  93. if (result == null)
  94. {
  95. CurrDb.Rollback();
  96. return null;
  97. }
  98. Hashtable reds = new Hashtable();
  99. reds.Add(nameof(TLcd), JsonConvert.SerializeObject(result));
  100. CurrDb.Commit();
  101. return reds;
  102. }
  103. catch (Exception ex)
  104. {
  105. errorinfo = ex.Message.ToString();
  106. error = 1;
  107. CurrDb.Rollback();
  108. return null;
  109. }
  110. finally
  111. {
  112. if (CurrDb != null)
  113. {
  114. CurrDb.Close();
  115. }
  116. }
  117. }
  118. public Hashtable IUTEntity(Hashtable imputds, ref string errorinfo, ref int error)
  119. {
  120. try
  121. {
  122. if (imputds == null)
  123. {
  124. errorinfo = "传入数据不能为空,请确认";
  125. error = 1;
  126. return null;
  127. }
  128. ConstOrder order = JsonConvert.DeserializeObject<ConstOrder>((string)imputds[nameof(ConstOrder)]);
  129. TEntity entity = JsonConvert.DeserializeObject<TEntity>((string)imputds[nameof(TEntity)]);
  130. string usercode = order.usercode;
  131. CurrDb.BeginTrans();
  132. TEntityDal tempdal = new TEntityDal(CurrDb);
  133. entity = tempdal.IUTEntity(entity, order.usercode, ref errorinfo);
  134. if (entity == null)
  135. {
  136. CurrDb.Rollback();
  137. return null;
  138. }
  139. Hashtable reds = new Hashtable();
  140. reds.Add(nameof(TEntity), JsonConvert.SerializeObject(entity));
  141. CurrDb.Commit();
  142. return reds;
  143. }
  144. catch (Exception ex)
  145. {
  146. errorinfo = ex.Message.ToString();
  147. error = 1;
  148. CurrDb.Rollback();
  149. return null;
  150. }
  151. finally
  152. {
  153. if (CurrDb != null)
  154. {
  155. CurrDb.Close();
  156. }
  157. }
  158. }
  159. public Hashtable DelTEntity(Hashtable imputds, ref string errorinfo, ref int error)
  160. {
  161. try
  162. {
  163. if (imputds == null)
  164. {
  165. errorinfo = "传入数据不能为空,请确认";
  166. error = 1;
  167. return null;
  168. }
  169. ConstOrder order = JsonConvert.DeserializeObject<ConstOrder>((string)imputds[nameof(ConstOrder)]);
  170. List<TEntity> entity = JsonConvert.DeserializeObject<List<TEntity>>((string)imputds[nameof(TEntity)]);
  171. string usercode = order.usercode;
  172. CurrDb.BeginTrans();
  173. TEntityDal tempdal = new TEntityDal(CurrDb);
  174. TEntity result = tempdal.DelTEntity(entity, order.usercode, ref errorinfo);
  175. if (result == null)
  176. {
  177. CurrDb.Rollback();
  178. return null;
  179. }
  180. Hashtable reds = new Hashtable();
  181. reds.Add(nameof(TEntity), JsonConvert.SerializeObject(result));
  182. CurrDb.Commit();
  183. return reds;
  184. }
  185. catch (Exception ex)
  186. {
  187. errorinfo = ex.Message.ToString();
  188. error = 1;
  189. CurrDb.Rollback();
  190. return null;
  191. }
  192. finally
  193. {
  194. if (CurrDb != null)
  195. {
  196. CurrDb.Close();
  197. }
  198. }
  199. }
  200. public Hashtable IULayoutMst(Hashtable imputds, ref string errorinfo, ref int error)
  201. {
  202. try
  203. {
  204. if (imputds == null)
  205. {
  206. errorinfo = "传入数据不能为空,请确认";
  207. error = 1;
  208. return null;
  209. }
  210. ConstOrder order = JsonConvert.DeserializeObject<ConstOrder>((string)imputds[nameof(ConstOrder)]);
  211. LayoutMst entity = JsonConvert.DeserializeObject<LayoutMst>((string)imputds[nameof(LayoutMst)]);
  212. List<LayoutDetail> details = JsonConvert.DeserializeObject<List<LayoutDetail>>((string)imputds[nameof(LayoutDetail)]);
  213. string usercode = order.usercode;
  214. CurrDb.BeginTrans();
  215. LayoutMstDal tempdal = new LayoutMstDal(CurrDb);
  216. entity = tempdal.IULayoutMst(entity, details, order.usercode, ref errorinfo);
  217. if (entity == null)
  218. {
  219. CurrDb.Rollback();
  220. return null;
  221. }
  222. Hashtable reds = new Hashtable();
  223. reds.Add(nameof(LayoutMst), JsonConvert.SerializeObject(entity));
  224. CurrDb.Commit();
  225. //广播layout改变
  226. BroadcastLayout(entity, ref errorinfo);
  227. errorinfo = "";
  228. return reds;
  229. }
  230. catch (Exception ex)
  231. {
  232. errorinfo = ex.Message.ToString();
  233. error = 1;
  234. CurrDb.Rollback();
  235. return null;
  236. }
  237. finally
  238. {
  239. if (CurrDb != null)
  240. {
  241. CurrDb.Close();
  242. }
  243. }
  244. }
  245. private int BroadcastLayout(LayoutMst mst, ref string errorinfo)
  246. {
  247. IConnection connection = null;
  248. try
  249. {
  250. List<MQServer> mqserver = CurrDb.FindListForCondition<MQServer>("", ref errorinfo).ToList();
  251. if (mqserver == null)
  252. return -1;
  253. foreach (var item in mqserver)
  254. {
  255. var factory = new ConnectionFactory();
  256. factory.HostName = item.IpAddress;
  257. factory.UserName = item.FUser;
  258. factory.Password = item.FPasswd;
  259. connection = factory.CreateConnection();
  260. var channel = connection.CreateModel();
  261. byte[] queuedata = EntityHelper.SerializeBytes<LayoutMst>(mst);
  262. if (queuedata == null)
  263. return -1;
  264. string LayoutExchange = AppConfigurtaionServices.Configuration["rabbitmq:LayoutExchange"];
  265. channel.ExchangeDeclare(exchange: LayoutExchange, type: "fanout", durable: false, autoDelete: true);
  266. channel.BasicPublish(LayoutExchange, "", null, queuedata); //开始传递
  267. channel.Close();
  268. connection.Close();
  269. }
  270. return 1;
  271. }
  272. catch (Exception ex)
  273. {
  274. errorinfo = ex.Message.ToString();
  275. return -1;
  276. }
  277. }
  278. public Hashtable DelLayoutMst(Hashtable imputds, ref string errorinfo, ref int error)
  279. {
  280. try
  281. {
  282. if (imputds == null)
  283. {
  284. errorinfo = "传入数据不能为空,请确认";
  285. error = 1;
  286. return null;
  287. }
  288. ConstOrder order = JsonConvert.DeserializeObject<ConstOrder>((string)imputds[nameof(ConstOrder)]);
  289. List<LayoutMst> entity = JsonConvert.DeserializeObject<List<LayoutMst>>((string)imputds[nameof(LayoutMst)]);
  290. string usercode = order.usercode;
  291. CurrDb.BeginTrans();
  292. LayoutMstDal tempdal = new LayoutMstDal(CurrDb);
  293. LayoutMst result = tempdal.DelLayoutMst(entity, order.usercode, ref errorinfo);
  294. if (result == null)
  295. {
  296. CurrDb.Rollback();
  297. return null;
  298. }
  299. Hashtable reds = new Hashtable();
  300. reds.Add(nameof(LayoutMst), JsonConvert.SerializeObject(result));
  301. CurrDb.Commit();
  302. return reds;
  303. }
  304. catch (Exception ex)
  305. {
  306. errorinfo = ex.Message.ToString();
  307. error = 1;
  308. CurrDb.Rollback();
  309. return null;
  310. }
  311. finally
  312. {
  313. if (CurrDb != null)
  314. {
  315. CurrDb.Close();
  316. }
  317. }
  318. }
  319. public Hashtable IMacStatus(Hashtable imputds, ref string errorinfo, ref int error)
  320. {
  321. try
  322. {
  323. if (imputds == null)
  324. {
  325. errorinfo = "传入数据不能为空,请确认";
  326. error = 1;
  327. return null;
  328. }
  329. ConstOrder order = JsonConvert.DeserializeObject<ConstOrder>((string)imputds[nameof(ConstOrder)]);
  330. MacStatus entity = JsonConvert.DeserializeObject<MacStatus>((string)imputds[nameof(MacStatus)]);
  331. string usercode = order.usercode;
  332. CurrDb.BeginTrans();
  333. MacStatusDal tempdal = new MacStatusDal(CurrDb);
  334. entity = tempdal.IMacStatus(entity, order.usercode, ref errorinfo);
  335. if (entity == null)
  336. {
  337. CurrDb.Rollback();
  338. return null;
  339. }
  340. //将状态广播到消息队列里
  341. string temperrorinfo = "";
  342. BroadcastStatus(entity, ref temperrorinfo);
  343. Hashtable reds = new Hashtable();
  344. reds.Add(nameof(MacStatus), JsonConvert.SerializeObject(entity));
  345. CurrDb.Commit();
  346. return reds;
  347. }
  348. catch (Exception ex)
  349. {
  350. errorinfo = ex.Message.ToString();
  351. error = 1;
  352. CurrDb.Rollback();
  353. return null;
  354. }
  355. finally
  356. {
  357. if (CurrDb != null)
  358. {
  359. CurrDb.Close();
  360. }
  361. }
  362. }
  363. /// <summary>
  364. /// 广播状态
  365. /// </summary>
  366. /// <param name="status"></param>
  367. /// <param name="errorinfo"></param>
  368. /// <returns></returns>
  369. private int BroadcastStatus(MacStatus status, ref string errorinfo)
  370. {
  371. IConnection connection = null;
  372. try
  373. {
  374. var factory = new ConnectionFactory();
  375. factory.HostName = AppConfigurtaionServices.Configuration["rabbitmq:IPAddress"];// "127.0.0.1";// System.Configuration.ConfigurationManager.AppSettings["mqaddress"].ToString();
  376. factory.UserName = AppConfigurtaionServices.Configuration["rabbitmq:UserName"];// "admin";// System.Configuration.ConfigurationManager.AppSettings["mquser"].ToString();
  377. factory.Password = AppConfigurtaionServices.Configuration["rabbitmq:Password"];// "admin";// System.Configuration.ConfigurationManager.AppSettings["mqpassword"].ToString();
  378. connection = factory.CreateConnection();
  379. var channel = connection.CreateModel();
  380. byte[] queuedata = EntityHelper.SerializeBytes<MacStatus>(status);
  381. if (queuedata == null)
  382. return -1;
  383. string StatusExchange = AppConfigurtaionServices.Configuration["rabbitmq:StatusExchange"];
  384. channel.ExchangeDeclare(exchange: StatusExchange, type: "fanout", durable: false, autoDelete: true);
  385. channel.BasicPublish(StatusExchange, "", null, queuedata); //开始传递
  386. channel.Close();
  387. return 1;
  388. }
  389. catch (Exception ex)
  390. {
  391. errorinfo = ex.Message.ToString();
  392. return -1;
  393. }
  394. finally
  395. {
  396. if (connection != null)
  397. connection.Close();
  398. }
  399. }
  400. public Hashtable BatUpdatePreStatus(Hashtable imputds, ref string errorinfo, ref int error)
  401. {
  402. try
  403. {
  404. if (imputds == null)
  405. {
  406. errorinfo = "传入数据不能为空,请确认";
  407. error = 1;
  408. return null;
  409. }
  410. ConstOrder order = JsonConvert.DeserializeObject<ConstOrder>((string)imputds[nameof(ConstOrder)]);
  411. List<LayoutDetail> entity = JsonConvert.DeserializeObject<List<LayoutDetail>>((string)imputds[nameof(LayoutDetail)]);
  412. string usercode = order.usercode;
  413. CurrDb.BeginTrans();
  414. MacStatusDal tempdal = new MacStatusDal(CurrDb);
  415. LayoutDetail result = tempdal.BatUpdatePreStatus(entity, order.usercode, ref errorinfo);
  416. if (result == null)
  417. {
  418. CurrDb.Rollback();
  419. return null;
  420. }
  421. Hashtable reds = new Hashtable();
  422. reds.Add(nameof(LayoutDetail), JsonConvert.SerializeObject(result));
  423. CurrDb.Commit();
  424. return reds;
  425. }
  426. catch (Exception ex)
  427. {
  428. errorinfo = ex.Message.ToString();
  429. error = 1;
  430. CurrDb.Rollback();
  431. return null;
  432. }
  433. finally
  434. {
  435. if (CurrDb != null)
  436. {
  437. CurrDb.Close();
  438. }
  439. }
  440. }
  441. public Hashtable ReadOrderMst(Hashtable imputds, ref string errorinfo, ref int error)
  442. {
  443. try
  444. {
  445. if (imputds == null)
  446. {
  447. errorinfo = "传入数据不能为空,请确认";
  448. error = 1;
  449. return null;
  450. }
  451. ConstOrder order = JsonConvert.DeserializeObject<ConstOrder>((string)imputds[nameof(ConstOrder)]);
  452. LayoutMst entity = JsonConvert.DeserializeObject<LayoutMst>((string)imputds[nameof(LayoutMst)]);
  453. string usercode = order.usercode;
  454. CurrDb.BeginTrans();
  455. List<MacOrder> macorders = new List<MacOrder>();
  456. List<OrderStatus> orderstatus = new List<OrderStatus>();
  457. LayoutMstDal tempdal = new LayoutMstDal(CurrDb);
  458. entity = tempdal.ReadOrderMst(entity, macorders, orderstatus, ref errorinfo);
  459. if (entity == null)
  460. {
  461. CurrDb.Rollback();
  462. return null;
  463. }
  464. Hashtable reds = new Hashtable();
  465. reds.Add(nameof(MacOrder), JsonConvert.SerializeObject(macorders));
  466. reds.Add(nameof(OrderStatus), JsonConvert.SerializeObject(orderstatus));
  467. CurrDb.Commit();
  468. return reds;
  469. }
  470. catch (Exception ex)
  471. {
  472. errorinfo = ex.Message.ToString();
  473. error = 1;
  474. CurrDb.Rollback();
  475. return null;
  476. }
  477. finally
  478. {
  479. if (CurrDb != null)
  480. {
  481. CurrDb.Close();
  482. }
  483. }
  484. }
  485. public Hashtable SynchronousMac(Hashtable imputds, ref string errorinfo, ref int error)
  486. {
  487. try
  488. {
  489. if (imputds == null)
  490. {
  491. errorinfo = "传入数据不能为空,请确认";
  492. error = 1;
  493. return null;
  494. }
  495. ConstOrder order = JsonConvert.DeserializeObject<ConstOrder>((string)imputds[nameof(ConstOrder)]);
  496. //TEntity entity = JsonConvert.DeserializeObject<TEntity>((string)imputds[nameof(TEntity)]);
  497. string usercode = order.usercode;
  498. CurrDb.BeginTrans();
  499. TEntityDal tempdal = new TEntityDal(CurrDb);
  500. int result = tempdal.SynchronousMac(order.usercode, ref errorinfo);
  501. if (result <= 0)
  502. {
  503. CurrDb.Rollback();
  504. return null;
  505. }
  506. Hashtable reds = new Hashtable();
  507. reds.Add(nameof(ConstOrder), JsonConvert.SerializeObject(order));
  508. CurrDb.Commit();
  509. return reds;
  510. }
  511. catch (Exception ex)
  512. {
  513. errorinfo = ex.Message.ToString();
  514. error = 1;
  515. CurrDb.Rollback();
  516. return null;
  517. }
  518. finally
  519. {
  520. if (CurrDb != null)
  521. {
  522. CurrDb.Close();
  523. }
  524. }
  525. }
  526. /// <summary>
  527. /// 读取状态信息
  528. /// </summary>
  529. /// <param name="imputds"></param>
  530. /// <param name="errorinfo"></param>
  531. /// <param name="error"></param>
  532. /// <returns></returns>
  533. public Hashtable ReadStatusInfo(Hashtable imputds, ref string errorinfo, ref int error)
  534. {
  535. try
  536. {
  537. if (imputds == null)
  538. {
  539. errorinfo = "传入数据不能为空,请确认";
  540. error = 1;
  541. return null;
  542. }
  543. ConstOrder order = JsonConvert.DeserializeObject<ConstOrder>((string)imputds[nameof(ConstOrder)]);
  544. LayoutDetail entity = JsonConvert.DeserializeObject<LayoutDetail>((string)imputds[nameof(LayoutDetail)]);
  545. //MacStatus status = JsonConvert.DeserializeObject<MacStatus>((string)imputds[nameof(MacStatus)]);
  546. //string usercode = order.usercode;
  547. ////CurrDb.BeginTrans();
  548. //List<MacOrder> macorders = new List<MacOrder>();
  549. //List<OrderStatus> orderstatus = new List<OrderStatus>();
  550. //LayoutMstDal tempdal = new LayoutMstDal(CurrDb);
  551. ////entity = tempdal.ReadOrderMst(entity, macorders, orderstatus, ref errorinfo);
  552. ////if (entity == null)
  553. ////{
  554. //// CurrDb.Rollback();
  555. //// return null;
  556. ////}
  557. //从MES系统里读取数据
  558. StatusEntityInfo result = ReadStatusInfoFromMes(entity.FCode);
  559. Hashtable reds = new Hashtable();
  560. reds.Add(nameof(StatusEntityInfo), JsonConvert.SerializeObject(result));
  561. //reds.Add(nameof(OrderStatus), JsonConvert.SerializeObject(orderstatus));
  562. //CurrDb.Commit();
  563. return reds;
  564. }
  565. catch (Exception ex)
  566. {
  567. errorinfo = ex.Message.ToString();
  568. error = 1;
  569. CurrDb.Rollback();
  570. return null;
  571. }
  572. }
  573. private StatusEntityInfo ReadStatusInfoFromMes(string maccode)
  574. {
  575. StatusEntityInfo entity = new StatusEntityInfo();
  576. IDatabase sqldb = DbFactory.Base("sqlconn");
  577. //查找机台正在进行中的lot
  578. string sqlstr = $@"select a.ID,b.PoCode,c.PartCode,d.FName partname from JobBooking a
  579. inner join LotMst b on a.LotNo = b.LotNo
  580. inner join ProductOrder c on b.PoCode = c.FCode
  581. inner join Part d on c.PartCode=d.Fcode
  582. where a.MacCode = '{maccode}' and a.StatusID = 1";
  583. DataTable jbdt = sqldb.FindTableFor(sqlstr, "JobBooking");
  584. if (jbdt.Rows.Count <= 0)
  585. return entity;
  586. entity.PartCode = jbdt.Rows[0]["PartCode"].ToString();
  587. entity.PkgModel = jbdt.Rows[0]["partname"].ToString();
  588. //读取报工记录
  589. sqlstr = $@"select b.FName from JbStaff a
  590. inner join Staff b on a.StaffCode = b.FCode
  591. where a.JbID = '{jbdt.Rows[0]["ID"].ToString()}' and a.StatusID = 1";
  592. DataTable tempdt = sqldb.FindTableFor(sqlstr, "JbStaff");
  593. if (tempdt.Rows.Count > 0)
  594. entity.OperUser = tempdt.Rows[0]["FName"].ToString();
  595. //读取材料信息
  596. sqlstr = $@"select a.PtCode,b.FName from PoPart a
  597. inner join Part b on a.PtCode=b.FCode
  598. where a.PoCode='{jbdt.Rows[0]["PoCode"].ToString()}'";
  599. tempdt = sqldb.FindTableFor(sqlstr, "PoPart");
  600. if (tempdt.Rows.Count > 0)
  601. {
  602. int row = tempdt.Rows.Count < 4 ? tempdt.Rows.Count : 4;
  603. for (int i = 0; i < row; i++)
  604. {
  605. EntityHelper.SetPropertyValue(entity, "MaterialModel" + i.ToString(), tempdt.Rows[i]["PtCode"].ToString());
  606. EntityHelper.SetPropertyValue(entity, "MaterialName" + i.ToString(), tempdt.Rows[i]["FName"].ToString());
  607. }
  608. }
  609. sqldb.Close();
  610. return entity;
  611. }
  612. /// <summary>
  613. /// 读取状态统计
  614. /// </summary>
  615. /// <param name="imputds"></param>
  616. /// <param name="errorinfo"></param>
  617. /// <param name="error"></param>
  618. /// <returns></returns>
  619. public Hashtable ReadStatusTotal(Hashtable imputds, ref string errorinfo, ref int error)
  620. {
  621. try
  622. {
  623. if (imputds == null)
  624. {
  625. errorinfo = "传入数据不能为空,请确认";
  626. error = 1;
  627. return null;
  628. }
  629. ConstOrder order = JsonConvert.DeserializeObject<ConstOrder>((string)imputds[nameof(ConstOrder)]);
  630. //LayoutDetail entity = JsonConvert.DeserializeObject<LayoutDetail>((string)imputds[nameof(LayoutDetail)]);
  631. //MacStatus status = JsonConvert.DeserializeObject<MacStatus>((string)imputds[nameof(MacStatus)]);
  632. //string usercode = order.usercode;
  633. ////CurrDb.BeginTrans();
  634. //List<MacOrder> macorders = new List<MacOrder>();
  635. //List<OrderStatus> orderstatus = new List<OrderStatus>();
  636. //LayoutMstDal tempdal = new LayoutMstDal(CurrDb);
  637. ////entity = tempdal.ReadOrderMst(entity, macorders, orderstatus, ref errorinfo);
  638. ////if (entity == null)
  639. ////{
  640. //// CurrDb.Rollback();
  641. //// return null;
  642. ////}
  643. //从MES系统里读取数据
  644. StatusTotal result = ReadStatusTotalFromMes();
  645. Hashtable reds = new Hashtable();
  646. reds.Add(nameof(StatusTotal), JsonConvert.SerializeObject(result));
  647. //reds.Add(nameof(OrderStatus), JsonConvert.SerializeObject(orderstatus));
  648. //CurrDb.Commit();
  649. return reds;
  650. }
  651. catch (Exception ex)
  652. {
  653. errorinfo = ex.Message.ToString();
  654. error = 1;
  655. CurrDb.Rollback();
  656. return null;
  657. }
  658. }
  659. public StatusTotal ReadStatusTotalFromMes()
  660. {
  661. StatusTotal entity = new StatusTotal();
  662. entity.Mtbfs = new List<MTBFDto>();
  663. IDatabase sqldb = DbFactory.Base("eap");
  664. McaEventStatisticByDayDal totaldal = new McaEventStatisticByDayDal(sqldb);
  665. //string condition = $" and StartTime>='2019-03-31 00:00:00'";
  666. DateTime dateStart = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 00:00:00"));
  667. DateTime dateEnd = DateTime.Now;
  668. string condition = $" and StartTime>='{DateTime.Now.ToString("yyyy-MM-dd")} 00:00:00'";
  669. List<MTBFDto> mtbfs = totaldal.GetMTBFs(condition, string.Empty, "machine").ToList();
  670. var pcode = mtbfs.GroupBy(t => t.pcode).Where(p => p.Key != null).ToList();
  671. if (pcode.Count <= 0)
  672. {
  673. }
  674. else
  675. {
  676. foreach (var item in pcode)
  677. {
  678. MTBFDto tempentity = new MTBFDto();
  679. tempentity.pcode = item.Key;
  680. tempentity.MTBF = item.Sum(t => t.MTBF);
  681. entity.Mtbfs.Add(tempentity);
  682. }
  683. }
  684. List<MachineEfficiency> effics = totaldal.GetMachineEfficienciesGroupByPcode(condition, string.Empty, dateStart, dateEnd).ToList();
  685. entity.Effics = effics == null ? new List<MachineEfficiency>() : effics;
  686. // var efficsgroupby = effics.GroupBy(t => t.PCode).Where(p => p.Key != null).ToList();
  687. //if (efficsgroupby.Count <= 0)
  688. //{
  689. //}
  690. //else
  691. //{
  692. // foreach (var item in efficsgroupby)
  693. // {
  694. // MachineEfficiency tempentity = item;
  695. // tempentity.PCode = item.Key;
  696. // tempentity.OverallEfficiency = item.Sum(t => t.OverallEfficiency) / item.Count();
  697. // entity.Effics.Add(tempentity);
  698. // }
  699. //}
  700. //entity.TotalMtbf = mtbfs.Sum(t => t.MTBF).Value;
  701. //entity.DieMtbf = mtbfs.Where(t => t.pcode == "DB").Sum(t => t.MTBF).Value;
  702. //entity.WireMtbf = mtbfs.Where(t => t.pcode == "WB").Sum(t => t.MTBF).Value;
  703. //List<MachineEfficiency> effics = totaldal.GetMachineEfficienciesGroupByMacModel(condition).ToList();
  704. //if(effics.Count>0)
  705. // entity.TotalEfficiency = (double)effics.Sum(t => t.OverallEfficiency)/effics.Count;
  706. //effics = effics.Where(t => t.PCode == "DB").ToList();
  707. //if (effics.Count > 0)
  708. // entity.DieEfficiency = (double)effics.Sum(t => t.OverallEfficiency)/ effics.Count;
  709. //effics = effics.Where(t => t.PCode == "WB").ToList();
  710. //if (effics.Count > 0)
  711. // entity.WireEfficiency = (double)effics.Sum(t => t.OverallEfficiency) / effics.Count;
  712. sqldb.Close();
  713. return entity;
  714. }
  715. public Hashtable UStandardStatus(Hashtable imputds, ref string errorinfo, ref int error)
  716. {
  717. try
  718. {
  719. if (imputds == null)
  720. {
  721. errorinfo = "传入数据不能为空,请确认";
  722. error = 1;
  723. return null;
  724. }
  725. ConstOrder order = JsonConvert.DeserializeObject<ConstOrder>((string)imputds[nameof(ConstOrder)]);
  726. List<StandardStatus> entitys = JsonConvert.DeserializeObject<List<StandardStatus>>((string)imputds[nameof(StandardStatus)]);
  727. string usercode = order.usercode;
  728. CurrDb.BeginTrans();
  729. int result = CurrDb.UpdateFor<StandardStatus>(entitys, usercode);
  730. if (result < 0)
  731. {
  732. CurrDb.Rollback();
  733. return null;
  734. }
  735. Hashtable reds = new Hashtable();
  736. reds.Add(nameof(StandardStatus), JsonConvert.SerializeObject(entitys[0]));
  737. CurrDb.Commit();
  738. return reds;
  739. }
  740. catch (Exception ex)
  741. {
  742. errorinfo = ex.Message.ToString();
  743. error = 1;
  744. CurrDb.Rollback();
  745. return null;
  746. }
  747. finally
  748. {
  749. if (CurrDb != null)
  750. {
  751. CurrDb.Close();
  752. }
  753. }
  754. }
  755. /// <summary>
  756. /// 上传程序文件
  757. /// </summary>
  758. /// <param name="imputds"></param>
  759. /// <param name="errorinfo"></param>
  760. /// <param name="error"></param>
  761. /// <returns></returns>
  762. //public Hashtable UpProgram(Hashtable imputds, ref string errorinfo, ref int error)
  763. //{
  764. // try
  765. // {
  766. // if (imputds == null)
  767. // {
  768. // errorinfo = "传入数据不能为空,请确认";
  769. // error = 1;
  770. // return null;
  771. // }
  772. // ConstOrder order = JsonConvert.DeserializeObject<ConstOrder>((string)imputds[nameof(ConstOrder)]);
  773. // OrderBlock entitys = JsonConvert.DeserializeObject<OrderBlock>((string)imputds[nameof(OrderBlock)]);
  774. // string usercode = order.usercode;
  775. // CurrDb.BeginTrans();
  776. // //上传文件
  777. // int result = UpProgram(CurrDb, entitys, usercode, ref errorinfo);
  778. // if(result==-100)
  779. // {
  780. // CurrDb.Commit();
  781. // return null;
  782. // }
  783. // else if(result<=0)
  784. // {
  785. // CurrDb.Rollback();
  786. // return null;
  787. // }
  788. // Hashtable reds = new Hashtable();
  789. // reds.Add(nameof(McaSecVMst), JsonConvert.SerializeObject(entitys.MainMsg));
  790. // CurrDb.Commit();
  791. // return reds;
  792. // }
  793. // catch (Exception ex)
  794. // {
  795. // errorinfo = ex.Message.ToString();
  796. // error = 1;
  797. // CurrDb.Rollback();
  798. // return null;
  799. // }
  800. //}
  801. //private int UpProgram(IDatabase db,OrderBlock entity,string usercode,ref string errorinfo)
  802. //{
  803. // try
  804. // {
  805. // string filedir = AppConfigurtaionServices.Configuration["ProgramDir"];
  806. // List<OrderData> datas = entity.Datalists.Where(t => t.ParentID == 0).OrderBy(t => t.FNum).ToList();
  807. // int parentid = datas[0].ID;//获取L的ID值
  808. // datas = entity.Datalists.Where(t => t.ParentID == parentid).OrderBy(t => t.FNum).ToList();
  809. // string programname = datas[0].FContent;
  810. // string programdata = datas[1].FContent;
  811. // byte[] filedatas = datas[1].OrgDatas;
  812. // //查找程序表,是否存在此程序名称的记录
  813. // string condition = $" and {EntityAttribute.GetPropertyCondition<ProgramMst>(nameof(ProgramMst.FName))}='{programname}'";
  814. // List<ProgramMst> programmst = db.FindListForCondition<ProgramMst>(condition, ref errorinfo).ToList();
  815. // ProgramMst programentity = null;
  816. // if(programmst.Count<=0)
  817. // {
  818. // //添加程序记录
  819. // programentity = new ProgramMst();
  820. // errorinfo = $"未找到程序【{programname}】,请先配置程序及其比对的参数。";
  821. // return -1;
  822. // }
  823. // else
  824. // {
  825. // programentity = programmst[0];
  826. // }
  827. // //比对参数,并保存比对结果
  828. // ParamsComMstDal comparedal = new ParamsComMstDal(db);
  829. // ParamsComMst commst = comparedal.CompareParams(entity.MainMsg.McaCode, programentity.ID, ref errorinfo);
  830. // if (commst == null)
  831. // return -1;
  832. // //if(commst.IsPass<=0)
  833. // //{
  834. // // errorinfo = "参数比对没有通过。";
  835. // // return -100;
  836. // //}
  837. // commst = comparedal.IUParamsComMst(commst, usercode, ref errorinfo);
  838. // if (commst == null)
  839. // return -1;
  840. // if (commst.IsPass <= 0)
  841. // {
  842. // errorinfo = "参数比对没有通过。";
  843. // return -100;
  844. // }
  845. // programentity.ServerPath = filedir + $"\\{programentity.ID}";
  846. // int result = UnityHelper.WriteFile(programentity.ServerPath, filedatas, ref errorinfo);
  847. // if (result <= 0)
  848. // return -1;
  849. // //更新服务器程序路径
  850. // result=db.UpdateFor<ProgramMst>(programentity, usercode);
  851. // if (result <= 0)
  852. // return -1;
  853. // return 1;
  854. // }
  855. // catch(Exception ex)
  856. // {
  857. // errorinfo = ex.Message.ToString();
  858. // return -1;
  859. // }
  860. //}
  861. /// <summary>
  862. /// 参数比对
  863. /// </summary>
  864. /// <param name="imputds"></param>
  865. /// <param name="errorinfo"></param>
  866. /// <param name="error"></param>
  867. /// <returns></returns>
  868. public Hashtable CompareParams(Hashtable imputds, ref string errorinfo, ref int error)
  869. {
  870. try
  871. {
  872. if (imputds == null)
  873. {
  874. errorinfo = "传入数据不能为空,请确认";
  875. error = 1;
  876. return null;
  877. }
  878. ConstOrder order = JsonConvert.DeserializeObject<ConstOrder>((string)imputds[nameof(ConstOrder)]);
  879. string maccode = (string)imputds["maccode"];
  880. CurrDb.BeginTrans();
  881. //读取机台信息
  882. string condition = $" and a.FCode='{maccode}'";
  883. Machine mac = CurrDb.FindListForCondition<Machine>(condition, ref errorinfo).ToList()[0];
  884. if (mac.IsControl <= 0)
  885. {
  886. //说明此机台没有开启参数比对功能,无需比对
  887. CurrDb.Commit();
  888. Hashtable tempreds = new Hashtable();
  889. tempreds.Add("result", "1");
  890. return tempreds;
  891. }
  892. //string programname = (string)imputds["programname"];
  893. ParamsComMstDal comdal = new ParamsComMstDal(CurrDb);
  894. //string programname = comdal.GetMacProgram(maccode, ref errorinfo);
  895. //if(string.IsNullOrEmpty(programname))
  896. //{
  897. // CurrDb.Rollback();
  898. // return null;
  899. //}
  900. ProgramMst programmst = comdal.GetMacProgram(mac, ref errorinfo);
  901. if (programmst == null)
  902. {
  903. string logerrorinfo = "";
  904. WriteLog.WriteLogStr(maccode, "", DateTime.Now, $"查找程序错误:{errorinfo}", ref logerrorinfo);
  905. CurrDb.Rollback();
  906. return null;
  907. }
  908. ParamsComMst mst = comdal.CompareParams(mac, programmst, ref errorinfo);
  909. if (mst == null)
  910. {
  911. string logerrorinfo = "";
  912. WriteLog.WriteLogStr(maccode, "", DateTime.Now, $"比对发生错误:{errorinfo}", ref logerrorinfo);
  913. CurrDb.Rollback();
  914. return null;
  915. }
  916. //插入比对记录
  917. mst = comdal.IUParamsComMst(mst, order.usercode, ref errorinfo);
  918. if (mst == null)
  919. {
  920. string logerrorinfo = "";
  921. WriteLog.WriteLogStr(maccode, "", DateTime.Now, $"添加比对记录发生错误:{errorinfo}", ref logerrorinfo);
  922. CurrDb.Rollback();
  923. return null;
  924. }
  925. CurrDb.Commit();
  926. //如果参数不对,就发送停机指令
  927. if (mst.IsPass <= 0)
  928. {
  929. MacOrderSendDal tempdal = new MacOrderSendDal(CurrDb);
  930. int result = tempdal.SendStopMac(maccode, ref errorinfo);
  931. if (result <= 0)
  932. {
  933. return null;
  934. }
  935. }
  936. Hashtable reds = new Hashtable();
  937. reds.Add("result", "1");
  938. return reds;
  939. }
  940. catch (Exception ex)
  941. {
  942. errorinfo = ex.Message.ToString();
  943. error = 1;
  944. CurrDb.Rollback();
  945. return null;
  946. }
  947. finally
  948. {
  949. if (CurrDb != null)
  950. {
  951. CurrDb.Close();
  952. }
  953. }
  954. }
  955. public Hashtable DownloadProgram(Hashtable imputds, ref string errorinfo, ref int error)
  956. {
  957. try
  958. {
  959. if (imputds == null)
  960. {
  961. errorinfo = "传入数据不能为空,请确认";
  962. error = 1;
  963. return null;
  964. }
  965. ConstOrder order = JsonConvert.DeserializeObject<ConstOrder>((string)imputds[nameof(ConstOrder)]);
  966. string maccode = (string)imputds["maccode"];
  967. string partcode = (string)imputds["partcode"];
  968. string pcode = (string)imputds["pcode"];
  969. //string programname = (string)imputds["programname"];
  970. CurrDb.BeginTrans();
  971. ProgramDal programdal = new ProgramDal(CurrDb);
  972. Machine mac = programdal.ReadMachine(maccode, ref errorinfo);
  973. if (mac == null)
  974. {
  975. string logerrorinfo = "";
  976. WriteLog.WriteLogStr(maccode, "", DateTime.Now, $"读取机台错误:{errorinfo}", ref logerrorinfo);
  977. CurrDb.Rollback();
  978. return null;
  979. }
  980. ProgramMst mst = programdal.FindProgram(mac, partcode, pcode, ref errorinfo);
  981. if (mst == null)
  982. {
  983. string logerrorinfo = "";
  984. WriteLog.WriteLogStr(maccode, "", DateTime.Now, $"查找程序错误:{errorinfo}", ref logerrorinfo);
  985. CurrDb.Rollback();
  986. return null;
  987. }
  988. ProgramDal dal = new ProgramDal(CurrDb);
  989. int result = dal.DownloadProgram(maccode, mst.FName, ref errorinfo);
  990. if (result <= 0)
  991. {
  992. string logerrorinfo = "";
  993. WriteLog.WriteLogStr(maccode, "", DateTime.Now, $"调程发生错误:{errorinfo}", ref logerrorinfo);
  994. CurrDb.Rollback();
  995. return null;
  996. }
  997. ////读取程序数据
  998. //string programdir = AppConfigurtaionServices.Configuration["ProgramDir"];
  999. //MacProgramDal macprogramdal = new MacProgramDal(CurrDb);
  1000. //int filelen = 0;
  1001. //string filepath = "";
  1002. //string programid = "";
  1003. //int result = macprogramdal.ReadMacProgram(mac.FCode, mst.FName, programdir, ref filelen, ref filepath, ref errorinfo);
  1004. //if (result <= 0)
  1005. //{
  1006. // CurrDb.Rollback();
  1007. // return null;
  1008. //}
  1009. //switch (mac.SupplierFCode)
  1010. //{
  1011. // case "ASM":
  1012. // AsmProgramDal comdal = new AsmProgramDal(CurrDb);
  1013. // mst = comdal.DownloadProgram(maccode, partcode, pcode, filelen, filepath, ref errorinfo);
  1014. // if (mst == null)
  1015. // {
  1016. // string logerrorinfo = "";
  1017. // WriteLog.WriteLogStr(maccode, "", DateTime.Now, $"下载程序错误:{errorinfo}", ref logerrorinfo);
  1018. // CurrDb.Rollback();
  1019. // return null;
  1020. // }
  1021. // break;
  1022. // case "KNS":
  1023. // KnsProgramDal comdal1 = new KnsProgramDal(CurrDb);
  1024. // mst = comdal1.DownloadProgram(mac, mst, filelen, filepath, ref errorinfo);
  1025. // if (mst == null)
  1026. // {
  1027. // string logerrorinfo = "";
  1028. // WriteLog.WriteLogStr(maccode, "", DateTime.Now, $"下载程序错误:{errorinfo}", ref logerrorinfo);
  1029. // CurrDb.Rollback();
  1030. // return null;
  1031. // }
  1032. // //选择程序
  1033. // int res = comdal1.SelectProgram(mac, mst.FName, ref errorinfo);
  1034. // if (res <= 0)
  1035. // {
  1036. // string logerrorinfo = "";
  1037. // WriteLog.WriteLogStr(maccode, "", DateTime.Now, $"选择程序错误:{errorinfo}", ref logerrorinfo);
  1038. // CurrDb.Rollback();
  1039. // return null;
  1040. // }
  1041. // break;
  1042. //}
  1043. Hashtable reds = new Hashtable();
  1044. reds.Add(nameof(ProgramMst), JsonConvert.SerializeObject(mst));
  1045. CurrDb.Commit();
  1046. return reds;
  1047. }
  1048. catch (Exception ex)
  1049. {
  1050. errorinfo = ex.Message.ToString();
  1051. error = 1;
  1052. CurrDb.Rollback();
  1053. return null;
  1054. }
  1055. finally
  1056. {
  1057. if (CurrDb != null)
  1058. {
  1059. CurrDb.Close();
  1060. }
  1061. }
  1062. }
  1063. public Hashtable GetQuality(Hashtable imputds, ref string errorinfo, ref int error)
  1064. {
  1065. try
  1066. {
  1067. if (imputds == null)
  1068. {
  1069. errorinfo = "传入数据不能为空,请确认";
  1070. error = 1;
  1071. return null;
  1072. }
  1073. ConstOrder order = JsonConvert.DeserializeObject<ConstOrder>((string)imputds[nameof(ConstOrder)]);
  1074. string maccode = (string)imputds["maccode"];
  1075. //string programname = (string)imputds["programname"];
  1076. CurrDb.BeginTrans();
  1077. ProgramDal programdal = new ProgramDal(CurrDb);
  1078. Machine mac = programdal.ReadMachine(maccode, ref errorinfo);
  1079. if (mac == null)
  1080. {
  1081. CurrDb.Rollback();
  1082. return null;
  1083. }
  1084. MacCountDal dal = new MacCountDal(CurrDb);
  1085. int result = dal.IMacCount(mac, order.usercode, ref errorinfo);
  1086. if (result < 0)
  1087. {
  1088. CurrDb.Rollback();
  1089. return null;
  1090. }
  1091. Hashtable reds = new Hashtable();
  1092. reds.Add("result", result);
  1093. CurrDb.Commit();
  1094. return reds;
  1095. }
  1096. catch (Exception ex)
  1097. {
  1098. errorinfo = ex.Message.ToString();
  1099. error = 1;
  1100. CurrDb.Rollback();
  1101. return null;
  1102. }
  1103. finally
  1104. {
  1105. if(CurrDb!=null)
  1106. {
  1107. CurrDb.Close();
  1108. }
  1109. }
  1110. }
  1111. public List<MacStatus> ReadLastStatus(ref string errorinfo)
  1112. {
  1113. string condition = $@" and {EntityAttribute.GetPropertyCondition<MacStatus>(nameof(MacStatus.ETime))}<date_format('2008-01-01 00:00:00', '%Y%m%d%H%i%s')";
  1114. // string condition = string.Empty;
  1115. List<MacStatus> laststatus = CurrDb.FindListForCondition<MacStatus>(condition, ref errorinfo).ToList();
  1116. List<MacStatus> result = new List<MacStatus>();
  1117. MacStatus entity = new MacStatus();
  1118. entity.StatusID = MacStatusVal.Run;
  1119. entity.StatusFName = "运行";
  1120. entity.FLen = laststatus.Where(t => t.StatusID == entity.StatusID).Count();
  1121. result.Add(entity);
  1122. entity = new MacStatus();
  1123. entity.StatusID = MacStatusVal.Error;
  1124. entity.StatusFName = "故障";
  1125. entity.FLen = laststatus.Where(t => t.StatusID == entity.StatusID).Count();
  1126. result.Add(entity);
  1127. entity = new MacStatus();
  1128. entity.StatusID = MacStatusVal.Pause;
  1129. entity.StatusFName = "暂停";
  1130. entity.FLen = laststatus.Where(t => t.StatusID == entity.StatusID).Count();
  1131. result.Add(entity);
  1132. entity = new MacStatus();
  1133. entity.StatusID = MacStatusVal.Idle;
  1134. entity.StatusFName = "空闲";
  1135. entity.FLen = laststatus.Where(t => t.StatusID == entity.StatusID).Count();
  1136. result.Add(entity);
  1137. entity = new MacStatus();
  1138. entity.StatusID = MacStatusVal.Pending;
  1139. entity.StatusFName = "待料";
  1140. entity.FLen = laststatus.Where(t => t.StatusID == entity.StatusID).Count();
  1141. result.Add(entity);
  1142. return result.Where(c => c.FLen > 0).ToList();
  1143. }
  1144. public List<ParamsComMst> ReadParamsComMst(ref string errorinfo)
  1145. {
  1146. string condition = $@" and a.IsPass<=0 and a.rectime between date_format('{DateTime.Now.AddDays(-30).ToString("yyyy-MM-dd")} 00:00:00', '%Y%m%d%H%i%s')
  1147. and date_format('{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}', '%Y%m%d%H%i%s')";
  1148. // string condition = $@" and a.IsPass<=0 ";
  1149. List<ParamsComMst> mts = CurrDb.FindListForCondition<ParamsComMst>(condition, ref errorinfo).Where(c => !string.IsNullOrEmpty(c.ProgramFName))
  1150. .OrderByDescending(c => c.RecTime).Take(5).ToList();
  1151. return mts;
  1152. }
  1153. }
  1154. }