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.

7088 lines
437 KiB

3 weeks 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.DHAY
  22. {
  23. public class DHICSRCVIQCsApp : 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 = @"
  41. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempLLData_1'))
  42. drop table #TempLLData_1
  43. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempLLData_1_1'))
  44. drop table #TempLLData_1_1
  45. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_1'))
  46. drop table #TempIcsinsp_1
  47. select ID,QualifiedQuantity,UnqualifiedQuantity,WaiveQuantity,
  48. SampleQuantity,MUSERName,MTIME,Result,LotNo,BCCode,workpoint,BRCode
  49. into #TempIcsinsp_1
  50. from dbo.ICSInspection
  51. where workpoint='" + WorkPoint + @"' and Enable='1'
  52. select DISTINCT
  53. a.ID as DHID,
  54. d.ID ,
  55. h.ID as JYID,
  56. a.DNCode ,
  57. -- a.Sequence ,
  58. a.ASNCode ,
  59. l.POCode,
  60. c.InvCode ,
  61. c.InvName ,
  62. c.INVSTD ,
  63. c.ClassName,
  64. c.EATTRIBUTE3 as InvEATTRIBUTE3,
  65. CAST(b.DNQuantity as decimal(18,4)) as AllNumber,
  66. CAST(ISNULL(h.QualifiedQuantity, b.DNQuantity)as decimal(18,4))as YLOTQTY ,
  67. CAST(ISNULL(h.UnqualifiedQuantity, 0) as decimal(18,4)) as NLOTQTY,
  68. CAST(ISNULL(h.WaiveQuantity, 0) as decimal(18,4)) as SpecialQTY,
  69. CASE WHEN isnull(task.ValueParameters,'') =''THEN '否' ELSE '是' END AS IsPrint,
  70. --CAST(ISNULL(h.SampleQuantity, 0) as decimal(18,4)) as SampleQuantity,
  71. c.InvUnit ,
  72. b.LotNo ,
  73. g.BadReasonDesc as BadReasonDesc ,
  74. g.BadReasonCode as BRCodeValue,
  75. j.BadCode as BCCodeValue,
  76. j.BadDesc as BadDesc,
  77. k.ContainerID,
  78. q.ContainerCode,
  79. isnull(h.MUSERName,'') MUSERName,
  80. CONVERT(VARCHAR(100),d.ProductDate,120) as ProductTime,
  81. CONVERT(VARCHAR(100),a.CreateDateTime,120) as CreateDateTime,
  82. CONVERT(VARCHAR(100),h.MTIME,120) as MTIME,
  83. CASE WHEN isnull(h.ID,'') =''THEN '' ELSE '' END AS TestState,
  84. a.VenCode,
  85. m.VenName,
  86. isnull(h.MUSERName,'') as Surveyor,
  87. h.MTime as ProvingTime
  88. ,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
  89. ,CASE WHEN h.Result='0' THEN '' when ISNULL(h.Result,'')='' THEN '' ELSE '' END AS Result,
  90. n.FileName
  91. ,CASE WHEN isnull(h.ID,'') ='' and s.Type='Quantity' THEN isnull(p.SampleQuantity,0)
  92. WHEN isnull(h.ID,'') ='' and s.Type='Ratio' THEN isnull(p.SampleQuantity,0)*DNQuantity ELSE CAST(ISNULL(h.SampleQuantity, 0) as decimal(18,4)) END AS SampleQuantity
  93. ,o.Editable
  94. ,(CASE ISNULL((SELECT COUNT(1) FROM dbo.ICSInspection hH2
  95. WHERE hH2.LotNo=b.LotNo AND hH2.WorkPoint=b.WorkPoint),0)
  96. WHEN 0 THEN '' WHEN 1 THEN '是' else '否' end ) IsFirstCK
  97. ,case d.EATTRIBUTE6 when '1' then '是' else '否' end IsUrgent,c.InvIQC
  98. into #TempLLData_1
  99. FROM ICSDeliveryNotice a
  100. inner JOIN ICSASNDetail b ON a.ASNCode=b.ASNCode AND a.WorkPoint=b.WorkPoint
  101. inner JOIN ICSInventory c ON a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint --and c.InvIQC='1'
  102. inner JOIN ICSInventoryLot d ON b.LotNo=d.LotNo AND a.ExtensionID=d.ExtensionID AND a.InvCode=d.InvCode AND b.WorkPoint=d.WorkPoint
  103. left join ICSInventoryLotDetail e on d.LotNo=e.LotNo and d.WorkPoint=e.WorkPoint
  104. LEFT JOIN #TempIcsinsp_1 h ON h.LotNo=b.LotNo AND h.WorkPoint=b.WorkPoint
  105. LEFT JOIN (SELECT DISTINCT ValueParameters FROM Sys_LableTask) task ON task.ValueParameters=h.ID
  106. left join ICSBadReason g on h.BRCode =g.BadReasonCode and h.WorkPoint=g.WorkPoint
  107. left join ICSBadCode j on h.BCCode =j.BadCode and h.WorkPoint=j.WorkPoint
  108. LEFT JOIN ICSContainerLot k ON b.LotNo=k.LotNo AND b.WorkPoint=k.WorkPoint
  109. LEFT JOIN ICSContainer q on k.ContainerID=q.ContainerID AND k.WorkPoint=q.WorkPoint
  110. inner JOIN ICSPurchaseOrder l ON e.TransCode =l.POCode AND e.TransSequence=l.Sequence AND a.PODetailID=l.PODetailID AND d.WorkPoint=l.WorkPoint
  111. left join ICSExtension f on d.ExtensionID=f.ID and d.WorkPoint=f.WorkPoint
  112. left join dbo.ICSVendor m on a.VenCode=m.VenCode and a.WorkPoint=m.WorkPoint
  113. left join ICSInspectionFile n on h.id=n.InspectionID and h.WorkPoint=n.WorkPoint
  114. LEFT JOIN ICSInventoryInspectionRulesGroup o ON a.InvCode=o.InvCode AND a.WorkPoint=o.WorkPoint
  115. left JOIN ICSInspectionRulesGroup s ON o.RulesCode=s.RulesCode AND o.WorkPoint=s.WorkPoint
  116. LEFT JOIN ICSInventoryInspectionRuleslist p ON o.id=p.invrulesid AND o.WorkPoint=p.WorkPoint AND b.DNQuantity BETWEEN p.SetValueMin AND p.SetValueMax
  117. where b.LotNo is not null and a.DNType='1' AND a.WorkPoint='{1}' {0}
  118. select * into #TempLLData_1_1 from #TempLLData_1 where InvIQC='1'
  119. ";
  120. }
  121. else
  122. {
  123. sql = @" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempLLData_1'))
  124. drop table #TempLLData_1
  125. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_1'))
  126. drop table #TempIcsinsp_1
  127. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempLLData_1_1'))
  128. drop table #TempLLData_1_1
  129. select ID,QualifiedQuantity,UnqualifiedQuantity,WaiveQuantity,SampleQuantity,
  130. MUSERName,MTIME,Result,LotNo,BCCode,workpoint,BRCode
  131. into #TempIcsinsp_1
  132. from dbo.ICSInspection
  133. where workpoint='" + WorkPoint + @"' and Enable='1'
  134. select DISTINCT
  135. a.ID as DHID,
  136. d.ID ,
  137. h.ID as JYID,
  138. a.DNCode ,
  139. a.Sequence ,
  140. a.ASNCode ,
  141. l.POCode,
  142. c.InvCode ,
  143. c.InvName ,
  144. c.INVSTD ,
  145. c.ClassName,
  146. c.EATTRIBUTE3 as InvEATTRIBUTE3,
  147. CAST(d.Quantity as decimal(18,4)) as AllNumber,
  148. CAST(ISNULL(h.QualifiedQuantity, d.Quantity)as decimal(18,4))as YLOTQTY ,
  149. CAST(ISNULL(h.UnqualifiedQuantity, 0) as decimal(18,4)) as NLOTQTY,
  150. CAST(ISNULL(h.WaiveQuantity, 0) as decimal(18,4)) as SpecialQTY,
  151. CASE WHEN isnull(task.ValueParameters,'') =''THEN '否' ELSE '是' END AS IsPrint,
  152. -- CAST(ISNULL(h.SampleQuantity, 0) as decimal(18,4)) as SampleQuantity,
  153. c.InvUnit ,
  154. d.LotNo ,
  155. g.BadReasonDesc as BadReasonDesc ,
  156. g.BadReasonCode as BRCodeValue,
  157. j.BadCode as BCCodeValue,
  158. j.BadDesc as BadDesc,
  159. k.ContainerID,
  160. isnull(h.MUSERName,'') MUSERName,
  161. CONVERT(VARCHAR(100),d.ProductDate,120) as ProductTime,
  162. CONVERT(VARCHAR(100),a.CreateDateTime,120) as CreateDateTime,
  163. CONVERT(VARCHAR(100),h.MTIME,120) as MTIME,
  164. CASE WHEN isnull(h.ID,'') =''THEN '' ELSE '' END AS TestState,
  165. a.VenCode,
  166. m.VenName,
  167. isnull(h.MUSERName,'') as Surveyor,
  168. h.MTime as ProvingTime
  169. ,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
  170. ,CASE WHEN h.Result='0' THEN '' when ISNULL(h.Result,'')='' THEN '' ELSE '' END AS Result,
  171. n.FileName
  172. ,CASE WHEN isnull(h.ID,'') ='' and s.Type='Quantity' THEN isnull(p.SampleQuantity,0)
  173. WHEN isnull(h.ID,'') ='' and s.Type='Ratio' THEN isnull(p.SampleQuantity,0)*DNQuantity ELSE CAST(ISNULL(h.SampleQuantity, 0) as decimal(18,4)) END AS SampleQuantity
  174. ,o.Editable
  175. ,(CASE ISNULL((SELECT COUNT(1) FROM dbo.ICSInspection hH2
  176. WHERE hH2.LotNo=d.LotNo AND hH2.WorkPoint=a.WorkPoint),0)
  177. WHEN 0 THEN '' WHEN 1 THEN '是' else '否' end ) IsFirstCK
  178. , case d.EATTRIBUTE6 when '1' then '是' else '否' end IsUrgent,c.InvIQC
  179. into #TempLLData_1
  180. FROM ICSDeliveryNotice a
  181. --inner JOIN ICSASNDetail b ON a.ASNCode=b.ASNCode AND a.WorkPoint=b.WorkPoint
  182. left join ICSInventoryLotDetail e on a.DNCode=e.TransCode and a.Sequence=e.TransSequence and a.WorkPoint=e.WorkPoint
  183. inner JOIN ICSInventory c ON a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint and c.InvIQC='1'
  184. inner JOIN ICSInventoryLot d ON e.LotNo=d.LotNo AND a.InvCode=d.InvCode AND a.WorkPoint=d.WorkPoint
  185. LEFT JOIN #TempIcsinsp_1 h ON h.LotNo=d.LotNo AND h.WorkPoint=a.WorkPoint
  186. LEFT JOIN (SELECT DISTINCT ValueParameters FROM Sys_LableTask) task ON task.ValueParameters=h.ID
  187. left join ICSBadReason g on h.BRCode =g.BadReasonCode and h.WorkPoint=g.WorkPoint
  188. left join ICSBadCode j on h.BCCode =j.BadCode and h.WorkPoint=j.WorkPoint
  189. LEFT JOIN ICSContainerLot k ON d.LotNo=k.LotNo AND a.WorkPoint=k.WorkPoint
  190. inner JOIN ICSPurchaseOrder l ON a.PODetailID=l.PODetailID AND a.WorkPoint=l.WorkPoint
  191. left join ICSExtension f on d.ExtensionID=f.ID and d.WorkPoint=f.WorkPoint
  192. left join dbo.ICSVendor m on a.VenCode=m.VenCode and a.WorkPoint=m.WorkPoint
  193. left join ICSInspectionFile n on h.id=n.InspectionID and h.WorkPoint=n.WorkPoint
  194. LEFT JOIN ICSInventoryInspectionRulesGroup o ON a.InvCode=o.InvCode AND a.WorkPoint=o.WorkPoint
  195. left JOIN ICSInspectionRulesGroup s ON o.RulesCode=s.RulesCode AND o.WorkPoint=s.WorkPoint
  196. LEFT JOIN ICSInventoryInspectionRuleslist p ON o.id=p.invrulesid AND o.WorkPoint=p.WorkPoint AND d.Quantity BETWEEN p.SetValueMax AND p.SetValueMin
  197. where d.LotNo is not null and a.DNType='1' AND a.WorkPoint='{1}' {0}
  198. select * into #TempLLData_1_1 from #TempLLData_1
  199. ";
  200. }
  201. string wheresql = "";
  202. if (!string.IsNullOrWhiteSpace(queryJson))
  203. {
  204. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  205. {
  206. wheresql += " and a.DNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  207. }
  208. if (!string.IsNullOrWhiteSpace(queryParam["ASNCode"].ToString()))
  209. {
  210. wheresql += " and a.ASNCode like '%" + queryParam["ASNCode"].ToString() + "%' ";
  211. }
  212. if (!string.IsNullOrWhiteSpace(queryParam["CaiGouCode"].ToString()))
  213. {
  214. wheresql += " and l.POCode like '%" + queryParam["CaiGouCode"].ToString() + "%' ";
  215. }
  216. if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
  217. {
  218. wheresql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
  219. }
  220. if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
  221. {
  222. wheresql += " and m.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
  223. }
  224. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  225. {
  226. wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  227. }
  228. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  229. {
  230. wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  231. }
  232. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  233. {
  234. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  235. }
  236. if (!string.IsNullOrWhiteSpace(queryParam["TimeFrom"].ToString()))
  237. {
  238. wheresql += " and a.CreateDateTime >= '" + queryParam["TimeFrom"].ToString() + "' ";
  239. }
  240. if (!string.IsNullOrWhiteSpace(queryParam["TimeArrive"].ToString()))
  241. {
  242. wheresql += " and a.CreateDateTime <= '" + queryParam["TimeArrive"].ToString() + "' ";
  243. }
  244. if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
  245. {
  246. wheresql += " and b.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
  247. }
  248. if (!string.IsNullOrWhiteSpace(queryParam["selIsUrgent"].ToString()))
  249. {
  250. wheresql += " and case d.EATTRIBUTE6 when '1' then '是' else '否' end = '" + queryParam["selIsUrgent"].ToString() + "' ";
  251. }
  252. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  253. {
  254. string ReleaseState = queryParam["ReleaseState"].ToString();
  255. if (ReleaseState == "1")
  256. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
  257. else if (ReleaseState == "0")
  258. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
  259. else
  260. wheresql += " ";
  261. }
  262. if (!string.IsNullOrWhiteSpace(queryParam["selIsPrint"].ToString()))
  263. {
  264. string printState = queryParam["selIsPrint"].ToString();
  265. if (printState == "否")
  266. wheresql += " and isnull(task.ValueParameters,'') ='' ";
  267. else if (printState == "是")
  268. wheresql += " and isnull(task.ValueParameters,'') <>''";
  269. }
  270. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  271. {
  272. string selEnableShow = queryParam["selEnableShow"].ToString();
  273. if (selEnableShow == "1")
  274. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
  275. else if (selEnableShow == "0")
  276. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
  277. }
  278. }
  279. sql = string.Format(sql, wheresql, WorkPoint);
  280. return Repository().FindTablePageBySql_OtherTemp(sql, "#TempLLData_1_1",
  281. @" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempLLData_1'))
  282. drop table #TempLLData_1
  283. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_1'))
  284. drop table #TempIcsinsp_1
  285. if exists(select * from tempdb..sysobjects where id = object_id('tempdb..#TempLLData_1_1'))
  286. drop table #TempLLData_1_1 ",
  287. "connstr", parameter.ToArray(), ref jqgridparam);
  288. // return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  289. }
  290. public DataTable GetInspectionFile(ref Pagination jqgridparam, string queryJson, string JYID)
  291. {
  292. var queryParam = queryJson.ToJObject();
  293. List<DbParameter> parameter = new List<DbParameter>();
  294. string sql = @"SELECT * FROM dbo.ICSInspectionFile WHERE InspectionID='{0}'";
  295. sql = string.Format(sql, JYID);
  296. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  297. }
  298. /// <summary>
  299. /// 根据批次获取检验信息
  300. /// </summary>
  301. /// <param name="jqgridparam"></param>
  302. /// <param name="queryJson"></param>
  303. /// <returns></returns>
  304. public DataTable GetICSInspectionBatchCode(ref Pagination jqgridparam, string queryJson)
  305. {
  306. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  307. DataTable dt = new DataTable();
  308. var queryParam = queryJson.ToJObject();
  309. List<DbParameter> parameter = new List<DbParameter>();
  310. string sql = string.Empty;
  311. sql = @" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempLLData_1'))
  312. drop table #TempLLData_1
  313. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempLLData_1_1'))
  314. drop table #TempLLData_1_1
  315. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_1'))
  316. drop table #TempIcsinsp_1
  317. select ID,QualifiedQuantity,UnqualifiedQuantity,WaiveQuantity,SampleQuantity,MUSERName,MTIME,Result,LotNo,BCCode,workpoint,BRCode
  318. into #TempIcsinsp_1
  319. from dbo.ICSInspection
  320. where workpoint='{1}' and Enable='1'
  321. SELECT a.ASNCode,A.DNCode,a.Sequence,e.BatchCode,l.POCode,j.InvCode ,j.InvName ,j.INVSTD ,j.InvUnit ,j.InvDesc,a.WorkPoint,n.VenName,n.VenCode,c.MTIME as CreateDateTime,CAST(ISNULL(SUM(c.Quantity),0)AS DECIMAL (18,4) ) as AllNumber, CAST(ISNULL(SUM(h.QualifiedQuantity), 0)as decimal(18,4))as YLOTQTY , CAST ( ISNULL( SUM(h.UnqualifiedQuantity), 0 ) AS DECIMAL (18, 4) ) AS NLOTQTY,CAST ( ISNULL( SUM(h.WaiveQuantity), 0 ) AS DECIMAL (18, 4) ) AS SpecialQTY,CAST ( ISNULL( SUM(h.SampleQuantity), 0 ) AS DECIMAL (18, 4) ) AS SampleQuantity into #TempLLData_1
  322. FROM ICSDeliveryNotice a
  323. INNER JOIN ICSInventoryLot b ON a.ExtensionID=b.ExtensionID AND a.WorkPoint=b.WorkPoint
  324. INNER JOIN ICSASNDetail c ON c.LotNo=b.LotNo AND c.WorkPoint=b.WorkPoint AND a.ASNCode=c.ASNCode
  325. left JOIN #TempIcsinsp_1 h ON c.LotNo=h.LotNo AND h.WorkPoint= c.WorkPoint
  326. LEFT JOIN (SELECT DISTINCT ValueParameters FROM Sys_LableTask) task ON task.ValueParameters=h.ID
  327. LEFT JOIN ICSExtension e ON e.ID=a.ExtensionID AND e.WorkPoint =a.WorkPoint
  328. LEFT JOIN ICSInventoryLotDetail m ON m.LotNo= c.LotNo AND m.WorkPoint= c.WorkPoint
  329. INNER JOIN ICSPurchaseOrder l ON m.TransCode = l.POCode AND m.TransSequence= l.Sequence AND m.WorkPoint= l.WorkPoint AND l.POID=a.POID AND l.PODetailID=a.PODetailID
  330. LEFT JOIN ICSVendor n ON a.VenCode= n.VenCode AND a.WorkPoint= n.WorkPoint
  331. INNER JOIN ICSInventory j ON a.invCode=j.invCode AND a.WorkPoint=j.workPoint AND j.InvIQC='1' where b.LotNo is not null and a.DNType='1' AND a.WorkPoint='{1}' {0} ";
  332. string wheresql = "";
  333. if (!string.IsNullOrWhiteSpace(queryJson))
  334. {
  335. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  336. {
  337. wheresql += " and a.DNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  338. }
  339. if (!string.IsNullOrWhiteSpace(queryParam["ASNCode"].ToString()))
  340. {
  341. wheresql += " and a.ASNCode like '%" + queryParam["ASNCode"].ToString() + "%' ";
  342. }
  343. if (!string.IsNullOrWhiteSpace(queryParam["CaiGouCode"].ToString()))
  344. {
  345. wheresql += " and l.POCode like '%" + queryParam["CaiGouCode"].ToString() + "%' ";
  346. }
  347. if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
  348. {
  349. wheresql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
  350. }
  351. if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
  352. {
  353. wheresql += " and n.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
  354. }
  355. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  356. {
  357. wheresql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  358. }
  359. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  360. {
  361. wheresql += " and j.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  362. }
  363. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  364. {
  365. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  366. }
  367. if (!string.IsNullOrWhiteSpace(queryParam["TimeFrom"].ToString()))
  368. {
  369. wheresql += " and a.CreateDateTime >= '" + queryParam["TimeFrom"].ToString() + "' ";
  370. }
  371. if (!string.IsNullOrWhiteSpace(queryParam["TimeArrive"].ToString()))
  372. {
  373. wheresql += " and a.CreateDateTime <= '" + queryParam["TimeArrive"].ToString() + "' ";
  374. }
  375. if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
  376. {
  377. wheresql += " and b.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
  378. }
  379. if (!string.IsNullOrWhiteSpace(queryParam["selIsUrgent"].ToString()))
  380. {
  381. wheresql += " and case b.EATTRIBUTE6 when '1' then '是' else '否' end = '" + queryParam["selIsUrgent"].ToString() + "' ";
  382. }
  383. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  384. {
  385. string ReleaseState = queryParam["ReleaseState"].ToString();
  386. if (ReleaseState == "1")
  387. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
  388. else if (ReleaseState == "0")
  389. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
  390. else
  391. wheresql += " ";
  392. }
  393. if (!string.IsNullOrWhiteSpace(queryParam["selIsPrint"].ToString()))
  394. {
  395. string printState = queryParam["selIsPrint"].ToString();
  396. if (printState == "否")
  397. wheresql += " and isnull(task.ValueParameters,'') ='' ";
  398. else if (printState == "是")
  399. wheresql += " and isnull(task.ValueParameters,'') <>''";
  400. }
  401. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  402. {
  403. string selEnableShow = queryParam["selEnableShow"].ToString();
  404. if (selEnableShow == "1")
  405. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
  406. else if (selEnableShow == "0")
  407. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
  408. }
  409. }
  410. sql += "GROUP BY a.ASNCode,A.DNCode,e.BatchCode,l.POCode,j.InvCode ,j.InvName ,j.INVSTD , j.InvUnit ,j.InvDesc ,j.InvIQC,a.WorkPoint,n.VenName,n.VenCode,c.MTIME,a.Sequence; select * into #TempLLData_1_1 from #TempLLData_1 ; ";
  411. sql = string.Format(sql, wheresql, WorkPoint);
  412. return Repository().FindTablePageBySql_OtherTemp(sql, "#TempLLData_1_1",
  413. @" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempLLData_1'))
  414. drop table #TempLLData_1
  415. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_1'))
  416. drop table #TempIcsinsp_1
  417. if exists(select * from tempdb..sysobjects where id = object_id('tempdb..#TempLLData_1_1'))
  418. drop table #TempLLData_1_1 ",
  419. "connstr", parameter.ToArray(), ref jqgridparam);
  420. }
  421. /// <summary>
  422. /// 根据单据和行获取检验信息
  423. /// </summary>
  424. /// <param name="jqgridparam"></param>
  425. /// <param name="queryJson"></param>
  426. /// <returns></returns>
  427. public DataTable GetICSInspectionDocSequence(ref Pagination jqgridparam, string queryJson)
  428. {
  429. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  430. DataTable dt = new DataTable();
  431. var queryParam = queryJson.ToJObject();
  432. List<DbParameter> parameter = new List<DbParameter>();
  433. string sql = string.Empty;
  434. sql = @" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempLLData_1'))
  435. drop table #TempLLData_1
  436. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempLLData_1_1'))
  437. drop table #TempLLData_1_1
  438. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_1'))
  439. drop table #TempIcsinsp_1
  440. select ID,QualifiedQuantity,UnqualifiedQuantity,WaiveQuantity,SampleQuantity,MUSERName,MTIME,Result,LotNo,BCCode,workpoint,BRCode
  441. into #TempIcsinsp_1
  442. from dbo.ICSInspection
  443. where workpoint='{1}' and Enable='1'
  444. SELECT a.ASNCode,A.DNCode,a.Sequence,l.POCode,j.InvCode ,j.InvName ,j.INVSTD ,j.InvUnit ,j.InvDesc,a.WorkPoint,n.VenName,n.VenCode,c.MTIME as CreateDateTime,CAST(ISNULL(SUM(c.Quantity),0)AS DECIMAL (18,4) ) as AllNumber, CAST(ISNULL(SUM(h.QualifiedQuantity), 0)as decimal(18,4))as YLOTQTY , CAST ( ISNULL( SUM(h.UnqualifiedQuantity), 0 ) AS DECIMAL (18, 4) ) AS NLOTQTY,CAST ( ISNULL( SUM(h.WaiveQuantity), 0 ) AS DECIMAL (18, 4) ) AS SpecialQTY,CAST ( ISNULL( SUM(h.SampleQuantity), 0 ) AS DECIMAL (18, 4) ) AS SampleQuantity into #TempLLData_1
  445. FROM ICSDeliveryNotice a
  446. INNER JOIN ICSInventoryLot b ON a.ExtensionID=b.ExtensionID AND a.WorkPoint=b.WorkPoint
  447. INNER JOIN ICSASNDetail c ON c.LotNo=b.LotNo AND c.WorkPoint=b.WorkPoint AND a.ASNCode=c.ASNCode
  448. left JOIN #TempIcsinsp_1 h ON c.LotNo=h.LotNo AND h.WorkPoint= c.WorkPoint
  449. LEFT JOIN (SELECT DISTINCT ValueParameters FROM Sys_LableTask) task ON task.ValueParameters=h.ID
  450. LEFT JOIN ICSExtension e ON e.ID=a.ExtensionID AND e.WorkPoint =a.WorkPoint
  451. LEFT JOIN ICSInventoryLotDetail m ON m.LotNo= c.LotNo AND m.WorkPoint= c.WorkPoint
  452. INNER JOIN ICSPurchaseOrder l ON m.TransCode = l.POCode AND m.TransSequence= l.Sequence AND m.WorkPoint= l.WorkPoint AND l.POID=a.POID AND l.PODetailID=a.PODetailID
  453. LEFT JOIN ICSVendor n ON a.VenCode= n.VenCode AND a.WorkPoint= n.WorkPoint
  454. INNER JOIN ICSInventory j ON a.invCode=j.invCode AND a.WorkPoint=j.workPoint AND j.InvIQC='1' where b.LotNo is not null and a.DNType='1' AND a.WorkPoint='{1}' {0} ";
  455. string wheresql = "";
  456. if (!string.IsNullOrWhiteSpace(queryJson))
  457. {
  458. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  459. {
  460. wheresql += " and a.DNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  461. }
  462. if (!string.IsNullOrWhiteSpace(queryParam["ASNCode"].ToString()))
  463. {
  464. wheresql += " and a.ASNCode like '%" + queryParam["ASNCode"].ToString() + "%' ";
  465. }
  466. if (!string.IsNullOrWhiteSpace(queryParam["CaiGouCode"].ToString()))
  467. {
  468. wheresql += " and l.POCode like '%" + queryParam["CaiGouCode"].ToString() + "%' ";
  469. }
  470. if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
  471. {
  472. wheresql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
  473. }
  474. if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
  475. {
  476. wheresql += " and n.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
  477. }
  478. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  479. {
  480. wheresql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  481. }
  482. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  483. {
  484. wheresql += " and j.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  485. }
  486. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  487. {
  488. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  489. }
  490. if (!string.IsNullOrWhiteSpace(queryParam["TimeFrom"].ToString()))
  491. {
  492. wheresql += " and a.CreateDateTime >= '" + queryParam["TimeFrom"].ToString() + "' ";
  493. }
  494. if (!string.IsNullOrWhiteSpace(queryParam["TimeArrive"].ToString()))
  495. {
  496. wheresql += " and a.CreateDateTime <= '" + queryParam["TimeArrive"].ToString() + "' ";
  497. }
  498. if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
  499. {
  500. wheresql += " and b.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
  501. }
  502. if (!string.IsNullOrWhiteSpace(queryParam["selIsUrgent"].ToString()))
  503. {
  504. wheresql += " and case b.EATTRIBUTE6 when '1' then '是' else '否' end = '" + queryParam["selIsUrgent"].ToString() + "' ";
  505. }
  506. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  507. {
  508. string ReleaseState = queryParam["ReleaseState"].ToString();
  509. if (ReleaseState == "1")
  510. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
  511. else if (ReleaseState == "0")
  512. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
  513. else
  514. wheresql += " ";
  515. }
  516. if (!string.IsNullOrWhiteSpace(queryParam["selIsPrint"].ToString()))
  517. {
  518. string printState = queryParam["selIsPrint"].ToString();
  519. if (printState == "否")
  520. wheresql += " and isnull(task.ValueParameters,'') ='' ";
  521. else if (printState == "是")
  522. wheresql += " and isnull(task.ValueParameters,'') <>''";
  523. }
  524. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  525. {
  526. string selEnableShow = queryParam["selEnableShow"].ToString();
  527. if (selEnableShow == "1")
  528. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
  529. else if (selEnableShow == "0")
  530. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
  531. }
  532. }
  533. sql += "GROUP BY a.ASNCode,A.DNCode,l.POCode,j.InvCode ,j.InvName ,j.INVSTD , j.InvUnit ,j.InvDesc ,j.InvIQC,a.WorkPoint,n.VenName,n.VenCode,c.MTIME,a.Sequence; select * into #TempLLData_1_1 from #TempLLData_1 ; ";
  534. sql = string.Format(sql, wheresql, WorkPoint);
  535. return Repository().FindTablePageBySql_OtherTemp(sql, "#TempLLData_1_1",
  536. @" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempLLData_1'))
  537. drop table #TempLLData_1
  538. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_1'))
  539. drop table #TempIcsinsp_1
  540. if exists(select * from tempdb..sysobjects where id = object_id('tempdb..#TempLLData_1_1'))
  541. drop table #TempLLData_1_1 ",
  542. "connstr", parameter.ToArray(), ref jqgridparam);
  543. }
  544. /// <summary>
  545. /// 根据单据获取检验信息
  546. /// </summary>
  547. /// <param name="jqgridparam"></param>
  548. /// <param name="queryJson"></param>
  549. /// <returns></returns>
  550. public DataTable GetICSInspectionDoc(ref Pagination jqgridparam, string queryJson)
  551. {
  552. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  553. DataTable dt = new DataTable();
  554. var queryParam = queryJson.ToJObject();
  555. List<DbParameter> parameter = new List<DbParameter>();
  556. string sql = string.Empty;
  557. sql = @" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempLLData_1'))
  558. drop table #TempLLData_1
  559. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempLLData_1_1'))
  560. drop table #TempLLData_1_1
  561. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_1'))
  562. drop table #TempIcsinsp_1
  563. select ID,QualifiedQuantity,UnqualifiedQuantity,WaiveQuantity,SampleQuantity,MUSERName,MTIME,Result,LotNo,BCCode,workpoint,BRCode
  564. into #TempIcsinsp_1
  565. from dbo.ICSInspection
  566. where workpoint='{1}' and Enable='1'
  567. SELECT a.ASNCode,A.DNCode,l.POCode,a.WorkPoint,c.MTIME as CreateDateTime,CAST(ISNULL(SUM(c.Quantity),0)AS DECIMAL (18,4) ) as AllNumber, CAST(ISNULL(SUM(h.QualifiedQuantity), 0)as decimal(18,4))as YLOTQTY , CAST ( ISNULL( SUM(h.UnqualifiedQuantity), 0 ) AS DECIMAL (18, 4) ) AS NLOTQTY,CAST ( ISNULL( SUM(h.WaiveQuantity), 0 ) AS DECIMAL (18, 4) ) AS SpecialQTY,CAST ( ISNULL( SUM(h.SampleQuantity), 0 ) AS DECIMAL (18, 4) ) AS SampleQuantity into #TempLLData_1
  568. FROM ICSDeliveryNotice a
  569. INNER JOIN ICSInventoryLot b ON a.ExtensionID=b.ExtensionID AND a.WorkPoint=b.WorkPoint
  570. INNER JOIN ICSASNDetail c ON c.LotNo=b.LotNo AND c.WorkPoint=b.WorkPoint AND a.ASNCode=c.ASNCode
  571. left JOIN #TempIcsinsp_1 h ON c.LotNo=h.LotNo AND h.WorkPoint= c.WorkPoint
  572. LEFT JOIN (SELECT DISTINCT ValueParameters FROM Sys_LableTask) task ON task.ValueParameters=h.ID
  573. LEFT JOIN ICSExtension e ON e.ID=a.ExtensionID AND e.WorkPoint =a.WorkPoint
  574. LEFT JOIN ICSInventoryLotDetail m ON m.LotNo= c.LotNo AND m.WorkPoint= c.WorkPoint
  575. INNER JOIN ICSPurchaseOrder l ON m.TransCode = l.POCode AND m.TransSequence= l.Sequence AND m.WorkPoint= l.WorkPoint AND l.POID=a.POID AND l.PODetailID=a.PODetailID
  576. LEFT JOIN ICSVendor n ON a.VenCode= n.VenCode AND a.WorkPoint= n.WorkPoint
  577. INNER JOIN ICSInventory j ON a.invCode=j.invCode AND a.WorkPoint=j.workPoint AND j.InvIQC='1' where b.LotNo is not null and a.DNType='1' AND a.WorkPoint='{1}' {0} ";
  578. string wheresql = "";
  579. if (!string.IsNullOrWhiteSpace(queryJson))
  580. {
  581. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  582. {
  583. wheresql += " and a.DNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  584. }
  585. if (!string.IsNullOrWhiteSpace(queryParam["ASNCode"].ToString()))
  586. {
  587. wheresql += " and a.ASNCode like '%" + queryParam["ASNCode"].ToString() + "%' ";
  588. }
  589. if (!string.IsNullOrWhiteSpace(queryParam["CaiGouCode"].ToString()))
  590. {
  591. wheresql += " and l.POCode like '%" + queryParam["CaiGouCode"].ToString() + "%' ";
  592. }
  593. if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
  594. {
  595. wheresql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
  596. }
  597. if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
  598. {
  599. wheresql += " and n.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
  600. }
  601. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  602. {
  603. wheresql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  604. }
  605. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  606. {
  607. wheresql += " and j.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  608. }
  609. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  610. {
  611. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  612. }
  613. if (!string.IsNullOrWhiteSpace(queryParam["TimeFrom"].ToString()))
  614. {
  615. wheresql += " and a.CreateDateTime >= '" + queryParam["TimeFrom"].ToString() + "' ";
  616. }
  617. if (!string.IsNullOrWhiteSpace(queryParam["TimeArrive"].ToString()))
  618. {
  619. wheresql += " and a.CreateDateTime <= '" + queryParam["TimeArrive"].ToString() + "' ";
  620. }
  621. if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
  622. {
  623. wheresql += " and b.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
  624. }
  625. if (!string.IsNullOrWhiteSpace(queryParam["selIsUrgent"].ToString()))
  626. {
  627. wheresql += " and case b.EATTRIBUTE6 when '1' then '是' else '否' end = '" + queryParam["selIsUrgent"].ToString() + "' ";
  628. }
  629. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  630. {
  631. string ReleaseState = queryParam["ReleaseState"].ToString();
  632. if (ReleaseState == "1")
  633. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
  634. else if (ReleaseState == "0")
  635. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
  636. else
  637. wheresql += " ";
  638. }
  639. if (!string.IsNullOrWhiteSpace(queryParam["selIsPrint"].ToString()))
  640. {
  641. string printState = queryParam["selIsPrint"].ToString();
  642. if (printState == "否")
  643. wheresql += " and isnull(task.ValueParameters,'') ='' ";
  644. else if (printState == "是")
  645. wheresql += " and isnull(task.ValueParameters,'') <>''";
  646. }
  647. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  648. {
  649. string selEnableShow = queryParam["selEnableShow"].ToString();
  650. if (selEnableShow == "1")
  651. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
  652. else if (selEnableShow == "0")
  653. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
  654. }
  655. }
  656. sql += "GROUP BY a.ASNCode,A.DNCode,l.POCode,a.WorkPoint,c.MTIME; select * into #TempLLData_1_1 from #TempLLData_1 ; ";
  657. sql = string.Format(sql, wheresql, WorkPoint);
  658. return Repository().FindTablePageBySql_OtherTemp(sql, "#TempLLData_1_1",
  659. @" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempLLData_1'))
  660. drop table #TempLLData_1
  661. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_1'))
  662. drop table #TempIcsinsp_1
  663. if exists(select * from tempdb..sysobjects where id = object_id('tempdb..#TempLLData_1_1'))
  664. drop table #TempLLData_1_1 ",
  665. "connstr", parameter.ToArray(), ref jqgridparam);
  666. }
  667. //委外
  668. public DataTable GetICSInspection2(ref Pagination jqgridparam, string queryJson)
  669. {
  670. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  671. DataTable dt = new DataTable();
  672. var queryParam = queryJson.ToJObject();
  673. List<DbParameter> parameter = new List<DbParameter>();
  674. string sql = @"
  675. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempWWLLData_2'))
  676. drop table #TempWWLLData_2
  677. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempWWLLData_2_1'))
  678. drop table #TempWWLLData_2_1
  679. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_2'))
  680. drop table #TempIcsinsp_2
  681. select ID,QualifiedQuantity,UnqualifiedQuantity,WaiveQuantity,
  682. SampleQuantity,MUSERName,MTIME,Result,LotNo,BCCode,workpoint,BRCode
  683. into #TempIcsinsp_2
  684. from dbo.ICSInspection
  685. where workpoint='" + WorkPoint + @"' and Enable='1'
  686. 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,
  687. 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,
  688. CAST(b.ODNQuantity as NUMERIC(10,4)) as AllNumber, c.EATTRIBUTE3 as InvEATTRIBUTE3,
  689. CAST(ISNULL(h.QualifiedQuantity, b.ODNQuantity)as NUMERIC(10,4))as YLOTQTY ,
  690. CAST(ISNULL(h.UnqualifiedQuantity, 0) as NUMERIC(10,4)) as NLOTQTY,
  691. CAST(ISNULL(h.WaiveQuantity, 0) as NUMERIC(10,4)) as SpecialQTY,
  692. CASE WHEN isnull(h.ID,'') ='' THEN isnull(p.SampleQuantity,0) ELSE CAST(ISNULL(h.SampleQuantity, 0) as decimal(18,4)) END AS SampleQuantity ,
  693. CASE WHEN isnull(task.ValueParameters,'') =''THEN '否' ELSE '是' END AS IsPrint,
  694. c.InvUnit , b.LotNo , g.BadReasonDesc as BadReasonDesc ,g.BadReasonCode as BRCodeValue,j.BadCode as BCCodeValue, j.BadDesc as BadDesc,
  695. k.ContainerID,isnull(h.MUSERName,'') MUSERName, CONVERT(VARCHAR(100),d.ProductDate,120) as ProductTime,
  696. CONVERT(VARCHAR(100),a.CreateDateTime,120) as CreateDateTime,CONVERT(VARCHAR(100),h.MTIME,120) as MTIME,
  697. CASE WHEN isnull(h.ID,'') =''THEN '' ELSE '' END AS TestState,a.VenCode,m.VenName,
  698. isnull(h.MUSERName,'') as Surveyor, h.MTime as ProvingTime
  699. ,CASE WHEN h.Result='0' THEN '' when ISNULL(h.Result,'')='' THEN '' ELSE '' END AS Result,
  700. n.FileName,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  701. a.EATTRIBUTE9,a.EATTRIBUTE10
  702. ,(CASE ISNULL((SELECT COUNT(1) FROM dbo.ICSInspection hH2
  703. WHERE hH2.LotNo=b.LotNo AND hH2.WorkPoint=b.WorkPoint),0)
  704. WHEN 0 THEN '' WHEN 1 THEN '是' else '否' end ) IsFirstCK
  705. ,case d.EATTRIBUTE6 when '1' then '是' else '否' end IsUrgent,c.InvIQC
  706. into #TempWWLLData_2
  707. FROM ICSODeliveryNotice a
  708. LEFT JOIN ICSOASNDetail b ON a.OASNCode=b.OASNCode AND a.WorkPoint=b.WorkPoint
  709. inner JOIN ICSInventory c ON a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint --and c.InvIQC='1'
  710. inner JOIN ICSInventoryLot d ON b.LotNo=d.LotNo AND a.InvCode=d.InvCode AND b.WorkPoint=d.WorkPoint
  711. left join ICSInventoryLotDetail e on d.LotNo=e.LotNo and d.WorkPoint=e.WorkPoint
  712. LEFT JOIN #TempIcsinsp_2 h ON h.LotNo=b.LotNo AND h.WorkPoint=b.WorkPoint -- and Enable='1'
  713. LEFT JOIN (SELECT DISTINCT ValueParameters FROM Sys_LableTask) task ON task.ValueParameters=h.ID
  714. left join ICSBadReason g on h.BRCode =g.BadReasonCode and h.WorkPoint=g.WorkPoint
  715. left join ICSBadCode j on h.BCCode =j.BadCode and h.WorkPoint=j.WorkPoint
  716. LEFT JOIN ICSContainerLot k ON b.LotNo=k.LotNo AND b.WorkPoint=k.WorkPoint
  717. inner JOIN ICSOutsourcingOrder l ON e.TransCode =l.OOCode AND e.TransSequence=l.Sequence AND a.OODetailID=l.OODetailID AND d.WorkPoint=l.WorkPoint
  718. left join ICSExtension f on d.ExtensionID=f.ID and d.WorkPoint=f.WorkPoint
  719. left join dbo.ICSVendor m on a.VenCode=m.VenCode and a.WorkPoint=m.WorkPoint
  720. left join ICSInspectionFile n on h.id=n.InspectionID and h.WorkPoint=n.WorkPoint
  721. LEFT JOIN ICSInventoryInspectionRulesGroup o ON a.InvCode=o.InvCode AND a.WorkPoint=o.WorkPoint
  722. LEFT JOIN ICSInventoryInspectionRuleslist p ON o.id=p.invrulesid AND o.WorkPoint=p.WorkPoint AND d.Quantity BETWEEN p.SetValueMax AND p.SetValueMin
  723. where b.LotNo is not null and ISNULL(CAST(b.ODNQuantity as VARCHAR), '')! =''
  724. AND ISNULL(b.ODNQuantity, 0)<>0 {0} and a.workpoint='{1}'
  725. select * into #TempWWLLData_2_1 from #TempWWLLData_2 where InvIQC='1'
  726. ";
  727. #region 无SRM逻辑
  728. // sql = @"UNION all
  729. //select
  730. // a.ID as DHID,
  731. // d.ID ,
  732. // h.ID as JYID,
  733. // a.ODNCode as DNCode ,
  734. // a.Sequence ,
  735. // a.OASNCode ,
  736. // c.InvCode ,
  737. // c.InvName ,
  738. // c.INVSTD ,
  739. // c.ClassName,
  740. // f.BatchCode ,
  741. // CAST(d.Quantity as NUMERIC(10,4)) as AllNumber,
  742. // CAST(ISNULL(h.QualifiedQuantity, d.Quantity)as NUMERIC(10,4))as YLOTQTY ,
  743. // CAST(ISNULL(h.UnqualifiedQuantity, 0) as NUMERIC(10,4)) as NLOTQTY,
  744. // CAST(ISNULL(h.WaiveQuantity, 0) as NUMERIC(10,4)) as SpecialQTY,
  745. // c.InvUnit ,
  746. // d.LotNo ,
  747. // g.BadReasonDesc as BadReasonDesc ,
  748. // g.BadReasonCode as BRCodeValue,
  749. // j.BadCode as BCCodeValue,
  750. // j.BadDesc as BadDesc,
  751. // k.ContainerID,
  752. // isnull(h.MUSERName,'开发者') MUSERName,
  753. // CONVERT(VARCHAR(100),d.ProductDate,23) as ProductTime,
  754. // CONVERT(VARCHAR(100),h.MTIME,23) as MTIME,
  755. // CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END AS TestState
  756. // FROM ICSODeliveryNotice a
  757. // inner join ICSInventoryLotDetail e on e.TransCode =a.ODNCode AND e.TransSequence=a.Sequence AND e.WorkPoint=a.WorkPoint
  758. // inner JOIN ICSInventoryLot d ON d.LotNo=e.LotNo and d.WorkPoint=e.WorkPoint
  759. // LEFT JOIN ICSInventory c ON a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint
  760. // LEFT JOIN dbo.ICSInspection h ON h.LotNo=d.LotNo AND h.WorkPoint=d.WorkPoint
  761. // left join ICSBadReason g on h.BRCode =g.BadReasonCode and h.WorkPoint=g.WorkPoint
  762. // left join ICSBadCode j on h.BCCode =j.BadCode and h.WorkPoint=j.WorkPoint
  763. // LEFT JOIN ICSContainerLot k ON d.LotNo=k.LotNo AND d.WorkPoint=k.WorkPoint
  764. // left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  765. // where 1=1 {0}";
  766. #endregion
  767. string wheresql = "";
  768. if (!string.IsNullOrWhiteSpace(queryJson))
  769. {
  770. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  771. {
  772. wheresql += " and a.ODNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  773. }
  774. if (!string.IsNullOrWhiteSpace(queryParam["ASNCode"].ToString()))
  775. {
  776. wheresql += " and a.OASNCode like '%" + queryParam["ASNCode"].ToString() + "%' ";
  777. }
  778. if (!string.IsNullOrWhiteSpace(queryParam["CaiGouCode"].ToString()))
  779. {
  780. wheresql += " and l.OOCode like '%" + queryParam["CaiGouCode"].ToString() + "%' ";
  781. }
  782. if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
  783. {
  784. wheresql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
  785. }
  786. if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
  787. {
  788. wheresql += " and m.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
  789. }
  790. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  791. {
  792. wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  793. }
  794. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  795. {
  796. wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  797. }
  798. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  799. {
  800. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  801. }
  802. if (!string.IsNullOrWhiteSpace(queryParam["TimeFrom"].ToString()))
  803. {
  804. wheresql += " and a.CreateDateTime >= '" + queryParam["TimeFrom"].ToString() + "' ";
  805. }
  806. if (!string.IsNullOrWhiteSpace(queryParam["TimeArrive"].ToString()))
  807. {
  808. wheresql += " and a.CreateDateTime <= '" + queryParam["TimeArrive"].ToString() + "' ";
  809. }
  810. if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
  811. {
  812. wheresql += " and b.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
  813. }
  814. if (!string.IsNullOrWhiteSpace(queryParam["selIsUrgent"].ToString()))
  815. {
  816. wheresql += " and case d.EATTRIBUTE6 when '1' then '是' else '否' end = '" + queryParam["selIsUrgent"].ToString() + "' ";
  817. }
  818. if (!string.IsNullOrWhiteSpace(queryParam["selIsPrint"].ToString()))
  819. {
  820. string printState = queryParam["selIsPrint"].ToString();
  821. if (printState == "否")
  822. wheresql += " and isnull(task.ValueParameters,'') ='' ";
  823. else if (printState == "是")
  824. wheresql += " and isnull(task.ValueParameters,'') <>''";
  825. }
  826. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  827. {
  828. string ReleaseState = queryParam["ReleaseState"].ToString();
  829. if (ReleaseState == "1")
  830. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
  831. else if (ReleaseState == "0")
  832. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
  833. else
  834. wheresql += " ";
  835. }
  836. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  837. {
  838. string selEnableShow = queryParam["selEnableShow"].ToString();
  839. if (selEnableShow == "1")
  840. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
  841. else if (selEnableShow == "0")
  842. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
  843. }
  844. }
  845. sql = string.Format(sql, wheresql, WorkPoint);
  846. return Repository().FindTablePageBySql_OtherTemp(sql, "#TempWWLLData_2_1",
  847. @" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempWWLLData_2'))
  848. drop table #TempWWLLData_2
  849. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempWWLLData_2_1'))
  850. drop table #TempWWLLData_2_1
  851. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_2'))
  852. drop table #TempIcsinsp_2 ",
  853. "connstr", parameter.ToArray(), ref jqgridparam);
  854. // return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  855. }
  856. //委外批次维度检验
  857. public DataTable GetICSInspection2BatchCode(ref Pagination jqgridparam, string queryJson)
  858. {
  859. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  860. DataTable dt = new DataTable();
  861. var queryParam = queryJson.ToJObject();
  862. List<DbParameter> parameter = new List<DbParameter>();
  863. string sql = @"
  864. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempWWLLData_2'))
  865. drop table #TempWWLLData_2
  866. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempWWLLData_2_1'))
  867. drop table #TempWWLLData_2_1
  868. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_2'))
  869. drop table #TempIcsinsp_2
  870. select ID,QualifiedQuantity,UnqualifiedQuantity,WaiveQuantity,
  871. SampleQuantity,MUSERName,MTIME,Result,LotNo,BCCode,workpoint,BRCode
  872. into #TempIcsinsp_2
  873. from dbo.ICSInspection
  874. where workpoint='" + WorkPoint + @"' and Enable='1'
  875. select DISTINCT a.ID as DHID, a.ODNCode as DNCode ,a.Sequence ,a.OASNCode ,l.OOCode,c.InvCode , c.InvName , c.INVSTD , c.ClassName, 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,
  876. CAST(ISNULL(Sum(b.ODNQuantity), 0) as NUMERIC(10,4)) as AllNumber,
  877. CAST(ISNULL(Sum(h.QualifiedQuantity), Sum(b.ODNQuantity))as NUMERIC(10,4))as YLOTQTY ,
  878. CAST(ISNULL(Sum(h.UnqualifiedQuantity), 0) as NUMERIC(10,4)) as NLOTQTY,
  879. CAST(ISNULL(Sum(h.WaiveQuantity), 0) as NUMERIC(10,4)) as SpecialQTY,
  880. CAST(ISNULL(Sum(h.SampleQuantity), 0) as NUMERIC(10,4)) as SampleQuantity,
  881. c.InvUnit ,
  882. CONVERT(VARCHAR(100),a.CreateDateTime,120) as CreateDateTime,a.VenCode,m.VenName,
  883. a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a. EATTRIBUTE7,a.EATTRIBUTE8,
  884. a.EATTRIBUTE9,a.EATTRIBUTE10 into #TempWWLLData_2
  885. FROM ICSODeliveryNotice a
  886. LEFT JOIN ICSOASNDetail b ON a.OASNCode=b.OASNCode AND a.WorkPoint=b.WorkPoint
  887. inner JOIN ICSInventory c ON a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint and c.InvIQC='1'
  888. inner JOIN ICSInventoryLot d ON b.LotNo=d.LotNo AND a.InvCode=d.InvCode AND b.WorkPoint=d.WorkPoint
  889. left join ICSInventoryLotDetail e on d.LotNo=e.LotNo and d.WorkPoint=e.WorkPoint
  890. LEFT JOIN #TempIcsinsp_2 h ON h.LotNo=b.LotNo AND h.WorkPoint=b.WorkPoint
  891. inner JOIN ICSOutsourcingOrder l ON e.TransCode =l.OOCode AND e.TransSequence=l.Sequence AND a.OODetailID=l.OODetailID AND d.WorkPoint=l.WorkPoint
  892. left join ICSExtension f on d.ExtensionID=f.ID and d.WorkPoint=f.WorkPoint
  893. left join dbo.ICSVendor m on a.VenCode=m.VenCode and a.WorkPoint=m.WorkPoint
  894. where b.LotNo is not null and ISNULL(CAST(b.ODNQuantity as VARCHAR), '')! =''
  895. AND ISNULL(b.ODNQuantity, 0)<>0 {0} and a.workpoint='{1}'
  896. ";
  897. string wheresql = "";
  898. if (!string.IsNullOrWhiteSpace(queryJson))
  899. {
  900. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  901. {
  902. wheresql += " and a.ODNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  903. }
  904. if (!string.IsNullOrWhiteSpace(queryParam["ASNCode"].ToString()))
  905. {
  906. wheresql += " and a.OASNCode like '%" + queryParam["ASNCode"].ToString() + "%' ";
  907. }
  908. if (!string.IsNullOrWhiteSpace(queryParam["CaiGouCode"].ToString()))
  909. {
  910. wheresql += " and l.OOCode like '%" + queryParam["CaiGouCode"].ToString() + "%' ";
  911. }
  912. if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
  913. {
  914. wheresql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
  915. }
  916. if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
  917. {
  918. wheresql += " and m.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
  919. }
  920. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  921. {
  922. wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  923. }
  924. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  925. {
  926. wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  927. }
  928. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  929. {
  930. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  931. }
  932. if (!string.IsNullOrWhiteSpace(queryParam["TimeFrom"].ToString()))
  933. {
  934. wheresql += " and a.CreateDateTime >= '" + queryParam["TimeFrom"].ToString() + "' ";
  935. }
  936. if (!string.IsNullOrWhiteSpace(queryParam["TimeArrive"].ToString()))
  937. {
  938. wheresql += " and a.CreateDateTime <= '" + queryParam["TimeArrive"].ToString() + "' ";
  939. }
  940. if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
  941. {
  942. wheresql += " and b.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
  943. }
  944. if (!string.IsNullOrWhiteSpace(queryParam["selIsUrgent"].ToString()))
  945. {
  946. wheresql += " and case d.EATTRIBUTE6 when '1' then '是' else '否' end = '" + queryParam["selIsUrgent"].ToString() + "' ";
  947. }
  948. if (!string.IsNullOrWhiteSpace(queryParam["selIsPrint"].ToString()))
  949. {
  950. string printState = queryParam["selIsPrint"].ToString();
  951. if (printState == "否")
  952. wheresql += " and isnull(task.ValueParameters,'') ='' ";
  953. else if (printState == "是")
  954. wheresql += " and isnull(task.ValueParameters,'') <>''";
  955. }
  956. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  957. {
  958. string ReleaseState = queryParam["ReleaseState"].ToString();
  959. if (ReleaseState == "1")
  960. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
  961. else if (ReleaseState == "0")
  962. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
  963. else
  964. wheresql += " ";
  965. }
  966. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  967. {
  968. string selEnableShow = queryParam["selEnableShow"].ToString();
  969. if (selEnableShow == "1")
  970. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
  971. else if (selEnableShow == "0")
  972. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
  973. }
  974. }
  975. sql += @" GROUP BY a.ID , a.ODNCode ,a.Sequence ,a.OASNCode ,l.OOCode,c.InvCode , c.InvName , c.INVSTD , c.ClassName, 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,c.InvUnit , a.CreateDateTime,a.MTIME,a.VenCode,m.VenName,
  976. a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a. EATTRIBUTE7,a.EATTRIBUTE8,
  977. a.EATTRIBUTE9,a.EATTRIBUTE10;select * into #TempWWLLData_2_1 from #TempWWLLData_2 ;";
  978. sql = string.Format(sql, wheresql, WorkPoint);
  979. return Repository().FindTablePageBySql_OtherTemp(sql, "#TempWWLLData_2_1",
  980. @" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempWWLLData_2'))
  981. drop table #TempWWLLData_2
  982. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempWWLLData_2_1'))
  983. drop table #TempWWLLData_2_1
  984. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_2'))
  985. drop table #TempIcsinsp_2 ",
  986. "connstr", parameter.ToArray(), ref jqgridparam);
  987. // return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  988. }
  989. /// <summary>
  990. /// 委外按单据维度检验
  991. /// </summary>
  992. /// <param name="jqgridparam"></param>
  993. /// <param name="queryJson"></param>
  994. /// <returns></returns>
  995. public DataTable GetICSInspection2Doc(ref Pagination jqgridparam, string queryJson)
  996. {
  997. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  998. DataTable dt = new DataTable();
  999. var queryParam = queryJson.ToJObject();
  1000. List<DbParameter> parameter = new List<DbParameter>();
  1001. string sql = @"
  1002. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempWWLLData_2'))
  1003. drop table #TempWWLLData_2
  1004. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempWWLLData_2_1'))
  1005. drop table #TempWWLLData_2_1
  1006. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_2'))
  1007. drop table #TempIcsinsp_2
  1008. select ID,QualifiedQuantity,UnqualifiedQuantity,WaiveQuantity,
  1009. SampleQuantity,MUSERName,MTIME,Result,LotNo,BCCode,workpoint,BRCode
  1010. into #TempIcsinsp_2
  1011. from dbo.ICSInspection
  1012. where workpoint='" + WorkPoint + @"' and Enable='1'
  1013. select DISTINCT a.ODNCode as DNCode ,a.OASNCode ,l.OOCode,
  1014. CAST(ISNULL(Sum(b.ODNQuantity), 0) as NUMERIC(10,4)) as AllNumber,
  1015. CAST(ISNULL(Sum(h.QualifiedQuantity), Sum(b.ODNQuantity))as NUMERIC(10,4))as YLOTQTY ,
  1016. CAST(ISNULL(Sum(h.UnqualifiedQuantity), 0) as NUMERIC(10,4)) as NLOTQTY,
  1017. CAST(ISNULL(Sum(h.WaiveQuantity), 0) as NUMERIC(10,4)) as SpecialQTY,
  1018. CAST(ISNULL(Sum(h.SampleQuantity), 0) as NUMERIC(10,4)) as SampleQuantity
  1019. into #TempWWLLData_2
  1020. FROM ICSODeliveryNotice a
  1021. LEFT JOIN ICSOASNDetail b ON a.OASNCode=b.OASNCode AND a.WorkPoint=b.WorkPoint
  1022. inner JOIN ICSInventory c ON a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint and c.InvIQC='1'
  1023. inner JOIN ICSInventoryLot d ON b.LotNo=d.LotNo AND a.InvCode=d.InvCode AND b.WorkPoint=d.WorkPoint
  1024. left join ICSInventoryLotDetail e on d.LotNo=e.LotNo and d.WorkPoint=e.WorkPoint
  1025. LEFT JOIN #TempIcsinsp_2 h ON h.LotNo=b.LotNo AND h.WorkPoint=b.WorkPoint
  1026. inner JOIN ICSOutsourcingOrder l ON e.TransCode =l.OOCode AND e.TransSequence=l.Sequence AND a.OODetailID=l.OODetailID AND d.WorkPoint=l.WorkPoint
  1027. left join ICSExtension f on l.ExtensionID=f.ID and l.WorkPoint=f.WorkPoint
  1028. left join dbo.ICSVendor m on a.VenCode=m.VenCode and a.WorkPoint=m.WorkPoint
  1029. where b.LotNo is not null and ISNULL(CAST(b.ODNQuantity as VARCHAR), '')! =''
  1030. AND ISNULL(b.ODNQuantity, 0)<>0 {0} and a.workpoint='{1}'
  1031. ";
  1032. string wheresql = "";
  1033. if (!string.IsNullOrWhiteSpace(queryJson))
  1034. {
  1035. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1036. {
  1037. wheresql += " and a.ODNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1038. }
  1039. if (!string.IsNullOrWhiteSpace(queryParam["ASNCode"].ToString()))
  1040. {
  1041. wheresql += " and a.OASNCode like '%" + queryParam["ASNCode"].ToString() + "%' ";
  1042. }
  1043. if (!string.IsNullOrWhiteSpace(queryParam["CaiGouCode"].ToString()))
  1044. {
  1045. wheresql += " and l.OOCode like '%" + queryParam["CaiGouCode"].ToString() + "%' ";
  1046. }
  1047. if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
  1048. {
  1049. wheresql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
  1050. }
  1051. if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
  1052. {
  1053. wheresql += " and m.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
  1054. }
  1055. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1056. {
  1057. wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1058. }
  1059. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1060. {
  1061. wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1062. }
  1063. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1064. {
  1065. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1066. }
  1067. if (!string.IsNullOrWhiteSpace(queryParam["TimeFrom"].ToString()))
  1068. {
  1069. wheresql += " and a.CreateDateTime >= '" + queryParam["TimeFrom"].ToString() + "' ";
  1070. }
  1071. if (!string.IsNullOrWhiteSpace(queryParam["TimeArrive"].ToString()))
  1072. {
  1073. wheresql += " and a.CreateDateTime <= '" + queryParam["TimeArrive"].ToString() + "' ";
  1074. }
  1075. if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
  1076. {
  1077. wheresql += " and b.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
  1078. }
  1079. if (!string.IsNullOrWhiteSpace(queryParam["selIsUrgent"].ToString()))
  1080. {
  1081. wheresql += " and case d.EATTRIBUTE6 when '1' then '是' else '否' end = '" + queryParam["selIsUrgent"].ToString() + "' ";
  1082. }
  1083. if (!string.IsNullOrWhiteSpace(queryParam["selIsPrint"].ToString()))
  1084. {
  1085. string printState = queryParam["selIsPrint"].ToString();
  1086. if (printState == "否")
  1087. wheresql += " and isnull(task.ValueParameters,'') ='' ";
  1088. else if (printState == "是")
  1089. wheresql += " and isnull(task.ValueParameters,'') <>''";
  1090. }
  1091. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  1092. {
  1093. string ReleaseState = queryParam["ReleaseState"].ToString();
  1094. if (ReleaseState == "1")
  1095. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
  1096. else if (ReleaseState == "0")
  1097. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
  1098. else
  1099. wheresql += " ";
  1100. }
  1101. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  1102. {
  1103. string selEnableShow = queryParam["selEnableShow"].ToString();
  1104. if (selEnableShow == "1")
  1105. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
  1106. else if (selEnableShow == "0")
  1107. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
  1108. }
  1109. }
  1110. sql += @" GROUP BY a.ODNCode ,a.OASNCode ,l.OOCode; select * into #TempWWLLData_2_1 from #TempWWLLData_2 ";
  1111. sql = string.Format(sql, wheresql, WorkPoint);
  1112. return Repository().FindTablePageBySql_OtherTemp(sql, "#TempWWLLData_2_1",
  1113. @" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempWWLLData_2'))
  1114. drop table #TempWWLLData_2
  1115. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempWWLLData_2_1'))
  1116. drop table #TempWWLLData_2_1
  1117. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_2'))
  1118. drop table #TempIcsinsp_2 ",
  1119. "connstr", parameter.ToArray(), ref jqgridparam);
  1120. // return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1121. }
  1122. /// <summary>
  1123. /// 委外按单据行维度检验
  1124. /// </summary>
  1125. /// <param name="jqgridparam"></param>
  1126. /// <param name="queryJson"></param>
  1127. /// <returns></returns>
  1128. public DataTable GetICSInspection2DocSequence(ref Pagination jqgridparam, string queryJson)
  1129. {
  1130. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1131. DataTable dt = new DataTable();
  1132. var queryParam = queryJson.ToJObject();
  1133. List<DbParameter> parameter = new List<DbParameter>();
  1134. string sql = @"
  1135. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempWWLLData_2'))
  1136. drop table #TempWWLLData_2
  1137. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempWWLLData_2_1'))
  1138. drop table #TempWWLLData_2_1
  1139. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_2'))
  1140. drop table #TempIcsinsp_2
  1141. select ID,QualifiedQuantity,UnqualifiedQuantity,WaiveQuantity,
  1142. SampleQuantity,MUSERName,MTIME,Result,LotNo,BCCode,workpoint,BRCode
  1143. into #TempIcsinsp_2
  1144. from dbo.ICSInspection
  1145. where workpoint='" + WorkPoint + @"' and Enable='1'
  1146. select DISTINCT a.ID as DHID, a.ODNCode as DNCode ,a.Sequence ,a.OASNCode ,l.OOCode,c.InvCode , c.InvName , c.INVSTD , c.ClassName,
  1147. CAST(ISNULL(Sum(b.ODNQuantity), 0) as NUMERIC(10,4)) as AllNumber,
  1148. CAST(ISNULL(Sum(h.QualifiedQuantity), Sum(b.ODNQuantity))as NUMERIC(10,4))as YLOTQTY ,
  1149. CAST(ISNULL(Sum(h.UnqualifiedQuantity), 0) as NUMERIC(10,4)) as NLOTQTY,
  1150. CAST(ISNULL(Sum(h.WaiveQuantity), 0) as NUMERIC(10,4)) as SpecialQTY,
  1151. CAST(ISNULL(Sum(h.SampleQuantity), 0) as NUMERIC(10,4)) as SampleQuantity,
  1152. c.InvUnit ,
  1153. CONVERT(VARCHAR(100),a.CreateDateTime,120) as CreateDateTime,a.VenCode,m.VenName,
  1154. a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a. EATTRIBUTE7,a.EATTRIBUTE8,
  1155. a.EATTRIBUTE9,a.EATTRIBUTE10 into #TempWWLLData_2
  1156. FROM ICSODeliveryNotice a
  1157. LEFT JOIN ICSOASNDetail b ON a.OASNCode=b.OASNCode AND a.WorkPoint=b.WorkPoint
  1158. inner JOIN ICSInventory c ON a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint and c.InvIQC='1'
  1159. inner JOIN ICSInventoryLot d ON b.LotNo=d.LotNo AND a.InvCode=d.InvCode AND b.WorkPoint=d.WorkPoint
  1160. left join ICSInventoryLotDetail e on d.LotNo=e.LotNo and d.WorkPoint=e.WorkPoint
  1161. LEFT JOIN #TempIcsinsp_2 h ON h.LotNo=b.LotNo AND h.WorkPoint=b.WorkPoint
  1162. inner JOIN ICSOutsourcingOrder l ON e.TransCode =l.OOCode AND e.TransSequence=l.Sequence AND a.OODetailID=l.OODetailID AND d.WorkPoint=l.WorkPoint
  1163. left join ICSExtension f on l.ExtensionID=f.ID and l.WorkPoint=f.WorkPoint
  1164. left join dbo.ICSVendor m on a.VenCode=m.VenCode and a.WorkPoint=m.WorkPoint
  1165. where b.LotNo is not null and ISNULL(CAST(b.ODNQuantity as VARCHAR), '')! =''
  1166. AND ISNULL(b.ODNQuantity, 0)<>0 {0} and a.workpoint='{1}'
  1167. ";
  1168. string wheresql = "";
  1169. if (!string.IsNullOrWhiteSpace(queryJson))
  1170. {
  1171. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1172. {
  1173. wheresql += " and a.ODNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1174. }
  1175. if (!string.IsNullOrWhiteSpace(queryParam["ASNCode"].ToString()))
  1176. {
  1177. wheresql += " and a.OASNCode like '%" + queryParam["ASNCode"].ToString() + "%' ";
  1178. }
  1179. if (!string.IsNullOrWhiteSpace(queryParam["CaiGouCode"].ToString()))
  1180. {
  1181. wheresql += " and l.OOCode like '%" + queryParam["CaiGouCode"].ToString() + "%' ";
  1182. }
  1183. if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
  1184. {
  1185. wheresql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
  1186. }
  1187. if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
  1188. {
  1189. wheresql += " and m.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
  1190. }
  1191. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1192. {
  1193. wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1194. }
  1195. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1196. {
  1197. wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1198. }
  1199. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1200. {
  1201. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1202. }
  1203. if (!string.IsNullOrWhiteSpace(queryParam["TimeFrom"].ToString()))
  1204. {
  1205. wheresql += " and a.CreateDateTime >= '" + queryParam["TimeFrom"].ToString() + "' ";
  1206. }
  1207. if (!string.IsNullOrWhiteSpace(queryParam["TimeArrive"].ToString()))
  1208. {
  1209. wheresql += " and a.CreateDateTime <= '" + queryParam["TimeArrive"].ToString() + "' ";
  1210. }
  1211. if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
  1212. {
  1213. wheresql += " and b.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
  1214. }
  1215. if (!string.IsNullOrWhiteSpace(queryParam["selIsUrgent"].ToString()))
  1216. {
  1217. wheresql += " and case d.EATTRIBUTE6 when '1' then '是' else '否' end = '" + queryParam["selIsUrgent"].ToString() + "' ";
  1218. }
  1219. if (!string.IsNullOrWhiteSpace(queryParam["selIsPrint"].ToString()))
  1220. {
  1221. string printState = queryParam["selIsPrint"].ToString();
  1222. if (printState == "否")
  1223. wheresql += " and isnull(task.ValueParameters,'') ='' ";
  1224. else if (printState == "是")
  1225. wheresql += " and isnull(task.ValueParameters,'') <>''";
  1226. }
  1227. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  1228. {
  1229. string ReleaseState = queryParam["ReleaseState"].ToString();
  1230. if (ReleaseState == "1")
  1231. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
  1232. else if (ReleaseState == "0")
  1233. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
  1234. else
  1235. wheresql += " ";
  1236. }
  1237. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  1238. {
  1239. string selEnableShow = queryParam["selEnableShow"].ToString();
  1240. if (selEnableShow == "1")
  1241. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
  1242. else if (selEnableShow == "0")
  1243. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
  1244. }
  1245. }
  1246. sql += @" GROUP BY a.ID , a.ODNCode ,a.Sequence ,a.OASNCode ,l.OOCode,c.InvCode , c.InvName , c.INVSTD , c.ClassName, c.InvUnit , a.CreateDateTime,a.MTIME,a.VenCode,m.VenName,
  1247. a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a. EATTRIBUTE7,a.EATTRIBUTE8,
  1248. a.EATTRIBUTE9,a.EATTRIBUTE10;select * into #TempWWLLData_2_1 from #TempWWLLData_2 ";
  1249. sql = string.Format(sql, wheresql, WorkPoint);
  1250. return Repository().FindTablePageBySql_OtherTemp(sql, "#TempWWLLData_2_1",
  1251. @" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempWWLLData_2'))
  1252. drop table #TempWWLLData_2
  1253. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempWWLLData_2_1'))
  1254. drop table #TempWWLLData_2_1
  1255. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_2'))
  1256. drop table #TempIcsinsp_2 ",
  1257. "connstr", parameter.ToArray(), ref jqgridparam);
  1258. // return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1259. }
  1260. //工单
  1261. public DataTable GetICSInspection3(ref Pagination jqgridparam, string queryJson)
  1262. {
  1263. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1264. DataTable dt = new DataTable();
  1265. var queryParam = queryJson.ToJObject();
  1266. List<DbParameter> parameter = new List<DbParameter>();
  1267. string sql = @"
  1268. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_3'))
  1269. drop table #TempMOData_3
  1270. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_3_1'))
  1271. drop table #TempMOData_3_1
  1272. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_3'))
  1273. drop table #TempIcsinsp_3
  1274. select ID,QualifiedQuantity,UnqualifiedQuantity,WaiveQuantity,
  1275. SampleQuantity,MUSERName,MTIME,Result,LotNo,BCCode,workpoint,BRCode,InvCode
  1276. into #TempIcsinsp_3
  1277. from dbo.ICSInspection
  1278. where workpoint='" + WorkPoint + @"' and Enable='1'
  1279. 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,
  1280. 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,
  1281. CAST(ISNULL(h.QualifiedQuantity,e.Quantity)as NUMERIC(10,4))as YLOTQTY ,
  1282. CAST(ISNULL(h.UnqualifiedQuantity, 0) as NUMERIC(10,4)) as NLOTQTY,
  1283. CAST(ISNULL(h.WaiveQuantity, 0) as NUMERIC(10,4)) as SpecialQTY,
  1284. CASE WHEN isnull(h.ID,'') ='' THEN isnull(p.SampleQuantity,0) ELSE CAST(ISNULL(h.SampleQuantity, 0) as decimal(18,4)) END AS SampleQuantity ,
  1285. c.InvUnit , e.LotNo , g.BadReasonDesc as BadReasonDesc ,
  1286. g.BadReasonCode as BRCodeValue,j.BadCode as BCCodeValue, j.BadDesc as BadDesc, i.ContainerID,
  1287. isnull(h.MUSERName,'') MUSERName, CONVERT(VARCHAR(100),e.ProductDate,120) as ProductTime,CONVERT(VARCHAR(100),h.MTIME,120) as MTIME,
  1288. CASE WHEN isnull(h.ID,'') ='' and c.InvFQC='1' THEN '' WHEN c.InvFQC='0' then '' ELSE '' END AS TestState,
  1289. isnull(h.MUSERName,'') as Surveyor, h.MTime as ProvingTime
  1290. ,CASE WHEN h.Result='0' THEN '' when ISNULL(h.Result,'')='' THEN '' ELSE '' END AS Result,
  1291. n.FileName,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  1292. a.EATTRIBUTE9,a.EATTRIBUTE10--,c.InvIQC
  1293. ,c.InvFQC
  1294. into #TempMOData_3
  1295. from ICSMO a
  1296. inner JOIN dbo.ICSInventory c ON a.InvCode = c.InvCode AND a.WorkPoint=c.WorkPoint --and c.InvIQC='1'
  1297. left join ICSInventoryLotDetail b on a.MOCode=b.TransCode and a.Sequence=b.TransSequence and a.WorkPoint=b.WorkPoint
  1298. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  1299. LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo=b.LotNo AND e.WorkPoint=b.WorkPoint
  1300. LEFT JOIN #TempIcsinsp_3 h ON h.LotNO=e.LotNO and h.InvCode=e.InvCode and h.WorkPoint=e.WorkPoint --and Enable='1'
  1301. left join ICSBadReason g on h.BRCode =g.BadReasonCode and h.WorkPoint=g.WorkPoint
  1302. left join ICSBadCode j on h.BCCode =j.BadCode and h.WorkPoint=j.WorkPoint
  1303. LEFT JOIN dbo.ICSContainerLot i ON e.LotNO=i.LotNO AND e.WorkPoint=i.WorkPoint
  1304. left join ICSInspectionFile n on h.id=n.InspectionID and h.WorkPoint=n.WorkPoint
  1305. LEFT JOIN ICSInventoryInspectionRulesGroup o ON a.InvCode=o.InvCode AND a.WorkPoint=o.WorkPoint
  1306. LEFT JOIN ICSInventoryInspectionRuleslist p ON o.id=p.invrulesid AND o.WorkPoint=p.WorkPoint AND e.Quantity BETWEEN p.SetValueMax AND p.SetValueMin
  1307. where a.MOStatus<>'3' and e.LotNO is not null {0} and isnull(e.EATTRIBUTE1,'' )='' and a.workpoint='{1}'
  1308. select * into #TempMOData_3_1 from #TempMOData_3 where --InvIQC='1'
  1309. InvFQC='1'
  1310. ";
  1311. string wheresql = "";
  1312. if (!string.IsNullOrWhiteSpace(queryJson))
  1313. {
  1314. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1315. {
  1316. wheresql += " and a.MOCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1317. }
  1318. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1319. {
  1320. wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1321. }
  1322. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1323. {
  1324. wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1325. }
  1326. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1327. {
  1328. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1329. }
  1330. if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
  1331. {
  1332. wheresql += " and e.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
  1333. }
  1334. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  1335. {
  1336. string ReleaseState = queryParam["ReleaseState"].ToString();
  1337. if (ReleaseState == "1")
  1338. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
  1339. else if (ReleaseState == "0")
  1340. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
  1341. else
  1342. wheresql += " ";
  1343. }
  1344. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  1345. {
  1346. string selEnableShow = queryParam["selEnableShow"].ToString();
  1347. if (selEnableShow == "1")
  1348. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
  1349. else if (selEnableShow == "0")
  1350. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
  1351. }
  1352. }
  1353. sql = string.Format(sql, wheresql, WorkPoint);
  1354. // return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1355. return Repository().FindTablePageBySql_OtherTemp(sql, "#TempMOData_3_1",
  1356. @" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_3'))
  1357. drop table #TempMOData_3
  1358. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_3_1'))
  1359. drop table #TempMOData_3_1
  1360. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_3'))
  1361. drop table #TempIcsinsp_3",
  1362. "connstr", parameter.ToArray(), ref jqgridparam);
  1363. }
  1364. /// <summary>
  1365. /// 工单检验(批次维度)
  1366. /// </summary>
  1367. /// <param name="jqgridparam"></param>
  1368. /// <param name="queryJson"></param>
  1369. /// <returns></returns>
  1370. public DataTable GetICSInspection3BatchCode(ref Pagination jqgridparam, string queryJson)
  1371. {
  1372. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1373. DataTable dt = new DataTable();
  1374. var queryParam = queryJson.ToJObject();
  1375. List<DbParameter> parameter = new List<DbParameter>();
  1376. string sql = @"
  1377. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_3'))
  1378. drop table #TempMOData_3
  1379. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_3_1'))
  1380. drop table #TempMOData_3_1
  1381. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_3'))
  1382. drop table #TempIcsinsp_3
  1383. select ID,QualifiedQuantity,UnqualifiedQuantity,WaiveQuantity,
  1384. SampleQuantity,MUSERName,MTIME,Result,LotNo,BCCode,workpoint,BRCode,InvCode
  1385. into #TempIcsinsp_3
  1386. from dbo.ICSInspection
  1387. where workpoint='" + WorkPoint + @"' and Enable='1'
  1388. select DISTINCT a.ID as GDID, a.MOCode as DNCode, a.Sequence , c.InvCode , c.InvName , c.INVSTD , c.ClassName,c.InvDesc,
  1389. 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, sum(e.Quantity)as AllNumber,
  1390. CAST(ISNULL(sum(h.QualifiedQuantity),sum(e.Quantity))as NUMERIC(10,4))as YLOTQTY ,
  1391. CAST(ISNULL(Sum(h.UnqualifiedQuantity), 0) as NUMERIC(10,4)) as NLOTQTY,
  1392. CAST(ISNULL(sum(h.WaiveQuantity), 0) as NUMERIC(10,4)) as SpecialQTY,
  1393. CAST(ISNULL(sum(h.SampleQuantity), 0) as NUMERIC(10,4)) as SampleQuantity,
  1394. c.InvUnit ,c.EATTRIBUTE3 as InvEATTRIBUTE3,
  1395. a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  1396. a.EATTRIBUTE9,a.EATTRIBUTE10
  1397. ,c.InvFQC
  1398. into #TempMOData_3
  1399. from ICSMO a
  1400. inner JOIN dbo.ICSInventory c ON a.InvCode = c.InvCode AND a.WorkPoint=c.WorkPoint --and c.InvIQC='1'
  1401. left join ICSInventoryLotDetail b on a.MOCode=b.TransCode and a.Sequence=b.TransSequence and a.WorkPoint=b.WorkPoint
  1402. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  1403. LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo=b.LotNo AND e.WorkPoint=b.WorkPoint
  1404. LEFT JOIN #TempIcsinsp_3 h ON h.LotNO=e.LotNO and h.InvCode=e.InvCode and h.WorkPoint=e.WorkPoint --and Enable='1'
  1405. where a.MOStatus<>'3' and e.LotNO is not null {0} and isnull(e.EATTRIBUTE1,'' )='' and a.workpoint='{1}'
  1406. ";
  1407. string wheresql = "";
  1408. if (!string.IsNullOrWhiteSpace(queryJson))
  1409. {
  1410. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1411. {
  1412. wheresql += " and a.MOCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1413. }
  1414. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1415. {
  1416. wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1417. }
  1418. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1419. {
  1420. wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1421. }
  1422. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1423. {
  1424. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1425. }
  1426. if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
  1427. {
  1428. wheresql += " and e.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
  1429. }
  1430. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  1431. {
  1432. string ReleaseState = queryParam["ReleaseState"].ToString();
  1433. if (ReleaseState == "1")
  1434. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
  1435. else if (ReleaseState == "0")
  1436. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
  1437. else
  1438. wheresql += " ";
  1439. }
  1440. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  1441. {
  1442. string selEnableShow = queryParam["selEnableShow"].ToString();
  1443. if (selEnableShow == "1")
  1444. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
  1445. else if (selEnableShow == "0")
  1446. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
  1447. }
  1448. }
  1449. sql += @" GROUP BY a.ID , a.MOCode , a.Sequence , c.InvCode , c.InvName , c.INVSTD , c.ClassName,c.InvDesc,
  1450. 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 , c.InvUnit ,
  1451. a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  1452. a.EATTRIBUTE9,a.EATTRIBUTE10
  1453. ,c.InvFQC ;select * into #TempMOData_3_1 from #TempMOData_3 where --InvIQC='1'
  1454. InvFQC='1';";
  1455. sql = string.Format(sql, wheresql, WorkPoint);
  1456. // return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1457. return Repository().FindTablePageBySql_OtherTemp(sql, "#TempMOData_3_1",
  1458. @" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_3'))
  1459. drop table #TempMOData_3
  1460. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_3_1'))
  1461. drop table #TempMOData_3_1
  1462. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_3'))
  1463. drop table #TempIcsinsp_3",
  1464. "connstr", parameter.ToArray(), ref jqgridparam);
  1465. }
  1466. /// <summary>
  1467. /// 工单检验(单据行维度)
  1468. /// </summary>
  1469. /// <param name="jqgridparam"></param>
  1470. /// <param name="queryJson"></param>
  1471. /// <returns></returns>
  1472. public DataTable GetICSInspection3DocSequence(ref Pagination jqgridparam, string queryJson)
  1473. {
  1474. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1475. DataTable dt = new DataTable();
  1476. var queryParam = queryJson.ToJObject();
  1477. List<DbParameter> parameter = new List<DbParameter>();
  1478. string sql = @"
  1479. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_3'))
  1480. drop table #TempMOData_3
  1481. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_3_1'))
  1482. drop table #TempMOData_3_1
  1483. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_3'))
  1484. drop table #TempIcsinsp_3
  1485. select ID,QualifiedQuantity,UnqualifiedQuantity,WaiveQuantity,
  1486. SampleQuantity,MUSERName,MTIME,Result,LotNo,BCCode,workpoint,BRCode,InvCode
  1487. into #TempIcsinsp_3
  1488. from dbo.ICSInspection
  1489. where workpoint='" + WorkPoint + @"' and Enable='1'
  1490. select DISTINCT a.ID as GDID, a.MOCode as DNCode, a.Sequence , c.InvCode , c.InvName , c.INVSTD , c.ClassName,c.InvDesc,
  1491. sum(e.Quantity)as AllNumber,
  1492. CAST(ISNULL(sum(h.QualifiedQuantity),sum(e.Quantity))as NUMERIC(10,4))as YLOTQTY ,
  1493. CAST(ISNULL(Sum(h.UnqualifiedQuantity), 0) as NUMERIC(10,4)) as NLOTQTY,
  1494. CAST(ISNULL(sum(h.WaiveQuantity), 0) as NUMERIC(10,4)) as SpecialQTY,
  1495. CAST(ISNULL(sum(h.SampleQuantity), 0) as NUMERIC(10,4)) as SampleQuantity,
  1496. c.InvUnit ,
  1497. a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  1498. a.EATTRIBUTE9,a.EATTRIBUTE10
  1499. ,c.InvFQC
  1500. into #TempMOData_3
  1501. from ICSMO a
  1502. inner JOIN dbo.ICSInventory c ON a.InvCode = c.InvCode AND a.WorkPoint=c.WorkPoint --and c.InvIQC='1'
  1503. left join ICSInventoryLotDetail b on a.MOCode=b.TransCode and a.Sequence=b.TransSequence and a.WorkPoint=b.WorkPoint
  1504. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  1505. LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo=b.LotNo AND e.WorkPoint=b.WorkPoint
  1506. LEFT JOIN #TempIcsinsp_3 h ON h.LotNO=e.LotNO and h.InvCode=e.InvCode and h.WorkPoint=e.WorkPoint --and Enable='1'
  1507. where a.MOStatus<>'3' and e.LotNO is not null {0} and isnull(e.EATTRIBUTE1,'' )='' and a.workpoint='{1}'
  1508. ";
  1509. string wheresql = "";
  1510. if (!string.IsNullOrWhiteSpace(queryJson))
  1511. {
  1512. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1513. {
  1514. wheresql += " and a.MOCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1515. }
  1516. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1517. {
  1518. wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1519. }
  1520. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1521. {
  1522. wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1523. }
  1524. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1525. {
  1526. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1527. }
  1528. if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
  1529. {
  1530. wheresql += " and e.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
  1531. }
  1532. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  1533. {
  1534. string ReleaseState = queryParam["ReleaseState"].ToString();
  1535. if (ReleaseState == "1")
  1536. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
  1537. else if (ReleaseState == "0")
  1538. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
  1539. else
  1540. wheresql += " ";
  1541. }
  1542. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  1543. {
  1544. string selEnableShow = queryParam["selEnableShow"].ToString();
  1545. if (selEnableShow == "1")
  1546. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
  1547. else if (selEnableShow == "0")
  1548. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
  1549. }
  1550. }
  1551. sql += @" GROUP BY a.ID , a.MOCode , a.Sequence , c.InvCode , c.InvName , c.INVSTD , c.ClassName,c.InvDesc,
  1552. c.InvUnit ,
  1553. a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  1554. a.EATTRIBUTE9,a.EATTRIBUTE10
  1555. ,c.InvFQC ;select * into #TempMOData_3_1 from #TempMOData_3 where --InvIQC='1'
  1556. InvFQC='1';";
  1557. sql = string.Format(sql, wheresql, WorkPoint);
  1558. // return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1559. return Repository().FindTablePageBySql_OtherTemp(sql, "#TempMOData_3_1",
  1560. @" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_3'))
  1561. drop table #TempMOData_3
  1562. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_3_1'))
  1563. drop table #TempMOData_3_1
  1564. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_3'))
  1565. drop table #TempIcsinsp_3",
  1566. "connstr", parameter.ToArray(), ref jqgridparam);
  1567. }
  1568. /// <summary>
  1569. /// 工单检验(单据维度)
  1570. /// </summary>
  1571. /// <param name="jqgridparam"></param>
  1572. /// <param name="queryJson"></param>
  1573. /// <returns></returns>
  1574. public DataTable GetICSInspection3Doc(ref Pagination jqgridparam, string queryJson)
  1575. {
  1576. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1577. DataTable dt = new DataTable();
  1578. var queryParam = queryJson.ToJObject();
  1579. List<DbParameter> parameter = new List<DbParameter>();
  1580. string sql = @"
  1581. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_3'))
  1582. drop table #TempMOData_3
  1583. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_3_1'))
  1584. drop table #TempMOData_3_1
  1585. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_3'))
  1586. drop table #TempIcsinsp_3
  1587. select ID,QualifiedQuantity,UnqualifiedQuantity,WaiveQuantity,
  1588. SampleQuantity,MUSERName,MTIME,Result,LotNo,BCCode,workpoint,BRCode,InvCode
  1589. into #TempIcsinsp_3
  1590. from dbo.ICSInspection
  1591. where workpoint='" + WorkPoint + @"' and Enable='1'
  1592. select DISTINCT a.MOCode as DNCode,
  1593. sum(e.Quantity)as AllNumber,
  1594. CAST(ISNULL(sum(h.QualifiedQuantity),sum(e.Quantity))as NUMERIC(10,4))as YLOTQTY ,
  1595. CAST(ISNULL(Sum(h.UnqualifiedQuantity), 0) as NUMERIC(10,4)) as NLOTQTY,
  1596. CAST(ISNULL(sum(h.WaiveQuantity), 0) as NUMERIC(10,4)) as SpecialQTY,
  1597. CAST(ISNULL(sum(h.SampleQuantity), 0) as NUMERIC(10,4)) as SampleQuantity
  1598. into #TempMOData_3
  1599. from ICSMO a
  1600. inner JOIN dbo.ICSInventory c ON a.InvCode = c.InvCode AND a.WorkPoint=c.WorkPoint and c.InvFQC='1'
  1601. left join ICSInventoryLotDetail b on a.MOCode=b.TransCode and a.Sequence=b.TransSequence and a.WorkPoint=b.WorkPoint
  1602. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  1603. LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo=b.LotNo AND e.WorkPoint=b.WorkPoint
  1604. LEFT JOIN #TempIcsinsp_3 h ON h.LotNO=e.LotNO and h.InvCode=e.InvCode and h.WorkPoint=e.WorkPoint --and Enable='1'
  1605. where a.MOStatus<>'3' and e.LotNO is not null {0} and isnull(e.EATTRIBUTE1,'' )='' and a.workpoint='{1}'
  1606. ";
  1607. string wheresql = "";
  1608. if (!string.IsNullOrWhiteSpace(queryJson))
  1609. {
  1610. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1611. {
  1612. wheresql += " and a.MOCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1613. }
  1614. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1615. {
  1616. wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1617. }
  1618. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1619. {
  1620. wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1621. }
  1622. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1623. {
  1624. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1625. }
  1626. if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
  1627. {
  1628. wheresql += " and e.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
  1629. }
  1630. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  1631. {
  1632. string ReleaseState = queryParam["ReleaseState"].ToString();
  1633. if (ReleaseState == "1")
  1634. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
  1635. else if (ReleaseState == "0")
  1636. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
  1637. else
  1638. wheresql += " ";
  1639. }
  1640. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  1641. {
  1642. string selEnableShow = queryParam["selEnableShow"].ToString();
  1643. if (selEnableShow == "1")
  1644. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
  1645. else if (selEnableShow == "0")
  1646. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
  1647. }
  1648. }
  1649. sql += @" GROUP BY a.MOCode ;select * into #TempMOData_3_1 from #TempMOData_3 ;";
  1650. sql = string.Format(sql, wheresql, WorkPoint);
  1651. // return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1652. return Repository().FindTablePageBySql_OtherTemp(sql, "#TempMOData_3_1",
  1653. @" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_3'))
  1654. drop table #TempMOData_3
  1655. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_3_1'))
  1656. drop table #TempMOData_3_1
  1657. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_3'))
  1658. drop table #TempIcsinsp_3",
  1659. "connstr", parameter.ToArray(), ref jqgridparam);
  1660. }
  1661. //其他入库
  1662. public DataTable GetICSInspection4(ref Pagination jqgridparam, string queryJson)
  1663. {
  1664. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1665. DataTable dt = new DataTable();
  1666. var queryParam = queryJson.ToJObject();
  1667. List<DbParameter> parameter = new List<DbParameter>();
  1668. string sql = @"
  1669. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempQTLLData_4'))
  1670. drop table #TempQTLLData_4
  1671. if exists(select * from tempdb..sysobjects where id = object_id('tempdb..#TempQTLLData_4_1'))
  1672. drop table #TempQTLLData_4_1
  1673. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_4'))
  1674. drop table #TempIcsinsp_4
  1675. select ID,QualifiedQuantity,UnqualifiedQuantity,WaiveQuantity,
  1676. SampleQuantity,MUSERName,MTIME,Result,LotNo,BCCode,workpoint,BRCode,InvCode
  1677. into #TempIcsinsp_4
  1678. from dbo.ICSInspection
  1679. where workpoint='" + WorkPoint + @"' and Enable='1'
  1680. 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,
  1681. 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, c.EATTRIBUTE3 as InvEATTRIBUTE3,
  1682. CAST(ISNULL(h.QualifiedQuantity,e.Quantity)as NUMERIC(10,4))as YLOTQTY ,
  1683. CAST(ISNULL(h.UnqualifiedQuantity, 0) as NUMERIC(10,4)) as NLOTQTY,
  1684. CAST(ISNULL(h.WaiveQuantity, 0) as NUMERIC(10,4)) as SpecialQTY,
  1685. CASE WHEN isnull(h.ID,'') ='' THEN isnull(p.SampleQuantity,0) ELSE CAST(ISNULL(h.SampleQuantity, 0) as decimal(18,4)) END AS SampleQuantity ,
  1686. c.InvUnit , e.LotNo , g.BadReasonDesc as BadReasonDesc ,
  1687. g.BadReasonCode as BRCodeValue,j.BadCode as BCCodeValue, j.BadDesc as BadDesc, i.ContainerID,
  1688. isnull(h.MUSERName,'') MUSERName, CONVERT(VARCHAR(100),e.ProductDate,120) as ProductTime,CONVERT(VARCHAR(100),h.MTIME,120) as MTIME,
  1689. CASE WHEN isnull(h.ID,'') =''THEN '' ELSE '' END AS TestState,
  1690. CASE WHEN isnull(task.ValueParameters,'') =''THEN '否' ELSE '是' END AS IsPrint,
  1691. isnull(h.MUSERName,'') as Surveyor, h.MTime as ProvingTime
  1692. ,CASE WHEN h.Result='0' THEN '' when ISNULL(h.Result,'')='' THEN '' ELSE '' END AS Result,
  1693. n.FileName,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  1694. a.EATTRIBUTE9,a.EATTRIBUTE10
  1695. ,(CASE ISNULL((SELECT COUNT(1) FROM dbo.ICSInspection hH2
  1696. WHERE hH2.LotNo=e.LotNo AND hH2.WorkPoint=b.WorkPoint and hh2.InvCode=e.InvCode),0)
  1697. WHEN 0 THEN '' WHEN 1 THEN '是' else '否' end ) IsFirstCK
  1698. ,case e.EATTRIBUTE6 when '1' then '是' else '否' end IsUrgent,c.InvIQC
  1699. INTO #TempQTLLData_4
  1700. from ICSOtherIn a
  1701. inner JOIN dbo.ICSInventory c ON a.InvCode = c.InvCode AND a.WorkPoint=c.WorkPoint --and c.InvIQC='1'
  1702. left join ICSInventoryLotDetail b on a.InCode=b.TransCode and a.Sequence=b.TransSequence and a.WorkPoint=b.WorkPoint
  1703. LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo=b.LotNo AND e.WorkPoint=b.WorkPoint AND ISNULL(e.EATTRIBUTE1,'')=''
  1704. left join ICSExtension f on e.ExtensionID=f.ID and e.WorkPoint=f.WorkPoint
  1705. LEFT JOIN #TempIcsinsp_4 h ON h.LotNO=e.LotNO and h.InvCode=e.InvCode and h.WorkPoint=e.WorkPoint --and Enable='1'
  1706. LEFT JOIN (SELECT DISTINCT ValueParameters FROM Sys_LableTask) task ON task.ValueParameters=h.ID
  1707. left join ICSBadReason g on h.BRCode =g.BadReasonCode and h.WorkPoint=g.WorkPoint
  1708. left join ICSBadCode j on h.BCCode =j.BadCode and h.WorkPoint=j.WorkPoint
  1709. LEFT JOIN dbo.ICSContainerLot i ON e.LotNO=i.LotNO AND e.WorkPoint=i.WorkPoint
  1710. left join ICSInspectionFile n on h.id=n.InspectionID and h.WorkPoint=n.WorkPoint
  1711. LEFT JOIN ICSInventoryInspectionRulesGroup o ON a.InvCode=o.InvCode AND a.WorkPoint=o.WorkPoint
  1712. LEFT JOIN ICSInventoryInspectionRuleslist p ON o.id=p.invrulesid AND o.WorkPoint=p.WorkPoint AND e.Quantity BETWEEN p.SetValueMax AND p.SetValueMin
  1713. where e.LotNO is not null {0} and a.workpoint='{1}'
  1714. select * into #TempQTLLData_4_1 from #TempQTLLData_4 where InvIQC='1' ";
  1715. string wheresql = "";
  1716. if (!string.IsNullOrWhiteSpace(queryJson))
  1717. {
  1718. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1719. {
  1720. wheresql += " and a.InCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1721. }
  1722. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1723. {
  1724. wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1725. }
  1726. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1727. {
  1728. wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1729. }
  1730. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1731. {
  1732. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1733. }
  1734. if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
  1735. {
  1736. wheresql += " and e.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
  1737. }
  1738. if (!string.IsNullOrWhiteSpace(queryParam["selIsUrgent"].ToString()))
  1739. {
  1740. wheresql += " and case e.EATTRIBUTE6 when '1' then '是' else '否' end = '" + queryParam["selIsUrgent"].ToString() + "' ";
  1741. }
  1742. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  1743. {
  1744. string ReleaseState = queryParam["ReleaseState"].ToString();
  1745. if (ReleaseState == "1")
  1746. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
  1747. else if (ReleaseState == "0")
  1748. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
  1749. else
  1750. wheresql += " ";
  1751. }
  1752. if (!string.IsNullOrWhiteSpace(queryParam["selIsPrint"].ToString()))
  1753. {
  1754. string printState = queryParam["selIsPrint"].ToString();
  1755. if (printState == "否")
  1756. wheresql += " and isnull(task.ValueParameters,'') ='' ";
  1757. else if (printState == "是")
  1758. wheresql += " and isnull(task.ValueParameters,'') <>''";
  1759. }
  1760. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  1761. {
  1762. string selEnableShow = queryParam["selEnableShow"].ToString();
  1763. if (selEnableShow == "1")
  1764. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
  1765. else if (selEnableShow == "0")
  1766. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
  1767. }
  1768. }
  1769. sql = string.Format(sql, wheresql, WorkPoint);
  1770. return Repository().FindTablePageBySql_OtherTemp(sql, "#TempQTLLData_4_1",
  1771. @" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempQTLLData_4'))
  1772. drop table #TempQTLLData_4
  1773. if exists(select * from tempdb..sysobjects where id = object_id('tempdb..#TempQTLLData_4_1'))
  1774. drop table #TempQTLLData_4_1
  1775. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_4'))
  1776. drop table #TempIcsinsp_4 ",
  1777. "connstr", parameter.ToArray(), ref jqgridparam);
  1778. // return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1779. }
  1780. /// <summary>
  1781. /// 其他入库检验(批次维度)
  1782. /// </summary>
  1783. /// <param name="jqgridparam"></param>
  1784. /// <param name="queryJson"></param>
  1785. /// <returns></returns>
  1786. public DataTable GetICSInspection4BatchCode(ref Pagination jqgridparam, string queryJson)
  1787. {
  1788. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1789. DataTable dt = new DataTable();
  1790. var queryParam = queryJson.ToJObject();
  1791. List<DbParameter> parameter = new List<DbParameter>();
  1792. string sql = @"
  1793. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempQTLLData_4'))
  1794. drop table #TempQTLLData_4
  1795. if exists(select * from tempdb..sysobjects where id = object_id('tempdb..#TempQTLLData_4_1'))
  1796. drop table #TempQTLLData_4_1
  1797. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_4'))
  1798. drop table #TempIcsinsp_4
  1799. select ID,QualifiedQuantity,UnqualifiedQuantity,WaiveQuantity,
  1800. SampleQuantity,MUSERName,MTIME,Result,LotNo,BCCode,workpoint,BRCode,InvCode
  1801. into #TempIcsinsp_4
  1802. from dbo.ICSInspection
  1803. where workpoint='" + WorkPoint + @"' and Enable='1'
  1804. select DISTINCT a.ID as GDID, a.InCode as DNCode, a.Sequence , c.InvCode , c.InvName , c.INVSTD , c.ClassName,
  1805. 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, sum(e.Quantity) as AllNumber,
  1806. CAST(ISNULL(sum(h.QualifiedQuantity),sum(e.Quantity))as NUMERIC(10,4))as YLOTQTY ,
  1807. CAST(ISNULL(sum(h.UnqualifiedQuantity), 0) as NUMERIC(10,4)) as NLOTQTY,
  1808. CAST(ISNULL(sum(h.WaiveQuantity), 0) as NUMERIC(10,4)) as SpecialQTY,
  1809. CAST(ISNULL(sum(h.SampleQuantity), 0) as NUMERIC(10,4)) as SampleQuantity,
  1810. c.InvUnit ,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  1811. a.EATTRIBUTE9,a.EATTRIBUTE10
  1812. INTO #TempQTLLData_4
  1813. from ICSOtherIn a
  1814. inner JOIN dbo.ICSInventory c ON a.InvCode = c.InvCode AND a.WorkPoint=c.WorkPoint and c.InvIQC='1'
  1815. left join ICSInventoryLotDetail b on a.InCode=b.TransCode and a.Sequence=b.TransSequence and a.WorkPoint=b.WorkPoint
  1816. LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo=b.LotNo AND e.WorkPoint=b.WorkPoint AND ISNULL(e.EATTRIBUTE1,'')=''
  1817. left join ICSExtension f on e.ExtensionID=f.ID and e.WorkPoint=f.WorkPoint
  1818. LEFT JOIN #TempIcsinsp_4 h ON h.LotNO=e.LotNO and h.InvCode=e.InvCode and h.WorkPoint=e.WorkPoint --and Enable='1'
  1819. where e.LotNO is not null {0} and a.workpoint='{1}'
  1820. ";
  1821. string wheresql = "";
  1822. if (!string.IsNullOrWhiteSpace(queryJson))
  1823. {
  1824. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1825. {
  1826. wheresql += " and a.InCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1827. }
  1828. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1829. {
  1830. wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1831. }
  1832. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1833. {
  1834. wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1835. }
  1836. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1837. {
  1838. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1839. }
  1840. if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
  1841. {
  1842. wheresql += " and e.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
  1843. }
  1844. if (!string.IsNullOrWhiteSpace(queryParam["selIsUrgent"].ToString()))
  1845. {
  1846. wheresql += " and case e.EATTRIBUTE6 when '1' then '是' else '否' end = '" + queryParam["selIsUrgent"].ToString() + "' ";
  1847. }
  1848. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  1849. {
  1850. string ReleaseState = queryParam["ReleaseState"].ToString();
  1851. if (ReleaseState == "1")
  1852. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
  1853. else if (ReleaseState == "0")
  1854. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
  1855. else
  1856. wheresql += " ";
  1857. }
  1858. if (!string.IsNullOrWhiteSpace(queryParam["selIsPrint"].ToString()))
  1859. {
  1860. string printState = queryParam["selIsPrint"].ToString();
  1861. if (printState == "否")
  1862. wheresql += " and isnull(task.ValueParameters,'') ='' ";
  1863. else if (printState == "是")
  1864. wheresql += " and isnull(task.ValueParameters,'') <>''";
  1865. }
  1866. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  1867. {
  1868. string selEnableShow = queryParam["selEnableShow"].ToString();
  1869. if (selEnableShow == "1")
  1870. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
  1871. else if (selEnableShow == "0")
  1872. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
  1873. }
  1874. }
  1875. sql += @" GROUP BY a.ID ,a.InCode , a.Sequence ,c.InvCode , c.InvName , c.INVSTD , c.ClassName,
  1876. 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, c.InvUnit ,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  1877. a.EATTRIBUTE9,a.EATTRIBUTE10;select * into #TempQTLLData_4_1 from #TempQTLLData_4 ";
  1878. sql = string.Format(sql, wheresql, WorkPoint);
  1879. return Repository().FindTablePageBySql_OtherTemp(sql, "#TempQTLLData_4_1",
  1880. @" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempQTLLData_4'))
  1881. drop table #TempQTLLData_4
  1882. if exists(select * from tempdb..sysobjects where id = object_id('tempdb..#TempQTLLData_4_1'))
  1883. drop table #TempQTLLData_4_1
  1884. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_4'))
  1885. drop table #TempIcsinsp_4 ",
  1886. "connstr", parameter.ToArray(), ref jqgridparam);
  1887. // return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1888. }
  1889. /// <summary>
  1890. /// 其他入库检验(单据行维度)
  1891. /// </summary>
  1892. /// <param name="jqgridparam"></param>
  1893. /// <param name="queryJson"></param>
  1894. /// <returns></returns>
  1895. public DataTable GetICSInspection4DocSequence(ref Pagination jqgridparam, string queryJson)
  1896. {
  1897. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1898. DataTable dt = new DataTable();
  1899. var queryParam = queryJson.ToJObject();
  1900. List<DbParameter> parameter = new List<DbParameter>();
  1901. string sql = @"
  1902. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempQTLLData_4'))
  1903. drop table #TempQTLLData_4
  1904. if exists(select * from tempdb..sysobjects where id = object_id('tempdb..#TempQTLLData_4_1'))
  1905. drop table #TempQTLLData_4_1
  1906. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_4'))
  1907. drop table #TempIcsinsp_4
  1908. select ID,QualifiedQuantity,UnqualifiedQuantity,WaiveQuantity,
  1909. SampleQuantity,MUSERName,MTIME,Result,LotNo,BCCode,workpoint,BRCode,InvCode
  1910. into #TempIcsinsp_4
  1911. from dbo.ICSInspection
  1912. where workpoint='" + WorkPoint + @"' and Enable='1'
  1913. select DISTINCT a.ID as GDID, a.InCode as DNCode, c.InvCode , c.InvName , c.INVSTD , c.ClassName,
  1914. sum(e.Quantity) as AllNumber,
  1915. CAST(ISNULL(sum(h.QualifiedQuantity),sum(e.Quantity))as NUMERIC(10,4))as YLOTQTY ,
  1916. CAST(ISNULL(sum(h.UnqualifiedQuantity), 0) as NUMERIC(10,4)) as NLOTQTY,
  1917. CAST(ISNULL(sum(h.WaiveQuantity), 0) as NUMERIC(10,4)) as SpecialQTY,
  1918. CAST(ISNULL(sum(h.SampleQuantity), 0) as NUMERIC(10,4)) as SampleQuantity,
  1919. c.InvUnit ,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  1920. a.EATTRIBUTE9,a.EATTRIBUTE10
  1921. INTO #TempQTLLData_4
  1922. from ICSOtherIn a
  1923. inner JOIN dbo.ICSInventory c ON a.InvCode = c.InvCode AND a.WorkPoint=c.WorkPoint and c.InvIQC='1'
  1924. left join ICSInventoryLotDetail b on a.InCode=b.TransCode and a.Sequence=b.TransSequence and a.WorkPoint=b.WorkPoint
  1925. LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo=b.LotNo AND e.WorkPoint=b.WorkPoint AND ISNULL(e.EATTRIBUTE1,'')=''
  1926. left join ICSExtension f on e.ExtensionID=f.ID and e.WorkPoint=f.WorkPoint
  1927. LEFT JOIN #TempIcsinsp_4 h ON h.LotNO=e.LotNO and h.InvCode=e.InvCode and h.WorkPoint=e.WorkPoint --and Enable='1'
  1928. where e.LotNO is not null {0} and a.workpoint='{1}'
  1929. ";
  1930. string wheresql = "";
  1931. if (!string.IsNullOrWhiteSpace(queryJson))
  1932. {
  1933. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  1934. {
  1935. wheresql += " and a.InCode like '%" + queryParam["POCode"].ToString() + "%' ";
  1936. }
  1937. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  1938. {
  1939. wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  1940. }
  1941. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  1942. {
  1943. wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  1944. }
  1945. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  1946. {
  1947. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  1948. }
  1949. if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
  1950. {
  1951. wheresql += " and e.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
  1952. }
  1953. if (!string.IsNullOrWhiteSpace(queryParam["selIsUrgent"].ToString()))
  1954. {
  1955. wheresql += " and case e.EATTRIBUTE6 when '1' then '是' else '否' end = '" + queryParam["selIsUrgent"].ToString() + "' ";
  1956. }
  1957. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  1958. {
  1959. string ReleaseState = queryParam["ReleaseState"].ToString();
  1960. if (ReleaseState == "1")
  1961. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
  1962. else if (ReleaseState == "0")
  1963. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
  1964. else
  1965. wheresql += " ";
  1966. }
  1967. if (!string.IsNullOrWhiteSpace(queryParam["selIsPrint"].ToString()))
  1968. {
  1969. string printState = queryParam["selIsPrint"].ToString();
  1970. if (printState == "否")
  1971. wheresql += " and isnull(task.ValueParameters,'') ='' ";
  1972. else if (printState == "是")
  1973. wheresql += " and isnull(task.ValueParameters,'') <>''";
  1974. }
  1975. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  1976. {
  1977. string selEnableShow = queryParam["selEnableShow"].ToString();
  1978. if (selEnableShow == "1")
  1979. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
  1980. else if (selEnableShow == "0")
  1981. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
  1982. }
  1983. }
  1984. sql += @" GROUP BY a.ID , a.InCode ,c.InvCode , c.InvName , c.INVSTD , c.ClassName, c.InvUnit ,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  1985. a.EATTRIBUTE9,a.EATTRIBUTE10 ;select * into #TempQTLLData_4_1 from #TempQTLLData_4 ";
  1986. sql = string.Format(sql, wheresql, WorkPoint);
  1987. return Repository().FindTablePageBySql_OtherTemp(sql, "#TempQTLLData_4_1",
  1988. @" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempQTLLData_4'))
  1989. drop table #TempQTLLData_4
  1990. if exists(select * from tempdb..sysobjects where id = object_id('tempdb..#TempQTLLData_4_1'))
  1991. drop table #TempQTLLData_4_1
  1992. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_4'))
  1993. drop table #TempIcsinsp_4 ",
  1994. "connstr", parameter.ToArray(), ref jqgridparam);
  1995. // return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  1996. }
  1997. /// <summary>
  1998. /// 其他入库检验(单据维度)
  1999. /// </summary>
  2000. /// <param name="jqgridparam"></param>
  2001. /// <param name="queryJson"></param>
  2002. /// <returns></returns>
  2003. public DataTable GetICSInspection4Doc(ref Pagination jqgridparam, string queryJson)
  2004. {
  2005. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2006. DataTable dt = new DataTable();
  2007. var queryParam = queryJson.ToJObject();
  2008. List<DbParameter> parameter = new List<DbParameter>();
  2009. string sql = @"
  2010. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempQTLLData_4'))
  2011. drop table #TempQTLLData_4
  2012. if exists(select * from tempdb..sysobjects where id = object_id('tempdb..#TempQTLLData_4_1'))
  2013. drop table #TempQTLLData_4_1
  2014. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_4'))
  2015. drop table #TempIcsinsp_4
  2016. select ID,QualifiedQuantity,UnqualifiedQuantity,WaiveQuantity,
  2017. SampleQuantity,MUSERName,MTIME,Result,LotNo,BCCode,workpoint,BRCode,InvCode
  2018. into #TempIcsinsp_4
  2019. from dbo.ICSInspection
  2020. where workpoint='" + WorkPoint + @"' and Enable='1'
  2021. select DISTINCT a.InCode as DNCode,
  2022. sum(e.Quantity) as AllNumber,
  2023. CAST(ISNULL(sum(h.QualifiedQuantity),sum(e.Quantity))as NUMERIC(10,4))as YLOTQTY ,
  2024. CAST(ISNULL(sum(h.UnqualifiedQuantity), 0) as NUMERIC(10,4)) as NLOTQTY,
  2025. CAST(ISNULL(sum(h.WaiveQuantity), 0) as NUMERIC(10,4)) as SpecialQTY,
  2026. CAST(ISNULL(sum(h.SampleQuantity), 0) as NUMERIC(10,4)) as SampleQuantity
  2027. INTO #TempQTLLData_4
  2028. from ICSOtherIn a
  2029. inner JOIN dbo.ICSInventory c ON a.InvCode = c.InvCode AND a.WorkPoint=c.WorkPoint and c.InvIQC='1'
  2030. left join ICSInventoryLotDetail b on a.InCode=b.TransCode and a.Sequence=b.TransSequence and a.WorkPoint=b.WorkPoint
  2031. LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo=b.LotNo AND e.WorkPoint=b.WorkPoint AND ISNULL(e.EATTRIBUTE1,'')=''
  2032. left join ICSExtension f on e.ExtensionID=f.ID and e.WorkPoint=f.WorkPoint
  2033. LEFT JOIN #TempIcsinsp_4 h ON h.LotNO=e.LotNO and h.InvCode=e.InvCode and h.WorkPoint=e.WorkPoint --and Enable='1'
  2034. where e.LotNO is not null {0} and a.workpoint='{1}'
  2035. ";
  2036. string wheresql = "";
  2037. if (!string.IsNullOrWhiteSpace(queryJson))
  2038. {
  2039. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  2040. {
  2041. wheresql += " and a.InCode like '%" + queryParam["POCode"].ToString() + "%' ";
  2042. }
  2043. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  2044. {
  2045. wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  2046. }
  2047. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  2048. {
  2049. wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  2050. }
  2051. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  2052. {
  2053. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  2054. }
  2055. if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
  2056. {
  2057. wheresql += " and e.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
  2058. }
  2059. if (!string.IsNullOrWhiteSpace(queryParam["selIsUrgent"].ToString()))
  2060. {
  2061. wheresql += " and case e.EATTRIBUTE6 when '1' then '是' else '否' end = '" + queryParam["selIsUrgent"].ToString() + "' ";
  2062. }
  2063. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  2064. {
  2065. string ReleaseState = queryParam["ReleaseState"].ToString();
  2066. if (ReleaseState == "1")
  2067. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
  2068. else if (ReleaseState == "0")
  2069. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
  2070. else
  2071. wheresql += " ";
  2072. }
  2073. if (!string.IsNullOrWhiteSpace(queryParam["selIsPrint"].ToString()))
  2074. {
  2075. string printState = queryParam["selIsPrint"].ToString();
  2076. if (printState == "否")
  2077. wheresql += " and isnull(task.ValueParameters,'') ='' ";
  2078. else if (printState == "是")
  2079. wheresql += " and isnull(task.ValueParameters,'') <>''";
  2080. }
  2081. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  2082. {
  2083. string selEnableShow = queryParam["selEnableShow"].ToString();
  2084. if (selEnableShow == "1")
  2085. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
  2086. else if (selEnableShow == "0")
  2087. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
  2088. }
  2089. }
  2090. sql += @" GROUP BY a.InCode ;select * into #TempQTLLData_4_1 from #TempQTLLData_4 ";
  2091. sql = string.Format(sql, wheresql, WorkPoint);
  2092. return Repository().FindTablePageBySql_OtherTemp(sql, "#TempQTLLData_4_1",
  2093. @" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempQTLLData_4'))
  2094. drop table #TempQTLLData_4
  2095. if exists(select * from tempdb..sysobjects where id = object_id('tempdb..#TempQTLLData_4_1'))
  2096. drop table #TempQTLLData_4_1
  2097. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_4'))
  2098. drop table #TempIcsinsp_4 ",
  2099. "connstr", parameter.ToArray(), ref jqgridparam);
  2100. // return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2101. }
  2102. //生产退料
  2103. public DataTable GetICSInspection5(ref Pagination jqgridparam, string queryJson)
  2104. {
  2105. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2106. DataTable dt = new DataTable();
  2107. var queryParam = queryJson.ToJObject();
  2108. List<DbParameter> parameter = new List<DbParameter>();
  2109. string sql = @"
  2110. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_5'))
  2111. drop table #TempMOData_5
  2112. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_5_1'))
  2113. drop table #TempMOData_5_1
  2114. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_5'))
  2115. drop table #TempIcsinsp_5
  2116. select ID,QualifiedQuantity,UnqualifiedQuantity,WaiveQuantity,
  2117. SampleQuantity,MUSERName,MTIME,Result,LotNo,BCCode,workpoint,BRCode,InvCode
  2118. into #TempIcsinsp_5
  2119. from dbo.ICSInspection
  2120. where workpoint='" + WorkPoint + @"' and Enable='1'
  2121. 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,
  2122. 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,
  2123. CAST(ISNULL(h.QualifiedQuantity,e.Quantity)as NUMERIC(10,4))as YLOTQTY ,
  2124. CAST(ISNULL(h.UnqualifiedQuantity, 0) as NUMERIC(10,4)) as NLOTQTY,
  2125. CAST(ISNULL(h.WaiveQuantity, 0) as NUMERIC(10,4)) as SpecialQTY,
  2126. CASE WHEN isnull(h.ID,'') ='' THEN isnull(p.SampleQuantity,0) ELSE CAST(ISNULL(h.SampleQuantity, 0) as decimal(18,4)) END AS SampleQuantity ,
  2127. c.InvUnit , e.LotNo , g.BadReasonDesc as BadReasonDesc ,c.EATTRIBUTE3 as InvEATTRIBUTE3,
  2128. g.BadReasonCode as BRCodeValue,j.BadCode as BCCodeValue, j.BadDesc as BadDesc, i.ContainerID,
  2129. isnull(h.MUSERName,'') MUSERName, CONVERT(VARCHAR(100),e.ProductDate,120) as ProductTime,CONVERT(VARCHAR(100),h.MTIME,120) as MTIME,
  2130. CASE WHEN isnull(h.ID,'') =''THEN '' ELSE '' END AS TestState,
  2131. isnull(h.MUSERName,'') as Surveyor, h.MTime as ProvingTime
  2132. ,CASE WHEN h.Result='0' THEN '' when ISNULL(h.Result,'')='' THEN '' ELSE '' END AS Result,
  2133. n.FileName ,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  2134. a.EATTRIBUTE9,a.EATTRIBUTE10,c.InvIQC
  2135. into #TempMOData_5
  2136. from ICSMOApplyNeg a
  2137. LEFT JOIN ICSMOApplyNegDetail ad ON a.ApplyNegCode=ad.ApplyNegCode AND a.WorkPoint=ad.WorkPoint
  2138. inner JOIN dbo.ICSInventory c ON ad.InvCode = c.InvCode AND ad.WorkPoint=c.WorkPoint --and c.InvIQC='1'
  2139. left join ICSInventoryLotDetail b on a.ApplyNegCode=b.TransCode and ad.Sequence=b.TransSequence and ad.WorkPoint=b.WorkPoint
  2140. left join ICSExtension f on ad.ExtensionID=f.ID and ad.WorkPoint=f.WorkPoint
  2141. LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo=b.LotNo AND e.WorkPoint=b.WorkPoint
  2142. LEFT JOIN #TempIcsinsp_5 h ON h.LotNO=e.LotNO and h.InvCode=e.InvCode and h.WorkPoint=e.WorkPoint-- and Enable='1'
  2143. left join ICSBadReason g on h.BRCode =g.BadReasonCode and h.WorkPoint=g.WorkPoint
  2144. left join ICSBadCode j on h.BCCode =j.BadCode and h.WorkPoint=j.WorkPoint
  2145. LEFT JOIN dbo.ICSContainerLot i ON e.LotNO=i.LotNO AND e.WorkPoint=i.WorkPoint
  2146. left join ICSInspectionFile n on h.id=n.InspectionID and h.WorkPoint=n.WorkPoint
  2147. LEFT JOIN ICSInventoryInspectionRulesGroup o ON ad.InvCode=o.InvCode AND a.WorkPoint=o.WorkPoint
  2148. LEFT JOIN ICSInventoryInspectionRuleslist p ON o.id=p.invrulesid AND o.WorkPoint=p.WorkPoint AND e.Quantity BETWEEN p.SetValueMax AND p.SetValueMin
  2149. where e.LotNO is not null {0} AND A.Workpoint='{1}'
  2150. select * into #TempMOData_5_1 from #TempMOData_5 where InvIQC='1' ";
  2151. string wheresql = "";
  2152. if (!string.IsNullOrWhiteSpace(queryJson))
  2153. {
  2154. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  2155. {
  2156. wheresql += " and a.ApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
  2157. }
  2158. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  2159. {
  2160. wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  2161. }
  2162. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  2163. {
  2164. wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  2165. }
  2166. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  2167. {
  2168. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  2169. }
  2170. if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
  2171. {
  2172. wheresql += " and e.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
  2173. }
  2174. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  2175. {
  2176. string ReleaseState = queryParam["ReleaseState"].ToString();
  2177. if (ReleaseState == "1")
  2178. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
  2179. else if (ReleaseState == "0")
  2180. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
  2181. else
  2182. wheresql += " ";
  2183. }
  2184. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  2185. {
  2186. string selEnableShow = queryParam["selEnableShow"].ToString();
  2187. if (selEnableShow == "1")
  2188. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
  2189. else if (selEnableShow == "0")
  2190. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
  2191. }
  2192. }
  2193. sql = string.Format(sql, wheresql, WorkPoint);
  2194. // return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2195. return Repository().FindTablePageBySql_OtherTemp(sql, "#TempMOData_5_1",
  2196. @" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_5'))
  2197. drop table #TempMOData_5
  2198. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_5_1'))
  2199. drop table #TempMOData_5_1
  2200. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_5'))
  2201. drop table #TempIcsinsp_5 ",
  2202. "connstr", parameter.ToArray(), ref jqgridparam);
  2203. }
  2204. /// <summary>
  2205. /// 生产退料(批次维度)
  2206. /// </summary>
  2207. /// <param name="jqgridparam"></param>
  2208. /// <param name="queryJson"></param>
  2209. /// <returns></returns>
  2210. public DataTable GetICSInspection5BatchCode(ref Pagination jqgridparam, string queryJson)
  2211. {
  2212. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2213. DataTable dt = new DataTable();
  2214. var queryParam = queryJson.ToJObject();
  2215. List<DbParameter> parameter = new List<DbParameter>();
  2216. string sql = @"
  2217. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_5'))
  2218. drop table #TempMOData_5
  2219. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_5_1'))
  2220. drop table #TempMOData_5_1
  2221. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_5'))
  2222. drop table #TempIcsinsp_5
  2223. select ID,QualifiedQuantity,UnqualifiedQuantity,WaiveQuantity,
  2224. SampleQuantity,MUSERName,MTIME,Result,LotNo,BCCode,workpoint,BRCode,InvCode
  2225. into #TempIcsinsp_5
  2226. from dbo.ICSInspection
  2227. where workpoint='" + WorkPoint + @"' and Enable='1'
  2228. select DISTINCT a.ID as GDID, a.ApplyNegCode as DNCode, ad.Sequence , c.InvCode , c.InvName , c.INVSTD , c.ClassName,
  2229. 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, sum(e.Quantity) as AllNumber,
  2230. CAST(ISNULL(sum(h.QualifiedQuantity),sum(e.Quantity))as NUMERIC(10,4))as YLOTQTY ,
  2231. CAST(ISNULL(sum(h.UnqualifiedQuantity), 0) as NUMERIC(10,4)) as NLOTQTY,
  2232. CAST(ISNULL(sum(h.WaiveQuantity), 0) as NUMERIC(10,4)) as SpecialQTY,
  2233. CAST(ISNULL(sum(h.SampleQuantity), 0) as NUMERIC(10,4)) as SampleQuantity,
  2234. c.InvUnit , a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,a.EATTRIBUTE9,a.EATTRIBUTE10,c.InvIQC
  2235. into #TempMOData_5
  2236. from ICSMOApplyNeg a
  2237. LEFT JOIN ICSMOApplyNegDetail ad ON a.ApplyNegCode=ad.ApplyNegCode AND a.WorkPoint=ad.WorkPoint
  2238. inner JOIN dbo.ICSInventory c ON ad.InvCode = c.InvCode AND ad.WorkPoint=c.WorkPoint --and c.InvIQC='1'
  2239. left join ICSInventoryLotDetail b on a.ApplyNegCode=b.TransCode and ad.Sequence=b.TransSequence and ad.WorkPoint=b.WorkPoint
  2240. left join ICSExtension f on ad.ExtensionID=f.ID and ad.WorkPoint=f.WorkPoint
  2241. LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo=b.LotNo AND e.WorkPoint=b.WorkPoint
  2242. LEFT JOIN #TempIcsinsp_5 h ON h.LotNO=e.LotNO and h.InvCode=e.InvCode and h.WorkPoint=e.WorkPoint-- and Enable='1'
  2243. where e.LotNO is not null {0} AND A.Workpoint='{1}'
  2244. ";
  2245. string wheresql = "";
  2246. if (!string.IsNullOrWhiteSpace(queryJson))
  2247. {
  2248. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  2249. {
  2250. wheresql += " and a.ApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
  2251. }
  2252. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  2253. {
  2254. wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  2255. }
  2256. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  2257. {
  2258. wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  2259. }
  2260. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  2261. {
  2262. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  2263. }
  2264. if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
  2265. {
  2266. wheresql += " and e.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
  2267. }
  2268. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  2269. {
  2270. string ReleaseState = queryParam["ReleaseState"].ToString();
  2271. if (ReleaseState == "1")
  2272. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
  2273. else if (ReleaseState == "0")
  2274. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
  2275. else
  2276. wheresql += " ";
  2277. }
  2278. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  2279. {
  2280. string selEnableShow = queryParam["selEnableShow"].ToString();
  2281. if (selEnableShow == "1")
  2282. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
  2283. else if (selEnableShow == "0")
  2284. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
  2285. }
  2286. }
  2287. sql += @" GROUP BY a.ID , a.ApplyNegCode , ad.Sequence , c.InvCode , c.InvName , c.INVSTD , c.ClassName,
  2288. 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,c.InvUnit , a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,a.EATTRIBUTE9,a.EATTRIBUTE10,c.InvIQC ; select * into #TempMOData_5_1 from #TempMOData_5 where InvIQC='1' ";
  2289. sql = string.Format(sql, wheresql, WorkPoint);
  2290. // return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2291. return Repository().FindTablePageBySql_OtherTemp(sql, "#TempMOData_5_1",
  2292. @" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_5'))
  2293. drop table #TempMOData_5
  2294. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_5_1'))
  2295. drop table #TempMOData_5_1
  2296. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_5'))
  2297. drop table #TempIcsinsp_5 ",
  2298. "connstr", parameter.ToArray(), ref jqgridparam);
  2299. }
  2300. /// <summary>
  2301. /// 生产退料(单据行维度)
  2302. /// </summary>
  2303. /// <param name="jqgridparam"></param>
  2304. /// <param name="queryJson"></param>
  2305. /// <returns></returns>
  2306. public DataTable GetICSInspection5DocSequence(ref Pagination jqgridparam, string queryJson)
  2307. {
  2308. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2309. DataTable dt = new DataTable();
  2310. var queryParam = queryJson.ToJObject();
  2311. List<DbParameter> parameter = new List<DbParameter>();
  2312. string sql = @"
  2313. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_5'))
  2314. drop table #TempMOData_5
  2315. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_5_1'))
  2316. drop table #TempMOData_5_1
  2317. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_5'))
  2318. drop table #TempIcsinsp_5
  2319. select ID,QualifiedQuantity,UnqualifiedQuantity,WaiveQuantity,
  2320. SampleQuantity,MUSERName,MTIME,Result,LotNo,BCCode,workpoint,BRCode,InvCode
  2321. into #TempIcsinsp_5
  2322. from dbo.ICSInspection
  2323. where workpoint='" + WorkPoint + @"' and Enable='1'
  2324. select a.ID as GDID, a.ApplyNegCode as DNCode, ad.Sequence , c.InvCode , c.InvName , c.INVSTD , c.ClassName,
  2325. sum(e.Quantity) as AllNumber,
  2326. CAST(ISNULL(sum(h.QualifiedQuantity),sum(e.Quantity))as NUMERIC(10,4))as YLOTQTY ,
  2327. CAST(ISNULL(sum(h.UnqualifiedQuantity), 0) as NUMERIC(10,4)) as NLOTQTY,
  2328. CAST(ISNULL(sum(h.WaiveQuantity), 0) as NUMERIC(10,4)) as SpecialQTY,
  2329. CAST(ISNULL(sum(h.SampleQuantity), 0) as NUMERIC(10,4)) as SampleQuantity,
  2330. c.InvUnit , a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,a.EATTRIBUTE9,a.EATTRIBUTE10,c.InvIQC
  2331. into #TempMOData_5
  2332. from ICSMOApplyNeg a
  2333. LEFT JOIN ICSMOApplyNegDetail ad ON a.ApplyNegCode=ad.ApplyNegCode AND a.WorkPoint=ad.WorkPoint
  2334. inner JOIN dbo.ICSInventory c ON ad.InvCode = c.InvCode AND ad.WorkPoint=c.WorkPoint --and c.InvIQC='1'
  2335. left join ICSInventoryLotDetail b on a.ApplyNegCode=b.TransCode and ad.Sequence=b.TransSequence and ad.WorkPoint=b.WorkPoint
  2336. left join ICSExtension f on ad.ExtensionID=f.ID and ad.WorkPoint=f.WorkPoint
  2337. LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo=b.LotNo AND e.WorkPoint=b.WorkPoint
  2338. LEFT JOIN #TempIcsinsp_5 h ON h.LotNO=e.LotNO and h.InvCode=e.InvCode and h.WorkPoint=e.WorkPoint-- and Enable='1'
  2339. where e.LotNO is not null {0} AND A.Workpoint='{1}'
  2340. ";
  2341. string wheresql = "";
  2342. if (!string.IsNullOrWhiteSpace(queryJson))
  2343. {
  2344. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  2345. {
  2346. wheresql += " and a.ApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
  2347. }
  2348. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  2349. {
  2350. wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  2351. }
  2352. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  2353. {
  2354. wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  2355. }
  2356. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  2357. {
  2358. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  2359. }
  2360. if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
  2361. {
  2362. wheresql += " and e.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
  2363. }
  2364. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  2365. {
  2366. string ReleaseState = queryParam["ReleaseState"].ToString();
  2367. if (ReleaseState == "1")
  2368. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
  2369. else if (ReleaseState == "0")
  2370. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
  2371. else
  2372. wheresql += " ";
  2373. }
  2374. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  2375. {
  2376. string selEnableShow = queryParam["selEnableShow"].ToString();
  2377. if (selEnableShow == "1")
  2378. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
  2379. else if (selEnableShow == "0")
  2380. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
  2381. }
  2382. }
  2383. sql += @" GROUP BY a.ID , a.ApplyNegCode , ad.Sequence , c.InvCode , c.InvName , c.INVSTD , c.ClassName, c.InvUnit ,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,a.EATTRIBUTE9,a.EATTRIBUTE10,c.InvIQC ; select * into #TempMOData_5_1 from #TempMOData_5 where InvIQC='1' ";
  2384. sql = string.Format(sql, wheresql, WorkPoint);
  2385. // return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2386. return Repository().FindTablePageBySql_OtherTemp(sql, "#TempMOData_5_1",
  2387. @" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_5'))
  2388. drop table #TempMOData_5
  2389. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_5_1'))
  2390. drop table #TempMOData_5_1
  2391. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_5'))
  2392. drop table #TempIcsinsp_5 ",
  2393. "connstr", parameter.ToArray(), ref jqgridparam);
  2394. }
  2395. /// <summary>
  2396. /// 生产退料(单据维度)
  2397. /// </summary>
  2398. /// <param name="jqgridparam"></param>
  2399. /// <param name="queryJson"></param>
  2400. /// <returns></returns>
  2401. public DataTable GetICSInspection5Doc(ref Pagination jqgridparam, string queryJson)
  2402. {
  2403. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2404. DataTable dt = new DataTable();
  2405. var queryParam = queryJson.ToJObject();
  2406. List<DbParameter> parameter = new List<DbParameter>();
  2407. string sql = @"
  2408. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_5'))
  2409. drop table #TempMOData_5
  2410. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_5_1'))
  2411. drop table #TempMOData_5_1
  2412. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_5'))
  2413. drop table #TempIcsinsp_5
  2414. select ID,QualifiedQuantity,UnqualifiedQuantity,WaiveQuantity,
  2415. SampleQuantity,MUSERName,MTIME,Result,LotNo,BCCode,workpoint,BRCode,InvCode
  2416. into #TempIcsinsp_5
  2417. from dbo.ICSInspection
  2418. where workpoint='" + WorkPoint + @"' and Enable='1'
  2419. select a.ApplyNegCode as DNCode,
  2420. sum(e.Quantity) as AllNumber,
  2421. CAST(ISNULL(sum(h.QualifiedQuantity),sum(e.Quantity))as NUMERIC(10,4))as YLOTQTY ,
  2422. CAST(ISNULL(sum(h.UnqualifiedQuantity), 0) as NUMERIC(10,4)) as NLOTQTY,
  2423. CAST(ISNULL(sum(h.WaiveQuantity), 0) as NUMERIC(10,4)) as SpecialQTY,
  2424. CAST(ISNULL(sum(h.SampleQuantity), 0) as NUMERIC(10,4)) as SampleQuantity
  2425. into #TempMOData_5
  2426. from ICSMOApplyNeg a
  2427. LEFT JOIN ICSMOApplyNegDetail ad ON a.ApplyNegCode=ad.ApplyNegCode AND a.WorkPoint=ad.WorkPoint
  2428. inner JOIN dbo.ICSInventory c ON ad.InvCode = c.InvCode AND ad.WorkPoint=c.WorkPoint and c.InvIQC='1'
  2429. left join ICSInventoryLotDetail b on a.ApplyNegCode=b.TransCode and ad.Sequence=b.TransSequence and ad.WorkPoint=b.WorkPoint
  2430. left join ICSExtension f on ad.ExtensionID=f.ID and ad.WorkPoint=f.WorkPoint
  2431. LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo=b.LotNo AND e.WorkPoint=b.WorkPoint
  2432. LEFT JOIN #TempIcsinsp_5 h ON h.LotNO=e.LotNO and h.InvCode=e.InvCode and h.WorkPoint=e.WorkPoint-- and Enable='1'
  2433. where e.LotNO is not null {0} AND A.Workpoint='{1}'
  2434. ";
  2435. string wheresql = "";
  2436. if (!string.IsNullOrWhiteSpace(queryJson))
  2437. {
  2438. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  2439. {
  2440. wheresql += " and a.ApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
  2441. }
  2442. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  2443. {
  2444. wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  2445. }
  2446. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  2447. {
  2448. wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  2449. }
  2450. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  2451. {
  2452. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  2453. }
  2454. if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
  2455. {
  2456. wheresql += " and e.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
  2457. }
  2458. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  2459. {
  2460. string ReleaseState = queryParam["ReleaseState"].ToString();
  2461. if (ReleaseState == "1")
  2462. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
  2463. else if (ReleaseState == "0")
  2464. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
  2465. else
  2466. wheresql += " ";
  2467. }
  2468. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  2469. {
  2470. string selEnableShow = queryParam["selEnableShow"].ToString();
  2471. if (selEnableShow == "1")
  2472. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
  2473. else if (selEnableShow == "0")
  2474. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
  2475. }
  2476. }
  2477. sql += @" GROUP BY a.ApplyNegCode ; select * into #TempMOData_5_1 from #TempMOData_5 ";
  2478. sql = string.Format(sql, wheresql, WorkPoint);
  2479. // return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2480. return Repository().FindTablePageBySql_OtherTemp(sql, "#TempMOData_5_1",
  2481. @" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_5'))
  2482. drop table #TempMOData_5
  2483. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_5_1'))
  2484. drop table #TempMOData_5_1
  2485. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_5'))
  2486. drop table #TempIcsinsp_5 ",
  2487. "connstr", parameter.ToArray(), ref jqgridparam);
  2488. }
  2489. //委外退料
  2490. public DataTable GetICSInspection6(ref Pagination jqgridparam, string queryJson)
  2491. {
  2492. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2493. DataTable dt = new DataTable();
  2494. var queryParam = queryJson.ToJObject();
  2495. List<DbParameter> parameter = new List<DbParameter>();
  2496. string sql = @"
  2497. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_6'))
  2498. drop table #TempMOData_6
  2499. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_6_1'))
  2500. drop table #TempMOData_6_1
  2501. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_6'))
  2502. drop table #TempIcsinsp_6
  2503. select ID,QualifiedQuantity,UnqualifiedQuantity,WaiveQuantity,
  2504. SampleQuantity,MUSERName,MTIME,Result,LotNo,BCCode,workpoint,BRCode,InvCode
  2505. into #TempIcsinsp_6
  2506. from dbo.ICSInspection
  2507. where workpoint='" + WorkPoint + @"' and Enable='1'
  2508. 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,
  2509. 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, c.EATTRIBUTE3 as InvEATTRIBUTE3,
  2510. CAST(ISNULL(h.QualifiedQuantity,e.Quantity)as NUMERIC(10,4))as YLOTQTY ,
  2511. CAST(ISNULL(h.UnqualifiedQuantity, 0) as NUMERIC(10,4)) as NLOTQTY,
  2512. CAST(ISNULL(h.WaiveQuantity, 0) as NUMERIC(10,4)) as SpecialQTY,
  2513. CASE WHEN isnull(h.ID,'') ='' THEN isnull(p.SampleQuantity,0) ELSE CAST(ISNULL(h.SampleQuantity, 0) as decimal(18,4)) END AS SampleQuantity ,
  2514. c.InvUnit , e.LotNo , g.BadReasonDesc as BadReasonDesc ,
  2515. g.BadReasonCode as BRCodeValue,j.BadCode as BCCodeValue, j.BadDesc as BadDesc, i.ContainerID,
  2516. isnull(h.MUSERName,'') MUSERName, CONVERT(VARCHAR(100),e.ProductDate,120) as ProductTime,CONVERT(VARCHAR(100),h.MTIME,120) as MTIME,
  2517. CASE WHEN isnull(h.ID,'') =''THEN '' ELSE '' END AS TestState,
  2518. isnull(h.MUSERName,'') as Surveyor, h.MTime as ProvingTime
  2519. ,CASE WHEN h.Result='0' THEN '' when ISNULL(h.Result,'')='' THEN '' ELSE '' END AS Result,
  2520. n.FileName,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  2521. a.EATTRIBUTE9,a.EATTRIBUTE10,c.InvIQC
  2522. into #TempMOData_6
  2523. from ICSOApplyNeg a
  2524. LEFT JOIN ICSOApplyNegDetail ad ON a.OApplyNegCode=ad.OApplyNegCode AND a.WorkPoint=ad.WorkPoint
  2525. inner JOIN dbo.ICSInventory c ON ad.InvCode = c.InvCode AND ad.WorkPoint=c.WorkPoint --and c.InvIQC='1'
  2526. left join ICSInventoryLotDetail b on a.OApplyNegCode=b.TransCode and ad.Sequence=b.TransSequence and ad.WorkPoint=b.WorkPoint
  2527. left join ICSExtension f on ad.ExtensionID=f.ID and ad.WorkPoint=f.WorkPoint
  2528. LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo=b.LotNo AND e.WorkPoint=b.WorkPoint
  2529. LEFT JOIN #TempIcsinsp_6 h ON h.LotNO=e.LotNO and h.InvCode=e.InvCode and h.WorkPoint=e.WorkPoint -- and Enable='1'
  2530. left join ICSBadReason g on h.BRCode =g.BadReasonCode and h.WorkPoint=g.WorkPoint
  2531. left join ICSBadCode j on h.BCCode =j.BadCode and h.WorkPoint=j.WorkPoint
  2532. LEFT JOIN dbo.ICSContainerLot i ON e.LotNO=i.LotNO AND e.WorkPoint=i.WorkPoint
  2533. left join ICSInspectionFile n on h.id=n.InspectionID and h.WorkPoint=n.WorkPoint
  2534. LEFT JOIN ICSInventoryInspectionRulesGroup o ON a.InvCode=o.InvCode AND a.WorkPoint=o.WorkPoint
  2535. LEFT JOIN ICSInventoryInspectionRuleslist p ON o.id=p.invrulesid AND o.WorkPoint=p.WorkPoint AND e.Quantity BETWEEN p.SetValueMax AND p.SetValueMin
  2536. where e.LotNO is not null {0} and a.workpoint='{1}'
  2537. select * into #TempMOData_6_1 from #TempMOData_6 where InvIQC='1'
  2538. ";
  2539. string wheresql = "";
  2540. if (!string.IsNullOrWhiteSpace(queryJson))
  2541. {
  2542. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  2543. {
  2544. wheresql += " and a.OApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
  2545. }
  2546. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  2547. {
  2548. wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  2549. }
  2550. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  2551. {
  2552. wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  2553. }
  2554. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  2555. {
  2556. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  2557. }
  2558. if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
  2559. {
  2560. wheresql += " and e.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
  2561. }
  2562. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  2563. {
  2564. string ReleaseState = queryParam["ReleaseState"].ToString();
  2565. if (ReleaseState == "1")
  2566. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
  2567. else if (ReleaseState == "0")
  2568. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
  2569. else
  2570. wheresql += " ";
  2571. }
  2572. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  2573. {
  2574. string selEnableShow = queryParam["selEnableShow"].ToString();
  2575. if (selEnableShow == "1")
  2576. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
  2577. else if (selEnableShow == "0")
  2578. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
  2579. }
  2580. }
  2581. sql = string.Format(sql, wheresql, WorkPoint);
  2582. // return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2583. return Repository().FindTablePageBySql_OtherTemp(sql, "#TempMOData_6_1",
  2584. @" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_6'))
  2585. drop table #TempMOData_6
  2586. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_6_1'))
  2587. drop table #TempMOData_6_1
  2588. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_6'))
  2589. drop table #TempIcsinsp_6 ",
  2590. "connstr", parameter.ToArray(), ref jqgridparam);
  2591. }
  2592. /// <summary>
  2593. /// 委外退料(批次维度)
  2594. /// </summary>
  2595. /// <param name="jqgridparam"></param>
  2596. /// <param name="queryJson"></param>
  2597. /// <returns></returns>
  2598. public DataTable GetICSInspection6BatchCode(ref Pagination jqgridparam, string queryJson)
  2599. {
  2600. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2601. DataTable dt = new DataTable();
  2602. var queryParam = queryJson.ToJObject();
  2603. List<DbParameter> parameter = new List<DbParameter>();
  2604. string sql = @"
  2605. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_6'))
  2606. drop table #TempMOData_6
  2607. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_6_1'))
  2608. drop table #TempMOData_6_1
  2609. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_6'))
  2610. drop table #TempIcsinsp_6
  2611. select ID,QualifiedQuantity,UnqualifiedQuantity,WaiveQuantity,
  2612. SampleQuantity,MUSERName,MTIME,Result,LotNo,BCCode,workpoint,BRCode,InvCode
  2613. into #TempIcsinsp_6
  2614. from dbo.ICSInspection
  2615. where workpoint='" + WorkPoint + @"' and Enable='1'
  2616. select DISTINCT a.ID as GDID, a.OApplyNegCode as DNCode, ad.Sequence , c.InvCode , c.InvName , c.INVSTD , c.ClassName,
  2617. 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, sum(e.Quantity) as AllNumber,
  2618. CAST(ISNULL(sum(h.QualifiedQuantity),sum(e.Quantity))as NUMERIC(10,4))as YLOTQTY ,
  2619. CAST(ISNULL(sum(h.UnqualifiedQuantity), 0) as NUMERIC(10,4)) as NLOTQTY,
  2620. CAST(ISNULL(sum(h.WaiveQuantity), 0) as NUMERIC(10,4)) as SpecialQTY,
  2621. CAST(ISNULL(sum(h.SampleQuantity), 0) as NUMERIC(10,4)) as SampleQuantity,
  2622. c.InvUnit ,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,a.EATTRIBUTE9,a.EATTRIBUTE10,c.InvIQC
  2623. into #TempMOData_6
  2624. from ICSOApplyNeg a
  2625. LEFT JOIN ICSOApplyNegDetail ad ON a.OApplyNegCode=ad.OApplyNegCode AND a.WorkPoint=ad.WorkPoint
  2626. inner JOIN dbo.ICSInventory c ON ad.InvCode = c.InvCode AND ad.WorkPoint=c.WorkPoint --and c.InvIQC='1'
  2627. left join ICSInventoryLotDetail b on a.OApplyNegCode=b.TransCode and ad.Sequence=b.TransSequence and ad.WorkPoint=b.WorkPoint
  2628. left join ICSExtension f on ad.ExtensionID=f.ID and ad.WorkPoint=f.WorkPoint
  2629. LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo=b.LotNo AND e.WorkPoint=b.WorkPoint
  2630. LEFT JOIN #TempIcsinsp_6 h ON h.LotNO=e.LotNO and h.InvCode=e.InvCode and h.WorkPoint=e.WorkPoint -- and Enable='1'
  2631. where e.LotNO is not null {0} and a.workpoint='{1}'
  2632. ";
  2633. string wheresql = "";
  2634. if (!string.IsNullOrWhiteSpace(queryJson))
  2635. {
  2636. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  2637. {
  2638. wheresql += " and a.OApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
  2639. }
  2640. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  2641. {
  2642. wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  2643. }
  2644. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  2645. {
  2646. wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  2647. }
  2648. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  2649. {
  2650. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  2651. }
  2652. if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
  2653. {
  2654. wheresql += " and e.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
  2655. }
  2656. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  2657. {
  2658. string ReleaseState = queryParam["ReleaseState"].ToString();
  2659. if (ReleaseState == "1")
  2660. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
  2661. else if (ReleaseState == "0")
  2662. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
  2663. else
  2664. wheresql += " ";
  2665. }
  2666. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  2667. {
  2668. string selEnableShow = queryParam["selEnableShow"].ToString();
  2669. if (selEnableShow == "1")
  2670. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
  2671. else if (selEnableShow == "0")
  2672. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
  2673. }
  2674. }
  2675. sql += @" GROUP BY a.ID , a.OApplyNegCode , ad.Sequence , c.InvCode , c.InvName , c.INVSTD , c.ClassName, 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, c.InvUnit ,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,a.EATTRIBUTE9,a.EATTRIBUTE10,c.InvIQC; select * into #TempMOData_6_1 from #TempMOData_6 where InvIQC='1' ;";
  2676. sql = string.Format(sql, wheresql, WorkPoint);
  2677. // return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2678. return Repository().FindTablePageBySql_OtherTemp(sql, "#TempMOData_6_1",
  2679. @" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_6'))
  2680. drop table #TempMOData_6
  2681. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_6_1'))
  2682. drop table #TempMOData_6_1
  2683. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_6'))
  2684. drop table #TempIcsinsp_6 ",
  2685. "connstr", parameter.ToArray(), ref jqgridparam);
  2686. }
  2687. /// <summary>
  2688. /// 委外退料(单据行维度)
  2689. /// </summary>
  2690. /// <param name="jqgridparam"></param>
  2691. /// <param name="queryJson"></param>
  2692. /// <returns></returns>
  2693. public DataTable GetICSInspection6DocSequence(ref Pagination jqgridparam, string queryJson)
  2694. {
  2695. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2696. DataTable dt = new DataTable();
  2697. var queryParam = queryJson.ToJObject();
  2698. List<DbParameter> parameter = new List<DbParameter>();
  2699. string sql = @"
  2700. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_6'))
  2701. drop table #TempMOData_6
  2702. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_6_1'))
  2703. drop table #TempMOData_6_1
  2704. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_6'))
  2705. drop table #TempIcsinsp_6
  2706. select ID,QualifiedQuantity,UnqualifiedQuantity,WaiveQuantity,
  2707. SampleQuantity,MUSERName,MTIME,Result,LotNo,BCCode,workpoint,BRCode,InvCode
  2708. into #TempIcsinsp_6
  2709. from dbo.ICSInspection
  2710. where workpoint='" + WorkPoint + @"' and Enable='1'
  2711. select DISTINCT a.ID as GDID, a.OApplyNegCode as DNCode, ad.Sequence , c.InvCode , c.InvName , c.INVSTD , c.ClassName,
  2712. sum(e.Quantity) as AllNumber,
  2713. CAST(ISNULL(sum(h.QualifiedQuantity),sum(e.Quantity))as NUMERIC(10,4))as YLOTQTY ,
  2714. CAST(ISNULL(sum(h.UnqualifiedQuantity), 0) as NUMERIC(10,4)) as NLOTQTY,
  2715. CAST(ISNULL(sum(h.WaiveQuantity), 0) as NUMERIC(10,4)) as SpecialQTY,
  2716. CAST(ISNULL(sum(h.SampleQuantity), 0) as NUMERIC(10,4)) as SampleQuantity,
  2717. c.InvUnit ,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,a.EATTRIBUTE9,a.EATTRIBUTE10,c.InvIQC
  2718. into #TempMOData_6
  2719. from ICSOApplyNeg a
  2720. LEFT JOIN ICSOApplyNegDetail ad ON a.OApplyNegCode=ad.OApplyNegCode AND a.WorkPoint=ad.WorkPoint
  2721. inner JOIN dbo.ICSInventory c ON ad.InvCode = c.InvCode AND ad.WorkPoint=c.WorkPoint --and c.InvIQC='1'
  2722. left join ICSInventoryLotDetail b on a.OApplyNegCode=b.TransCode and ad.Sequence=b.TransSequence and ad.WorkPoint=b.WorkPoint
  2723. left join ICSExtension f on ad.ExtensionID=f.ID and ad.WorkPoint=f.WorkPoint
  2724. LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo=b.LotNo AND e.WorkPoint=b.WorkPoint
  2725. LEFT JOIN #TempIcsinsp_6 h ON h.LotNO=e.LotNO and h.InvCode=e.InvCode and h.WorkPoint=e.WorkPoint -- and Enable='1'
  2726. where e.LotNO is not null {0} and a.workpoint='{1}'
  2727. ";
  2728. string wheresql = "";
  2729. if (!string.IsNullOrWhiteSpace(queryJson))
  2730. {
  2731. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  2732. {
  2733. wheresql += " and a.OApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
  2734. }
  2735. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  2736. {
  2737. wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  2738. }
  2739. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  2740. {
  2741. wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  2742. }
  2743. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  2744. {
  2745. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  2746. }
  2747. if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
  2748. {
  2749. wheresql += " and e.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
  2750. }
  2751. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  2752. {
  2753. string ReleaseState = queryParam["ReleaseState"].ToString();
  2754. if (ReleaseState == "1")
  2755. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
  2756. else if (ReleaseState == "0")
  2757. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
  2758. else
  2759. wheresql += " ";
  2760. }
  2761. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  2762. {
  2763. string selEnableShow = queryParam["selEnableShow"].ToString();
  2764. if (selEnableShow == "1")
  2765. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
  2766. else if (selEnableShow == "0")
  2767. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
  2768. }
  2769. }
  2770. sql += @" GROUP BY a.ID , a.OApplyNegCode , ad.Sequence , c.InvCode , c.InvName , c.INVSTD , c.ClassName,
  2771. c.InvUnit ,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,a.EATTRIBUTE9,a.EATTRIBUTE10,c.InvIQC; select * into #TempMOData_6_1 from #TempMOData_6 where InvIQC='1' ;";
  2772. sql = string.Format(sql, wheresql, WorkPoint);
  2773. // return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2774. return Repository().FindTablePageBySql_OtherTemp(sql, "#TempMOData_6_1",
  2775. @" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_6'))
  2776. drop table #TempMOData_6
  2777. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_6_1'))
  2778. drop table #TempMOData_6_1
  2779. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_6'))
  2780. drop table #TempIcsinsp_6 ",
  2781. "connstr", parameter.ToArray(), ref jqgridparam);
  2782. }
  2783. /// <summary>
  2784. /// 委外退料(单据维度)
  2785. /// </summary>
  2786. /// <param name="jqgridparam"></param>
  2787. /// <param name="queryJson"></param>
  2788. /// <returns></returns>
  2789. public DataTable GetICSInspection6Doc(ref Pagination jqgridparam, string queryJson)
  2790. {
  2791. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2792. DataTable dt = new DataTable();
  2793. var queryParam = queryJson.ToJObject();
  2794. List<DbParameter> parameter = new List<DbParameter>();
  2795. string sql = @"
  2796. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_6'))
  2797. drop table #TempMOData_6
  2798. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_6_1'))
  2799. drop table #TempMOData_6_1
  2800. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_6'))
  2801. drop table #TempIcsinsp_6
  2802. select ID,QualifiedQuantity,UnqualifiedQuantity,WaiveQuantity,
  2803. SampleQuantity,MUSERName,MTIME,Result,LotNo,BCCode,workpoint,BRCode,InvCode
  2804. into #TempIcsinsp_6
  2805. from dbo.ICSInspection
  2806. where workpoint='" + WorkPoint + @"' and Enable='1'
  2807. select DISTINCT a.OApplyNegCode as DNCode,
  2808. sum(e.Quantity) as AllNumber,
  2809. CAST(ISNULL(sum(h.QualifiedQuantity),sum(e.Quantity))as NUMERIC(10,4))as YLOTQTY ,
  2810. CAST(ISNULL(sum(h.UnqualifiedQuantity), 0) as NUMERIC(10,4)) as NLOTQTY,
  2811. CAST(ISNULL(sum(h.WaiveQuantity), 0) as NUMERIC(10,4)) as SpecialQTY,
  2812. CAST(ISNULL(sum(h.SampleQuantity), 0) as NUMERIC(10,4)) as SampleQuantity
  2813. into #TempMOData_6
  2814. from ICSOApplyNeg a
  2815. LEFT JOIN ICSOApplyNegDetail ad ON a.OApplyNegCode=ad.OApplyNegCode AND a.WorkPoint=ad.WorkPoint
  2816. inner JOIN dbo.ICSInventory c ON ad.InvCode = c.InvCode AND ad.WorkPoint=c.WorkPoint and c.InvIQC='1'
  2817. left join ICSInventoryLotDetail b on a.OApplyNegCode=b.TransCode and ad.Sequence=b.TransSequence and ad.WorkPoint=b.WorkPoint
  2818. left join ICSExtension f on ad.ExtensionID=f.ID and ad.WorkPoint=f.WorkPoint
  2819. LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo=b.LotNo AND e.WorkPoint=b.WorkPoint
  2820. LEFT JOIN #TempIcsinsp_6 h ON h.LotNO=e.LotNO and h.InvCode=e.InvCode and h.WorkPoint=e.WorkPoint -- and Enable='1'
  2821. where e.LotNO is not null {0} and a.workpoint='{1}'
  2822. ";
  2823. string wheresql = "";
  2824. if (!string.IsNullOrWhiteSpace(queryJson))
  2825. {
  2826. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  2827. {
  2828. wheresql += " and a.OApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
  2829. }
  2830. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  2831. {
  2832. wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  2833. }
  2834. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  2835. {
  2836. wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  2837. }
  2838. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  2839. {
  2840. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  2841. }
  2842. if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
  2843. {
  2844. wheresql += " and e.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
  2845. }
  2846. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  2847. {
  2848. string ReleaseState = queryParam["ReleaseState"].ToString();
  2849. if (ReleaseState == "1")
  2850. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
  2851. else if (ReleaseState == "0")
  2852. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
  2853. else
  2854. wheresql += " ";
  2855. }
  2856. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  2857. {
  2858. string selEnableShow = queryParam["selEnableShow"].ToString();
  2859. if (selEnableShow == "1")
  2860. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
  2861. else if (selEnableShow == "0")
  2862. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
  2863. }
  2864. }
  2865. sql += @" GROUP BY a.OApplyNegCode; select * into #TempMOData_6_1 from #TempMOData_6 ;";
  2866. sql = string.Format(sql, wheresql, WorkPoint);
  2867. // return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2868. return Repository().FindTablePageBySql_OtherTemp(sql, "#TempMOData_6_1",
  2869. @" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_6'))
  2870. drop table #TempMOData_6
  2871. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_6_1'))
  2872. drop table #TempMOData_6_1
  2873. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_6'))
  2874. drop table #TempIcsinsp_6 ",
  2875. "connstr", parameter.ToArray(), ref jqgridparam);
  2876. }
  2877. //销售退货
  2878. public DataTable GetICSInspection7(ref Pagination jqgridparam, string queryJson)
  2879. {
  2880. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2881. DataTable dt = new DataTable();
  2882. var queryParam = queryJson.ToJObject();
  2883. List<DbParameter> parameter = new List<DbParameter>();
  2884. string sql = @"
  2885. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_7'))
  2886. drop table #TempMOData_7
  2887. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData7_1'))
  2888. drop table #TempMOData_7_1
  2889. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_7'))
  2890. drop table #TempIcsinsp_7
  2891. select ID,QualifiedQuantity,UnqualifiedQuantity,WaiveQuantity,
  2892. SampleQuantity,MUSERName,MTIME,Result,LotNo,BCCode,workpoint,BRCode,InvCode
  2893. into #TempIcsinsp_7
  2894. from dbo.ICSInspection
  2895. where workpoint='" + WorkPoint + @"' and Enable='1'
  2896. 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,
  2897. 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, c.EATTRIBUTE3 as InvEATTRIBUTE3,
  2898. CAST(ISNULL(h.QualifiedQuantity,e.Quantity)as NUMERIC(10,4))as YLOTQTY ,
  2899. CAST(ISNULL(h.UnqualifiedQuantity, 0) as NUMERIC(10,4)) as NLOTQTY,
  2900. CAST(ISNULL(h.WaiveQuantity, 0) as NUMERIC(10,4)) as SpecialQTY,
  2901. CASE WHEN isnull(h.ID,'') ='' THEN isnull(p.SampleQuantity,0) ELSE CAST(ISNULL(h.SampleQuantity, 0) as decimal(18,4)) END AS SampleQuantity ,
  2902. c.InvUnit , e.LotNo , g.BadReasonDesc as BadReasonDesc ,
  2903. g.BadReasonCode as BRCodeValue,j.BadCode as BCCodeValue, j.BadDesc as BadDesc, i.ContainerID,
  2904. isnull(h.MUSERName,'') MUSERName, CONVERT(VARCHAR(100),e.ProductDate,120) as ProductTime,CONVERT(VARCHAR(100),h.MTIME,120) as MTIME,
  2905. CASE WHEN isnull(h.ID,'') =''THEN '' ELSE '' END AS TestState,
  2906. isnull(h.MUSERName,'') as Surveyor, h.MTime as ProvingTime
  2907. ,CASE WHEN h.Result='0' THEN '' when ISNULL(h.Result,'')='' THEN '' ELSE '' END AS Result,
  2908. n.FileName,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  2909. a.EATTRIBUTE9,a.EATTRIBUTE10,c.InvIQC
  2910. into #TempMOData_7
  2911. from ICSSDN a
  2912. inner JOIN dbo.ICSInventory c ON a.InvCode = c.InvCode AND a.WorkPoint=c.WorkPoint --and c.InvIQC='1'
  2913. left join ICSInventoryLotDetail b on a.SDNCode=b.TransCode and a.Sequence=b.TransSequence and a.WorkPoint=b.WorkPoint
  2914. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  2915. LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo=b.LotNo AND e.WorkPoint=b.WorkPoint
  2916. LEFT JOIN #TempIcsinsp_7 h ON h.LotNO=e.LotNO and h.InvCode=e.InvCode and h.WorkPoint=e.WorkPoint -- and Enable='1'
  2917. left join ICSBadReason g on h.BRCode =g.BadReasonCode and h.WorkPoint=g.WorkPoint
  2918. left join ICSBadCode j on h.BCCode =j.BadCode and h.WorkPoint=j.WorkPoint
  2919. LEFT JOIN dbo.ICSContainerLot i ON e.LotNO=i.LotNO AND e.WorkPoint=i.WorkPoint
  2920. left join ICSInspectionFile n on h.id=n.InspectionID and h.WorkPoint=n.WorkPoint
  2921. LEFT JOIN ICSInventoryInspectionRulesGroup o ON a.InvCode=o.InvCode AND a.WorkPoint=o.WorkPoint
  2922. LEFT JOIN ICSInventoryInspectionRuleslist p ON o.id=p.invrulesid AND o.WorkPoint=p.WorkPoint AND e.Quantity BETWEEN p.SetValueMax AND p.SetValueMin
  2923. where e.LotNO is not null AND a.Type='2' {0} and a.workpoint='{1}'
  2924. select * into #TempMOData_7_1 from #TempMOData_7 where InvIQC='1' ";
  2925. string wheresql = "";
  2926. if (!string.IsNullOrWhiteSpace(queryJson))
  2927. {
  2928. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  2929. {
  2930. wheresql += " and a.SDNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  2931. }
  2932. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  2933. {
  2934. wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  2935. }
  2936. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  2937. {
  2938. wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  2939. }
  2940. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  2941. {
  2942. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  2943. }
  2944. if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
  2945. {
  2946. wheresql += " and e.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
  2947. }
  2948. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  2949. {
  2950. string ReleaseState = queryParam["ReleaseState"].ToString();
  2951. if (ReleaseState == "1")
  2952. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
  2953. else if (ReleaseState == "0")
  2954. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
  2955. else
  2956. wheresql += " ";
  2957. }
  2958. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  2959. {
  2960. string selEnableShow = queryParam["selEnableShow"].ToString();
  2961. if (selEnableShow == "1")
  2962. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
  2963. else if (selEnableShow == "0")
  2964. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
  2965. }
  2966. }
  2967. sql = string.Format(sql, wheresql, WorkPoint);
  2968. // return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  2969. return Repository().FindTablePageBySql_OtherTemp(sql, "#TempMOData_7_1",
  2970. @" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_7'))
  2971. drop table #TempMOData_7
  2972. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData7_1'))
  2973. drop table #TempMOData_7_1
  2974. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_7'))
  2975. drop table #TempIcsinsp_7 ",
  2976. "connstr", parameter.ToArray(), ref jqgridparam);
  2977. }
  2978. /// <summary>
  2979. /// 销售退货(批次维度)
  2980. /// </summary>
  2981. /// <param name="jqgridparam"></param>
  2982. /// <param name="queryJson"></param>
  2983. /// <returns></returns>
  2984. public DataTable GetICSInspection7BatchCode(ref Pagination jqgridparam, string queryJson)
  2985. {
  2986. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  2987. DataTable dt = new DataTable();
  2988. var queryParam = queryJson.ToJObject();
  2989. List<DbParameter> parameter = new List<DbParameter>();
  2990. string sql = @"
  2991. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_7'))
  2992. drop table #TempMOData_7
  2993. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData7_1'))
  2994. drop table #TempMOData_7_1
  2995. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_7'))
  2996. drop table #TempIcsinsp_7
  2997. select ID,QualifiedQuantity,UnqualifiedQuantity,WaiveQuantity,
  2998. SampleQuantity,MUSERName,MTIME,Result,LotNo,BCCode,workpoint,BRCode,InvCode
  2999. into #TempIcsinsp_7
  3000. from dbo.ICSInspection
  3001. where workpoint='" + WorkPoint + @"' and Enable='1'
  3002. select DISTINCT a.ID as GDID, a.SDNCode as DNCode, a.Sequence , c.InvCode , c.InvName , c.INVSTD , c.ClassName,
  3003. 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, sum(e.Quantity) as AllNumber,
  3004. CAST(ISNULL(sum(h.QualifiedQuantity),sum(e.Quantity))as NUMERIC(10,4))as YLOTQTY ,
  3005. CAST(ISNULL(sum(h.UnqualifiedQuantity), 0) as NUMERIC(10,4)) as NLOTQTY,
  3006. CAST(ISNULL(sum(h.WaiveQuantity), 0) as NUMERIC(10,4)) as SpecialQTY,
  3007. CAST(ISNULL(sum(h.SampleQuantity), 0) as NUMERIC(10,4)) as SampleQuantity,
  3008. c.InvUnit ,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  3009. a.EATTRIBUTE9,a.EATTRIBUTE10,c.InvIQC
  3010. into #TempMOData_7
  3011. from ICSSDN a
  3012. inner JOIN dbo.ICSInventory c ON a.InvCode = c.InvCode AND a.WorkPoint=c.WorkPoint --and c.InvIQC='1'
  3013. left join ICSInventoryLotDetail b on a.SDNCode=b.TransCode and a.Sequence=b.TransSequence and a.WorkPoint=b.WorkPoint
  3014. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  3015. LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo=b.LotNo AND e.WorkPoint=b.WorkPoint
  3016. LEFT JOIN #TempIcsinsp_7 h ON h.LotNO=e.LotNO and h.InvCode=e.InvCode and h.WorkPoint=e.WorkPoint -- and Enable='1'
  3017. where e.LotNO is not null AND a.Type='2' {0} and a.workpoint='{1}'
  3018. ";
  3019. string wheresql = "";
  3020. if (!string.IsNullOrWhiteSpace(queryJson))
  3021. {
  3022. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  3023. {
  3024. wheresql += " and a.SDNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  3025. }
  3026. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  3027. {
  3028. wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  3029. }
  3030. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  3031. {
  3032. wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  3033. }
  3034. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  3035. {
  3036. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  3037. }
  3038. if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
  3039. {
  3040. wheresql += " and e.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
  3041. }
  3042. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  3043. {
  3044. string ReleaseState = queryParam["ReleaseState"].ToString();
  3045. if (ReleaseState == "1")
  3046. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
  3047. else if (ReleaseState == "0")
  3048. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
  3049. else
  3050. wheresql += " ";
  3051. }
  3052. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  3053. {
  3054. string selEnableShow = queryParam["selEnableShow"].ToString();
  3055. if (selEnableShow == "1")
  3056. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
  3057. else if (selEnableShow == "0")
  3058. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
  3059. }
  3060. }
  3061. sql += @" GROUP BY a.ID , a.SDNCode , a.Sequence , c.InvCode , c.InvName , c.INVSTD , c.ClassName, 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,c.InvUnit ,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,a.EATTRIBUTE9,a.EATTRIBUTE10,c.InvIQC ;select * into #TempMOData_7_1 from #TempMOData_7 where InvIQC='1'";
  3062. sql = string.Format(sql, wheresql, WorkPoint);
  3063. // return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  3064. return Repository().FindTablePageBySql_OtherTemp(sql, "#TempMOData_7_1",
  3065. @" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_7'))
  3066. drop table #TempMOData_7
  3067. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData7_1'))
  3068. drop table #TempMOData_7_1
  3069. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_7'))
  3070. drop table #TempIcsinsp_7 ",
  3071. "connstr", parameter.ToArray(), ref jqgridparam);
  3072. }
  3073. /// <summary>
  3074. /// 销售退货(单据行维度)
  3075. /// </summary>
  3076. /// <param name="jqgridparam"></param>
  3077. /// <param name="queryJson"></param>
  3078. /// <returns></returns>
  3079. public DataTable GetICSInspection7DocSequence(ref Pagination jqgridparam, string queryJson)
  3080. {
  3081. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  3082. DataTable dt = new DataTable();
  3083. var queryParam = queryJson.ToJObject();
  3084. List<DbParameter> parameter = new List<DbParameter>();
  3085. string sql = @"
  3086. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_7'))
  3087. drop table #TempMOData_7
  3088. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData7_1'))
  3089. drop table #TempMOData_7_1
  3090. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_7'))
  3091. drop table #TempIcsinsp_7
  3092. select ID,QualifiedQuantity,UnqualifiedQuantity,WaiveQuantity,
  3093. SampleQuantity,MUSERName,MTIME,Result,LotNo,BCCode,workpoint,BRCode,InvCode
  3094. into #TempIcsinsp_7
  3095. from dbo.ICSInspection
  3096. where workpoint='" + WorkPoint + @"' and Enable='1'
  3097. select DISTINCT a.ID as GDID, a.SDNCode as DNCode, a.Sequence , c.InvCode , c.InvName , c.INVSTD , c.ClassName,
  3098. sum(e.Quantity) as AllNumber,
  3099. CAST(ISNULL(sum(h.QualifiedQuantity),sum(e.Quantity))as NUMERIC(10,4))as YLOTQTY ,
  3100. CAST(ISNULL(sum(h.UnqualifiedQuantity), 0) as NUMERIC(10,4)) as NLOTQTY,
  3101. CAST(ISNULL(sum(h.WaiveQuantity), 0) as NUMERIC(10,4)) as SpecialQTY,
  3102. CAST(ISNULL(sum(h.SampleQuantity), 0) as NUMERIC(10,4)) as SampleQuantity,
  3103. c.InvUnit ,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  3104. a.EATTRIBUTE9,a.EATTRIBUTE10,c.InvIQC
  3105. into #TempMOData_7
  3106. from ICSSDN a
  3107. inner JOIN dbo.ICSInventory c ON a.InvCode = c.InvCode AND a.WorkPoint=c.WorkPoint --and c.InvIQC='1'
  3108. left join ICSInventoryLotDetail b on a.SDNCode=b.TransCode and a.Sequence=b.TransSequence and a.WorkPoint=b.WorkPoint
  3109. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  3110. LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo=b.LotNo AND e.WorkPoint=b.WorkPoint
  3111. LEFT JOIN #TempIcsinsp_7 h ON h.LotNO=e.LotNO and h.InvCode=e.InvCode and h.WorkPoint=e.WorkPoint -- and Enable='1'
  3112. where e.LotNO is not null AND a.Type='2' {0} and a.workpoint='{1}'
  3113. ";
  3114. string wheresql = "";
  3115. if (!string.IsNullOrWhiteSpace(queryJson))
  3116. {
  3117. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  3118. {
  3119. wheresql += " and a.SDNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  3120. }
  3121. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  3122. {
  3123. wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  3124. }
  3125. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  3126. {
  3127. wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  3128. }
  3129. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  3130. {
  3131. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  3132. }
  3133. if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
  3134. {
  3135. wheresql += " and e.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
  3136. }
  3137. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  3138. {
  3139. string ReleaseState = queryParam["ReleaseState"].ToString();
  3140. if (ReleaseState == "1")
  3141. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
  3142. else if (ReleaseState == "0")
  3143. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
  3144. else
  3145. wheresql += " ";
  3146. }
  3147. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  3148. {
  3149. string selEnableShow = queryParam["selEnableShow"].ToString();
  3150. if (selEnableShow == "1")
  3151. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
  3152. else if (selEnableShow == "0")
  3153. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
  3154. }
  3155. }
  3156. sql += @" GROUP BY a.ID , a.SDNCode , a.Sequence , c.InvCode , c.InvName , c.INVSTD , c.ClassName,c.InvUnit ,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,a.EATTRIBUTE9,a.EATTRIBUTE10,c.InvIQC ;select * into #TempMOData_7_1 from #TempMOData_7 where InvIQC='1'";
  3157. sql = string.Format(sql, wheresql, WorkPoint);
  3158. // return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  3159. return Repository().FindTablePageBySql_OtherTemp(sql, "#TempMOData_7_1",
  3160. @" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_7'))
  3161. drop table #TempMOData_7
  3162. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData7_1'))
  3163. drop table #TempMOData_7_1
  3164. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_7'))
  3165. drop table #TempIcsinsp_7 ",
  3166. "connstr", parameter.ToArray(), ref jqgridparam);
  3167. }
  3168. /// <summary>
  3169. /// 销售退货(单据维度)
  3170. /// </summary>
  3171. /// <param name="jqgridparam"></param>
  3172. /// <param name="queryJson"></param>
  3173. /// <returns></returns>
  3174. public DataTable GetICSInspection7Doc(ref Pagination jqgridparam, string queryJson)
  3175. {
  3176. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  3177. DataTable dt = new DataTable();
  3178. var queryParam = queryJson.ToJObject();
  3179. List<DbParameter> parameter = new List<DbParameter>();
  3180. string sql = @"
  3181. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_7'))
  3182. drop table #TempMOData_7
  3183. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData7_1'))
  3184. drop table #TempMOData_7_1
  3185. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_7'))
  3186. drop table #TempIcsinsp_7
  3187. select ID,QualifiedQuantity,UnqualifiedQuantity,WaiveQuantity,
  3188. SampleQuantity,MUSERName,MTIME,Result,LotNo,BCCode,workpoint,BRCode,InvCode
  3189. into #TempIcsinsp_7
  3190. from dbo.ICSInspection
  3191. where workpoint='" + WorkPoint + @"' and Enable='1'
  3192. select DISTINCT a.SDNCode as DNCode,
  3193. sum(e.Quantity) as AllNumber,
  3194. CAST(ISNULL(sum(h.QualifiedQuantity),sum(e.Quantity))as NUMERIC(10,4))as YLOTQTY ,
  3195. CAST(ISNULL(sum(h.UnqualifiedQuantity), 0) as NUMERIC(10,4)) as NLOTQTY,
  3196. CAST(ISNULL(sum(h.WaiveQuantity), 0) as NUMERIC(10,4)) as SpecialQTY,
  3197. CAST(ISNULL(sum(h.SampleQuantity), 0) as NUMERIC(10,4)) as SampleQuantity
  3198. into #TempMOData_7
  3199. from ICSSDN a
  3200. inner JOIN dbo.ICSInventory c ON a.InvCode = c.InvCode AND a.WorkPoint=c.WorkPoint and c.InvIQC='1'
  3201. left join ICSInventoryLotDetail b on a.SDNCode=b.TransCode and a.Sequence=b.TransSequence and a.WorkPoint=b.WorkPoint
  3202. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  3203. LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo=b.LotNo AND e.WorkPoint=b.WorkPoint
  3204. LEFT JOIN #TempIcsinsp_7 h ON h.LotNO=e.LotNO and h.InvCode=e.InvCode and h.WorkPoint=e.WorkPoint
  3205. where e.LotNO is not null AND a.Type='2' {0} and a.workpoint='{1}'
  3206. ";
  3207. string wheresql = "";
  3208. if (!string.IsNullOrWhiteSpace(queryJson))
  3209. {
  3210. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  3211. {
  3212. wheresql += " and a.SDNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  3213. }
  3214. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  3215. {
  3216. wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  3217. }
  3218. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  3219. {
  3220. wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  3221. }
  3222. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  3223. {
  3224. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  3225. }
  3226. if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
  3227. {
  3228. wheresql += " and e.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
  3229. }
  3230. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  3231. {
  3232. string ReleaseState = queryParam["ReleaseState"].ToString();
  3233. if (ReleaseState == "1")
  3234. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
  3235. else if (ReleaseState == "0")
  3236. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
  3237. else
  3238. wheresql += " ";
  3239. }
  3240. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  3241. {
  3242. string selEnableShow = queryParam["selEnableShow"].ToString();
  3243. if (selEnableShow == "1")
  3244. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
  3245. else if (selEnableShow == "0")
  3246. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
  3247. }
  3248. }
  3249. sql += @" GROUP BY a.SDNCode ;select * into #TempMOData_7_1 from #TempMOData_7 ";
  3250. sql = string.Format(sql, wheresql, WorkPoint);
  3251. // return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  3252. return Repository().FindTablePageBySql_OtherTemp(sql, "#TempMOData_7_1",
  3253. @" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_7'))
  3254. drop table #TempMOData_7
  3255. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData7_1'))
  3256. drop table #TempMOData_7_1
  3257. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_7'))
  3258. drop table #TempIcsinsp_7 ",
  3259. "connstr", parameter.ToArray(), ref jqgridparam);
  3260. }
  3261. //获取不良原因
  3262. public DataTable Select_ICSBadReason(string InvCode)
  3263. {
  3264. string sql = string.Empty;
  3265. DataTable dt = null;
  3266. sql = @"select '' as BadReasonCode,'' as BadReasonDesc from ICSBadReason a left join
  3267. ICSInventoryBadGroup b on a.BRGroupID=b.BRGroupID
  3268. union
  3269. select a.BadReasonCode,a.BadReasonDesc from ICSBadReason a left join
  3270. ICSInventoryBadGroup b on a.BRGroupID=b.BRGroupID
  3271. where b.InvCode='{0}'";
  3272. sql = string.Format(sql, InvCode);
  3273. dt = SqlHelper.GetDataTableBySql(sql);
  3274. return dt;
  3275. }
  3276. //获取不良代码
  3277. public DataTable GetSelectICSBadCode(string InvCode)
  3278. {
  3279. string sql = string.Empty;
  3280. DataTable dt = null;
  3281. sql = @"
  3282. select '' as BadCode ,'' as BadDesc
  3283. from dbo.ICSBadCode a left join
  3284. ICSInventoryBadGroup b on a.BCGroupID=b.BCGroupID
  3285. union
  3286. select BadCode,BadDesc from dbo.ICSBadCode a left join
  3287. ICSInventoryBadGroup b on a.BCGroupID=b.BCGroupID where b.InvCode='{0}'";
  3288. // sql = @"select BadCode,BadDesc from dbo.ICSBadCode a left join
  3289. //ICSInventoryBadGroup b on a.BCGroupID=b.BCGroupID
  3290. //where b.InvCode='{0}'";
  3291. sql = string.Format(sql, InvCode);
  3292. dt = SqlHelper.GetDataTableBySql(sql);
  3293. return dt;
  3294. }
  3295. /// <summary>
  3296. /// 新增检验
  3297. /// </summary>
  3298. /// <param name="queryJson"></param>
  3299. /// <returns></returns>
  3300. public string CreateICSInspection(string keyValue, string ICSInspections)
  3301. {
  3302. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  3303. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  3304. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  3305. string msg = "";
  3306. string sql = string.Empty;
  3307. JArray res = (JArray)JsonConvert.DeserializeObject(ICSInspections);
  3308. try
  3309. {
  3310. foreach (var item in res)
  3311. {
  3312. object CARID = Guid.NewGuid();
  3313. JObject jo = (JObject)item;
  3314. string sqls = string.Empty;
  3315. string type = jo["Type"].ToString();
  3316. if (jo["FlagVersion"].ToString() == "1")
  3317. {
  3318. #region 2024-08-09 检验添加是否入库验证
  3319. var checksql = $@"SELECT ID FROM ICSWareHouseLotInfo WHERE LotNo='{jo["LotNo"]}' AND WorkPoint='{WorkPoint}'";
  3320. var checkdt = SqlHelper.CmdExecuteDataTable(checksql);
  3321. if (checkdt.Rows.Count > 0)
  3322. {
  3323. msg = $"条码:{jo["LotNo"]}已经入库,不能再次检验";
  3324. return msg;
  3325. }
  3326. #endregion
  3327. if (!string.IsNullOrWhiteSpace(jo["JYID"].ToString()))
  3328. {
  3329. sqls += "update ICSInspectionDetailGroup set InspectionID='{2}' WHERE InspectionID='{3}' and WorkPoint='{1}' ";
  3330. }
  3331. sqls += @"update ICSInspection set Enable='0' WHERE LotNO='{0}' and Enable='1' and WorkPoint='{1}'";
  3332. sqls = string.Format(sqls, jo["LotNo"].ToString(), WorkPoint, CARID, jo["JYID"].ToString());
  3333. SqlHelper.CmdExecuteNonQueryLi(sqls);
  3334. sql += @"INSERT INTO dbo.ICSInspection
  3335. ( ID ,LotNo,InvCode ,Quantity,QualifiedQuantity ,UnqualifiedQuantity,WaiveQuantity,BCCode,BRCode,Type,MTIME,MUSER ,MUSERName ,WorkPoint ,Enable,SampleQuantity,Result,EATTRIBUTE1)
  3336. Values('{13}','{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}',getdate(),'{9}','{10}','{11}','1','{12}','{14}','{15}')
  3337. ";
  3338. 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(), CARID, jo["Result"].ToString(), jo["FlagVersion"].ToString());
  3339. }
  3340. else
  3341. {
  3342. var lotNosql = string.Empty;
  3343. var dt = new DataTable();
  3344. if (jo["FlagVersion"].ToString() == "2")
  3345. {
  3346. //获取各种单据类型的条码数量信息
  3347. if (type == "1")
  3348. {
  3349. lotNosql = $@"SELECT b.LotNo,b.Quantity,b.InvCode FROM ICSDeliveryNotice a
  3350. INNER JOIN ICSInventoryLot b ON a.ExtensionID=b.ExtensionID AND a.WorkPoint=b.WorkPoint
  3351. INNER JOIN ICSASNDetail c ON c.LotNo=b.LotNo AND c.WorkPoint=b.WorkPoint AND a.ASNCode=c.ASNCode
  3352. INNER JOIN ICSExtension d ON d.ID=b.ExtensionID AND b.WorkPoint=d.WorkPoint
  3353. LEFT JOIN ICSInventoryLotDetail m ON m.LotNo= c.LotNo AND m.WorkPoint= c.WorkPoint
  3354. INNER JOIN ICSPurchaseOrder l ON m.TransID = l.ID AND m.WorkPoint= l.WorkPoint AND l.POID=a.POID
  3355. AND l.PODetailID=a.PODetailID
  3356. WHERE d.BatchCode='{jo["BatchCode"]}' AND a.WorkPoint='{WorkPoint}' AND a.DNCode='{jo["DNCode"]}' AND a.Sequence='{jo["Sequence"]}' AND a.DNType='1'";
  3357. }
  3358. else if (type == "2")
  3359. {
  3360. lotNosql = $@"SELECT d.LotNo,d.Quantity,d.InvCode FROM ICSODeliveryNotice a
  3361. LEFT JOIN ICSOASNDetail b ON a.OASNCode = b.OASNCode AND a.WorkPoint = b.WorkPoint
  3362. inner JOIN ICSInventoryLot d ON b.LotNo = d.LotNo AND a.InvCode = d.InvCode AND b.WorkPoint = d.WorkPoint
  3363. left join ICSInventoryLotDetail e on d.LotNo = e.LotNo and d.WorkPoint = e.WorkPoint
  3364. left join ICSExtension f on a.ExtensionID = f.ID and a.WorkPoint = f.WorkPoint
  3365. inner JOIN ICSOutsourcingOrder l ON e.TransID = l.ID AND d.WorkPoint = l.WorkPoint
  3366. WHERE a.WorkPoint = '{WorkPoint}' AND a.ODNCode = '{jo["DNCode"]}' AND a.Sequence = '{jo["Sequence"]}' AND f.BatchCode = '{jo["BatchCode"]}' AND a.ODNType = '1'";
  3367. }
  3368. else if (type == "3")
  3369. {
  3370. lotNosql = $@"SELECT e.LotNo,e.Quantity,e.Invcode from ICSMO a
  3371. inner JOIN dbo.ICSInventory c ON a.InvCode = c.InvCode AND a.WorkPoint = c.WorkPoint--and c.InvIQC = '1'
  3372. left join ICSInventoryLotDetail b on a.MOCode = b.TransCode and a.Sequence = b.TransSequence and a.WorkPoint = b.WorkPoint
  3373. left join ICSExtension f on a.ExtensionID = f.ID and a.WorkPoint = f.WorkPoint
  3374. LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo = b.LotNo AND e.WorkPoint = b.WorkPoint AND e.ExtensionID = f.ID
  3375. WHERE a.WorkPoint = '{WorkPoint}' AND a.MOCode = '{jo["DNCode"]}' AND a.Sequence = '{jo["Sequence"]}' AND f.BatchCode = '{jo["BatchCode"]}' ";
  3376. }
  3377. else if (type == "4")
  3378. {
  3379. lotNosql = $@"SELECT e.LotNo,e.Quantity,e.Invcode from ICSOtherIn a
  3380. inner JOIN dbo.ICSInventory c ON a.InvCode = c.InvCode AND a.WorkPoint = c.WorkPoint and c.InvIQC = '1'
  3381. left join ICSInventoryLotDetail b on a.InCode = b.TransCode and a.Sequence = b.TransSequence and a.WorkPoint = b.WorkPoint
  3382. LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo = b.LotNo AND e.WorkPoint = b.WorkPoint AND ISNULL(e.EATTRIBUTE1,'')= ''
  3383. left join ICSExtension f on e.ExtensionID = f.ID and e.WorkPoint = f.WorkPoint
  3384. WHERE a.WorkPoint = '{WorkPoint}' AND a.InCode = '{jo["DNCode"]}' AND a.Sequence = '{jo["Sequence"]}' AND f.BatchCode = '{jo["BatchCode"]}' ";
  3385. }
  3386. else if (type == "5")
  3387. {
  3388. lotNosql = $@"SELECT e.LotNo,e.Quantity,e.Invcode from ICSMOApplyNeg a
  3389. LEFT JOIN ICSMOApplyNegDetail ad ON a.ApplyNegCode = ad.ApplyNegCode AND a.WorkPoint = ad.WorkPoint
  3390. inner JOIN dbo.ICSInventory c ON ad.InvCode = c.InvCode AND ad.WorkPoint = c.WorkPoint--and c.InvIQC = '1'
  3391. left join ICSInventoryLotDetail b on a.ApplyNegCode = b.TransCode and ad.Sequence = b.TransSequence and ad.WorkPoint = b.WorkPoint
  3392. left join ICSExtension f on ad.ExtensionID = f.ID and ad.WorkPoint = f.WorkPoint
  3393. LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo = b.LotNo AND e.WorkPoint = b.WorkPoint
  3394. WHERE a.WorkPoint = '{WorkPoint}' AND a.ApplyNegCode = '{jo["DNCode"]}' AND a.Sequence = '{jo["Sequence"]}' AND f.BatchCode = '{jo["BatchCode"]}' ";
  3395. }
  3396. else if (type == "6")
  3397. {
  3398. lotNosql = $@" SELECT e.LotNo,e.Quantity,e.Invcode from ICSOApplyNeg a
  3399. LEFT JOIN ICSOApplyNegDetail ad ON a.OApplyNegCode = ad.OApplyNegCode AND a.WorkPoint = ad.WorkPoint
  3400. inner JOIN dbo.ICSInventory c ON ad.InvCode = c.InvCode AND ad.WorkPoint = c.WorkPoint--and c.InvIQC = '1'
  3401. left join ICSInventoryLotDetail b on a.OApplyNegCode = b.TransCode and ad.Sequence = b.TransSequence and ad.WorkPoint = b.WorkPoint
  3402. left join ICSExtension f on ad.ExtensionID = f.ID and ad.WorkPoint = f.WorkPoint
  3403. LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo = b.LotNo AND e.WorkPoint = b.WorkPoint
  3404. WHERE a.WorkPoint = '{WorkPoint}' AND a.OApplyNegCode = '{jo["DNCode"]}' AND a.Sequence = '{jo["Sequence"]}' AND f.BatchCode = '{jo["BatchCode"]}' ";
  3405. }
  3406. else if (type == "7")
  3407. {
  3408. lotNosql = $@" SELECT e.LotNo,e.Quantity,e.Invcode from ICSOApplyNeg a
  3409. from ICSSDN a
  3410. inner JOIN dbo.ICSInventory c ON a.InvCode = c.InvCode AND a.WorkPoint = c.WorkPoint--and c.InvIQC = '1'
  3411. left join ICSInventoryLotDetail b on a.SDNCode = b.TransCode and a.Sequence = b.TransSequence and a.WorkPoint = b.WorkPoint
  3412. left join ICSExtension f on a.ExtensionID = f.ID and a.WorkPoint = f.WorkPoint
  3413. LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo = b.LotNo AND e.WorkPoint = b.WorkPoint
  3414. WHERE a.WorkPoint = '{WorkPoint}' AND a.SDNCode = '{jo["DNCode"]}' AND a.Sequence = '{jo["Sequence"]}' AND f.BatchCode = '{jo["BatchCode"]}' ";
  3415. }
  3416. else if (type == "8")
  3417. {
  3418. lotNosql = $@" SELECT d.LotNo,d.Quantity,d.Invcode FROM ICSDeliveryNotice a
  3419. left join ICSInventoryLotDetail e on a.DNCode = e.TransCode and a.Sequence = e.TransSequence and a.WorkPoint = e.WorkPoint
  3420. inner JOIN ICSInventory c ON a.InvCode = c.InvCode and a.WorkPoint = c.WorkPoint-- and c.InvIQC = '1'
  3421. inner JOIN ICSInventoryLot d ON e.LotNo = d.LotNo AND a.InvCode = d.InvCode AND a.WorkPoint = d.WorkPoint and d.type = '7'
  3422. left join ICSExtension f on a.ExtensionID = f.ID and a.WorkPoint = f.WorkPoint
  3423. WHERE a.WorkPoint = '{WorkPoint}' AND a.DNCode = '{jo["DNCode"]}' AND a.Sequence = '{jo["Sequence"]}' AND f.BatchCode = '{jo["BatchCode"]}' and a.DNType = '1' ";
  3424. }
  3425. else if (type == "9")
  3426. {
  3427. lotNosql = $@" SELECT d.LotNo,d.Quantity,d.Invcode
  3428. FROM ICSODeliveryNotice a
  3429. inner join ICSInventoryLotDetail e on e.TransCode = a.ODNCode AND e.TransSequence = a.Sequence AND e.WorkPoint = a.WorkPoint
  3430. inner JOIN ICSInventoryLot d ON d.LotNo = e.LotNo and d.WorkPoint = e.WorkPoint and d.type = '8'
  3431. inner JOIN ICSInventory c ON a.InvCode = c.InvCode and a.WorkPoint = c.WorkPoint--and c.InvIQC = '1'
  3432. LEFT JOIN dbo.ICSInspection h ON h.LotNo = d.LotNo AND h.WorkPoint = d.WorkPoint
  3433. left join ICSExtension f on a.ExtensionID = f.ID and a.WorkPoint = f.WorkPoint
  3434. WHERE a.WorkPoint = '{WorkPoint}' AND a.ODNCode = '{jo["DNCode"]}' AND a.Sequence = '{jo["Sequence"]}' AND f.BatchCode = '{jo["BatchCode"]}' ";
  3435. }
  3436. else if (type == "10")
  3437. {
  3438. lotNosql = $@" SELECT e.LotNo,e.Quantity,e.Invcode
  3439. from ICSMO a
  3440. inner JOIN dbo.ICSInventory c ON a.InvCode = c.InvCode AND a.WorkPoint = c.WorkPoint--and c.InvIQC = '1'
  3441. LEFT JOIN ICSMOPick pick ON a.MODetailID = pick.MODetailID AND a.WorkPoint = pick.WorkPoint AND pick.EATTRIBUTE1 = '1'
  3442. left join ICSInventoryLotDetail b on a.MOCode = b.TransCode and a.Sequence + '~' + pick.Sequence = b.TransSequence and a.WorkPoint = b.WorkPoint
  3443. left join ICSExtension f on a.ExtensionID = f.ID and a.WorkPoint = f.WorkPoint
  3444. LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo = b.LotNo AND e.WorkPoint = b.WorkPoint
  3445. WHERE a.WorkPoint = '{WorkPoint}' AND a.MOCode = '{jo["DNCode"]}' AND a.Sequence = '{jo["Sequence"]}' AND f.BatchCode = '{jo["BatchCode"]}' AND a.MOStatus <> '3' ";
  3446. }
  3447. }
  3448. else if (jo["FlagVersion"].ToString() == "3")
  3449. {
  3450. if (type == "1")
  3451. {
  3452. lotNosql = $@"SELECT b.LotNo,b.Quantity,b.InvCode FROM ICSDeliveryNotice a
  3453. INNER JOIN ICSInventoryLot b ON a.ExtensionID=b.ExtensionID AND a.WorkPoint=b.WorkPoint
  3454. INNER JOIN ICSASNDetail c ON c.LotNo=b.LotNo AND c.WorkPoint=b.WorkPoint AND a.ASNCode=c.ASNCode
  3455. INNER JOIN ICSExtension d ON d.ID=b.ExtensionID AND b.WorkPoint=d.WorkPoint
  3456. LEFT JOIN ICSInventoryLotDetail m ON m.LotNo= c.LotNo AND m.WorkPoint= c.WorkPoint
  3457. INNER JOIN ICSPurchaseOrder l ON m.TransID = l.ID AND m.WorkPoint= l.WorkPoint AND l.POID=a.POID
  3458. AND l.PODetailID=a.PODetailID
  3459. WHERE a.WorkPoint='{WorkPoint}' AND a.DNCode='{jo["DNCode"]}' AND a.Sequence='{jo["Sequence"]}' AND a.DNType='1'";
  3460. }
  3461. else if (type == "2")
  3462. {
  3463. lotNosql = $@"SELECT d.LotNo,d.Quantity,d.InvCode FROM ICSODeliveryNotice a
  3464. LEFT JOIN ICSOASNDetail b ON a.OASNCode = b.OASNCode AND a.WorkPoint = b.WorkPoint
  3465. inner JOIN ICSInventoryLot d ON b.LotNo = d.LotNo AND a.InvCode = d.InvCode AND b.WorkPoint = d.WorkPoint
  3466. left join ICSInventoryLotDetail e on d.LotNo = e.LotNo and d.WorkPoint = e.WorkPoint
  3467. inner JOIN ICSOutsourcingOrder l ON e.TransID = l.ID AND d.WorkPoint = l.WorkPoint
  3468. WHERE a.WorkPoint = '{WorkPoint}' AND a.ODNCode = '{jo["DNCode"]}' AND a.Sequence = '{jo["Sequence"]}' AND a.ODNType = '1'";
  3469. }
  3470. else if (type == "3")
  3471. {
  3472. lotNosql = $@"SELECT e.LotNo,e.Quantity,e.Invcode from ICSMO a
  3473. inner JOIN dbo.ICSInventory c ON a.InvCode = c.InvCode AND a.WorkPoint=c.WorkPoint --and c.InvIQC='1'
  3474. left join ICSInventoryLotDetail b on a.MOCode=b.TransCode and a.Sequence=b.TransSequence and a.WorkPoint=b.WorkPoint
  3475. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  3476. LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo=b.LotNo AND e.WorkPoint=b.WorkPoint AND e.ExtensionID=f.ID
  3477. WHERE a.WorkPoint='{WorkPoint}' AND a.MOCode='{jo["DNCode"]}' AND a.Sequence='{jo["Sequence"]}' ";
  3478. }
  3479. else if (type == "4")
  3480. {
  3481. lotNosql = $@"SELECT e.LotNo,e.Quantity,e.Invcode from ICSOtherIn a
  3482. inner JOIN dbo.ICSInventory c ON a.InvCode = c.InvCode AND a.WorkPoint = c.WorkPoint and c.InvIQC = '1'
  3483. left join ICSInventoryLotDetail b on a.InCode = b.TransCode and a.Sequence = b.TransSequence and a.WorkPoint = b.WorkPoint
  3484. LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo = b.LotNo AND e.WorkPoint = b.WorkPoint AND ISNULL(e.EATTRIBUTE1,'')= ''
  3485. left join ICSExtension f on e.ExtensionID = f.ID and e.WorkPoint = f.WorkPoint
  3486. WHERE a.WorkPoint = '{WorkPoint}' AND a.InCode = '{jo["DNCode"]}' AND a.Sequence = '{jo["Sequence"]}' ";
  3487. }
  3488. else if (type == "5")
  3489. {
  3490. lotNosql = $@"SELECT e.LotNo,e.Quantity,e.Invcode from ICSMOApplyNeg a
  3491. LEFT JOIN ICSMOApplyNegDetail ad ON a.ApplyNegCode = ad.ApplyNegCode AND a.WorkPoint = ad.WorkPoint
  3492. inner JOIN dbo.ICSInventory c ON ad.InvCode = c.InvCode AND ad.WorkPoint = c.WorkPoint--and c.InvIQC = '1'
  3493. left join ICSInventoryLotDetail b on a.ApplyNegCode = b.TransCode and ad.Sequence = b.TransSequence and ad.WorkPoint = b.WorkPoint
  3494. left join ICSExtension f on ad.ExtensionID = f.ID and ad.WorkPoint = f.WorkPoint
  3495. LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo = b.LotNo AND e.WorkPoint = b.WorkPoint
  3496. WHERE a.WorkPoint = '{WorkPoint}' AND a.ApplyNegCode = '{jo["DNCode"]}' AND a.Sequence = '{jo["Sequence"]}' ";
  3497. }
  3498. else if (type == "6")
  3499. {
  3500. lotNosql = $@" SELECT e.LotNo,e.Quantity,e.Invcode from ICSOApplyNeg a
  3501. LEFT JOIN ICSOApplyNegDetail ad ON a.OApplyNegCode = ad.OApplyNegCode AND a.WorkPoint = ad.WorkPoint
  3502. inner JOIN dbo.ICSInventory c ON ad.InvCode = c.InvCode AND ad.WorkPoint = c.WorkPoint--and c.InvIQC = '1'
  3503. left join ICSInventoryLotDetail b on a.OApplyNegCode = b.TransCode and ad.Sequence = b.TransSequence and ad.WorkPoint = b.WorkPoint
  3504. left join ICSExtension f on ad.ExtensionID = f.ID and ad.WorkPoint = f.WorkPoint
  3505. LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo = b.LotNo AND e.WorkPoint = b.WorkPoint
  3506. WHERE a.WorkPoint = '{WorkPoint}' AND a.OApplyNegCode = '{jo["DNCode"]}' AND a.Sequence = '{jo["Sequence"]}' ";
  3507. }
  3508. else if (type == "7")
  3509. {
  3510. lotNosql = $@" SELECT e.LotNo,e.Quantity,e.Invcode from ICSOApplyNeg a
  3511. from ICSSDN a
  3512. inner JOIN dbo.ICSInventory c ON a.InvCode = c.InvCode AND a.WorkPoint = c.WorkPoint--and c.InvIQC = '1'
  3513. left join ICSInventoryLotDetail b on a.SDNCode = b.TransCode and a.Sequence = b.TransSequence and a.WorkPoint = b.WorkPoint
  3514. left join ICSExtension f on a.ExtensionID = f.ID and a.WorkPoint = f.WorkPoint
  3515. LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo = b.LotNo AND e.WorkPoint = b.WorkPoint
  3516. WHERE a.WorkPoint = '{WorkPoint}' AND a.SDNCode = '{jo["DNCode"]}' AND a.Sequence = '{jo["Sequence"]}' ";
  3517. }
  3518. else if (type == "8")
  3519. {
  3520. lotNosql = $@" SELECT d.LotNo,d.Quantity,d.Invcode FROM ICSDeliveryNotice a
  3521. left join ICSInventoryLotDetail e on a.DNCode = e.TransCode and a.Sequence = e.TransSequence and a.WorkPoint = e.WorkPoint
  3522. inner JOIN ICSInventory c ON a.InvCode = c.InvCode and a.WorkPoint = c.WorkPoint-- and c.InvIQC = '1'
  3523. inner JOIN ICSInventoryLot d ON e.LotNo = d.LotNo AND a.InvCode = d.InvCode AND a.WorkPoint = d.WorkPoint and d.type = '7'
  3524. left join ICSExtension f on a.ExtensionID = f.ID and a.WorkPoint = f.WorkPoint
  3525. WHERE a.WorkPoint = '{WorkPoint}' AND a.DNCode = '{jo["DNCode"]}' AND a.Sequence = '{jo["Sequence"]}' and a.DNType = '1' ";
  3526. }
  3527. else if (type == "9")
  3528. {
  3529. lotNosql = $@" SELECT d.LotNo,d.Quantity,d.Invcode
  3530. FROM ICSODeliveryNotice a
  3531. inner join ICSInventoryLotDetail e on e.TransCode = a.ODNCode AND e.TransSequence = a.Sequence AND e.WorkPoint = a.WorkPoint
  3532. inner JOIN ICSInventoryLot d ON d.LotNo = e.LotNo and d.WorkPoint = e.WorkPoint and d.type = '8'
  3533. inner JOIN ICSInventory c ON a.InvCode = c.InvCode and a.WorkPoint = c.WorkPoint--and c.InvIQC = '1'
  3534. LEFT JOIN dbo.ICSInspection h ON h.LotNo = d.LotNo AND h.WorkPoint = d.WorkPoint
  3535. left join ICSExtension f on a.ExtensionID = f.ID and a.WorkPoint = f.WorkPoint
  3536. WHERE a.WorkPoint = '{WorkPoint}' AND a.ODNCode = '{jo["DNCode"]}' AND a.Sequence = '{jo["Sequence"]}' ";
  3537. }
  3538. else if (type == "10")
  3539. {
  3540. lotNosql = $@" SELECT e.LotNo,e.Quantity,e.Invcode
  3541. from ICSMO a
  3542. inner JOIN dbo.ICSInventory c ON a.InvCode = c.InvCode AND a.WorkPoint = c.WorkPoint--and c.InvIQC = '1'
  3543. LEFT JOIN ICSMOPick pick ON a.MODetailID = pick.MODetailID AND a.WorkPoint = pick.WorkPoint AND pick.EATTRIBUTE1 = '1'
  3544. left join ICSInventoryLotDetail b on a.MOCode = b.TransCode and a.Sequence + '~' + pick.Sequence = b.TransSequence and a.WorkPoint = b.WorkPoint
  3545. left join ICSExtension f on a.ExtensionID = f.ID and a.WorkPoint = f.WorkPoint
  3546. LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo = b.LotNo AND e.WorkPoint = b.WorkPoint
  3547. WHERE a.WorkPoint = '{WorkPoint}' AND a.MOCode = '{jo["DNCode"]}' AND a.Sequence = '{jo["Sequence"]}' AND a.MOStatus <> '3' ";
  3548. }
  3549. }
  3550. else
  3551. {
  3552. if (type == "1")
  3553. {
  3554. lotNosql = $@"SELECT b.LotNo,b.Quantity,b.InvCode FROM ICSDeliveryNotice a
  3555. INNER JOIN ICSInventoryLot b ON a.ExtensionID=b.ExtensionID AND a.WorkPoint=b.WorkPoint
  3556. INNER JOIN ICSASNDetail c ON c.LotNo=b.LotNo AND c.WorkPoint=b.WorkPoint AND a.ASNCode=c.ASNCode
  3557. INNER JOIN ICSExtension d ON d.ID=b.ExtensionID AND b.WorkPoint=d.WorkPoint
  3558. LEFT JOIN ICSInventoryLotDetail m ON m.LotNo= c.LotNo AND m.WorkPoint= c.WorkPoint
  3559. INNER JOIN ICSPurchaseOrder l ON m.TransID = l.ID AND m.WorkPoint= l.WorkPoint AND l.POID=a.POID
  3560. AND l.PODetailID=a.PODetailID
  3561. WHERE a.WorkPoint='{WorkPoint}' AND a.DNCode='{jo["DNCode"]}' AND a.DNType='1'";
  3562. }
  3563. else if (type == "2")
  3564. {
  3565. lotNosql = $@"SELECT d.LotNo,d.Quantity,d.InvCode FROM ICSODeliveryNotice a
  3566. LEFT JOIN ICSOASNDetail b ON a.OASNCode = b.OASNCode AND a.WorkPoint = b.WorkPoint
  3567. inner JOIN ICSInventoryLot d ON b.LotNo = d.LotNo AND a.InvCode = d.InvCode AND b.WorkPoint = d.WorkPoint
  3568. left join ICSInventoryLotDetail e on d.LotNo = e.LotNo and d.WorkPoint = e.WorkPoint
  3569. inner JOIN ICSOutsourcingOrder l ON e.TransID = l.ID AND d.WorkPoint = l.WorkPoint
  3570. WHERE a.WorkPoint = '{WorkPoint}' AND a.ODNCode = '{jo["DNCode"]}' AND a.ODNType = '1'";
  3571. }
  3572. else if (type == "3")
  3573. {
  3574. lotNosql = $@"SELECT e.LotNo,e.Quantity,e.Invcode from ICSMO a
  3575. inner JOIN dbo.ICSInventory c ON a.InvCode = c.InvCode AND a.WorkPoint=c.WorkPoint --and c.InvIQC='1'
  3576. left join ICSInventoryLotDetail b on a.MOCode=b.TransCode and a.Sequence=b.TransSequence and a.WorkPoint=b.WorkPoint
  3577. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  3578. LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo=b.LotNo AND e.WorkPoint=b.WorkPoint AND e.ExtensionID=f.ID
  3579. WHERE a.WorkPoint='{WorkPoint}' AND a.MOCode='{jo["DNCode"]}' ";
  3580. }
  3581. else if (type == "4")
  3582. {
  3583. lotNosql = $@"SELECT e.LotNo,e.Quantity,e.Invcode from ICSOtherIn a
  3584. inner JOIN dbo.ICSInventory c ON a.InvCode = c.InvCode AND a.WorkPoint = c.WorkPoint and c.InvIQC = '1'
  3585. left join ICSInventoryLotDetail b on a.InCode = b.TransCode and a.Sequence = b.TransSequence and a.WorkPoint = b.WorkPoint
  3586. LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo = b.LotNo AND e.WorkPoint = b.WorkPoint AND ISNULL(e.EATTRIBUTE1,'')= ''
  3587. left join ICSExtension f on e.ExtensionID = f.ID and e.WorkPoint = f.WorkPoint
  3588. WHERE a.WorkPoint = '{WorkPoint}' AND a.InCode = '{jo["DNCode"]}' AND a.Sequence = '{jo["Sequence"]}' AND f.BatchCode = '{jo["BatchCode"]}' ";
  3589. }
  3590. else if (type == "5")
  3591. {
  3592. lotNosql = $@"SELECT e.LotNo,e.Quantity,e.Invcode from ICSMOApplyNeg a
  3593. LEFT JOIN ICSMOApplyNegDetail ad ON a.ApplyNegCode = ad.ApplyNegCode AND a.WorkPoint = ad.WorkPoint
  3594. inner JOIN dbo.ICSInventory c ON ad.InvCode = c.InvCode AND ad.WorkPoint = c.WorkPoint--and c.InvIQC = '1'
  3595. left join ICSInventoryLotDetail b on a.ApplyNegCode = b.TransCode and ad.Sequence = b.TransSequence and ad.WorkPoint = b.WorkPoint
  3596. left join ICSExtension f on ad.ExtensionID = f.ID and ad.WorkPoint = f.WorkPoint
  3597. LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo = b.LotNo AND e.WorkPoint = b.WorkPoint
  3598. WHERE a.WorkPoint = '{WorkPoint}' AND a.ApplyNegCode = '{jo["DNCode"]}' ";
  3599. }
  3600. else if (type == "6")
  3601. {
  3602. lotNosql = $@" SELECT e.LotNo,e.Quantity,e.Invcode from ICSOApplyNeg a
  3603. LEFT JOIN ICSOApplyNegDetail ad ON a.OApplyNegCode = ad.OApplyNegCode AND a.WorkPoint = ad.WorkPoint
  3604. inner JOIN dbo.ICSInventory c ON ad.InvCode = c.InvCode AND ad.WorkPoint = c.WorkPoint--and c.InvIQC = '1'
  3605. left join ICSInventoryLotDetail b on a.OApplyNegCode = b.TransCode and ad.Sequence = b.TransSequence and ad.WorkPoint = b.WorkPoint
  3606. left join ICSExtension f on ad.ExtensionID = f.ID and ad.WorkPoint = f.WorkPoint
  3607. LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo = b.LotNo AND e.WorkPoint = b.WorkPoint
  3608. WHERE a.WorkPoint = '{WorkPoint}' AND a.OApplyNegCode = '{jo["DNCode"]}' ";
  3609. }
  3610. else if (type == "7")
  3611. {
  3612. lotNosql = $@" SELECT e.LotNo,e.Quantity,e.Invcode from ICSOApplyNeg a
  3613. from ICSSDN a
  3614. inner JOIN dbo.ICSInventory c ON a.InvCode = c.InvCode AND a.WorkPoint = c.WorkPoint--and c.InvIQC = '1'
  3615. left join ICSInventoryLotDetail b on a.SDNCode = b.TransCode and a.Sequence = b.TransSequence and a.WorkPoint = b.WorkPoint
  3616. left join ICSExtension f on a.ExtensionID = f.ID and a.WorkPoint = f.WorkPoint
  3617. LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo = b.LotNo AND e.WorkPoint = b.WorkPoint
  3618. WHERE a.WorkPoint = '{WorkPoint}' AND a.SDNCode = '{jo["DNCode"]}' ";
  3619. }
  3620. else if (type == "8")
  3621. {
  3622. lotNosql = $@" SELECT d.LotNo,d.Quantity,d.Invcode FROM ICSDeliveryNotice a
  3623. left join ICSInventoryLotDetail e on a.DNCode = e.TransCode and a.Sequence = e.TransSequence and a.WorkPoint = e.WorkPoint
  3624. inner JOIN ICSInventory c ON a.InvCode = c.InvCode and a.WorkPoint = c.WorkPoint-- and c.InvIQC = '1'
  3625. inner JOIN ICSInventoryLot d ON e.LotNo = d.LotNo AND a.InvCode = d.InvCode AND a.WorkPoint = d.WorkPoint and d.type = '7'
  3626. left join ICSExtension f on a.ExtensionID = f.ID and a.WorkPoint = f.WorkPoint
  3627. WHERE a.WorkPoint = '{WorkPoint}' AND a.DNCode = '{jo["DNCode"]}' and a.DNType = '1' ";
  3628. }
  3629. else if (type == "9")
  3630. {
  3631. lotNosql = $@" SELECT d.LotNo,d.Quantity,d.Invcode
  3632. FROM ICSODeliveryNotice a
  3633. inner join ICSInventoryLotDetail e on e.TransCode = a.ODNCode AND e.TransSequence = a.Sequence AND e.WorkPoint = a.WorkPoint
  3634. inner JOIN ICSInventoryLot d ON d.LotNo = e.LotNo and d.WorkPoint = e.WorkPoint and d.type = '8'
  3635. inner JOIN ICSInventory c ON a.InvCode = c.InvCode and a.WorkPoint = c.WorkPoint--and c.InvIQC = '1'
  3636. LEFT JOIN dbo.ICSInspection h ON h.LotNo = d.LotNo AND h.WorkPoint = d.WorkPoint
  3637. left join ICSExtension f on a.ExtensionID = f.ID and a.WorkPoint = f.WorkPoint
  3638. WHERE a.WorkPoint = '{WorkPoint}' AND a.ODNCode = '{jo["DNCode"]}' ";
  3639. }
  3640. else if (type == "10")
  3641. {
  3642. lotNosql = $@" SELECT e.LotNo,e.Quantity,e.Invcode
  3643. from ICSMO a
  3644. inner JOIN dbo.ICSInventory c ON a.InvCode = c.InvCode AND a.WorkPoint = c.WorkPoint--and c.InvIQC = '1'
  3645. LEFT JOIN ICSMOPick pick ON a.MODetailID = pick.MODetailID AND a.WorkPoint = pick.WorkPoint AND pick.EATTRIBUTE1 = '1'
  3646. left join ICSInventoryLotDetail b on a.MOCode = b.TransCode and a.Sequence + '~' + pick.Sequence = b.TransSequence and a.WorkPoint = b.WorkPoint
  3647. left join ICSExtension f on a.ExtensionID = f.ID and a.WorkPoint = f.WorkPoint
  3648. LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo = b.LotNo AND e.WorkPoint = b.WorkPoint
  3649. WHERE a.WorkPoint = '{WorkPoint}' AND a.MOCode = '{jo["DNCode"]}' AND a.MOStatus <> '3' ";
  3650. }
  3651. }
  3652. dt = SqlHelper.CmdExecuteDataTable(lotNosql);
  3653. if (dt.Rows.Count > 0)
  3654. {
  3655. for (int i = 0; i < dt.Rows.Count; i++)
  3656. {
  3657. #region 2024-08-09 检验添加是否入库验证
  3658. var checksql = $@"SELECT ID FROM ICSWareHouseLotInfo WHERE LotNo='{dt.Rows[i]["LotNo"]}' AND WorkPoint='{WorkPoint}'";
  3659. var checkdt = SqlHelper.CmdExecuteDataTable(checksql);
  3660. if (checkdt.Rows.Count > 0)
  3661. {
  3662. msg = $"条码:{jo["LotNo"]}已经入库,不能再次检验";
  3663. return msg;
  3664. }
  3665. #endregion
  3666. object id = Guid.NewGuid();
  3667. sql += $@" update ICSInspectionDetailGroup set InspectionID='{id}' WHERE InspectionID=(Select ID from ICSInspection WHERE LotNO='{dt.Rows[i]["LotNo"]}' and Enable='1' and WorkPoint='{WorkPoint}') and WorkPoint='{WorkPoint}' ;
  3668. update ICSInspection set Enable='0' WHERE LotNO='{dt.Rows[i]["LotNo"]}' and Enable='1' and WorkPoint='{WorkPoint}' ;
  3669. INSERT INTO dbo.ICSInspection ( ID ,LotNo,InvCode ,Quantity,QualifiedQuantity ,UnqualifiedQuantity,WaiveQuantity,BCCode,BRCode,Type,MTIME,MUSER ,MUSERName ,WorkPoint ,Enable,SampleQuantity,Result,EATTRIBUTE1)
  3670. Values('{id}','{dt.Rows[i]["LotNo"]}','{dt.Rows[i]["InvCode"]}','{dt.Rows[i]["Quantity"]}','{dt.Rows[i]["Quantity"]}','0','0','','','{type}',getdate(),'{MUSER}','{MUSERNAME}','{WorkPoint}','1','0','1','{jo["FlagVersion"]}') ; ";
  3671. }
  3672. }
  3673. }
  3674. }
  3675. //}
  3676. if (SqlHelper.ExecuteNonQuery(sql) > 0)
  3677. {
  3678. }
  3679. else
  3680. {
  3681. msg = "新增失败";
  3682. }
  3683. }
  3684. catch (Exception ex)
  3685. {
  3686. throw new Exception(ex.Message);
  3687. }
  3688. return msg;
  3689. }
  3690. /// <summary>
  3691. /// 在库检验保存检验结果
  3692. /// </summary>
  3693. /// <param name="queryJson"></param>
  3694. /// <returns></returns>
  3695. public string ICSWHLotInspection(string keyValue, string ICSInspections)
  3696. {
  3697. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  3698. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  3699. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  3700. string msg = "";
  3701. string sql = string.Empty;
  3702. JArray res = (JArray)JsonConvert.DeserializeObject(ICSInspections);
  3703. string sqls = string.Empty;
  3704. foreach (var item in res)
  3705. {
  3706. JObject jo = (JObject)item;
  3707. object CARID = Guid.NewGuid();
  3708. decimal YLotQty = Convert.ToDecimal(jo["YLOTQTY"].ToString());
  3709. sqls += @"update ICSInspection set Enable='0' WHERE LotNO='{0}' and Enable='1' and WorkPoint='{1}'";
  3710. sqls = string.Format(sqls, jo["LotNo"].ToString(), WorkPoint);
  3711. sqls += @"INSERT INTO dbo.ICSInspection
  3712. ( ID ,LotNo,InvCode ,Quantity,QualifiedQuantity ,UnqualifiedQuantity,WaiveQuantity,BCCode,BRCode,Type,MTIME,MUSER ,MUSERName ,WorkPoint ,Enable,SampleQuantity,Result,EATTRIBUTE1)
  3713. Values('{13}','{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}',getdate(),'{9}','{10}','{11}','1','{12}','{14}','{15}')
  3714. ";
  3715. sqls = string.Format(sqls, jo["LotNo"].ToString(), jo["InvCode"].ToString(), jo["AllNumber"].ToString(), jo["YLOTQTY"].ToString()
  3716. , jo["NLOTQTY"].ToString(), "0", jo["BCCode"].ToString(), jo["BRCode"].ToString()
  3717. , jo["Type"].ToString(), MUSER, MUSERNAME, WorkPoint, "0", CARID, jo["Result"].ToString(), jo["DNCode"].ToString());
  3718. sqls += @"update ICSInspectDetail set InspectQuantity={2},MTIME=GETDATE(),MUSER='{5}',MUSERName='{6}',EATTRIBUTE1='已检验'
  3719. where InspectCode='{0}' and LotNo='{3}' and WorkPoint='{1}' ";
  3720. //if (YLotQty == 0)
  3721. //{
  3722. // sqls += @"update ICSWareHouseLotInfo set Quantity=ISNULL(LockQuantity,0)
  3723. // where LotNo='{3}' and WorkPoint='{1}' ";
  3724. //}
  3725. //else
  3726. //{
  3727. // sqls += @"update ICSWareHouseLotInfo set Quantity={4}+ISNULL(LockQuantity,0)
  3728. // where LotNo='{3}' and WorkPoint='{1}'
  3729. // UPDATE ICSInventoryLot SET ExpirationDate='{7}'
  3730. // WHERE LotNo='{3}' AND WorkPoint='{1}' ";
  3731. //}
  3732. sqls = string.Format(sqls, jo["DNCode"].ToString(), WorkPoint, jo["YLOTQTY"].ToString(), jo["LotNo"].ToString(), YLotQty, MUSER, MUSERNAME, Convert.ToDateTime(jo["ExpirationDate"]));
  3733. }
  3734. try
  3735. {
  3736. if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  3737. {
  3738. }
  3739. else
  3740. {
  3741. msg = "保存失败";
  3742. }
  3743. }
  3744. catch (Exception ex)
  3745. {
  3746. throw new Exception(ex.Message);
  3747. }
  3748. return msg;
  3749. }
  3750. /// <summary>
  3751. /// 在库检验审核
  3752. /// </summary>
  3753. /// <param name="queryJson"></param>
  3754. /// <returns></returns>
  3755. public string ApproveWHLotInspection(string keyValue, string ICSInspections)
  3756. {
  3757. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  3758. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  3759. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  3760. string msg = "";
  3761. string sql = string.Empty;
  3762. JArray res = (JArray)JsonConvert.DeserializeObject(ICSInspections);
  3763. string sqls = string.Empty;
  3764. foreach (var item in res)
  3765. {
  3766. JObject jo = (JObject)item;
  3767. sqls += @"update ICSInspectDetail set EATTRIBUTE1='已审核',EATTRIBUTE2='{3}',EATTRIBUTE3='{4}'
  3768. where InspectCode='{0}' and LotNo='{1}' and WorkPoint='{2}' ";
  3769. sqls = string.Format(sqls, jo["DNCode"].ToString(), jo["LotNo"].ToString(), WorkPoint, MUSER, MUSERNAME);
  3770. }
  3771. try
  3772. {
  3773. if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  3774. {
  3775. }
  3776. else
  3777. {
  3778. msg = "审核失败";
  3779. }
  3780. }
  3781. catch (Exception ex)
  3782. {
  3783. throw new Exception(ex.Message);
  3784. }
  3785. return msg;
  3786. }
  3787. /// <summary>
  3788. /// 在库检验复审
  3789. /// </summary>
  3790. /// <param name="queryJson"></param>
  3791. /// <returns></returns>
  3792. public string SecApproveWHLotInspection(string keyValue, string ICSInspections)
  3793. {
  3794. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  3795. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  3796. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  3797. string msg = "";
  3798. bool IsCQ = false;
  3799. string sql = string.Empty;
  3800. JArray res = (JArray)JsonConvert.DeserializeObject(ICSInspections);
  3801. string chksql = @"select Type from ICSInspect
  3802. where InspectCode='{0}' and WorkPoint='{1}'";
  3803. chksql = string.Format(chksql, res[0]["DNCode"].ToString(), WorkPoint);
  3804. DataTable chkdt = SqlHelper.GetDataTableBySql(chksql);
  3805. if (chkdt.Rows[0]["Type"].ToString() == "0")
  3806. {
  3807. IsCQ = false;
  3808. }
  3809. else
  3810. {
  3811. IsCQ = true;
  3812. }
  3813. string sqls = string.Empty;
  3814. foreach (var item in res)
  3815. {
  3816. JObject jo = (JObject)item;
  3817. object CARID = Guid.NewGuid();
  3818. decimal YLotQty = Convert.ToDecimal(jo["YLOTQTY"].ToString());
  3819. sqls += @"update ICSInspectDetail set EATTRIBUTE1='已复审',EATTRIBUTE4='{3}',EATTRIBUTE5='{4}'
  3820. where InspectCode='{0}' and LotNo='{1}' and WorkPoint='{2}' ";
  3821. if (YLotQty == 0)
  3822. {
  3823. sqls += @"update ICSWareHouseLotInfo set Quantity=ISNULL(LockQuantity,0)
  3824. where LotNo='{1}' and WorkPoint='{2}' ";
  3825. }
  3826. else
  3827. {
  3828. if (IsCQ == false)
  3829. {
  3830. sqls += @"update ICSWareHouseLotInfo set Quantity={5}+ISNULL(LockQuantity,0)
  3831. where LotNo='{1}' and WorkPoint='{2}' ";
  3832. }
  3833. else
  3834. {
  3835. sqls += @"update ICSWareHouseLotInfo set Quantity={5}+ISNULL(LockQuantity,0)
  3836. where LotNo='{1}' and WorkPoint='{2}'
  3837. UPDATE ICSInventoryLot SET ExpirationDate=DateAdd(DAY,Convert(Int,(select F_Define1 from Sys_SRM_ItemsDetail
  3838. where F_ItemCode='Delay_day')),Convert(DateTime,ExpirationDate))
  3839. WHERE LotNo='{1}' AND WorkPoint='{2}' ";
  3840. }
  3841. }
  3842. sqls = string.Format(sqls, jo["DNCode"].ToString(), jo["LotNo"].ToString(), WorkPoint, MUSER, MUSERNAME, YLotQty);
  3843. }
  3844. try
  3845. {
  3846. if (SqlHelper.ExecuteNonQuery(sqls) > 0)
  3847. {
  3848. }
  3849. else
  3850. {
  3851. msg = "保存失败";
  3852. }
  3853. }
  3854. catch (Exception ex)
  3855. {
  3856. throw new Exception(ex.Message);
  3857. }
  3858. return msg;
  3859. }
  3860. //生成采购拒收单
  3861. public string CreateRejection(string keyValue)
  3862. {
  3863. string msg = "";
  3864. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  3865. string sqlAsn = @"select distinct a.VenCode,a.DNID,a.DepCode,a.DNCode,a.Sequence from ICSDeliveryNotice a
  3866. inner join ICSASNDetail b on a.ASNCode=b.ASNCode
  3867. left join dbo.ICSInventoryLot c on b.LotNo=c.LotNo and a.InvCode=c.InvCode and b.WorkPoint=c.WorkPoint AND c.ExtensionID=a.ExtensionID
  3868. left join ICSInventoryLotDetail e on c.LotNo=e.LotNo and c.WorkPoint=e.WorkPoint
  3869. inner JOIN ICSPurchaseOrder l ON e.TransCode =l.POCode AND e.TransSequence=l.Sequence AND a.PODetailID=l.PODetailID AND c.WorkPoint=l.WorkPoint
  3870. WHERE b.LotNo IN (" + keyValue.TrimEnd(',') + ")";
  3871. // string sqlAsn = @"select distinct a.VenCode,a.DNID,a.DepCode,a.DNCode from ICSDeliveryNotice a
  3872. //left join ICSInventoryLotDetail e on a.DNCode=e.TransCode and a.Sequence=e.TransSequence and a.WorkPoint=e.WorkPoint
  3873. //left join dbo.ICSInventoryLot c on e.LotNo=c.LotNo and a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint
  3874. //inner JOIN ICSPurchaseOrder l ON a.PODetailID=l.PODetailID AND c.WorkPoint=l.WorkPoint
  3875. //WHERE c.LotNo IN (" + keyValue.TrimEnd(',') + ")";
  3876. DataTable dt = Repository().FindTableBySql(sqlAsn.ToString());
  3877. 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
  3878. from ICSDeliveryNotice a
  3879. left join ICSASNDetail b on a.ASNCode=b.ASNCode and a.WorkPoint=b.WorkPoint
  3880. left join ICSInventoryLot c on b.LotNo=c.LotNo and a.InvCode=c.InvCode and b.WorkPoint=c.WorkPoint
  3881. left join ICSInventoryLotDetail e on c.LotNo=e.LotNo and c.WorkPoint=e.WorkPoint
  3882. inner JOIN ICSPurchaseOrder l ON e.TransCode =l.POCode AND e.TransSequence=l.Sequence AND a.PODetailID=l.PODetailID AND c.WorkPoint=l.WorkPoint
  3883. left join ICSInspection d on b.LotNo=d.LotNo and b.WorkPoint=d.WorkPoint AND d.Enable='1'
  3884. WHERE b.LotNo in (" + keyValue.TrimEnd(',') + ") ";
  3885. // 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
  3886. //from ICSDeliveryNotice a
  3887. //left join ICSInventoryLotDetail e on a.DNCode=e.TransCode and a.Sequence=e.TransSequence and a.WorkPoint=e.WorkPoint
  3888. //left join ICSInventoryLot c on e.LotNo=c.LotNo and a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint
  3889. // inner JOIN ICSPurchaseOrder l ON a.PODetailID=l.PODetailID AND c.WorkPoint=l.WorkPoint
  3890. //left join ICSInspection d on c.LotNo=d.LotNo and a.WorkPoint=d.WorkPoint and d.Enable='1'
  3891. //WHERE d.LotNo in (" + keyValue.TrimEnd(',') + ") ";
  3892. DataTable dtD = Repository().FindTableBySql(sqlAsnD.ToString());
  3893. List<RejectionHead> asn = new List<RejectionHead>();
  3894. for (int i = 0; i < dt.Rows.Count; i++)
  3895. {
  3896. RejectionHead ass = new RejectionHead();
  3897. ass.VenCode = dt.Rows[i]["VenCode"].ToString();
  3898. ass.ID = dt.Rows[i]["DNID"].ToString();
  3899. ass.DepCode = dt.Rows[i]["DepCode"].ToString();
  3900. ass.DNCode = dt.Rows[i]["DNCode"].ToString();
  3901. ass.User = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  3902. ass.MTIME = System.DateTime.Now.ToString("s");
  3903. ass.WorkPoint = WorkPoint;
  3904. DataRow[] drs = dtD.Select("DNID='" + dt.Rows[i]["DNID"].ToString() + "'");
  3905. for (int j = 0; j < drs.Length; j++)
  3906. {
  3907. RejectionBody DetailList = new RejectionBody();
  3908. DetailList.Sequence = (j + 1).ToString();
  3909. DetailList.InvCode = drs[j]["InvCode"].ToString();
  3910. DetailList.Quantity = drs[j]["Quantity"].ToString();
  3911. DetailList.Amount = drs[j]["Amount"].ToString();
  3912. DetailList.Currency = drs[j]["Currency"].ToString();
  3913. DetailList.UnitPrice = drs[j]["UnitPrice"].ToString();
  3914. DetailList.DNDetailID = drs[j]["DNDetailID"].ToString();
  3915. DetailList.LotNo = drs[j]["LotNo"].ToString();
  3916. ass.detail.Add(DetailList);
  3917. }
  3918. asn.Add(ass);
  3919. }
  3920. string input = JsonConvert.SerializeObject(asn);
  3921. string APIURL = ConfigurationManager.ConnectionStrings["APIURL"].ConnectionString + "PurchaseRejectDoc/Create";
  3922. string result = HttpPost(APIURL, input);
  3923. JObject Obj = (JObject)JsonConvert.DeserializeObject(result);//或者JObject jo = JObject.Parse(jsonText);
  3924. string MessAge = Obj["Message"].ToString();
  3925. string Success = Obj["Success"].ToString();
  3926. if (Success.ToUpper() == "FALSE")
  3927. {
  3928. msg = MessAge;
  3929. }
  3930. return msg;
  3931. }
  3932. /// <summary>
  3933. /// 比博专用拒收单
  3934. /// </summary>
  3935. /// <param name="keyValue"></param>
  3936. /// <returns></returns>
  3937. public string CreateRejection4BB(string keyValue)
  3938. {
  3939. string msg = "";
  3940. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  3941. string sqlAsn = @"select distinct a.VenCode,a.DNID,a.DepCode,a.DNCode from ICSDeliveryNotice a
  3942. inner join ICSASNDetail b on a.ASNCode=b.ASNCode
  3943. left join dbo.ICSInventoryLot c on b.LotNo=c.LotNo and a.InvCode=c.InvCode and b.WorkPoint=c.WorkPoint
  3944. left join ICSInventoryLotDetail e on c.LotNo=e.LotNo and c.WorkPoint=e.WorkPoint
  3945. inner JOIN ICSPurchaseOrder l ON e.TransCode =l.POCode AND e.TransSequence=l.Sequence AND a.PODetailID=l.PODetailID AND c.WorkPoint=l.WorkPoint
  3946. WHERE b.LotNo IN (" + keyValue.TrimEnd(',') + ")";
  3947. // string sqlAsn = @"select distinct a.VenCode,a.DNID,a.DepCode,a.DNCode from ICSDeliveryNotice a
  3948. //left join ICSInventoryLotDetail e on a.DNCode=e.TransCode and a.Sequence=e.TransSequence and a.WorkPoint=e.WorkPoint
  3949. //left join dbo.ICSInventoryLot c on e.LotNo=c.LotNo and a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint
  3950. //inner JOIN ICSPurchaseOrder l ON a.PODetailID=l.PODetailID AND c.WorkPoint=l.WorkPoint
  3951. //WHERE c.LotNo IN (" + keyValue.TrimEnd(',') + ")";
  3952. DataTable dt = Repository().FindTableBySql(sqlAsn.ToString());
  3953. 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
  3954. from ICSASNDetail b
  3955. left join ICSInventoryLot c on b.LotNo=c.LotNo and b.WorkPoint=c.WorkPoint
  3956. left join ICSInventoryLotDetail e on c.LotNo=e.LotNo and c.WorkPoint=e.WorkPoint
  3957. inner JOIN ICSPurchaseOrder l ON e.TransCode =l.POCode AND e.TransSequence=l.Sequence AND c.WorkPoint=l.WorkPoint
  3958. left join ICSInspection d on b.LotNo=d.LotNo and b.WorkPoint=d.WorkPoint AND d.Enable='1'
  3959. LEFT JOIN ICSDeliveryNotice a ON a.ASNCode=b.ASNCode AND a.PODetailID=l.PODetailID AND a.ExtensionID=c.ExtensionID
  3960. WHERE b.LotNo in (" + keyValue.TrimEnd(',') + ") ";
  3961. // 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
  3962. //from ICSDeliveryNotice a
  3963. //left join ICSInventoryLotDetail e on a.DNCode=e.TransCode and a.Sequence=e.TransSequence and a.WorkPoint=e.WorkPoint
  3964. //left join ICSInventoryLot c on e.LotNo=c.LotNo and a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint
  3965. // inner JOIN ICSPurchaseOrder l ON a.PODetailID=l.PODetailID AND c.WorkPoint=l.WorkPoint
  3966. //left join ICSInspection d on c.LotNo=d.LotNo and a.WorkPoint=d.WorkPoint and d.Enable='1'
  3967. //WHERE d.LotNo in (" + keyValue.TrimEnd(',') + ") ";
  3968. DataTable dtD = Repository().FindTableBySql(sqlAsnD.ToString());
  3969. List<RejectionHead> asn = new List<RejectionHead>();
  3970. for (int i = 0; i < dt.Rows.Count; i++)
  3971. {
  3972. RejectionHead ass = new RejectionHead();
  3973. ass.VenCode = dt.Rows[i]["VenCode"].ToString();
  3974. ass.ID = dt.Rows[i]["DNID"].ToString();
  3975. ass.DepCode = dt.Rows[i]["DepCode"].ToString();
  3976. ass.DNCode = dt.Rows[i]["DNCode"].ToString();
  3977. ass.User = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  3978. ass.MTIME = System.DateTime.Now.ToString("s");
  3979. ass.WorkPoint = WorkPoint;
  3980. DataRow[] drs = dtD.Select("DNID='" + dt.Rows[i]["DNID"].ToString() + "'");
  3981. for (int j = 0; j < drs.Length; j++)
  3982. {
  3983. RejectionBody DetailList = new RejectionBody();
  3984. DetailList.Sequence = (j + 1).ToString();
  3985. DetailList.InvCode = drs[j]["InvCode"].ToString();
  3986. DetailList.Quantity = drs[j]["Quantity"].ToString();
  3987. DetailList.Amount = drs[j]["Amount"].ToString();
  3988. DetailList.Currency = drs[j]["Currency"].ToString();
  3989. DetailList.UnitPrice = drs[j]["UnitPrice"].ToString();
  3990. DetailList.DNDetailID = drs[j]["DNDetailID"].ToString();
  3991. DetailList.LotNo = drs[j]["LotNo"].ToString();
  3992. ass.detail.Add(DetailList);
  3993. }
  3994. asn.Add(ass);
  3995. }
  3996. string input = JsonConvert.SerializeObject(asn);
  3997. string APIURL = ConfigurationManager.ConnectionStrings["APIURL"].ConnectionString + "PurchaseRejectDoc/Create";
  3998. string result = HttpPost(APIURL, input);
  3999. JObject Obj = (JObject)JsonConvert.DeserializeObject(result);//或者JObject jo = JObject.Parse(jsonText);
  4000. string MessAge = Obj["Message"].ToString();
  4001. string Success = Obj["Success"].ToString();
  4002. if (Success.ToUpper() == "FALSE")
  4003. {
  4004. msg = MessAge;
  4005. }
  4006. return msg;
  4007. }
  4008. /// <summary>
  4009. /// 卡博士专用拒收单
  4010. /// </summary>
  4011. /// <param name="keyValue"></param>
  4012. /// <returns></returns>
  4013. public string CreateRejection4KBS(string keyValue)
  4014. {
  4015. string msg = "";
  4016. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  4017. string sqlAsn = @"select distinct a.VenCode,a.DNID,a.DepCode,a.DNCode from ICSDeliveryNotice a
  4018. inner join ICSASNDetail b on a.ASNCode=b.ASNCode
  4019. left join dbo.ICSInventoryLot c on b.LotNo=c.LotNo and a.InvCode=c.InvCode and b.WorkPoint=c.WorkPoint
  4020. left join ICSInventoryLotDetail e on c.LotNo=e.LotNo and c.WorkPoint=e.WorkPoint
  4021. inner JOIN ICSPurchaseOrder l ON e.TransCode =l.POCode AND e.TransSequence=l.Sequence AND a.PODetailID=l.PODetailID AND c.WorkPoint=l.WorkPoint
  4022. WHERE b.LotNo IN (" + keyValue.TrimEnd(',') + ")";
  4023. // string sqlAsn = @"select distinct a.VenCode,a.DNID,a.DepCode,a.DNCode from ICSDeliveryNotice a
  4024. //left join ICSInventoryLotDetail e on a.DNCode=e.TransCode and a.Sequence=e.TransSequence and a.WorkPoint=e.WorkPoint
  4025. //left join dbo.ICSInventoryLot c on e.LotNo=c.LotNo and a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint
  4026. //inner JOIN ICSPurchaseOrder l ON a.PODetailID=l.PODetailID AND c.WorkPoint=l.WorkPoint
  4027. //WHERE c.LotNo IN (" + keyValue.TrimEnd(',') + ")";
  4028. DataTable dt = Repository().FindTableBySql(sqlAsn.ToString());
  4029. 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,DNID,b.LotNo
  4030. from ICSDeliveryNotice a
  4031. left join ICSASNDetail b on a.ASNCode=b.ASNCode and a.WorkPoint=b.WorkPoint
  4032. left join ICSInventoryLot c on b.LotNo=c.LotNo and a.InvCode=c.InvCode and b.WorkPoint=c.WorkPoint
  4033. left join ICSInventoryLotDetail e on c.LotNo=e.LotNo and c.WorkPoint=e.WorkPoint
  4034. inner JOIN ICSPurchaseOrder l ON e.TransCode =l.POCode AND e.TransSequence=l.Sequence AND a.PODetailID=l.PODetailID AND c.WorkPoint=l.WorkPoint
  4035. left join ICSInspection d on b.LotNo=d.LotNo and b.WorkPoint=d.WorkPoint AND d.Enable='1'
  4036. WHERE b.LotNo in (" + keyValue.TrimEnd(',') + ") ";
  4037. // 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
  4038. //from ICSDeliveryNotice a
  4039. //left join ICSInventoryLotDetail e on a.DNCode=e.TransCode and a.Sequence=e.TransSequence and a.WorkPoint=e.WorkPoint
  4040. //left join ICSInventoryLot c on e.LotNo=c.LotNo and a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint
  4041. // inner JOIN ICSPurchaseOrder l ON a.PODetailID=l.PODetailID AND c.WorkPoint=l.WorkPoint
  4042. //left join ICSInspection d on c.LotNo=d.LotNo and a.WorkPoint=d.WorkPoint and d.Enable='1'
  4043. //WHERE d.LotNo in (" + keyValue.TrimEnd(',') + ") ";
  4044. DataTable dtD = Repository().FindTableBySql(sqlAsnD.ToString());
  4045. List<RejectionHead> asn = new List<RejectionHead>();
  4046. for (int i = 0; i < dt.Rows.Count; i++)
  4047. {
  4048. RejectionHead ass = new RejectionHead();
  4049. ass.VenCode = dt.Rows[i]["VenCode"].ToString();
  4050. ass.ID = dt.Rows[i]["DNID"].ToString();
  4051. ass.DepCode = dt.Rows[i]["DepCode"].ToString();
  4052. ass.DNCode = dt.Rows[i]["DNCode"].ToString();
  4053. ass.User = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  4054. ass.MTIME = System.DateTime.Now.ToString("s");
  4055. ass.WorkPoint = WorkPoint;
  4056. DataRow[] drs = dtD.Select("DNID='" + dt.Rows[i]["DNID"].ToString() + "'");
  4057. for (int j = 0; j < drs.Length; j++)
  4058. {
  4059. RejectionBody DetailList = new RejectionBody();
  4060. DetailList.Sequence = (j + 1).ToString();
  4061. DetailList.InvCode = drs[j]["InvCode"].ToString();
  4062. DetailList.Quantity = drs[j]["Quantity"].ToString();
  4063. DetailList.Amount = drs[j]["Amount"].ToString();
  4064. DetailList.Currency = drs[j]["Currency"].ToString();
  4065. DetailList.UnitPrice = drs[j]["UnitPrice"].ToString();
  4066. //DetailList.DNDetailID = drs[j]["DNDetailID"].ToString();//这个字段不能串,会导致表体重复,最后条码重复无法创建拒收单
  4067. DetailList.LotNo = drs[j]["LotNo"].ToString();
  4068. ass.detail.Add(DetailList);
  4069. }
  4070. asn.Add(ass);
  4071. }
  4072. string input = JsonConvert.SerializeObject(asn);
  4073. string APIURL = ConfigurationManager.ConnectionStrings["APIURL"].ConnectionString + "PurchaseRejectDoc/Create";
  4074. string result = HttpPost(APIURL, input);
  4075. JObject Obj = (JObject)JsonConvert.DeserializeObject(result);//或者JObject jo = JObject.Parse(jsonText);
  4076. string MessAge = Obj["Message"].ToString();
  4077. string Success = Obj["Success"].ToString();
  4078. if (Success.ToUpper() == "FALSE")
  4079. {
  4080. msg = MessAge;
  4081. }
  4082. return msg;
  4083. }
  4084. //生成采购拒收单(无来源)
  4085. public string CreateWLYRejection(string keyValue)
  4086. {
  4087. string msg = "";
  4088. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  4089. //string sqlAsn = @"select distinct a.VenCode,a.DNID,a.DepCode,a.DNCode from ICSDeliveryNotice a
  4090. // inner join ICSASNDetail b on a.ASNCode=b.ASNCode and a.WorkPoint=b.WorkPoint
  4091. // left join dbo.ICSInventoryLot c on b.LotNo=c.LotNo and a.InvCode=c.InvCode and b.WorkPoint=c.WorkPoint
  4092. // left join ICSInventoryLotDetail e on c.LotNo=e.LotNo and c.WorkPoint=e.WorkPoint
  4093. // inner JOIN ICSPurchaseOrder l ON e.TransCode =l.POCode AND e.TransSequence=l.Sequence AND a.PODetailID=l.PODetailID AND c.WorkPoint=l.WorkPoint
  4094. // WHERE b.LotNo IN (" + keyValue.TrimEnd(',') + ")";
  4095. string sqlAsn = @"select distinct a.VenCode,a.DNID,a.DepCode,a.DNCode from ICSDeliveryNotice a
  4096. left join ICSInventoryLotDetail e on a.DNCode=e.TransCode and a.Sequence=e.TransSequence and a.WorkPoint=e.WorkPoint
  4097. left join dbo.ICSInventoryLot c on e.LotNo=c.LotNo and a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint
  4098. -- left JOIN ICSPurchaseOrder l ON a.PODetailID=l.PODetailID AND c.WorkPoint=l.WorkPoint
  4099. WHERE c.LotNo IN (" + keyValue.TrimEnd(',') + ")";
  4100. DataTable dt = Repository().FindTableBySql(sqlAsn.ToString());
  4101. //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
  4102. // from ICSDeliveryNotice a
  4103. // left join ICSASNDetail b on a.ASNCode=b.ASNCode and a.WorkPoint=b.WorkPoint
  4104. // left join ICSInventoryLot c on b.LotNo=c.LotNo and a.InvCode=c.InvCode and b.WorkPoint=c.WorkPoint
  4105. // left join ICSInventoryLotDetail e on c.LotNo=e.LotNo and c.WorkPoint=e.WorkPoint
  4106. // inner JOIN ICSPurchaseOrder l ON e.TransCode =l.POCode AND e.TransSequence=l.Sequence AND a.PODetailID=l.PODetailID AND c.WorkPoint=l.WorkPoint
  4107. // left join ICSInspection d on b.LotNo=d.LotNo and b.WorkPoint=d.WorkPoint
  4108. // WHERE b.LotNo in (" + keyValue.TrimEnd(',') + ") ";
  4109. 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
  4110. from ICSDeliveryNotice a
  4111. left join ICSInventoryLotDetail e on a.DNCode=e.TransCode and a.Sequence=e.TransSequence and a.WorkPoint=e.WorkPoint
  4112. left join ICSInventoryLot c on e.LotNo=c.LotNo and a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint
  4113. inner JOIN ICSPurchaseOrder l ON a.PODetailID=l.PODetailID AND c.WorkPoint=l.WorkPoint
  4114. left join ICSInspection d on c.LotNo=d.LotNo and a.WorkPoint=d.WorkPoint and d.Enable='1'
  4115. WHERE d.LotNo in (" + keyValue.TrimEnd(',') + ") ";
  4116. DataTable dtD = Repository().FindTableBySql(sqlAsnD.ToString());
  4117. List<RejectionHead> asn = new List<RejectionHead>();
  4118. for (int i = 0; i < dt.Rows.Count; i++)
  4119. {
  4120. RejectionHead ass = new RejectionHead();
  4121. ass.VenCode = dt.Rows[i]["VenCode"].ToString();
  4122. ass.ID = dt.Rows[i]["DNID"].ToString();
  4123. ass.DepCode = dt.Rows[i]["DepCode"].ToString();
  4124. ass.DNCode = dt.Rows[i]["DNCode"].ToString();
  4125. ass.User = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  4126. ass.MTIME = System.DateTime.Now.ToString("s");
  4127. ass.WorkPoint = WorkPoint;
  4128. DataRow[] drs = dtD.Select("DNID='" + dt.Rows[i]["DNID"].ToString() + "'");
  4129. for (int j = 0; j < drs.Length; j++)
  4130. {
  4131. RejectionBody DetailList = new RejectionBody();
  4132. DetailList.Sequence = (j + 1).ToString();
  4133. DetailList.InvCode = drs[j]["InvCode"].ToString();
  4134. DetailList.Quantity = drs[j]["Quantity"].ToString();
  4135. DetailList.Amount = drs[j]["Amount"].ToString();
  4136. DetailList.Currency = drs[j]["Currency"].ToString();
  4137. DetailList.UnitPrice = drs[j]["UnitPrice"].ToString();
  4138. DetailList.DNDetailID = drs[j]["DNDetailID"].ToString();
  4139. DetailList.LotNo = drs[j]["LotNo"].ToString();
  4140. ass.detail.Add(DetailList);
  4141. }
  4142. asn.Add(ass);
  4143. }
  4144. string input = JsonConvert.SerializeObject(asn);
  4145. string APIURL = ConfigurationManager.ConnectionStrings["APIURL"].ConnectionString + "PurchaseRejectDocNoTrans/Create";
  4146. string result = HttpPost(APIURL, input);
  4147. JObject Obj = (JObject)JsonConvert.DeserializeObject(result);//或者JObject jo = JObject.Parse(jsonText);
  4148. string MessAge = Obj["Message"].ToString();
  4149. string Success = Obj["Success"].ToString();
  4150. if (Success.ToUpper() == "FALSE")
  4151. {
  4152. msg = MessAge;
  4153. }
  4154. return msg;
  4155. }
  4156. //生成委外拒收单
  4157. public string CreateWWRejection(string keyValue)
  4158. {
  4159. string msg = "";
  4160. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  4161. string sqlAsn = @"select distinct a.VenCode,a.ODNID,a.DepCode,a.ODNCode from ICSODeliveryNotice a
  4162. left join ICSOASNDetail b on a.OASNCode=b.OASNCode and a.WorkPoint=b.WorkPoint
  4163. LEFT JOIN ICSInventory c ON a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint
  4164. inner JOIN ICSInventoryLot d ON b.LotNo=d.LotNo AND a.InvCode=d.InvCode AND b.WorkPoint=d.WorkPoint
  4165. left join ICSInventoryLotDetail e on d.LotNo=e.LotNo and d.WorkPoint=e.WorkPoint
  4166. inner JOIN ICSOutsourcingOrder l ON e.TransCode =l.OOCode AND e.TransSequence=l.Sequence AND a.OODetailID=l.OODetailID AND d.WorkPoint=l.WorkPoint
  4167. WHERE b.LotNo in (" + keyValue.TrimEnd(',') + ")";
  4168. DataTable dt = Repository().FindTableBySql(sqlAsn.ToString());
  4169. 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
  4170. from ICSODeliveryNotice a
  4171. inner join ICSOASNDetail b on a.OASNCode=b.OASNCode and a.WorkPoint=b.WorkPoint
  4172. inner join ICSInventoryLot c on b.LotNo=c.LotNo and a.InvCode=c.InvCode and b.WorkPoint=c.WorkPoint
  4173. left join ICSInventoryLotDetail e on c.LotNo=e.LotNo and c.WorkPoint=e.WorkPoint
  4174. inner JOIN ICSOutsourcingOrder l ON e.TransCode =l.OOCode AND e.TransSequence=l.Sequence AND a.OODetailID=l.OODetailID AND c.WorkPoint=l.WorkPoint
  4175. inner join ICSInspection d on c.LotNo=d.LotNo and b.WorkPoint=d.WorkPoint and d.Enable='1'
  4176. WHERE b.LotNo IN (" + keyValue.TrimEnd(',') + ") ";
  4177. DataTable dtD = Repository().FindTableBySql(sqlAsnD.ToString());
  4178. List<WWRejectionHead> asn = new List<WWRejectionHead>();
  4179. for (int i = 0; i < dt.Rows.Count; i++)
  4180. {
  4181. WWRejectionHead ass = new WWRejectionHead();
  4182. ass.VenCode = dt.Rows[i]["VenCode"].ToString();
  4183. ass.ID = dt.Rows[i]["ODNID"].ToString();
  4184. ass.DepCode = dt.Rows[i]["DepCode"].ToString();
  4185. ass.ODNCode = dt.Rows[i]["ODNCode"].ToString();
  4186. ass.User = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  4187. ass.MTIME = System.DateTime.Now.ToString("s");
  4188. ass.WorkPoint = WorkPoint;
  4189. DataRow[] drs = dtD.Select("ODNID='" + dt.Rows[i]["ODNID"].ToString() + "'");
  4190. for (int j = 0; j < drs.Length; j++)
  4191. {
  4192. WWRejectionBody DetailList = new WWRejectionBody();
  4193. DetailList.Sequence = (j + 1).ToString();
  4194. DetailList.InvCode = drs[j]["InvCode"].ToString();
  4195. DetailList.Quantity = drs[j]["Quantity"].ToString();
  4196. DetailList.Amount = drs[j]["Amount"].ToString();
  4197. DetailList.Currency = drs[j]["Currency"].ToString();
  4198. DetailList.UnitPrice = drs[j]["UnitPrice"].ToString();
  4199. DetailList.ODNDetailID = drs[j]["ODNDetailID"].ToString();
  4200. DetailList.LotNo = drs[j]["LotNo"].ToString();
  4201. ass.detail.Add(DetailList);
  4202. }
  4203. asn.Add(ass);
  4204. }
  4205. string input = JsonConvert.SerializeObject(asn);
  4206. string APIURL = ConfigurationManager.ConnectionStrings["APIURL"].ConnectionString + "OutsourcingRejectDoc/Create";
  4207. string result = HttpPost(APIURL, input);
  4208. JObject Obj = (JObject)JsonConvert.DeserializeObject(result);//或者JObject jo = JObject.Parse(jsonText);
  4209. string MessAge = Obj["Message"].ToString();
  4210. string Success = Obj["Success"].ToString();
  4211. if (Success.ToUpper() == "FALSE")
  4212. {
  4213. msg = MessAge;
  4214. }
  4215. return msg;
  4216. }
  4217. //生成委外拒收单
  4218. public string CreateBBWWRejection(string keyValue)
  4219. {
  4220. string msg = "";
  4221. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  4222. string sqlAsn = @"select distinct a.VenCode,a.ODNID,a.DepCode,a.ODNCode from ICSODeliveryNotice a
  4223. left join ICSOASNDetail b on a.OASNCode=b.OASNCode and a.WorkPoint=b.WorkPoint
  4224. LEFT JOIN ICSInventory c ON a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint
  4225. inner JOIN ICSInventoryLot d ON b.LotNo=d.LotNo AND a.InvCode=d.InvCode AND b.WorkPoint=d.WorkPoint
  4226. left join ICSInventoryLotDetail e on d.LotNo=e.LotNo and d.WorkPoint=e.WorkPoint
  4227. inner JOIN ICSOutsourcingOrder l ON e.TransCode =l.OOCode AND e.TransSequence=l.Sequence AND a.OODetailID=l.OODetailID AND d.WorkPoint=l.WorkPoint
  4228. WHERE b.LotNo in (" + keyValue.TrimEnd(',') + ")";
  4229. DataTable dt = Repository().FindTableBySql(sqlAsn.ToString());
  4230. 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
  4231. from ICSODeliveryNotice a
  4232. inner join ICSOASNDetail b on a.OASNCode=b.OASNCode and a.WorkPoint=b.WorkPoint
  4233. inner join ICSInventoryLot c on b.LotNo=c.LotNo and a.InvCode=c.InvCode and b.WorkPoint=c.WorkPoint AND a.ExtensionID=c.ExtensionID
  4234. left join ICSInventoryLotDetail e on c.LotNo=e.LotNo and c.WorkPoint=e.WorkPoint
  4235. inner JOIN ICSOutsourcingOrder l ON e.TransCode =l.OOCode AND e.TransSequence=l.Sequence AND a.OODetailID=l.OODetailID AND c.WorkPoint=l.WorkPoint
  4236. inner join ICSInspection d on c.LotNo=d.LotNo and b.WorkPoint=d.WorkPoint and d.Enable='1'
  4237. WHERE b.LotNo IN (" + keyValue.TrimEnd(',') + ") ";
  4238. DataTable dtD = Repository().FindTableBySql(sqlAsnD.ToString());
  4239. List<WWRejectionHead> asn = new List<WWRejectionHead>();
  4240. for (int i = 0; i < dt.Rows.Count; i++)
  4241. {
  4242. WWRejectionHead ass = new WWRejectionHead();
  4243. ass.VenCode = dt.Rows[i]["VenCode"].ToString();
  4244. ass.ID = dt.Rows[i]["ODNID"].ToString();
  4245. ass.DepCode = dt.Rows[i]["DepCode"].ToString();
  4246. ass.ODNCode = dt.Rows[i]["ODNCode"].ToString();
  4247. ass.User = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  4248. ass.MTIME = System.DateTime.Now.ToString("s");
  4249. ass.WorkPoint = WorkPoint;
  4250. DataRow[] drs = dtD.Select("ODNID='" + dt.Rows[i]["ODNID"].ToString() + "'");
  4251. for (int j = 0; j < drs.Length; j++)
  4252. {
  4253. WWRejectionBody DetailList = new WWRejectionBody();
  4254. DetailList.Sequence = (j + 1).ToString();
  4255. DetailList.InvCode = drs[j]["InvCode"].ToString();
  4256. DetailList.Quantity = drs[j]["Quantity"].ToString();
  4257. DetailList.Amount = drs[j]["Amount"].ToString();
  4258. DetailList.Currency = drs[j]["Currency"].ToString();
  4259. DetailList.UnitPrice = drs[j]["UnitPrice"].ToString();
  4260. DetailList.ODNDetailID = drs[j]["ODNDetailID"].ToString();
  4261. DetailList.LotNo = drs[j]["LotNo"].ToString();
  4262. ass.detail.Add(DetailList);
  4263. }
  4264. asn.Add(ass);
  4265. }
  4266. string input = JsonConvert.SerializeObject(asn);
  4267. string APIURL = ConfigurationManager.ConnectionStrings["APIURL"].ConnectionString + "OutsourcingRejectDoc/Create";
  4268. string result = HttpPost(APIURL, input);
  4269. JObject Obj = (JObject)JsonConvert.DeserializeObject(result);//或者JObject jo = JObject.Parse(jsonText);
  4270. string MessAge = Obj["Message"].ToString();
  4271. string Success = Obj["Success"].ToString();
  4272. if (Success.ToUpper() == "FALSE")
  4273. {
  4274. msg = MessAge;
  4275. }
  4276. return msg;
  4277. }
  4278. public string CreateWWRejection4KBS(string keyValue)
  4279. {
  4280. string msg = "";
  4281. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  4282. string sqlAsn = @"select distinct a.VenCode,a.ODNID,a.DepCode,a.ODNCode from ICSODeliveryNotice a
  4283. left join ICSOASNDetail b on a.OASNCode=b.OASNCode and a.WorkPoint=b.WorkPoint
  4284. LEFT JOIN ICSInventory c ON a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint
  4285. inner JOIN ICSInventoryLot d ON b.LotNo=d.LotNo AND a.InvCode=d.InvCode AND b.WorkPoint=d.WorkPoint
  4286. left join ICSInventoryLotDetail e on d.LotNo=e.LotNo and d.WorkPoint=e.WorkPoint
  4287. inner JOIN ICSOutsourcingOrder l ON e.TransCode =l.OOCode AND e.TransSequence=l.Sequence AND a.OODetailID=l.OODetailID AND d.WorkPoint=l.WorkPoint
  4288. WHERE b.LotNo in (" + keyValue.TrimEnd(',') + ")";
  4289. DataTable dt = Repository().FindTableBySql(sqlAsn.ToString());
  4290. 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
  4291. from ICSODeliveryNotice a
  4292. inner join ICSOASNDetail b on a.OASNCode=b.OASNCode and a.WorkPoint=b.WorkPoint
  4293. inner join ICSInventoryLot c on b.LotNo=c.LotNo and a.InvCode=c.InvCode and b.WorkPoint=c.WorkPoint and a.ExtensionID=c.ExtensionID
  4294. left join ICSInventoryLotDetail e on c.LotNo=e.LotNo and c.WorkPoint=e.WorkPoint
  4295. inner JOIN ICSOutsourcingOrder l ON e.TransCode =l.OOCode AND e.TransSequence=l.Sequence AND a.OODetailID=l.OODetailID AND c.WorkPoint=l.WorkPoint
  4296. inner join ICSInspection d on c.LotNo=d.LotNo and b.WorkPoint=d.WorkPoint and d.Enable='1'
  4297. WHERE b.LotNo IN (" + keyValue.TrimEnd(',') + ") ";
  4298. DataTable dtD = Repository().FindTableBySql(sqlAsnD.ToString());
  4299. List<WWRejectionHead> asn = new List<WWRejectionHead>();
  4300. for (int i = 0; i < dt.Rows.Count; i++)
  4301. {
  4302. WWRejectionHead ass = new WWRejectionHead();
  4303. ass.VenCode = dt.Rows[i]["VenCode"].ToString();
  4304. ass.ID = dt.Rows[i]["ODNID"].ToString();
  4305. ass.DepCode = dt.Rows[i]["DepCode"].ToString();
  4306. ass.ODNCode = dt.Rows[i]["ODNCode"].ToString();
  4307. ass.User = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  4308. ass.MTIME = System.DateTime.Now.ToString("s");
  4309. ass.WorkPoint = WorkPoint;
  4310. DataRow[] drs = dtD.Select("ODNID='" + dt.Rows[i]["ODNID"].ToString() + "'");
  4311. for (int j = 0; j < drs.Length; j++)
  4312. {
  4313. WWRejectionBody DetailList = new WWRejectionBody();
  4314. DetailList.Sequence = (j + 1).ToString();
  4315. DetailList.InvCode = drs[j]["InvCode"].ToString();
  4316. DetailList.Quantity = drs[j]["Quantity"].ToString();
  4317. DetailList.Amount = drs[j]["Amount"].ToString();
  4318. DetailList.Currency = drs[j]["Currency"].ToString();
  4319. DetailList.UnitPrice = drs[j]["UnitPrice"].ToString();
  4320. DetailList.ODNDetailID = drs[j]["ODNDetailID"].ToString();
  4321. DetailList.LotNo = drs[j]["LotNo"].ToString();
  4322. ass.detail.Add(DetailList);
  4323. }
  4324. // var group = ass.detail.GroupBy(x => x.InvCode).ToList();
  4325. asn.Add(ass);
  4326. }
  4327. string input = JsonConvert.SerializeObject(asn);
  4328. string APIURL = ConfigurationManager.ConnectionStrings["APIURL"].ConnectionString + "OutsourcingRejectDoc/Create";
  4329. string result = HttpPost(APIURL, input);
  4330. JObject Obj = (JObject)JsonConvert.DeserializeObject(result);//或者JObject jo = JObject.Parse(jsonText);
  4331. string MessAge = Obj["Message"].ToString();
  4332. string Success = Obj["Success"].ToString();
  4333. if (Success.ToUpper() == "FALSE")
  4334. {
  4335. msg = MessAge;
  4336. }
  4337. return msg;
  4338. }
  4339. //生成委外拒收单(无来源)
  4340. public string CreateWWWLYRejection(string keyValue)
  4341. {
  4342. string msg = "";
  4343. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  4344. string sqlAsn = @"select distinct a.VenCode,a.ODNID,a.DepCode,a.ODNCode
  4345. from ICSODeliveryNotice a
  4346. left join ICSInventoryLotDetail e on a.ODNCode=e.TransCode and a.Sequence=e.TransSequence and a.WorkPoint=e.WorkPoint
  4347. inner JOIN ICSInventoryLot d ON e.LotNo=d.LotNo AND a.InvCode=d.InvCode AND e.WorkPoint=d.WorkPoint
  4348. left JOIN ICSInventory c ON a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint
  4349. WHERE d.LotNo in (" + keyValue.TrimEnd(',') + ")";
  4350. DataTable dt = Repository().FindTableBySql(sqlAsn.ToString());
  4351. 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
  4352. from ICSODeliveryNotice a
  4353. left join ICSInventoryLotDetail e on a.ODNCode=e.TransCode and a.Sequence=e.TransSequence and a.WorkPoint=e.WorkPoint
  4354. inner join ICSInventoryLot c on e.LotNo=c.LotNo and a.InvCode=c.InvCode and e.WorkPoint=c.WorkPoint
  4355. inner join ICSInspection d on c.LotNo=d.LotNo and a.WorkPoint=d.WorkPoint and d.Enable='1'
  4356. WHERE c.LotNo IN (" + keyValue.TrimEnd(',') + ") ";
  4357. DataTable dtD = Repository().FindTableBySql(sqlAsnD.ToString());
  4358. List<WWRejectionHead> asn = new List<WWRejectionHead>();
  4359. for (int i = 0; i < dt.Rows.Count; i++)
  4360. {
  4361. WWRejectionHead ass = new WWRejectionHead();
  4362. ass.VenCode = dt.Rows[i]["VenCode"].ToString();
  4363. ass.ID = dt.Rows[i]["ODNID"].ToString();
  4364. ass.DepCode = dt.Rows[i]["DepCode"].ToString();
  4365. ass.ODNCode = dt.Rows[i]["ODNCode"].ToString();
  4366. ass.User = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  4367. ass.MTIME = System.DateTime.Now.ToString("s");
  4368. ass.WorkPoint = WorkPoint;
  4369. DataRow[] drs = dtD.Select("ODNID='" + dt.Rows[i]["ODNID"].ToString() + "'");
  4370. for (int j = 0; j < drs.Length; j++)
  4371. {
  4372. WWRejectionBody DetailList = new WWRejectionBody();
  4373. DetailList.Sequence = (j + 1).ToString();
  4374. DetailList.InvCode = drs[j]["InvCode"].ToString();
  4375. DetailList.Quantity = drs[j]["Quantity"].ToString();
  4376. DetailList.Amount = drs[j]["Amount"].ToString();
  4377. DetailList.Currency = drs[j]["Currency"].ToString();
  4378. DetailList.UnitPrice = drs[j]["UnitPrice"].ToString();
  4379. DetailList.ODNDetailID = drs[j]["ODNDetailID"].ToString();
  4380. DetailList.LotNo = drs[j]["LotNo"].ToString();
  4381. ass.detail.Add(DetailList);
  4382. }
  4383. asn.Add(ass);
  4384. }
  4385. string input = JsonConvert.SerializeObject(asn);
  4386. string APIURL = ConfigurationManager.ConnectionStrings["APIURL"].ConnectionString + "OutsourcingRejectDocNoTrans/Create";
  4387. string result = HttpPost(APIURL, input);
  4388. JObject Obj = (JObject)JsonConvert.DeserializeObject(result);//或者JObject jo = JObject.Parse(jsonText);
  4389. string MessAge = Obj["Message"].ToString();
  4390. string Success = Obj["Success"].ToString();
  4391. if (Success.ToUpper() == "FALSE")
  4392. {
  4393. msg = MessAge;
  4394. }
  4395. return msg;
  4396. }
  4397. public static string HttpPost(string url, string body)
  4398. {
  4399. try
  4400. {
  4401. Encoding encoding = Encoding.UTF8;
  4402. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
  4403. request.Method = "POST";
  4404. request.Accept = "application/json, text/javascript, */*"; //"text/html, application/xhtml+xml, */*";
  4405. request.ContentType = "application/json; charset=utf-8";
  4406. byte[] buffer = encoding.GetBytes(body);
  4407. request.ContentLength = buffer.Length;
  4408. request.GetRequestStream().Write(buffer, 0, buffer.Length);
  4409. HttpWebResponse response = (HttpWebResponse)request.GetResponse();
  4410. using (StreamReader reader = new StreamReader(response.GetResponseStream(), encoding))
  4411. {
  4412. return reader.ReadToEnd();
  4413. }
  4414. }
  4415. catch (WebException ex)
  4416. {
  4417. throw new Exception(ex.Message);
  4418. }
  4419. }
  4420. /// <summary>
  4421. /// 删除拒收单
  4422. /// </summary>
  4423. /// <param name="keyValue">传入ID</param>
  4424. /// <returns></returns>
  4425. public string DelectRejection(string keyValue)
  4426. {
  4427. //站点信息
  4428. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  4429. string msg = "";
  4430. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  4431. string sql = string.Empty;
  4432. sql = string.Format(@"DELETE FROM dbo.ICSDeliveryNotice WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  4433. try
  4434. {
  4435. SqlHelper.ExecuteNonQuery(sql);
  4436. }
  4437. catch (Exception ex)
  4438. {
  4439. throw new Exception(ex.Message);
  4440. }
  4441. return msg;
  4442. }
  4443. /// <summary>
  4444. /// 删除委外拒收单
  4445. /// </summary>
  4446. /// <param name="keyValue">传入ID</param>
  4447. /// <returns></returns>
  4448. public string DelectWWRejection(string keyValue)
  4449. {
  4450. //站点信息
  4451. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  4452. string msg = "";
  4453. keyValue = keyValue.Substring(1, keyValue.Length - 2);
  4454. string sql = string.Empty;
  4455. sql = string.Format(@"DELETE FROM dbo.ICSODeliveryNotice WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
  4456. try
  4457. {
  4458. SqlHelper.ExecuteNonQuery(sql);
  4459. }
  4460. catch (Exception ex)
  4461. {
  4462. throw new Exception(ex.Message);
  4463. }
  4464. return msg;
  4465. }
  4466. public DataTable GetInventoryInspection(ref Pagination jqgridparam, string InvCode, int SampleQuantity, string ResultINp)
  4467. {
  4468. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  4469. DataTable dt = new DataTable();
  4470. List<DbParameter> parameter = new List<DbParameter>();
  4471. string sql = string.Empty;
  4472. if (ResultINp == "")
  4473. {
  4474. sql = "SELECT 1 AS NUM INTO #TEmpType";
  4475. for (int i = 2; i <= SampleQuantity; i++)
  4476. {
  4477. sql += @" UNION
  4478. SELECT " + i + " AS NUM";
  4479. }
  4480. 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
  4481. INTO #TEmpTypedetail from ICSInventoryInspectionGroup a
  4482. left join ICSInventoryInspectionList b on a.ID=b.InvGroupID and a.WorkPoint=b.WorkPoint
  4483. left join ICSInspectionDetail c on b.ListCode=c.ListCode and b.ListName=c.ListName and b.WorkPoint=c.WorkPoint
  4484. where a.InvCode='{0}' and b.Enable='1' and a.WorkPoint='{1}'
  4485. 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
  4486. ";
  4487. sql = string.Format(sql, InvCode, WorkPoint);
  4488. return SqlHelper.FindTablePageBySql_OtherTemp(sql.ToString(), " " + "##SUMCount" + " ", " DROP TABLE #TEmpType;DROP TABLE #TEmpTypedetail;DROP TABLE ##SUMCount", parameter.ToArray(), ref jqgridparam);
  4489. }
  4490. else
  4491. {
  4492. 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
  4493. from ICSInventoryInspectionGroup a
  4494. left join ICSInventoryInspectionList b on a.ID=b.InvGroupID and a.WorkPoint=b.WorkPoint
  4495. left join ICSInspectionDetail c on b.ListCode=c.ListCode and b.ListName=c.ListName and b.WorkPoint=c.WorkPoint
  4496. where a.InvCode='{0}' and b.Enable='1' and a.WorkPoint='{1}'
  4497. ";
  4498. sql = string.Format(sql, InvCode, WorkPoint);
  4499. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  4500. }
  4501. }
  4502. public string SaveICSInspectionDetail(string ICSMTDOC, string InvCode, string ResultINp)
  4503. {
  4504. string msg = "";
  4505. try
  4506. {
  4507. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  4508. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  4509. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  4510. string sql = string.Empty;
  4511. JArray res = (JArray)JsonConvert.DeserializeObject(ICSMTDOC);
  4512. bool ISOK = false;
  4513. string ID = string.Empty;
  4514. foreach (var item in res)
  4515. {
  4516. JObject jo = (JObject)item;
  4517. ID = jo["InspectionID"].ToString();
  4518. if (string.IsNullOrWhiteSpace(ResultINp))
  4519. {
  4520. sql += @"
  4521. INSERT INTO dbo.ICSInspectionDetail
  4522. ( ID ,InspectionID ,ListCode ,ListName ,
  4523. Unit ,SetValueMax ,SetValueMin ,SetValue ,Result, MUSER ,MUSERName ,MTIME, WorkPoint,GroupCode,GroupName,EATTRIBUTE1)
  4524. values(newid(),'{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}',getdate(),'{10}','{11}','{12}','{13}')";
  4525. 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());
  4526. }
  4527. else
  4528. {
  4529. 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}'";
  4530. 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());
  4531. }
  4532. if (jo["Result"].ToString() == "0")
  4533. {
  4534. ISOK = true;
  4535. }
  4536. }
  4537. if (ISOK == true)
  4538. {
  4539. sql += @" update ICSInspection set Result='{0}' where ID='{1}'";
  4540. sql = string.Format(sql, 0, ID);
  4541. }
  4542. else
  4543. {
  4544. sql += @" update ICSInspection set Result='{0}' where ID='{1}'";
  4545. sql = string.Format(sql, 1, ID);
  4546. }
  4547. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  4548. {
  4549. }
  4550. else
  4551. {
  4552. msg = "绑定失败";
  4553. }
  4554. }
  4555. catch (Exception ex)
  4556. {
  4557. msg = ex.Message;
  4558. }
  4559. return msg;
  4560. }
  4561. /// <summary>
  4562. /// 上传招标文件
  4563. /// </summary>
  4564. /// <param name="keyValue"></param>
  4565. /// <returns></returns>
  4566. public int InsertICSInspectionFile(string ID, string UploadfileName, string fileName)
  4567. {
  4568. DataTable dt = new DataTable();
  4569. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  4570. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  4571. string MUSERName = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  4572. string sql = "";
  4573. 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);
  4574. sql += "\r\n";
  4575. StringBuilder Str = new StringBuilder(sql);
  4576. return Repository().ExecuteBySql(Str);
  4577. }
  4578. public DataTable GetICSInspection8(ref Pagination jqgridparam, string queryJson)
  4579. {
  4580. //string ERPSign = Configs.GetValue("ERPSign");
  4581. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  4582. DataTable dt = new DataTable();
  4583. var queryParam = queryJson.ToJObject();
  4584. List<DbParameter> parameter = new List<DbParameter>();
  4585. string sql = string.Empty;
  4586. sql = @"
  4587. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_8'))
  4588. drop table #TempMOData_8
  4589. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_8_1'))
  4590. drop table #TempMOData_8_1
  4591. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_8'))
  4592. drop table #TempIcsinsp_8
  4593. select ID,QualifiedQuantity,UnqualifiedQuantity,WaiveQuantity,
  4594. SampleQuantity,MUSERName,MTIME,Result,LotNo,BCCode,workpoint,BRCode,InvCode
  4595. into #TempIcsinsp_8
  4596. from dbo.ICSInspection
  4597. where workpoint='" + WorkPoint + @"' and Enable='1'
  4598. select DISTINCT
  4599. a.ID as DHID,
  4600. d.ID ,
  4601. h.ID as JYID,
  4602. a.DNCode ,
  4603. a.Sequence ,
  4604. a.ASNCode ,
  4605. --l.POCode,
  4606. c.InvCode ,
  4607. c.InvName ,
  4608. c.INVSTD ,
  4609. c.ClassName,
  4610. CAST(d.Quantity as decimal(18,4)) as AllNumber,
  4611. CAST(ISNULL(h.QualifiedQuantity, d.Quantity)as decimal(18,4))as YLOTQTY ,
  4612. CAST(ISNULL(h.UnqualifiedQuantity, 0) as decimal(18,4)) as NLOTQTY,
  4613. CAST(ISNULL(h.WaiveQuantity, 0) as decimal(18,4)) as SpecialQTY,
  4614. CASE WHEN isnull(h.ID,'') ='' THEN isnull(p.SampleQuantity,0) ELSE CAST(ISNULL(h.SampleQuantity, 0) as decimal(18,4)) END AS SampleQuantity ,
  4615. c.InvUnit ,
  4616. d.LotNo ,
  4617. g.BadReasonDesc as BadReasonDesc ,
  4618. g.BadReasonCode as BRCodeValue,
  4619. j.BadCode as BCCodeValue,
  4620. j.BadDesc as BadDesc,
  4621. k.ContainerID,
  4622. isnull(h.MUSERName,'') MUSERName,
  4623. CONVERT(VARCHAR(100),d.ProductDate,120) as ProductTime,
  4624. CONVERT(VARCHAR(100),a.CreateDateTime,120) as CreateDateTime,
  4625. CONVERT(VARCHAR(100),h.MTIME,120) as MTIME,
  4626. CASE WHEN isnull(h.ID,'') =''THEN '' ELSE '' END AS TestState,
  4627. a.VenCode,
  4628. m.VenName,c.EATTRIBUTE3 as InvEATTRIBUTE3,
  4629. isnull(h.MUSERName,'') as Surveyor,
  4630. h.mtime as ProvingTime
  4631. ,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
  4632. ,CASE WHEN h.Result='0' THEN '' when ISNULL(h.Result,'')='' THEN '' ELSE '' END AS Result,
  4633. n.FileName,c.InvIQC
  4634. into #TempMOData_8
  4635. FROM ICSDeliveryNotice a
  4636. --inner JOIN ICSASNDetail b ON a.ASNCode=b.ASNCode AND a.WorkPoint=b.WorkPoint
  4637. left join ICSInventoryLotDetail e on a.DNCode=e.TransCode and a.Sequence=e.TransSequence and a.WorkPoint=e.WorkPoint
  4638. inner JOIN ICSInventory c ON a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint-- and c.InvIQC='1'
  4639. inner JOIN ICSInventoryLot d ON e.LotNo=d.LotNo AND a.InvCode=d.InvCode AND a.WorkPoint=d.WorkPoint and d.type='7'
  4640. LEFT JOIN #TempIcsinsp_8 h ON h.LotNo=d.LotNo AND h.WorkPoint=a.WorkPoint --and Enable='1'
  4641. left join ICSBadReason g on h.BRCode =g.BadReasonCode and h.WorkPoint=g.WorkPoint
  4642. left join ICSBadCode j on h.BCCode =j.BadCode and h.WorkPoint=j.WorkPoint
  4643. LEFT JOIN ICSContainerLot k ON d.LotNo=k.LotNo AND a.WorkPoint=k.WorkPoint
  4644. left join ICSExtension f on d.ExtensionID=f.ID and d.WorkPoint=f.WorkPoint
  4645. left join dbo.ICSVendor m on a.VenCode=m.VenCode and a.WorkPoint=m.WorkPoint
  4646. left join ICSInspectionFile n on h.id=n.InspectionID and h.WorkPoint=n.WorkPoint
  4647. LEFT JOIN ICSInventoryInspectionRulesGroup o ON a.InvCode=o.InvCode AND a.WorkPoint=o.WorkPoint
  4648. LEFT JOIN ICSInventoryInspectionRuleslist p ON o.id=p.invrulesid AND o.WorkPoint=p.WorkPoint AND d.Quantity BETWEEN p.SetValueMax AND p.SetValueMin
  4649. where d.LotNo is not null and a.DNType='1' {0} and a.workpoint='{1}' and Isnull(d.EATTRIBUTE1,'') = ''
  4650. select * into #TempMOData_8_1 from #TempMOData_8 where InvIQC='1'
  4651. ";
  4652. string wheresql = "";
  4653. if (!string.IsNullOrWhiteSpace(queryJson))
  4654. {
  4655. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  4656. {
  4657. wheresql += " and a.DNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  4658. }
  4659. //if (!string.IsNullOrWhiteSpace(queryParam["ASNCode"].ToString()))
  4660. //{
  4661. // wheresql += " and a.ASNCode like '%" + queryParam["ASNCode"].ToString() + "%' ";
  4662. //}
  4663. //if (!string.IsNullOrWhiteSpace(queryParam["CaiGouCode"].ToString()))
  4664. //{
  4665. // wheresql += " and l.POCode like '%" + queryParam["CaiGouCode"].ToString() + "%' ";
  4666. //}
  4667. if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
  4668. {
  4669. wheresql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
  4670. }
  4671. if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
  4672. {
  4673. wheresql += " and m.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
  4674. }
  4675. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  4676. {
  4677. wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  4678. }
  4679. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  4680. {
  4681. wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  4682. }
  4683. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  4684. {
  4685. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  4686. }
  4687. if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
  4688. {
  4689. wheresql += " and d.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
  4690. }
  4691. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  4692. {
  4693. string ReleaseState = queryParam["ReleaseState"].ToString();
  4694. if (ReleaseState == "1")
  4695. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
  4696. else if (ReleaseState == "0")
  4697. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
  4698. else
  4699. wheresql += " ";
  4700. }
  4701. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  4702. {
  4703. string selEnableShow = queryParam["selEnableShow"].ToString();
  4704. if (selEnableShow == "1")
  4705. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
  4706. else if (selEnableShow == "0")
  4707. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
  4708. }
  4709. }
  4710. sql = string.Format(sql, wheresql, WorkPoint);
  4711. // return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  4712. return Repository().FindTablePageBySql_OtherTemp(sql, "#TempMOData_8_1",
  4713. @" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_8'))
  4714. drop table #TempMOData_8
  4715. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_8_1'))
  4716. drop table #TempMOData_8_1
  4717. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_8'))
  4718. drop table #TempIcsinsp_8 ",
  4719. "connstr", parameter.ToArray(), ref jqgridparam);
  4720. }
  4721. /// <summary>
  4722. /// 采购到货检验(批次维度)
  4723. /// </summary>
  4724. /// <param name="jqgridparam"></param>
  4725. /// <param name="queryJson"></param>
  4726. /// <returns></returns>
  4727. public DataTable GetICSInspection8BatchCode(ref Pagination jqgridparam, string queryJson)
  4728. {
  4729. //string ERPSign = Configs.GetValue("ERPSign");
  4730. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  4731. DataTable dt = new DataTable();
  4732. var queryParam = queryJson.ToJObject();
  4733. List<DbParameter> parameter = new List<DbParameter>();
  4734. string sql = string.Empty;
  4735. sql = @"
  4736. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_8'))
  4737. drop table #TempMOData_8
  4738. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_8_1'))
  4739. drop table #TempMOData_8_1
  4740. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_8'))
  4741. drop table #TempIcsinsp_8
  4742. select ID,QualifiedQuantity,UnqualifiedQuantity,WaiveQuantity,
  4743. SampleQuantity,MUSERName,MTIME,Result,LotNo,BCCode,workpoint,BRCode,InvCode
  4744. into #TempIcsinsp_8
  4745. from dbo.ICSInspection
  4746. where workpoint='" + WorkPoint + @"' and Enable='1'
  4747. select DISTINCT
  4748. a.ID as DHID,
  4749. a.DNCode ,
  4750. a.Sequence ,
  4751. a.ASNCode ,
  4752. --l.POCode,
  4753. c.InvCode ,
  4754. c.InvName ,
  4755. c.INVSTD ,
  4756. c.ClassName,
  4757. CAST(sum(d.Quantity) as decimal(18,4)) as AllNumber,
  4758. CAST(ISNULL(sum(h.QualifiedQuantity), sum(d.Quantity))as decimal(18,4))as YLOTQTY ,
  4759. CAST(ISNULL(sum(h.UnqualifiedQuantity), 0) as decimal(18,4)) as NLOTQTY,
  4760. CAST(ISNULL(sum(h.WaiveQuantity), 0) as decimal(18,4)) as SpecialQTY,
  4761. CAST(ISNULL(sum(h.SampleQuantity), 0) as decimal(18,4)) as SampleQuantity,
  4762. c.InvUnit ,
  4763. a.VenCode,
  4764. m.VenName,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,c.InvIQC
  4765. into #TempMOData_8
  4766. FROM ICSDeliveryNotice a
  4767. --inner JOIN ICSASNDetail b ON a.ASNCode=b.ASNCode AND a.WorkPoint=b.WorkPoint
  4768. left join ICSInventoryLotDetail e on a.DNCode=e.TransCode and a.Sequence=e.TransSequence and a.WorkPoint=e.WorkPoint
  4769. inner JOIN ICSInventory c ON a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint-- and c.InvIQC='1'
  4770. inner JOIN ICSInventoryLot d ON e.LotNo=d.LotNo AND a.InvCode=d.InvCode AND a.WorkPoint=d.WorkPoint and d.type='7'
  4771. LEFT JOIN #TempIcsinsp_8 h ON h.LotNo=d.LotNo AND h.WorkPoint=a.WorkPoint --and Enable='1'
  4772. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  4773. left join dbo.ICSVendor m on a.VenCode=m.VenCode and a.WorkPoint=m.WorkPoint
  4774. where d.LotNo is not null and a.DNType='1' {0} and a.workpoint='{1}'
  4775. ";
  4776. string wheresql = "";
  4777. if (!string.IsNullOrWhiteSpace(queryJson))
  4778. {
  4779. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  4780. {
  4781. wheresql += " and a.DNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  4782. }
  4783. //if (!string.IsNullOrWhiteSpace(queryParam["ASNCode"].ToString()))
  4784. //{
  4785. // wheresql += " and a.ASNCode like '%" + queryParam["ASNCode"].ToString() + "%' ";
  4786. //}
  4787. //if (!string.IsNullOrWhiteSpace(queryParam["CaiGouCode"].ToString()))
  4788. //{
  4789. // wheresql += " and l.POCode like '%" + queryParam["CaiGouCode"].ToString() + "%' ";
  4790. //}
  4791. if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
  4792. {
  4793. wheresql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
  4794. }
  4795. if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
  4796. {
  4797. wheresql += " and m.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
  4798. }
  4799. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  4800. {
  4801. wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  4802. }
  4803. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  4804. {
  4805. wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  4806. }
  4807. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  4808. {
  4809. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  4810. }
  4811. if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
  4812. {
  4813. wheresql += " and d.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
  4814. }
  4815. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  4816. {
  4817. string ReleaseState = queryParam["ReleaseState"].ToString();
  4818. if (ReleaseState == "1")
  4819. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
  4820. else if (ReleaseState == "0")
  4821. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
  4822. else
  4823. wheresql += " ";
  4824. }
  4825. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  4826. {
  4827. string selEnableShow = queryParam["selEnableShow"].ToString();
  4828. if (selEnableShow == "1")
  4829. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
  4830. else if (selEnableShow == "0")
  4831. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
  4832. }
  4833. }
  4834. sql += @" GROUP BY a.ID,a.DNCode ,a.Sequence ,a.ASNCode ,--l.POCode
  4835. c.InvCode ,c.InvName ,c.INVSTD ,c.ClassName,c.InvUnit ,a.VenCode,m.VenName,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,c.InvIQC ;select * into #TempMOData_8_1 from #TempMOData_8 where InvIQC='1' ";
  4836. sql = string.Format(sql, wheresql, WorkPoint);
  4837. // return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  4838. return Repository().FindTablePageBySql_OtherTemp(sql, "#TempMOData_8_1",
  4839. @" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_8'))
  4840. drop table #TempMOData_8
  4841. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_8_1'))
  4842. drop table #TempMOData_8_1
  4843. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_8'))
  4844. drop table #TempIcsinsp_8 ",
  4845. "connstr", parameter.ToArray(), ref jqgridparam);
  4846. }
  4847. /// <summary>
  4848. /// 采购到货检验(单据行维度)
  4849. /// </summary>
  4850. /// <param name="jqgridparam"></param>
  4851. /// <param name="queryJson"></param>
  4852. /// <returns></returns>
  4853. public DataTable GetICSInspection8DocSequence(ref Pagination jqgridparam, string queryJson)
  4854. {
  4855. //string ERPSign = Configs.GetValue("ERPSign");
  4856. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  4857. DataTable dt = new DataTable();
  4858. var queryParam = queryJson.ToJObject();
  4859. List<DbParameter> parameter = new List<DbParameter>();
  4860. string sql = string.Empty;
  4861. sql = @"
  4862. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_8'))
  4863. drop table #TempMOData_8
  4864. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_8_1'))
  4865. drop table #TempMOData_8_1
  4866. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_8'))
  4867. drop table #TempIcsinsp_8
  4868. select ID,QualifiedQuantity,UnqualifiedQuantity,WaiveQuantity,
  4869. SampleQuantity,MUSERName,MTIME,Result,LotNo,BCCode,workpoint,BRCode,InvCode
  4870. into #TempIcsinsp_8
  4871. from dbo.ICSInspection
  4872. where workpoint='" + WorkPoint + @"' and Enable='1'
  4873. select DISTINCT
  4874. a.ID as DHID,
  4875. a.DNCode ,
  4876. a.Sequence ,
  4877. a.ASNCode ,
  4878. --l.POCode,
  4879. c.InvCode ,
  4880. c.InvName ,
  4881. c.INVSTD ,
  4882. c.ClassName,
  4883. CAST(sum(d.Quantity) as decimal(18,4)) as AllNumber,
  4884. CAST(ISNULL(sum(h.QualifiedQuantity), sum(d.Quantity))as decimal(18,4))as YLOTQTY ,
  4885. CAST(ISNULL(sum(h.UnqualifiedQuantity), 0) as decimal(18,4)) as NLOTQTY,
  4886. CAST(ISNULL(sum(h.WaiveQuantity), 0) as decimal(18,4)) as SpecialQTY,
  4887. CAST(ISNULL(sum(h.SampleQuantity), 0) as decimal(18,4)) as SampleQuantity,
  4888. c.InvUnit ,
  4889. a.VenCode,
  4890. m.VenName,c.InvIQC
  4891. into #TempMOData_8
  4892. FROM ICSDeliveryNotice a
  4893. --inner JOIN ICSASNDetail b ON a.ASNCode=b.ASNCode AND a.WorkPoint=b.WorkPoint
  4894. left join ICSInventoryLotDetail e on a.DNCode=e.TransCode and a.Sequence=e.TransSequence and a.WorkPoint=e.WorkPoint
  4895. inner JOIN ICSInventory c ON a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint-- and c.InvIQC='1'
  4896. inner JOIN ICSInventoryLot d ON e.LotNo=d.LotNo AND a.InvCode=d.InvCode AND a.WorkPoint=d.WorkPoint and d.type='7'
  4897. LEFT JOIN #TempIcsinsp_8 h ON h.LotNo=d.LotNo AND h.WorkPoint=a.WorkPoint --and Enable='1'
  4898. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  4899. left join dbo.ICSVendor m on a.VenCode=m.VenCode and a.WorkPoint=m.WorkPoint
  4900. where d.LotNo is not null and a.DNType='1' {0} and a.workpoint='{1}'
  4901. ";
  4902. string wheresql = "";
  4903. if (!string.IsNullOrWhiteSpace(queryJson))
  4904. {
  4905. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  4906. {
  4907. wheresql += " and a.DNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  4908. }
  4909. //if (!string.IsNullOrWhiteSpace(queryParam["ASNCode"].ToString()))
  4910. //{
  4911. // wheresql += " and a.ASNCode like '%" + queryParam["ASNCode"].ToString() + "%' ";
  4912. //}
  4913. //if (!string.IsNullOrWhiteSpace(queryParam["CaiGouCode"].ToString()))
  4914. //{
  4915. // wheresql += " and l.POCode like '%" + queryParam["CaiGouCode"].ToString() + "%' ";
  4916. //}
  4917. if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
  4918. {
  4919. wheresql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
  4920. }
  4921. if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
  4922. {
  4923. wheresql += " and m.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
  4924. }
  4925. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  4926. {
  4927. wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  4928. }
  4929. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  4930. {
  4931. wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  4932. }
  4933. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  4934. {
  4935. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  4936. }
  4937. if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
  4938. {
  4939. wheresql += " and d.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
  4940. }
  4941. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  4942. {
  4943. string ReleaseState = queryParam["ReleaseState"].ToString();
  4944. if (ReleaseState == "1")
  4945. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
  4946. else if (ReleaseState == "0")
  4947. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
  4948. else
  4949. wheresql += " ";
  4950. }
  4951. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  4952. {
  4953. string selEnableShow = queryParam["selEnableShow"].ToString();
  4954. if (selEnableShow == "1")
  4955. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
  4956. else if (selEnableShow == "0")
  4957. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
  4958. }
  4959. }
  4960. sql += @" GROUP BY a.ID,a.DNCode ,a.Sequence ,a.ASNCode ,--l.POCode
  4961. c.InvCode ,c.InvName ,c.INVSTD ,c.ClassName,c.InvUnit ,a.VenCode,m.VenName,c.InvIQC ;select * into #TempMOData_8_1 from #TempMOData_8 where InvIQC='1' ";
  4962. sql = string.Format(sql, wheresql, WorkPoint);
  4963. // return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  4964. return Repository().FindTablePageBySql_OtherTemp(sql, "#TempMOData_8_1",
  4965. @" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_8'))
  4966. drop table #TempMOData_8
  4967. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_8_1'))
  4968. drop table #TempMOData_8_1
  4969. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_8'))
  4970. drop table #TempIcsinsp_8 ",
  4971. "connstr", parameter.ToArray(), ref jqgridparam);
  4972. }
  4973. /// <summary>
  4974. /// 采购到货检验(单据维度)
  4975. /// </summary>
  4976. /// <param name="jqgridparam"></param>
  4977. /// <param name="queryJson"></param>
  4978. /// <returns></returns>
  4979. public DataTable GetICSInspection8Doc(ref Pagination jqgridparam, string queryJson)
  4980. {
  4981. //string ERPSign = Configs.GetValue("ERPSign");
  4982. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  4983. DataTable dt = new DataTable();
  4984. var queryParam = queryJson.ToJObject();
  4985. List<DbParameter> parameter = new List<DbParameter>();
  4986. string sql = string.Empty;
  4987. sql = @"
  4988. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_8'))
  4989. drop table #TempMOData_8
  4990. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_8_1'))
  4991. drop table #TempMOData_8_1
  4992. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_8'))
  4993. drop table #TempIcsinsp_8
  4994. select ID,QualifiedQuantity,UnqualifiedQuantity,WaiveQuantity,
  4995. SampleQuantity,MUSERName,MTIME,Result,LotNo,BCCode,workpoint,BRCode,InvCode
  4996. into #TempIcsinsp_8
  4997. from dbo.ICSInspection
  4998. where workpoint='" + WorkPoint + @"' and Enable='1'
  4999. select DISTINCT a.DNCode ,a.ASNCode ,
  5000. CAST(sum(d.Quantity) as decimal(18,4)) as AllNumber,
  5001. CAST(ISNULL(sum(h.QualifiedQuantity), sum(d.Quantity))as decimal(18,4))as YLOTQTY ,
  5002. CAST(ISNULL(sum(h.UnqualifiedQuantity), 0) as decimal(18,4)) as NLOTQTY,
  5003. CAST(ISNULL(sum(h.WaiveQuantity), 0) as decimal(18,4)) as SpecialQTY,
  5004. CAST(ISNULL(sum(h.SampleQuantity), 0) as decimal(18,4)) as SampleQuantity
  5005. into #TempMOData_8
  5006. FROM ICSDeliveryNotice a
  5007. --inner JOIN ICSASNDetail b ON a.ASNCode=b.ASNCode AND a.WorkPoint=b.WorkPoint
  5008. left join ICSInventoryLotDetail e on a.DNCode=e.TransCode and a.Sequence=e.TransSequence and a.WorkPoint=e.WorkPoint
  5009. inner JOIN ICSInventory c ON a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint and c.InvIQC='1'
  5010. inner JOIN ICSInventoryLot d ON e.LotNo=d.LotNo AND a.InvCode=d.InvCode AND a.WorkPoint=d.WorkPoint and d.type='7'
  5011. LEFT JOIN #TempIcsinsp_8 h ON h.LotNo=d.LotNo AND h.WorkPoint=a.WorkPoint --and Enable='1'
  5012. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  5013. left join dbo.ICSVendor m on a.VenCode=m.VenCode and a.WorkPoint=m.WorkPoint
  5014. where d.LotNo is not null and a.DNType='1' {0} and a.workpoint='{1}'
  5015. ";
  5016. string wheresql = "";
  5017. if (!string.IsNullOrWhiteSpace(queryJson))
  5018. {
  5019. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  5020. {
  5021. wheresql += " and a.DNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  5022. }
  5023. //if (!string.IsNullOrWhiteSpace(queryParam["ASNCode"].ToString()))
  5024. //{
  5025. // wheresql += " and a.ASNCode like '%" + queryParam["ASNCode"].ToString() + "%' ";
  5026. //}
  5027. //if (!string.IsNullOrWhiteSpace(queryParam["CaiGouCode"].ToString()))
  5028. //{
  5029. // wheresql += " and l.POCode like '%" + queryParam["CaiGouCode"].ToString() + "%' ";
  5030. //}
  5031. if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
  5032. {
  5033. wheresql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
  5034. }
  5035. if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
  5036. {
  5037. wheresql += " and m.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
  5038. }
  5039. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  5040. {
  5041. wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  5042. }
  5043. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  5044. {
  5045. wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  5046. }
  5047. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  5048. {
  5049. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  5050. }
  5051. if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
  5052. {
  5053. wheresql += " and d.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
  5054. }
  5055. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  5056. {
  5057. string ReleaseState = queryParam["ReleaseState"].ToString();
  5058. if (ReleaseState == "1")
  5059. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
  5060. else if (ReleaseState == "0")
  5061. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
  5062. else
  5063. wheresql += " ";
  5064. }
  5065. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  5066. {
  5067. string selEnableShow = queryParam["selEnableShow"].ToString();
  5068. if (selEnableShow == "1")
  5069. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
  5070. else if (selEnableShow == "0")
  5071. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
  5072. }
  5073. }
  5074. sql += @" GROUP BY a.DNCode ,a.ASNCode ;select * into #TempMOData_8_1 from #TempMOData_8 ";
  5075. sql = string.Format(sql, wheresql, WorkPoint);
  5076. // return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  5077. return Repository().FindTablePageBySql_OtherTemp(sql, "#TempMOData_8_1",
  5078. @" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_8'))
  5079. drop table #TempMOData_8
  5080. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_8_1'))
  5081. drop table #TempMOData_8_1
  5082. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_8'))
  5083. drop table #TempIcsinsp_8 ",
  5084. "connstr", parameter.ToArray(), ref jqgridparam);
  5085. }
  5086. public DataTable GetICSInspection9(ref Pagination jqgridparam, string queryJson)
  5087. {
  5088. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  5089. DataTable dt = new DataTable();
  5090. var queryParam = queryJson.ToJObject();
  5091. List<DbParameter> parameter = new List<DbParameter>();
  5092. #region
  5093. string sql = @"
  5094. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_9'))
  5095. drop table #TempMOData_9
  5096. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_9_1'))
  5097. drop table #TempMOData_9_1
  5098. select
  5099. a.ID as DHID,
  5100. d.ID ,
  5101. h.ID as JYID,
  5102. a.ODNCode as DNCode ,
  5103. a.Sequence ,
  5104. a.OASNCode ,
  5105. c.InvCode ,
  5106. c.InvName ,
  5107. c.INVSTD ,
  5108. c.ClassName,
  5109. f.BatchCode ,
  5110. CAST(d.Quantity as NUMERIC(10,4)) as AllNumber,
  5111. CAST(ISNULL(h.QualifiedQuantity, d.Quantity)as NUMERIC(10,4))as YLOTQTY ,
  5112. CAST(ISNULL(h.UnqualifiedQuantity, 0) as NUMERIC(10,4)) as NLOTQTY,
  5113. CAST(ISNULL(h.WaiveQuantity, 0) as NUMERIC(10,4)) as SpecialQTY,
  5114. CASE WHEN isnull(h.ID,'') ='' THEN isnull(p.SampleQuantity,0) ELSE CAST(ISNULL(h.SampleQuantity, 0) as decimal(18,4)) END AS SampleQuantity ,
  5115. c.InvUnit ,c.EATTRIBUTE3 as InvEATTRIBUTE3,
  5116. d.LotNo ,
  5117. g.BadReasonDesc as BadReasonDesc ,
  5118. g.BadReasonCode as BRCodeValue,
  5119. j.BadCode as BCCodeValue,
  5120. j.BadDesc as BadDesc,
  5121. k.ContainerID,
  5122. isnull(h.MUSERName,'') MUSERName,
  5123. CONVERT(VARCHAR(100),d.ProductDate,120) as ProductTime,
  5124. CONVERT(VARCHAR(100),h.MTIME,120) as MTIME,
  5125. CASE WHEN isnull(h.ID,'') =''THEN '' ELSE '' END AS TestState,c.InvIQC
  5126. into #TempMOData_9
  5127. FROM ICSODeliveryNotice a
  5128. inner join ICSInventoryLotDetail e on e.TransCode =a.ODNCode AND e.TransSequence=a.Sequence AND e.WorkPoint=a.WorkPoint
  5129. inner JOIN ICSInventoryLot d ON d.LotNo=e.LotNo and d.WorkPoint=e.WorkPoint and d.type='8'
  5130. inner JOIN ICSInventory c ON a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint --and c.InvIQC='1'
  5131. LEFT JOIN dbo.ICSInspection h ON h.LotNo=d.LotNo AND h.WorkPoint=d.WorkPoint
  5132. left join ICSBadReason g on h.BRCode =g.BadReasonCode and h.WorkPoint=g.WorkPoint
  5133. left join ICSBadCode j on h.BCCode =j.BadCode and h.WorkPoint=j.WorkPoint
  5134. LEFT JOIN ICSContainerLot k ON d.LotNo=k.LotNo AND d.WorkPoint=k.WorkPoint
  5135. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  5136. LEFT JOIN ICSInventoryInspectionRulesGroup o ON a.InvCode=o.InvCode AND a.WorkPoint=o.WorkPoint
  5137. LEFT JOIN ICSInventoryInspectionRuleslist p ON o.id=p.invrulesid AND o.WorkPoint=p.WorkPoint AND d.Quantity BETWEEN p.SetValueMax AND p.SetValueMin
  5138. where 1=1 {0} and a.workpoint='{1}'
  5139. select * into #TempMOData_9_1 from #TempMOData_9 where InvIQC='1'";
  5140. #endregion
  5141. string wheresql = "";
  5142. if (!string.IsNullOrWhiteSpace(queryJson))
  5143. {
  5144. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  5145. {
  5146. wheresql += " and a.ODNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  5147. }
  5148. //if (!string.IsNullOrWhiteSpace(queryParam["ASNCode"].ToString()))
  5149. //{
  5150. // wheresql += " and a.OASNCode like '%" + queryParam["ASNCode"].ToString() + "%' ";
  5151. //}
  5152. //if (!string.IsNullOrWhiteSpace(queryParam["CaiGouCode"].ToString()))
  5153. //{
  5154. // wheresql += " and l.OOCode like '%" + queryParam["CaiGouCode"].ToString() + "%' ";
  5155. //}
  5156. if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
  5157. {
  5158. wheresql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
  5159. }
  5160. if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
  5161. {
  5162. wheresql += " and m.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
  5163. }
  5164. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  5165. {
  5166. wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  5167. }
  5168. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  5169. {
  5170. wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  5171. }
  5172. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  5173. {
  5174. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  5175. }
  5176. if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
  5177. {
  5178. wheresql += " and d.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
  5179. }
  5180. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  5181. {
  5182. string ReleaseState = queryParam["ReleaseState"].ToString();
  5183. if (ReleaseState == "1")
  5184. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
  5185. else if (ReleaseState == "0")
  5186. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
  5187. else
  5188. wheresql += " ";
  5189. }
  5190. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  5191. {
  5192. string selEnableShow = queryParam["selEnableShow"].ToString();
  5193. if (selEnableShow == "1")
  5194. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
  5195. else if (selEnableShow == "0")
  5196. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
  5197. }
  5198. }
  5199. sql = string.Format(sql, wheresql, WorkPoint);
  5200. // return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  5201. return Repository().FindTablePageBySql_OtherTemp(sql, "#TempMOData_9_1",
  5202. @" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_9'))
  5203. drop table #TempMOData_9
  5204. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_9_1'))
  5205. drop table #TempMOData_9_1 ",
  5206. "connstr", parameter.ToArray(), ref jqgridparam);
  5207. }
  5208. /// <summary>
  5209. /// 委外采购到货单检验(批次维度)
  5210. /// </summary>
  5211. /// <param name="jqgridparam"></param>
  5212. /// <param name="queryJson"></param>
  5213. /// <returns></returns>
  5214. public DataTable GetICSInspection9BatchCode(ref Pagination jqgridparam, string queryJson)
  5215. {
  5216. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  5217. DataTable dt = new DataTable();
  5218. var queryParam = queryJson.ToJObject();
  5219. List<DbParameter> parameter = new List<DbParameter>();
  5220. #region
  5221. string sql = @"
  5222. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_9'))
  5223. drop table #TempMOData_9
  5224. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_9_1'))
  5225. drop table #TempMOData_9_1
  5226. select a.ID as DHID,a.ODNCode as DNCode ,a.Sequence , a.OASNCode ,c.InvCode ,c.InvName ,c.INVSTD ,c.ClassName,
  5227. f.BatchCode ,
  5228. CAST(sum(d.Quantity) as NUMERIC(10,4)) as AllNumber,
  5229. CAST(ISNULL(sum(h.QualifiedQuantity), sum(d.Quantity))as NUMERIC(10,4))as YLOTQTY ,
  5230. CAST(ISNULL(Sum(h.UnqualifiedQuantity), 0) as NUMERIC(10,4)) as NLOTQTY,
  5231. CAST(ISNULL(sum(h.WaiveQuantity), 0) as NUMERIC(10,4)) as SpecialQTY,
  5232. CAST(ISNULL(sum(h.SampleQuantity), 0) as decimal(18,4)) as SampleQuantity,
  5233. c.InvUnit ,c.InvIQC
  5234. into #TempMOData_9
  5235. FROM ICSODeliveryNotice a
  5236. inner join ICSInventoryLotDetail e on e.TransCode =a.ODNCode AND e.TransSequence=a.Sequence AND e.WorkPoint=a.WorkPoint
  5237. inner JOIN ICSInventoryLot d ON d.LotNo=e.LotNo and d.WorkPoint=e.WorkPoint and d.type='8'
  5238. inner JOIN ICSInventory c ON a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint --and c.InvIQC='1'
  5239. LEFT JOIN dbo.ICSInspection h ON h.LotNo=d.LotNo AND h.WorkPoint=d.WorkPoint
  5240. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  5241. where 1=1 {0} and a.workpoint='{1}'
  5242. ";
  5243. #endregion
  5244. string wheresql = "";
  5245. if (!string.IsNullOrWhiteSpace(queryJson))
  5246. {
  5247. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  5248. {
  5249. wheresql += " and a.ODNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  5250. }
  5251. //if (!string.IsNullOrWhiteSpace(queryParam["ASNCode"].ToString()))
  5252. //{
  5253. // wheresql += " and a.OASNCode like '%" + queryParam["ASNCode"].ToString() + "%' ";
  5254. //}
  5255. //if (!string.IsNullOrWhiteSpace(queryParam["CaiGouCode"].ToString()))
  5256. //{
  5257. // wheresql += " and l.OOCode like '%" + queryParam["CaiGouCode"].ToString() + "%' ";
  5258. //}
  5259. if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
  5260. {
  5261. wheresql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
  5262. }
  5263. if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
  5264. {
  5265. wheresql += " and m.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
  5266. }
  5267. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  5268. {
  5269. wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  5270. }
  5271. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  5272. {
  5273. wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  5274. }
  5275. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  5276. {
  5277. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  5278. }
  5279. if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
  5280. {
  5281. wheresql += " and d.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
  5282. }
  5283. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  5284. {
  5285. string ReleaseState = queryParam["ReleaseState"].ToString();
  5286. if (ReleaseState == "1")
  5287. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
  5288. else if (ReleaseState == "0")
  5289. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
  5290. else
  5291. wheresql += " ";
  5292. }
  5293. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  5294. {
  5295. string selEnableShow = queryParam["selEnableShow"].ToString();
  5296. if (selEnableShow == "1")
  5297. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
  5298. else if (selEnableShow == "0")
  5299. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
  5300. }
  5301. }
  5302. sql += @" GROUP BY a.ID ,a.ODNCode ,a.Sequence , a.OASNCode ,c.InvCode ,c.InvName ,c.INVSTD ,c.ClassName,
  5303. f.BatchCode ,c.InvUnit ,c.InvIQC ;select * into #TempMOData_9_1 from #TempMOData_9 where InvIQC='1'";
  5304. sql = string.Format(sql, wheresql, WorkPoint);
  5305. // return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  5306. return Repository().FindTablePageBySql_OtherTemp(sql, "#TempMOData_9_1",
  5307. @" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_9'))
  5308. drop table #TempMOData_9
  5309. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_9_1'))
  5310. drop table #TempMOData_9_1 ",
  5311. "connstr", parameter.ToArray(), ref jqgridparam);
  5312. }
  5313. /// <summary>
  5314. /// 委外采购到货单检验(单据行维度)
  5315. /// </summary>
  5316. /// <param name="jqgridparam"></param>
  5317. /// <param name="queryJson"></param>
  5318. /// <returns></returns>
  5319. public DataTable GetICSInspection9DocSequence(ref Pagination jqgridparam, string queryJson)
  5320. {
  5321. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  5322. DataTable dt = new DataTable();
  5323. var queryParam = queryJson.ToJObject();
  5324. List<DbParameter> parameter = new List<DbParameter>();
  5325. #region
  5326. string sql = @"
  5327. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_9'))
  5328. drop table #TempMOData_9
  5329. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_9_1'))
  5330. drop table #TempMOData_9_1
  5331. select a.ID as DHID,a.ODNCode as DNCode ,a.Sequence , a.OASNCode ,c.InvCode ,c.InvName ,c.INVSTD ,c.ClassName,
  5332. CAST(sum(d.Quantity) as NUMERIC(10,4)) as AllNumber,
  5333. CAST(ISNULL(sum(h.QualifiedQuantity), sum(d.Quantity))as NUMERIC(10,4))as YLOTQTY ,
  5334. CAST(ISNULL(Sum(h.UnqualifiedQuantity), 0) as NUMERIC(10,4)) as NLOTQTY,
  5335. CAST(ISNULL(sum(h.WaiveQuantity), 0) as NUMERIC(10,4)) as SpecialQTY,
  5336. CAST(ISNULL(sum(h.SampleQuantity), 0) as decimal(18,4)) as SampleQuantity,
  5337. c.InvUnit ,c.InvIQC
  5338. into #TempMOData_9
  5339. FROM ICSODeliveryNotice a
  5340. inner join ICSInventoryLotDetail e on e.TransCode =a.ODNCode AND e.TransSequence=a.Sequence AND e.WorkPoint=a.WorkPoint
  5341. inner JOIN ICSInventoryLot d ON d.LotNo=e.LotNo and d.WorkPoint=e.WorkPoint and d.type='8'
  5342. inner JOIN ICSInventory c ON a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint --and c.InvIQC='1'
  5343. LEFT JOIN dbo.ICSInspection h ON h.LotNo=d.LotNo AND h.WorkPoint=d.WorkPoint
  5344. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  5345. where 1=1 {0} and a.workpoint='{1}'
  5346. ";
  5347. #endregion
  5348. string wheresql = "";
  5349. if (!string.IsNullOrWhiteSpace(queryJson))
  5350. {
  5351. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  5352. {
  5353. wheresql += " and a.ODNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  5354. }
  5355. //if (!string.IsNullOrWhiteSpace(queryParam["ASNCode"].ToString()))
  5356. //{
  5357. // wheresql += " and a.OASNCode like '%" + queryParam["ASNCode"].ToString() + "%' ";
  5358. //}
  5359. //if (!string.IsNullOrWhiteSpace(queryParam["CaiGouCode"].ToString()))
  5360. //{
  5361. // wheresql += " and l.OOCode like '%" + queryParam["CaiGouCode"].ToString() + "%' ";
  5362. //}
  5363. if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
  5364. {
  5365. wheresql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
  5366. }
  5367. if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
  5368. {
  5369. wheresql += " and m.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
  5370. }
  5371. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  5372. {
  5373. wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  5374. }
  5375. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  5376. {
  5377. wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  5378. }
  5379. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  5380. {
  5381. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  5382. }
  5383. if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
  5384. {
  5385. wheresql += " and d.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
  5386. }
  5387. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  5388. {
  5389. string ReleaseState = queryParam["ReleaseState"].ToString();
  5390. if (ReleaseState == "1")
  5391. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
  5392. else if (ReleaseState == "0")
  5393. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
  5394. else
  5395. wheresql += " ";
  5396. }
  5397. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  5398. {
  5399. string selEnableShow = queryParam["selEnableShow"].ToString();
  5400. if (selEnableShow == "1")
  5401. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
  5402. else if (selEnableShow == "0")
  5403. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
  5404. }
  5405. }
  5406. sql += @" GROUP BY a.ID ,a.ODNCode ,a.Sequence , a.OASNCode ,c.InvCode ,c.InvName ,c.INVSTD ,c.ClassName,c.InvUnit ,c.InvIQC ;select * into #TempMOData_9_1 from #TempMOData_9 where InvIQC='1'";
  5407. sql = string.Format(sql, wheresql, WorkPoint);
  5408. // return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  5409. return Repository().FindTablePageBySql_OtherTemp(sql, "#TempMOData_9_1",
  5410. @" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_9'))
  5411. drop table #TempMOData_9
  5412. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_9_1'))
  5413. drop table #TempMOData_9_1 ",
  5414. "connstr", parameter.ToArray(), ref jqgridparam);
  5415. }
  5416. /// <summary>
  5417. /// 委外采购到货单检验(单据维度)
  5418. /// </summary>
  5419. /// <param name="jqgridparam"></param>
  5420. /// <param name="queryJson"></param>
  5421. /// <returns></returns>
  5422. public DataTable GetICSInspection9Doc(ref Pagination jqgridparam, string queryJson)
  5423. {
  5424. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  5425. DataTable dt = new DataTable();
  5426. var queryParam = queryJson.ToJObject();
  5427. List<DbParameter> parameter = new List<DbParameter>();
  5428. #region
  5429. string sql = @"
  5430. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_9'))
  5431. drop table #TempMOData_9
  5432. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_9_1'))
  5433. drop table #TempMOData_9_1
  5434. select distinct a.ODNCode as DNCode ,a.OASNCode ,
  5435. CAST(sum(d.Quantity) as NUMERIC(10,4)) as AllNumber,
  5436. CAST(ISNULL(sum(h.QualifiedQuantity), sum(d.Quantity))as NUMERIC(10,4))as YLOTQTY ,
  5437. CAST(ISNULL(Sum(h.UnqualifiedQuantity), 0) as NUMERIC(10,4)) as NLOTQTY,
  5438. CAST(ISNULL(sum(h.WaiveQuantity), 0) as NUMERIC(10,4)) as SpecialQTY,
  5439. CAST(ISNULL(sum(h.SampleQuantity), 0) as decimal(18,4)) as SampleQuantity
  5440. into #TempMOData_9
  5441. FROM ICSODeliveryNotice a
  5442. inner join ICSInventoryLotDetail e on e.TransCode =a.ODNCode AND e.TransSequence=a.Sequence AND e.WorkPoint=a.WorkPoint
  5443. inner JOIN ICSInventoryLot d ON d.LotNo=e.LotNo and d.WorkPoint=e.WorkPoint and d.type='8'
  5444. inner JOIN ICSInventory c ON a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint and c.InvIQC='1'
  5445. LEFT JOIN dbo.ICSInspection h ON h.LotNo=d.LotNo AND h.WorkPoint=d.WorkPoint
  5446. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  5447. where 1=1 {0} and a.workpoint='{1}'
  5448. ";
  5449. #endregion
  5450. string wheresql = "";
  5451. if (!string.IsNullOrWhiteSpace(queryJson))
  5452. {
  5453. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  5454. {
  5455. wheresql += " and a.ODNCode like '%" + queryParam["POCode"].ToString() + "%' ";
  5456. }
  5457. //if (!string.IsNullOrWhiteSpace(queryParam["ASNCode"].ToString()))
  5458. //{
  5459. // wheresql += " and a.OASNCode like '%" + queryParam["ASNCode"].ToString() + "%' ";
  5460. //}
  5461. //if (!string.IsNullOrWhiteSpace(queryParam["CaiGouCode"].ToString()))
  5462. //{
  5463. // wheresql += " and l.OOCode like '%" + queryParam["CaiGouCode"].ToString() + "%' ";
  5464. //}
  5465. if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
  5466. {
  5467. wheresql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
  5468. }
  5469. if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
  5470. {
  5471. wheresql += " and m.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
  5472. }
  5473. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  5474. {
  5475. wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  5476. }
  5477. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  5478. {
  5479. wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  5480. }
  5481. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  5482. {
  5483. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  5484. }
  5485. if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
  5486. {
  5487. wheresql += " and d.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
  5488. }
  5489. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  5490. {
  5491. string ReleaseState = queryParam["ReleaseState"].ToString();
  5492. if (ReleaseState == "1")
  5493. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
  5494. else if (ReleaseState == "0")
  5495. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
  5496. else
  5497. wheresql += " ";
  5498. }
  5499. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  5500. {
  5501. string selEnableShow = queryParam["selEnableShow"].ToString();
  5502. if (selEnableShow == "1")
  5503. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
  5504. else if (selEnableShow == "0")
  5505. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
  5506. }
  5507. }
  5508. sql += @" GROUP BY a.ODNCode , a.OASNCode ;select * into #TempMOData_9_1 from #TempMOData_9 ";
  5509. sql = string.Format(sql, wheresql, WorkPoint);
  5510. // return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  5511. return Repository().FindTablePageBySql_OtherTemp(sql, "#TempMOData_9_1",
  5512. @" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_9'))
  5513. drop table #TempMOData_9
  5514. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_9_1'))
  5515. drop table #TempMOData_9_1 ",
  5516. "connstr", parameter.ToArray(), ref jqgridparam);
  5517. }
  5518. /// <summary>
  5519. /// 委外采购到货单检验
  5520. /// </summary>
  5521. /// <param name="jqgridparam"></param>
  5522. /// <param name="queryJson"></param>
  5523. /// <returns></returns>
  5524. public DataTable GetICSInspection10(ref Pagination jqgridparam, string queryJson)
  5525. {
  5526. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  5527. DataTable dt = new DataTable();
  5528. var queryParam = queryJson.ToJObject();
  5529. List<DbParameter> parameter = new List<DbParameter>();
  5530. string sql = @"
  5531. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_10'))
  5532. drop table #TempMOData_10
  5533. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_10_1'))
  5534. drop table #TempMOData_10_1
  5535. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_10'))
  5536. drop table #TempIcsinsp_10
  5537. select ID,QualifiedQuantity,UnqualifiedQuantity,WaiveQuantity,
  5538. SampleQuantity,MUSERName,MTIME,Result,LotNo,BCCode,workpoint,BRCode,InvCode
  5539. into #TempIcsinsp_10
  5540. from dbo.ICSInspection
  5541. where workpoint='" + WorkPoint + @"' and Enable='1'
  5542. select DISTINCT a.ID as GDID, e.ID , a.MOCode as DNCode, a.Sequence , h.ID as JYID, pick.InvCode, c.InvName , c.INVSTD , c.ClassName,c.InvDesc,
  5543. 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,
  5544. CAST(ISNULL(h.QualifiedQuantity,e.Quantity)as NUMERIC(10,4))as YLOTQTY ,
  5545. CAST(ISNULL(h.UnqualifiedQuantity, 0) as NUMERIC(10,4)) as NLOTQTY,
  5546. CAST(ISNULL(h.WaiveQuantity, 0) as NUMERIC(10,4)) as SpecialQTY,
  5547. CASE WHEN isnull(h.ID,'') ='' THEN isnull(p.SampleQuantity,0) ELSE CAST(ISNULL(h.SampleQuantity, 0) as decimal(18,4)) END AS SampleQuantity ,
  5548. c.InvUnit , e.LotNo , g.BadReasonDesc as BadReasonDesc ,
  5549. g.BadReasonCode as BRCodeValue,j.BadCode as BCCodeValue, j.BadDesc as BadDesc, i.ContainerID,
  5550. isnull(h.MUSERName,'') MUSERName, CONVERT(VARCHAR(100),e.ProductDate,120) as ProductTime,CONVERT(VARCHAR(100),h.MTIME,120) as MTIME,
  5551. CASE WHEN isnull(h.ID,'') =''THEN '' ELSE '' END AS TestState,
  5552. isnull(h.MUSERName,'') as Surveyor, h.mtime as ProvingTime
  5553. ,CASE WHEN h.Result='0' THEN '' when ISNULL(h.Result,'')='' THEN '' ELSE '' END AS Result,
  5554. c.EATTRIBUTE3 as InvEATTRIBUTE3,n.FileName,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  5555. a.EATTRIBUTE9,a.EATTRIBUTE10,c.InvIQC
  5556. into #TempMOData_10
  5557. from ICSMO a
  5558. inner JOIN dbo.ICSInventory c ON a.InvCode = c.InvCode AND a.WorkPoint=c.WorkPoint --and c.InvIQC='1'
  5559. LEFT JOIN ICSMOPick pick ON a.MODetailID=pick.MODetailID AND a.WorkPoint=pick.WorkPoint AND pick.EATTRIBUTE1='1'
  5560. left join ICSInventoryLotDetail b on a.MOCode=b.TransCode and a.Sequence+'~'+ pick.Sequence=b.TransSequence and a.WorkPoint=b.WorkPoint
  5561. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  5562. LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo=b.LotNo AND e.WorkPoint=b.WorkPoint
  5563. LEFT JOIN #TempIcsinsp_10 h ON h.LotNO=e.LotNO and h.InvCode=e.InvCode and h.WorkPoint=e.WorkPoint --and Enable='1'
  5564. left join ICSBadReason g on h.BRCode =g.BadReasonCode and h.WorkPoint=g.WorkPoint
  5565. left join ICSBadCode j on h.BCCode =j.BadCode and h.WorkPoint=j.WorkPoint
  5566. LEFT JOIN dbo.ICSContainerLot i ON e.LotNO=i.LotNO AND e.WorkPoint=i.WorkPoint
  5567. left join ICSInspectionFile n on h.id=n.InspectionID and h.WorkPoint=n.WorkPoint
  5568. LEFT JOIN ICSInventoryInspectionRulesGroup o ON a.InvCode=o.InvCode AND a.WorkPoint=o.WorkPoint
  5569. LEFT JOIN ICSInventoryInspectionRuleslist p ON o.id=p.invrulesid AND o.WorkPoint=p.WorkPoint AND e.Quantity BETWEEN p.SetValueMax AND p.SetValueMin
  5570. where a.MOStatus<>'3' and e.LotNO is not null {0} and a.workpoint='{1}'
  5571. select * into #TempMOData_10_1 from #TempMOData_10 where InvIQC='1' ";
  5572. string wheresql = "";
  5573. if (!string.IsNullOrWhiteSpace(queryJson))
  5574. {
  5575. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  5576. {
  5577. wheresql += " and a.MOCode like '%" + queryParam["POCode"].ToString() + "%' ";
  5578. }
  5579. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  5580. {
  5581. wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  5582. }
  5583. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  5584. {
  5585. wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  5586. }
  5587. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  5588. {
  5589. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  5590. }
  5591. if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
  5592. {
  5593. wheresql += " and e.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
  5594. }
  5595. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  5596. {
  5597. string ReleaseState = queryParam["ReleaseState"].ToString();
  5598. if (ReleaseState == "1")
  5599. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
  5600. else if (ReleaseState == "0")
  5601. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
  5602. else
  5603. wheresql += " ";
  5604. }
  5605. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  5606. {
  5607. string selEnableShow = queryParam["selEnableShow"].ToString();
  5608. if (selEnableShow == "1")
  5609. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
  5610. else if (selEnableShow == "0")
  5611. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
  5612. }
  5613. }
  5614. sql = string.Format(sql, wheresql, WorkPoint);
  5615. // return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  5616. return Repository().FindTablePageBySql_OtherTemp(sql, "#TempMOData_10_1",
  5617. @" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_10'))
  5618. drop table #TempMOData_10
  5619. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_10_1'))
  5620. drop table #TempMOData_10_1
  5621. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_10'))
  5622. drop table #TempIcsinsp_10 ",
  5623. "connstr", parameter.ToArray(), ref jqgridparam);
  5624. }
  5625. /// <summary>
  5626. /// 委外采购到货单检验(批次维度)
  5627. /// </summary>
  5628. /// <param name="jqgridparam"></param>
  5629. /// <param name="queryJson"></param>
  5630. /// <returns></returns>
  5631. public DataTable GetICSInspection10BatchCode(ref Pagination jqgridparam, string queryJson)
  5632. {
  5633. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  5634. DataTable dt = new DataTable();
  5635. var queryParam = queryJson.ToJObject();
  5636. List<DbParameter> parameter = new List<DbParameter>();
  5637. string sql = @"
  5638. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_10'))
  5639. drop table #TempMOData_10
  5640. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_10_1'))
  5641. drop table #TempMOData_10_1
  5642. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_10'))
  5643. drop table #TempIcsinsp_10
  5644. select ID,QualifiedQuantity,UnqualifiedQuantity,WaiveQuantity,
  5645. SampleQuantity,MUSERName,MTIME,Result,LotNo,BCCode,workpoint,BRCode,InvCode
  5646. into #TempIcsinsp_10
  5647. from dbo.ICSInspection
  5648. where workpoint='" + WorkPoint + @"' and Enable='1'
  5649. select DISTINCT a.ID as GDID, a.MOCode as DNCode, a.Sequence , pick.InvCode, c.InvName , c.INVSTD , c.ClassName,c.InvDesc,
  5650. 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, sum(e.Quantity) as AllNumber,
  5651. CAST(ISNULL(sum(h.QualifiedQuantity),sum(e.Quantity))as NUMERIC(10,4))as YLOTQTY ,
  5652. CAST(ISNULL(sum(h.UnqualifiedQuantity), 0) as NUMERIC(10,4)) as NLOTQTY,
  5653. CAST(ISNULL(Sum(h.WaiveQuantity), 0) as NUMERIC(10,4)) as SpecialQTY,
  5654. CAST(ISNULL(sum(h.SampleQuantity), 0) as NUMERIC(10,4)) as SampleQuantity,
  5655. c.InvUnit ,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8, a.EATTRIBUTE9,a.EATTRIBUTE10,c.InvIQC
  5656. into #TempMOData_10
  5657. from ICSMO a
  5658. inner JOIN dbo.ICSInventory c ON a.InvCode = c.InvCode AND a.WorkPoint=c.WorkPoint --and c.InvIQC='1'
  5659. LEFT JOIN ICSMOPick pick ON a.MODetailID=pick.MODetailID AND a.WorkPoint=pick.WorkPoint AND pick.EATTRIBUTE1='1'
  5660. left join ICSInventoryLotDetail b on a.MOCode=b.TransCode and a.Sequence+'~'+ pick.Sequence=b.TransSequence and a.WorkPoint=b.WorkPoint
  5661. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  5662. LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo=b.LotNo AND e.WorkPoint=b.WorkPoint
  5663. LEFT JOIN #TempIcsinsp_10 h ON h.LotNO=e.LotNO and h.InvCode=e.InvCode and h.WorkPoint=e.WorkPoint --and Enable='1'
  5664. where a.MOStatus<>'3' and e.LotNO is not null {0} and a.workpoint='{1}'
  5665. ";
  5666. string wheresql = "";
  5667. if (!string.IsNullOrWhiteSpace(queryJson))
  5668. {
  5669. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  5670. {
  5671. wheresql += " and a.MOCode like '%" + queryParam["POCode"].ToString() + "%' ";
  5672. }
  5673. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  5674. {
  5675. wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  5676. }
  5677. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  5678. {
  5679. wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  5680. }
  5681. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  5682. {
  5683. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  5684. }
  5685. if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
  5686. {
  5687. wheresql += " and e.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
  5688. }
  5689. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  5690. {
  5691. string ReleaseState = queryParam["ReleaseState"].ToString();
  5692. if (ReleaseState == "1")
  5693. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
  5694. else if (ReleaseState == "0")
  5695. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
  5696. else
  5697. wheresql += " ";
  5698. }
  5699. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  5700. {
  5701. string selEnableShow = queryParam["selEnableShow"].ToString();
  5702. if (selEnableShow == "1")
  5703. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
  5704. else if (selEnableShow == "0")
  5705. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
  5706. }
  5707. }
  5708. sql += @" GROUP BY a.ID , a.MOCode, a.Sequence , pick.InvCode, c.InvName , c.INVSTD , c.ClassName,c.InvDesc,
  5709. 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,c.InvUnit ,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8, a.EATTRIBUTE9,a.EATTRIBUTE10,c.InvIQC;select * into #TempMOData_10_1 from #TempMOData_10 where InvIQC='1'";
  5710. sql = string.Format(sql, wheresql, WorkPoint);
  5711. // return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  5712. return Repository().FindTablePageBySql_OtherTemp(sql, "#TempMOData_10_1",
  5713. @" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_10'))
  5714. drop table #TempMOData_10
  5715. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_10_1'))
  5716. drop table #TempMOData_10_1
  5717. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_10'))
  5718. drop table #TempIcsinsp_10 ",
  5719. "connstr", parameter.ToArray(), ref jqgridparam);
  5720. }
  5721. /// <summary>
  5722. /// 委外采购到货单检验(单据行维度)
  5723. /// </summary>
  5724. /// <param name="jqgridparam"></param>
  5725. /// <param name="queryJson"></param>
  5726. /// <returns></returns>
  5727. public DataTable GetICSInspection10DocSequence(ref Pagination jqgridparam, string queryJson)
  5728. {
  5729. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  5730. DataTable dt = new DataTable();
  5731. var queryParam = queryJson.ToJObject();
  5732. List<DbParameter> parameter = new List<DbParameter>();
  5733. string sql = @"
  5734. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_10'))
  5735. drop table #TempMOData_10
  5736. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_10_1'))
  5737. drop table #TempMOData_10_1
  5738. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_10'))
  5739. drop table #TempIcsinsp_10
  5740. select ID,QualifiedQuantity,UnqualifiedQuantity,WaiveQuantity,
  5741. SampleQuantity,MUSERName,MTIME,Result,LotNo,BCCode,workpoint,BRCode,InvCode
  5742. into #TempIcsinsp_10
  5743. from dbo.ICSInspection
  5744. where workpoint='" + WorkPoint + @"' and Enable='1'
  5745. select DISTINCT a.ID as GDID, a.MOCode as DNCode, a.Sequence , pick.InvCode, c.InvName , c.INVSTD , c.ClassName,c.InvDesc,
  5746. sum(e.Quantity) as AllNumber,
  5747. CAST(ISNULL(sum(h.QualifiedQuantity),sum(e.Quantity))as NUMERIC(10,4))as YLOTQTY ,
  5748. CAST(ISNULL(sum(h.UnqualifiedQuantity), 0) as NUMERIC(10,4)) as NLOTQTY,
  5749. CAST(ISNULL(Sum(h.WaiveQuantity), 0) as NUMERIC(10,4)) as SpecialQTY,
  5750. CAST(ISNULL(sum(h.SampleQuantity), 0) as NUMERIC(10,4)) as SampleQuantity,
  5751. c.InvUnit ,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8, a.EATTRIBUTE9,a.EATTRIBUTE10,c.InvIQC
  5752. into #TempMOData_10
  5753. from ICSMO a
  5754. inner JOIN dbo.ICSInventory c ON a.InvCode = c.InvCode AND a.WorkPoint=c.WorkPoint --and c.InvIQC='1'
  5755. LEFT JOIN ICSMOPick pick ON a.MODetailID=pick.MODetailID AND a.WorkPoint=pick.WorkPoint AND pick.EATTRIBUTE1='1'
  5756. left join ICSInventoryLotDetail b on a.MOCode=b.TransCode and a.Sequence+'~'+ pick.Sequence=b.TransSequence and a.WorkPoint=b.WorkPoint
  5757. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  5758. LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo=b.LotNo AND e.WorkPoint=b.WorkPoint
  5759. LEFT JOIN #TempIcsinsp_10 h ON h.LotNO=e.LotNO and h.InvCode=e.InvCode and h.WorkPoint=e.WorkPoint --and Enable='1'
  5760. where a.MOStatus<>'3' and e.LotNO is not null {0} and a.workpoint='{1}'
  5761. ";
  5762. string wheresql = "";
  5763. if (!string.IsNullOrWhiteSpace(queryJson))
  5764. {
  5765. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  5766. {
  5767. wheresql += " and a.MOCode like '%" + queryParam["POCode"].ToString() + "%' ";
  5768. }
  5769. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  5770. {
  5771. wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  5772. }
  5773. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  5774. {
  5775. wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  5776. }
  5777. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  5778. {
  5779. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  5780. }
  5781. if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
  5782. {
  5783. wheresql += " and e.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
  5784. }
  5785. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  5786. {
  5787. string ReleaseState = queryParam["ReleaseState"].ToString();
  5788. if (ReleaseState == "1")
  5789. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
  5790. else if (ReleaseState == "0")
  5791. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
  5792. else
  5793. wheresql += " ";
  5794. }
  5795. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  5796. {
  5797. string selEnableShow = queryParam["selEnableShow"].ToString();
  5798. if (selEnableShow == "1")
  5799. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
  5800. else if (selEnableShow == "0")
  5801. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
  5802. }
  5803. }
  5804. sql += @" GROUP BY a.ID , a.MOCode, a.Sequence , pick.InvCode, c.InvName , c.INVSTD , c.ClassName,c.InvDesc,
  5805. c.InvUnit ,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8, a.EATTRIBUTE9,a.EATTRIBUTE10,c.InvIQC ;select * into #TempMOData_10_1 from #TempMOData_10 where InvIQC='1'";
  5806. sql = string.Format(sql, wheresql, WorkPoint);
  5807. // return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  5808. return Repository().FindTablePageBySql_OtherTemp(sql, "#TempMOData_10_1",
  5809. @" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_10'))
  5810. drop table #TempMOData_10
  5811. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_10_1'))
  5812. drop table #TempMOData_10_1
  5813. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_10'))
  5814. drop table #TempIcsinsp_10 ",
  5815. "connstr", parameter.ToArray(), ref jqgridparam);
  5816. }
  5817. /// <summary>
  5818. /// 委外采购到货单检验(单据维度)
  5819. /// </summary>
  5820. /// <param name="jqgridparam"></param>
  5821. /// <param name="queryJson"></param>
  5822. /// <returns></returns>
  5823. public DataTable GetICSInspection10Doc(ref Pagination jqgridparam, string queryJson)
  5824. {
  5825. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  5826. DataTable dt = new DataTable();
  5827. var queryParam = queryJson.ToJObject();
  5828. List<DbParameter> parameter = new List<DbParameter>();
  5829. string sql = @"
  5830. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_10'))
  5831. drop table #TempMOData_10
  5832. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_10_1'))
  5833. drop table #TempMOData_10_1
  5834. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_10'))
  5835. drop table #TempIcsinsp_10
  5836. select ID,QualifiedQuantity,UnqualifiedQuantity,WaiveQuantity,
  5837. SampleQuantity,MUSERName,MTIME,Result,LotNo,BCCode,workpoint,BRCode,InvCode
  5838. into #TempIcsinsp_10
  5839. from dbo.ICSInspection
  5840. where workpoint='" + WorkPoint + @"' and Enable='1'
  5841. select DISTINCT a.MOCode as DNCode,
  5842. sum(e.Quantity) as AllNumber,
  5843. CAST(ISNULL(sum(h.QualifiedQuantity),sum(e.Quantity))as NUMERIC(10,4))as YLOTQTY ,
  5844. CAST(ISNULL(sum(h.UnqualifiedQuantity), 0) as NUMERIC(10,4)) as NLOTQTY,
  5845. CAST(ISNULL(Sum(h.WaiveQuantity), 0) as NUMERIC(10,4)) as SpecialQTY,
  5846. CAST(ISNULL(sum(h.SampleQuantity), 0) as NUMERIC(10,4)) as SampleQuantity
  5847. into #TempMOData_10
  5848. from ICSMO a
  5849. inner JOIN dbo.ICSInventory c ON a.InvCode = c.InvCode AND a.WorkPoint=c.WorkPoint --and c.InvIQC='1'
  5850. LEFT JOIN ICSMOPick pick ON a.MODetailID=pick.MODetailID AND a.WorkPoint=pick.WorkPoint AND pick.EATTRIBUTE1='1'
  5851. left join ICSInventoryLotDetail b on a.MOCode=b.TransCode and a.Sequence+'~'+ pick.Sequence=b.TransSequence and a.WorkPoint=b.WorkPoint
  5852. left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
  5853. LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo=b.LotNo AND e.WorkPoint=b.WorkPoint
  5854. LEFT JOIN #TempIcsinsp_10 h ON h.LotNO=e.LotNO and h.InvCode=e.InvCode and h.WorkPoint=e.WorkPoint --and Enable='1'
  5855. where a.MOStatus<>'3' and e.LotNO is not null {0} and a.workpoint='{1}'
  5856. ";
  5857. string wheresql = "";
  5858. if (!string.IsNullOrWhiteSpace(queryJson))
  5859. {
  5860. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  5861. {
  5862. wheresql += " and a.MOCode like '%" + queryParam["POCode"].ToString() + "%' ";
  5863. }
  5864. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  5865. {
  5866. wheresql += " and c.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  5867. }
  5868. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  5869. {
  5870. wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  5871. }
  5872. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  5873. {
  5874. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  5875. }
  5876. if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
  5877. {
  5878. wheresql += " and e.LotNO like '%" + queryParam["LotNO"].ToString() + "%' ";
  5879. }
  5880. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  5881. {
  5882. string ReleaseState = queryParam["ReleaseState"].ToString();
  5883. if (ReleaseState == "1")
  5884. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='已检验'";
  5885. else if (ReleaseState == "0")
  5886. wheresql += " and CASE WHEN isnull(h.ID,'') =''THEN '未检验' ELSE '已检验' END='未检验'";
  5887. else
  5888. wheresql += " ";
  5889. }
  5890. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  5891. {
  5892. string selEnableShow = queryParam["selEnableShow"].ToString();
  5893. if (selEnableShow == "1")
  5894. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) <= 0";
  5895. else if (selEnableShow == "0")
  5896. wheresql += " and ISNULL(h.UnqualifiedQuantity, 0) > 0";
  5897. }
  5898. }
  5899. sql += @" GROUP BY a.MOCode ;select * into #TempMOData_10_1 from #TempMOData_10 where InvIQC='1'";
  5900. sql = string.Format(sql, wheresql, WorkPoint);
  5901. // return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  5902. return Repository().FindTablePageBySql_OtherTemp(sql, "#TempMOData_10_1",
  5903. @" if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_10'))
  5904. drop table #TempMOData_10
  5905. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempMOData_10_1'))
  5906. drop table #TempMOData_10_1
  5907. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempIcsinsp_10'))
  5908. drop table #TempIcsinsp_10 ",
  5909. "connstr", parameter.ToArray(), ref jqgridparam);
  5910. }
  5911. //在库检验
  5912. public DataTable GetICSInspection11(ref Pagination jqgridparam, string queryJson)
  5913. {
  5914. try
  5915. {
  5916. string DataActionsql = DataActionSqlGet();
  5917. DataTable dt = new DataTable();
  5918. var queryParam = queryJson.ToJObject();
  5919. List<DbParameter> parameter = new List<DbParameter>();
  5920. string sql = @" select DISTINCT a.ID as GDID, e.ID AS LotID , a.InspectCode as DNCode, d.Sequence , d.ID as ID, e.InvCode, c.InvName , c.INVSTD , c.ClassName,c.InvDesc,
  5921. 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, g.Quantity-ISNULL(g.LockQuantity,0) as AllNumber,
  5922. Case When d.EATTRIBUTE1='' Then 0 Else d.InspectQuantity END as YLOTQTY ,
  5923. Case When d.EATTRIBUTE1='' Then 0 Else Convert(decimal(18,4),d.Quantity)-Convert(decimal(18,4),d.InspectQuantity) END as NLOTQTY,
  5924. Case When a.Type=0 Then '' ELSE '' END AS DocType,
  5925. c.InvUnit , d.LotNo ,i.ContainerID,CONVERT(varchar(100), e.ExpirationDate, 23) AS ExpirationDate,
  5926. isnull(a.MUSERName,'') MUSERName, CONVERT(VARCHAR(100),e.ProductDate,120) as ProductTime,CONVERT(VARCHAR(100),a.MTIME,120) as MTIME,
  5927. d.EATTRIBUTE1 AS TestState,c.EATTRIBUTE3 as InvEATTRIBUTE3,
  5928. isnull(d.MUSERName,'') as Surveyor, d.MTIME as ProvingTime,
  5929. a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
  5930. a.EATTRIBUTE9,a.EATTRIBUTE10,K.BadReasonDesc as BadReasonDesc ,
  5931. K.BadReasonCode as BRCodeValue,L.BadCode as BCCodeValue, L.BadDesc as BadDesc
  5932. from ICSInspect a
  5933. inner join ICSInspectDetail d on d.InspectCode=a.InspectCode and d.WorkPoint=a.WorkPoint
  5934. LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo=d.LotNo AND e.WorkPoint=d.WorkPoint
  5935. LEFT JOIN dbo.ICSWareHouseLotInfo g ON g.LotNo=e.LotNo and g.WorkPoint=e.WorkPoint
  5936. inner JOIN dbo.ICSInventory c ON c.InvCode=e.InvCode AND c.WorkPoint=e.WorkPoint --and c.InvIQC='1'
  5937. left join ICSExtension f on f.ID=e.ExtensionID and f.WorkPoint=e.WorkPoint
  5938. LEFT JOIN dbo.ICSContainerLot i ON e.LotNO=i.LotNO AND e.WorkPoint=i.WorkPoint
  5939. LEFT JOIN DBO.ICSInspection J ON J.LotNo=D.LotNo AND J.EATTRIBUTE1=d.InspectCode AND J.WorkPoint=d.WorkPoint AND J.Enable=1
  5940. LEFT JOIN DBO.ICSBadReason K ON K.BadReasonCode=J.BRCode AND K.WorkPoint=J.WorkPoint
  5941. LEFT JOIN DBO.ICSBadCode L ON L.BadCode=J.BCCode AND L.WorkPoint=J.WorkPoint
  5942. where g.LotNO is not null {0} ";
  5943. string wheresql = "";
  5944. if (!string.IsNullOrWhiteSpace(queryJson))
  5945. {
  5946. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  5947. {
  5948. wheresql += " and a.InspectCode like '%" + queryParam["POCode"].ToString() + "%' ";
  5949. }
  5950. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  5951. {
  5952. wheresql += " and e.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  5953. }
  5954. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  5955. {
  5956. wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  5957. }
  5958. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  5959. {
  5960. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  5961. }
  5962. if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
  5963. {
  5964. wheresql += " and d.LotNo like '%" + queryParam["LotNO"].ToString() + "%' ";
  5965. }
  5966. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  5967. {
  5968. string ReleaseState = queryParam["ReleaseState"].ToString();
  5969. if (ReleaseState == "1")
  5970. wheresql += " and d.EATTRIBUTE1='已检验'";
  5971. else if (ReleaseState == "0")
  5972. wheresql += " and d.EATTRIBUTE1='未检验'";
  5973. else if (ReleaseState == "3")
  5974. wheresql += " and d.EATTRIBUTE1='已审核'";
  5975. else if (ReleaseState == "4")
  5976. wheresql += " and d.EATTRIBUTE1='已复审'";
  5977. else
  5978. wheresql += " ";
  5979. }
  5980. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  5981. {
  5982. string selEnableShow = queryParam["selEnableShow"].ToString();
  5983. if (selEnableShow == "1")
  5984. wheresql += " and Convert(decimal(18,4),ISNULL(d.InspectQuantity,0))=Convert(decimal(18,4),ISNULL(d.Quantity,0))";
  5985. else if (selEnableShow == "0")
  5986. wheresql += " and Convert(decimal(18,4),ISNULL(d.InspectQuantity,0))!=Convert(decimal(18,4),ISNULL(d.Quantity,0))";
  5987. }
  5988. }
  5989. if (DataActionsql != "")
  5990. {
  5991. sql += DataActionsql;
  5992. }
  5993. sql = string.Format(sql, wheresql);
  5994. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  5995. }
  5996. catch (Exception ex)
  5997. {
  5998. throw new Exception(ex.Message);
  5999. }
  6000. }
  6001. /// <summary>
  6002. /// 在库检验(批次维度)
  6003. /// </summary>
  6004. /// <param name="jqgridparam"></param>
  6005. /// <param name="queryJson"></param>
  6006. /// <returns></returns>
  6007. /// <exception cref="Exception"></exception>
  6008. public DataTable GetICSInspection11BatchCode(ref Pagination jqgridparam, string queryJson)
  6009. {
  6010. try
  6011. {
  6012. string DataActionsql = DataActionSqlGet();
  6013. DataTable dt = new DataTable();
  6014. var queryParam = queryJson.ToJObject();
  6015. List<DbParameter> parameter = new List<DbParameter>();
  6016. string sql = @" select DISTINCT a.InspectCode as DNCode,
  6017. sum(g.Quantity)-ISNULL(sum(g.LockQuantity),0) as AllNumber,
  6018. Case When d.EATTRIBUTE1='' Then 0 Else sum(d.InspectQuantity) END as YLOTQTY ,
  6019. Case When d.EATTRIBUTE1='' Then 0 Else Convert(decimal(18,4),sum(d.Quantity))-Convert(decimal(18,4),sum(d.InspectQuantity)) END as NLOTQTY,
  6020. Case When a.Type=0 Then '' ELSE '' END AS DocType,
  6021. isnull(a.MUSERName,'') MUSERName, CONVERT(VARCHAR(100),a.MTIME,120) as MTIME,
  6022. a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,a.EATTRIBUTE9,a.EATTRIBUTE10
  6023. from ICSInspect a
  6024. inner join ICSInspectDetail d on d.InspectCode=a.InspectCode and d.WorkPoint=a.WorkPoint
  6025. LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo=d.LotNo AND e.WorkPoint=d.WorkPoint
  6026. LEFT JOIN dbo.ICSWareHouseLotInfo g ON g.LotNo=e.LotNo and g.WorkPoint=e.WorkPoint
  6027. inner JOIN dbo.ICSInventory c ON c.InvCode=e.InvCode AND c.WorkPoint=e.WorkPoint --and c.InvIQC='1'
  6028. left join ICSExtension f on f.ID=e.ExtensionID and f.WorkPoint=e.WorkPoint
  6029. where g.LotNO is not null {0} ";
  6030. string wheresql = "";
  6031. if (!string.IsNullOrWhiteSpace(queryJson))
  6032. {
  6033. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  6034. {
  6035. wheresql += " and a.InspectCode like '%" + queryParam["POCode"].ToString() + "%' ";
  6036. }
  6037. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  6038. {
  6039. wheresql += " and e.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  6040. }
  6041. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  6042. {
  6043. wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  6044. }
  6045. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  6046. {
  6047. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  6048. }
  6049. if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
  6050. {
  6051. wheresql += " and d.LotNo like '%" + queryParam["LotNO"].ToString() + "%' ";
  6052. }
  6053. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  6054. {
  6055. string ReleaseState = queryParam["ReleaseState"].ToString();
  6056. if (ReleaseState == "1")
  6057. wheresql += " and d.EATTRIBUTE1='已检验'";
  6058. else if (ReleaseState == "0")
  6059. wheresql += " and d.EATTRIBUTE1='未检验'";
  6060. else if (ReleaseState == "3")
  6061. wheresql += " and d.EATTRIBUTE1='已审核'";
  6062. else if (ReleaseState == "4")
  6063. wheresql += " and d.EATTRIBUTE1='已复审'";
  6064. else
  6065. wheresql += " ";
  6066. }
  6067. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  6068. {
  6069. string selEnableShow = queryParam["selEnableShow"].ToString();
  6070. if (selEnableShow == "1")
  6071. wheresql += " and Convert(decimal(18,4),ISNULL(d.InspectQuantity,0))=Convert(decimal(18,4),ISNULL(d.Quantity,0))";
  6072. else if (selEnableShow == "0")
  6073. wheresql += " and Convert(decimal(18,4),ISNULL(d.InspectQuantity,0))!=Convert(decimal(18,4),ISNULL(d.Quantity,0))";
  6074. }
  6075. }
  6076. if (DataActionsql != "")
  6077. {
  6078. sql += DataActionsql;
  6079. }
  6080. sql += @" GROUP BY a.InspectCode ,a.MUSERName, a.MTIME,d.EATTRIBUTE1 , a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,a.EATTRIBUTE9,a.EATTRIBUTE10,a.Type";
  6081. sql = string.Format(sql, wheresql);
  6082. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  6083. }
  6084. catch (Exception ex)
  6085. {
  6086. throw new Exception(ex.Message);
  6087. }
  6088. }
  6089. /// <summary>
  6090. /// 在库检验(单据行维度)
  6091. /// </summary>
  6092. /// <param name="jqgridparam"></param>
  6093. /// <param name="queryJson"></param>
  6094. /// <returns></returns>
  6095. /// <exception cref="Exception"></exception>
  6096. public DataTable GetICSInspection11DocSequence(ref Pagination jqgridparam, string queryJson)
  6097. {
  6098. try
  6099. {
  6100. string DataActionsql = DataActionSqlGet();
  6101. DataTable dt = new DataTable();
  6102. var queryParam = queryJson.ToJObject();
  6103. List<DbParameter> parameter = new List<DbParameter>();
  6104. string sql = @" select DISTINCT a.ID as GDID, a.InspectCode as DNCode, d.Sequence , d.ID as ID, e.InvCode, c.InvName , c.INVSTD , c.ClassName,c.InvDesc,
  6105. sum(g.Quantity)-ISNULL(sum(g.LockQuantity),0) as AllNumber,
  6106. Case When d.EATTRIBUTE1='' Then 0 Else sum(d.InspectQuantity) END as YLOTQTY ,
  6107. Case When d.EATTRIBUTE1='' Then 0 Else Convert(decimal(18,4),sum(d.Quantity))-Convert(decimal(18,4),sum(d.InspectQuantity)) END as NLOTQTY,
  6108. Case When a.Type=0 Then '' ELSE '' END AS DocType,
  6109. c.InvUnit ,
  6110. isnull(a.MUSERName,'') MUSERName, CONVERT(VARCHAR(100),a.MTIME,120) as MTIME,
  6111. d.EATTRIBUTE1 AS TestState,
  6112. isnull(d.MUSERName,'') as Surveyor, d.MTIME as ProvingTime,
  6113. a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,a.EATTRIBUTE9,a.EATTRIBUTE10
  6114. from ICSInspect a
  6115. inner join ICSInspectDetail d on d.InspectCode=a.InspectCode and d.WorkPoint=a.WorkPoint
  6116. LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo=d.LotNo AND e.WorkPoint=d.WorkPoint
  6117. LEFT JOIN dbo.ICSWareHouseLotInfo g ON g.LotNo=e.LotNo and g.WorkPoint=e.WorkPoint
  6118. inner JOIN dbo.ICSInventory c ON c.InvCode=e.InvCode AND c.WorkPoint=e.WorkPoint --and c.InvIQC='1'
  6119. left join ICSExtension f on f.ID=e.ExtensionID and f.WorkPoint=e.WorkPoint
  6120. where g.LotNO is not null {0} ";
  6121. string wheresql = "";
  6122. if (!string.IsNullOrWhiteSpace(queryJson))
  6123. {
  6124. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  6125. {
  6126. wheresql += " and a.InspectCode like '%" + queryParam["POCode"].ToString() + "%' ";
  6127. }
  6128. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  6129. {
  6130. wheresql += " and e.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  6131. }
  6132. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  6133. {
  6134. wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  6135. }
  6136. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  6137. {
  6138. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  6139. }
  6140. if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
  6141. {
  6142. wheresql += " and d.LotNo like '%" + queryParam["LotNO"].ToString() + "%' ";
  6143. }
  6144. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  6145. {
  6146. string ReleaseState = queryParam["ReleaseState"].ToString();
  6147. if (ReleaseState == "1")
  6148. wheresql += " and d.EATTRIBUTE1='已检验'";
  6149. else if (ReleaseState == "0")
  6150. wheresql += " and d.EATTRIBUTE1='未检验'";
  6151. else if (ReleaseState == "3")
  6152. wheresql += " and d.EATTRIBUTE1='已审核'";
  6153. else if (ReleaseState == "4")
  6154. wheresql += " and d.EATTRIBUTE1='已复审'";
  6155. else
  6156. wheresql += " ";
  6157. }
  6158. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  6159. {
  6160. string selEnableShow = queryParam["selEnableShow"].ToString();
  6161. if (selEnableShow == "1")
  6162. wheresql += " and Convert(decimal(18,4),ISNULL(d.InspectQuantity,0))=Convert(decimal(18,4),ISNULL(d.Quantity,0))";
  6163. else if (selEnableShow == "0")
  6164. wheresql += " and Convert(decimal(18,4),ISNULL(d.InspectQuantity,0))!=Convert(decimal(18,4),ISNULL(d.Quantity,0))";
  6165. }
  6166. }
  6167. if (DataActionsql != "")
  6168. {
  6169. sql += DataActionsql;
  6170. }
  6171. sql += @" GROUP BY a.ID , a.InspectCode , d.Sequence , d.ID , e.InvCode, c.InvName , c.INVSTD , c.ClassName,c.InvDesc,
  6172. c.InvUnit ,a.MUSERName, a.MTIME,d.EATTRIBUTE1 ,d.MUSERName, d.MTIME ,
  6173. a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,a.EATTRIBUTE9,a.EATTRIBUTE10,a.Type";
  6174. sql = string.Format(sql, wheresql);
  6175. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  6176. }
  6177. catch (Exception ex)
  6178. {
  6179. throw new Exception(ex.Message);
  6180. }
  6181. }
  6182. /// <summary>
  6183. /// 在库检验(单据维度)
  6184. /// </summary>
  6185. /// <param name="jqgridparam"></param>
  6186. /// <param name="queryJson"></param>
  6187. /// <returns></returns>
  6188. /// <exception cref="Exception"></exception>
  6189. public DataTable GetICSInspection11Doc(ref Pagination jqgridparam, string queryJson)
  6190. {
  6191. try
  6192. {
  6193. string DataActionsql = DataActionSqlGet();
  6194. DataTable dt = new DataTable();
  6195. var queryParam = queryJson.ToJObject();
  6196. List<DbParameter> parameter = new List<DbParameter>();
  6197. string sql = @" select DISTINCT a.ID as GDID, a.InspectCode as DNCode, d.Sequence , d.ID as ID, e.InvCode, c.InvName , c.INVSTD , c.ClassName,c.InvDesc,
  6198. sum(g.Quantity)-ISNULL(sum(g.LockQuantity),0) as AllNumber,
  6199. Case When d.EATTRIBUTE1='' Then 0 Else sum(d.InspectQuantity) END as YLOTQTY ,
  6200. Case When d.EATTRIBUTE1='' Then 0 Else Convert(decimal(18,4),sum(d.Quantity))-Convert(decimal(18,4),sum(d.InspectQuantity)) END as NLOTQTY,
  6201. Case When a.Type=0 Then '' ELSE '' END AS DocType,
  6202. c.InvUnit , d.LotNo ,
  6203. isnull(a.MUSERName,'') MUSERName, CONVERT(VARCHAR(100),a.MTIME,120) as MTIME,
  6204. d.EATTRIBUTE1 AS TestState,
  6205. isnull(d.MUSERName,'') as Surveyor, d.MTIME as ProvingTime,
  6206. a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,a.EATTRIBUTE9,a.EATTRIBUTE10
  6207. from ICSInspect a
  6208. inner join ICSInspectDetail d on d.InspectCode=a.InspectCode and d.WorkPoint=a.WorkPoint
  6209. LEFT JOIN dbo.ICSInventoryLot e ON e.LotNo=d.LotNo AND e.WorkPoint=d.WorkPoint
  6210. LEFT JOIN dbo.ICSWareHouseLotInfo g ON g.LotNo=e.LotNo and g.WorkPoint=e.WorkPoint
  6211. inner JOIN dbo.ICSInventory c ON c.InvCode=e.InvCode AND c.WorkPoint=e.WorkPoint --and c.InvIQC='1'
  6212. left join ICSExtension f on f.ID=e.ExtensionID and f.WorkPoint=e.WorkPoint
  6213. where g.LotNO is not null {0} ";
  6214. string wheresql = "";
  6215. if (!string.IsNullOrWhiteSpace(queryJson))
  6216. {
  6217. if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
  6218. {
  6219. wheresql += " and a.InspectCode like '%" + queryParam["POCode"].ToString() + "%' ";
  6220. }
  6221. if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
  6222. {
  6223. wheresql += " and e.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
  6224. }
  6225. if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
  6226. {
  6227. wheresql += " and c.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
  6228. }
  6229. if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
  6230. {
  6231. wheresql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
  6232. }
  6233. if (!string.IsNullOrWhiteSpace(queryParam["LotNO"].ToString()))
  6234. {
  6235. wheresql += " and d.LotNo like '%" + queryParam["LotNO"].ToString() + "%' ";
  6236. }
  6237. if (!string.IsNullOrWhiteSpace(queryParam["ReleaseState"].ToString()))
  6238. {
  6239. string ReleaseState = queryParam["ReleaseState"].ToString();
  6240. if (ReleaseState == "1")
  6241. wheresql += " and d.EATTRIBUTE1='已检验'";
  6242. else if (ReleaseState == "0")
  6243. wheresql += " and d.EATTRIBUTE1='未检验'";
  6244. else if (ReleaseState == "3")
  6245. wheresql += " and d.EATTRIBUTE1='已审核'";
  6246. else if (ReleaseState == "4")
  6247. wheresql += " and d.EATTRIBUTE1='已复审'";
  6248. else
  6249. wheresql += " ";
  6250. }
  6251. if (!string.IsNullOrWhiteSpace(queryParam["selEnableShow"].ToString()))
  6252. {
  6253. string selEnableShow = queryParam["selEnableShow"].ToString();
  6254. if (selEnableShow == "1")
  6255. wheresql += " and Convert(decimal(18,4),ISNULL(d.InspectQuantity,0))=Convert(decimal(18,4),ISNULL(d.Quantity,0))";
  6256. else if (selEnableShow == "0")
  6257. wheresql += " and Convert(decimal(18,4),ISNULL(d.InspectQuantity,0))!=Convert(decimal(18,4),ISNULL(d.Quantity,0))";
  6258. }
  6259. }
  6260. if (DataActionsql != "")
  6261. {
  6262. sql += DataActionsql;
  6263. }
  6264. sql += @" GROUP BY a.ID , a.InspectCode , d.Sequence , d.ID , e.InvCode, c.InvName , c.INVSTD , c.ClassName,c.InvDesc,
  6265. c.InvUnit , d.LotNo ,a.MUSERName, a.MTIME,d.EATTRIBUTE1 ,d.MUSERName, d.MTIME ,
  6266. a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,a.EATTRIBUTE9,a.EATTRIBUTE10,a.Type";
  6267. sql = string.Format(sql, wheresql);
  6268. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  6269. }
  6270. catch (Exception ex)
  6271. {
  6272. throw new Exception(ex.Message);
  6273. }
  6274. }
  6275. public DataTable GetInventoryInspectionNew(ref Pagination jqgridparam, string InvCode, int SampleQuantity, string ResultINp, string JYID)
  6276. {
  6277. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  6278. DataTable dt = new DataTable();
  6279. List<DbParameter> parameter = new List<DbParameter>();
  6280. string sql = string.Empty;
  6281. if (ResultINp == "")
  6282. {
  6283. sql += @" select DISTINCT b.ID,a.GroupCode,a.GroupName,d.ID as InspectionID,b.ListCode, b.ListName,b.Unit,b.SetValueMax,b.SetValueMin,d.SetValue,CASE WHEN c.Result='0' THEN '不合格' when ISNULL(c.Result,'')='' THEN '' ELSE '合格' END AS Result
  6284. from ICSInventoryInspectionGroup a
  6285. inner join ICSInventoryInspectionList b on a.ID=b.InvGroupID and a.WorkPoint=b.WorkPoint
  6286. left join ICSInspectionDetailGroup c on b.ListCode=c.ListCode and a.GroupCode=c.GroupCode and b.WorkPoint=c.WorkPoint and c.InspectionID='{2}'
  6287. left JOIN ICSInspectionDetail d ON c.InspectionID=d.ID AND c.WorkPoint=d.WorkPoint
  6288. where a.InvCode='{0}' and b.Enable='1' and a.WorkPoint='{1}'
  6289. ";
  6290. sql = string.Format(sql, InvCode, WorkPoint, JYID);
  6291. return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
  6292. }
  6293. else
  6294. {
  6295. sql += @" declare @sql varchar(8000)
  6296. select b.ID,a.GroupCode,a.GroupName,c.InspectionID,b.ListCode, b.ListName,b.Unit,b.SetValueMax,b.SetValueMin,d.SetValue,CASE WHEN c.Result='0' THEN '' when ISNULL(c.Result,'')='' THEN '' ELSE '' END AS Result,d.Sequence
  6297. into #TempSORRFQ
  6298. from ICSInventoryInspectionGroup a
  6299. inner join ICSInventoryInspectionList b on a.ID=b.InvGroupID and a.WorkPoint=b.WorkPoint
  6300. left join ICSInspectionDetailGroup c on b.ListCode=c.ListCode and a.GroupCode=c.GroupCode and b.WorkPoint=c.WorkPoint
  6301. left JOIN ICSInspectionDetail d ON c.ID=d.DetailGroupID AND c.WorkPoint=d.WorkPoint
  6302. where a.InvCode='{0}' and b.Enable='1' and a.WorkPoint='{1}'and c.InspectionID='{2}'
  6303. select @sql=isnull(@sql+',','')+' ['+Sequence+']'
  6304. from(select distinct Sequence from #TempSORRFQ)as a
  6305. set @sql='SELECT STUFF((select'','' + Sequence from (SELECT DISTINCT Sequence FROM #TempSORRFQ ) DD for xml path('''')),1,1,'''') as IsTou,*
  6306. FROM #TempSORRFQ PIVOT(MAX(SetValue) FOR Sequence IN ('+@sql+'))a '
  6307. exec(@sql)
  6308. ";
  6309. sql = string.Format(sql, InvCode, WorkPoint, JYID);
  6310. return SqlHelper.FindTablePageBySql_OtherTempSORRFQ(sql.ToString(), " " + "#TempSORRFQ" + " ", " drop table #TempSORRFQ", parameter.ToArray(), ref jqgridparam);
  6311. }
  6312. }
  6313. public DataTable GetRulesDetail(string LotNo)
  6314. {
  6315. DataTable dt = new DataTable();
  6316. //var queryParam = queryJson.ToJObject();
  6317. List<DbParameter> parameter = new List<DbParameter>();
  6318. string sql = string.Empty;
  6319. //增加pp子表查询 主要查询U8到货单数量
  6320. sql = @"select DISTINCT
  6321. CAST(ISNULL(h.SampleQuantity, 0) as decimal(18,4)) as SampleQuantity,
  6322. b.LotNo ,
  6323. b.Quantity,
  6324. '',
  6325. g.RulesCode,
  6326. g.InvCode,
  6327. c.InvStd,
  6328. c.InvName
  6329. FROM ICSDeliveryNotice a
  6330. inner JOIN ICSASNDetail b ON a.ASNCode=b.ASNCode AND a.WorkPoint=b.WorkPoint
  6331. inner JOIN ICSInventory c ON a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint --and c.InvIQC='1'
  6332. inner JOIN ICSInventoryLot d ON b.LotNo=d.LotNo AND a.InvCode=d.InvCode AND b.WorkPoint=d.WorkPoint
  6333. left join ICSInventoryLotDetail e on d.LotNo=e.LotNo and d.WorkPoint=e.WorkPoint
  6334. LEFT JOIN dbo.ICSInspection h ON h.LotNo=b.LotNo AND h.WorkPoint=b.WorkPoint --and Enable='1'
  6335. LEFT JOIN ICSInventoryInspectionRulesGroup g ON c.InvCode=g.InvCode AND c.WorkPoint=g.WorkPoint
  6336. Where b.LotNo='" + LotNo + "'";
  6337. return Repository().FindTableBySql(sql.ToString());
  6338. }
  6339. /// <summary>
  6340. /// 检验保存
  6341. /// </summary>
  6342. /// <param name="ICSMTDOC"></param>
  6343. /// <param name="InvCode"></param>
  6344. /// <param name="ResultINp"></param>
  6345. /// <returns></returns>
  6346. public string SaveICSInspectionDetailNew(string ICSMTDOC, string InvCode, string JYID, string AllNumber, string YLOTQTY, string NLOTQTY, string WaiveQuantity, string BCCode, string BRCode, string ResultINp, string Lot, string Type, decimal CJQty)
  6347. {
  6348. string msg = "";
  6349. try
  6350. {
  6351. object CARID = Guid.NewGuid();
  6352. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  6353. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  6354. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  6355. string sql = string.Empty;
  6356. JArray res = (JArray)JsonConvert.DeserializeObject(ICSMTDOC);
  6357. bool ISOK = false;
  6358. string ID = string.Empty;
  6359. if (string.IsNullOrEmpty(JYID) || JYID == "null")
  6360. {
  6361. sql += $@"
  6362. INSERT INTO dbo.ICSInspection ( ID ,LotNo,InvCode ,Quantity,QualifiedQuantity ,UnqualifiedQuantity,WaiveQuantity,BCCode,BRCode,Type,MTIME,MUSER ,MUSERName ,WorkPoint ,Enable,SampleQuantity)
  6363. Values('{CARID}','{Lot}','{InvCode}','{AllNumber}','{YLOTQTY}','{NLOTQTY}','{WaiveQuantity}','{BCCode}','{BRCode}','{Type}',getdate(),'{MUSER}','{MUSERNAME}','{WorkPoint}','1','{CJQty}')
  6364. ";
  6365. }
  6366. else
  6367. {
  6368. CARID = JYID;
  6369. }
  6370. foreach (var item in res)
  6371. {
  6372. string Guids = Guid.NewGuid().ToString();
  6373. JObject jo = (JObject)item;
  6374. JArray detailres = (JArray)JsonConvert.DeserializeObject(jo["LWFiledName"].ToString());
  6375. sql += @"
  6376. INSERT INTO dbo.ICSInspectionDetailGroup
  6377. ( ID ,InspectionID,ListCode ,ListName ,
  6378. Unit ,SetValueMax ,SetValueMin ,UnqualifiedQuantity ,Result, MUSER ,MUSERName ,MTIME, WorkPoint,GroupCode,GroupName)
  6379. values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}',getdate(),'{11}','{12}','{13}')";
  6380. sql = string.Format(sql, Guids, CARID, jo["ListCode"].ToString(), jo["ListName"].ToString(), jo["Unit"].ToString(),
  6381. jo["SetValueMax"].ToString(), jo["SetValueMin"].ToString(), jo["SetValue"].ToString(), jo["Result"].ToString()
  6382. , MUSER, MUSERNAME, WorkPoint, jo["GroupCode"].ToString(), jo["GroupName"].ToString());
  6383. foreach (var itemdetail in detailres)
  6384. {
  6385. JObject jodetail = (JObject)itemdetail;
  6386. if (string.IsNullOrWhiteSpace(ResultINp))
  6387. {
  6388. sql += @"
  6389. INSERT INTO dbo.ICSInspectionDetail
  6390. ( ID ,DetailGroupID,Sequence ,SetValue ,Result, MUSER ,MUSERName ,MTIME, WorkPoint)
  6391. values(newid(),'{0}','{1}','{2}','{3}','{4}','{5}',getdate(),'{6}')";
  6392. sql = string.Format(sql, Guids, jodetail["FiledNamekey"].ToString(), jodetail["FiledNamevalue"].ToString(),
  6393. jo["Result"].ToString(),
  6394. MUSER, MUSERNAME, WorkPoint);
  6395. }
  6396. else
  6397. {
  6398. 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}'";
  6399. sql = string.Format(sql, jodetail["InspectionID"].ToString(), jodetail["ListCode"].ToString(), jodetail["ListName"].ToString(), jodetail["Unit"].ToString(), jodetail["SetValueMax"].ToString(), jodetail["SetValueMin"].ToString(), jodetail["SetValue"].ToString(), jodetail["Result"].ToString(), MUSER, MUSERNAME, WorkPoint, jodetail["GroupCode"].ToString(), jodetail["GroupName"].ToString(), jodetail["ID"].ToString(), jodetail["NUM"].ToString());
  6400. }
  6401. if (jo["Result"].ToString() == "0")
  6402. {
  6403. ISOK = true;
  6404. }
  6405. }
  6406. ID = jo["InspectionID"].ToString();
  6407. }
  6408. if (ISOK == true)
  6409. {
  6410. sql += @" update ICSInspection set Result='{0}' where ID='{1}'";
  6411. sql = string.Format(sql, 0, CARID);
  6412. }
  6413. else
  6414. {
  6415. sql += @" update ICSInspection set Result='{0}' where ID='{1}'";
  6416. sql = string.Format(sql, 1, CARID);
  6417. }
  6418. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  6419. {
  6420. }
  6421. else
  6422. {
  6423. msg = "绑定失败";
  6424. }
  6425. }
  6426. catch (Exception ex)
  6427. {
  6428. msg = ex.Message;
  6429. }
  6430. return msg;
  6431. }
  6432. /// <summary>
  6433. /// 检验修改
  6434. /// </summary>
  6435. /// <param name="ICSMTDOC"></param>
  6436. /// <param name="InvCode"></param>
  6437. /// <param name="ResultINp"></param>
  6438. /// <returns></returns>
  6439. public string UpdateICSInspectionDetailNew(string ICSMTDOC, string JYID, string ResultINp)
  6440. {
  6441. string msg = "";
  6442. try
  6443. {
  6444. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  6445. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  6446. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  6447. string sql = string.Empty;
  6448. JArray res = (JArray)JsonConvert.DeserializeObject(ICSMTDOC);
  6449. bool ISOK = false;
  6450. string ID = string.Empty;
  6451. sql = @"DELETE c from ICSInspection a
  6452. left join ICSInspectionDetailGroup b on a.ID = b.inspectionID and a.workPoint = b.workPoint
  6453. left join ICSInspectionDetail c on b.id = c.DetailGroupID and b.workPoint = c.workPoint
  6454. Where a.ID='" + JYID + "'";
  6455. sql += "DELETE ICSInspectionDetailGroup where inspectionID='" + JYID + "'";
  6456. foreach (var item in res)
  6457. {
  6458. string Guids = Guid.NewGuid().ToString();
  6459. JObject jo = (JObject)item;
  6460. JArray detailres = (JArray)JsonConvert.DeserializeObject(jo["LWFiledName"].ToString());
  6461. sql += @"
  6462. INSERT INTO dbo.ICSInspectionDetailGroup
  6463. ( ID ,InspectionID,ListCode ,ListName ,
  6464. Unit ,SetValueMax ,SetValueMin ,UnqualifiedQuantity ,Result, MUSER ,MUSERName ,MTIME, WorkPoint,GroupCode,GroupName)
  6465. values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}',getdate(),'{11}','{12}','{13}')";
  6466. sql = string.Format(sql, Guids, jo["InspectionID"].ToString(), jo["ListCode"].ToString(), jo["ListName"].ToString(), jo["Unit"].ToString(),
  6467. jo["SetValueMax"].ToString(), jo["SetValueMin"].ToString(), 0, jo["Result"].ToString()
  6468. , MUSER, MUSERNAME, WorkPoint, jo["GroupCode"].ToString(), jo["GroupName"].ToString());
  6469. foreach (var itemdetail in detailres)
  6470. {
  6471. JObject jodetail = (JObject)itemdetail;
  6472. //if (string.IsNullOrWhiteSpace(ResultINp))
  6473. //{
  6474. sql += @"
  6475. INSERT INTO dbo.ICSInspectionDetail
  6476. ( ID ,DetailGroupID,Sequence ,SetValue ,Result, MUSER ,MUSERName ,MTIME, WorkPoint)
  6477. values(newid(),'{0}','{1}','{2}','{3}','{4}','{5}',getdate(),'{6}')";
  6478. sql = string.Format(sql, Guids, jodetail["FiledNamekey"].ToString(), jodetail["FiledNamevalue"].ToString(),
  6479. jo["Result"].ToString(),
  6480. MUSER, MUSERNAME, WorkPoint);
  6481. //}
  6482. //else
  6483. //{
  6484. // 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}'";
  6485. // sql = string.Format(sql, jodetail["InspectionID"].ToString(), jodetail["ListCode"].ToString(), jodetail["ListName"].ToString(), jodetail["Unit"].ToString(), jodetail["SetValueMax"].ToString(), jodetail["SetValueMin"].ToString(), jodetail["SetValue"].ToString(), jodetail["Result"].ToString(), MUSER, MUSERNAME, WorkPoint, jodetail["GroupCode"].ToString(), jodetail["GroupName"].ToString(), jodetail["ID"].ToString(), jodetail["NUM"].ToString());
  6486. //}
  6487. if (jo["Result"].ToString() == "0")
  6488. {
  6489. ISOK = true;
  6490. }
  6491. }
  6492. ID = jo["InspectionID"].ToString();
  6493. }
  6494. if (ISOK == true)
  6495. {
  6496. sql += @" update ICSInspection set Result='{0}' where ID='{1}'";
  6497. sql = string.Format(sql, 0, ID);
  6498. }
  6499. else
  6500. {
  6501. sql += @" update ICSInspection set Result='{0}' where ID='{1}'";
  6502. sql = string.Format(sql, 1, ID);
  6503. }
  6504. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  6505. {
  6506. }
  6507. else
  6508. {
  6509. msg = "绑定失败";
  6510. }
  6511. }
  6512. catch (Exception ex)
  6513. {
  6514. msg = ex.Message;
  6515. }
  6516. return msg;
  6517. }
  6518. public DataTable SelectSORRFQColumnName(string InvCode, string JYID)
  6519. {
  6520. string sql = @"declare @sql varchar(8000)
  6521. SELECT d.Sequence,d.SetValue
  6522. into #Temp
  6523. from ICSInventoryInspectionGroup a
  6524. inner join ICSInventoryInspectionList b on a.ID=b.InvGroupID and a.WorkPoint=b.WorkPoint
  6525. left join ICSInspectionDetailGroup c on b.ListCode=c.ListCode and a.GroupCode=c.GroupCode and b.WorkPoint=c.WorkPoint and c.InspectionID='{1}'
  6526. left JOIN ICSInspectionDetail d ON c.ID=d.DetailGroupID AND c.WorkPoint=d.WorkPoint
  6527. where a.InvCode='{0}' and b.Enable='1'
  6528. select distinct Sequence as ColCaption,Sequence as ColFiledName from #Temp
  6529. drop table #Temp";
  6530. sql = string.Format(sql, InvCode, JYID);
  6531. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  6532. return dt;
  6533. }
  6534. public DataTable GetDeleteRulesDetail(string InvCode, string JYID)
  6535. {
  6536. DataTable dt = new DataTable();
  6537. //var queryParam = queryJson.ToJObject();
  6538. List<DbParameter> parameter = new List<DbParameter>();
  6539. string sql = string.Empty;
  6540. //增加pp子表查询 主要查询U8到货单数量
  6541. sql = @"
  6542. select a.ID as inspectionID,c.ID,a.lotNO,a.Invcode,c.SetValue from ICSInspection a
  6543. left join ICSInspectionDetailGroup b on a.ID=b.inspectionID and a.workPoint=b.workPoint
  6544. left join ICSInspectionDetail c on b.id=c.DetailGroupID and b.workPoint=c.workPoint
  6545. where a.id='{0}' and a.Invcode='{1}'";
  6546. sql = string.Format(sql, JYID, InvCode);
  6547. return Repository().FindTableBySql(sql.ToString());
  6548. }
  6549. public string DeleteICSInspection(string DetailID)
  6550. {
  6551. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  6552. string MUSERName = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  6553. string sql = string.Empty;
  6554. sql = @"delete FROM ICSInspectionDetail where ID in ({0})";
  6555. sql = string.Format(sql, DetailID.TrimEnd(','));
  6556. string msg = "";
  6557. try
  6558. {
  6559. SqlHelper.ExecuteNonQuery(sql);
  6560. }
  6561. catch (Exception ex)
  6562. {
  6563. msg = ex.Message;
  6564. }
  6565. return msg;
  6566. }
  6567. public string DataActionSqlGet()
  6568. {
  6569. OperatorModel oo = NFine.Code.OperatorProvider.Provider.GetCurrent();
  6570. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  6571. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  6572. string sqlstr = string.Empty;
  6573. try
  6574. {
  6575. string sql = @" select B.DataActionId from Sys_SRM_User A
  6576. INNER JOIN Sys_RoleDataPower B ON B.RoleId=A.F_RoleId
  6577. where F_Account='{0}' and F_Location='{1}'";
  6578. sql = string.Format(sql, MUSER, WorkPoint);
  6579. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  6580. if (dt.Rows.Count == 0)
  6581. {
  6582. sqlstr = "";
  6583. }
  6584. else
  6585. {
  6586. string DataActionID = "";
  6587. foreach (DataRow dr in dt.Rows)
  6588. {
  6589. DataActionID += "'" + dr["DataActionId"].ToString() + "',";
  6590. }
  6591. sql = @" SELECT CCaption 条件名称, CValueBegin 起始值,CValueEnd 结束值
  6592. from Sys_FormDataAction con
  6593. where con.ID in ({0})";
  6594. sql = string.Format(sql, DataActionID.TrimEnd(','));
  6595. dt = SqlHelper.GetDataTableBySql(sql);
  6596. foreach (DataRow dr in dt.Rows)
  6597. {
  6598. if (dr["起始值"].ToString() != "" && dr["结束值"].ToString() != "")
  6599. {
  6600. sqlstr += " and " + dr["条件名称"].ToString() + " >= '" + dr["起始值"].ToString() + @"'
  6601. and " + dr[""].ToString() + " <= '" + dr[""].ToString() + "'";
  6602. }
  6603. else if (dr["起始值"].ToString() == "" && dr["结束值"].ToString() == "")
  6604. {
  6605. continue;
  6606. }
  6607. else
  6608. {
  6609. if (dr["起始值"].ToString() != "")
  6610. {
  6611. sqlstr += " and " + dr["条件名称"].ToString() + " = '" + dr["起始值"].ToString() + "'";
  6612. }
  6613. else
  6614. {
  6615. sqlstr += " and " + dr["条件名称"].ToString() + " = '" + dr["结束值"].ToString() + "'";
  6616. }
  6617. }
  6618. if (dr["起始值"].ToString().Contains("[AppConfig.WorkPointCode]") || dr["起始值"].ToString().Contains("[AppConfig.UserId]")
  6619. || dr["起始值"].ToString().Contains("[AppConfig.UserCode]") || dr["起始值"].ToString().Contains("[AppConfig.UserName]")
  6620. || dr["起始值"].ToString().Contains("[AppConfig.RoleCode]"))
  6621. {
  6622. sqlstr = sqlstr.Replace("[AppConfig.WorkPointCode]", oo.Location);
  6623. sqlstr = sqlstr.Replace("[AppConfig.UserId]", oo.UserId);
  6624. sqlstr = sqlstr.Replace("[AppConfig.UserCode]", oo.UserCode);
  6625. sqlstr = sqlstr.Replace("[AppConfig.UserName]", oo.UserName);
  6626. sqlstr = sqlstr.Replace("[AppConfig.RoleCode]", oo.RoleEnCode);
  6627. }
  6628. }
  6629. }
  6630. }
  6631. catch (Exception ex)
  6632. {
  6633. throw new Exception(ex.Message);
  6634. }
  6635. return sqlstr;
  6636. }
  6637. }
  6638. }