ParticleAnalysis.cs 38 KB

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