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.

1623 lines
97 KiB

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