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.

1606 lines
97 KiB

  1. using NFine.Data.Extensions;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using NFine.Code;
  9. using NFine.Repository;
  10. using System.Data.Common;
  11. using NFine.Domain._03_Entity.SRM;
  12. using ICS.Application.Entity;
  13. using Newtonsoft.Json;
  14. using System.Configuration;
  15. using System.Data.SqlClient;
  16. using ICS.Data;
  17. using Newtonsoft.Json.Linq;
  18. using NFine.Domain._03_Entity.WMS;
  19. using System.Net;
  20. using System.IO;
  21. namespace NFine.Application.WMS
  22. {
  23. public class ICSRCVIQCsApp : RepositoryFactory<ICSVendor>
  24. {
  25. /// <summary>
  26. /// 采购
  27. /// </summary>
  28. /// <param name="jqgridparam"></param>
  29. /// <returns></returns>
  30. public DataTable GetICSInspection(ref Pagination jqgridparam, string queryJson)
  31. {
  32. string ERPSign = Configs.GetValue("ERPSign");
  33. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  34. DataTable dt = new DataTable();
  35. var queryParam = queryJson.ToJObject();
  36. List<DbParameter> parameter = new List<DbParameter>();
  37. string sql = string.Empty;
  38. if (ERPSign=="U8")
  39. {
  40. sql = @" select DISTINCT
  41. a.ID as DHID,
  42. d.ID ,
  43. h.ID as JYID,
  44. a.DNCode ,
  45. a.Sequence ,
  46. a.ASNCode ,
  47. l.POCode,
  48. c.InvCode ,
  49. c.InvName ,
  50. c.INVSTD ,
  51. c.ClassName,
  52. CAST(b.DNQuantity as decimal(18,4)) as AllNumber,
  53. CAST(ISNULL(h.QualifiedQuantity, b.DNQuantity)as decimal(18,4))as YLOTQTY ,
  54. CAST(ISNULL(h.UnqualifiedQuantity, 0) as decimal(18,4)) as NLOTQTY,
  55. CAST(ISNULL(h.WaiveQuantity, 0) as decimal(18,4)) as SpecialQTY,
  56. CAST(ISNULL(h.SampleQuantity, 0) as decimal(18,4)) as SampleQuantity,
  57. c.InvUnit ,
  58. b.LotNo ,
  59. g.BadReasonDesc as BadReasonDesc ,
  60. g.BadReasonCode as BRCodeValue,
  61. j.BadCode as BCCodeValue,
  62. j.BadDesc as BadDesc,
  63. k.ContainerID,
  64. isnull(h.MUSERName,'') MUSERName,
  65. CONVERT(VARCHAR(100),d.ProductDate,23) as ProductTime,
  66. CONVERT(VARCHAR(100),a.CreateDateTime,23) as CreateDateTime,
  67. CONVERT(VARCHAR(100),h.MTIME,23) as MTIME,
  68. CASE WHEN isnull(h.ID,'') =''THEN '' ELSE '' END AS TestState,
  69. a.VenCode,
  70. m.VenName,
  71. isnull(h.MUSER,'') as Surveyor,
  72. h.MUSERName as ProvingTime
  73. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4 ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  74. ,CASE WHEN h.Result='0' THEN '' when ISNULL(h.Result,'')='' THEN '' ELSE '' END AS Result,
  75. n.FileName
  76. FROM ICSDeliveryNotice a
  77. inner JOIN ICSASNDetail b ON a.ASNCode=b.ASNCode AND a.WorkPoint=b.WorkPoint
  78. inner JOIN ICSInventory c ON a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint --and c.InvIQC='1'
  79. inner JOIN ICSInventoryLot d ON b.LotNo=d.LotNo AND a.InvCode=d.InvCode AND b.WorkPoint=d.WorkPoint
  80. left join ICSInventoryLotDetail e on d.LotNo=e.LotNo and d.WorkPoint=e.WorkPoint
  81. LEFT JOIN dbo.ICSInspection h ON h.LotNo=b.LotNo AND h.WorkPoint=b.WorkPoint --and Enable='1'
  82. left join ICSBadReason g on h.BRCode =g.BadReasonCode and h.WorkPoint=g.WorkPoint
  83. left join ICSBadCode j on h.BCCode =j.BadCode and h.WorkPoint=j.WorkPoint
  84. LEFT JOIN ICSContainerLot k ON b.LotNo=k.LotNo AND b.WorkPoint=k.WorkPoint
  85. inner JOIN ICSPurchaseOrder l ON e.TransCode =l.POCode AND e.TransSequence=l.Sequence AND a.PODetailID=l.PODetailID AND d.WorkPoint=l.WorkPoint
  86. left join ICSExtension f on l.ExtensionID=f.ID and l.WorkPoint=f.WorkPoint
  87. left join dbo.ICSVendor m on a.VenCode=m.VenCode and a.WorkPoint=m.WorkPoint
  88. left join ICSInspectionFile n on h.id=n.InspectionID and h.WorkPoint=n.WorkPoint
  89. where b.LotNo is not null and a.DNType='1' {0}
  90. ";
  91. }
  92. else
  93. {
  94. sql = @" select DISTINCT
  95. a.ID as DHID,
  96. d.ID ,
  97. h.ID as JYID,
  98. a.DNCode ,
  99. a.Sequence ,
  100. a.ASNCode ,
  101. l.POCode,
  102. c.InvCode ,
  103. c.InvName ,
  104. c.INVSTD ,
  105. c.ClassName,
  106. CAST(d.Quantity as decimal(18,4)) as AllNumber,
  107. CAST(ISNULL(h.QualifiedQuantity, d.Quantity)as decimal(18,4))as YLOTQTY ,
  108. CAST(ISNULL(h.UnqualifiedQuantity, 0) as decimal(18,4)) as NLOTQTY,
  109. CAST(ISNULL(h.WaiveQuantity, 0) as decimal(18,4)) as SpecialQTY,
  110. CAST(ISNULL(h.SampleQuantity, 0) as decimal(18,4)) as SampleQuantity,
  111. c.InvUnit ,
  112. d.LotNo ,
  113. g.BadReasonDesc as BadReasonDesc ,
  114. g.BadReasonCode as BRCodeValue,
  115. j.BadCode as BCCodeValue,
  116. j.BadDesc as BadDesc,
  117. k.ContainerID,
  118. isnull(h.MUSERName,'') MUSERName,
  119. CONVERT(VARCHAR(100),d.ProductDate,23) as ProductTime,
  120. CONVERT(VARCHAR(100),a.CreateDateTime,23) as CreateDateTime,
  121. CONVERT(VARCHAR(100),h.MTIME,23) as MTIME,
  122. CASE WHEN isnull(h.ID,'') =''THEN '' ELSE '' END AS TestState,
  123. a.VenCode,
  124. m.VenName,
  125. isnull(h.MUSER,'') as Surveyor,
  126. h.MUSERName as ProvingTime
  127. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4 ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  128. ,CASE WHEN h.Result='0' THEN '' when ISNULL(h.Result,'')='' THEN '' ELSE '' END AS Result,
  129. n.FileName
  130. FROM ICSDeliveryNotice a
  131. --inner JOIN ICSASNDetail b ON a.ASNCode=b.ASNCode AND a.WorkPoint=b.WorkPoint
  132. left join ICSInventoryLotDetail e on a.DNCode=e.TransCode and a.Sequence=e.TransSequence and a.WorkPoint=e.WorkPoint
  133. inner JOIN ICSInventory c ON a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint and c.InvIQC='1'
  134. inner JOIN ICSInventoryLot d ON e.LotNo=d.LotNo AND a.InvCode=d.InvCode AND a.WorkPoint=d.WorkPoint
  135. LEFT JOIN dbo.ICSInspection h ON h.LotNo=d.LotNo AND h.WorkPoint=a.WorkPoint and Enable='1'
  136. left join ICSBadReason g on h.BRCode =g.BadReasonCode and h.WorkPoint=g.WorkPoint
  137. left join ICSBadCode j on h.BCCode =j.BadCode and h.WorkPoint=j.WorkPoint
  138. LEFT JOIN ICSContainerLot k ON d.LotNo=k.LotNo AND a.WorkPoint=k.WorkPoint
  139. inner JOIN ICSPurchaseOrder l ON a.PODetailID=l.PODetailID AND a.WorkPoint=l.WorkPoint
  140. left join ICSExtension f on l.ExtensionID=f.ID and l.WorkPoint=f.WorkPoint
  141. left join dbo.ICSVendor m on a.VenCode=m.VenCode and a.WorkPoint=m.WorkPoint
  142. left join ICSInspectionFile n on h.id=n.InspectionID and h.WorkPoint=n.WorkPoint
  143. where d.LotNo is not null and a.DNType='1' AND a.WorkPoint='{1}' {0}
  144. ";
  145. }
  146. string wheresql = "";
  147. if (!string.IsNullOrWhiteSpace(queryJson))
  148. {
  149. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  150. {
  151. wheresql += " and a.DNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  152. }
  153. if (!string.IsNullOrWhiteSpace(queryParam["ASNCode"].ToString()))
  154. {
  155. wheresql += " and a.ASNCode like '%" + queryParam["ASNCode"].ToString() + "%' ";
  156. }
  157. if (!string.IsNullOrWhiteSpace(queryParam["CaiGouCode"].ToString()))
  158. {
  159. wheresql += " and l.POCode like '%" + queryParam["CaiGouCode"].ToString() + "%' ";
  160. }
  161. if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
  162. {
  163. wheresql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
  164. }
  165. if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
  166. {
  167. wheresql += " and m.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
  168. }
  169. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  170. {
  171. wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  172. }
  173. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  174. {
  175. wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  176. }
  177. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  178. {
  179. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  180. }
  181. if (!string.IsNullOrWhiteSpace(queryParam["TimeFrom"].ToString()))
  182. {
  183. wheresql += " and a.CreateDateTime >= '" + queryParam["TimeFrom"].ToString() + "' ";
  184. }
  185. if (!string.IsNullOrWhiteSpace(queryParam["TimeArrive"].ToString()))
  186. {
  187. wheresql += " and a.CreateDateTime <= '" + queryParam["TimeArrive"].ToString() + "' ";
  188. }
  189. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  190. {
  191. string ReleaseState = queryParam["ReleaseState"].ToString();
  192. if (ReleaseState == "1")
  193. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
  194. else if (ReleaseState == "0")
  195. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
  196. else
  197. wheresql += " ";
  198. }
  199. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  200. {
  201. string selEnableShow = queryParam["selEnableShow"].ToString();
  202. if (selEnableShow == "1")
  203. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
  204. else if (selEnableShow == "0")
  205. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
  206. }
  207. }
  208. sql = string.Format(sql, wheresql, WorkPoint);
  209. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  210. }
  211. public DataTable GetInspectionFile(ref Pagination jqgridparam, string queryJson,string JYID)
  212. {
  213. var queryParam = queryJson.ToJObject();
  214. List<DbParameter> parameter = new List<DbParameter>();
  215. string sql = @"SELECT * FROM dbo.ICSInspectionFile WHERE InspectionID='{0}'";
  216. sql = string.Format(sql, JYID);
  217. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  218. }
  219. //委外
  220. public DataTable GetICSInspection2(ref Pagination jqgridparam, string queryJson)
  221. {
  222. DataTable dt = new DataTable();
  223. var queryParam = queryJson.ToJObject();
  224. List<DbParameter> parameter = new List<DbParameter>();
  225. string sql = @"select DISTINCT a.ID as DHID, d.ID ,h.ID as JYID, a.ODNCode as DNCode ,a.Sequence ,a.OASNCode ,l.OOCode,c.InvCode , c.InvName , c.INVSTD , c.ClassName,
  226. f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4 ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,
  227. CAST(b.ODNQuantity as NUMERIC(10,4)) as AllNumber,
  228. CAST(ISNULL(h.QualifiedQuantity, b.ODNQuantity)as NUMERIC(10,4))as YLOTQTY ,
  229. CAST(ISNULL(h.UnqualifiedQuantity, 0) as NUMERIC(10,4)) as NLOTQTY,
  230. CAST(ISNULL(h.WaiveQuantity, 0) as NUMERIC(10,4)) as SpecialQTY,
  231. CAST(ISNULL(h.SampleQuantity, 0) as NUMERIC(10,4)) as SampleQuantity,
  232. c.InvUnit , b.LotNo , g.BadReasonDesc as BadReasonDesc ,g.BadReasonCode as BRCodeValue,j.BadCode as BCCodeValue, j.BadDesc as BadDesc,
  233. k.ContainerID,isnull(h.MUSERName,'') MUSERName, CONVERT(VARCHAR(100),d.ProductDate,23) as ProductTime,
  234. CONVERT(VARCHAR(100),a.CreateDateTime,23) as CreateDateTime,CONVERT(VARCHAR(100),h.MTIME,23) as MTIME,
  235. CASE WHEN isnull(h.ID,'') =''THEN '' ELSE '' END AS TestState,a.VenCode,m.VenName,
  236. isnull(h.MUSER,'') as Surveyor, h.MUSERName as ProvingTime
  237. ,CASE WHEN h.Result='0' THEN '' when ISNULL(h.Result,'')='' THEN '' ELSE '' END AS Result,
  238. n.FileName,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  239. a.EATTRIBUTE9,a.EATTRIBUTE10
  240. FROM ICSODeliveryNotice a
  241. LEFT JOIN ICSOASNDetail b ON a.OASNCode=b.OASNCode AND a.WorkPoint=b.WorkPoint
  242. inner JOIN ICSInventory c ON a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint and c.InvIQC='1'
  243. inner JOIN ICSInventoryLot d ON b.LotNo=d.LotNo AND a.InvCode=d.InvCode AND b.WorkPoint=d.WorkPoint
  244. left join ICSInventoryLotDetail e on d.LotNo=e.LotNo and d.WorkPoint=e.WorkPoint
  245. LEFT JOIN dbo.ICSInspection h ON h.LotNo=b.LotNo AND h.WorkPoint=b.WorkPoint and Enable='1'
  246. left join ICSBadReason g on h.BRCode =g.BadReasonCode and h.WorkPoint=g.WorkPoint
  247. left join ICSBadCode j on h.BCCode =j.BadCode and h.WorkPoint=j.WorkPoint
  248. LEFT JOIN ICSContainerLot k ON b.LotNo=k.LotNo AND b.WorkPoint=k.WorkPoint
  249. inner JOIN ICSOutsourcingOrder l ON e.TransCode =l.OOCode AND e.TransSequence=l.Sequence AND a.OODetailID=l.OODetailID AND d.WorkPoint=l.WorkPoint
  250. left join ICSExtension f on l.ExtensionID=f.ID and l.WorkPoint=f.WorkPoint
  251. left join dbo.ICSVendor m on a.VenCode=m.VenCode and a.WorkPoint=m.WorkPoint
  252. left join ICSInspectionFile n on h.id=n.InspectionID and h.WorkPoint=n.WorkPoint
  253. where b.LotNo is not null and ISNULL(CAST(b.ODNQuantity as VARCHAR), '')! ='' AND ISNULL(b.ODNQuantity, 0)<>0 {0}
  254. ";
  255. #region 无SRM逻辑
  256. // sql = @"UNION all
  257. //select
  258. // a.ID as DHID,
  259. // d.ID ,
  260. // h.ID as JYID,
  261. // a.ODNCode as DNCode ,
  262. // a.Sequence ,
  263. // a.OASNCode ,
  264. // c.InvCode ,
  265. // c.InvName ,
  266. // c.INVSTD ,
  267. // c.ClassName,
  268. // f.BatchCode ,
  269. // CAST(d.Quantity as NUMERIC(10,4)) as AllNumber,
  270. // CAST(ISNULL(h.QualifiedQuantity, d.Quantity)as NUMERIC(10,4))as YLOTQTY ,
  271. // CAST(ISNULL(h.UnqualifiedQuantity, 0) as NUMERIC(10,4)) as NLOTQTY,
  272. // CAST(ISNULL(h.WaiveQuantity, 0) as NUMERIC(10,4)) as SpecialQTY,
  273. // c.InvUnit ,
  274. // d.LotNo ,
  275. // g.BadReasonDesc as BadReasonDesc ,
  276. // g.BadReasonCode as BRCodeValue,
  277. // j.BadCode as BCCodeValue,
  278. // j.BadDesc as BadDesc,
  279. // k.ContainerID,
  280. // isnull(h.MUSERName,'开发者') MUSERName,
  281. // CONVERT(VARCHAR(100),d.ProductDate,23) as ProductTime,
  282. // CONVERT(VARCHAR(100),h.MTIME,23) as MTIME,
  283. // CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END AS TestState
  284. // FROM ICSODeliveryNotice a
  285. // inner join ICSInventoryLotDetail e on e.TransCode =a.ODNCode AND e.TransSequence=a.Sequence AND e.WorkPoint=a.WorkPoint
  286. // inner JOIN ICSInventoryLot d ON d.LotNo=e.LotNo and d.WorkPoint=e.WorkPoint
  287. // LEFT JOIN ICSInventory c ON a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint
  288. // LEFT JOIN dbo.ICSInspection h ON h.LotNo=d.LotNo AND h.WorkPoint=d.WorkPoint
  289. // left join ICSBadReason g on h.BRCode =g.BadReasonCode and h.WorkPoint=g.WorkPoint
  290. // left join ICSBadCode j on h.BCCode =j.BadCode and h.WorkPoint=j.WorkPoint
  291. // LEFT JOIN ICSContainerLot k ON d.LotNo=k.LotNo AND d.WorkPoint=k.WorkPoint
  292. // left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  293. // where 1=1 {0}";
  294. #endregion
  295. string wheresql = "";
  296. if (!string.IsNullOrWhiteSpace(queryJson))
  297. {
  298. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  299. {
  300. wheresql += " and a.ODNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  301. }
  302. if (!string.IsNullOrWhiteSpace(queryParam["ASNCode"].ToString()))
  303. {
  304. wheresql += " and a.OASNCode like '%" + queryParam["ASNCode"].ToString() + "%' ";
  305. }
  306. if (!string.IsNullOrWhiteSpace(queryParam["CaiGouCode"].ToString()))
  307. {
  308. wheresql += " and l.OOCode like '%" + queryParam["CaiGouCode"].ToString() + "%' ";
  309. }
  310. if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
  311. {
  312. wheresql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
  313. }
  314. if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
  315. {
  316. wheresql += " and m.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
  317. }
  318. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  319. {
  320. wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  321. }
  322. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  323. {
  324. wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  325. }
  326. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  327. {
  328. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  329. }
  330. if (!string.IsNullOrWhiteSpace(queryParam["TimeFrom"].ToString()))
  331. {
  332. wheresql += " and a.CreateDateTime >= '" + queryParam["TimeFrom"].ToString() + "' ";
  333. }
  334. if (!string.IsNullOrWhiteSpace(queryParam["TimeArrive"].ToString()))
  335. {
  336. wheresql += " and a.CreateDateTime <= '" + queryParam["TimeArrive"].ToString() + "' ";
  337. }
  338. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  339. {
  340. string ReleaseState = queryParam["ReleaseState"].ToString();
  341. if (ReleaseState == "1")
  342. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
  343. else if (ReleaseState == "0")
  344. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
  345. else
  346. wheresql += " ";
  347. }
  348. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  349. {
  350. string selEnableShow = queryParam["selEnableShow"].ToString();
  351. if (selEnableShow == "1")
  352. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
  353. else if (selEnableShow == "0")
  354. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
  355. }
  356. }
  357. sql = string.Format(sql, wheresql);
  358. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  359. }
  360. //工单
  361. public DataTable GetICSInspection3(ref Pagination jqgridparam, string queryJson)
  362. {
  363. DataTable dt = new DataTable();
  364. var queryParam = queryJson.ToJObject();
  365. List<DbParameter> parameter = new List<DbParameter>();
  366. string sql = @"select DISTINCT a.ID as GDID, e.ID , a.MOCode as DNCode, a.Sequence , h.ID as JYID, c.InvCode , c.InvName , c.INVSTD , c.ClassName,c.InvDesc,
  367. f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4 ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10, e.Quantity as AllNumber,
  368. CAST(ISNULL(h.QualifiedQuantity,e.Quantity)as NUMERIC(10,4))as YLOTQTY ,
  369. CAST(ISNULL(h.UnqualifiedQuantity, 0) as NUMERIC(10,4)) as NLOTQTY,
  370. CAST(ISNULL(h.WaiveQuantity, 0) as NUMERIC(10,4)) as SpecialQTY,
  371. CAST(ISNULL(h.SampleQuantity, 0) as NUMERIC(10,4)) as SampleQuantity,
  372. c.InvUnit , e.LotNo , g.BadReasonDesc as BadReasonDesc ,
  373. g.BadReasonCode as BRCodeValue,j.BadCode as BCCodeValue, j.BadDesc as BadDesc, i.ContainerID,
  374. isnull(h.MUSERName,'') MUSERName, CONVERT(VARCHAR(100),e.ProductDate,23) as ProductTime,CONVERT(VARCHAR(100),h.MTIME,23) as MTIME,
  375. CASE WHEN isnull(h.ID,'') =''THEN '' ELSE '' END AS TestState,
  376. isnull(h.MUSER,'') as Surveyor, h.MUSERName as ProvingTime
  377. ,CASE WHEN h.Result='0' THEN '' when ISNULL(h.Result,'')='' THEN '' ELSE '' END AS Result,
  378. n.FileName,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  379. a.EATTRIBUTE9,a.EATTRIBUTE10
  380. from ICSMO a
  381. inner JOIN dbo.ICSInventory c ON a.InvCode = c.InvCode AND a.WorkPoint=c.WorkPoint and c.InvIQC='1'
  382. left join ICSInventoryLotDetail b on a.MOCode=b.TransCode and a.Sequence=b.TransSequence and a.WorkPoint=b.WorkPoint
  383. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  384. LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo=b.LotNo AND e.WorkPoint=b.WorkPoint
  385. LEFT JOIN dbo.ICSInspection h ON h.LotNO=e.LotNO and h.InvCode=e.InvCode and h.WorkPoint=e.WorkPoint and Enable='1'
  386. left join ICSBadReason g on h.BRCode =g.BadReasonCode and h.WorkPoint=g.WorkPoint
  387. left join ICSBadCode j on h.BCCode =j.BadCode and h.WorkPoint=j.WorkPoint
  388. LEFT JOIN dbo.ICSContainerLot i ON e.LotNO=i.LotNO AND e.WorkPoint=i.WorkPoint
  389. left join ICSInspectionFile n on h.id=n.InspectionID and h.WorkPoint=n.WorkPoint
  390. where a.MOStatus<>'3' and e.LotNO is not null {0} ";
  391. string wheresql = "";
  392. if (!string.IsNullOrWhiteSpace(queryJson))
  393. {
  394. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  395. {
  396. wheresql += " and a.MOCode like '%" + queryParam["POCode"].ToString() + "%' ";
  397. }
  398. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  399. {
  400. wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  401. }
  402. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  403. {
  404. wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  405. }
  406. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  407. {
  408. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  409. }
  410. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  411. {
  412. string ReleaseState = queryParam["ReleaseState"].ToString();
  413. if (ReleaseState == "1")
  414. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
  415. else if (ReleaseState == "0")
  416. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
  417. else
  418. wheresql += " ";
  419. }
  420. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  421. {
  422. string selEnableShow = queryParam["selEnableShow"].ToString();
  423. if (selEnableShow == "1")
  424. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
  425. else if (selEnableShow == "0")
  426. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
  427. }
  428. }
  429. sql = string.Format(sql, wheresql);
  430. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  431. }
  432. //其他入库
  433. public DataTable GetICSInspection4(ref Pagination jqgridparam, string queryJson)
  434. {
  435. DataTable dt = new DataTable();
  436. var queryParam = queryJson.ToJObject();
  437. List<DbParameter> parameter = new List<DbParameter>();
  438. string sql = @"select DISTINCT a.ID as GDID, e.ID , a.InCode as DNCode, a.Sequence , h.ID as JYID, c.InvCode , c.InvName , c.INVSTD , c.ClassName,
  439. f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4 ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10, e.Quantity as AllNumber,
  440. CAST(ISNULL(h.QualifiedQuantity,e.Quantity)as NUMERIC(10,4))as YLOTQTY ,
  441. CAST(ISNULL(h.UnqualifiedQuantity, 0) as NUMERIC(10,4)) as NLOTQTY,
  442. CAST(ISNULL(h.WaiveQuantity, 0) as NUMERIC(10,4)) as SpecialQTY,
  443. CAST(ISNULL(h.SampleQuantity, 0) as NUMERIC(10,4)) as SampleQuantity,
  444. c.InvUnit , e.LotNo , g.BadReasonDesc as BadReasonDesc ,
  445. g.BadReasonCode as BRCodeValue,j.BadCode as BCCodeValue, j.BadDesc as BadDesc, i.ContainerID,
  446. isnull(h.MUSERName,'') MUSERName, CONVERT(VARCHAR(100),e.ProductDate,23) as ProductTime,CONVERT(VARCHAR(100),h.MTIME,23) as MTIME,
  447. CASE WHEN isnull(h.ID,'') =''THEN '' ELSE '' END AS TestState,
  448. isnull(h.MUSER,'') as Surveyor, h.MUSERName as ProvingTime
  449. ,CASE WHEN h.Result='0' THEN '' when ISNULL(h.Result,'')='' THEN '' ELSE '' END AS Result,
  450. n.FileName,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  451. a.EATTRIBUTE9,a.EATTRIBUTE10
  452. from ICSOtherIn a
  453. inner JOIN dbo.ICSInventory c ON a.InvCode = c.InvCode AND a.WorkPoint=c.WorkPoint and c.InvIQC='1'
  454. left join ICSInventoryLotDetail b on a.InCode=b.TransCode and a.Sequence=b.TransSequence and a.WorkPoint=b.WorkPoint
  455. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  456. LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo=b.LotNo AND e.WorkPoint=b.WorkPoint
  457. LEFT JOIN dbo.ICSInspection h ON h.LotNO=e.LotNO and h.InvCode=e.InvCode and h.WorkPoint=e.WorkPoint and Enable='1'
  458. left join ICSBadReason g on h.BRCode =g.BadReasonCode and h.WorkPoint=g.WorkPoint
  459. left join ICSBadCode j on h.BCCode =j.BadCode and h.WorkPoint=j.WorkPoint
  460. LEFT JOIN dbo.ICSContainerLot i ON e.LotNO=i.LotNO AND e.WorkPoint=i.WorkPoint
  461. left join ICSInspectionFile n on h.id=n.InspectionID and h.WorkPoint=n.WorkPoint
  462. where e.LotNO is not null {0} ";
  463. string wheresql = "";
  464. if (!string.IsNullOrWhiteSpace(queryJson))
  465. {
  466. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  467. {
  468. wheresql += " and a.InCode like '%" + queryParam["POCode"].ToString() + "%' ";
  469. }
  470. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  471. {
  472. wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  473. }
  474. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  475. {
  476. wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  477. }
  478. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  479. {
  480. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  481. }
  482. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  483. {
  484. string ReleaseState = queryParam["ReleaseState"].ToString();
  485. if (ReleaseState == "1")
  486. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
  487. else if (ReleaseState == "0")
  488. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
  489. else
  490. wheresql += " ";
  491. }
  492. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  493. {
  494. string selEnableShow = queryParam["selEnableShow"].ToString();
  495. if (selEnableShow == "1")
  496. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
  497. else if (selEnableShow == "0")
  498. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
  499. }
  500. }
  501. sql = string.Format(sql, wheresql);
  502. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  503. }
  504. //生产退料
  505. public DataTable GetICSInspection5(ref Pagination jqgridparam, string queryJson)
  506. {
  507. DataTable dt = new DataTable();
  508. var queryParam = queryJson.ToJObject();
  509. List<DbParameter> parameter = new List<DbParameter>();
  510. string sql = @"select DISTINCT a.ID as GDID, e.ID , a.ApplyNegCode as DNCode, ad.Sequence , h.ID as JYID, c.InvCode , c.InvName , c.INVSTD , c.ClassName,
  511. f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4 ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10, e.Quantity as AllNumber,
  512. CAST(ISNULL(h.QualifiedQuantity,e.Quantity)as NUMERIC(10,4))as YLOTQTY ,
  513. CAST(ISNULL(h.UnqualifiedQuantity, 0) as NUMERIC(10,4)) as NLOTQTY,
  514. CAST(ISNULL(h.WaiveQuantity, 0) as NUMERIC(10,4)) as SpecialQTY,
  515. CAST(ISNULL(h.SampleQuantity, 0) as NUMERIC(10,4)) as SampleQuantity,
  516. c.InvUnit , e.LotNo , g.BadReasonDesc as BadReasonDesc ,
  517. g.BadReasonCode as BRCodeValue,j.BadCode as BCCodeValue, j.BadDesc as BadDesc, i.ContainerID,
  518. isnull(h.MUSERName,'') MUSERName, CONVERT(VARCHAR(100),e.ProductDate,23) as ProductTime,CONVERT(VARCHAR(100),h.MTIME,23) as MTIME,
  519. CASE WHEN isnull(h.ID,'') =''THEN '' ELSE '' END AS TestState,
  520. isnull(h.MUSER,'') as Surveyor, h.MUSERName as ProvingTime
  521. ,CASE WHEN h.Result='0' THEN '' when ISNULL(h.Result,'')='' THEN '' ELSE '' END AS Result,
  522. n.FileName ,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  523. a.EATTRIBUTE9,a.EATTRIBUTE10
  524. from ICSMOApplyNeg a
  525. LEFT JOIN ICSMOApplyNegDetail ad ON a.ApplyNegCode=ad.ApplyNegCode AND a.WorkPoint=ad.WorkPoint
  526. inner JOIN dbo.ICSInventory c ON ad.InvCode = c.InvCode AND ad.WorkPoint=c.WorkPoint and c.InvIQC='1'
  527. left join ICSInventoryLotDetail b on a.ApplyNegCode=b.TransCode and ad.Sequence=b.TransSequence and ad.WorkPoint=b.WorkPoint
  528. left join ICSExtension f on ad.ExtensionID=f.ID and ad.WorkPoint=f.WorkPoint
  529. LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo=b.LotNo AND e.WorkPoint=b.WorkPoint
  530. LEFT JOIN dbo.ICSInspection h ON h.LotNO=e.LotNO and h.InvCode=e.InvCode and h.WorkPoint=e.WorkPoint and Enable='1'
  531. left join ICSBadReason g on h.BRCode =g.BadReasonCode and h.WorkPoint=g.WorkPoint
  532. left join ICSBadCode j on h.BCCode =j.BadCode and h.WorkPoint=j.WorkPoint
  533. LEFT JOIN dbo.ICSContainerLot i ON e.LotNO=i.LotNO AND e.WorkPoint=i.WorkPoint
  534. left join ICSInspectionFile n on h.id=n.InspectionID and h.WorkPoint=n.WorkPoint
  535. where e.LotNO is not null {0} ";
  536. string wheresql = "";
  537. if (!string.IsNullOrWhiteSpace(queryJson))
  538. {
  539. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  540. {
  541. wheresql += " and a.ApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
  542. }
  543. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  544. {
  545. wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  546. }
  547. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  548. {
  549. wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  550. }
  551. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  552. {
  553. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  554. }
  555. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  556. {
  557. string ReleaseState = queryParam["ReleaseState"].ToString();
  558. if (ReleaseState == "1")
  559. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
  560. else if (ReleaseState == "0")
  561. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
  562. else
  563. wheresql += " ";
  564. }
  565. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  566. {
  567. string selEnableShow = queryParam["selEnableShow"].ToString();
  568. if (selEnableShow == "1")
  569. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
  570. else if (selEnableShow == "0")
  571. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
  572. }
  573. }
  574. sql = string.Format(sql, wheresql);
  575. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  576. }
  577. //委外退料
  578. public DataTable GetICSInspection6(ref Pagination jqgridparam, string queryJson)
  579. {
  580. DataTable dt = new DataTable();
  581. var queryParam = queryJson.ToJObject();
  582. List<DbParameter> parameter = new List<DbParameter>();
  583. string sql = @"select DISTINCT a.ID as GDID, e.ID , a.OApplyNegCode as DNCode, ad.Sequence , h.ID as JYID, c.InvCode , c.InvName , c.INVSTD , c.ClassName,
  584. f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4 ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10, e.Quantity as AllNumber,
  585. CAST(ISNULL(h.QualifiedQuantity,e.Quantity)as NUMERIC(10,4))as YLOTQTY ,
  586. CAST(ISNULL(h.UnqualifiedQuantity, 0) as NUMERIC(10,4)) as NLOTQTY,
  587. CAST(ISNULL(h.WaiveQuantity, 0) as NUMERIC(10,4)) as SpecialQTY,
  588. CAST(ISNULL(h.SampleQuantity, 0) as NUMERIC(10,4)) as SampleQuantity,
  589. c.InvUnit , e.LotNo , g.BadReasonDesc as BadReasonDesc ,
  590. g.BadReasonCode as BRCodeValue,j.BadCode as BCCodeValue, j.BadDesc as BadDesc, i.ContainerID,
  591. isnull(h.MUSERName,'') MUSERName, CONVERT(VARCHAR(100),e.ProductDate,23) as ProductTime,CONVERT(VARCHAR(100),h.MTIME,23) as MTIME,
  592. CASE WHEN isnull(h.ID,'') =''THEN '' ELSE '' END AS TestState,
  593. isnull(h.MUSER,'') as Surveyor, h.MUSERName as ProvingTime
  594. ,CASE WHEN h.Result='0' THEN '' when ISNULL(h.Result,'')='' THEN '' ELSE '' END AS Result,
  595. n.FileName,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  596. a.EATTRIBUTE9,a.EATTRIBUTE10
  597. from ICSOApplyNeg a
  598. LEFT JOIN ICSOApplyNegDetail ad ON a.OApplyNegCode=ad.OApplyNegCode AND a.WorkPoint=ad.WorkPoint
  599. inner JOIN dbo.ICSInventory c ON ad.InvCode = c.InvCode AND ad.WorkPoint=c.WorkPoint and c.InvIQC='1'
  600. left join ICSInventoryLotDetail b on a.OApplyNegCode=b.TransCode and ad.Sequence=b.TransSequence and ad.WorkPoint=b.WorkPoint
  601. left join ICSExtension f on ad.ExtensionID=f.ID and ad.WorkPoint=f.WorkPoint
  602. LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo=b.LotNo AND e.WorkPoint=b.WorkPoint
  603. LEFT JOIN dbo.ICSInspection h ON h.LotNO=e.LotNO and h.InvCode=e.InvCode and h.WorkPoint=e.WorkPoint and Enable='1'
  604. left join ICSBadReason g on h.BRCode =g.BadReasonCode and h.WorkPoint=g.WorkPoint
  605. left join ICSBadCode j on h.BCCode =j.BadCode and h.WorkPoint=j.WorkPoint
  606. LEFT JOIN dbo.ICSContainerLot i ON e.LotNO=i.LotNO AND e.WorkPoint=i.WorkPoint
  607. left join ICSInspectionFile n on h.id=n.InspectionID and h.WorkPoint=n.WorkPoint
  608. where e.LotNO is not null {0} ";
  609. string wheresql = "";
  610. if (!string.IsNullOrWhiteSpace(queryJson))
  611. {
  612. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  613. {
  614. wheresql += " and a.OApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
  615. }
  616. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  617. {
  618. wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  619. }
  620. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  621. {
  622. wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  623. }
  624. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  625. {
  626. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  627. }
  628. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  629. {
  630. string ReleaseState = queryParam["ReleaseState"].ToString();
  631. if (ReleaseState == "1")
  632. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
  633. else if (ReleaseState == "0")
  634. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
  635. else
  636. wheresql += " ";
  637. }
  638. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  639. {
  640. string selEnableShow = queryParam["selEnableShow"].ToString();
  641. if (selEnableShow == "1")
  642. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
  643. else if (selEnableShow == "0")
  644. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
  645. }
  646. }
  647. sql = string.Format(sql, wheresql);
  648. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  649. }
  650. //销售退货
  651. public DataTable GetICSInspection7(ref Pagination jqgridparam, string queryJson)
  652. {
  653. DataTable dt = new DataTable();
  654. var queryParam = queryJson.ToJObject();
  655. List<DbParameter> parameter = new List<DbParameter>();
  656. string sql = @"select DISTINCT a.ID as GDID, e.ID , a.SDNCode as DNCode, a.Sequence , h.ID as JYID, c.InvCode , c.InvName , c.INVSTD , c.ClassName,
  657. f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4 ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10, e.Quantity as AllNumber,
  658. CAST(ISNULL(h.QualifiedQuantity,e.Quantity)as NUMERIC(10,4))as YLOTQTY ,
  659. CAST(ISNULL(h.UnqualifiedQuantity, 0) as NUMERIC(10,4)) as NLOTQTY,
  660. CAST(ISNULL(h.WaiveQuantity, 0) as NUMERIC(10,4)) as SpecialQTY,
  661. CAST(ISNULL(h.SampleQuantity, 0) as NUMERIC(10,4)) as SampleQuantity,
  662. c.InvUnit , e.LotNo , g.BadReasonDesc as BadReasonDesc ,
  663. g.BadReasonCode as BRCodeValue,j.BadCode as BCCodeValue, j.BadDesc as BadDesc, i.ContainerID,
  664. isnull(h.MUSERName,'') MUSERName, CONVERT(VARCHAR(100),e.ProductDate,23) as ProductTime,CONVERT(VARCHAR(100),h.MTIME,23) as MTIME,
  665. CASE WHEN isnull(h.ID,'') =''THEN '' ELSE '' END AS TestState,
  666. isnull(h.MUSER,'') as Surveyor, h.MUSERName as ProvingTime
  667. ,CASE WHEN h.Result='0' THEN '' when ISNULL(h.Result,'')='' THEN '' ELSE '' END AS Result,
  668. n.FileName,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  669. a.EATTRIBUTE9,a.EATTRIBUTE10
  670. from ICSSDN a
  671. inner JOIN dbo.ICSInventory c ON a.InvCode = c.InvCode AND a.WorkPoint=c.WorkPoint and c.InvIQC='1'
  672. left join ICSInventoryLotDetail b on a.SDNCode=b.TransCode and a.Sequence=b.TransSequence and a.WorkPoint=b.WorkPoint
  673. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  674. LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo=b.LotNo AND e.WorkPoint=b.WorkPoint
  675. LEFT JOIN dbo.ICSInspection h ON h.LotNO=e.LotNO and h.InvCode=e.InvCode and h.WorkPoint=e.WorkPoint and Enable='1'
  676. left join ICSBadReason g on h.BRCode =g.BadReasonCode and h.WorkPoint=g.WorkPoint
  677. left join ICSBadCode j on h.BCCode =j.BadCode and h.WorkPoint=j.WorkPoint
  678. LEFT JOIN dbo.ICSContainerLot i ON e.LotNO=i.LotNO AND e.WorkPoint=i.WorkPoint
  679. left join ICSInspectionFile n on h.id=n.InspectionID and h.WorkPoint=n.WorkPoint
  680. where e.LotNO is not null AND a.Type='2' {0} ";
  681. string wheresql = "";
  682. if (!string.IsNullOrWhiteSpace(queryJson))
  683. {
  684. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  685. {
  686. wheresql += " and a.SDNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  687. }
  688. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  689. {
  690. wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  691. }
  692. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  693. {
  694. wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  695. }
  696. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  697. {
  698. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  699. }
  700. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  701. {
  702. string ReleaseState = queryParam["ReleaseState"].ToString();
  703. if (ReleaseState == "1")
  704. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
  705. else if (ReleaseState == "0")
  706. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
  707. else
  708. wheresql += " ";
  709. }
  710. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  711. {
  712. string selEnableShow = queryParam["selEnableShow"].ToString();
  713. if (selEnableShow == "1")
  714. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
  715. else if (selEnableShow == "0")
  716. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
  717. }
  718. }
  719. sql = string.Format(sql, wheresql);
  720. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  721. }
  722. //获取不良原因
  723. public DataTable Select_ICSBadReason(string BCCode)
  724. {
  725. string sql = string.Empty;
  726. DataTable dt = null;
  727. sql = @"select '' as BadReasonCode,'' as BadReasonDesc from ICSBadReasonGroup a inner join ICSBadReason b on a.ID=b.BRGroupID
  728. union
  729. select BadReasonCode, BadReasonDesc from ICSBadReasonGroup a inner join ICSBadReason b on a.ID=b.BRGroupID
  730. where 1=1 ";
  731. dt = SqlHelper.GetDataTableBySql(sql);
  732. return dt;
  733. }
  734. public DataTable Select_ChangeA(string BCCode)
  735. {
  736. string sql = string.Empty;
  737. DataTable dt = null;
  738. sql = @"select '' as BadReasonCode,'' as BadReasonDesc from ICSBadReasonGroup a inner join ICSBadReason b on a.ID=b.BRGroupID
  739. union
  740. select BadReasonCode, BadReasonDesc from ICSBadReasonGroup a inner join ICSBadReason b on a.ID=b.BRGroupID
  741. where 1=1 ";
  742. if (!string.IsNullOrWhiteSpace(BCCode))
  743. {
  744. sql += " and a.BRGCode= '" + BCCode + "' ";
  745. }
  746. dt = SqlHelper.GetDataTableBySql(sql);
  747. return dt;
  748. }
  749. //获取不良代码组
  750. public DataTable GetSelectICSBadCode(string BRCode)
  751. {
  752. string sql = string.Empty;
  753. DataTable dt = null;
  754. sql = @"select '' as BRGCode,'' as BRGDesc from ICSBadReasonGroup a inner join ICSBadReason b on a.ID=b.BRGroupID
  755. union
  756. select BRGCode, BRGDesc from ICSBadReasonGroup a inner join ICSBadReason b on a.ID=b.BRGroupID
  757. where 1=1 ";
  758. dt = SqlHelper.GetDataTableBySql(sql);
  759. return dt;
  760. }
  761. public DataTable Select_ChangeB(string BRCode)
  762. {
  763. string sql = string.Empty;
  764. DataTable dt = null;
  765. sql = @"
  766. select BRGCode, BRGDesc from ICSBadReasonGroup a inner join ICSBadReason b on a.ID=b.BRGroupID
  767. where 1=1 ";
  768. if (!string.IsNullOrWhiteSpace(BRCode))
  769. {
  770. sql += " and b.BadReasonCode= '" + BRCode + "' ";
  771. }
  772. dt = SqlHelper.GetDataTableBySql(sql);
  773. return dt;
  774. }
  775. /// <summary>
  776. /// 新增检验
  777. /// </summary>
  778. /// <param name="queryJson"></param>
  779. /// <returns></returns>
  780. public string CreateICSInspection(string keyValue, string ICSInspections)
  781. {
  782. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  783. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  784. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  785. string msg = "";
  786. string sql = string.Empty;
  787. JArray res = (JArray)JsonConvert.DeserializeObject(ICSInspections);
  788. foreach (var item in res)
  789. {
  790. JObject jo = (JObject)item;
  791. string sqls = string.Empty;
  792. sqls = @"update ICSInspection set Enable='0' WHERE LotNO='{0}' and Enable='1' and WorkPoint='{1}'";
  793. sqls = string.Format(sqls, jo["LotNo"].ToString(), WorkPoint);
  794. SqlHelper.CmdExecuteNonQueryLi(sqls);
  795. //if (jo["TestState"].ToString()=="已检验")
  796. //{
  797. // sql += @"UPDATE dbo.ICSInspection set QualifiedQuantity='{0}',UnqualifiedQuantity='{1}',WaiveQuantity='{2}',BCCode='{3}',BRCode='{4}',MTIME=GETDATE(),MUSER='{5}',MUSERName='{6}',WorkPoint='{7}' WHERE ID='{8}'";
  798. // sql = string.Format(sql, jo["YLOTQTY"].ToString(), jo["NLOTQTY"].ToString(), jo["SpecialQTY"].ToString(), jo["BCCode"].ToString(), jo["BRCode"].ToString(), MUSER, MUSERNAME, WorkPoint, jo["JYID"].ToString());
  799. //}
  800. //else
  801. //{
  802. sql += @"
  803. -- IF EXISTS(select LotNo from dbo.ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{11}')
  804. -- BEGIN
  805. -- RAISERROR(':{0}!',16,1);
  806. -- RETURN
  807. -- end
  808. INSERT INTO dbo.ICSInspection
  809. ( ID ,LotNo,InvCode ,Quantity,QualifiedQuantity ,UnqualifiedQuantity,WaiveQuantity,BCCode,BRCode,Type,MTIME,MUSER ,MUSERName ,WorkPoint ,Enable,SampleQuantity)
  810. Values(NEWID(),'{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}',getdate(),'{9}','{10}','{11}','1','{12}')
  811. ";
  812. sql = string.Format(sql, jo["LotNo"].ToString(), jo["InvCode"].ToString(), jo["AllNumber"].ToString(), jo["YLOTQTY"].ToString(), jo["NLOTQTY"].ToString(), jo["SpecialQTY"].ToString(), jo["BCCode"].ToString(), jo["BRCode"].ToString(), jo["Type"].ToString(), MUSER, MUSERNAME, WorkPoint, jo["SampleQuantity"].ToString());
  813. }
  814. //}
  815. try
  816. {
  817. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  818. {
  819. }
  820. else
  821. {
  822. msg = "新增失败";
  823. }
  824. }
  825. catch (Exception ex)
  826. {
  827. msg=ex.Message;
  828. }
  829. return msg;
  830. }
  831. //生成采购拒收单
  832. public string CreateRejection(string keyValue)
  833. {
  834. string msg = "";
  835. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  836. string sqlAsn = @"select distinct a.VenCode,a.DNID,a.DepCode,a.DNCode from ICSDeliveryNotice a
  837. inner join ICSASNDetail b on a.ASNCode=b.ASNCode and a.WorkPoint=b.WorkPoint
  838. left join dbo.ICSInventoryLot c on b.LotNo=c.LotNo and a.InvCode=c.InvCode and b.WorkPoint=c.WorkPoint
  839. left join ICSInventoryLotDetail e on c.LotNo=e.LotNo and c.WorkPoint=e.WorkPoint
  840. inner JOIN ICSPurchaseOrder l ON e.TransCode =l.POCode AND e.TransSequence=l.Sequence AND a.PODetailID=l.PODetailID AND c.WorkPoint=l.WorkPoint
  841. WHERE b.LotNo IN (" + keyValue.TrimEnd(',') + ")";
  842. // string sqlAsn = @"select distinct a.VenCode,a.DNID,a.DepCode,a.DNCode from ICSDeliveryNotice a
  843. //left join ICSInventoryLotDetail e on a.DNCode=e.TransCode and a.Sequence=e.TransSequence and a.WorkPoint=e.WorkPoint
  844. //left join dbo.ICSInventoryLot c on e.LotNo=c.LotNo and a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint
  845. //inner JOIN ICSPurchaseOrder l ON a.PODetailID=l.PODetailID AND c.WorkPoint=l.WorkPoint
  846. //WHERE c.LotNo IN (" + keyValue.TrimEnd(',') + ")";
  847. DataTable dt = Repository().FindTableBySql(sqlAsn.ToString());
  848. string sqlAsnD = @"select distinct c.InvCode,d.UnqualifiedQuantity-d.WaiveQuantity as Quantity,isnull(c.Amount,0) as Amount,a.Currency,isnull(a.UnitPrice,0) as UnitPrice,DNDetailID,DNID,b.LotNo
  849. from ICSDeliveryNotice a
  850. left join ICSASNDetail b on a.ASNCode=b.ASNCode and a.WorkPoint=b.WorkPoint
  851. left join ICSInventoryLot c on b.LotNo=c.LotNo and a.InvCode=c.InvCode and b.WorkPoint=c.WorkPoint
  852. left join ICSInventoryLotDetail e on c.LotNo=e.LotNo and c.WorkPoint=e.WorkPoint
  853. inner JOIN ICSPurchaseOrder l ON e.TransCode =l.POCode AND e.TransSequence=l.Sequence AND a.PODetailID=l.PODetailID AND c.WorkPoint=l.WorkPoint
  854. left join ICSInspection d on b.LotNo=d.LotNo and b.WorkPoint=d.WorkPoint
  855. WHERE b.LotNo in (" + keyValue.TrimEnd(',') + ") ";
  856. // string sqlAsnD = @"select distinct c.InvCode,d.UnqualifiedQuantity-d.WaiveQuantity as Quantity,isnull(c.Amount,0) as Amount,a.Currency,isnull(a.UnitPrice,0) as UnitPrice,DNDetailID,DNID,d.LotNo
  857. //from ICSDeliveryNotice a
  858. //left join ICSInventoryLotDetail e on a.DNCode=e.TransCode and a.Sequence=e.TransSequence and a.WorkPoint=e.WorkPoint
  859. //left join ICSInventoryLot c on e.LotNo=c.LotNo and a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint
  860. // inner JOIN ICSPurchaseOrder l ON a.PODetailID=l.PODetailID AND c.WorkPoint=l.WorkPoint
  861. //left join ICSInspection d on c.LotNo=d.LotNo and a.WorkPoint=d.WorkPoint and d.Enable='1'
  862. //WHERE d.LotNo in (" + keyValue.TrimEnd(',') + ") ";
  863. DataTable dtD = Repository().FindTableBySql(sqlAsnD.ToString());
  864. List<RejectionHead> asn = new List<RejectionHead>();
  865. for (int i = 0; i < dt.Rows.Count; i++)
  866. {
  867. RejectionHead ass = new RejectionHead();
  868. ass.VenCode = dt.Rows[i]["VenCode"].ToString();
  869. ass.ID = dt.Rows[i]["DNID"].ToString();
  870. ass.DepCode = dt.Rows[i]["DepCode"].ToString();
  871. ass.DNCode = dt.Rows[i]["DNCode"].ToString();
  872. ass.User = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  873. ass.MTIME = System.DateTime.Now.ToString("s");
  874. ass.WorkPoint = WorkPoint;
  875. DataRow[] drs = dtD.Select("DNID='" + dt.Rows[i]["DNID"].ToString() + "'");
  876. for (int j = 0; j < drs.Length; j++)
  877. {
  878. RejectionBody DetailList = new RejectionBody();
  879. DetailList.Sequence = (j + 1).ToString();
  880. DetailList.InvCode = drs[j]["InvCode"].ToString();
  881. DetailList.Quantity = drs[j]["Quantity"].ToString();
  882. DetailList.Amount = drs[j]["Amount"].ToString();
  883. DetailList.Currency = drs[j]["Currency"].ToString();
  884. DetailList.UnitPrice = drs[j]["UnitPrice"].ToString();
  885. DetailList.DNDetailID = drs[j]["DNDetailID"].ToString();
  886. DetailList.LotNo = drs[j]["LotNo"].ToString();
  887. ass.detail.Add(DetailList);
  888. }
  889. asn.Add(ass);
  890. }
  891. string input = JsonConvert.SerializeObject(asn);
  892. string APIURL = ConfigurationManager.ConnectionStrings["APIURL"].ConnectionString + "PurchaseRejectDoc/Create";
  893. string result = HttpPost(APIURL, input);
  894. JObject Obj = (JObject)JsonConvert.DeserializeObject(result);//或者JObject jo = JObject.Parse(jsonText);
  895. string MessAge = Obj["Message"].ToString();
  896. string Success = Obj["Success"].ToString();
  897. if (Success.ToUpper() == "FALSE")
  898. {
  899. msg = MessAge;
  900. }
  901. return msg;
  902. }
  903. //生成采购拒收单(无来源)
  904. public string CreateWLYRejection(string keyValue)
  905. {
  906. string msg = "";
  907. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  908. //string sqlAsn = @"select distinct a.VenCode,a.DNID,a.DepCode,a.DNCode from ICSDeliveryNotice a
  909. // inner join ICSASNDetail b on a.ASNCode=b.ASNCode and a.WorkPoint=b.WorkPoint
  910. // left join dbo.ICSInventoryLot c on b.LotNo=c.LotNo and a.InvCode=c.InvCode and b.WorkPoint=c.WorkPoint
  911. // left join ICSInventoryLotDetail e on c.LotNo=e.LotNo and c.WorkPoint=e.WorkPoint
  912. // inner JOIN ICSPurchaseOrder l ON e.TransCode =l.POCode AND e.TransSequence=l.Sequence AND a.PODetailID=l.PODetailID AND c.WorkPoint=l.WorkPoint
  913. // WHERE b.LotNo IN (" + keyValue.TrimEnd(',') + ")";
  914. string sqlAsn = @"select distinct a.VenCode,a.DNID,a.DepCode,a.DNCode from ICSDeliveryNotice a
  915. left join ICSInventoryLotDetail e on a.DNCode=e.TransCode and a.Sequence=e.TransSequence and a.WorkPoint=e.WorkPoint
  916. left join dbo.ICSInventoryLot c on e.LotNo=c.LotNo and a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint
  917. -- left JOIN ICSPurchaseOrder l ON a.PODetailID=l.PODetailID AND c.WorkPoint=l.WorkPoint
  918. WHERE c.LotNo IN (" + keyValue.TrimEnd(',') + ")";
  919. DataTable dt = Repository().FindTableBySql(sqlAsn.ToString());
  920. //string sqlAsnD = @"select distinct c.InvCode,d.UnqualifiedQuantity-d.WaiveQuantity as Quantity,isnull(c.Amount,0) as Amount,a.Currency,isnull(a.UnitPrice,0) as UnitPrice,DNDetailID,DNID,b.LotNo
  921. // from ICSDeliveryNotice a
  922. // left join ICSASNDetail b on a.ASNCode=b.ASNCode and a.WorkPoint=b.WorkPoint
  923. // left join ICSInventoryLot c on b.LotNo=c.LotNo and a.InvCode=c.InvCode and b.WorkPoint=c.WorkPoint
  924. // left join ICSInventoryLotDetail e on c.LotNo=e.LotNo and c.WorkPoint=e.WorkPoint
  925. // inner JOIN ICSPurchaseOrder l ON e.TransCode =l.POCode AND e.TransSequence=l.Sequence AND a.PODetailID=l.PODetailID AND c.WorkPoint=l.WorkPoint
  926. // left join ICSInspection d on b.LotNo=d.LotNo and b.WorkPoint=d.WorkPoint
  927. // WHERE b.LotNo in (" + keyValue.TrimEnd(',') + ") ";
  928. string sqlAsnD = @"select distinct c.InvCode,d.UnqualifiedQuantity-d.WaiveQuantity as Quantity,isnull(c.Amount,0) as Amount,a.Currency,isnull(a.UnitPrice,0) as UnitPrice,DNDetailID,DNID,d.LotNo
  929. from ICSDeliveryNotice a
  930. left join ICSInventoryLotDetail e on a.DNCode=e.TransCode and a.Sequence=e.TransSequence and a.WorkPoint=e.WorkPoint
  931. left join ICSInventoryLot c on e.LotNo=c.LotNo and a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint
  932. inner JOIN ICSPurchaseOrder l ON a.PODetailID=l.PODetailID AND c.WorkPoint=l.WorkPoint
  933. left join ICSInspection d on c.LotNo=d.LotNo and a.WorkPoint=d.WorkPoint and d.Enable='1'
  934. WHERE d.LotNo in (" + keyValue.TrimEnd(',') + ") ";
  935. DataTable dtD = Repository().FindTableBySql(sqlAsnD.ToString());
  936. List<RejectionHead> asn = new List<RejectionHead>();
  937. for (int i = 0; i < dt.Rows.Count; i++)
  938. {
  939. RejectionHead ass = new RejectionHead();
  940. ass.VenCode = dt.Rows[i]["VenCode"].ToString();
  941. ass.ID = dt.Rows[i]["DNID"].ToString();
  942. ass.DepCode = dt.Rows[i]["DepCode"].ToString();
  943. ass.DNCode = dt.Rows[i]["DNCode"].ToString();
  944. ass.User = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  945. ass.MTIME = System.DateTime.Now.ToString("s");
  946. ass.WorkPoint = WorkPoint;
  947. DataRow[] drs = dtD.Select("DNID='" + dt.Rows[i]["DNID"].ToString() + "'");
  948. for (int j = 0; j < drs.Length; j++)
  949. {
  950. RejectionBody DetailList = new RejectionBody();
  951. DetailList.Sequence = (j + 1).ToString();
  952. DetailList.InvCode = drs[j]["InvCode"].ToString();
  953. DetailList.Quantity = drs[j]["Quantity"].ToString();
  954. DetailList.Amount = drs[j]["Amount"].ToString();
  955. DetailList.Currency = drs[j]["Currency"].ToString();
  956. DetailList.UnitPrice = drs[j]["UnitPrice"].ToString();
  957. DetailList.DNDetailID = drs[j]["DNDetailID"].ToString();
  958. DetailList.LotNo = drs[j]["LotNo"].ToString();
  959. ass.detail.Add(DetailList);
  960. }
  961. asn.Add(ass);
  962. }
  963. string input = JsonConvert.SerializeObject(asn);
  964. string APIURL = ConfigurationManager.ConnectionStrings["APIURL"].ConnectionString + "PurchaseRejectDocNoTrans/Create";
  965. string result = HttpPost(APIURL, input);
  966. JObject Obj = (JObject)JsonConvert.DeserializeObject(result);//或者JObject jo = JObject.Parse(jsonText);
  967. string MessAge = Obj["Message"].ToString();
  968. string Success = Obj["Success"].ToString();
  969. if (Success.ToUpper() == "FALSE")
  970. {
  971. msg = MessAge;
  972. }
  973. return msg;
  974. }
  975. //生成委外拒收单
  976. public string CreateWWRejection(string keyValue)
  977. {
  978. string msg = "";
  979. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  980. string sqlAsn = @"select distinct a.VenCode,a.ODNID,a.DepCode,a.ODNCode from ICSODeliveryNotice a
  981. left join ICSOASNDetail b on a.OASNCode=b.OASNCode and a.WorkPoint=b.WorkPoint
  982. LEFT JOIN ICSInventory c ON a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint
  983. inner JOIN ICSInventoryLot d ON b.LotNo=d.LotNo AND a.InvCode=d.InvCode AND b.WorkPoint=d.WorkPoint
  984. left join ICSInventoryLotDetail e on d.LotNo=e.LotNo and d.WorkPoint=e.WorkPoint
  985. inner JOIN ICSOutsourcingOrder l ON e.TransCode =l.OOCode AND e.TransSequence=l.Sequence AND a.OODetailID=l.OODetailID AND d.WorkPoint=l.WorkPoint
  986. WHERE b.LotNo in (" + keyValue.TrimEnd(',') + ")";
  987. DataTable dt = Repository().FindTableBySql(sqlAsn.ToString());
  988. string sqlAsnD = @"select distinct c.InvCode,d.UnqualifiedQuantity-d.WaiveQuantity as Quantity,isnull(c.Amount,0) as Amount,a.Currency,isnull(a.UnitPrice,0) as UnitPrice,ODNDetailID,ODNID,b.LotNo
  989. from ICSODeliveryNotice a
  990. inner join ICSOASNDetail b on a.OASNCode=b.OASNCode and a.WorkPoint=b.WorkPoint
  991. inner join ICSInventoryLot c on b.LotNo=c.LotNo and a.InvCode=c.InvCode and b.WorkPoint=c.WorkPoint
  992. left join ICSInventoryLotDetail e on c.LotNo=e.LotNo and c.WorkPoint=e.WorkPoint
  993. inner JOIN ICSOutsourcingOrder l ON e.TransCode =l.OOCode AND e.TransSequence=l.Sequence AND a.OODetailID=l.OODetailID AND c.WorkPoint=l.WorkPoint
  994. inner join ICSInspection d on c.LotNo=d.LotNo and b.WorkPoint=d.WorkPoint and d.Enable='1'
  995. WHERE b.LotNo IN (" + keyValue.TrimEnd(',') + ") ";
  996. DataTable dtD = Repository().FindTableBySql(sqlAsnD.ToString());
  997. List<WWRejectionHead> asn = new List<WWRejectionHead>();
  998. for (int i = 0; i < dt.Rows.Count; i++)
  999. {
  1000. WWRejectionHead ass = new WWRejectionHead();
  1001. ass.VenCode = dt.Rows[i]["VenCode"].ToString();
  1002. ass.ID = dt.Rows[i]["ODNID"].ToString();
  1003. ass.DepCode = dt.Rows[i]["DepCode"].ToString();
  1004. ass.ODNCode = dt.Rows[i]["ODNCode"].ToString();
  1005. ass.User = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1006. ass.MTIME = System.DateTime.Now.ToString("s");
  1007. ass.WorkPoint = WorkPoint;
  1008. DataRow[] drs = dtD.Select("ODNID='" + dt.Rows[i]["ODNID"].ToString() + "'");
  1009. for (int j = 0; j < drs.Length; j++)
  1010. {
  1011. WWRejectionBody DetailList = new WWRejectionBody();
  1012. DetailList.Sequence = (j + 1).ToString();
  1013. DetailList.InvCode = drs[j]["InvCode"].ToString();
  1014. DetailList.Quantity = drs[j]["Quantity"].ToString();
  1015. DetailList.Amount = drs[j]["Amount"].ToString();
  1016. DetailList.Currency = drs[j]["Currency"].ToString();
  1017. DetailList.UnitPrice = drs[j]["UnitPrice"].ToString();
  1018. DetailList.ODNDetailID = drs[j]["ODNDetailID"].ToString();
  1019. DetailList.LotNo = drs[j]["LotNo"].ToString();
  1020. ass.detail.Add(DetailList);
  1021. }
  1022. asn.Add(ass);
  1023. }
  1024. string input = JsonConvert.SerializeObject(asn);
  1025. string APIURL = ConfigurationManager.ConnectionStrings["APIURL"].ConnectionString + "OutsourcingRejectDoc/Create";
  1026. string result = HttpPost(APIURL, input);
  1027. JObject Obj = (JObject)JsonConvert.DeserializeObject(result);//或者JObject jo = JObject.Parse(jsonText);
  1028. string MessAge = Obj["Message"].ToString();
  1029. string Success = Obj["Success"].ToString();
  1030. if (Success.ToUpper() == "FALSE")
  1031. {
  1032. msg = MessAge;
  1033. }
  1034. return msg;
  1035. }
  1036. //生成委外拒收单(无来源)
  1037. public string CreateWWWLYRejection(string keyValue)
  1038. {
  1039. string msg = "";
  1040. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1041. string sqlAsn = @"select distinct a.VenCode,a.ODNID,a.DepCode,a.ODNCode
  1042. from ICSODeliveryNotice a
  1043. left join ICSInventoryLotDetail e on a.ODNCode=e.TransCode and a.Sequence=e.TransSequence and a.WorkPoint=e.WorkPoint
  1044. inner JOIN ICSInventoryLot d ON e.LotNo=d.LotNo AND a.InvCode=d.InvCode AND e.WorkPoint=d.WorkPoint
  1045. left JOIN ICSInventory c ON a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint
  1046. WHERE d.LotNo in (" + keyValue.TrimEnd(',') + ")";
  1047. DataTable dt = Repository().FindTableBySql(sqlAsn.ToString());
  1048. string sqlAsnD = @"select distinct c.InvCode,d.UnqualifiedQuantity-d.WaiveQuantity as Quantity,isnull(c.Amount,0) as Amount,a.Currency,isnull(a.UnitPrice,0) as UnitPrice,ODNDetailID,ODNID,c.LotNo
  1049. from ICSODeliveryNotice a
  1050. left join ICSInventoryLotDetail e on a.ODNCode=e.TransCode and a.Sequence=e.TransSequence and a.WorkPoint=e.WorkPoint
  1051. inner join ICSInventoryLot c on e.LotNo=c.LotNo and a.InvCode=c.InvCode and e.WorkPoint=c.WorkPoint
  1052. inner join ICSInspection d on c.LotNo=d.LotNo and a.WorkPoint=d.WorkPoint and d.Enable='1'
  1053. WHERE c.LotNo IN (" + keyValue.TrimEnd(',') + ") ";
  1054. DataTable dtD = Repository().FindTableBySql(sqlAsnD.ToString());
  1055. List<WWRejectionHead> asn = new List<WWRejectionHead>();
  1056. for (int i = 0; i < dt.Rows.Count; i++)
  1057. {
  1058. WWRejectionHead ass = new WWRejectionHead();
  1059. ass.VenCode = dt.Rows[i]["VenCode"].ToString();
  1060. ass.ID = dt.Rows[i]["ODNID"].ToString();
  1061. ass.DepCode = dt.Rows[i]["DepCode"].ToString();
  1062. ass.ODNCode = dt.Rows[i]["ODNCode"].ToString();
  1063. ass.User = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1064. ass.MTIME = System.DateTime.Now.ToString("s");
  1065. ass.WorkPoint = WorkPoint;
  1066. DataRow[] drs = dtD.Select("ODNID='" + dt.Rows[i]["ODNID"].ToString() + "'");
  1067. for (int j = 0; j < drs.Length; j++)
  1068. {
  1069. WWRejectionBody DetailList = new WWRejectionBody();
  1070. DetailList.Sequence = (j + 1).ToString();
  1071. DetailList.InvCode = drs[j]["InvCode"].ToString();
  1072. DetailList.Quantity = drs[j]["Quantity"].ToString();
  1073. DetailList.Amount = drs[j]["Amount"].ToString();
  1074. DetailList.Currency = drs[j]["Currency"].ToString();
  1075. DetailList.UnitPrice = drs[j]["UnitPrice"].ToString();
  1076. DetailList.ODNDetailID = drs[j]["ODNDetailID"].ToString();
  1077. DetailList.LotNo = drs[j]["LotNo"].ToString();
  1078. ass.detail.Add(DetailList);
  1079. }
  1080. asn.Add(ass);
  1081. }
  1082. string input = JsonConvert.SerializeObject(asn);
  1083. string APIURL = ConfigurationManager.ConnectionStrings["APIURL"].ConnectionString + "OutsourcingRejectDocNoTrans/Create";
  1084. string result = HttpPost(APIURL, input);
  1085. JObject Obj = (JObject)JsonConvert.DeserializeObject(result);//或者JObject jo = JObject.Parse(jsonText);
  1086. string MessAge = Obj["Message"].ToString();
  1087. string Success = Obj["Success"].ToString();
  1088. if (Success.ToUpper() == "FALSE")
  1089. {
  1090. msg = MessAge;
  1091. }
  1092. return msg;
  1093. }
  1094. public static string HttpPost(string url, string body)
  1095. {
  1096. try
  1097. {
  1098. Encoding encoding = Encoding.UTF8;
  1099. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
  1100. request.Method = "POST";
  1101. request.Accept = "application/json, text/javascript, */*"; //"text/html, application/xhtml+xml, */*";
  1102. request.ContentType = "application/json; charset=utf-8";
  1103. byte[] buffer = encoding.GetBytes(body);
  1104. request.ContentLength = buffer.Length;
  1105. request.GetRequestStream().Write(buffer, 0, buffer.Length);
  1106. HttpWebResponse response = (HttpWebResponse)request.GetResponse();
  1107. using (StreamReader reader = new StreamReader(response.GetResponseStream(), encoding))
  1108. {
  1109. return reader.ReadToEnd();
  1110. }
  1111. }
  1112. catch (WebException ex)
  1113. {
  1114. throw new Exception(ex.Message);
  1115. }
  1116. }
  1117. /// <summary>
  1118. /// 删除拒收单
  1119. /// </summary>
  1120. /// <param name="keyValue">传入ID</param>
  1121. /// <returns></returns>
  1122. public string DelectRejection(string keyValue)
  1123. {
  1124. //站点信息
  1125. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1126. string msg = "";
  1127. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  1128. string sql = string.Empty;
  1129. sql = string.Format(@"DELETE FROM dbo.ICSDeliveryNotice WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  1130. try
  1131. {
  1132. SqlHelper.ExecuteNonQuery(sql);
  1133. }
  1134. catch (Exception ex)
  1135. {
  1136. throw new Exception(ex.Message);
  1137. }
  1138. return msg;
  1139. }
  1140. /// <summary>
  1141. /// 删除委外拒收单
  1142. /// </summary>
  1143. /// <param name="keyValue">传入ID</param>
  1144. /// <returns></returns>
  1145. public string DelectWWRejection(string keyValue)
  1146. {
  1147. //站点信息
  1148. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1149. string msg = "";
  1150. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  1151. string sql = string.Empty;
  1152. sql = string.Format(@"DELETE FROM dbo.ICSODeliveryNotice WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  1153. try
  1154. {
  1155. SqlHelper.ExecuteNonQuery(sql);
  1156. }
  1157. catch (Exception ex)
  1158. {
  1159. throw new Exception(ex.Message);
  1160. }
  1161. return msg;
  1162. }
  1163. public DataTable GetInventoryInspection(ref Pagination jqgridparam, string InvCode, int SampleQuantity, string ResultINp)
  1164. {
  1165. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1166. DataTable dt = new DataTable();
  1167. List<DbParameter> parameter = new List<DbParameter>();
  1168. string sql = string.Empty;
  1169. if (ResultINp == "")
  1170. {
  1171. sql = "SELECT 1 AS NUM INTO #TEmpType";
  1172. for (int i = 2; i <= SampleQuantity; i++)
  1173. {
  1174. sql += @" UNION
  1175. SELECT " + i + " AS NUM";
  1176. }
  1177. sql += @" select c.ID,a.GroupCode,a.GroupName,c.InspectionID,b.ListCode, b.ListName,b.Unit,b.SetValueMax,b.SetValueMin,c.SetValue,CASE WHEN c.Result='0' THEN '不合格' when ISNULL(c.Result,'')='' THEN '' ELSE '合格' END AS Result
  1178. INTO #TEmpTypedetail from ICSInventoryInspectionGroup a
  1179. left join ICSInventoryInspectionList b on a.ID=b.InvGroupID and a.WorkPoint=b.WorkPoint
  1180. left join ICSInspectionDetail c on b.ListCode=c.ListCode and b.ListName=c.ListName and b.WorkPoint=c.WorkPoint
  1181. where a.InvCode='{0}' and b.Enable='1' and a.WorkPoint='{1}'
  1182. SELECT a.NUM, NEWID() AS ID,b.GroupCode,b.GroupName,b.InspectionID,b.ListCode, b.ListName,b.Unit,b.SetValueMax,b.SetValueMin,b.SetValue,CASE WHEN b.Result='0' THEN '' when ISNULL(b.Result,'')='' THEN '' ELSE '' END AS Result INTO ##SUMCount FROM #TEmpType a ,#TEmpTypedetail b ORDER BY a.NUM,b.GroupCode ASC
  1183. ";
  1184. sql = string.Format(sql, InvCode, WorkPoint);
  1185. return SqlHelper.FindTablePageBySql_OtherTemp(sql.ToString(), " " + "##SUMCount" + " ", " DROP TABLE #TEmpType;DROP TABLE #TEmpTypedetail;DROP TABLE ##SUMCount", parameter.ToArray(), ref jqgridparam);
  1186. }
  1187. else
  1188. {
  1189. sql += @" select c.EATTRIBUTE1 as NUM, c.ID,a.GroupCode,a.GroupName,c.InspectionID,b.ListCode, b.ListName,b.Unit,b.SetValueMax,b.SetValueMin,c.SetValue,CASE WHEN c.Result='0' THEN '不合格' when ISNULL(c.Result,'')='' THEN '' ELSE '合格' END AS Result
  1190. from ICSInventoryInspectionGroup a
  1191. left join ICSInventoryInspectionList b on a.ID=b.InvGroupID and a.WorkPoint=b.WorkPoint
  1192. left join ICSInspectionDetail c on b.ListCode=c.ListCode and b.ListName=c.ListName and b.WorkPoint=c.WorkPoint
  1193. where a.InvCode='{0}' and b.Enable='1' and a.WorkPoint='{1}'
  1194. ";
  1195. sql = string.Format(sql, InvCode, WorkPoint);
  1196. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1197. }
  1198. }
  1199. public string SaveICSInspectionDetail(string ICSMTDOC, string InvCode, string ResultINp)
  1200. {
  1201. string msg = "";
  1202. try
  1203. {
  1204. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1205. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1206. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1207. string sql = string.Empty;
  1208. JArray res = (JArray)JsonConvert.DeserializeObject(ICSMTDOC);
  1209. bool ISOK = false;
  1210. string ID = string.Empty;
  1211. foreach (var item in res)
  1212. {
  1213. JObject jo = (JObject)item;
  1214. ID = jo["InspectionID"].ToString();
  1215. if (string.IsNullOrWhiteSpace(ResultINp))
  1216. {
  1217. sql += @"
  1218. INSERT INTO dbo.ICSInspectionDetail
  1219. ( ID ,InspectionID ,ListCode ,ListName ,
  1220. Unit ,SetValueMax ,SetValueMin ,SetValue ,Result, MUSER ,MUSERName ,MTIME, WorkPoint,GroupCode,GroupName,EATTRIBUTE1)
  1221. values(newid(),'{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}',getdate(),'{10}','{11}','{12}','{13}')";
  1222. sql = string.Format(sql, jo["InspectionID"].ToString(), jo["ListCode"].ToString(), jo["ListName"].ToString(), jo["Unit"].ToString(), jo["SetValueMax"].ToString(), jo["SetValueMin"].ToString(), jo["SetValue"].ToString(), jo["Result"].ToString(), MUSER, MUSERNAME, WorkPoint, jo["GroupCode"].ToString(), jo["GroupName"].ToString(), jo["NUM"].ToString());
  1223. }
  1224. else
  1225. {
  1226. sql += @" update ICSInspectionDetail set InspectionID='{0}',ListCode='{1}',ListName='{2}', Unit='{3}' ,SetValueMax='{4}' ,SetValueMin='{5}' ,SetValue='{6}' ,Result='{7}', MUSER='{8}' ,MUSERName='{9}' ,MTIME=getdate(), WorkPoint='{10}', GroupCode='{11}', GroupName='{12}',EATTRIBUTE1='{14}' where ID='{13}'";
  1227. sql = string.Format(sql, jo["InspectionID"].ToString(), jo["ListCode"].ToString(), jo["ListName"].ToString(), jo["Unit"].ToString(), jo["SetValueMax"].ToString(), jo["SetValueMin"].ToString(), jo["SetValue"].ToString(), jo["Result"].ToString(), MUSER, MUSERNAME, WorkPoint, jo["GroupCode"].ToString(), jo["GroupName"].ToString(), jo["ID"].ToString(), jo["NUM"].ToString());
  1228. }
  1229. if (jo["Result"].ToString() == "0")
  1230. {
  1231. ISOK = true;
  1232. }
  1233. }
  1234. if (ISOK == true)
  1235. {
  1236. sql += @" update ICSInspection set Result='{0}' where ID='{1}'";
  1237. sql = string.Format(sql, 0, ID);
  1238. }
  1239. else
  1240. {
  1241. sql += @" update ICSInspection set Result='{0}' where ID='{1}'";
  1242. sql = string.Format(sql, 1, ID);
  1243. }
  1244. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  1245. {
  1246. }
  1247. else
  1248. {
  1249. msg = "绑定失败";
  1250. }
  1251. }
  1252. catch (Exception ex)
  1253. {
  1254. msg = ex.Message;
  1255. }
  1256. return msg;
  1257. }
  1258. /// <summary>
  1259. /// 上传招标文件
  1260. /// </summary>
  1261. /// <param name="keyValue"></param>
  1262. /// <returns></returns>
  1263. public int InsertICSInspectionFile(string ID,string UploadfileName, string fileName)
  1264. {
  1265. DataTable dt = new DataTable();
  1266. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1267. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1268. string MUSERName = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1269. string sql = "";
  1270. sql += string.Format(@"Insert into ICSInspectionFile(ID,InspectionID,FileCode,FileName,MUSER,MUSERName,MTIME,WorkPoint) values(NEWID(),'{0}','{1}','{2}','{3}','{4}',GetDate(),'{5}')", ID, UploadfileName, fileName, MUSER, MUSERName, WorkPoint);
  1271. sql += "\r\n";
  1272. StringBuilder Str = new StringBuilder(sql);
  1273. return Repository().ExecuteBySql(Str);
  1274. }
  1275. public DataTable GetICSInspection8(ref Pagination jqgridparam, string queryJson)
  1276. {
  1277. //string ERPSign = Configs.GetValue("ERPSign");
  1278. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1279. DataTable dt = new DataTable();
  1280. var queryParam = queryJson.ToJObject();
  1281. List<DbParameter> parameter = new List<DbParameter>();
  1282. string sql = string.Empty;
  1283. sql = @" select DISTINCT
  1284. a.ID as DHID,
  1285. d.ID ,
  1286. h.ID as JYID,
  1287. a.DNCode ,
  1288. a.Sequence ,
  1289. a.ASNCode ,
  1290. --l.POCode,
  1291. c.InvCode ,
  1292. c.InvName ,
  1293. c.INVSTD ,
  1294. c.ClassName,
  1295. CAST(d.Quantity as decimal(18,4)) as AllNumber,
  1296. CAST(ISNULL(h.QualifiedQuantity, d.Quantity)as decimal(18,4))as YLOTQTY ,
  1297. CAST(ISNULL(h.UnqualifiedQuantity, 0) as decimal(18,4)) as NLOTQTY,
  1298. CAST(ISNULL(h.WaiveQuantity, 0) as decimal(18,4)) as SpecialQTY,
  1299. CAST(ISNULL(h.SampleQuantity, 0) as decimal(18,4)) as SampleQuantity,
  1300. c.InvUnit ,
  1301. d.LotNo ,
  1302. g.BadReasonDesc as BadReasonDesc ,
  1303. g.BadReasonCode as BRCodeValue,
  1304. j.BadCode as BCCodeValue,
  1305. j.BadDesc as BadDesc,
  1306. k.ContainerID,
  1307. isnull(h.MUSERName,'') MUSERName,
  1308. CONVERT(VARCHAR(100),d.ProductDate,23) as ProductTime,
  1309. CONVERT(VARCHAR(100),a.CreateDateTime,23) as CreateDateTime,
  1310. CONVERT(VARCHAR(100),h.MTIME,23) as MTIME,
  1311. CASE WHEN isnull(h.ID,'') =''THEN '' ELSE '' END AS TestState,
  1312. a.VenCode,
  1313. m.VenName,
  1314. isnull(h.MUSER,'') as Surveyor,
  1315. h.MUSERName as ProvingTime
  1316. ,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4 ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
  1317. ,CASE WHEN h.Result='0' THEN '' when ISNULL(h.Result,'')='' THEN '' ELSE '' END AS Result,
  1318. n.FileName
  1319. FROM ICSDeliveryNotice a
  1320. --inner JOIN ICSASNDetail b ON a.ASNCode=b.ASNCode AND a.WorkPoint=b.WorkPoint
  1321. left join ICSInventoryLotDetail e on a.DNCode=e.TransCode and a.Sequence=e.TransSequence and a.WorkPoint=e.WorkPoint
  1322. inner JOIN ICSInventory c ON a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint and c.InvIQC='1'
  1323. inner JOIN ICSInventoryLot d ON e.LotNo=d.LotNo AND a.InvCode=d.InvCode AND a.WorkPoint=d.WorkPoint and d.type='7'
  1324. LEFT JOIN dbo.ICSInspection h ON h.LotNo=d.LotNo AND h.WorkPoint=a.WorkPoint and Enable='1'
  1325. left join ICSBadReason g on h.BRCode =g.BadReasonCode and h.WorkPoint=g.WorkPoint
  1326. left join ICSBadCode j on h.BCCode =j.BadCode and h.WorkPoint=j.WorkPoint
  1327. LEFT JOIN ICSContainerLot k ON d.LotNo=k.LotNo AND a.WorkPoint=k.WorkPoint
  1328. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  1329. left join dbo.ICSVendor m on a.VenCode=m.VenCode and a.WorkPoint=m.WorkPoint
  1330. left join ICSInspectionFile n on h.id=n.InspectionID and h.WorkPoint=n.WorkPoint
  1331. where d.LotNo is not null and a.DNType='1' {0}
  1332. ";
  1333. string wheresql = "";
  1334. if (!string.IsNullOrWhiteSpace(queryJson))
  1335. {
  1336. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1337. {
  1338. wheresql += " and a.DNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1339. }
  1340. //if (!string.IsNullOrWhiteSpace(queryParam["ASNCode"].ToString()))
  1341. //{
  1342. // wheresql += " and a.ASNCode like '%" + queryParam["ASNCode"].ToString() + "%' ";
  1343. //}
  1344. //if (!string.IsNullOrWhiteSpace(queryParam["CaiGouCode"].ToString()))
  1345. //{
  1346. // wheresql += " and l.POCode like '%" + queryParam["CaiGouCode"].ToString() + "%' ";
  1347. //}
  1348. if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
  1349. {
  1350. wheresql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
  1351. }
  1352. if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
  1353. {
  1354. wheresql += " and m.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
  1355. }
  1356. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1357. {
  1358. wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1359. }
  1360. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1361. {
  1362. wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1363. }
  1364. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1365. {
  1366. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1367. }
  1368. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  1369. {
  1370. string ReleaseState = queryParam["ReleaseState"].ToString();
  1371. if (ReleaseState == "1")
  1372. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
  1373. else if (ReleaseState == "0")
  1374. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
  1375. else
  1376. wheresql += " ";
  1377. }
  1378. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  1379. {
  1380. string selEnableShow = queryParam["selEnableShow"].ToString();
  1381. if (selEnableShow == "1")
  1382. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
  1383. else if (selEnableShow == "0")
  1384. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
  1385. }
  1386. }
  1387. sql = string.Format(sql, wheresql, WorkPoint);
  1388. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1389. }
  1390. public DataTable GetICSInspection9(ref Pagination jqgridparam, string queryJson)
  1391. {
  1392. DataTable dt = new DataTable();
  1393. var queryParam = queryJson.ToJObject();
  1394. List<DbParameter> parameter = new List<DbParameter>();
  1395. #region
  1396. string sql = @"
  1397. select
  1398. a.ID as DHID,
  1399. d.ID ,
  1400. h.ID as JYID,
  1401. a.ODNCode as DNCode ,
  1402. a.Sequence ,
  1403. a.OASNCode ,
  1404. c.InvCode ,
  1405. c.InvName ,
  1406. c.INVSTD ,
  1407. c.ClassName,
  1408. f.BatchCode ,
  1409. CAST(d.Quantity as NUMERIC(10,4)) as AllNumber,
  1410. CAST(ISNULL(h.QualifiedQuantity, d.Quantity)as NUMERIC(10,4))as YLOTQTY ,
  1411. CAST(ISNULL(h.UnqualifiedQuantity, 0) as NUMERIC(10,4)) as NLOTQTY,
  1412. CAST(ISNULL(h.WaiveQuantity, 0) as NUMERIC(10,4)) as SpecialQTY,
  1413. CAST(ISNULL(h.SampleQuantity, 0) as decimal(18,4)) as SampleQuantity,
  1414. c.InvUnit ,
  1415. d.LotNo ,
  1416. g.BadReasonDesc as BadReasonDesc ,
  1417. g.BadReasonCode as BRCodeValue,
  1418. j.BadCode as BCCodeValue,
  1419. j.BadDesc as BadDesc,
  1420. k.ContainerID,
  1421. isnull(h.MUSERName,'') MUSERName,
  1422. CONVERT(VARCHAR(100),d.ProductDate,23) as ProductTime,
  1423. CONVERT(VARCHAR(100),h.MTIME,23) as MTIME,
  1424. CASE WHEN isnull(h.ID,'') =''THEN '' ELSE '' END AS TestState
  1425. FROM ICSODeliveryNotice a
  1426. inner join ICSInventoryLotDetail e on e.TransCode =a.ODNCode AND e.TransSequence=a.Sequence AND e.WorkPoint=a.WorkPoint
  1427. inner JOIN ICSInventoryLot d ON d.LotNo=e.LotNo and d.WorkPoint=e.WorkPoint and d.type='8'
  1428. inner JOIN ICSInventory c ON a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint and c.InvIQC='1'
  1429. LEFT JOIN dbo.ICSInspection h ON h.LotNo=d.LotNo AND h.WorkPoint=d.WorkPoint
  1430. left join ICSBadReason g on h.BRCode =g.BadReasonCode and h.WorkPoint=g.WorkPoint
  1431. left join ICSBadCode j on h.BCCode =j.BadCode and h.WorkPoint=j.WorkPoint
  1432. LEFT JOIN ICSContainerLot k ON d.LotNo=k.LotNo AND d.WorkPoint=k.WorkPoint
  1433. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  1434. where 1=1 {0}";
  1435. #endregion
  1436. string wheresql = "";
  1437. if (!string.IsNullOrWhiteSpace(queryJson))
  1438. {
  1439. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1440. {
  1441. wheresql += " and a.ODNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1442. }
  1443. //if (!string.IsNullOrWhiteSpace(queryParam["ASNCode"].ToString()))
  1444. //{
  1445. // wheresql += " and a.OASNCode like '%" + queryParam["ASNCode"].ToString() + "%' ";
  1446. //}
  1447. //if (!string.IsNullOrWhiteSpace(queryParam["CaiGouCode"].ToString()))
  1448. //{
  1449. // wheresql += " and l.OOCode like '%" + queryParam["CaiGouCode"].ToString() + "%' ";
  1450. //}
  1451. if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
  1452. {
  1453. wheresql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
  1454. }
  1455. if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
  1456. {
  1457. wheresql += " and m.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
  1458. }
  1459. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1460. {
  1461. wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1462. }
  1463. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1464. {
  1465. wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1466. }
  1467. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1468. {
  1469. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1470. }
  1471. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  1472. {
  1473. string ReleaseState = queryParam["ReleaseState"].ToString();
  1474. if (ReleaseState == "1")
  1475. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
  1476. else if (ReleaseState == "0")
  1477. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
  1478. else
  1479. wheresql += " ";
  1480. }
  1481. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  1482. {
  1483. string selEnableShow = queryParam["selEnableShow"].ToString();
  1484. if (selEnableShow == "1")
  1485. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
  1486. else if (selEnableShow == "0")
  1487. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
  1488. }
  1489. }
  1490. sql = string.Format(sql, wheresql);
  1491. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1492. }
  1493. }
  1494. }