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

3008 lines
184 KiB

3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 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
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 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
3 years ago
3 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
3 years ago
3 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
3 years ago
3 years ago
3 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
3 years ago
  1. using NFine.Data.Extensions;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using NFine.Code;
  6. using NFine.Repository;
  7. using System.Data.Common;
  8. using NFine.Domain._03_Entity.SRM;
  9. using System.Configuration;
  10. using System.Text;
  11. using System.Net;
  12. using Newtonsoft.Json.Linq;
  13. using Newtonsoft.Json;
  14. using System.IO;
  15. using NFine.Domain._03_Entity.WMS;
  16. namespace NFine.Application.WMS
  17. {
  18. public class WMSCreateItemLotApp : RepositoryFactory<ICSVendor>
  19. {
  20. public DataTable GetGridJson(string queryJson, ref Pagination jqgridparam)
  21. {
  22. DataTable dt = new DataTable();
  23. var queryParam = queryJson.ToJObject();
  24. List<DbParameter> parameter = new List<DbParameter>();
  25. object Figure = GetDecimalDigits();
  26. #region [SQL]
  27. string sql = @"select a.ID,a.ApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit, CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity
  28. ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount , CAST(a.IssueNegQuantity AS DECIMAL(18,{0})) as IssueNegQuantity ,a.ExtensionID,a.MUSERName,a.MTIME , CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  29. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  30. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  31. from ICSMOApplyNegDetail a
  32. left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
  33. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  34. left join (
  35. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  36. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='1'
  37. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  38. )c
  39. on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  40. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  41. where d.Type='1'";
  42. sql = string.Format(sql, Figure);
  43. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  44. #endregion
  45. if (!string.IsNullOrWhiteSpace(queryJson))
  46. {
  47. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  48. {
  49. sql += " and a.ApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
  50. }
  51. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  52. {
  53. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  54. }
  55. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  56. {
  57. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  58. }
  59. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  60. {
  61. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  62. }
  63. }
  64. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  65. {
  66. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  67. }
  68. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  69. {
  70. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  71. }
  72. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  73. }
  74. public DataTable GetSubGridJson(string ApplyNegCode, string Sequence, string Type, ref Pagination jqgridparam)
  75. {
  76. DataTable dt = new DataTable();
  77. object Figure = GetDecimalDigits();
  78. List<DbParameter> parameter = new List<DbParameter>();
  79. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  80. string sql = @" select c.TransCode,c.TransSequence ,a.ID,a.LotNo, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity ,a.MUSERName,a.MTIME
  81. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  82. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  83. from ICSInventoryLot a
  84. left join (select count(LotNo) LotNoCount,LotNo,WorkPoint from ICSWareHouseLotInfo
  85. group by LotNo,WorkPoint)b on a.LotNo=b.LotNo and a.WorkPoint=b.WorkPoint
  86. left join ICSInventoryLotDetail c on a.LotNo=c.LotNo and a.WorkPoint=c.WorkPoint
  87. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  88. WHERE a.Type='" + Type + "' and c.TransCode='" + ApplyNegCode + "' and c.TransSequence='" + Sequence + "' and a.WorkPoint in ('" + WorkPoint + "')";
  89. sql = string.Format(sql, Figure);
  90. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  91. }
  92. /// <summary>
  93. /// 点击生成条码
  94. /// </summary>
  95. public DataTable GetSubGridJsonByCreate(string ApplyNegCode, string Sequence, string WorkPoint)
  96. {
  97. DataTable dt = new DataTable();
  98. object Figure = GetDecimalDigits();
  99. List<DbParameter> parameter = new List<DbParameter>();
  100. string sql = @" select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity, CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty ,
  101. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  102. from ICSMOApplyNegDetail a
  103. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  104. left join (
  105. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  106. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  107. group by b.TransCode,b.TransSequence
  108. ) c on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
  109. WHERE 1 =1
  110. and a.ApplyNegCode='" + ApplyNegCode + "' and a.Sequence='" + Sequence + "'";
  111. sql += " and a.WorkPoint='" + WorkPoint + "'";
  112. sql = string.Format(sql, Figure);
  113. return Repository().FindTableBySql(sql.ToString());
  114. }
  115. public DataTable GetVendorLotNo(string VenCode, string WorkPoint)
  116. {
  117. DataTable dt = new DataTable();
  118. //var queryParam = queryJson.ToJObject();
  119. List<DbParameter> parameter = new List<DbParameter>();
  120. string dtPre = DateTime.Now.ToString("yyyyMMdd");
  121. string sql = @"EXEC Addins_GetSerialCode '" + WorkPoint + "','ICSITEMLotNo','VendorLotNo','" + VenCode + dtPre + "',2";
  122. return Repository().FindTableBySql(sql.ToString());
  123. }
  124. /// <summary>
  125. /// 生产退料生成条码
  126. /// </summary>
  127. /// <param name="POCode"></param>
  128. /// <param name="PORow"></param>
  129. /// <param name="keyValue"></param>
  130. /// 已改
  131. /// <returns></returns>
  132. public int CreateItemLotNo(string ApplyNegCode, string Sequence, string keyValue, string WorkPoint)
  133. {
  134. var queryParam = keyValue.ToJObject();
  135. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  136. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  137. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  138. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  139. decimal LOTQTY = minPackQty;
  140. //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  141. //string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint);
  142. string Pre = "MDN" + ApplyNegCode + Sequence;
  143. string sql = string.Empty;
  144. //string VendorLot = queryParam["VendorLot"].ToString();
  145. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  146. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  147. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  148. string Colspan = "";
  149. string sqls = string.Empty;
  150. for (int i = 0; i < createPageCount; i++)
  151. {
  152. if (i + 1 == createPageCount)
  153. {
  154. if (minPackQty * createPageCount > thisCreateQty)
  155. {
  156. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  157. }
  158. }
  159. Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
  160. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  161. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  162. if (ExtensionID == null)
  163. {
  164. ExtensionID = Guid.NewGuid();
  165. sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  166. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  167. ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
  168. MUSER, MUSERNAME, WorkPoints);
  169. }
  170. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  171. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  172. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  173. LotNo, ApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  174. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  175. //{
  176. sql += string.Format(@"insert into ICSInventoryLot
  177. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  178. select
  179. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','1','{3}','{4}', getdate(),'{5}','{9}'
  180. from ICSMOApplyNegDetail where ApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  181. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ApplyNegCode, Sequence, ExtensionID, Convert.ToDecimal(Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  182. sql += "\r\n";
  183. //}
  184. }
  185. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  186. return count;
  187. }
  188. public string GetSerialCode(string workPointCode, string tbName, string colName, string Pre, int numLen)
  189. {
  190. string sql = "EXEC Addins_GetSerialCode '{0}','{1}','{2}','{3}',{4}";
  191. sql = string.Format(sql, new object[] { workPointCode, tbName, colName, Pre, numLen });
  192. return DbHelper.ExecuteScalar(CommandType.Text, sql).ToString();
  193. }
  194. /// <summary>
  195. /// 删除条码
  196. /// </summary>
  197. /// <param name="keyValue"></param>
  198. /// <returns></returns>
  199. public string DeleteItemLot(string keyValue)
  200. {
  201. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  202. string msg = string.Empty;
  203. string sql = string.Format(@"SELECT * FROM dbo.ICSInspection
  204. WHERE LotNo IN (SELECT LotNO FROM dbo.ICSInventoryLot WHERE ID IN ({0})) and WorkPoint in ('{1}')", keyValue.TrimEnd(','), WorkPoint);
  205. DataTable dtASN = SqlHelper.GetDataTableBySql(sql);
  206. if (dtASN != null && dtASN.Rows.Count > 0)
  207. {
  208. msg = "所选条码已生成检验单,无法删除!";
  209. }
  210. sql = string.Format(@"SELECT * FROM dbo.ICSWareHouseLotInfo WHERE LotNO IN
  211. (SELECT LotNO FROM dbo.ICSInventoryLot WHERE ID IN ({0})) and WorkPoint in ('{1}')", keyValue.TrimEnd(','), WorkPoint);
  212. DataTable dtCarton = SqlHelper.GetDataTableBySql(sql);
  213. if (dtCarton != null && dtCarton.Rows.Count > 0)
  214. {
  215. msg += "所选条码已入库,无法删除!";
  216. }
  217. if (string.IsNullOrEmpty(msg))
  218. {
  219. string sqls = string.Format("DELETE FROM ICSInventoryLotDetail WHERE LotNO IN (select LotNO from ICSInventoryLot where ID in ({0}) ) and WorkPoint in ('{1}')", keyValue.TrimEnd(','), WorkPoint);
  220. sqls += string.Format("DELETE FROM dbo.ICSInventoryLot WHERE ID IN ({0}) and WorkPoint in ('{1}')", keyValue.TrimEnd(','), WorkPoint);
  221. SqlHelper.CmdExecuteNonQueryLi(sqls);
  222. }
  223. return msg;
  224. }
  225. public DataTable GetGridJsonWeiWai(string queryJson, ref Pagination jqgridparam)
  226. {
  227. DataTable dt = new DataTable();
  228. var queryParam = queryJson.ToJObject();
  229. List<DbParameter> parameter = new List<DbParameter>();
  230. object Figure = GetDecimalDigits();
  231. #region [SQL]
  232. string sql = @"select a.ID,a.OApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit, CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity
  233. ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount , CAST(a.IssueNegQuantity AS DECIMAL(18,{0})) as IssueNegQuantity,a.ExtensionID,a.MUSERName,a.MTIME ,
  234. CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  235. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  236. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  237. from ICSOApplyNegDetail a
  238. left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
  239. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  240. left join (
  241. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  242. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='2'
  243. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  244. )c
  245. on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  246. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  247. WHERE d.Type='1' ";
  248. sql = string.Format(sql, Figure);
  249. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  250. #endregion
  251. if (!string.IsNullOrWhiteSpace(queryJson))
  252. {
  253. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  254. {
  255. sql += " and a.OApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
  256. }
  257. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  258. {
  259. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  260. }
  261. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  262. {
  263. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  264. }
  265. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  266. {
  267. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  268. }
  269. }
  270. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  271. {
  272. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  273. }
  274. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  275. {
  276. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  277. }
  278. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  279. }
  280. public DataTable GetSubGridJsonWeiWai(string OApplyNegCode, string Sequence, ref Pagination jqgridparam)
  281. {
  282. DataTable dt = new DataTable();
  283. object Figure = GetDecimalDigits();
  284. //var queryParam = queryJson.ToJObject();
  285. List<DbParameter> parameter = new List<DbParameter>();
  286. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  287. string sql = @" select c.TransCode,c.TransSequence ,a.ID,a.LotNo,CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity from ICSInventoryLot a
  288. left join (select count(LotNo) LotNoCount,LotNo,WorkPoint from ICSWareHouseLotInfo
  289. group by LotNo,WorkPoint)b on a.LotNo=b.LotNo and a.WorkPoint=b.WorkPoint
  290. left join ICSInventoryLotDetail c on a.LotNo=c.LotNo
  291. WHERE c.TransCode='" + OApplyNegCode + "' and c.TransSequence='" + Sequence + "' and a.WorkPoint in (" + WorkPoint + ")";
  292. sql = string.Format(sql, Figure);
  293. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  294. }
  295. /// <summary>
  296. /// 点击委外退料生成条码
  297. /// </summary>
  298. public DataTable GetSubGridJsonWeiWaiByCreate(string OApplyNegCode, string Sequence, string WorkPoint)
  299. {
  300. DataTable dt = new DataTable();
  301. object Figure = GetDecimalDigits();
  302. List<DbParameter> parameter = new List<DbParameter>();
  303. string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  304. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  305. from ICSOApplyNegDetail a
  306. left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
  307. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  308. left join (
  309. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  310. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  311. group by b.TransCode,b.TransSequence
  312. ) c on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
  313. WHERE d.Type='1'
  314. and a.OApplyNegCode='" + OApplyNegCode + "' and a.Sequence='" + Sequence + "'";
  315. sql += " and a.WorkPoint='" + WorkPoint + "'";
  316. sql = string.Format(sql, Figure);
  317. return Repository().FindTableBySql(sql.ToString());
  318. }
  319. /// <summary>
  320. /// 委外退料生成条码
  321. /// </summary>
  322. /// <param name="POCode"></param>
  323. /// <param name="PORow"></param>
  324. /// <param name="keyValue"></param>
  325. /// 已改
  326. /// <returns></returns>
  327. public int SubmitFormWeiWai(string OApplyNegCode, string Sequence, string keyValue, string WorkPoint)
  328. {
  329. var queryParam = keyValue.ToJObject();
  330. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  331. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  332. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  333. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  334. decimal LOTQTY = minPackQty;
  335. string Pre = "OI" + OApplyNegCode + Sequence;
  336. string sql = string.Empty;
  337. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  338. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  339. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  340. string sqls = string.Empty;
  341. string Colspan = "";
  342. for (int i = 0; i < createPageCount; i++)
  343. {
  344. if (i + 1 == createPageCount)
  345. {
  346. if (minPackQty * createPageCount > thisCreateQty)
  347. {
  348. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  349. }
  350. }
  351. Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
  352. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  353. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  354. if (ExtensionID == null)
  355. {
  356. ExtensionID = Guid.NewGuid();
  357. sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  358. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  359. ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
  360. MUSER, MUSERNAME, WorkPoints);
  361. }
  362. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  363. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  364. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  365. LotNo, OApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  366. sql += string.Format(@"insert into ICSInventoryLot
  367. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  368. select
  369. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','2','{3}','{4}', getdate(),'{5}','{9}'
  370. from ICSOApplyNegDetail where OApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  371. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, OApplyNegCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  372. sql += "\r\n";
  373. }
  374. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  375. return count;
  376. }
  377. public DataTable GetGridJsonChengPing(string queryJson, ref Pagination jqgridparam)
  378. {
  379. DataTable dt = new DataTable();
  380. var queryParam = queryJson.ToJObject();
  381. List<DbParameter> parameter = new List<DbParameter>();
  382. object Figure = GetDecimalDigits();
  383. #region [SQL]
  384. string sql = @" select a.ID, a.MODetailID,a.MOCode,a.Sequence, CAST(a.RCVQuantity AS DECIMAL(18,{0})) as RCVQuantity ,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount,a.StartDate
  385. ,a.DueDate,a.MOStatus,a.ExtensionID,a.MUSERName,a.MTIME ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  386. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  387. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  388. from ICSMO a
  389. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  390. left join (
  391. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  392. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='3'
  393. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  394. )c
  395. on a.MOCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  396. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint ";
  397. sql += " WHERE 1=1";
  398. sql = string.Format(sql, Figure);
  399. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  400. #endregion
  401. if (!string.IsNullOrWhiteSpace(queryJson))
  402. {
  403. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  404. {
  405. sql += " and a.MOCode like '%" + queryParam["POCode"].ToString() + "%' ";
  406. }
  407. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  408. {
  409. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  410. }
  411. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  412. {
  413. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  414. }
  415. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  416. {
  417. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  418. }
  419. if (!string.IsNullOrWhiteSpace(queryParam["Container"].ToString()))
  420. {
  421. if (queryParam["Container"].ToString() == "1")
  422. {
  423. sql += " and a.RCVQuantity=a.Quantity ";
  424. }
  425. else
  426. {
  427. sql += " and (a.RCVQuantity<a.Quantity Or a.Quantity<=0) ";
  428. }
  429. }
  430. }
  431. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  432. {
  433. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  434. }
  435. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  436. {
  437. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  438. }
  439. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  440. }
  441. /// <summary>
  442. /// 点击成品生成条码(成品)
  443. /// </summary>
  444. public DataTable GetSubGridJsonChengPingByCreate(string MOCode, string Sequence, string WorkPoint)
  445. {
  446. DataTable dt = new DataTable();
  447. object Figure = GetDecimalDigits();
  448. List<DbParameter> parameter = new List<DbParameter>();
  449. string sql = @"select d.Enable, a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  450. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  451. from ICSMO a
  452. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  453. left join (
  454. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  455. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  456. group by b.TransCode,b.TransSequence
  457. ) c on a.MOCode=c.TransCode and a.Sequence=c.TransSequence
  458. left join ICSConfiguration d on d.Code='CompleteVerification'
  459. WHERE 1 =1
  460. and a.MOCode='" + MOCode + "' and a.Sequence='" + Sequence + "'";
  461. sql += " and a.WorkPoint='" + WorkPoint + "'";
  462. sql = string.Format(sql, Figure);
  463. return Repository().FindTableBySql(sql.ToString());
  464. }
  465. /// <summary>
  466. /// 成品生成条码
  467. /// </summary>
  468. /// <param name="POCode"></param>
  469. /// <param name="PORow"></param>
  470. /// <param name="keyValue"></param>
  471. /// 已改
  472. /// <returns></returns>
  473. public int SubmitFormChengPing(string MOCode, string Sequence, string keyValue, string WorkPoint)
  474. {
  475. var queryParam = keyValue.ToJObject();
  476. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  477. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  478. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  479. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  480. decimal LOTQTY = minPackQty;
  481. //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  482. //string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint);
  483. string Pre = "CP" + MOCode + Sequence;
  484. string sql = string.Empty;
  485. //string VendorLot = queryParam["VendorLot"].ToString();
  486. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  487. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  488. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  489. string sqls = string.Empty;
  490. string Colspan = "";
  491. for (int i = 0; i < createPageCount; i++)
  492. {
  493. if (i + 1 == createPageCount)
  494. {
  495. if (minPackQty * createPageCount > thisCreateQty)
  496. {
  497. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  498. }
  499. }
  500. Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
  501. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  502. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  503. if (ExtensionID == null)
  504. {
  505. ExtensionID = Guid.NewGuid();
  506. sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  507. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  508. ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
  509. MUSER, MUSERNAME, WorkPoints);
  510. }
  511. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  512. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  513. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  514. LotNo, MOCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  515. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  516. //{
  517. sql += string.Format(@"insert into ICSInventoryLot
  518. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  519. select
  520. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','3','{3}','{4}', getdate(),'{5}','{9}'
  521. from ICSMO where MOCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  522. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, MOCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  523. sql += "\r\n";
  524. //}
  525. }
  526. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  527. return count;
  528. }
  529. /// <summary>
  530. /// 销售退货单
  531. /// </summary>
  532. /// <param name="queryJson"></param>
  533. /// <param name="jqgridparam"></param>
  534. /// <returns></returns>
  535. public DataTable GetGridJsonXiaoShou(string queryJson, ref Pagination jqgridparam)
  536. {
  537. DataTable dt = new DataTable();
  538. var queryParam = queryJson.ToJObject();
  539. List<DbParameter> parameter = new List<DbParameter>();
  540. object Figure = GetDecimalDigits();
  541. #region [SQL]
  542. string sql = @" select a.ID,a.SDNCode,a.Sequence,a.SOCode,a.SOSequence,a.CusCode,a.CusName,a.Type,a.ArriveDate,a.InvCode,a.WHCode,detail.LocationCode AS Area,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity
  543. ,cast(a.Amount as decimal(18,{0})) as Amount, CAST(a.SDNQuantity AS DECIMAL(18,{0})) as SDNQuantity ,a.Status,a.ExtensionID,a.CreatePerson,a.CreateDateTime ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  544. ,a.WorkPoint,a.Points,a.DeliveryType,a.DeliveryDescribe,a.InvDescribe,a.OtherDescribe,a.SalesUnit,a.StockIndicator,a.IsSerialNumber
  545. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  546. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  547. from ICSSDN a
  548. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  549. LEFT JOIN ICSInventoryDetail detail on b.InvCode=detail.INVCode AND a.WHCode=detail.WHCode AND a.WorkPoint=detail.WorkPoint
  550. left join (
  551. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  552. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='4'
  553. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  554. )c
  555. on a.SDNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  556. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  557. where a.Type='2'";
  558. sql = string.Format(sql, Figure);
  559. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  560. #endregion
  561. if (!string.IsNullOrWhiteSpace(queryJson))
  562. {
  563. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  564. {
  565. sql += " and a.SDNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  566. }
  567. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  568. {
  569. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  570. }
  571. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  572. {
  573. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  574. }
  575. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  576. {
  577. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  578. }
  579. if (!string.IsNullOrWhiteSpace(queryParam["Location"].ToString()))
  580. {
  581. sql += " and a.WHCode like '%" + queryParam["Location"].ToString() + "%' ";
  582. }
  583. if (!string.IsNullOrWhiteSpace(queryParam["Area"].ToString()))
  584. {
  585. sql += " and detail.LocationCode like '%" + queryParam["Area"].ToString() + "%' ";
  586. }
  587. if (!string.IsNullOrWhiteSpace(queryParam["Container"].ToString()))
  588. {
  589. if (queryParam["Container"].ToString() == "1")
  590. {
  591. sql += " and a.SDNQuantity=a.Quantity ";
  592. }
  593. else
  594. {
  595. sql += " and (a.SDNQuantity<a.Quantity Or a.Quantity<=0) ";
  596. }
  597. }
  598. }
  599. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  600. {
  601. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  602. }
  603. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  604. {
  605. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  606. }
  607. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  608. }
  609. /// <summary>
  610. /// 点击销售退货生成条码(销售退货)
  611. /// </summary>
  612. public DataTable GetSubGridJsonXiaoShouByCreate(string SDNCode, string Sequence, string WorkPoint)
  613. {
  614. DataTable dt = new DataTable();
  615. object Figure = GetDecimalDigits();
  616. List<DbParameter> parameter = new List<DbParameter>();
  617. string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  618. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  619. from ICSSDN a
  620. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  621. left join (
  622. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  623. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  624. group by b.TransCode,b.TransSequence
  625. ) c on a.SDNCode=c.TransCode and a.Sequence=c.TransSequence
  626. WHERE 1 =1
  627. and a.Type='2' and a.SDNCode='" + SDNCode + "' and a.Sequence='" + Sequence + "'";
  628. sql += " and a.WorkPoint='" + WorkPoint + "'";
  629. sql = string.Format(sql, Figure);
  630. return Repository().FindTableBySql(sql.ToString());
  631. }
  632. /// <summary>
  633. /// 销售退货生成条码
  634. /// </summary>
  635. /// <param name="POCode"></param>
  636. /// <param name="PORow"></param>
  637. /// <param name="keyValue"></param>
  638. /// 已改
  639. /// <returns></returns>
  640. public int SubmitFormXiaoShou(string SDNCode, string Sequence, string keyValue, string WorkPoint)
  641. {
  642. var queryParam = keyValue.ToJObject();
  643. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  644. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  645. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  646. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  647. decimal LOTQTY = minPackQty;
  648. //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  649. //string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint);
  650. string Pre = "SR" + SDNCode + Sequence;
  651. string sql = string.Empty;
  652. //string VendorLot = queryParam["VendorLot"].ToString();
  653. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  654. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  655. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  656. string sqls = string.Empty;
  657. string Colspan = "";
  658. for (int i = 0; i < createPageCount; i++)
  659. {
  660. if (i + 1 == createPageCount)
  661. {
  662. if (minPackQty * createPageCount > thisCreateQty)
  663. {
  664. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  665. }
  666. }
  667. Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
  668. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  669. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  670. if (ExtensionID == null)
  671. {
  672. ExtensionID = Guid.NewGuid();
  673. sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  674. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  675. ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
  676. MUSER, MUSERNAME, WorkPoints);
  677. }
  678. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  679. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  680. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}')",
  681. LotNo, SDNCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  682. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  683. //{
  684. sql += string.Format(@"
  685. insert into ICSInventoryLot
  686. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  687. select
  688. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','4','{3}','{4}', getdate(),'{5}','{9}'
  689. from ICSSDN where Type='2' and SDNCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  690. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, SDNCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  691. sql += "\r\n";
  692. //}
  693. }
  694. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  695. return count;
  696. }
  697. public DataTable GetGridJsonQiTa(string queryJson, ref Pagination jqgridparam)
  698. {
  699. DataTable dt = new DataTable();
  700. var queryParam = queryJson.ToJObject();
  701. List<DbParameter> parameter = new List<DbParameter>();
  702. object Figure = GetDecimalDigits();
  703. #region [SQL]
  704. string sql = @" select a.ID,a.InCode,a.Sequence,a.WHCode,a.InvCode,a.WorkPoint,a.OrderType,
  705. a.TypeDescribe,a.CostCenter,a.Remarks,a.PersonNumber,a.InvDescribe,
  706. a.Unit,a.StockIndicator,detail.LocationCode AS Area, b.InvName,b.InvStd,b.InvDesc,b.InvUnit,
  707. CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST(a.Amount AS DECIMAL(18,{0})) as Amount, CAST(a.InQuantity AS DECIMAL(18,{0})) as InQuantity,a.CreatePerson,a.CreateDateTime,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  708. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  709. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  710. from ICSOtherIn a
  711. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  712. LEFT JOIN ICSInventoryDetail detail on b.InvCode=detail.INVCode AND a.WHCode=detail.WHCode AND a.WorkPoint=detail.WorkPoint
  713. left join (
  714. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  715. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='5'
  716. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  717. )c
  718. on a.InCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  719. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  720. where a.Status='1'";
  721. sql = string.Format(sql, Figure);
  722. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  723. #endregion
  724. if (!string.IsNullOrWhiteSpace(queryJson))
  725. {
  726. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  727. {
  728. sql += " and a.InCode like '%" + queryParam["POCode"].ToString() + "%' ";
  729. }
  730. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  731. {
  732. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  733. }
  734. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  735. {
  736. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  737. }
  738. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  739. {
  740. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  741. }
  742. if (!string.IsNullOrWhiteSpace(queryParam["Location"].ToString()))
  743. {
  744. sql += " and a.WHCode like '%" + queryParam["Location"].ToString() + "%' ";
  745. }
  746. if (!string.IsNullOrWhiteSpace(queryParam["Area"].ToString()))
  747. {
  748. sql += " and detail.LocationCode like '%" + queryParam["Area"].ToString() + "%' ";
  749. }
  750. if (!string.IsNullOrWhiteSpace(queryParam["Container"].ToString()))
  751. {
  752. if (queryParam["Container"].ToString() == "1")
  753. {
  754. sql += " and a.InQuantity=a.Quantity ";
  755. }
  756. else
  757. {
  758. sql += " and (a.InQuantity<a.Quantity Or a.Quantity<=0) ";
  759. }
  760. }
  761. }
  762. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  763. {
  764. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  765. }
  766. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  767. {
  768. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  769. }
  770. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  771. }
  772. /// <summary>
  773. /// 点击销售退货生成条码(其他入库)
  774. /// </summary>
  775. public DataTable GetSubGridJsonQiTaByCreate(string InCode, string Sequence, string WorkPoint)
  776. {
  777. DataTable dt = new DataTable();
  778. object Figure = GetDecimalDigits();
  779. List<DbParameter> parameter = new List<DbParameter>();
  780. string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  781. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  782. from ICSOtherIn a
  783. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  784. left join (
  785. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  786. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  787. group by b.TransCode,b.TransSequence
  788. ) c on a.InCode=c.TransCode and a.Sequence=c.TransSequence
  789. WHERE 1 =1
  790. and a.InCode='" + InCode + "' and a.Sequence='" + Sequence + "'";
  791. sql += " and a.WorkPoint='" + WorkPoint + "'";
  792. sql = string.Format(sql, Figure);
  793. return Repository().FindTableBySql(sql.ToString());
  794. }
  795. /// <summary>
  796. /// 其他入库生成条码
  797. /// </summary>
  798. /// <param name="POCode"></param>
  799. /// <param name="PORow"></param>
  800. /// <param name="keyValue"></param>
  801. /// 已改
  802. /// <returns></returns>
  803. public int SubmitFormQiTa(string InCode, string Sequence, string keyValue, string WorkPoint)
  804. {
  805. var queryParam = keyValue.ToJObject();
  806. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  807. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  808. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  809. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  810. decimal LOTQTY = minPackQty;
  811. //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  812. //string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint);
  813. string Pre = "QT" + InCode + Sequence;
  814. string sql = string.Empty;
  815. //string VendorLot = queryParam["VendorLot"].ToString();
  816. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  817. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  818. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  819. string sqls = string.Empty;
  820. string Colspan = "";
  821. for (int i = 0; i < createPageCount; i++)
  822. {
  823. if (i + 1 == createPageCount)
  824. {
  825. if (minPackQty * createPageCount > thisCreateQty)
  826. {
  827. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  828. }
  829. }
  830. Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
  831. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  832. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  833. if (ExtensionID == null)
  834. {
  835. ExtensionID = Guid.NewGuid();
  836. sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  837. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  838. ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
  839. MUSER, MUSERNAME, WorkPoints);
  840. }
  841. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  842. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  843. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  844. LotNo, InCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  845. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  846. //{
  847. sql += string.Format(@"
  848. insert into ICSInventoryLot
  849. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  850. select
  851. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','5','{3}','{4}', getdate(),'{5}','{9}'
  852. from ICSOtherIn where InCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  853. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, InCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  854. sql += "\r\n";
  855. //}
  856. }
  857. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  858. return count;
  859. }
  860. //归还
  861. public DataTable GetGridJsonGuiHuan(string queryJson, ref Pagination jqgridparam)
  862. {
  863. DataTable dt = new DataTable();
  864. var queryParam = queryJson.ToJObject();
  865. List<DbParameter> parameter = new List<DbParameter>();
  866. object Figure = GetDecimalDigits();
  867. #region [SQL]
  868. string sql = @"select a.ID,a.ReturnCode,a.Sequence,a.WHCode,a.InvCode, detail.LocationCode AS Area, b.InvName,b.InvStd,b.InvDesc,b.InvUnit,CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount, CAST(a.ReturnQuantity AS DECIMAL(18,{0})) as ReturnQuantity,a.CreatePerson,a.CreateDateTime,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  869. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  870. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10 from ICSReturn a
  871. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  872. LEFT JOIN ICSInventoryDetail detail on b.InvCode=detail.INVCode AND a.WHCode=detail.WHCode AND a.WorkPoint=detail.WorkPoint
  873. left join (
  874. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  875. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='6'
  876. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  877. ) c on a.ReturnCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  878. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  879. where a.Status='2'";
  880. sql = string.Format(sql, Figure);
  881. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  882. #endregion
  883. if (!string.IsNullOrWhiteSpace(queryJson))
  884. {
  885. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  886. {
  887. sql += " and a.ReturnCode like '%" + queryParam["POCode"].ToString() + "%' ";
  888. }
  889. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  890. {
  891. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  892. }
  893. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  894. {
  895. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  896. }
  897. if (!string.IsNullOrWhiteSpace(queryParam["Area"].ToString()))
  898. {
  899. sql += " and detail.LocationCode like '%" + queryParam["Area"].ToString() + "%' ";
  900. }
  901. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  902. {
  903. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  904. }
  905. }
  906. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  907. {
  908. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  909. }
  910. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  911. {
  912. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  913. }
  914. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  915. }
  916. //审核到货单(采购订单需与审核到货单一起同步)
  917. public DataTable GetGridJsonSHDH(string queryJson, ref Pagination jqgridparam)
  918. {
  919. DataTable dt = new DataTable();
  920. var queryParam = queryJson.ToJObject();
  921. List<DbParameter> parameter = new List<DbParameter>();
  922. object Figure = GetDecimalDigits();
  923. #region [SQL]
  924. string sql = @"select a.ID, '' as 'POCode',-- d.POCode,d.Sequence as POSequence,
  925. '' as POSequence,a.ModificationDate,a.TrackingNumber,a.NonconformingForm,
  926. a.DNCode,a.Sequence,a.VenCode,a.DepCode AS VenName,a.WHCode,a.InvCode,a.DNID,a.DNDetailID,a.WorkPoint,a.InspectionType,a.InvoDescribe,a.Unity,a.StockIndicator, b.InvName,b.InvStd,b.InvDesc,b.InvUnit, b.DrawingNo,
  927. b.Version AS Version1, detail.LocationCode AS Area,
  928. CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.RCVQuantity AS DECIMAL(18,{0})) as RCVQuantity,CAST(a.UnitPrice AS DECIMAL(18,{0})) as UnitPrice,a.Currency,a.CreatePerson,a.CreateDateTime,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  929. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  930. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  931. ,Case When a.WHCode+';'+detail.LocationCode in (select F_Define1+';'+F_Define2 from Sys_SRM_ItemsDetail where F_Define3='HGAreaConfig')
  932. THEN '' ELSE '' END AS AreaType
  933. from ICSDeliveryNotice a
  934. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  935. LEFT JOIN ICSInventoryDetail detail on b.InvCode=detail.INVCode AND a.WHCode=detail.WHCode AND a.WorkPoint=detail.WorkPoint
  936. left join (
  937. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  938. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='7'
  939. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  940. ) c on a.DNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  941. -- inner join ICSPurchaseOrder d on a.POID=d.POID and a.PODetailID=d.PODetailID and a.WorkPoint=d.WorkPoint
  942. left join ICSVendor e on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
  943. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  944. where a.DNType='1' and a.Status='2' and a.ASNCode is null
  945. ";
  946. sql = string.Format(sql, Figure);
  947. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  948. #endregion
  949. if (!string.IsNullOrWhiteSpace(queryJson))
  950. {
  951. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  952. {
  953. sql += " and a.DNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  954. }
  955. if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
  956. {
  957. sql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
  958. }
  959. if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
  960. {
  961. sql += " and a.DepCode like '%" + queryParam["VenName"].ToString() + "%' ";
  962. }
  963. if (!string.IsNullOrWhiteSpace(queryParam["Area"].ToString()))
  964. {
  965. sql += " and detail.LocationCode like '%" + queryParam["Area"].ToString() + "%' ";
  966. }
  967. if (!string.IsNullOrWhiteSpace(queryParam["Location"].ToString()))
  968. {
  969. sql += " and a.WHCode like '%" + queryParam["Location"].ToString() + "%' ";
  970. }
  971. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  972. {
  973. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  974. }
  975. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  976. {
  977. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  978. }
  979. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  980. {
  981. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  982. }
  983. if (!string.IsNullOrWhiteSpace(queryParam["Container"].ToString()))
  984. {
  985. if (queryParam["Container"].ToString() == "1")
  986. {
  987. sql += " and a.RCVQuantity=a.Quantity and a.Quantity!=0 ";
  988. }
  989. else
  990. {
  991. sql += " and (a.RCVQuantity<a.Quantity Or a.Quantity<=0) ";
  992. }
  993. }
  994. }
  995. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  996. {
  997. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  998. }
  999. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  1000. {
  1001. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  1002. }
  1003. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1004. }
  1005. //审核委外到货单
  1006. public DataTable GetGridJsonWWSHDH(string queryJson, ref Pagination jqgridparam)
  1007. {
  1008. DataTable dt = new DataTable();
  1009. var queryParam = queryJson.ToJObject();
  1010. List<DbParameter> parameter = new List<DbParameter>();
  1011. object Figure = GetDecimalDigits();
  1012. #region [SQL]
  1013. string sql = @"select a.ID, d.OOCode,d.Sequence as OOSequence,a.ODNCode,a.Sequence,a.VenCode,e.VenName,a.InvCode, b.InvName,b.InvStd,b.InvDesc,b.InvUnit,detail.LocationCode AS Area,CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.RCVQuantity AS DECIMAL(18,{0})) as RCVQuantity,CAST(a.UnitPrice AS DECIMAL(18,{0})) as UnitPrice,a.Currency,a.CreatePerson,a.CreateDateTime,
  1014. CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  1015. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  1016. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  1017. from ICSODeliveryNotice a
  1018. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1019. LEFT JOIN ICSInventoryDetail detail on b.InvCode=detail.INVCode AND a.WHCode=detail.WHCode AND a.WorkPoint=detail.WorkPoint
  1020. left join (
  1021. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  1022. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='8'
  1023. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  1024. ) c on a.ODNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  1025. inner join ICSOutsourcingOrder d on a.OOID=d.OOID and a.OODetailID=d.OODetailID and a.WorkPoint=d.WorkPoint
  1026. left join ICSVendor e on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
  1027. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  1028. where a.ODNType='1' and a.Status='2' and a.OASNCode is null";
  1029. sql = string.Format(sql, Figure);
  1030. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  1031. #endregion
  1032. if (!string.IsNullOrWhiteSpace(queryJson))
  1033. {
  1034. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1035. {
  1036. sql += " and a.ODNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1037. }
  1038. if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
  1039. {
  1040. sql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
  1041. }
  1042. if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
  1043. {
  1044. sql += " and e.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
  1045. }
  1046. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1047. {
  1048. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1049. }
  1050. if (!string.IsNullOrWhiteSpace(queryParam["Area"].ToString()))
  1051. {
  1052. sql += " and detail.LocationCode like '%" + queryParam["Area"].ToString() + "%' ";
  1053. }
  1054. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1055. {
  1056. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1057. }
  1058. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1059. {
  1060. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1061. }
  1062. }
  1063. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  1064. {
  1065. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  1066. }
  1067. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  1068. {
  1069. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  1070. }
  1071. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1072. }
  1073. //开立得成品入库单
  1074. public DataTable GetGridJsonKLCPRK(string queryJson, ref Pagination jqgridparam)
  1075. {
  1076. DataTable dt = new DataTable();
  1077. var queryParam = queryJson.ToJObject();
  1078. List<DbParameter> parameter = new List<DbParameter>();
  1079. object Figure = GetDecimalDigits();
  1080. #region [SQL]
  1081. string sql = @"
  1082. select a.ID,a.RCVCode,a.Sequence,a.WHCode,a.InvCode,a.EATTRIBUTE,a.WorkPoint,a.InvDescribe,a.OrderNumber,
  1083. a.OrderInvCode,a.OrderInvDescribe,a.BillType,a.Remarks,a.Unit,
  1084. a.StockIndicator,a.RemarksTerm,detail.LocationCode AS Area, b.InvName,b.InvStd,b.InvDesc,b.InvUnit,CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,
  1085. CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.RCVQuantity AS DECIMAL(18,{0})) as RCVQuantity ,a.CreatePerson,a.CreateDateTime,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  1086. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  1087. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  1088. ,Case When a.WHCode+';'+detail.LocationCode in (select F_Define1+';'+F_Define2 from Sys_SRM_ItemsDetail where F_Define3='HGAreaConfig')
  1089. THEN '' ELSE '' END AS AreaType
  1090. from ICSManufactureReceive a
  1091. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1092. LEFT JOIN ICSInventoryDetail detail on b.InvCode=detail.INVCode AND a.WHCode=detail.WHCode AND a.WorkPoint=detail.WorkPoint
  1093. left join (
  1094. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  1095. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='9'
  1096. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  1097. ) c on a.RCVCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  1098. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  1099. where a.Status='1' and a.Type='1'";
  1100. sql = string.Format(sql, Figure);
  1101. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  1102. #endregion
  1103. if (!string.IsNullOrWhiteSpace(queryJson))
  1104. {
  1105. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1106. {
  1107. sql += " and a.RCVCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1108. }
  1109. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1110. {
  1111. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1112. }
  1113. if (!string.IsNullOrWhiteSpace(queryParam["OrderNumber"].ToString()))
  1114. {
  1115. sql += " and a.OrderNumber like '%" + queryParam["OrderNumber"].ToString() + "%' ";
  1116. }
  1117. if (!string.IsNullOrWhiteSpace(queryParam["Area"].ToString()))
  1118. {
  1119. sql += " and detail.LocationCode like '%" + queryParam["Area"].ToString() + "%' ";
  1120. }
  1121. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1122. {
  1123. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1124. }
  1125. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1126. {
  1127. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1128. }
  1129. if (!string.IsNullOrWhiteSpace(queryParam["Container"].ToString()))
  1130. {
  1131. if (queryParam["Container"].ToString() == "1")
  1132. {
  1133. sql += " and a.RCVQuantity=a.Quantity ";
  1134. }
  1135. else
  1136. {
  1137. sql += " and (a.RCVQuantity<a.Quantity Or a.Quantity<=0) ";
  1138. }
  1139. }
  1140. }
  1141. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  1142. {
  1143. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  1144. }
  1145. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  1146. {
  1147. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  1148. }
  1149. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1150. }
  1151. /// <summary>
  1152. /// 点击审核委外到货单生成条码(审核委外到货单)
  1153. /// </summary>
  1154. public DataTable GetSubGridJsonWWSHDHByCreate(string ODNCode, string Sequence, string WorkPoint)
  1155. {
  1156. DataTable dt = new DataTable();
  1157. object Figure = GetDecimalDigits();
  1158. List<DbParameter> parameter = new List<DbParameter>();
  1159. string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  1160. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  1161. from ICSODeliveryNotice a
  1162. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1163. left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1164. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  1165. group by b.TransCode,b.TransSequence
  1166. ) c on a.ODNCode=c.TransCode and a.Sequence=c.TransSequence
  1167. WHERE 1 =1
  1168. and a.ODNCode='" + ODNCode + "' and a.Sequence='" + Sequence + "'";
  1169. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1170. sql = string.Format(sql, Figure);
  1171. return Repository().FindTableBySql(sql.ToString());
  1172. }
  1173. /// <summary>
  1174. /// 点击开立成品入库生成条码(开立成品入库单)
  1175. /// </summary>
  1176. /// //--
  1177. public DataTable GetSubGridJsonKLCPRKByCreate(string RCVCode, string Sequence, string WorkPoint)
  1178. {
  1179. DataTable dt = new DataTable();
  1180. object Figure = GetDecimalDigits();
  1181. List<DbParameter> parameter = new List<DbParameter>();
  1182. string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  1183. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  1184. from ICSManufactureReceive a
  1185. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1186. left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1187. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  1188. group by b.TransCode,b.TransSequence
  1189. ) c on a.RCVCode=c.TransCode and a.Sequence=c.TransSequence
  1190. WHERE 1 =1
  1191. and a.RCVCode='" + RCVCode + "' and a.Sequence='" + Sequence + "'";
  1192. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1193. sql = string.Format(sql, Figure);
  1194. return Repository().FindTableBySql(sql.ToString());
  1195. }
  1196. /// <summary>
  1197. /// 点击审核到货单生成条码(审核到货单)
  1198. /// </summary>
  1199. public DataTable GetSubGridJsonSHDHByCreate(string DNCode, string Sequence, string WorkPoint)
  1200. {
  1201. DataTable dt = new DataTable();
  1202. object Figure = GetDecimalDigits();
  1203. List<DbParameter> parameter = new List<DbParameter>();
  1204. string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  1205. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays ,e.BatchCode,e.Brand,e.ProjectCode
  1206. from ICSDeliveryNotice a
  1207. left join ICSExtension e ON e.ID=a.ExtensionID
  1208. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1209. left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1210. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  1211. group by b.TransCode,b.TransSequence
  1212. ) c on a.DNCode=c.TransCode and a.Sequence=c.TransSequence
  1213. WHERE 1 =1
  1214. and a.DNCode='" + DNCode + "' and a.Sequence='" + Sequence + "'";
  1215. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1216. sql = string.Format(sql, Figure);
  1217. return Repository().FindTableBySql(sql.ToString());
  1218. }
  1219. /// <summary>
  1220. /// 点击归还生成条码(归还)
  1221. /// </summary>
  1222. public DataTable GetSubGridJsonGuiHuanByCreate(string ReturnCode, string Sequence, string WorkPoint)
  1223. {
  1224. DataTable dt = new DataTable();
  1225. object Figure = GetDecimalDigits();
  1226. List<DbParameter> parameter = new List<DbParameter>();
  1227. string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  1228. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  1229. from ICSReturn a
  1230. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1231. left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1232. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  1233. group by b.TransCode,b.TransSequence
  1234. ) c on a.ReturnCode=c.TransCode and a.Sequence=c.TransSequence
  1235. WHERE 1 =1
  1236. and a.ReturnCode='" + ReturnCode + "' and a.Sequence='" + Sequence + "'";
  1237. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1238. sql = string.Format(sql, Figure);
  1239. return Repository().FindTableBySql(sql.ToString());
  1240. }
  1241. /// <summary>
  1242. /// 归还单生成条码
  1243. /// </summary>
  1244. /// <param name="POCode"></param>
  1245. /// <param name="PORow"></param>
  1246. /// <param name="keyValue"></param>
  1247. /// 已改
  1248. /// <returns></returns>
  1249. public int SubmitFormGuiHuan(string ReturnCode, string Sequence, string keyValue, string WorkPoint)
  1250. {
  1251. var queryParam = keyValue.ToJObject();
  1252. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1253. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1254. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1255. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1256. decimal LOTQTY = minPackQty;
  1257. string Pre = "GH" + ReturnCode + Sequence;
  1258. string sql = string.Empty;
  1259. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1260. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1261. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1262. string sqls = string.Empty;
  1263. string Colspan = "";
  1264. for (int i = 0; i < createPageCount; i++)
  1265. {
  1266. if (i + 1 == createPageCount)
  1267. {
  1268. if (minPackQty * createPageCount > thisCreateQty)
  1269. {
  1270. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1271. }
  1272. }
  1273. Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
  1274. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  1275. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1276. if (ExtensionID == null)
  1277. {
  1278. ExtensionID = Guid.NewGuid();
  1279. sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  1280. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1281. ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
  1282. MUSER, MUSERNAME, WorkPoints);
  1283. }
  1284. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1285. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1286. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1287. LotNo, ReturnCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1288. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  1289. //{
  1290. sql += string.Format(@"
  1291. insert into ICSInventoryLot
  1292. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  1293. select
  1294. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','6','{3}','{4}', getdate(),'{5}','{9}'
  1295. from ICSReturn where ReturnCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  1296. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ReturnCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  1297. sql += "\r\n";
  1298. //}
  1299. }
  1300. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1301. return count;
  1302. }
  1303. /// <summary>
  1304. /// 审核到货单生成条码
  1305. /// </summary>
  1306. /// <param name="POCode"></param>
  1307. /// <param name="PORow"></param>
  1308. /// <param name="keyValue"></param>
  1309. /// 已改
  1310. /// <returns></returns>
  1311. public int SubmitFormSHDH(string DNCode, string Sequence, string INVCode, string keyValue, string WorkPoint)
  1312. {
  1313. try
  1314. {
  1315. //string postUrlStr = System.Configuration.ConfigurationManager.AppSettings["HGDocpostUrlStr"].ToString();
  1316. var queryParam = keyValue.ToJObject();
  1317. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1318. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1319. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1320. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1321. decimal LOTQTY = minPackQty;
  1322. string Pre = "DN" + DNCode + Sequence;
  1323. string sql = string.Empty;
  1324. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1325. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1326. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1327. string sqls = string.Empty;
  1328. string Colspan = "";
  1329. //string InspectJosn = "";
  1330. //InspectJosn += "{";
  1331. //InspectJosn += "\"IMP_ORDINI\":[";
  1332. //InspectJosn += "{";
  1333. //InspectJosn += "\"ORD_ORDINE\":\"" + DNCode + "\",";
  1334. //InspectJosn += "货柜区域预留";
  1335. //InspectJosn += "\"ORD_DES\":\"采购入库-采购到货单\",";
  1336. //InspectJosn += "\"ORD_TIPOOP\":\"V\",";
  1337. //InspectJosn += "\"ORD_CLIENTE\":\"" + WorkPoint + "\"";
  1338. //InspectJosn += "}";
  1339. //InspectJosn += "],";
  1340. //InspectJosn += "\"IMP_ORDINI_RIGHE\":[";
  1341. for (int i = 0; i < createPageCount; i++)
  1342. {
  1343. if (i + 1 == createPageCount)
  1344. {
  1345. if (minPackQty * createPageCount > thisCreateQty)
  1346. {
  1347. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1348. }
  1349. }
  1350. //Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
  1351. //sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  1352. //object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1353. sqls = $@"SELECT TOP 1 ExtensionID FROM ICSDeliveryNotice WHERE DNCode='{DNCode}'";
  1354. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1355. if (ExtensionID == null)
  1356. {
  1357. ExtensionID = Guid.NewGuid();
  1358. sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  1359. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1360. ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
  1361. MUSER, MUSERNAME, WorkPoints);
  1362. }
  1363. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1364. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1365. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1366. LotNo, DNCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1367. sql += string.Format(@"insert into ICSInventoryLot
  1368. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  1369. select
  1370. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','7','{3}','{4}', getdate(),'{5}','{9}'
  1371. from ICSDeliveryNotice where DNCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
  1372. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, DNCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  1373. sql += "\r\n";
  1374. //if (i == createPageCount - 1)
  1375. //{
  1376. // InspectJosn += "{";
  1377. // InspectJosn += "\"RIG_ORDINE\":\"" + DNCode + "\",";
  1378. // InspectJosn += "\"RIG_ARTICOLO\": \"" + INVCode + "\",";
  1379. // InspectJosn += "\"RIG_SUB1\": \"" + LotNo + "\",";
  1380. // InspectJosn += "\"RIG_SUB2\": \"\",";
  1381. // //InspectJosn += "\"RIG_OPERATORE_ASSEGNATO\": \"" + 20220968 + "\",";
  1382. // InspectJosn += "\"RIG_QTAR\": " + LOTQTY + ",";
  1383. // InspectJosn += "\"RIG_HOSTINF\": " + Sequence + "";
  1384. // InspectJosn += "}";
  1385. //}
  1386. //else
  1387. //{
  1388. // InspectJosn += "{";
  1389. // InspectJosn += "\"RIG_ORDINE\":\"" + DNCode + "\",";
  1390. // InspectJosn += "\"RIG_ARTICOLO\": \"" + INVCode + "\",";
  1391. // InspectJosn += "\"RIG_SUB1\": \"" + LotNo + "\",";
  1392. // InspectJosn += "\"RIG_SUB2\": \"\",";
  1393. // //InspectJosn += "\"RIG_OPERATORE_ASSEGNATO\": \"" + 20220968 + "\",";
  1394. // InspectJosn += "\"RIG_QTAR\": " + LOTQTY + ",";
  1395. // InspectJosn += "\"RIG_HOSTINF\": " + Sequence + "";
  1396. // InspectJosn += "},";
  1397. //}
  1398. }
  1399. //InspectJosn += "]";
  1400. //InspectJosn += "}";
  1401. //string result = "";
  1402. //#region 验证物料对应仓储区域,非货柜区域不调用接口向货柜传输数据
  1403. //string LocationCode = "";
  1404. //string InvWHCode = "";
  1405. //string chksql = @"select LocationCode,WHCode from ICSInventoryDetail
  1406. // where INVCode='{0}' and WHCode=(
  1407. // select WHCode from ICSDeliveryNotice
  1408. // where DNCode='{1}' and Sequence='{2}' and WorkPoint='{3}')";
  1409. //chksql = string.Format(chksql, INVCode, DNCode, Sequence, WorkPoint);
  1410. //DataTable chkdt = SqlHelper.GetDataTableBySql(chksql);
  1411. //if (chkdt.Rows.Count == 0)
  1412. //{
  1413. // throw new Exception("当前选中行物料在对应库存地点没有维护有效的区域,无法生成条码,请确认!");
  1414. //}
  1415. //else
  1416. //{
  1417. // LocationCode = chkdt.Rows[0]["LocationCode"].ToString();
  1418. // InvWHCode = chkdt.Rows[0]["WHCode"].ToString();
  1419. // chksql = @"select F_Id from Sys_SRM_ItemsDetail
  1420. // where F_Define3='HGAreaConfig' AND F_Define1='{0}' AND F_Define2='{1}' and F_Define4='{2}'";
  1421. // chksql = string.Format(chksql, InvWHCode, LocationCode, WorkPoint);
  1422. // chkdt = SqlHelper.GetDataTableBySql(chksql);
  1423. //}
  1424. //#endregion
  1425. //if (chkdt.Rows.Count > 0 && Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["UploadERP"]))
  1426. //{
  1427. // #region 货柜接口调用前日志
  1428. // object logID = Guid.NewGuid();
  1429. // string logsql = @"insert into ICSWMS_HGLog
  1430. // values
  1431. // ('{0}',GETDATE(),'{1}','{2}','{3}','{4}','{5}')";
  1432. // logsql = string.Format(logsql, logID, InspectJosn, "", WorkPoint, MUSER, MUSERNAME);
  1433. // SqlHelper.CmdExecuteNonQueryLi(logsql);
  1434. // #endregion
  1435. // InspectJosn = InspectJosn.Replace("货柜区域预留", "\"ORD_ELEAREE\":\"" + LocationCode + "\",");
  1436. // result = HTTPHelper.RestFulGet(InspectJosn, postUrlStr);
  1437. // #region 货柜接口调用后日志
  1438. // logsql = @"update ICSWMS_HGLog set ReturnResult='{0}'
  1439. // where ID='{1}'";
  1440. // logsql = string.Format(logsql, result, logID);
  1441. // SqlHelper.CmdExecuteNonQueryLi(logsql);
  1442. // #endregion
  1443. // if (!result.Contains("successo"))
  1444. // {
  1445. // ICSHGResult hgresult = JsonConvert.DeserializeObject<ICSHGResult>(result.TrimStart('[').TrimEnd(']'));
  1446. // throw new Exception("货柜单据传输接口调用报错,主要报错信息:" + hgresult.PrimaryError + ",次要报错信息:" + hgresult.SecondaryError + "");
  1447. // }
  1448. //}
  1449. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1450. return count;
  1451. }
  1452. catch (Exception ex)
  1453. {
  1454. throw new Exception(ex.Message);
  1455. }
  1456. }
  1457. //领料申请退料生成条码
  1458. public int SubmitFormLLSQTL(string ApplyNegCode, string Sequence, string INVCode, string keyValue, string WorkPoint)
  1459. {
  1460. string postUrlStr = System.Configuration.ConfigurationManager.AppSettings["HGDocpostUrlStr"].ToString();
  1461. var queryParam = keyValue.ToJObject();
  1462. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1463. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1464. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1465. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1466. decimal LOTQTY = minPackQty;
  1467. //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1468. //string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint);
  1469. string Pre = "MA" + ApplyNegCode + Sequence;
  1470. string sql = string.Empty;
  1471. //string VendorLot = queryParam["VendorLot"].ToString();
  1472. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1473. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1474. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1475. string sqls = string.Empty;
  1476. string Colspan = "";
  1477. for (int i = 0; i < createPageCount; i++)
  1478. {
  1479. if (i + 1 == createPageCount)
  1480. {
  1481. if (minPackQty * createPageCount > thisCreateQty)
  1482. {
  1483. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1484. }
  1485. }
  1486. Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
  1487. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  1488. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1489. if (ExtensionID == null)
  1490. {
  1491. ExtensionID = Guid.NewGuid();
  1492. sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  1493. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1494. ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
  1495. MUSER, MUSERNAME, WorkPoints);
  1496. }
  1497. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1498. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1499. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1500. LotNo, ApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1501. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  1502. //{
  1503. sql += string.Format(@"insert into ICSInventoryLot
  1504. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  1505. select
  1506. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','12','{3}','{4}', getdate(),'{5}','{9}'
  1507. from ICSMOApplyNegDetail where ApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  1508. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ApplyNegCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  1509. sql += "\r\n";
  1510. //}
  1511. }
  1512. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1513. return count;
  1514. }
  1515. /// <summary>
  1516. /// 开立成品入库单
  1517. /// </summary>
  1518. /// <param name="POCode"></param>
  1519. /// <param name="PORow"></param>
  1520. /// <param name="keyValue"></param>
  1521. /// 已改
  1522. /// <returns></returns>
  1523. public int SubmitFormKLCPRK(string RCVCode, string Sequence, string INVCode, string keyValue, string WorkPoint)
  1524. {
  1525. string postUrlStr = System.Configuration.ConfigurationManager.AppSettings["HGDocpostUrlStr"].ToString();
  1526. var queryParam = keyValue.ToJObject();
  1527. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1528. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1529. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1530. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1531. decimal LOTQTY = minPackQty;
  1532. string Pre = "KCP" + RCVCode + Sequence;
  1533. string sql = string.Empty;
  1534. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1535. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1536. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1537. string sqls = string.Empty;
  1538. string Colspan = "";
  1539. for (int i = 0; i < createPageCount; i++)
  1540. {
  1541. if (i + 1 == createPageCount)
  1542. {
  1543. if (minPackQty * createPageCount > thisCreateQty)
  1544. {
  1545. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1546. }
  1547. }
  1548. Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
  1549. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  1550. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1551. if (ExtensionID == null)
  1552. {
  1553. ExtensionID = Guid.NewGuid();
  1554. sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  1555. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1556. ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
  1557. MUSER, MUSERNAME, WorkPoints);
  1558. }
  1559. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1560. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1561. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1562. LotNo, RCVCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1563. sql += string.Format(@"
  1564. insert into ICSInventoryLot
  1565. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  1566. select
  1567. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','9','{3}','{4}', getdate(),'{5}','{9}'
  1568. from ICSManufactureReceive where RCVCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
  1569. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, RCVCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  1570. sql += "\r\n";
  1571. }
  1572. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1573. return count;
  1574. }
  1575. /// <summary>
  1576. /// 审核委外到货单生成条码
  1577. /// </summary>
  1578. /// <param name="POCode"></param>
  1579. /// <param name="PORow"></param>
  1580. /// <param name="keyValue"></param>
  1581. /// 已改
  1582. /// <returns></returns>
  1583. public int SubmitFormWWSHDH(string ODNCode, string Sequence, string keyValue, string WorkPoint)
  1584. {
  1585. var queryParam = keyValue.ToJObject();
  1586. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1587. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1588. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1589. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1590. decimal LOTQTY = minPackQty;
  1591. string Pre = "ODN" + ODNCode + Sequence;
  1592. string sql = string.Empty;
  1593. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1594. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1595. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1596. string sqls = string.Empty;
  1597. string Colspan = "";
  1598. for (int i = 0; i < createPageCount; i++)
  1599. {
  1600. if (i + 1 == createPageCount)
  1601. {
  1602. if (minPackQty * createPageCount > thisCreateQty)
  1603. {
  1604. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1605. }
  1606. }
  1607. Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
  1608. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  1609. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1610. if (ExtensionID == null)
  1611. {
  1612. ExtensionID = Guid.NewGuid();
  1613. sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  1614. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1615. ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
  1616. MUSER, MUSERNAME, WorkPoints);
  1617. }
  1618. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1619. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1620. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1621. LotNo, ODNCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1622. sql += string.Format(@"
  1623. insert into ICSInventoryLot
  1624. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  1625. select
  1626. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','8','{3}','{4}', getdate(),'{5}','{9}'
  1627. from ICSODeliveryNotice where ODNCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
  1628. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ODNCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  1629. sql += "\r\n";
  1630. }
  1631. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1632. return count;
  1633. }
  1634. //委外拒收单
  1635. public DataTable GetGridJsonWWJSD(string queryJson, ref Pagination jqgridparam)
  1636. {
  1637. DataTable dt = new DataTable();
  1638. var queryParam = queryJson.ToJObject();
  1639. List<DbParameter> parameter = new List<DbParameter>();
  1640. object Figure = GetDecimalDigits();
  1641. #region [SQL]
  1642. string sql = @"select a.ID, a.ODNCode OOCode,a.Sequence OOSequence,a.VenCode,e.VenName,a.InvCode, b.InvName,b.InvStd,b.InvDesc,b.InvUnit,
  1643. CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.RCVQuantity AS DECIMAL(18,{0})) as RCVQuantity,CAST(a.UnitPrice AS DECIMAL(18,{0})) as UnitPrice,a.Currency,a.CreatePerson,a.CreateDateTime,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  1644. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  1645. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  1646. from ICSODeliveryNotice a
  1647. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1648. left join (
  1649. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  1650. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='11'
  1651. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  1652. ) c on a.ODNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  1653. --inner join ICSOutsourcingOrder d on a.OOID=d.OOID and a.OODetailID=d.OODetailID and a.WorkPoint=d.WorkPoint
  1654. left join ICSVendor e on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
  1655. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  1656. where a.ODNType='3' and a.Status='2' and a.EATTRIBUTE1 is NOT null
  1657. ";
  1658. sql = string.Format(sql, Figure);
  1659. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  1660. #endregion
  1661. if (!string.IsNullOrWhiteSpace(queryJson))
  1662. {
  1663. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1664. {
  1665. sql += " and a.ODNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1666. }
  1667. if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
  1668. {
  1669. sql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
  1670. }
  1671. if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
  1672. {
  1673. sql += " and e.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
  1674. }
  1675. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1676. {
  1677. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1678. }
  1679. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1680. {
  1681. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1682. }
  1683. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1684. {
  1685. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1686. }
  1687. }
  1688. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  1689. {
  1690. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  1691. }
  1692. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  1693. {
  1694. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  1695. }
  1696. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1697. }
  1698. //拒收单
  1699. public DataTable GetGridJsonJSD(string queryJson, ref Pagination jqgridparam)
  1700. {
  1701. DataTable dt = new DataTable();
  1702. var queryParam = queryJson.ToJObject();
  1703. List<DbParameter> parameter = new List<DbParameter>();
  1704. object Figure = GetDecimalDigits();
  1705. #region [SQL]
  1706. string sql = @"select a.ID,a.DNCode ,a.Sequence ,a.VenCode,e.VenName,a.InvCode, b.InvName,b.InvStd,b.InvDesc,b.InvUnit,
  1707. CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.RCVQuantity AS DECIMAL(18,{0})) as RCVQuantity,CAST( a.UnitPrice AS DECIMAL(18,{0})) as UnitPrice,a.Currency,a.CreatePerson,a.CreateDateTime,
  1708. CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  1709. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  1710. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  1711. from ICSDeliveryNotice a
  1712. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1713. left join (
  1714. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  1715. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='10'
  1716. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  1717. ) c on a.DNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  1718. --inner join ICSPurchaseOrder d on a.POID=d.POID and a.PODetailID=d.PODetailID and a.WorkPoint=d.WorkPoint
  1719. left join ICSVendor e on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
  1720. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  1721. where a.DNType='3' and a.Status='2' and a.EATTRIBUTE1 is NOT null
  1722. ";
  1723. sql = string.Format(sql, Figure);
  1724. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  1725. #endregion
  1726. if (!string.IsNullOrWhiteSpace(queryJson))
  1727. {
  1728. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1729. {
  1730. sql += " and a.DNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1731. }
  1732. if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
  1733. {
  1734. sql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
  1735. }
  1736. if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
  1737. {
  1738. sql += " and e.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
  1739. }
  1740. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1741. {
  1742. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1743. }
  1744. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1745. {
  1746. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1747. }
  1748. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1749. {
  1750. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1751. }
  1752. }
  1753. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  1754. {
  1755. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  1756. }
  1757. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  1758. {
  1759. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  1760. }
  1761. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1762. }
  1763. //领料申请退料
  1764. public DataTable GetGridJsonLLSQTL(string queryJson, ref Pagination jqgridparam)
  1765. {
  1766. DataTable dt = new DataTable();
  1767. var queryParam = queryJson.ToJObject();
  1768. List<DbParameter> parameter = new List<DbParameter>();
  1769. object Figure = GetDecimalDigits();
  1770. #region [SQL]
  1771. string sql = @"select a.ID,a.ApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,d.CreateDateTime,
  1772. CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.IssueNegQuantity AS DECIMAL(18,{0})) as IssueNegQuantity
  1773. ,a.ExtensionID,a.MUSERName,a.MTIME ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  1774. ,a.WHCode,detail.LocationCode AS Area,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  1775. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  1776. ,Case When a.WHCode+';'+detail.LocationCode in (select F_Define1+';'+F_Define2 from Sys_SRM_ItemsDetail where F_Define3='HGAreaConfig')
  1777. THEN '' ELSE '' END AS AreaType
  1778. from ICSMOApplyNegDetail a
  1779. left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
  1780. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1781. LEFT JOIN ICSInventoryDetail detail ON b.InvCode=detail.INVCode AND a.WHCode=detail.WHCode AND a.WorkPoint=detail.WorkPoint
  1782. left join (
  1783. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  1784. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='12'
  1785. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  1786. )c
  1787. on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  1788. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  1789. WHERE d.Type='2'";
  1790. sql = string.Format(sql, Figure);
  1791. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  1792. #endregion
  1793. if (!string.IsNullOrWhiteSpace(queryJson))
  1794. {
  1795. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1796. {
  1797. sql += " and a.ApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1798. }
  1799. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1800. {
  1801. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1802. }
  1803. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1804. {
  1805. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1806. }
  1807. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1808. {
  1809. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1810. }
  1811. if (!string.IsNullOrWhiteSpace(queryParam["Location"].ToString()))
  1812. {
  1813. sql += " and a.WHCode like '%" + queryParam["Location"].ToString() + "%' ";
  1814. }
  1815. if (!string.IsNullOrWhiteSpace(queryParam["Area"].ToString()))
  1816. {
  1817. sql += " and detail.LocationCode like '%" + queryParam["Area"].ToString() + "%' ";
  1818. }
  1819. if (!string.IsNullOrWhiteSpace(queryParam["Container"].ToString()))
  1820. {
  1821. if (queryParam["Container"].ToString() == "1")
  1822. {
  1823. sql += " and a.IssueNegQuantity=a.Quantity ";
  1824. }
  1825. else
  1826. {
  1827. sql += " and (a.IssueNegQuantity<a.Quantity Or a.Quantity<=0) ";
  1828. }
  1829. }
  1830. }
  1831. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  1832. {
  1833. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  1834. }
  1835. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  1836. {
  1837. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  1838. }
  1839. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1840. }
  1841. /// <summary>
  1842. /// 拒收生成条码
  1843. /// </summary>
  1844. /// <param name="POCode"></param>
  1845. /// <param name="PORow"></param>
  1846. /// <param name="keyValue"></param>
  1847. /// <returns></returns>
  1848. public int SubmitFormJSD(string DNCode, string Sequence, string keyValue, string WorkPoint)
  1849. {
  1850. var queryParam = keyValue.ToJObject();
  1851. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1852. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1853. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1854. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1855. decimal LOTQTY = minPackQty;
  1856. string Pre = "JS" + DNCode + Sequence;
  1857. string sql = string.Empty;
  1858. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1859. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1860. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1861. string sqls = string.Empty;
  1862. string Colspan = "";
  1863. for (int i = 0; i < createPageCount; i++)
  1864. {
  1865. if (i + 1 == createPageCount)
  1866. {
  1867. if (minPackQty * createPageCount > thisCreateQty)
  1868. {
  1869. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1870. }
  1871. }
  1872. Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
  1873. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  1874. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1875. if (ExtensionID == null)
  1876. {
  1877. ExtensionID = Guid.NewGuid();
  1878. sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  1879. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1880. ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
  1881. MUSER, MUSERNAME, WorkPoints);
  1882. }
  1883. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1884. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1885. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1886. LotNo, DNCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1887. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  1888. //{
  1889. sql += string.Format(@"
  1890. insert into ICSInventoryLot
  1891. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  1892. select
  1893. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','10','{3}','{4}', getdate(),'{5}','{9}'
  1894. from ICSDeliveryNotice where DNCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
  1895. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, DNCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  1896. sql += "\r\n";
  1897. //}
  1898. }
  1899. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1900. return count;
  1901. }
  1902. /// <summary>
  1903. /// 委外拒收生成条码
  1904. /// </summary>
  1905. /// <param name="POCode"></param>
  1906. /// <param name="PORow"></param>
  1907. /// <param name="keyValue"></param>
  1908. /// <returns></returns>
  1909. public int SubmitFormWWJSD(string ODNCode, string Sequence, string keyValue, string WorkPoint)
  1910. {
  1911. var queryParam = keyValue.ToJObject();
  1912. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  1913. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  1914. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  1915. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  1916. decimal LOTQTY = minPackQty;
  1917. string Pre = "OJS" + ODNCode + Sequence;
  1918. string sql = string.Empty;
  1919. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1920. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1921. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  1922. string sqls = string.Empty;
  1923. string Colspan = "";
  1924. for (int i = 0; i < createPageCount; i++)
  1925. {
  1926. if (i + 1 == createPageCount)
  1927. {
  1928. if (minPackQty * createPageCount > thisCreateQty)
  1929. {
  1930. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  1931. }
  1932. }
  1933. Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
  1934. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  1935. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  1936. if (ExtensionID == null)
  1937. {
  1938. ExtensionID = Guid.NewGuid();
  1939. sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  1940. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  1941. ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
  1942. MUSER, MUSERNAME, WorkPoints);
  1943. }
  1944. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  1945. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  1946. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  1947. LotNo, ODNCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  1948. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  1949. //{
  1950. sql += string.Format(@"
  1951. insert into ICSInventoryLot
  1952. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  1953. select
  1954. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','11','{3}','{4}', getdate(),'{5}','{9}'
  1955. from ICSODeliveryNotice where ODNCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
  1956. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ODNCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  1957. sql += "\r\n";
  1958. //}
  1959. }
  1960. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  1961. return count;
  1962. }
  1963. /// <summary>
  1964. /// 点击审核到货单生成条码(审核到货单)
  1965. /// </summary>
  1966. public DataTable GetSubGridJsonJSDByCreate(string DNCode, string Sequence, string WorkPoint)
  1967. {
  1968. DataTable dt = new DataTable();
  1969. object Figure = GetDecimalDigits();
  1970. List<DbParameter> parameter = new List<DbParameter>();
  1971. string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  1972. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  1973. from ICSDeliveryNotice a
  1974. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1975. left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1976. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  1977. group by b.TransCode,b.TransSequence
  1978. ) c on a.DNCode=c.TransCode and a.Sequence=c.TransSequence
  1979. WHERE a.DNType='3'
  1980. and a.DNCode='" + DNCode + "' and a.Sequence='" + Sequence + "'";
  1981. sql += " and a.WorkPoint='" + WorkPoint + "'";
  1982. sql = string.Format(sql, Figure);
  1983. return Repository().FindTableBySql(sql.ToString());
  1984. }
  1985. /// <summary>
  1986. /// 点击审核委外到货单生成条码(审核委外到货单)
  1987. /// </summary>
  1988. public DataTable GetSubGridJsonWWJSDByCreate(string ODNCode, string Sequence, string WorkPoint)
  1989. {
  1990. DataTable dt = new DataTable();
  1991. object Figure = GetDecimalDigits();
  1992. List<DbParameter> parameter = new List<DbParameter>();
  1993. string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  1994. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  1995. from ICSODeliveryNotice a
  1996. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  1997. left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  1998. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  1999. group by b.TransCode,b.TransSequence
  2000. ) c on a.ODNCode=c.TransCode and a.Sequence=c.TransSequence
  2001. WHERE a.ODNType='3'
  2002. and a.ODNCode='" + ODNCode + "' and a.Sequence='" + Sequence + "'";
  2003. sql += " and a.WorkPoint='" + WorkPoint + "'";
  2004. sql = string.Format(sql, Figure);
  2005. return Repository().FindTableBySql(sql.ToString());
  2006. }
  2007. public DataTable GetSubGridJsonLLSQDByCreate(string ApplyNegCode, string Sequence, string WorkPoint)
  2008. {
  2009. DataTable dt = new DataTable();
  2010. object Figure = GetDecimalDigits();
  2011. List<DbParameter> parameter = new List<DbParameter>();
  2012. string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  2013. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  2014. from ICSMOApplyNegDetail a
  2015. left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
  2016. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2017. left join (
  2018. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  2019. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  2020. group by b.TransCode,b.TransSequence
  2021. ) c on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
  2022. WHERE d.Type='2'
  2023. and a.ApplyNegCode='" + ApplyNegCode + "' and a.Sequence='" + Sequence + "'";
  2024. sql += " and a.WorkPoint='" + WorkPoint + "'";
  2025. sql = string.Format(sql, Figure);
  2026. return Repository().FindTableBySql(sql.ToString());
  2027. }
  2028. //材料出库退料
  2029. public DataTable GetGridJsonCLCK(string queryJson, ref Pagination jqgridparam)
  2030. {
  2031. DataTable dt = new DataTable();
  2032. var queryParam = queryJson.ToJObject();
  2033. List<DbParameter> parameter = new List<DbParameter>();
  2034. object Figure = GetDecimalDigits();
  2035. #region [SQL]
  2036. string sql = @"
  2037. select a.ID,a.ApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,
  2038. CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity,
  2039. CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.IssueNegQuantity AS DECIMAL(18,{0})) as IssueNegQuantity ,a.ExtensionID,a.MUSERName,a.MTIME ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  2040. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  2041. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  2042. from ICSMOApplyNegDetail a
  2043. left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
  2044. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2045. left join (
  2046. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  2047. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='13'
  2048. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  2049. )c
  2050. on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  2051. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  2052. WHERE d.Type='3'";
  2053. sql = string.Format(sql, Figure);
  2054. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  2055. #endregion
  2056. if (!string.IsNullOrWhiteSpace(queryJson))
  2057. {
  2058. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  2059. {
  2060. sql += " and a.ApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
  2061. }
  2062. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  2063. {
  2064. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  2065. }
  2066. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  2067. {
  2068. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  2069. }
  2070. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  2071. {
  2072. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  2073. }
  2074. }
  2075. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  2076. {
  2077. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  2078. }
  2079. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  2080. {
  2081. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  2082. }
  2083. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2084. }
  2085. //材料出库退料
  2086. public DataTable GetSubGridJsonCLCKByCreate(string ApplyNegCode, string Sequence, string WorkPoint)
  2087. {
  2088. DataTable dt = new DataTable();
  2089. object Figure = GetDecimalDigits();
  2090. List<DbParameter> parameter = new List<DbParameter>();
  2091. string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  2092. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  2093. from ICSMOApplyNegDetail a
  2094. left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
  2095. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2096. left join (
  2097. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  2098. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  2099. group by b.TransCode,b.TransSequence
  2100. ) c on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
  2101. WHERE d.Type='3'
  2102. and a.ApplyNegCode='" + ApplyNegCode + "' and a.Sequence='" + Sequence + "'";
  2103. sql += " and a.WorkPoint='" + WorkPoint + "'";
  2104. sql = string.Format(sql, Figure);
  2105. return Repository().FindTableBySql(sql.ToString());
  2106. }
  2107. //材料出库退料生成条码
  2108. public int SubmitFormCLCKT(string ApplyNegCode, string Sequence, string keyValue, string WorkPoint)
  2109. {
  2110. var queryParam = keyValue.ToJObject();
  2111. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  2112. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  2113. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  2114. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  2115. decimal LOTQTY = minPackQty;
  2116. string Pre = "MD" + ApplyNegCode + Sequence;
  2117. string sql = string.Empty;
  2118. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2119. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2120. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  2121. string sqls = string.Empty;
  2122. string Colspan = "";
  2123. for (int i = 0; i < createPageCount; i++)
  2124. {
  2125. if (i + 1 == createPageCount)
  2126. {
  2127. if (minPackQty * createPageCount > thisCreateQty)
  2128. {
  2129. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  2130. }
  2131. }
  2132. Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
  2133. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  2134. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  2135. if (ExtensionID == null)
  2136. {
  2137. ExtensionID = Guid.NewGuid();
  2138. sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  2139. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  2140. ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
  2141. MUSER, MUSERNAME, WorkPoints);
  2142. }
  2143. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  2144. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  2145. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  2146. LotNo, ApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  2147. sql += string.Format(@"insert into ICSInventoryLot
  2148. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  2149. select
  2150. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','13','{3}','{4}', getdate(),'{5}','{9}'
  2151. from ICSMOApplyNegDetail where ApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  2152. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ApplyNegCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  2153. sql += "\r\n";
  2154. }
  2155. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  2156. return count;
  2157. }
  2158. public DataTable GetGridJsonWWLLTL(string queryJson, ref Pagination jqgridparam)
  2159. {
  2160. DataTable dt = new DataTable();
  2161. var queryParam = queryJson.ToJObject();
  2162. List<DbParameter> parameter = new List<DbParameter>();
  2163. object Figure = GetDecimalDigits();
  2164. #region [SQL]
  2165. string sql = @"select a.ID,a.OApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,
  2166. CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.IssueNegQuantity AS DECIMAL(18,{0})) as IssueNegQuantity ,a.ExtensionID,a.MUSERName,a.MTIME ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  2167. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  2168. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  2169. from ICSOApplyNegDetail a
  2170. left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
  2171. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2172. left join (
  2173. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  2174. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='14'
  2175. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  2176. )c
  2177. on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  2178. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  2179. WHERE d.Type='2'";
  2180. sql = string.Format(sql, Figure);
  2181. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  2182. #endregion
  2183. if (!string.IsNullOrWhiteSpace(queryJson))
  2184. {
  2185. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  2186. {
  2187. sql += " and a.OApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
  2188. }
  2189. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  2190. {
  2191. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  2192. }
  2193. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  2194. {
  2195. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  2196. }
  2197. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  2198. {
  2199. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  2200. }
  2201. }
  2202. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  2203. {
  2204. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  2205. }
  2206. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  2207. {
  2208. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  2209. }
  2210. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2211. }
  2212. /// <summary>
  2213. /// 点击委外领料退料生成条码
  2214. /// </summary>
  2215. public DataTable GetSubGridJsonWWLLByCreate(string OApplyNegCode, string Sequence, string WorkPoint)
  2216. {
  2217. DataTable dt = new DataTable();
  2218. object Figure = GetDecimalDigits();
  2219. List<DbParameter> parameter = new List<DbParameter>();
  2220. string sql = @"
  2221. select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  2222. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  2223. from ICSOApplyNegDetail a
  2224. left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
  2225. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2226. left join (
  2227. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  2228. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  2229. group by b.TransCode,b.TransSequence
  2230. ) c on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
  2231. WHERE d.Type='2'
  2232. and a.OApplyNegCode='" + OApplyNegCode + "' and a.Sequence='" + Sequence + "'";
  2233. sql += " and a.WorkPoint='" + WorkPoint + "'";
  2234. sql = string.Format(sql, Figure);
  2235. return Repository().FindTableBySql(sql.ToString());
  2236. }
  2237. //委外领料申请退料
  2238. public int SubmitFormWWLL(string OApplyNegCode, string Sequence, string keyValue, string WorkPoint)
  2239. {
  2240. var queryParam = keyValue.ToJObject();
  2241. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  2242. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  2243. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  2244. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  2245. decimal LOTQTY = minPackQty;
  2246. string Pre = "OMA" + OApplyNegCode + Sequence;
  2247. string sql = string.Empty;
  2248. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2249. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2250. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  2251. string sqls = string.Empty;
  2252. string Colspan = "";
  2253. for (int i = 0; i < createPageCount; i++)
  2254. {
  2255. if (i + 1 == createPageCount)
  2256. {
  2257. if (minPackQty * createPageCount > thisCreateQty)
  2258. {
  2259. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  2260. }
  2261. }
  2262. Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
  2263. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  2264. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  2265. if (ExtensionID == null)
  2266. {
  2267. ExtensionID = Guid.NewGuid();
  2268. sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  2269. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  2270. ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
  2271. MUSER, MUSERNAME, WorkPoints);
  2272. }
  2273. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  2274. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  2275. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  2276. LotNo, OApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  2277. sql += string.Format(@"insert into ICSInventoryLot
  2278. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  2279. select
  2280. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','14','{3}','{4}', getdate(),'{5}','{9}'
  2281. from ICSOApplyNegDetail where OApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  2282. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, OApplyNegCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  2283. sql += "\r\n";
  2284. }
  2285. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  2286. return count;
  2287. }
  2288. //委外材料出库
  2289. public DataTable GetGridJsonWWCLCK(string queryJson, ref Pagination jqgridparam)
  2290. {
  2291. DataTable dt = new DataTable();
  2292. var queryParam = queryJson.ToJObject();
  2293. List<DbParameter> parameter = new List<DbParameter>();
  2294. object Figure = GetDecimalDigits();
  2295. #region [SQL]
  2296. string sql = @"select a.ID,a.OApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,
  2297. CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.IssueNegQuantity AS DECIMAL(18,{0})) as IssueNegQuantity ,a.ExtensionID,a.MUSERName,a.MTIME ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  2298. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  2299. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  2300. from ICSOApplyNegDetail a
  2301. left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
  2302. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2303. left join (
  2304. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  2305. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='15'
  2306. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  2307. )c
  2308. on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  2309. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  2310. WHERE d.Type='3'";
  2311. sql = string.Format(sql, Figure);
  2312. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  2313. #endregion
  2314. if (!string.IsNullOrWhiteSpace(queryJson))
  2315. {
  2316. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  2317. {
  2318. sql += " and a.OApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
  2319. }
  2320. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  2321. {
  2322. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  2323. }
  2324. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  2325. {
  2326. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  2327. }
  2328. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  2329. {
  2330. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  2331. }
  2332. }
  2333. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  2334. {
  2335. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  2336. }
  2337. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  2338. {
  2339. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  2340. }
  2341. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2342. }
  2343. //委外材料出库
  2344. public DataTable GetSubGridJsonWWCLByCreate(string OApplyNegCode, string Sequence, string WorkPoint)
  2345. {
  2346. DataTable dt = new DataTable();
  2347. object Figure = GetDecimalDigits();
  2348. List<DbParameter> parameter = new List<DbParameter>();
  2349. string sql = @"
  2350. select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  2351. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  2352. from ICSOApplyNegDetail a
  2353. left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
  2354. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2355. left join (
  2356. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  2357. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  2358. group by b.TransCode,b.TransSequence
  2359. ) c on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
  2360. WHERE d.Type='3'
  2361. and a.OApplyNegCode='" + OApplyNegCode + "' and a.Sequence='" + Sequence + "'";
  2362. sql += " and a.WorkPoint='" + WorkPoint + "'";
  2363. sql = string.Format(sql, Figure);
  2364. return Repository().FindTableBySql(sql.ToString());
  2365. }
  2366. //委外材料出库
  2367. public int SubmitFormWWCL(string OApplyNegCode, string Sequence, string keyValue, string WorkPoint)
  2368. {
  2369. var queryParam = keyValue.ToJObject();
  2370. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  2371. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  2372. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  2373. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  2374. decimal LOTQTY = minPackQty;
  2375. //string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2376. //string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint);
  2377. string Pre = "OMD" + OApplyNegCode + Sequence;
  2378. string sql = string.Empty;
  2379. //string VendorLot = queryParam["VendorLot"].ToString();
  2380. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2381. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2382. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  2383. string sqls = string.Empty;
  2384. string Colspan = "";
  2385. for (int i = 0; i < createPageCount; i++)
  2386. {
  2387. if (i + 1 == createPageCount)
  2388. {
  2389. if (minPackQty * createPageCount > thisCreateQty)
  2390. {
  2391. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  2392. }
  2393. }
  2394. Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
  2395. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  2396. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  2397. if (ExtensionID == null)
  2398. {
  2399. ExtensionID = Guid.NewGuid();
  2400. sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  2401. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  2402. ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
  2403. MUSER, MUSERNAME, WorkPoints);
  2404. }
  2405. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  2406. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  2407. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  2408. LotNo, OApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  2409. //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  2410. //{
  2411. sql += string.Format(@"insert into ICSInventoryLot
  2412. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  2413. select
  2414. newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','15','{3}','{4}', getdate(),'{5}','{9}'
  2415. from ICSOApplyNegDetail where OApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
  2416. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, OApplyNegCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  2417. sql += "\r\n";
  2418. //}
  2419. }
  2420. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  2421. return count;
  2422. }
  2423. public DataTable SelectICSExtensionEnable(string BeginTime, string EndTime)
  2424. {
  2425. string sql = @"select ColCode from ICSExtensionEnable
  2426. where Enable=0
  2427. order by cast(EATTRIBUTE1 as int)";
  2428. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  2429. return dt;
  2430. }
  2431. //返工工单
  2432. public DataTable GetGridJsonFGGD(string queryJson, ref Pagination jqgridparam)
  2433. {
  2434. DataTable dt = new DataTable();
  2435. var queryParam = queryJson.ToJObject();
  2436. List<DbParameter> parameter = new List<DbParameter>();
  2437. object Figure = GetDecimalDigits();
  2438. #region [SQL]
  2439. string sql = @"select a.ID,d.MOCode,d.Sequence+'-'+ a.Sequence as Sequence,a.PickID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,
  2440. CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity
  2441. CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.IssueQuantity AS DECIMAL(18,{0})) as IssueQuantity ,a.ExtensionID,a.MUSERName,a.MTIME ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
  2442. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
  2443. ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  2444. from ICSMOPick a
  2445. left join ICSMO d on a.MODetailID=d.MODetailID and a.WorkPoint=d.WorkPoint
  2446. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2447. left join (
  2448. select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
  2449. left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='16'
  2450. group by mm.TransCode,mm.TransSequence,ee.WorkPoint
  2451. )c
  2452. on d.MOCode=c.TransCode and d.Sequence+'-'+a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
  2453. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  2454. where a.EATTRIBUTE1='1' and d.EATTRIBUTE1='1'";
  2455. sql = string.Format(sql, Figure);
  2456. sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
  2457. #endregion
  2458. if (!string.IsNullOrWhiteSpace(queryJson))
  2459. {
  2460. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  2461. {
  2462. sql += " and d.MOCode like '%" + queryParam["POCode"].ToString() + "%' ";
  2463. }
  2464. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  2465. {
  2466. sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  2467. }
  2468. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  2469. {
  2470. sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  2471. }
  2472. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  2473. {
  2474. sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  2475. }
  2476. }
  2477. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
  2478. {
  2479. sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
  2480. }
  2481. if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
  2482. {
  2483. sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
  2484. }
  2485. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2486. }
  2487. public DataTable GetSubGridJsonFGGDCreate(string FGGDMOCode, string Sequence, string WorkPoint)
  2488. {
  2489. DataTable dt = new DataTable();
  2490. object Figure = GetDecimalDigits();
  2491. List<DbParameter> parameter = new List<DbParameter>();
  2492. string sql = @"
  2493. select a.InvCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
  2494. CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
  2495. from ICSMOPick a
  2496. left join ICSMO d on a.MODetailID=d.MODetailID and a.WorkPoint=d.WorkPoint
  2497. left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
  2498. left join (
  2499. select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
  2500. left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
  2501. group by b.TransCode,b.TransSequence
  2502. ) c on d.MOCode=c.TransCode and d.Sequence+'-'+a.Sequence=c.TransSequence
  2503. WHERE 1=1
  2504. and d.MOCode='" + FGGDMOCode + "' and d.Sequence+'-'+a.Sequence='" + Sequence + "'";
  2505. sql += " and a.WorkPoint='" + WorkPoint + "'";
  2506. sql = string.Format(sql, Figure);
  2507. return Repository().FindTableBySql(sql.ToString());
  2508. }
  2509. //返工工单
  2510. public int SubmitFormFGGD(string FGGDMOCode, string Sequence, string keyValue, string WorkPoint)
  2511. {
  2512. var queryParam = keyValue.ToJObject();
  2513. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  2514. int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
  2515. decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
  2516. decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
  2517. decimal LOTQTY = minPackQty;
  2518. string Pre = "FG" + FGGDMOCode + Sequence;
  2519. string sql = string.Empty;
  2520. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2521. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2522. string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
  2523. string sqls = string.Empty;
  2524. string Colspan = "";
  2525. for (int i = 0; i < createPageCount; i++)
  2526. {
  2527. if (i + 1 == createPageCount)
  2528. {
  2529. if (minPackQty * createPageCount > thisCreateQty)
  2530. {
  2531. LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
  2532. }
  2533. }
  2534. Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
  2535. sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}'", Colspan);
  2536. object ExtensionID = SqlHelper.ExecuteScalar(sqls);
  2537. if (ExtensionID == null)
  2538. {
  2539. ExtensionID = Guid.NewGuid();
  2540. sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
  2541. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
  2542. ExtensionID, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
  2543. MUSER, MUSERNAME, WorkPoints);
  2544. }
  2545. string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
  2546. sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  2547. Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
  2548. LotNo, FGGDMOCode, Sequence, MUSER, MUSERNAME, WorkPoints);
  2549. sql += string.Format(@"insert into ICSInventoryLot
  2550. (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
  2551. select
  2552. newid(),'{0}',a.InvCode,'{1}','{10}','{2}','{8}','16','{3}','{4}', getdate(),'{5}','{9}'
  2553. from ICSMOPick a left join ICSMO d on a.MODetailID=d.MODetailID and a.WorkPoint=d.WorkPoint where d.MOCode='{6}' and d.Sequence+'-'+a.Sequence='{7}' and a.WorkPoint='{5}' ",
  2554. LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, FGGDMOCode, Sequence, ExtensionID, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString());
  2555. sql += "\r\n";
  2556. }
  2557. int count = SqlHelper.CmdExecuteNonQueryLi(sql);
  2558. return count;
  2559. }
  2560. //单据上传货柜
  2561. public string DocUpLoadToHG(string DocNoList,string Type, string WorkPoint)
  2562. {
  2563. string postUrlStr = System.Configuration.ConfigurationManager.AppSettings["HGDocpostUrlStr"].ToString();
  2564. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  2565. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  2566. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  2567. string DocNoInfo = DocNoList.TrimEnd(',');
  2568. string InspectJosn = "";
  2569. #region 检验合格单
  2570. if (Type == "7")
  2571. {
  2572. InspectJosn += "{";
  2573. InspectJosn += "\"IMP_ORDINI\":[";
  2574. foreach (string DocNO in DocNoInfo.Split(','))
  2575. {
  2576. InspectJosn += "{";
  2577. InspectJosn += "\"ORD_ORDINE\":\"" + DocNO + "\",";
  2578. InspectJosn += "\"ORD_DES\":\"采购入库-采购到货单\",";
  2579. InspectJosn += "\"ORD_TIPOOP\":\"V\",";
  2580. InspectJosn += "\"ORD_CLIENTE\":\"" + WorkPoint + "\"";
  2581. InspectJosn += "},";
  2582. }
  2583. InspectJosn = InspectJosn.TrimEnd(',');
  2584. InspectJosn += "],";
  2585. InspectJosn += "\"IMP_ORDINI_RIGHE\":[";
  2586. foreach (string DocNO in DocNoInfo.Split(','))
  2587. {
  2588. string sql = @" select A.DNCode,A.Sequence,A.InvCode,A.Quantity,B.LocationCode AS Area from ICSDeliveryNotice A
  2589. INNER JOIN ICSInventoryDetail B ON B.WHCode=A.WHCode AND B.INVCode=A.InvCode AND B.WorkPoint=A.WorkPoint
  2590. where A.DNCode='{0}' and A.WorkPoint='{1}'";
  2591. sql = string.Format(sql, DocNO, WorkPoint);
  2592. DataTable dt = Repository().FindTableBySql(sql.ToString());
  2593. for (int i = 0; i < dt.Rows.Count; i++)
  2594. {
  2595. //RIG_ELERUOLI_GEST-区域-出入库都要
  2596. //RIG_ELEBAIE-机器出口-出库-出库才要
  2597. InspectJosn += "{";
  2598. InspectJosn += "\"RIG_ORDINE\":\"" + DocNO + "\",";
  2599. InspectJosn += "\"RIG_ARTICOLO\": \"" + dt.Rows[i]["InvCode"].ToString() + "\",";
  2600. InspectJosn += "\"RIG_SUB1\": \"\",";
  2601. InspectJosn += "\"RIG_SUB2\": \"\",";
  2602. InspectJosn += "\"RIG_ELERUOLI_GEST\": \"" + dt.Rows[i]["Area"].ToString() + "\",";
  2603. InspectJosn += "\"RIG_QTAR\": " + dt.Rows[i]["Quantity"].ToString() + ",";
  2604. InspectJosn += "\"RIG_HOSTINF\": " + dt.Rows[i]["Sequence"].ToString() + "";
  2605. InspectJosn += "},";
  2606. }
  2607. }
  2608. InspectJosn = InspectJosn.TrimEnd(',');
  2609. InspectJosn += "]";
  2610. InspectJosn += "}";
  2611. }
  2612. #endregion
  2613. #region 机加工成品入库单
  2614. if (Type == "9")
  2615. {
  2616. InspectJosn += "{";
  2617. InspectJosn += "\"IMP_ORDINI\":[";
  2618. foreach (string DocNO in DocNoInfo.Split(','))
  2619. {
  2620. InspectJosn += "{";
  2621. InspectJosn += "\"ORD_ORDINE\":\"" + DocNO + "\",";
  2622. InspectJosn += "\"ORD_DES\":\"产成品入库-产成品入库单\",";
  2623. InspectJosn += "\"ORD_TIPOOP\":\"V\",";
  2624. InspectJosn += "\"ORD_CLIENTE\":\"" + WorkPoint + "\"";
  2625. InspectJosn += "},";
  2626. }
  2627. InspectJosn = InspectJosn.TrimEnd(',');
  2628. InspectJosn += "],";
  2629. InspectJosn += "\"IMP_ORDINI_RIGHE\":[";
  2630. foreach (string DocNO in DocNoInfo.Split(','))
  2631. {
  2632. string sql = @" select A.RCVCode,A.Sequence,A.InvCode,A.Quantity,B.LocationCode AS Area from ICSManufactureReceive A
  2633. INNER JOIN ICSInventoryDetail B ON B.WHCode=A.WHCode AND B.INVCode=A.InvCode AND B.WorkPoint=A.WorkPoint
  2634. where A.RCVCode='{0}' and A.WorkPoint='{1}'";
  2635. sql = string.Format(sql, DocNO, WorkPoint);
  2636. DataTable dt = Repository().FindTableBySql(sql.ToString());
  2637. for (int i = 0; i < dt.Rows.Count; i++)
  2638. {
  2639. //RIG_ELERUOLI_GEST-区域-出入库都要
  2640. //RIG_ELEBAIE-机器出口-出库-出库才要
  2641. InspectJosn += "{";
  2642. InspectJosn += "\"RIG_ORDINE\":\"" + DocNO + "\",";
  2643. InspectJosn += "\"RIG_ARTICOLO\": \"" + dt.Rows[i]["InvCode"].ToString() + "\",";
  2644. InspectJosn += "\"RIG_SUB1\": \"\",";
  2645. InspectJosn += "\"RIG_SUB2\": \"\",";
  2646. InspectJosn += "\"RIG_ELERUOLI_GEST\": \"" + dt.Rows[i]["Area"].ToString() + "\",";
  2647. InspectJosn += "\"RIG_QTAR\": " + dt.Rows[i]["Quantity"].ToString() + ",";
  2648. InspectJosn += "\"RIG_HOSTINF\": " + dt.Rows[i]["Sequence"].ToString() + "";
  2649. InspectJosn += "},";
  2650. }
  2651. }
  2652. InspectJosn = InspectJosn.TrimEnd(',');
  2653. InspectJosn += "]";
  2654. InspectJosn += "}";
  2655. }
  2656. #endregion
  2657. #region 生产退料单
  2658. if (Type == "12")
  2659. {
  2660. InspectJosn += "{";
  2661. InspectJosn += "\"IMP_ORDINI\":[";
  2662. foreach (string DocNO in DocNoInfo.Split(','))
  2663. {
  2664. InspectJosn += "{";
  2665. InspectJosn += "\"ORD_ORDINE\":\"" + DocNO + "\",";
  2666. InspectJosn += "\"ORD_DES\":\"生产退料-生产退料单-领料申请单\",";
  2667. InspectJosn += "\"ORD_TIPOOP\":\"V\",";
  2668. InspectJosn += "\"ORD_CLIENTE\":\"" + WorkPoint + "\"";
  2669. InspectJosn += "},";
  2670. }
  2671. InspectJosn = InspectJosn.TrimEnd(',');
  2672. InspectJosn += "],";
  2673. InspectJosn += "\"IMP_ORDINI_RIGHE\":[";
  2674. foreach (string DocNO in DocNoInfo.Split(','))
  2675. {
  2676. string sql = @" select A.ApplyNegCode,B.Sequence,B.InvCode,B.Quantity,C.LocationCode AS Area from ICSMOApplyNeg A
  2677. INNER JOIN ICSMOApplyNegDetail B ON B.ApplyNegCode=A.ApplyNegCode AND B.WorkPoint=A.WorkPoint
  2678. INNER JOIN ICSInventoryDetail C ON C.WHCode=B.WHCode AND C.INVCode=B.InvCode AND C.WorkPoint=B.WorkPoint
  2679. where A.ApplyNegCode='{0}' and A.WorkPoint='{1}'";
  2680. sql = string.Format(sql, DocNO, WorkPoint);
  2681. DataTable dt = Repository().FindTableBySql(sql.ToString());
  2682. for (int i = 0; i < dt.Rows.Count; i++)
  2683. {
  2684. //RIG_ELERUOLI_GEST-区域-出入库都要
  2685. //RIG_ELEBAIE-机器出口-出库-出库才要
  2686. InspectJosn += "{";
  2687. InspectJosn += "\"RIG_ORDINE\":\"" + DocNO + "\",";
  2688. InspectJosn += "\"RIG_ARTICOLO\": \"" + dt.Rows[i]["InvCode"].ToString() + "\",";
  2689. InspectJosn += "\"RIG_SUB1\": \"\",";
  2690. InspectJosn += "\"RIG_SUB2\": \"\",";
  2691. InspectJosn += "\"RIG_ELERUOLI_GEST\": \"" + dt.Rows[i]["Area"].ToString() + "\",";
  2692. InspectJosn += "\"RIG_QTAR\": " + dt.Rows[i]["Quantity"].ToString() + ",";
  2693. InspectJosn += "\"RIG_HOSTINF\": " + dt.Rows[i]["Sequence"].ToString() + "";
  2694. InspectJosn += "},";
  2695. }
  2696. }
  2697. InspectJosn = InspectJosn.TrimEnd(',');
  2698. InspectJosn += "]";
  2699. InspectJosn += "}";
  2700. }
  2701. #endregion
  2702. string result = "";
  2703. if (Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["UploadERP"]))
  2704. {
  2705. #region 货柜接口调用前日志
  2706. object logID = Guid.NewGuid();
  2707. string logsql = @"insert into ICSWMS_HGLog
  2708. values
  2709. ('{0}',GETDATE(),'{1}','{2}','{3}','{4}','{5}')";
  2710. logsql = string.Format(logsql, logID, InspectJosn, "", WorkPoint, MUSER, MUSERNAME);
  2711. SqlHelper.CmdExecuteNonQueryLi(logsql);
  2712. #endregion
  2713. result = HTTPHelper.RestFulGet(InspectJosn, postUrlStr);
  2714. #region 货柜接口调用后日志
  2715. logsql = @"update ICSWMS_HGLog set ReturnResult='{0}'
  2716. where ID='{1}'";
  2717. logsql = string.Format(logsql, result, logID);
  2718. SqlHelper.CmdExecuteNonQueryLi(logsql);
  2719. #endregion
  2720. if (!result.Contains("successo"))
  2721. {
  2722. ICSHGResult hgresult = JsonConvert.DeserializeObject<ICSHGResult>(result.TrimStart('[').TrimEnd(']'));
  2723. throw new Exception("货柜单据传输接口调用报错,主要报错信息:" + hgresult.PrimaryError + ",次要报错信息:" + hgresult.SecondaryError + "");
  2724. }
  2725. }
  2726. return "";
  2727. }
  2728. public object GetDecimalDigits()
  2729. {
  2730. try
  2731. {
  2732. string sql = string.Empty;
  2733. sql = @"select Figure from ICSConfiguration where Code='Figure001' and Enable='1'";
  2734. object Figure = SqlHelper.ExecuteScalar(sql);
  2735. return Figure;
  2736. }
  2737. catch (Exception ex)
  2738. {
  2739. throw new Exception(ex.Message.ToString());
  2740. }
  2741. }
  2742. public object GetQiSetNum(string keyValue)
  2743. {
  2744. int Num = 0;
  2745. string msg = "";
  2746. string APIURL = ConfigurationManager.ConnectionStrings["ERPAPIURL"].ConnectionString + "Complete/Approve";
  2747. string result = HttpPost(APIURL, keyValue);
  2748. JObject Obj = (JObject)JsonConvert.DeserializeObject(result);//或者JObject jo = JObject.Parse(jsonText);
  2749. string MessAge = Obj["Message"].ToString();
  2750. string Success = Obj["Success"].ToString();
  2751. if (Success.ToUpper() == "FALSE")
  2752. {
  2753. msg = MessAge;
  2754. }
  2755. if (msg == "")
  2756. {
  2757. JArray res = (JArray)JsonConvert.DeserializeObject(Obj["Data"].ToString());
  2758. foreach (var item in res)
  2759. {
  2760. JObject jo = (JObject)item;
  2761. Num = Convert.ToInt32(jo["min_lotqty"].ToString());
  2762. }
  2763. }
  2764. var Header = new
  2765. {
  2766. msg = msg,
  2767. Num = Num,
  2768. };
  2769. return Header;
  2770. }
  2771. //接口api解析
  2772. public static string HttpPost(string url, string body)
  2773. {
  2774. try
  2775. {
  2776. Encoding encoding = Encoding.UTF8;
  2777. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
  2778. request.Method = "POST";
  2779. request.Accept = "application/json, text/javascript, */*"; //"text/html, application/xhtml+xml, */*";
  2780. request.ContentType = "application/json; charset=utf-8";
  2781. byte[] buffer = encoding.GetBytes(body);
  2782. request.ContentLength = buffer.Length;
  2783. request.GetRequestStream().Write(buffer, 0, buffer.Length);
  2784. HttpWebResponse response = (HttpWebResponse)request.GetResponse();
  2785. using (StreamReader reader = new StreamReader(response.GetResponseStream(), encoding))
  2786. {
  2787. return reader.ReadToEnd();
  2788. }
  2789. }
  2790. catch (WebException ex)
  2791. {
  2792. throw new Exception(ex.Message);
  2793. }
  2794. }
  2795. }
  2796. }