锐腾搅拌上料功能
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

581 lines
20 KiB

5 months ago
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using ICSSoft.Frame.Data.DAL;
  6. using ICSSoft.Frame.Data.Entity;
  7. namespace ICSSoft.Frame.Data.BLL
  8. {
  9. public class ICSCollectBLL
  10. {
  11. public static void Save(string Appconstr, ICSLOTSIMULATION simulation)
  12. {
  13. FramDataContext db = new FramDataContext(Appconstr);
  14. db.Connection.Open();
  15. db.Transaction = db.Connection.BeginTransaction();
  16. try
  17. {
  18. if (string.IsNullOrWhiteSpace(Appconstr))
  19. throw new Exception("连接字符串不能为空!");
  20. //校验传入数据是否符合采集要求
  21. ICSCollectDAL.CheckInfo(db, simulation);
  22. //保存数据
  23. ICSCollectDAL.Save(db, simulation);
  24. db.SubmitChanges();
  25. db.Transaction.Commit();
  26. db.Connection.Close();
  27. }
  28. catch (Exception ex)
  29. {
  30. db.Transaction.Rollback();
  31. db.Connection.Close();
  32. throw ex;
  33. }
  34. }
  35. public static string SaveList(string Appconstr, List<ICSLOTONWIP> onwiplist, List<ICSPO_PoMain> polist, List<ICSWareHouseLotInfoLog> loglist)
  36. {
  37. string errormessage = "";
  38. FramDataContext db = new FramDataContext(Appconstr);
  39. db.Connection.Open();
  40. db.Transaction = db.Connection.BeginTransaction();
  41. try
  42. {
  43. if (string.IsNullOrWhiteSpace(Appconstr))
  44. throw new Exception("连接字符串不能为空!");
  45. foreach (ICSLOTONWIP info in onwiplist)
  46. {
  47. //校验传入数据是否符合采集要求
  48. string opmessage = ICSCollectDAL.CheckInfoWW(db, info);
  49. //校验工艺路线是否有新增工序且未派工
  50. string routemessage = ICSCollectDAL.CheckRoute(db, info);
  51. if (opmessage == "" && routemessage == "")
  52. {
  53. //保存数据
  54. ICSCollectDAL.Save(db, info);
  55. }
  56. else
  57. {
  58. errormessage += opmessage + routemessage;
  59. }
  60. }
  61. if (errormessage == "")
  62. {
  63. //采购订单已发数量更新
  64. foreach (ICSPO_PoMain info in polist)
  65. {
  66. ICSCollectDAL.UpdatePOInfo(db, info);
  67. }
  68. //日志表条码对应采购订单信息记录
  69. foreach (ICSWareHouseLotInfoLog info in loglist)
  70. {
  71. ICSCollectDAL.AddLogInfo(db, info);
  72. }
  73. }
  74. db.SubmitChanges();
  75. db.Transaction.Commit();
  76. db.Connection.Close();
  77. return errormessage;
  78. }
  79. catch (Exception ex)
  80. {
  81. db.Transaction.Rollback();
  82. db.Connection.Close();
  83. throw ex;
  84. }
  85. }
  86. public static string SaveList(string Appconstr, List<ICSLOTSIMULATION> infolist, List<ICSLOTONWIP> listOnwip, List<ICSPO_PoMain> polist, List<ICSWareHouseLotInfoLog> loglist)
  87. {
  88. string errormessage = "";
  89. FramDataContext db = new FramDataContext(Appconstr);
  90. db.Connection.Open();
  91. db.Transaction = db.Connection.BeginTransaction();
  92. try
  93. {
  94. if (string.IsNullOrWhiteSpace(Appconstr))
  95. throw new Exception("连接字符串不能为空!");
  96. foreach (ICSLOTONWIP info in listOnwip)
  97. {
  98. //校验传入数据是否符合采集要求
  99. string opmessage = ICSCollectDAL.CheckInfoWW(db, info);
  100. //校验工艺路线是否有新增工序且未派工
  101. string routemessage = ICSCollectDAL.CheckRoute(db, info);
  102. if (opmessage == "" && routemessage == "")
  103. {
  104. //保存数据
  105. ICSCollectDAL.Save(db, info);
  106. }
  107. else
  108. {
  109. errormessage += opmessage + routemessage;
  110. }
  111. }
  112. if (errormessage == "")
  113. {
  114. //采购订单已发数量更新
  115. foreach (ICSPO_PoMain info in polist)
  116. {
  117. ICSCollectDAL.UpdatePOInfo(db, info);
  118. }
  119. //日志表条码对应采购订单信息记录
  120. foreach (ICSWareHouseLotInfoLog info in loglist)
  121. {
  122. ICSCollectDAL.AddLogInfo(db, info);
  123. }
  124. }
  125. db.SubmitChanges();
  126. db.Transaction.Commit();
  127. db.Connection.Close();
  128. return errormessage;
  129. }
  130. catch (Exception ex)
  131. {
  132. db.Transaction.Rollback();
  133. db.Connection.Close();
  134. throw ex;
  135. }
  136. }
  137. public static void CheckListEnd(string Appconstr, List<ICSLOTSIMULATION> infolist)
  138. {
  139. FramDataContext db = new FramDataContext(Appconstr);
  140. db.Connection.Open();
  141. db.Transaction = db.Connection.BeginTransaction();
  142. try
  143. {
  144. if (string.IsNullOrWhiteSpace(Appconstr))
  145. throw new Exception("连接字符串不能为空!");
  146. //foreach (ICSLOTSIMULATION info in infolist)
  147. //{
  148. // //校验传入数据是否符合采集要求
  149. // ICSCollectDAL.CheckInfo(db, info);
  150. // //保存数据
  151. // ICSCollectDAL.Save(db, info);
  152. //}
  153. //批量委外自动开工完工
  154. ICSCollectDAL.CheckListEnd(db, infolist);
  155. db.SubmitChanges();
  156. db.Transaction.Commit();
  157. db.Connection.Close();
  158. }
  159. catch (Exception ex)
  160. {
  161. db.Transaction.Rollback();
  162. db.Connection.Close();
  163. throw ex;
  164. }
  165. }
  166. public static void SaveListEnd(string Appconstr, List<ICSLOTSIMULATION> infolist)
  167. {
  168. FramDataContext db = new FramDataContext(Appconstr);
  169. db.Connection.Open();
  170. db.Transaction = db.Connection.BeginTransaction();
  171. try
  172. {
  173. if (string.IsNullOrWhiteSpace(Appconstr))
  174. throw new Exception("连接字符串不能为空!");
  175. //foreach (ICSLOTSIMULATION info in infolist)
  176. //{
  177. // //校验传入数据是否符合采集要求
  178. // ICSCollectDAL.CheckInfo(db, info);
  179. // //保存数据
  180. // ICSCollectDAL.Save(db, info);
  181. //}
  182. //批量委外自动开工完工
  183. ICSCollectDAL.CheckAutoOP(db, infolist);
  184. db.SubmitChanges();
  185. db.Transaction.Commit();
  186. db.Connection.Close();
  187. }
  188. catch (Exception ex)
  189. {
  190. db.Transaction.Rollback();
  191. db.Connection.Close();
  192. throw ex;
  193. }
  194. }
  195. public static void Transfer(string Appconstr, ICSLOTSIMULATION simulation)
  196. {
  197. FramDataContext db = new FramDataContext(Appconstr);
  198. db.Connection.Open();
  199. db.Transaction = db.Connection.BeginTransaction();
  200. try
  201. {
  202. if (string.IsNullOrWhiteSpace(Appconstr))
  203. throw new Exception("连接字符串不能为空!");
  204. //校验传入数据是否符合采集要求
  205. ICSCollectDAL.CheckTransferInfo(db, simulation);
  206. //保存数据
  207. ICSCollectDAL.Transfer(db, simulation);
  208. db.SubmitChanges();
  209. db.Transaction.Commit();
  210. db.Connection.Close();
  211. }
  212. catch (Exception ex)
  213. {
  214. db.Transaction.Rollback();
  215. db.Connection.Close();
  216. throw ex;
  217. }
  218. }
  219. public static void SaveItem(string Appconstr, ICSLOTONWIPITEM simulation)
  220. {
  221. FramDataContext db = new FramDataContext(Appconstr);
  222. db.Connection.Open();
  223. db.Transaction = db.Connection.BeginTransaction();
  224. try
  225. {
  226. if (string.IsNullOrWhiteSpace(Appconstr))
  227. throw new Exception("连接字符串不能为空!");
  228. //校验传入数据是否符合采集要求
  229. ICSCollectDAL.CheckItemInfo(db, simulation);
  230. //保存数据
  231. ICSCollectDAL.SaveItem(db, simulation);
  232. db.SubmitChanges();
  233. db.Transaction.Commit();
  234. db.Connection.Close();
  235. }
  236. catch (Exception ex)
  237. {
  238. db.Transaction.Rollback();
  239. db.Connection.Close();
  240. throw ex;
  241. }
  242. }
  243. public static void Pause(string Appconstr, ICSLOTSIMULATION simulation)
  244. {
  245. FramDataContext db = new FramDataContext(Appconstr);
  246. db.Connection.Open();
  247. db.Transaction = db.Connection.BeginTransaction();
  248. try
  249. {
  250. if (string.IsNullOrWhiteSpace(Appconstr))
  251. throw new Exception("连接字符串不能为空!");
  252. //校验传入数据是否符合采集要求
  253. ICSLOTSIMULATION sim = db.ICSLOTSIMULATION.SingleOrDefault(a => a.LOTNO == simulation.LOTNO && a.OPCODE == simulation.OPCODE);
  254. if (sim == null)
  255. {
  256. throw new Exception("该批次工序不是在制品不可暂停!");
  257. }
  258. else if (sim.CollectStatus.Equals("COLLECT_END"))
  259. {
  260. throw new Exception("该工序已经完工,不能暂停!");
  261. }
  262. else if (sim.LOTStatus.Equals("暂停"))
  263. {
  264. throw new Exception("该批次工序已经暂停!");
  265. }
  266. //保存数据
  267. ICSCollectDAL.Pause(db, sim);
  268. db.SubmitChanges();
  269. db.Transaction.Commit();
  270. db.Connection.Close();
  271. }
  272. catch (Exception ex)
  273. {
  274. db.Transaction.Rollback();
  275. db.Connection.Close();
  276. throw ex;
  277. }
  278. }
  279. public static void CancelPause(string Appconstr, ICSLOTSIMULATION simulation)
  280. {
  281. FramDataContext db = new FramDataContext(Appconstr);
  282. db.Connection.Open();
  283. db.Transaction = db.Connection.BeginTransaction();
  284. try
  285. {
  286. if (string.IsNullOrWhiteSpace(Appconstr))
  287. throw new Exception("连接字符串不能为空!");
  288. //保存数据
  289. ICSCollectDAL.CancelPause(db, simulation);
  290. db.SubmitChanges();
  291. db.Transaction.Commit();
  292. db.Connection.Close();
  293. }
  294. catch (Exception ex)
  295. {
  296. db.Transaction.Rollback();
  297. db.Connection.Close();
  298. throw ex;
  299. }
  300. }
  301. //结算料费
  302. public static void Calculate(string Appconstr, List<string> list)
  303. {
  304. FramDataContext db = new FramDataContext(Appconstr);
  305. db.Connection.Open();
  306. db.Transaction = db.Connection.BeginTransaction();
  307. try
  308. {
  309. if (string.IsNullOrWhiteSpace(Appconstr))
  310. throw new Exception("连接字符串不能为空!");
  311. //保存数据
  312. ICSCollectDAL.Calculate(db, list, "不合格");
  313. db.SubmitChanges();
  314. db.Transaction.Commit();
  315. db.Connection.Close();
  316. }
  317. catch (Exception ex)
  318. {
  319. db.Transaction.Rollback();
  320. db.Connection.Close();
  321. throw ex;
  322. }
  323. }
  324. //第一次判定
  325. //public static void FirstResult(string Appconstr, List<ICSLOTONWIPCheck> list, List<string> idList)
  326. //{
  327. // FramDataContext db = new FramDataContext(Appconstr);
  328. // db.Connection.Open();
  329. // db.Transaction = db.Connection.BeginTransaction();
  330. // try
  331. // {
  332. // if (string.IsNullOrWhiteSpace(Appconstr))
  333. // throw new Exception("连接字符串不能为空!");
  334. // //保存数据
  335. // ICSCollectDAL.FirstResult(db, list, idList);
  336. // db.SubmitChanges();
  337. // db.Transaction.Commit();
  338. // db.Connection.Close();
  339. // }
  340. // catch (Exception ex)
  341. // {
  342. // db.Transaction.Rollback();
  343. // db.Connection.Close();
  344. // throw ex;
  345. // }
  346. //}
  347. ////第二次判定
  348. //public static void SecondResult(string Appconstr, List<ICSLOTONWIPCheck> list, List<string> idList)
  349. //{
  350. // FramDataContext db = new FramDataContext(Appconstr);
  351. // db.Connection.Open();
  352. // db.Transaction = db.Connection.BeginTransaction();
  353. // try
  354. // {
  355. // if (string.IsNullOrWhiteSpace(Appconstr))
  356. // throw new Exception("连接字符串不能为空!");
  357. // //保存数据
  358. // ICSCollectDAL.SecondResult(db, list, idList);
  359. // db.SubmitChanges();
  360. // db.Transaction.Commit();
  361. // db.Connection.Close();
  362. // }
  363. // catch (Exception ex)
  364. // {
  365. // db.Transaction.Rollback();
  366. // db.Connection.Close();
  367. // throw ex;
  368. // }
  369. //}
  370. #region 获取跟踪单当前的采集信息
  371. public static ICSLOTSIMULATION GetSimInfoByLotNo(string LotNo, string dsconn)
  372. {
  373. try
  374. {
  375. return ICSCollectDAL.GetSimInfoByLotNo(LotNo, dsconn);
  376. }
  377. catch (Exception ex)
  378. {
  379. throw ex;
  380. }
  381. }
  382. #endregion
  383. #region 检查当前检验的工序是否是委外工(True:委外,Flase:非委外)
  384. public static bool GetLotOPInfoByCode(string LotNo, string OPCode, string dsconn)
  385. {
  386. try
  387. {
  388. return ICSCollectDAL.GetLotOPInfoByCode(LotNo, OPCode, dsconn);
  389. }
  390. catch (Exception ex)
  391. {
  392. throw ex;
  393. }
  394. }
  395. #endregion
  396. //public static void TResult(string Appconstr, List<ICSLOTONWIPCheck> list)
  397. //{
  398. // FramDataContext db = new FramDataContext(Appconstr);
  399. // db.Connection.Open();
  400. // db.Transaction = db.Connection.BeginTransaction();
  401. // try
  402. // {
  403. // if (string.IsNullOrWhiteSpace(Appconstr))
  404. // throw new Exception("连接字符串不能为空!");
  405. // //保存数据
  406. // ICSCollectDAL.TResult(db, list);
  407. // db.SubmitChanges();
  408. // db.Transaction.Commit();
  409. // db.Connection.Close();
  410. // }
  411. // catch (Exception ex)
  412. // {
  413. // db.Transaction.Rollback();
  414. // db.Connection.Close();
  415. // throw ex;
  416. // }
  417. //}
  418. #region GetModel
  419. //public static ICSLOTONWIPCheck GetModel(string id, string dsconn)
  420. //{
  421. // try
  422. // {
  423. // return ICSCollectDAL.GetModel(id, dsconn);
  424. // }
  425. // catch (Exception ex)
  426. // {
  427. // throw ex;
  428. // }
  429. //}
  430. #endregion
  431. #region AddPDF
  432. public static void AddPDF(string id, string fname, string dsconn)
  433. {
  434. try
  435. {
  436. ICSCollectDAL.AddPDF(id, fname, dsconn);
  437. }
  438. catch (Exception ex)
  439. {
  440. throw ex;
  441. }
  442. }
  443. #endregion
  444. //public static void RResult(string Appconstr, List<ICSLOTONWIPCheck> list)
  445. //{
  446. // FramDataContext db = new FramDataContext(Appconstr);
  447. // db.Connection.Open();
  448. // db.Transaction = db.Connection.BeginTransaction();
  449. // try
  450. // {
  451. // if (string.IsNullOrWhiteSpace(Appconstr))
  452. // throw new Exception("连接字符串不能为空!");
  453. // //保存数据
  454. // ICSCollectDAL.RResult(db, list);
  455. // db.SubmitChanges();
  456. // db.Transaction.Commit();
  457. // db.Connection.Close();
  458. // }
  459. // catch (Exception ex)
  460. // {
  461. // db.Transaction.Rollback();
  462. // db.Connection.Close();
  463. // throw ex;
  464. // }
  465. //}
  466. //删除开工未完工的记录
  467. public static void DataDelete(string Appconstr, List<FormICSCollectDataDeleteUIModel> infolist, List<FormICSCollectWWDataDeleteUIModel> wwinfolist)
  468. {
  469. FramDataContext db = new FramDataContext(Appconstr);
  470. db.Connection.Open();
  471. db.Transaction = db.Connection.BeginTransaction();
  472. try
  473. {
  474. if (string.IsNullOrWhiteSpace(Appconstr))
  475. throw new Exception("连接字符串不能为空!");
  476. if (infolist.Count != 0)
  477. {
  478. ICSCollectDAL.DataDelete(db, infolist);
  479. }
  480. if (wwinfolist.Count != 0)
  481. {
  482. ICSCollectDAL.DataDeleteForWW(db, wwinfolist);
  483. }
  484. db.Transaction.Commit();
  485. db.Connection.Close();
  486. }
  487. catch (Exception ex)
  488. {
  489. db.Transaction.Rollback();
  490. db.Connection.Close();
  491. throw ex;
  492. }
  493. }
  494. #region 判断第二次检验是否与第一次检验相同(True:相同;False:不同)
  495. //public static string CheckFSDifferent(string Appconstr, List<ICSLOTONWIPCheck> infolist, List<string> LotNO, List<string> OPCode)
  496. //{
  497. // FramDataContext db = new FramDataContext(Appconstr);
  498. // db.Connection.Open();
  499. // db.Transaction = db.Connection.BeginTransaction();
  500. // try
  501. // {
  502. // string Result = ICSCollectDAL.CheckFSDifferent(db, infolist, LotNO, OPCode);
  503. // db.Connection.Close();
  504. // return Result;
  505. // }
  506. // catch (Exception ex)
  507. // {
  508. // db.Connection.Close();
  509. // throw new Exception(ex.Message);
  510. // }
  511. //}
  512. #endregion
  513. /// <summary>
  514. /// 委外发料/收料
  515. /// </summary>
  516. /// <param name="send">是否是发料</param>
  517. /// <param name="ds">ds中的dt为每个跟踪单连续委外工序信息</param>
  518. /// <param name="conn">套接字</param>
  519. public static void OutsourceSubmit(bool send, System.Data.DataSet ds, string conn)
  520. {
  521. ICSCollectDAL.OutsourceSubmit(send, ds, conn);
  522. }
  523. public static void DeleteWW(System.Data.DataSet ds, string conn)
  524. {
  525. ICSCollectDAL.DeleteWW(ds, conn);
  526. }
  527. }
  528. }