HOTMethod.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using CoreFS.CA06;
  6. using System.Data;
  7. using Core.Mes.Client.Comm.Server;
  8. using System.Collections;
  9. using Core.StlMes.Client.ZGMil.Entity;
  10. namespace Core.StlMes.Client.ZGMil.Common
  11. {
  12. class HOTMethod : FrmBase
  13. {
  14. private OpeBase _ob;
  15. public OpeBase OB
  16. {
  17. get { return _ob; }
  18. set { _ob = value; }
  19. }
  20. public HOTMethod(OpeBase ob)
  21. {
  22. OB = ob;
  23. }
  24. public HOTMethod()
  25. {
  26. // TODO: Complete member initialization
  27. }
  28. /// <summary>
  29. /// 判断炉号是否结炉
  30. /// </summary>
  31. /// <param name="JudgeStoveNo"></param>
  32. /// <param name="ProcessNo">0-锯切 1-加热炉 2-穿孔 3-连轧 4-再加热 5-定径 6-管排锯 7-矫直 8-探伤 9-质检</param>
  33. /// <returns></returns>
  34. public bool isNode(string JudgeStoveNo, string ResultNo, int ProcessNo, string PlineCode)
  35. {
  36. bool isnode = false;
  37. DataTable dt = ServerHelper.GetData("com.steering.mes.zgmil.coup.FeedSawResult.isNode", new object[] { JudgeStoveNo, ResultNo, ProcessNo, PlineCode }, this._ob);
  38. if (dt.Rows.Count > 0)
  39. {
  40. if (dt.Rows[0][0].ToString() == "1")
  41. {
  42. isnode = true;
  43. }
  44. }
  45. return isnode;
  46. }
  47. /// <summary>
  48. /// 查询炉内是否有正在装炉或正在出炉的计划
  49. /// </summary>
  50. /// <param name="Falg">0-正在装炉,2-正在出炉</param>
  51. /// <param name="FurType">0-加热炉,2-再加热炉</param>
  52. /// <returns>isInOrOut true-有 false-没有 </returns>
  53. public DataTable InFurIsEnd(string Falg, string PlineCode, int FurType = 0)
  54. {
  55. DataTable dt = null;
  56. if (FurType == 0)
  57. {
  58. dt = ServerHelper.GetData("com.steering.mes.zgmil.coup.FurResult.getINFurNonEndIN", new object[] { Falg, PlineCode }, this._ob);
  59. }
  60. else
  61. {
  62. dt = ServerHelper.GetData("com.steering.mes.zgmil.coup.FrmReFurResult.getINFurNonEndIN", new object[] { Falg, PlineCode }, this._ob);
  63. }
  64. return dt;
  65. }
  66. /// <summary>
  67. /// 查询当前炉次炉内状态
  68. /// </summary>
  69. /// <param name="JudgeStoveNo"></param>
  70. /// <returns></returns>
  71. public DataTable InFurStatus(string JudgeStoveNo)
  72. {
  73. DataTable dt = ServerHelper.GetData("com.steering.mes.zgmil.coup.FurResult.getInFurStatus", new object[] { JudgeStoveNo }, this._ob);
  74. return dt;
  75. }
  76. /// <summary>
  77. /// 查询上个班班次班组
  78. /// 天管白夜两班制,天淮早中晚三班制
  79. /// </summary>
  80. /// <param name="Shift"></param>
  81. /// <param name="Group"></param>
  82. /// <returns></returns>
  83. public static string GetShiftBefore(string Shift, string Group, string Date, string PlineCode)
  84. {
  85. ArrayList ShiftList = new ArrayList();
  86. string ShiftBefore = "";
  87. string[] ShiftD = new string[4] { "甲", "乙", "丙", "丁" };
  88. int[] ShiftNo = new int[4] { 3, 0, 1, 2 }; //通过修改此数组得到指定日期的班组 起始点为2015年12月31日排班顺序
  89. int[] MouseDay = new int[13] { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 29 };
  90. int LoopCount = 0; //循环次数
  91. //算出当前日期与起始点相差天数
  92. int Days = 0;
  93. string DYear = Date.Substring(0, 4);
  94. for (int i = 2016; i < int.Parse(DYear); i++)
  95. {
  96. if (i % 4 == 0)
  97. {
  98. Days += 366;
  99. }
  100. else
  101. {
  102. Days += 365;
  103. }
  104. }
  105. string DMouse = Date.Substring(4, 2);
  106. for (int i = 1; i < int.Parse(DMouse); i++)
  107. {
  108. if (i == 2)
  109. {
  110. if (int.Parse(DYear) % 4 == 0)
  111. {
  112. Days += MouseDay[12];
  113. }
  114. else
  115. {
  116. Days += MouseDay[i - 1];
  117. }
  118. }
  119. else
  120. {
  121. Days += MouseDay[i - 1];
  122. }
  123. }
  124. string DDay = Date.Substring(6, 2);
  125. Days += int.Parse(DDay);
  126. if (Days > 0)
  127. {
  128. if (Days % 2 == 0)
  129. {
  130. LoopCount = (Days / 2) % 4;
  131. }
  132. else
  133. {
  134. LoopCount = ((Days - 1) / 2 + 1) % 4;
  135. }
  136. }
  137. ShiftNo[0] = (ShiftNo[0] + 4 - LoopCount) % 4;
  138. ShiftNo[1] = (ShiftNo[1] + 4 - LoopCount) % 4;
  139. ShiftNo[2] = (ShiftNo[2] + 4 - LoopCount) % 4;
  140. ShiftNo[3] = (ShiftNo[3] + 4 - LoopCount) % 4;
  141. ShiftList.Add(ShiftD[ShiftNo[0]]); //早
  142. ShiftList.Add(ShiftD[ShiftNo[1]]); //中
  143. ShiftList.Add(ShiftD[ShiftNo[2]]); //晚
  144. ShiftList.Add(ShiftD[ShiftNo[3]]); //休
  145. //ShiftList.Add//2016年 1月1日 1月2日 配班表
  146. if (PlineCode.Equals("C072"))
  147. {
  148. //早中晚三班制
  149. switch (Shift)
  150. {
  151. case "1":
  152. ShiftBefore = "3";
  153. break;
  154. case "2":
  155. ShiftBefore = "1";
  156. break;
  157. case "3":
  158. ShiftBefore = "2";
  159. break;
  160. }
  161. if (Shift == "1")
  162. {
  163. switch (ShiftList[2].ToString())
  164. {
  165. case "甲":
  166. ShiftBefore += "1";
  167. break;
  168. case "乙":
  169. ShiftBefore += "2";
  170. break;
  171. case "丙":
  172. ShiftBefore += "3";
  173. break;
  174. case "丁":
  175. ShiftBefore += "4";
  176. break;
  177. }
  178. }
  179. else
  180. {
  181. for (int i = 0; i < ShiftNo.Count(); i++)
  182. {
  183. if (ShiftNo[i] == int.Parse(Group) - 1)
  184. {
  185. ShiftBefore += (int.Parse((ShiftNo[(i + 3) % 4]).ToString()) + 1).ToString();
  186. }
  187. }
  188. }
  189. }
  190. else
  191. {
  192. //白夜两班制
  193. switch (Shift)
  194. {
  195. case "3":
  196. ShiftBefore = "0";
  197. switch (Group)
  198. {
  199. case "1":
  200. ShiftBefore += "4";
  201. break;
  202. case "2":
  203. ShiftBefore += "1";
  204. break;
  205. case "3":
  206. ShiftBefore += "2";
  207. break;
  208. case "4":
  209. ShiftBefore += "3";
  210. break;
  211. }
  212. break;
  213. case "0":
  214. ShiftBefore = "3";
  215. switch (Group)
  216. {
  217. case "1":
  218. ShiftBefore += "3";
  219. break;
  220. case "2":
  221. ShiftBefore += "4";
  222. break;
  223. case "3":
  224. ShiftBefore += "1";
  225. break;
  226. case "4":
  227. ShiftBefore += "2";
  228. break;
  229. }
  230. break;
  231. }
  232. }
  233. return ShiftBefore;
  234. }
  235. /// <summary>
  236. /// 查询上个班班次班组
  237. /// </summary>
  238. /// <param name="Shift">当前班次</param>
  239. /// <param name="Group">当前班组</param>
  240. /// // <param name="Flag">0-上道班次 班组 1-下道班次班组</param>
  241. /// <param name="Date"></param>
  242. /// <returns></returns>
  243. public static string GetShiftBefore(string Shift, string Group, string Date)
  244. {
  245. ArrayList ShiftList = new ArrayList();
  246. string ShiftBefore = "";
  247. string[] ShiftD = new string[4] { "甲", "乙", "丙", "丁" };
  248. int[] ShiftNo = new int[4] { 3, 0, 1, 2 }; //通过修改此数组得到指定日期的班组 起始点为2015年12月31日排班顺序
  249. int[] MouseDay = new int[13] { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 29 };
  250. int LoopCount = 0; //循环次数
  251. //算出当前日期与起始点相差天数
  252. int Days = 0;
  253. string DYear = Date.Substring(0, 4);
  254. for (int i = 2016; i < int.Parse(DYear); i++)
  255. {
  256. if (i % 4 == 0)
  257. {
  258. Days += 366;
  259. }
  260. else
  261. {
  262. Days += 365;
  263. }
  264. }
  265. string DMouse = Date.Substring(4, 2);
  266. for (int i = 1; i < int.Parse(DMouse); i++)
  267. {
  268. if (i == 2)
  269. {
  270. if (int.Parse(DYear) % 4 == 0)
  271. {
  272. Days += MouseDay[12];
  273. }
  274. else
  275. {
  276. Days += MouseDay[i - 1];
  277. }
  278. }
  279. else
  280. {
  281. Days += MouseDay[i - 1];
  282. }
  283. }
  284. string DDay = Date.Substring(6, 2);
  285. Days += int.Parse(DDay);
  286. if (Days > 0)
  287. {
  288. if (Days % 2 == 0)
  289. {
  290. LoopCount = (Days / 2) % 4;
  291. }
  292. else
  293. {
  294. LoopCount = ((Days - 1) / 2 + 1) % 4;
  295. }
  296. }
  297. ShiftNo[0] = (ShiftNo[0] + 4 - LoopCount) % 4;
  298. ShiftNo[1] = (ShiftNo[1] + 4 - LoopCount) % 4;
  299. ShiftNo[2] = (ShiftNo[2] + 4 - LoopCount) % 4;
  300. ShiftNo[3] = (ShiftNo[3] + 4 - LoopCount) % 4;
  301. ShiftList.Add(ShiftD[ShiftNo[0]]); //早
  302. ShiftList.Add(ShiftD[ShiftNo[1]]); //中
  303. ShiftList.Add(ShiftD[ShiftNo[2]]); //晚
  304. ShiftList.Add(ShiftD[ShiftNo[3]]); //休
  305. //ShiftList.Add//2016年 1月1日 1月2日 配班表
  306. switch (Shift)
  307. {
  308. case "1":
  309. ShiftBefore = "3";
  310. break;
  311. case "2":
  312. ShiftBefore = "1";
  313. break;
  314. case "3":
  315. ShiftBefore = "2";
  316. break;
  317. }
  318. if (Shift == "1")
  319. {
  320. switch (ShiftList[2].ToString())
  321. {
  322. case "甲":
  323. ShiftBefore += "1";
  324. break;
  325. case "乙":
  326. ShiftBefore += "2";
  327. break;
  328. case "丙":
  329. ShiftBefore += "3";
  330. break;
  331. case "丁":
  332. ShiftBefore += "4";
  333. break;
  334. }
  335. }
  336. else
  337. {
  338. for (int i = 0; i < ShiftNo.Count(); i++)
  339. {
  340. if (ShiftNo[i] == int.Parse(Group) - 1)
  341. {
  342. ShiftBefore += (int.Parse((ShiftNo[(i + 3) % 4]).ToString()) + 1).ToString();
  343. }
  344. }
  345. }
  346. return ShiftBefore;
  347. }
  348. /// <summary>
  349. /// 查询下个班班次班组
  350. /// </summary>
  351. /// <param name="Shift">当前班次</param>
  352. /// <param name="Group">当前班组</param>
  353. /// <param name="Date"></param>
  354. /// <returns></returns>
  355. public static string GetShiftAfter(string Shift, string Group, string Date)
  356. {
  357. ArrayList ShiftList = new ArrayList();
  358. string ShiftAfter = "";
  359. string[] ShiftD = new string[4] { "甲", "乙", "丙", "丁" };
  360. int[] ShiftNo = new int[4] { 3, 0, 1, 2 }; //通过修改此数组得到指定日期的班组 起始点为2015年12月31日排班顺序
  361. int[] MouseDay = new int[13] { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 29 };
  362. int LoopCount = 0; //循环次数
  363. //算出当前日期与起始点相差天数
  364. int Days = 0;
  365. string DYear = Date.Substring(0, 4);
  366. for (int i = 2016; i < int.Parse(DYear); i++)
  367. {
  368. if (i % 4 == 0)
  369. {
  370. Days += 366;
  371. }
  372. else
  373. {
  374. Days += 365;
  375. }
  376. }
  377. string DMouse = Date.Substring(4, 2);
  378. for (int i = 1; i < int.Parse(DMouse); i++)
  379. {
  380. if (i == 2)
  381. {
  382. if (int.Parse(DYear) % 4 == 0)
  383. {
  384. Days += MouseDay[12];
  385. }
  386. else
  387. {
  388. Days += MouseDay[i - 1];
  389. }
  390. }
  391. else
  392. {
  393. Days += MouseDay[i - 1];
  394. }
  395. }
  396. string DDay = Date.Substring(6, 2);
  397. Days += int.Parse(DDay);
  398. if (Days > 0)
  399. {
  400. if (Days % 2 == 0)
  401. {
  402. LoopCount = (Days / 2) % 4;
  403. }
  404. else
  405. {
  406. LoopCount = ((Days - 1) / 2 + 1) % 4;
  407. }
  408. }
  409. ShiftNo[0] = (ShiftNo[0] + 4 - LoopCount) % 4;
  410. ShiftNo[1] = (ShiftNo[1] + 4 - LoopCount) % 4;
  411. ShiftNo[2] = (ShiftNo[2] + 4 - LoopCount) % 4;
  412. ShiftNo[3] = (ShiftNo[3] + 4 - LoopCount) % 4;
  413. ShiftList.Add(ShiftD[ShiftNo[0]]); //早
  414. ShiftList.Add(ShiftD[ShiftNo[1]]); //中
  415. ShiftList.Add(ShiftD[ShiftNo[2]]); //晚
  416. ShiftList.Add(ShiftD[ShiftNo[3]]); //休
  417. //ShiftList.Add//2016年 1月1日 1月2日 配班表
  418. switch (Shift)
  419. {
  420. case "1":
  421. ShiftAfter = "2";
  422. break;
  423. case "2":
  424. ShiftAfter = "3";
  425. break;
  426. case "3":
  427. ShiftAfter = "1";
  428. break;
  429. }
  430. if (Shift == "3")
  431. {
  432. switch (ShiftList[0].ToString())
  433. {
  434. case "甲":
  435. ShiftAfter += "1";
  436. break;
  437. case "乙":
  438. ShiftAfter += "2";
  439. break;
  440. case "丙":
  441. ShiftAfter += "3";
  442. break;
  443. case "丁":
  444. ShiftAfter += "4";
  445. break;
  446. }
  447. }
  448. else
  449. {
  450. for (int i = 0; i < ShiftNo.Count(); i++)
  451. {
  452. if (ShiftNo[i] == int.Parse(Group) - 1)
  453. {
  454. ShiftAfter += ((int.Parse((ShiftNo[(i + 3) % 4]).ToString()) + 3)%4).ToString();
  455. }
  456. }
  457. }
  458. return ShiftAfter;
  459. }
  460. /// <summary>
  461. /// 修改交班标识
  462. /// <param name="ProcessNo">0-锯切 1-加热炉 2-穿孔 3-连轧 4-再加热 5-定径 6-管排锯 7-矫直 8-探伤 9-质检</param>
  463. /// <param name="FurFlag">0-入炉 1-出炉</param>
  464. /// </summary>
  465. public void UpdateChangeFlag(string JudgeStvoeNo, string ResultNo, string FeedRowNo, int ProcessNo, int Seq, int FurFlag)
  466. {
  467. int count = ServerHelper.SetData("com.steering.mes.zgmil.coup.FeedSawResult.UpdateChangeFlag", new object[] { JudgeStvoeNo, ResultNo, FeedRowNo, ProcessNo, Seq, FurFlag }, this._ob);
  468. }
  469. /// <summary>
  470. /// 查询待接班确认Seq
  471. /// <param name="ProcessNo">0-锯切 1-加热炉 2-穿孔 3-连轧 4-再加热 5-定径 6-管排锯 7-矫直 8-探伤 9-质检</param>
  472. /// </summary>
  473. public int GetWaitChangeSeq(string JudgeStvoeNo, string ResultNo, string FeedRowNo, int ProcessNo, int FurFlag, string proPlanId, string gxPlanNo)
  474. {
  475. int Seq = 0;
  476. DataTable dt = ServerHelper.GetData("com.steering.mes.zgmil.coup.FeedSawResult.GetWaitChangeSeq", new object[] { JudgeStvoeNo, ResultNo, FeedRowNo, ProcessNo, FurFlag, proPlanId, gxPlanNo }, this._ob);
  477. if (dt.Rows.Count > 0)
  478. {
  479. Seq = int.Parse(dt.Rows[0][0].ToString());
  480. }
  481. return Seq;
  482. }
  483. /// <summary>
  484. /// 结炉前判断是否有待交班确认的管
  485. /// </summary>
  486. /// <param name="JudgeStoveNo"></param>
  487. /// <param name="ResultNo"></param>
  488. /// <param name="ProcessNo">工序号 0-锯切 1-环形加热炉 2-穿孔 3-连轧 4-再加热炉 5-定径 6-管排锯 7-矫直 8-探伤 9-质检</param>
  489. /// <returns></returns>
  490. public int NodeGetWaitChangeMat(string JudgeStoveNo, string ResultNo, int ProcessNo)
  491. {
  492. int MatNo = 0;
  493. DataTable dt = ServerHelper.GetData("com.steering.mes.zgmil.coup.FeedSawResult.NodeGetWaitChangeMat", new object[] { JudgeStoveNo, ResultNo, ProcessNo }, this._ob);
  494. if (dt.Rows.Count > 0)
  495. {
  496. MatNo = int.Parse(dt.Rows[0][0].ToString());
  497. }
  498. return MatNo;
  499. }
  500. /// <summary>
  501. /// 查询当班是否有完成的炉次
  502. /// </summary>
  503. /// <param name="Group"></param>
  504. /// <param name="Shift"></param>
  505. /// <returns>Result 0-未完成 1-已完成</returns>
  506. public int IsFirstFur(string DateTime, string Group, string Shift)
  507. {
  508. int Result = 0;
  509. return Result;
  510. }
  511. /// <summary>
  512. /// 查询是否已经接班登录
  513. /// </summary>
  514. /// <param name="StartTime"></param>
  515. /// <param name="EndTime"></param>
  516. /// <param name="Shift"></param>
  517. /// <param name="Group"></param>
  518. /// <param name="ProcessNo">工序号(0-锯切 1-加热炉 2-穿孔 3-连轧 4-再加热炉 5-定径 6-分切 7矫直 8-探伤 9-人工质检) </param>
  519. /// <param name="PlineCode"></param>
  520. /// <returns></returns>
  521. public bool IsChanged(string StartTime, string EndTime, string Shift, string Group, string ProcessNo, string PlineCode)
  522. {
  523. bool Result = false;
  524. DataTable dt = ServerHelper.GetData("com.steering.mes.zgmil.coup.FeedSawResult.GetIsChanged", new object[] { StartTime, EndTime, Shift, Group, ProcessNo, PlineCode }, this._ob);
  525. if (dt.Rows.Count > 0)
  526. {
  527. Result = true;
  528. }
  529. return Result;
  530. }
  531. /// <summary>
  532. /// 接班后插入履历
  533. /// </summary>
  534. /// <param name="StartTime"></param>
  535. /// <param name="EndTime"></param>
  536. /// <param name="Shift"></param>
  537. /// <param name="Group"></param>
  538. /// <param name="ProcessNo">工序号(0-锯切 1-加热炉 2-穿孔 3-连轧 4-再加热炉 5-定径 6-分切 7矫直 8-探伤 9-人工质检) </param>
  539. /// <param name="PlineCode"></param>
  540. /// <returns></returns>
  541. public void InsertChangeRemuse(string Shift, string Group, string User, string ProcessNo, string PlineCode)
  542. {
  543. ArrayList arry = new ArrayList();
  544. arry.Add(Shift);
  545. arry.Add(Group);
  546. arry.Add(User);
  547. arry.Add(ProcessNo);
  548. arry.Add(PlineCode);
  549. //bool Result = false;
  550. //string time = DateTime.Now.ToString();
  551. //int dt = ServerHelper.SetData("com.steering.mes.zgmil.coup.FeedSawResult.InsertChangeRemuse", new object[] {arry }, this._ob);
  552. //if (dt.Rows.Count > 0)
  553. //{
  554. // Result = true;
  555. //}
  556. }
  557. /// <summary>
  558. /// 获取前道班UserID
  559. /// </summary>
  560. /// <param name="StartTime">开始时间</param>
  561. /// <param name="EndTime">结束时间</param>
  562. /// <param name="Shift">前道班次</param>
  563. /// <param name="Group">前道班组</param>
  564. /// <param name="ProcessNo">工序号</param>
  565. /// <returns>UserID</returns>
  566. public string GetUserIDBefore(string StartTime, string EndTime, string Shift, string Group, int ProcessNo, string PlineCode)
  567. {
  568. string UserID = "";
  569. DataTable dt = ServerHelper.GetData("com.steering.mes.zgmil.coup.FeedSawResult.GetUserIDBefore", new object[] { StartTime, EndTime, Shift, Group, ProcessNo, PlineCode }, this._ob);
  570. if (dt.Rows.Count > 0)
  571. {
  572. UserID = dt.Rows[0][0].ToString();
  573. }
  574. return UserID;
  575. }
  576. }
  577. }