纽威
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.

200 lines
8.4 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. using ICSSoft.Common;
  2. using ICSSoft.Entity;
  3. using Newtonsoft.Json;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Data;
  7. using System.Data.SqlClient;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. namespace ICSSoft.DataProject
  12. {
  13. /// <summary>
  14. /// 管控方式
  15. /// </summary>
  16. public class ICSControlModeService
  17. {
  18. private static log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
  19. private static string connString = System.Configuration.ConfigurationManager.AppSettings["ConnStr"];
  20. private static string ERPDB = System.Configuration.ConfigurationManager.AppSettings["ERPDB"];
  21. DataTable table = null;
  22. SqlConnection conn = new System.Data.SqlClient.SqlConnection(connString);
  23. string sql = string.Empty;
  24. string sqlInfo = string.Empty;
  25. VerificationMethod verification = new VerificationMethod();
  26. /// <summary>
  27. /// 获取当前启用的管控方式
  28. /// </summary>
  29. /// <param name="cmd"></param>
  30. /// <param name="language"></param>
  31. /// <returns></returns>
  32. /// <exception cref="Exception"></exception>
  33. public static ControlMode GetControlMode()
  34. {
  35. using (SqlConnection conn = new System.Data.SqlClient.SqlConnection(connString))
  36. {
  37. conn.Open();
  38. SqlCommand cmd = new SqlCommand();
  39. SqlTransaction sqlTran = conn.BeginTransaction();
  40. cmd.Transaction = sqlTran;
  41. cmd.Connection = conn;
  42. try
  43. {
  44. string sql = @"SELECT TOP 1 F_ItemCode as itemCode,F_ItemName as itemName,F_EnabledMark as enableMark
  45. FROM [dbo].[Sys_SRM_ItemsDetail] WHERE F_ItemId='14361ce1-c5e3-4e85-a253-51aa3cdde3e6'AND F_EnabledMark='1' ORDER BY F_ItemCode";
  46. DataTable table = DBHelper.SQlReturnData(sql, cmd);
  47. string json = JsonConvert.SerializeObject(table);
  48. List<ControlMode> model = JsonConvert.DeserializeObject<List<ControlMode>>(json);
  49. cmd.Transaction.Commit();
  50. return model[0];
  51. }
  52. catch (Exception ex)
  53. {
  54. if (cmd.Transaction != null)
  55. cmd.Transaction.Rollback();
  56. log.Error(ex.Message);
  57. throw new Exception(ex.Message);
  58. }
  59. finally
  60. {
  61. if (conn.State == ConnectionState.Open)
  62. {
  63. conn.Close();
  64. }
  65. conn.Dispose();
  66. }
  67. }
  68. }
  69. /// <summary>
  70. /// 获取建议库位方式
  71. /// </summary>
  72. /// <param name="cmd"></param>
  73. /// <param name="language"></param>
  74. /// <returns></returns>
  75. /// <exception cref="Exception"></exception>
  76. public static ControlMode GetSuLocation()
  77. {
  78. using (SqlConnection conn = new System.Data.SqlClient.SqlConnection(connString))
  79. {
  80. conn.Open();
  81. SqlCommand cmd = new SqlCommand();
  82. SqlTransaction sqlTran = conn.BeginTransaction();
  83. cmd.Transaction = sqlTran;
  84. cmd.Connection = conn;
  85. try
  86. {
  87. string sql = @"SELECT Top 1 a.F_ItemCode as itemCode,a.F_ItemName as itemName,a.F_EnabledMark as enableMark
  88. FROM [dbo].[Sys_SRM_ItemsDetail] a
  89. LEFT JOIN [dbo].[Sys_SRM_Items] b ON a.F_ItemId=b.F_Id AND b.F_EnabledMark='1'
  90. WHERE F_ItemId='c8767643-1429-48b1-ad31-c6b19a1dfcb9'AND a.F_EnabledMark='1' ORDER BY a.F_ItemCode";
  91. DataTable table = DBHelper.SQlReturnData(sql, cmd);
  92. string json = JsonConvert.SerializeObject(table);
  93. List<ControlMode> model = JsonConvert.DeserializeObject<List<ControlMode>>(json);
  94. cmd.Transaction.Commit();
  95. return model?.FirstOrDefault();
  96. }
  97. catch (Exception ex)
  98. {
  99. if (cmd.Transaction != null)
  100. cmd.Transaction.Rollback();
  101. log.Error(ex.Message);
  102. throw new Exception(ex.Message);
  103. }
  104. finally
  105. {
  106. if (conn.State == ConnectionState.Open)
  107. {
  108. conn.Close();
  109. }
  110. conn.Dispose();
  111. }
  112. }
  113. }
  114. /// <summary>
  115. /// 根据条码获取信息
  116. /// </summary>
  117. /// <param name="LotNo"></param>
  118. /// <param name="WorkPoint"></param>
  119. /// <returns></returns>
  120. /// <exception cref="Exception"></exception>
  121. public static string QueryLotNo(string LotNo,string WorkPoint)
  122. {
  123. using (SqlConnection conn = new System.Data.SqlClient.SqlConnection(connString))
  124. {
  125. conn.Open();
  126. SqlCommand cmd = new SqlCommand();
  127. SqlTransaction sqlTran = conn.BeginTransaction();
  128. cmd.Transaction = sqlTran;
  129. cmd.Connection = conn;
  130. try
  131. {
  132. string sql = @"SELECT a.ID,
  133. con.ContainerCode,
  134. con.ContainerName,
  135. a.LotNo,
  136. a.InvCode,
  137. inv.InvName,
  138. inv.InvStd,
  139. inv.InvUnit,-- {0}
  140. inv.AmountUnit,
  141. ext.ID AS ExtensionID,
  142. ext.ProjectCode,
  143. ext.Version,
  144. ext.BatchCode,
  145. ext.Brand,
  146. ext.cFree1,
  147. ext.cFree2,
  148. ext.cFree3,
  149. ext.cFree4,
  150. ext.cFree5,
  151. ext.cFree6,
  152. ext.cFree7,
  153. ext.cFree8,
  154. ext.cFree9,
  155. ext.cFree10,
  156. a.MUSER AS [ USER ],
  157. a.MTIME AS [ MTime ]
  158. FROM
  159. ICSInventoryLot a
  160. LEFT JOIN ICSContainerLot conlot ON a.LotNo = conlot.LotNo AND a.WorkPoint = conlot.WorkPoint
  161. LEFT JOIN ICSContainer con ON conlot.ContainerID = con.ID AND conlot.WorkPoint = con.WorkPoint
  162. INNER JOIN ICSInventory inv ON a.InvCode = inv.InvCode AND a.WorkPoint = inv.WorkPoint
  163. INNER JOIN ICSExtension ext ON a.ExtensionID = ext.ID AND a.WorkPoint = ext.WorkPoint
  164. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}'";
  165. sql = string.Format(sql, LotNo, WorkPoint);
  166. DataTable table = DBHelper.SQlReturnData(sql, cmd);
  167. string json = JsonConvert.SerializeObject(table);
  168. //List<LotNoMode> model = JsonConvert.DeserializeObject<List<LotNoMode>>(json);
  169. cmd.Transaction.Commit();
  170. return json;
  171. }
  172. catch (Exception ex)
  173. {
  174. if (cmd.Transaction != null)
  175. cmd.Transaction.Rollback();
  176. log.Error(ex.Message);
  177. throw new Exception(ex.Message);
  178. }
  179. finally
  180. {
  181. if (conn.State == ConnectionState.Open)
  182. {
  183. conn.Close();
  184. }
  185. conn.Dispose();
  186. }
  187. }
  188. }
  189. }
  190. }