CaseFileCompareController.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680
  1. using DocumentFormat.OpenXml.InkML;
  2. using DynamicExpresso;
  3. using Microsoft.AspNetCore.Authorization;
  4. using Microsoft.AspNetCore.Http;
  5. using Microsoft.AspNetCore.Mvc;
  6. using Microsoft.EntityFrameworkCore;
  7. using Microsoft.EntityFrameworkCore.Query.SqlExpressions;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Data;
  11. using System.Diagnostics;
  12. using System.Dynamic;
  13. using System.Linq;
  14. using System.Linq.Expressions;
  15. using System.Text.RegularExpressions;
  16. using wispro.sp.api.AppealHandler;
  17. using wispro.sp.api.Services;
  18. using wispro.sp.entity;
  19. using wispro.sp.entity.CompareCase;
  20. using wispro.sp.share;
  21. using static OneOf.Types.TrueFalseOrNull;
  22. namespace wispro.sp.api.Controllers
  23. {
  24. [Route("api/[controller]/[action]")]
  25. [ApiController]
  26. public class CaseFileCompareController : ControllerBase
  27. {
  28. spDbContext Context;
  29. IFileTaskService fileTaskService;
  30. public CaseFileCompareController(spDbContext context, IFileTaskService _fileTaskService)
  31. {
  32. Context = context;
  33. fileTaskService = _fileTaskService;
  34. }
  35. [Authorize]
  36. public ApiSaveResponse Save(CaseInfo caseInfo)
  37. {
  38. ApiSaveResponse ret = new ApiSaveResponse();
  39. ret.Success = true;
  40. using (Context.Database.BeginTransaction())
  41. {
  42. try
  43. {
  44. #region 客户处理
  45. if (caseInfo.Customer != null && !string.IsNullOrEmpty(caseInfo.Customer.Name))
  46. {
  47. var temCustomer = Context.Customers.Where<Customer>(c => c.Name == caseInfo.Customer.Name).FirstOrDefault();
  48. if (temCustomer == null)
  49. {
  50. temCustomer = new Customer() { Name = caseInfo.Customer.Name };
  51. //item.Customer.Id = 0;
  52. Context.Customers.Add(temCustomer);
  53. Context.SaveChanges();
  54. caseInfo.Customer = temCustomer;
  55. //item.CustomerId = item.Customer.Id;
  56. }
  57. else
  58. {
  59. caseInfo.Customer = temCustomer;
  60. }
  61. caseInfo.CustomerId = caseInfo.Customer.Id;
  62. caseInfo.Customer = null;
  63. }
  64. else
  65. {
  66. caseInfo.Customer = null;
  67. }
  68. #endregion
  69. #region 审核人
  70. if (caseInfo.Reviewer != null && !string.IsNullOrEmpty(caseInfo.Reviewer.Name))
  71. {
  72. var temReviewer = Context.Staffs.Where<Staff>(c => c.Name == caseInfo.Reviewer.Name).FirstOrDefault();
  73. if (temReviewer == null)
  74. {
  75. temReviewer = new Staff() { Name = caseInfo.Reviewer.Name };
  76. //item.Customer.Id = 0;
  77. Context.Staffs.Add(temReviewer);
  78. Context.SaveChanges();
  79. caseInfo.Reviewer = temReviewer;
  80. //item.CustomerId = item.Customer.Id;
  81. }
  82. else
  83. {
  84. caseInfo.Reviewer = temReviewer;
  85. }
  86. caseInfo.ReviewerId = caseInfo.Reviewer.Id;
  87. caseInfo.Reviewer = null;
  88. }
  89. else
  90. {
  91. caseInfo.Reviewer = null;
  92. }
  93. #endregion
  94. if (caseInfo.DRRAbstract != null) {
  95. Context.CaseCompareResults.Add(caseInfo.DRRAbstract);
  96. Context.SaveChanges();
  97. caseInfo.DRRAbstractId = caseInfo.DRRAbstract.Id;
  98. caseInfo.DRRAbstract = null;
  99. }
  100. if (caseInfo.DRRCalim != null)
  101. {
  102. Context.CaseCompareResults.Add(caseInfo.DRRCalim);
  103. Context.SaveChanges();
  104. caseInfo.DRRCalimId = caseInfo.DRRCalim.Id;
  105. caseInfo.DRRCalim = null;
  106. }
  107. if (caseInfo.DRRFulltext != null)
  108. {
  109. Context.CaseCompareResults.Add(caseInfo.DRRFulltext);
  110. Context.SaveChanges();
  111. caseInfo.DRRFulltextId = caseInfo.DRRFulltext.Id;
  112. caseInfo.DRRFulltext = null;
  113. }
  114. if (caseInfo.DRRAll != null)
  115. {
  116. Context.CaseCompareResults.Add(caseInfo.DRRAll);
  117. Context.SaveChanges();
  118. caseInfo.DRRAllId = caseInfo.DRRAll.Id;
  119. caseInfo.DRRAll = null;
  120. }
  121. if (caseInfo.RFRAbstract != null)
  122. {
  123. Context.CaseCompareResults.Add(caseInfo.RFRAbstract);
  124. Context.SaveChanges();
  125. caseInfo.RFRAbstractId = caseInfo.RFRAbstract.Id;
  126. caseInfo.RFRAbstract = null;
  127. }
  128. if (caseInfo.RFRCalim != null)
  129. {
  130. Context.CaseCompareResults.Add(caseInfo.RFRCalim);
  131. Context.SaveChanges();
  132. caseInfo.RFRCalimId = caseInfo.RFRCalim.Id;
  133. caseInfo.RFRCalim = null;
  134. }
  135. if (caseInfo.RFRFulltext != null)
  136. {
  137. Context.CaseCompareResults.Add(caseInfo.RFRFulltext);
  138. Context.SaveChanges();
  139. caseInfo.RFRFulltextId = caseInfo.RFRFulltext.Id;
  140. caseInfo.RFRFulltext = null;
  141. }
  142. if (caseInfo.RFRAll != null)
  143. {
  144. Context.CaseCompareResults.Add(caseInfo.RFRAll);
  145. Context.SaveChanges();
  146. caseInfo.RFRAllId = caseInfo.RFRAll.Id;
  147. caseInfo.RFRAll = null;
  148. }
  149. Context.CaseInfos.Add(caseInfo);
  150. Context.SaveChanges();
  151. Context.Database.CommitTransaction();
  152. }
  153. catch (Exception ex)
  154. {
  155. ret.Success = false;
  156. ret.ErrorMessage = ex.Message;
  157. Context.Database.RollbackTransaction();
  158. }
  159. }
  160. return ret;
  161. }
  162. public ListApiResponse<CaseInfo> QueryFilter(QueryFilter queryFilter)
  163. {
  164. ListApiResponse<CaseInfo> ret = new ListApiResponse<CaseInfo>();
  165. IQueryable<CaseInfo> response = NewMethod(queryFilter);
  166. int totals = response.Count();
  167. if (totals > 0 && totals < (queryFilter.PageIndex) * queryFilter.PageSize)
  168. {
  169. response = response
  170. .Include(pi => pi.DRRCalim)
  171. .Include(pi => pi.DRRAbstract)
  172. .Include(pi => pi.DRRFulltext)
  173. .Include(pi => pi.DRRAll)
  174. .Include(pi => pi.RFRCalim)
  175. .Include(pi => pi.RFRAbstract)
  176. .Include(pi => pi.RFRFulltext)
  177. .Include(pi => pi.RFRAll)
  178. .Include(pi => pi.Customer)
  179. .Include(pi => pi.Reviewer)
  180. .OrderConditions<CaseInfo>(queryFilter.Sorts)
  181. .Skip((queryFilter.PageIndex - 1) * queryFilter.PageSize)
  182. .Take(totals - (queryFilter.PageIndex - 1) * queryFilter.PageSize);
  183. //.Pager<PerformanceItem>(1, queryFilter.PageSize, out totals);
  184. }
  185. else
  186. {
  187. response = response
  188. .Include(pi => pi.DRRCalim)
  189. .Include(pi => pi.DRRAbstract)
  190. .Include(pi => pi.DRRFulltext)
  191. .Include(pi=>pi.DRRAll)
  192. .Include(pi => pi.RFRCalim)
  193. .Include(pi => pi.RFRAbstract)
  194. .Include(pi => pi.RFRFulltext)
  195. .Include(pi => pi.RFRAll)
  196. .Include(pi => pi.Customer)
  197. .Include(pi => pi.Reviewer)
  198. .OrderConditions<CaseInfo>(queryFilter.Sorts)
  199. .Skip((queryFilter.PageIndex - 1) * queryFilter.PageSize)
  200. .Take(queryFilter.PageSize);
  201. }
  202. ret.TotalCount = totals;
  203. var retList = response.ToList<CaseInfo>();
  204. #region 将某些属性设为null,避免循环取值造成返回json过大
  205. foreach (CaseInfo item in retList)
  206. {
  207. if (item.Customer != null)
  208. {
  209. item.Customer.PerformanceItems = null;
  210. item.Customer.ResponseMan = null;
  211. }
  212. if (item.Reviewer != null)
  213. {
  214. item.Reviewer.Customers = null;
  215. item.Reviewer.ExternalHandlerItems = null;
  216. item.Reviewer.ItemStaffs = null;
  217. item.Reviewer.AllocationRatios = null;
  218. item.Reviewer.ReviewerItems = null;
  219. }
  220. }
  221. #endregion
  222. ret.Results = retList.ToList();
  223. return ret;
  224. }
  225. public bool CaseExist(string caseNo)
  226. {
  227. return Context.CaseInfos.Where(p => p.CaseNo == caseNo.Trim()).Count() > 0;
  228. }
  229. /// <summary>
  230. /// 计算案件的zScore
  231. /// </summary>
  232. /// <param name="start">定稿日开始时间</param>
  233. /// <param name="end">定稿日结束时间</param>
  234. /// <param name="type">0:基于文本相似度计算,1:基于文本修改差异度计算</param>
  235. /// <returns></returns>
  236. public IList<Object> CalCustomer_mean(DateTime start,DateTime end,int type=0)
  237. {
  238. var caseList = Context.CaseInfos.Where<CaseInfo>(
  239. p => p.FinalVersionDate >= start && p.FinalVersionDate <= end)
  240. .Include(p=>p.Customer)
  241. .Include(p=>p.Reviewer)
  242. .Include(p=>p.DRRAbstract)
  243. .Include(p => p.DRRAbstract)
  244. .Include(p => p.DRRCalim)
  245. .Include(p => p.DRRFulltext)
  246. .Include(p => p.DRRAll)
  247. .Include(p => p.RFRAbstract)
  248. .Include(p => p.RFRCalim)
  249. .Include(p => p.RFRFulltext)
  250. .Include(p => p.RFRAll);
  251. int iTotals = caseList.Count();
  252. int iIndex = 0;
  253. List<Object> retList = new List<Object>();
  254. #region 计算客户相似度平均值和标准方差
  255. List<CustomerAvg_Std> avg_std1 = new List<CustomerAvg_Std>();
  256. List<CustomerAvg_Std> avg_std2 = new List<CustomerAvg_Std>();
  257. foreach (var caseInfo in caseList)
  258. {
  259. iIndex++;
  260. Debug.WriteLine($"{iIndex}/{iTotals}\t{caseInfo.CaseNo}\t{caseInfo.DRRAbstractId},{caseInfo.DRRCalimId},{caseInfo.DRRFulltextId},{caseInfo.DRRAllId},{caseInfo.RFRAbstractId},{caseInfo.RFRCalimId},{caseInfo.RFRFulltextId},{caseInfo.RFRAllId}");
  261. string tmpCustomerName = "未知";
  262. if(caseInfo.Customer!= null)
  263. {
  264. tmpCustomerName = caseInfo.Customer.Name;
  265. }
  266. var one = avg_std1.Where<CustomerAvg_Std>(p => p.Name == tmpCustomerName).FirstOrDefault();
  267. if (one == null)
  268. {
  269. one = new CustomerAvg_Std() { Name = tmpCustomerName };
  270. avg_std1.Add(one);
  271. }
  272. var two = avg_std2.Where<CustomerAvg_Std>(p => p.Name == tmpCustomerName).FirstOrDefault();
  273. if (two == null)
  274. {
  275. two = new CustomerAvg_Std() { Name = tmpCustomerName };
  276. avg_std2.Add(two);
  277. }
  278. double? oneTmp = getCalValue(caseInfo, type, 0);
  279. if(oneTmp != null)
  280. {
  281. one.Sum += oneTmp.Value;
  282. one.SquareSum += oneTmp.Value * oneTmp.Value;
  283. one.count += 1;
  284. }
  285. double? twoTmp = getCalValue(caseInfo, type, 1);
  286. if (twoTmp != null)
  287. {
  288. two.Sum += twoTmp.Value;
  289. two.SquareSum += twoTmp.Value * twoTmp.Value;
  290. two.count += 1;
  291. }
  292. }
  293. #endregion
  294. System.Data.DataTable dt = new System.Data.DataTable();
  295. dt.Columns.Add("我方文号");
  296. dt.Columns.Add("案件名称");
  297. dt.Columns.Add("客户");
  298. dt.Columns.Add("处理人");
  299. dt.Columns.Add("核稿人");
  300. dt.Columns.Add("内部核稿分数");
  301. dt.Columns.Add("外部核稿分数");
  302. dt.Columns.Add("备注");
  303. foreach (var item in caseList)
  304. {
  305. string tmpCustomerName = "未知";
  306. if (item.Customer != null)
  307. {
  308. tmpCustomerName = item.Customer.Name;
  309. }
  310. var one = avg_std1.Where<CustomerAvg_Std>(p => p.Name == tmpCustomerName).FirstOrDefault();
  311. var two = avg_std2.Where<CustomerAvg_Std>(p => p.Name == tmpCustomerName).FirstOrDefault();
  312. double? oneSim = getCalValue(item,type,0);
  313. double? twoSim = getCalValue(item, type, 1); ;
  314. if(oneSim == null)
  315. {
  316. oneSim = 1;
  317. }
  318. if (twoSim == null)
  319. {
  320. twoSim = 1;
  321. }
  322. DataRow row = dt.NewRow();
  323. row["我方文号"] = item.CaseNo;
  324. row["案件名称"] = item.CaseName;
  325. row["客户"] = item.Customer?.Name;
  326. row["核稿人"] = item.Reviewer?.Name;
  327. row["处理人"] = item.Handlers;
  328. var zScoreA = (oneSim -one.Average)/one.Std_Deviation;
  329. row["内部核稿分数"] = zScoreA;
  330. var zScoreB = (twoSim -two.Average)/two.Std_Deviation;
  331. row["外部核稿分数"] = zScoreB;
  332. var distince = Math.Sqrt(zScoreB.Value * zScoreB.Value + zScoreA.Value * zScoreA.Value);
  333. if (type == 0 || type==2)
  334. {
  335. if (distince > 3)
  336. {
  337. if (zScoreA.Value > 0 && zScoreB.Value > 0)
  338. {
  339. row["备注"] = "内部核稿、外部核稿修改都较少![撰稿人给力或客户友好]";
  340. }
  341. if (zScoreA.Value > 0 && zScoreB.Value < 0)
  342. {
  343. row["备注"] = "内部核稿较少、外部核稿修改较多![核稿人没有尽责!]";
  344. }
  345. if (zScoreA.Value < 0 && zScoreB.Value > 0)
  346. {
  347. row["备注"] = "内部核稿较多、外部核稿修改都较少![核稿人给力]";
  348. }
  349. if (zScoreA.Value < 0 && zScoreB.Value < 0)
  350. {
  351. row["备注"] = "内部核稿和外部核稿修改都较多![案件沟通问题?]";
  352. }
  353. }
  354. }
  355. else
  356. {
  357. if (distince > 3)
  358. {
  359. if (zScoreA.Value > 0 && zScoreB.Value > 0)
  360. {
  361. row["备注"] = "内部核稿和外部核稿修改都较多![案件沟通问题?]";
  362. }
  363. if (zScoreA.Value > 0 && zScoreB.Value < 0)
  364. {
  365. row["备注"] = "内部核稿较多、外部核稿修改都较少![核稿人给力]";
  366. }
  367. if (zScoreA.Value < 0 && zScoreB.Value > 0)
  368. {
  369. row["备注"] = "内部核稿较少、外部核稿修改较多![核稿人没有尽责!]";
  370. }
  371. if (zScoreA.Value < 0 && zScoreB.Value < 0)
  372. {
  373. row["备注"] = "内部核稿、外部核稿修改都较少![撰稿人给力或客户友好]";
  374. }
  375. }
  376. }
  377. dt.Rows.Add(row);
  378. retList.Add(
  379. new
  380. {
  381. Id = item.Id,
  382. CaseNo = item.CaseNo,
  383. CaseName = item.CaseName,
  384. Customer = item.Customer,
  385. Reviewer = item.Reviewer,
  386. Handlers = item.Handlers,
  387. zScoreA = (oneSim - one.Average) / one.Std_Deviation,
  388. zScoreB = (twoSim - two.Average) / two.Std_Deviation
  389. }
  390. );
  391. }
  392. wispro.sp.utility.NPOIExcel.DataTableToExcel(dt,$"c:\\temp\\{DateTime.Now.ToString("yyyyMMdd")}-内部核稿外部核稿情况案件清单_{typeName(type)}.xlsx");
  393. return retList;
  394. }
  395. private double? getCalValue(CaseInfo caseInfo,int type,int stage)
  396. {
  397. double? calValue = null;
  398. switch (type)
  399. {
  400. case 0:
  401. if(stage == 0)
  402. {
  403. if(caseInfo.DRRFulltext != null && caseInfo.DRRAbstract != null)
  404. {
  405. calValue = caseInfo.DRRAll.TextSimilarity;
  406. }
  407. else
  408. {
  409. if(caseInfo.DRRCalim != null)
  410. {
  411. calValue = caseInfo.DRRCalim.TextSimilarity;
  412. }
  413. }
  414. }
  415. else
  416. {
  417. if (caseInfo.RFRFulltext != null && caseInfo.RFRAbstract != null)
  418. {
  419. calValue = caseInfo.RFRAll.TextSimilarity;
  420. }
  421. else
  422. {
  423. if (caseInfo.RFRCalim != null)
  424. {
  425. calValue = caseInfo.RFRCalim.TextSimilarity;
  426. }
  427. }
  428. }
  429. break;
  430. case 1:
  431. if (stage == 0)
  432. {
  433. if (caseInfo.DRRFulltext != null && caseInfo.DRRAbstract != null)
  434. {
  435. calValue = caseInfo.DRRAll.diffRate;
  436. }
  437. else
  438. {
  439. if (caseInfo.DRRCalim != null)
  440. {
  441. calValue = caseInfo.DRRCalim.diffRate;
  442. }
  443. }
  444. }
  445. else
  446. {
  447. if (caseInfo.RFRFulltext != null && caseInfo.RFRAbstract != null)
  448. {
  449. calValue = caseInfo.RFRAll.diffRate;
  450. }
  451. else
  452. {
  453. if (caseInfo.RFRCalim != null)
  454. {
  455. calValue = caseInfo.RFRCalim.diffRate;
  456. }
  457. }
  458. }
  459. break;
  460. case 2:
  461. if (stage == 0)
  462. {
  463. if(caseInfo.DRRFulltext != null && caseInfo.DRRCalim!= null)
  464. {
  465. calValue = caseInfo.DRRCalim.TextSimilarity * 0.7 + caseInfo.DRRFulltext.TextSimilarity * 0.3;
  466. }
  467. else
  468. {
  469. if( caseInfo.DRRCalim != null)
  470. {
  471. calValue = caseInfo.DRRCalim.TextSimilarity;
  472. }
  473. else
  474. {
  475. if(caseInfo.DRRAll != null)
  476. {
  477. calValue = caseInfo.DRRAll.TextSimilarity;
  478. }
  479. }
  480. }
  481. }
  482. else
  483. {
  484. if (caseInfo.RFRFulltext != null && caseInfo.RFRCalim != null)
  485. {
  486. calValue = caseInfo.RFRCalim.TextSimilarity * 0.7 + caseInfo.RFRFulltext.TextSimilarity * 0.3;
  487. }
  488. else
  489. {
  490. if (caseInfo.RFRCalim != null)
  491. {
  492. calValue = caseInfo.RFRCalim.TextSimilarity;
  493. }
  494. else
  495. {
  496. if (caseInfo.RFRAll != null)
  497. {
  498. calValue = caseInfo.RFRAll.TextSimilarity;
  499. }
  500. }
  501. }
  502. }
  503. break;
  504. }
  505. return calValue;
  506. }
  507. private string typeName(int type)
  508. {
  509. switch (type)
  510. {
  511. case 0:
  512. return "文本相似度计算";
  513. case 1:
  514. return "字符修改计算";
  515. case 2:
  516. return "权要权重70说明书30";
  517. }
  518. return "";
  519. }
  520. public IList<Object> CalMean_Std(DateTime start,DateTime end)
  521. {
  522. double AverageA = Context.CaseInfos.Where<CaseInfo>(
  523. p => p.FinalVersionDate >= start && p.FinalVersionDate <= end && p.DRRCalim!= null)
  524. .Average(x=>x.DRRCalim.TextSimilarity);
  525. double AverageB = Context.CaseInfos.Where<CaseInfo>(
  526. p => p.FinalVersionDate >= start && p.FinalVersionDate <= end && p.RFRAll != null)
  527. .Average(x => x.RFRAll.TextSimilarity);
  528. double stdA = Math.Sqrt( Context.CaseInfos.Where<CaseInfo>(
  529. p => p.FinalVersionDate >= start && p.FinalVersionDate <= end)
  530. .Average((x => (x.DRRCalim.TextSimilarity - AverageA) * (x.DRRCalim.TextSimilarity - AverageA))));
  531. double stdB = Math.Sqrt(Context.CaseInfos.Where<CaseInfo>(
  532. p => p.FinalVersionDate >= start && p.FinalVersionDate <= end)
  533. .Average((x => (x.RFRAll.TextSimilarity - AverageB) * (x.RFRAll.TextSimilarity - AverageB))));
  534. var response2 = Context.CaseInfos.Where<CaseInfo>(
  535. p => p.FinalVersionDate >= start && p.FinalVersionDate <= end)
  536. .Include(p=>p.DRRCalim)
  537. .Include(p=>p.RFRAll);
  538. IList<Object> results = new List<Object>();
  539. foreach(var item in response2.ToList())
  540. {
  541. results.Add(
  542. new {
  543. Id = item.Id,
  544. CaseNo = item.CaseNo,
  545. CaseName = item.CaseName,
  546. Customer = item.Customer,
  547. Reviewer = item.Reviewer,
  548. Handlers = item.Handlers,
  549. zScoreA = (item.DRRCalim?.TextSimilarity -AverageA)/stdA,
  550. zScoreB = (item.RFRAll?.TextSimilarity - AverageB) /stdB
  551. }
  552. );
  553. }
  554. return results;
  555. }
  556. private string GetExpress(IList<FieldCondition> conditions)
  557. {
  558. string str = "";
  559. foreach (var c in conditions)
  560. {
  561. if (string.IsNullOrEmpty(str))
  562. {
  563. str = c.ToExpressString("s");
  564. }
  565. else
  566. {
  567. if (c.LogicOperate == LogicEnum.And)
  568. {
  569. str = $"({str}) && {c.ToExpressString("s")}";
  570. }
  571. else
  572. {
  573. str = $"({str}) || {c.ToExpressString("s")}";
  574. }
  575. }
  576. }
  577. return str;
  578. }
  579. private IQueryable<CaseInfo> NewMethod(QueryFilter queryFilter)
  580. {
  581. string strExpress = "";
  582. if (queryFilter.ConditionTree != null)
  583. {
  584. strExpress = GetExpress(queryFilter.ConditionTree);
  585. }
  586. var interpreter = new Interpreter();
  587. if (string.IsNullOrEmpty(strExpress))
  588. {
  589. return new spDbContext().CaseInfos.Where<CaseInfo>(p=>(p.Id>0));
  590. }
  591. else
  592. {
  593. Expression<Func<CaseInfo, bool>> dynamicWhere = interpreter.ParseAsExpression<Func<CaseInfo, bool>>(strExpress, "s");
  594. IQueryable<CaseInfo> response = new spDbContext().CaseInfos.Where<CaseInfo>(dynamicWhere);
  595. return response;
  596. }
  597. }
  598. }
  599. }