ParticleAnalysis.cs 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895
  1. 
  2. using OTSCommon.DBOperate;
  3. using OTSIncAReportApp.DataOperation.DataAccess;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Data;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using static OTSDataType.otsdataconst;
  11. using static OTSIncAReportApp.OTSReport_Export;
  12. namespace OTSIncAReportApp._1_UI.OTSReportExport.DataIntegration
  13. {
  14. /// <summary>
  15. /// 颗粒分析
  16. /// </summary>
  17. class ParticleAnalysis
  18. {
  19. /// <summary>
  20. /// 大分类
  21. /// </summary>
  22. /// <returns></returns>
  23. public DataTable GetLargeClassification(BasicData basicData)
  24. {
  25. DataTable data = basicData.GetDBData();
  26. //获取粒级表
  27. List<string> colid = basicData.GetParticlesizeTable();
  28. DataTable ls_partsize_dt = new DataTable();
  29. ls_partsize_dt.TableName = "PartSize";
  30. for (int i = 0; i < colid.Count; i++)
  31. {
  32. ls_partsize_dt.Columns.Add("c" + (i + 1).ToString());
  33. }
  34. DataTable ls_Particel_dt = new DataTable();
  35. ls_Particel_dt.TableName = "Particel";
  36. DataRow dr = ls_partsize_dt.NewRow();
  37. int colidCount = 1;
  38. for (int i = 0; i < colid.Count; i++)
  39. {
  40. if (colid.Count < i)
  41. {
  42. dr["c" + (i + 1).ToString()] = "";
  43. }
  44. else
  45. {
  46. dr["c" + (i + 1).ToString()] = colid[i];
  47. ls_Particel_dt.Columns.Add("c" + (i + 1).ToString(), typeof(double));
  48. colidCount++;
  49. }
  50. }
  51. ls_partsize_dt.Rows.Add(dr);
  52. ls_Particel_dt.Columns.Add("Name");
  53. ls_Particel_dt.Columns.Add("total", typeof(double));
  54. ls_Particel_dt.Columns.Add("TypeId");
  55. ls_Particel_dt.Columns.Add("Class");
  56. for (int i = 0; i < data.Rows.Count; i++)
  57. {
  58. DataRow dr2 = ls_Particel_dt.NewRow();
  59. dr2["Name"] = data.Rows[i]["TypeName"].ToString();
  60. dr2["Class"] = data.Rows[i]["Class"].ToString();
  61. dr2["TypeId"] = data.Rows[i]["TypeId"].ToString();//获取分类编号
  62. for (int j = 1; j < colidCount; j++)
  63. {
  64. if (colid.Count >= j)
  65. {
  66. dr2["c" + j.ToString()] = Convert.ToDouble(data.Rows[i][colid[j - 1]]);
  67. }
  68. }
  69. if (dr2["Name"].ToString() != "" && dr2["Name"].ToString().IndexOf("number") < 0)
  70. {
  71. dr2["total"] = "0"; //求合
  72. double d_total = 0;
  73. for (int j = 1; j < colidCount; j++)
  74. {
  75. if (colid.Count >= j)
  76. {
  77. d_total = d_total + Convert.ToInt64(data.Rows[i][colid[j - 1]]);
  78. }
  79. }
  80. dr2["total"] = d_total.ToString();
  81. }
  82. ls_Particel_dt.Rows.Add(dr2);
  83. }
  84. //按照list列表进行物质类排序,物质类中的元素分类按照面积的大小进行排序
  85. List<string> ClassName = new List<string>();
  86. DataTable getClass_dt = basicData.GetAllClass();
  87. for (int i = 0; i < getClass_dt.Rows.Count; i++)
  88. {
  89. if (getClass_dt.Rows[i]["GroupName"].ToString() != "NOT_INCLUTION" && getClass_dt.Rows[i]["GroupName"].ToString() != "Invalid")
  90. if (getClass_dt.Rows[i]["GroupName"].ToString() == "")
  91. ClassName.Add("NULL");
  92. else
  93. ClassName.Add(getClass_dt.Rows[i]["GroupName"].ToString());
  94. }
  95. //获取大分类信息
  96. DataTable dt = QuantityOfIntegratedSubstances(ls_Particel_dt, ClassName);
  97. return dt;
  98. }
  99. /// <summary>
  100. /// 小分类
  101. /// </summary>
  102. /// <returns></returns>
  103. public DataTable GetSubClassification(BasicData basicData)
  104. {
  105. DataTable data = basicData.GetDBData();
  106. //获取粒级表
  107. List<string> colid = new List<string>();
  108. colid = basicData.GetParticlesizeTable();
  109. //------------------------------------------------
  110. DataTable ls_partsize_dt = new DataTable();
  111. ls_partsize_dt.TableName = "PartSize";
  112. for (int i=0;i< colid.Count;i++)
  113. {
  114. ls_partsize_dt.Columns.Add("c"+(i+1).ToString());
  115. }
  116. DataRow dr = ls_partsize_dt.NewRow();
  117. DataTable ls_Particel_dt = new DataTable();
  118. ls_Particel_dt.TableName = "Particel";
  119. int colidCount = 1;
  120. for (int i = 0; i < colid.Count; i++)
  121. {
  122. if (colid.Count < i)
  123. {
  124. dr["c" + (i + 1).ToString()] = "";
  125. }
  126. else
  127. {
  128. dr["c" + (i + 1).ToString()] = colid[i];
  129. ls_Particel_dt.Columns.Add("c" + (i + 1).ToString(), typeof(double));
  130. colidCount++;
  131. }
  132. }
  133. ls_Particel_dt.Columns.Add("Name");
  134. ls_Particel_dt.Columns.Add("total", typeof(double));
  135. ls_Particel_dt.Columns.Add("TypeId");
  136. ls_Particel_dt.Columns.Add("Class");
  137. for (int i = 0; i < data.Rows.Count; i++)
  138. {
  139. DataRow dr2 = ls_Particel_dt.NewRow();
  140. dr2["Name"] = data.Rows[i]["TypeName"].ToString();
  141. dr2["Class"] = data.Rows[i]["Class"].ToString();
  142. dr2["TypeId"] = data.Rows[i]["TypeId"].ToString();//获取分类编号
  143. for (int j = 1; j < colidCount; j++)
  144. {
  145. if (colid.Count >= j)
  146. {
  147. dr2["c" + j.ToString()] = Convert.ToDouble(data.Rows[i][colid[j - 1]]);
  148. }
  149. }
  150. if (dr2["Name"].ToString() != "" && dr2["Name"].ToString().IndexOf("number") < 0)
  151. {
  152. dr2["total"] = "0"; //求合
  153. double d_total = 0;
  154. for (int j = 1; j < colidCount; j++)
  155. {
  156. if (colid.Count >= j)
  157. {
  158. d_total = d_total + Convert.ToInt64(data.Rows[i][colid[j - 1]]);
  159. }
  160. }
  161. dr2["total"] = d_total.ToString();
  162. }
  163. ls_Particel_dt.Rows.Add(dr2);
  164. }
  165. return ls_Particel_dt;
  166. }
  167. /// <summary>
  168. /// 分类整合大小分类都有
  169. /// </summary>
  170. /// <returns></returns>
  171. public List<DataTable> GetClassificationConsolidationTable(OTSReport_Export m_otsreport_export, BasicData basicData)
  172. {
  173. List<DataTable> datas = new List<DataTable>();
  174. DataTable data = basicData.GetDBData();
  175. //获取粒级表
  176. List<string> colid = new List<string>();
  177. colid = basicData.GetParticlesizeTable();
  178. //------------------------------------------------
  179. DataTable ls_partsize_dt = new DataTable();
  180. ls_partsize_dt.TableName = "PartSize";
  181. for(int i=0;i< colid.Count;i++)
  182. {
  183. ls_partsize_dt.Columns.Add("c"+(i+1).ToString());
  184. }
  185. DataRow dr = ls_partsize_dt.NewRow();
  186. DataTable ls_Particel_dt = new DataTable();
  187. ls_Particel_dt.TableName = "Particel";
  188. int colidCount = 1;
  189. for (int i = 0; i < colid.Count; i++)
  190. {
  191. if (colid.Count < i)
  192. {
  193. dr["c" + (i+1).ToString()] = "";
  194. }
  195. else
  196. {
  197. dr["c" + (i + 1).ToString()] = colid[i];
  198. ls_Particel_dt.Columns.Add("c" + (i + 1).ToString(), typeof(double));
  199. colidCount++;
  200. }
  201. }
  202. ls_partsize_dt.Rows.Add(dr);
  203. ls_Particel_dt.Columns.Add("Name");
  204. ls_Particel_dt.Columns.Add("total", typeof(double));
  205. ls_Particel_dt.Columns.Add("TypeId");
  206. ls_Particel_dt.Columns.Add("Class");
  207. for (int i = 0; i < data.Rows.Count; i++)
  208. {
  209. DataRow dr2 = ls_Particel_dt.NewRow();
  210. dr2["Name"] = data.Rows[i]["TypeName"].ToString();
  211. dr2["Class"] = data.Rows[i]["Class"].ToString();
  212. dr2["TypeId"] = data.Rows[i]["TypeId"].ToString();//获取分类编号
  213. for (int j = 1; j < colidCount; j++)
  214. {
  215. if (colid.Count >= j)
  216. {
  217. dr2["c" + j.ToString()] = Convert.ToDouble(data.Rows[i][colid[j - 1]]);
  218. }
  219. }
  220. if (dr2["Name"].ToString() != "" && dr2["Name"].ToString().IndexOf("number") < 0)
  221. {
  222. dr2["total"] = "0"; //求合
  223. double d_total = 0;
  224. for (int j = 1; j < colidCount; j++)
  225. {
  226. if (colid.Count >= j)
  227. {
  228. d_total = d_total + Convert.ToInt64(data.Rows[i][colid[j - 1]]);
  229. }
  230. }
  231. dr2["total"] = d_total.ToString();
  232. }
  233. ls_Particel_dt.Rows.Add(dr2);
  234. }
  235. //按照list列表进行物质类排序,物质类中的元素分类按照面积的大小进行排序
  236. List<string> ClassName = ObtainParticleCategory(m_otsreport_export, basicData);
  237. // List<string> ClassName = new List<string>();
  238. ////DataTable getClass_dt = basicData.GetAllClass();
  239. //DataTable get_dt=ReadClassification(basicData);
  240. // DataTable getClass_dt = get_dt.Clone();
  241. //DataRow[] dataRow = get_dt.Select("", "iorder ASC");
  242. // foreach (DataRow row in dataRow)
  243. // {
  244. // if (row.ItemArray[1].ToString() != "Default")
  245. // {
  246. // getClass_dt.ImportRow(row);
  247. // }
  248. //}
  249. // for (int i = 0; i < getClass_dt.Rows.Count; i++)
  250. // {
  251. // ClassName.Add(getClass_dt.Rows[i][1].ToString());
  252. //}
  253. // ClassName.Add("Default");
  254. //获取大分类信息
  255. DataTable dt = QuantityOfIntegratedSubstances(ls_Particel_dt, ClassName);
  256. DataTable data2 = classIfIcationSort(ls_Particel_dt, ClassName, dt, colidCount);
  257. datas.Add(ls_partsize_dt.Copy());
  258. datas.Add(data2.Copy());
  259. return datas;
  260. }
  261. /// <summary>
  262. /// 获得颗粒类别
  263. /// </summary>
  264. /// <returns></returns>
  265. private List<string> ObtainParticleCategory(OTSReport_Export m_otsreport_export, BasicData basicData)
  266. {
  267. List<string> ClassName = new List<string>();
  268. if (m_otsreport_export.m_ReportApp.m_RptConfigFile.Systype != OTS_SysType_ID.IncA)
  269. {
  270. DataTable get_dt = ReadClassification(basicData);
  271. DataTable getClass_dt = get_dt.Clone();
  272. DataRow[] dataRow = get_dt.Select("", "iorder ASC");
  273. foreach (DataRow row in dataRow)
  274. {
  275. if (row.ItemArray[1].ToString() != "Default")
  276. {
  277. getClass_dt.ImportRow(row);
  278. }
  279. }
  280. for (int i = 0; i < getClass_dt.Rows.Count; i++)
  281. {
  282. ClassName.Add(getClass_dt.Rows[i][1].ToString());
  283. }
  284. ClassName.Add("Default");
  285. }
  286. else
  287. {
  288. DataTable getClass_dt = ReadClassification(basicData);
  289. for (int i = 0; i < getClass_dt.Rows.Count; i++)
  290. {
  291. ClassName.Add(getClass_dt.Rows[i][1].ToString());
  292. }
  293. bool bl = false;
  294. for (int i = 0; i < getClass_dt.Rows.Count; i++)
  295. {
  296. if (getClass_dt.Rows[i]["GroupName"].ToString() != "NOT_INCLUTION" && getClass_dt.Rows[i]["GroupName"].ToString() != "Invalid"
  297. && getClass_dt.Rows[i]["GroupName"].ToString() != "Not Identified")
  298. if (getClass_dt.Rows[i]["GroupName"].ToString() == "")
  299. {
  300. if (!bl)
  301. {
  302. ClassName.Add("Default");
  303. bl = true;
  304. }
  305. }
  306. else
  307. {
  308. bool isDefault = false;
  309. for (int a = 0; a < ClassName.Count; a++)
  310. {
  311. if (getClass_dt.Rows[i]["GroupName"].ToString() == "Default")
  312. {
  313. isDefault = true;
  314. }
  315. }
  316. if (isDefault)
  317. {
  318. if (getClass_dt.Rows[i]["GroupName"].ToString() != "Default")
  319. {
  320. ClassName.Add(getClass_dt.Rows[i]["GroupName"].ToString());
  321. }
  322. }
  323. else
  324. {
  325. ClassName.Add(getClass_dt.Rows[i]["GroupName"].ToString());
  326. }
  327. }
  328. }
  329. }
  330. return ClassName;
  331. }
  332. private DataTable ReadClassification(BasicData basicData )
  333. {
  334. DataTable dt_stl = new DataTable();
  335. SqLiteHelper sh = new SqLiteHelper("data source='" + basicData.GetFilePath()+ "\\"+basicData.GetResfile() + "'");
  336. dt_stl = sh.ExecuteQuery("select * from STDGroups");
  337. return dt_stl;
  338. }
  339. /// <summary>
  340. /// 大分类chart数据
  341. /// </summary>
  342. /// <param name="m_mbszclass"></param>
  343. /// <param name="m_otsreport_export"></param>
  344. /// <returns></returns>
  345. public DataTable GetChartDataCalss(BasicData basicData)
  346. {
  347. DataTable data =basicData.GetDBData();
  348. //获取粒级表
  349. List<string> colid = basicData.GetParticlesizeTable();
  350. //------------------------------------------------
  351. DataTable ls_partsize_dt = new DataTable();
  352. ls_partsize_dt.TableName = "PartSize";
  353. for (int i = 0; i < colid.Count; i++)
  354. {
  355. ls_partsize_dt.Columns.Add("c"+(i+1).ToString());
  356. }
  357. DataTable ls_Particel_dt = new DataTable();
  358. ls_Particel_dt.TableName = "Particel";
  359. DataRow dr = ls_partsize_dt.NewRow();
  360. int colidCount = 1;
  361. for (int i = 0; i < colid.Count; i++)
  362. {
  363. if (colid.Count < i)
  364. {
  365. dr["c" + (i + 1).ToString()] = "";
  366. }
  367. else
  368. {
  369. dr["c" + (i + 1).ToString()] = colid[i];
  370. ls_Particel_dt.Columns.Add("c" + (i + 1).ToString(), typeof(double));
  371. colidCount++;
  372. }
  373. }
  374. ls_partsize_dt.Rows.Add(dr);
  375. ls_Particel_dt.Columns.Add("Name");
  376. ls_Particel_dt.Columns.Add("total", typeof(double));
  377. ls_Particel_dt.Columns.Add("TypeId");
  378. ls_Particel_dt.Columns.Add("Class");
  379. for (int i = 0; i < data.Rows.Count; i++)
  380. {
  381. DataRow dr2 = ls_Particel_dt.NewRow();
  382. dr2["Name"] = data.Rows[i]["TypeName"].ToString();
  383. dr2["Class"] = data.Rows[i]["Class"].ToString();
  384. dr2["TypeId"] = data.Rows[i]["TypeId"].ToString();//获取分类编号
  385. for (int j = 1; j < colidCount; j++)
  386. {
  387. if (colid.Count >= j)
  388. {
  389. dr2["c" + j.ToString()] = Convert.ToDouble(data.Rows[i][colid[j - 1]]);
  390. }
  391. }
  392. if (dr2["Name"].ToString() != "" && dr2["Name"].ToString().IndexOf("number") < 0)
  393. {
  394. dr2["total"] = "0"; //求合
  395. double d_total = 0;
  396. for (int j = 1; j < colidCount; j++)
  397. {
  398. if (colid.Count >= j)
  399. {
  400. d_total = d_total + Convert.ToInt64(data.Rows[i][colid[j - 1]]);
  401. }
  402. }
  403. dr2["total"] = d_total.ToString();
  404. }
  405. ls_Particel_dt.Rows.Add(dr2);
  406. }
  407. //按照list列表进行物质类排序,物质类中的元素分类按照面积的大小进行排序
  408. List<string> ClassName = new List<string>();
  409. DataTable getClass_dt = basicData.GetAllClass();
  410. for (int i = 0; i < getClass_dt.Rows.Count; i++)
  411. {
  412. if (getClass_dt.Rows[i]["GroupName"].ToString() != "NOT_INCLUTION" && getClass_dt.Rows[i]["GroupName"].ToString() != "Invalid")
  413. if (getClass_dt.Rows[i]["GroupName"].ToString() == "")
  414. ClassName.Add("NULL");
  415. else
  416. ClassName.Add(getClass_dt.Rows[i]["GroupName"].ToString());
  417. }
  418. //颗粒尺寸数据(例 1.5有多少,2.0有多少)
  419. DataTable colid_data = new DataTable();
  420. colid_data.Columns.Add("name");
  421. colid_data.Columns.Add("quantity", typeof(double));
  422. for (int i = 0; i < ls_Particel_dt.Columns.Count; i++)
  423. {
  424. if (ls_Particel_dt.Columns[i].ColumnName == "c" + (i + 1).ToString())
  425. {
  426. if (i < colid.Count)
  427. {
  428. DataRow dr1 = colid_data.NewRow();
  429. dr1["name"] = colid[i].ToString();
  430. int quantity = 0;
  431. for (int a = 0; a < ls_Particel_dt.Rows.Count; a++)
  432. {
  433. quantity = quantity + Convert.ToInt32(ls_Particel_dt.Rows[a][i].ToString());
  434. }
  435. dr1["quantity"] = quantity.ToString();
  436. colid_data.Rows.Add(dr1);
  437. }
  438. }
  439. }
  440. return colid_data;
  441. }
  442. public DataTable ParticleResults(c_TemplateClass m_mbszclass, OTSReport_Export m_otsreport_export, string ComputeMode)
  443. {
  444. DataTable data = GetDBData(m_mbszclass, m_otsreport_export, ComputeMode);
  445. List<string> colid = new List<string>();
  446. //获取粒级表
  447. string path1 = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder +
  448. m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFile;
  449. DataSet ds = OTSIncAReportApp.DataOperation.DataAccess.XMLoperate.GetXml(path1);
  450. string sizestr = ds.Tables[0].Rows[0]["Sizes"].ToString();
  451. for (int i = 0; i < sizestr.Split(',').Length; i++)
  452. {
  453. if (sizestr.Split(',')[i].Length > 0)
  454. {
  455. double d1 = Convert.ToDouble(sizestr.Split(',')[i]);
  456. colid.Add("≥" + d1.ToString() );
  457. }
  458. }
  459. ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.GetWorkingResultId()].FilePath);
  460. //------------------------------------------------
  461. DataTable ls_partsize_dt = new DataTable();
  462. ls_partsize_dt.TableName = "PartSize";
  463. for(int i=0;i< colid.Count;i++)
  464. {
  465. ls_partsize_dt.Columns.Add("c"+(i+1).ToString());
  466. }
  467. DataRow dr = ls_partsize_dt.NewRow();
  468. DataTable ls_Particel_dt = new DataTable();
  469. ls_Particel_dt.TableName = "Particel";
  470. int colidCount = 1;
  471. for (int i = 0; i < colid.Count; i++)
  472. {
  473. dr["c" + (i+1).ToString()] = colid[i];
  474. ls_Particel_dt.Columns.Add("c"+ (i + 1).ToString());
  475. colidCount++;
  476. }
  477. ls_partsize_dt.Rows.Add(dr);
  478. ls_Particel_dt.Columns.Add("Name");
  479. ls_Particel_dt.Columns.Add("total");
  480. ls_Particel_dt.Columns.Add("TypeId");
  481. for (int i = 0; i < data.Rows.Count; i++)
  482. {
  483. DataRow dr2 = ls_Particel_dt.NewRow();
  484. dr2["Name"] = data.Rows[i]["TypeName"].ToString();
  485. dr2["TypeId"] = data.Rows[i]["TypeId"].ToString();//获取分类编号
  486. for (int j = 1; j < colidCount; j++)
  487. {
  488. if (colid.Count >= j)
  489. {
  490. double de = Convert.ToDouble(data.Rows[i][colid[j - 1]]);
  491. if (de == 0)
  492. dr2["c" + j.ToString()] = " ";
  493. else
  494. dr2["c" + j.ToString()] = de.ToString();
  495. }
  496. }
  497. if (dr2["Name"].ToString() != "" && dr2["Name"].ToString().IndexOf("number") < 0)
  498. {
  499. dr2["total"] = " "; //求合
  500. double d_total = 0;
  501. for (int j = 1; j < colidCount; j++)
  502. {
  503. if (colid.Count >= j)
  504. {
  505. d_total = d_total + Convert.ToInt64(data.Rows[i][colid[j - 1]]);
  506. }
  507. }
  508. if (d_total == 0)
  509. {
  510. continue;
  511. dr2["total"] = " ";
  512. }
  513. else
  514. dr2["total"] = d_total.ToString();
  515. }
  516. ls_Particel_dt.Rows.Add(dr2);
  517. }
  518. return ls_Particel_dt;
  519. }
  520. public DataTable TypeRange(c_TemplateClass m_mbszclass, OTSReport_Export m_otsreport_export)
  521. {
  522. List<string> colid = new List<string>();
  523. //获取粒级表
  524. string path1 = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder +
  525. m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFile;
  526. DataSet ds = OTSIncAReportApp.DataOperation.DataAccess.XMLoperate.GetXml(path1);
  527. string sizestr = ds.Tables[0].Rows[0]["Sizes"].ToString();
  528. for (int i = 0; i < sizestr.Split(',').Length; i++)
  529. {
  530. if (sizestr.Split(',')[i].Length > 0)
  531. {
  532. double d1 = Convert.ToDouble(sizestr.Split(',')[i]);
  533. colid.Add("≥" + d1.ToString());
  534. }
  535. }
  536. DataTable ls_partsize_dt = new DataTable();
  537. ls_partsize_dt.TableName = "PartSize";
  538. for (int i=0;i< colid.Count;i++)
  539. {
  540. ls_partsize_dt.Columns.Add("c"+(i+1).ToString());
  541. }
  542. DataRow dr = ls_partsize_dt.NewRow();
  543. for (int i = 0; i < colid.Count; i++)
  544. {
  545. dr["c" + (i+1).ToString()] = colid[i];
  546. }
  547. ls_partsize_dt.Rows.Add(dr);
  548. return ls_partsize_dt;
  549. }
  550. private DataTable QuantityOfIntegratedSubstances(DataTable dataTable, List<string> ClassName)
  551. {
  552. DataTable dt_Class = dataTable.Copy();
  553. dt_Class.Clear();
  554. dt_Class.TableName = "Particel";
  555. dt_Class.Columns.Remove("Name");
  556. for (int i = 0; i < ClassName.Count; i++)
  557. {
  558. //保留当前循环中大类物质,去除其他物质
  559. DataTable dt = dataTable.Copy();
  560. dt.Clear();
  561. for (int a = 0; a < dataTable.Rows.Count; a++)
  562. {
  563. if (dataTable.Rows[a]["Class"].ToString() == ClassName[i].ToString())
  564. {
  565. dt.Rows.Add(dataTable.Rows[a].ItemArray);
  566. }
  567. }
  568. //if (dt.Rows.Count == 0)
  569. // continue;
  570. DataTable dt_2 = new DataTable();
  571. dt_2 = dataTable.Copy();
  572. dt_2.Clear();
  573. DataRow row = dt_2.NewRow();
  574. dt_2.Rows.Add(row);
  575. for (int a = 0; a < dt.Columns.Count; a++)
  576. {
  577. if (dt.Columns[a].ToString() != "Name" && dt.Columns[a].ToString() != "Class" && dt.Columns[a].ToString() != "TypeId")
  578. {
  579. bool bl = false;
  580. for (int b = 0; b < dt.Rows.Count; b++)
  581. {
  582. if (!dt.Rows[b].IsNull(dt.Columns[a].ToString()))
  583. {
  584. bl = true;
  585. }
  586. }
  587. if (bl)
  588. {
  589. dt_2.Rows[0][dt.Columns[a].ToString()] = decimal.Parse(dt.Compute("sum(" + dt.Columns[a].ToString() + ")", "").ToString());
  590. }
  591. else
  592. {
  593. dt_2.Rows[0][dt.Columns[a].ToString()] = 0;
  594. }
  595. }
  596. }
  597. dt_2.Columns.Remove("Name");
  598. dt_2.Rows[0]["Class"] = ClassName[i];
  599. dt_Class.Rows.Add(dt_2.Rows[0].ItemArray);
  600. }
  601. return dt_Class;
  602. }
  603. private DataTable classIfIcationSort(DataTable dataTable, List<string> ClassName, DataTable data,int colidCount)
  604. {
  605. DataTable dt = new DataTable();
  606. dt = dataTable.Copy();
  607. dt.Clear();
  608. dt.TableName = "Particel_subdivision";
  609. //循环list中每个类型
  610. for (int i = 0; i < ClassName.Count(); i++)
  611. {
  612. DataTable data1 = dt.Copy();
  613. data1.Clear();
  614. data1.Rows.Add();
  615. for (int a = 0; a < data.Rows.Count; a++)
  616. {
  617. if (data.Rows[a]["Class"].ToString() == ClassName[i].ToString())
  618. {
  619. for (int b = 1; b < colidCount; b++)
  620. {
  621. data1.Rows[0]["c" + b.ToString()] = data.Rows[a]["c" + b.ToString()];
  622. }
  623. data1.Rows[0]["total"] = data.Rows[a]["total"];
  624. data1.Rows[0]["Class"] = data.Rows[a]["Class"];
  625. dt.Rows.Add(data1.Rows[0].ItemArray);
  626. }
  627. }
  628. DataTable dt_1 = new DataTable();
  629. dt_1 = dt.Copy();
  630. dt_1.Clear();
  631. //循环DataTable中每个分类的数据
  632. for (int a = 0; a < dataTable.Rows.Count; a++)
  633. {
  634. if (!string.IsNullOrWhiteSpace(ClassName[i].ToString()))
  635. if (dataTable.Rows[a]["Class"].ToString() == ClassName[i].ToString())
  636. {
  637. dataTable.Rows[a]["Class"] = "";
  638. dt_1.Rows.Add(dataTable.Rows[a].ItemArray);
  639. }
  640. }
  641. //将颗粒数量排序(从大到小)
  642. DataView dv = dt_1.DefaultView;
  643. dv.Sort = "total DESC";
  644. DataTable dt_1_sort = dv.ToTable();
  645. for (int a = 0; a < dt_1_sort.Rows.Count; a++)
  646. {
  647. dt.Rows.Add(dt_1_sort.Rows[a].ItemArray);
  648. }
  649. }
  650. return dt;
  651. }
  652. private DataTable InvalidRemoval(DataTable dt)
  653. {
  654. DataTable dataTable = dt.Copy();
  655. dataTable.Clear();
  656. for (int i = 0; i < dt.Rows.Count; i++)
  657. {
  658. if (Convert.ToInt32(dt.Rows[i]["TypeId"])>10 )
  659. {
  660. dataTable.Rows.Add(dt.Rows[i].ItemArray);
  661. }
  662. }
  663. return dataTable;
  664. }
  665. private string getWhere(string max, string min, string col, string partic)
  666. {
  667. return col + ">=" + min + " and " + col + "<" + max + " and TypeId=" + partic;
  668. }
  669. private DataTable GetDBData(c_TemplateClass m_mbszclass , OTSReport_Export m_otsreport_export,string ComputeMode)
  670. {
  671. DataTable m_bt_DBData = new DataTable();
  672. ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.GetWorkingResultId()].FilePath);
  673. List<string> colid = new List<string>() { "TypeName", "ar", "TypeId", "Largest", "Class", "con" };
  674. //获取粒级表
  675. string path1 = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder +
  676. m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFile;
  677. DataSet ds = OTSIncAReportApp.DataOperation.DataAccess.XMLoperate.GetXml(path1);
  678. string sizestr = ds.Tables[0].Rows[0]["Sizes"].ToString();
  679. for (int i = 0; i < sizestr.Split(',').Length ; i++)
  680. {
  681. if (sizestr.Split(',')[i].Length > 0)
  682. {
  683. double d1 = Convert.ToDouble(sizestr.Split(',')[i]);
  684. colid.Add("≥" + d1.ToString() );
  685. }
  686. }
  687. for (int i = 0; i < colid.Count; i++)
  688. {
  689. m_bt_DBData.Columns.Add(colid[i].ToString());
  690. }
  691. DataTable dt = InvalidRemoval(fielddata.GetParticleListForParticlSize("area", ""));
  692. DataTable AreaInformationOfAllElements = InvalidRemoval(fielddata.GetAreaByAllIncA(""));
  693. DataTable dtp = InvalidRemoval(fielddata.GetParticleAll(""));
  694. string po = ComputeMode;
  695. switch (po)
  696. {
  697. case "DMAX":
  698. po = "DMAX";
  699. break;
  700. case "DMIN":
  701. po = "DMIN";
  702. break;
  703. case "ECD":
  704. po = "Area";
  705. break;
  706. case "FERET":
  707. po = "DFERET";
  708. break;
  709. }
  710. for (int i = 0; i < dt.Rows.Count; i++)
  711. {
  712. DataRow dr = m_bt_DBData.NewRow();
  713. dr["TypeName"] = dt.Rows[i]["TypeName"].ToString();
  714. dr["TypeId"] = dt.Rows[i]["TypeId"].ToString();
  715. dr["con"] = dt.Rows[i]["con"].ToString();
  716. if (dt.Rows[i]["GroupName"].ToString() == "")
  717. dr["Class"] = "Default";
  718. else
  719. dr["Class"] = dt.Rows[i]["GroupName"].ToString();
  720. //continue;
  721. dr["Largest"] = Math.Round(Convert.ToDouble(dt.Rows[i]["max"]), 2);
  722. for (int a = 6; a < colid.Count; a++)
  723. {
  724. string d2;
  725. if (a== colid.Count-1)
  726. {
  727. d2 = "999";
  728. }
  729. else
  730. {
  731. d2 = colid[a+1].Split('≥')[1];
  732. }
  733. string d1 = colid[a].Split('≥')[1];
  734. DataRow[] datas = dtp.Select(getWhere(d2, d1, po, dt.Rows[i]["TypeId"].ToString()));
  735. dr[colid[a]] = datas.Count();
  736. }
  737. for (int a = 0; a < AreaInformationOfAllElements.Rows.Count; a++)
  738. {
  739. if (dt.Rows[i]["TypeId"].ToString() == AreaInformationOfAllElements.Rows[a]["TypeId"].ToString())
  740. {
  741. dr["ar"] = AreaInformationOfAllElements.Rows[a]["ar"];
  742. }
  743. }
  744. m_bt_DBData.Rows.Add(dr);
  745. }
  746. //去除物质分类(非夹杂物分类)
  747. for (int a = 0; a < m_mbszclass.M_KLLBXX.list_str_kllb_DeleteClass_Serial.Count; a++)
  748. {
  749. for (int i = m_bt_DBData.Rows.Count - 1; i >= 0; i--)
  750. {
  751. if (m_bt_DBData.Rows[i]["TypeId"].ToString() == m_mbszclass.M_KLLBXX.list_str_kllb_DeleteClass_Serial[a].ToString())
  752. {
  753. m_bt_DBData.Rows.RemoveAt(i);
  754. }
  755. }
  756. }
  757. if (m_mbszclass.list_str_MainPriority_Serial.Count==0)
  758. {
  759. return m_bt_DBData;
  760. }
  761. DataTable datass = m_bt_DBData.Clone();
  762. for (int i=0;i< m_mbszclass.list_str_MainPriority_Serial.Count;i++)
  763. {
  764. bool bl = false;
  765. for (int a = 0; a < m_bt_DBData.Rows.Count; a++)
  766. {
  767. if (m_bt_DBData.Rows[a]["TypeId"].ToString() == m_mbszclass.list_str_MainPriority_Serial[i])
  768. {
  769. datass.Rows.Add(m_bt_DBData.Rows[a].ItemArray);
  770. bl = true;
  771. continue;
  772. }
  773. }
  774. if(!bl)
  775. {
  776. DataTable dta= m_bt_DBData.Clone();
  777. if (m_bt_DBData.Rows.Count != 0)
  778. {
  779. dta.Rows.Add(m_bt_DBData.Rows[0].ItemArray);
  780. for (int b = 0; b < dta.Columns.Count; b++)
  781. {
  782. if (dta.Columns[b].ColumnName == "TypeName")
  783. {
  784. dta.Rows[0][b] = m_mbszclass.list_str_MainPriority[i];
  785. }
  786. else if (dta.Columns[b].ColumnName == "Class")
  787. {
  788. dta.Rows[0][b] = "Default";
  789. }
  790. else
  791. {
  792. dta.Rows[0][b] = 0;
  793. }
  794. }
  795. datass.Rows.Add(dta.Rows[0].ItemArray);
  796. }
  797. }
  798. }
  799. return datass;
  800. }
  801. }
  802. }