纽威

1361 lines
69 KiB

2 years ago
11 months ago
2 years ago
2 years ago
11 months ago
2 years ago
11 months ago
2 years ago
11 months ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
11 months ago
2 years ago
11 months ago
2 years ago
  1. using NFine.Code;
  2. using NFine.Domain.Entity.SystemManage;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Data.Common;
  6. using NFine.Repository;
  7. using System.Text;
  8. using System;
  9. using System.Configuration;
  10. using NFine.Data;
  11. using System.IO;
  12. using System.Linq;
  13. namespace NFine.Application.WMS
  14. {
  15. public class WatchPanelApp : RepositoryFactory<ModuleEntity>
  16. {
  17. string workpoint = ConfigurationManager.ConnectionStrings["WorkPointCode"].ConnectionString;
  18. private static string U9IP = ConfigurationManager.ConnectionStrings["U9connstr"].ConnectionString;
  19. private static string StratTimecfg = ConfigurationManager.ConnectionStrings["StratTime"].ConnectionString;
  20. private static string EndTimecfg = ConfigurationManager.ConnectionStrings["EndTime"].ConnectionString;
  21. private static string advDays = ConfigurationManager.ConnectionStrings["advDays"].ConnectionString;
  22. private static string workPoint = ConfigurationManager.ConnectionStrings["WorkPoint"].ConnectionString;
  23. string StratTime = DateTime.Parse(DateTime.Now.AddDays(-1).ToString()).ToString("yyyy-MM-dd") + ' ' + StratTimecfg;
  24. string EndTime = DateTime.Parse(DateTime.Now.ToString()).ToString("yyyy-MM-dd") + ' ' + EndTimecfg;
  25. //private string ERPName = U9IP.Substring(U9IP.IndexOf("Server=") + 7, 9) + "." + U9IP.Substring(U9IP.IndexOf("Catalog=") + 8, 7);
  26. //string dsaq = ConfigurationManager.ConnectionStrings["advDays"].ConnectionString;
  27. private static string conbegin = "Data Source=";
  28. private static int end = U9IP.IndexOf(";Uid=");
  29. private static string ERPName = "[" + U9IP.Substring(conbegin.Length, end - conbegin.Length).Replace(";Database=", "].");
  30. private static string ERPName1 = ERPName.Split('.')[ERPName.Split('.').Length - 1];
  31. string EndTime2 = "";
  32. //到货明细
  33. public DataTable GetList1(string queryJson, ref Pagination jqgridparam)
  34. {
  35. var queryParam = queryJson.ToJObject();
  36. OperatorModel oo = NFine.Code.OperatorProvider.Provider.GetCurrent();
  37. List<DbParameter> parameter = new List<DbParameter>();
  38. string SqlText = @"
  39. select * from (
  40. SELECT *,
  41. - ,
  42. CASE WHEN -> 0 THEN '' WHEN > 0 THEN '' ELSE '' END
  43. FROM (
  44. SELECT dd.orderno ,dd.itemcode ,dd.planqty ,inv.invname ,
  45. isnull((
  46. SELECT SUM (lotqty)
  47. FROM icsitemlot lot
  48. WHERE lot.TransNO=dd.ReceiptNO AND lot.TransLine=dd.ReceiptLine
  49. AND isnull(IQCStatus,'') !='' AND cc.workpoint=lot.workpoint),0) ,
  50. isnull((
  51. SELECT SUM (lotqty)
  52. FROM icsitemlot lot
  53. WHERE lot.TransNO=dd.ReceiptNO AND lot.TransLine=dd.ReceiptLine
  54. AND isnull(IQCStatus,'') !='' AND cc.workpoint=lot.workpoint
  55. AND NOT EXISTS (
  56. SELECT 1 FROM ICSWareHouseLotInfo info
  57. WHERE info.lotno=lot.lotno AND info.workpoint=lot.workpoint)),0)
  58. FROM ICSINVReceipt cc
  59. LEFT JOIN ICSINVReceiptDetail dd ON cc.ReceiptNO=dd.ReceiptNO AND dd.workpoint=cc.workpoint
  60. LEFT JOIN ICSINVENTORY inv ON inv.invcode=dd.itemcode AND dd.workpoint=inv.workpoint
  61. WHERE cc.mtime >=DATEADD(week, -1,getdate())
  62. and cc.workpoint='" + workpoint + @"'
  63. ) ff ) gg
  64. ";
  65. DataTable dt = Repository().FindTablePageBySql_Other(SqlText, "WMSconnstr", parameter.ToArray(), ref jqgridparam);
  66. return dt;
  67. }
  68. //来料不合格明细
  69. public DataTable GetList2(string queryJson, ref Pagination jqgridparam)
  70. {
  71. var queryParam = queryJson.ToJObject();
  72. OperatorModel oo = NFine.Code.OperatorProvider.Provider.GetCurrent();
  73. List<DbParameter> parameter = new List<DbParameter>();
  74. string SqlText = @"
  75. select * from (
  76. SELECT cc.receiptNo ,dd.orderno ,dd.itemcode , inv.invname ,
  77. sum(lot.lotqty) ,kk.CKITEMDESC
  78. FROM ICSINVReceipt cc
  79. LEFT JOIN ICSINVReceiptDetail dd ON cc.ReceiptNO=dd.ReceiptNO AND dd.workpoint=cc.workpoint
  80. LEFT JOIN ICSINVENTORY inv ON inv.invcode=dd.itemcode AND dd.workpoint=inv.workpoint
  81. left join icsitemlot lot on lot.TransNO=dd.ReceiptNO AND lot.TransLine=dd.ReceiptLine
  82. AND cc.workpoint=lot.workpoint
  83. left join (select * from (select ROW_NUMBER()over(partition by LOTNO order by mtime desc,id ) rowId,lotno ,errdata ,CKITEMDESC
  84. from ICSIQCErrList ck where workpoint='" + workpoint + @"' ) as AuctionRecords
  85. where rowId=1) kk on kk.lotno=lot.lotno
  86. WHERE 1=1
  87. and cc.mtime >=DATEADD(MONTH, -1,getdate())
  88. and kk.errdata=''
  89. and cc.workpoint='" + workpoint + @"'
  90. group by cc.receiptNo ,dd.orderno ,dd.itemcode , inv.invname ,kk.CKITEMDESC ) jj
  91. ";
  92. DataTable dt = Repository().FindTablePageBySql_Other(SqlText, "WMSconnstr", parameter.ToArray(), ref jqgridparam);
  93. return dt;
  94. }
  95. public DataTable GetWIPDATA()
  96. {
  97. List<DbParameter> parameter = new List<DbParameter>();
  98. string SqlText = @"
  99. select distinct mo.mocode ,mo.moseq ,mo.itemcode ,inv.invname ,
  100. mo.moplanqty ,sim.MUSERName ,sim.opcode
  101. ,row_number() over (partition by mo.mocode ,mo.moseq , sim.MUSERName ,sim.opcode order by sim.mtime desc,sim.id desc) rn
  102. from icsmo mo
  103. left join ICSITEMLot lot on lot.transno =mo.mocode and lot.TransLine=mo.moseq and lot.workpoint =mo.workpoint
  104. left join ICSLOTSIMULATION sim on mo.WorkPoint=sim.WorkPoint and sim.lotno=lot.lotno
  105. left join ICSINVENTORY inv on inv.invcode=mo.itemcode and inv.workpoint=mo.workpoint
  106. where sim.mtime>CAST(CAST(GETDATE() as date) as varchar(10)) + ' 00:00:00'
  107. and mo.WorkPoint='" + workpoint + @"'
  108. ";
  109. DataTable dt = Repository().GetDataTableBySql_Other(SqlText, "WMSconnstr", null);
  110. //测试
  111. for (int i = 0; i < 20; i++)
  112. {
  113. DataRow newRow;
  114. newRow = dt.NewRow();
  115. newRow["生产订单号"] = "MO-0001" + i.ToString();
  116. newRow["行号"] = "22";
  117. dt.Rows.Add(newRow);
  118. }
  119. return dt;
  120. }
  121. //车间人员信息
  122. public DataTable GetWIPUser()
  123. {
  124. List<DbParameter> parameter = new List<DbParameter>();
  125. string SqlText = @"
  126. select distinct mo.mocode ,mo.moseq ,mo.itemcode ,inv.invname ,
  127. mo.moplanqty ,sim.MUSERName ,sim.opcode
  128. ,row_number() over (partition by mo.mocode ,mo.moseq , sim.MUSERName ,sim.opcode order by sim.mtime desc,sim.id desc) rn
  129. from icsmo mo
  130. left join ICSITEMLot lot on lot.transno =mo.mocode and lot.TransLine=mo.moseq and lot.workpoint =mo.workpoint
  131. left join ICSLOTSIMULATION sim on mo.WorkPoint=sim.WorkPoint and sim.lotno=lot.lotno
  132. left join ICSINVENTORY inv on inv.invcode=mo.itemcode and inv.workpoint=mo.workpoint
  133. where sim.mtime>CAST(CAST(GETDATE() as date) as varchar(10)) + ' 00:00:00'
  134. and mo.WorkPoint='" + workpoint + @"'
  135. ";
  136. DataTable dt = Repository().GetDataTableBySql_Other(SqlText, "WMSconnstr", null);
  137. //测试
  138. for (int i = 0; i < 20; i++)
  139. {
  140. DataRow newRow;
  141. newRow = dt.NewRow();
  142. newRow["生产订单号"] = "MO-0001" + i.ToString();
  143. newRow["行号"] = "22";
  144. dt.Rows.Add(newRow);
  145. }
  146. return dt;
  147. }
  148. //收料信息
  149. public DataTable GetWIPRCV()
  150. {
  151. List<DbParameter> parameter = new List<DbParameter>();
  152. string SqlText = @"
  153. select B.CreatedOn ,A.DescFlexField_PrivateDescSeg1 ,A.DocNO ,B.DocLineNo
  154. ,ISNULL(B.QCBillNo,'') AS ,CASE WHEN A.Status='0' THEN '' WHEN A.Status='2' THEN '' WHEN A.Status='3' THEN '' ELSE '' END AS
  155. ,A.Supplier_ShortName ,A.DescFlexField_PubDescSeg13 ,B.ItemInfo_ItemCode
  156. ,B.ItemInfo_ItemName ,C.INVSTD ,C.INVUOM ,B.ArriveQtyTU ,B.QualifiedQtyTU
  157. ,case when B.Status='5' then B.QualifiedQtyTU When B.Status='5' AND ISNULL(B.QCBillNo,'')='' then B.QualifiedQtyTU ELSE 0 end as U9已上架数量
  158. ,ISNULL(F.QTY,0) AS WMS已上架数量,B.ArriveQtyTU-ISNULL(F.QTY,0) AS WMS未上架数量,E.Name
  159. from
  160. {0}.DBO.PM_Receivement A
  161. LEFT JOIN (SELECT a.ID,b.CreatedOn,b.DocLineNo,b.QCBillNo,b.ItemInfo_ItemCode,b.ItemInfo_ItemName,b.ItemInfo_ItemID,b.WhMan
  162. ,sum(b.ArriveQtyTU) ArriveQtyTU,SUM(b.QualifiedQtyTU) QualifiedQtyTU,b.Status
  163. from {0}.DBO.PM_Receivement a LEFT JOIN {0}.DBO.PM_RcvLine b on b.Receivement=a.ID
  164. where (SplitFlag=0 OR SplitFlag=2)
  165. GROUP BY a.ID,b.CreatedOn,b.DocLineNo,b.QCBillNo,b.ItemInfo_ItemCode,b.ItemInfo_ItemName,b.ItemInfo_ItemID,b.WhMan,b.Status ) B
  166. ON B.ID=A.ID
  167. LEFT JOIN ICSINVENTORY C on C.ID=B.ItemInfo_ItemID
  168. LEFT JOIN {0}.DBO.CBO_Operators_trl E on E.ID=B.WhMan
  169. LEFT JOIN (SELECT ASN.STNO,ASN.ITEMCODE,SUM(ISNULL(WHLOT.LotQty,0)) AS QTY FROM ICSASNDETAIL ASN
  170. LEFT JOIN ICSITEMLot LOT ON LOT.LotNO=ASN.LOTNO AND LOT.WorkPoint=ASN.WorkPoint
  171. LEFT JOIN ICSWareHouseLotInfo WHLOT ON WHLOT.LotNO=LOT.LotNO AND WHLOT.WorkPoint=LOT.WorkPoint
  172. GROUP BY ASN.STNO,ASN.ITEMCODE) F ON F.STNO=A.DescFlexField_PrivateDescSeg1 AND F.ITEMCODE=B.ItemInfo_ItemCode
  173. where 1=1 and B.CreatedOn>CAST(CAST(GETDATE() as date) as varchar(10)) + ' 00:00:00'
  174. order by B.CreatedOn";
  175. SqlText = string.Format(SqlText, ERPName, workpoint);
  176. DataTable dt = Repository().GetDataTableBySql_Other(SqlText, "WMSconnstr", null);
  177. return dt;
  178. }
  179. //收料图表
  180. public DataTable GetWIPRCVChart()
  181. {
  182. List<DbParameter> parameter = new List<DbParameter>();
  183. string SqlText = @"
  184. SELECT top 1 (SELECT COUNT(ID) FROM {0}.DBO.PM_RcvLine
  185. where (SplitFlag=0 OR SplitFlag=2)
  186. and CreatedOn>CAST(CAST(GETDATE() as date) as varchar(10)) + ' 00:00:00' and status<>'5') as U9dk,
  187. (SELECT COUNT(ID) FROM {0}.DBO.PM_RcvLine
  188. where (SplitFlag=0 OR SplitFlag=2)
  189. and CreatedOn>CAST(CAST(GETDATE() as date) as varchar(10)) + ' 00:00:00' and status='5') as U9gb
  190. from {0}.DBO.PM_RcvLine";
  191. SqlText = string.Format(SqlText, ERPName, workpoint);
  192. DataTable dt = Repository().GetDataTableBySql_Other(SqlText, "WMSconnstr", null);
  193. return dt;
  194. }
  195. //发料信息
  196. public DataTable GetMaterialPick()
  197. {
  198. List<DbParameter> parameter = new List<DbParameter>();
  199. string SqlText = $@" SELECT
  200. a.ApplyCode,
  201. A.Sequence,
  202. --a.SAPSequence,
  203. a.InvCode,
  204. c.LotNo,
  205. c.Quantity,
  206. e.StartLocation,
  207. e.EndLocation
  208. -- e.TaskCode
  209. FROM
  210. ICSMOApply a
  211. -- INNER JOIN ICSContainerReceiptsNumber b ON a.ApplyCode= b.TransCode
  212. INNER JOIN ICSWareHouseLotInfoLog c ON a.ApplyCode= c.TransCode
  213. AND
  214. c.TransType= '15'
  215. AND a.Sequence= c.TransSequence
  216. INNER JOIN ( SELECT DISTINCT e.StartLocation,e.EndLocation FROM
  217. ICSForkLiftTaskLog e WHERE e.EndLocation is not null AND e.EndLocation!=''AND (e.EATTRIBUTE1 IS NULL OR e.EATTRIBUTE1!='') ) e ON c.FromLocationCode= e.StartLocation
  218. WHERE
  219. a.WorkPoint in({workPoint})";
  220. //if (!string.IsNullOrWhiteSpace(StratTime))
  221. //{
  222. // SqlText += " and a.CreatedOn>'" + StratTime + "'";
  223. //}
  224. //if (!string.IsNullOrWhiteSpace(EndTime))
  225. //{
  226. // SqlText += " and a.CreatedOn<'" + EndTime + "'";
  227. //}
  228. //if (!string.IsNullOrWhiteSpace(advDays))
  229. //{
  230. // SqlText += @" and a.MTIME>CAST(CAST(DATEADD(day, -" + advDays + @", GETDATE()) as date) as varchar(10)) + ' 00:00:00'
  231. // and a.MTIME<=CAST(CAST(GETDATE() as date) as varchar(10)) + ' 23:59:59'";
  232. //}
  233. //if (string.IsNullOrWhiteSpace(StratTime) && string.IsNullOrWhiteSpace(EndTime) && string.IsNullOrWhiteSpace(advDays))
  234. //{
  235. // SqlText += @" and a.MTIME>CAST(CAST(GETDATE() as date) as varchar(10)) + ' 00:00:00'
  236. // and a.MTIME<=CAST(CAST(GETDATE() as date) as varchar(10)) + ' 23:59:59'";
  237. //}
  238. SqlText += @"order by a.MTIME ";
  239. //SqlText = string.Format(SqlText, ERPName, workpoint);
  240. DataTable dt = Repository().GetDataTableBySql_Other(SqlText, "WMSconnstr", null);
  241. return dt;
  242. }
  243. //发料图表
  244. public DataTable GetMaterialPickChart()
  245. {
  246. List<DbParameter> parameter = new List<DbParameter>();
  247. string SqlText = @" SELECT top 1
  248. (SELECT COUNT(*) from {0}.DBO.MO_MO a
  249. where a.CreatedOn>CAST(CAST(DATEADD(day, -{2}, GETDATE()) as date) as varchar(10)) + ' 00:00:00')-
  250. (SELECT COUNT(*) from {0}.DBO.MO_MO a
  251. LEFT JOIN (SELECT DISTINCT COUNT(VouchRow) ,MOCode from ICSMaterialPick GROUP BY MOCode) b on a.DocNo=b.MOCode
  252. LEFT JOIN (SELECT DISTINCT COUNT(VouchRow) ,MOCode from ICSMaterialPick where Quantity<=HasQuantity GROUP BY MOCode) c on a.DocNo=c.MOCode
  253. where a.CreatedOn>CAST(CAST(DATEADD(day, -{2}, GETDATE()) as date) as varchar(10)) + ' 00:00:00' and b.=c.)
  254. as ,
  255. (SELECT COUNT(*) from {0}.DBO.MO_MO a
  256. LEFT JOIN (SELECT DISTINCT COUNT(VouchRow) ,MOCode from ICSMaterialPick GROUP BY MOCode) b on a.DocNo=b.MOCode
  257. LEFT JOIN (SELECT DISTINCT COUNT(VouchRow) ,MOCode from ICSMaterialPick where Quantity<=HasQuantity GROUP BY MOCode) c on a.DocNo=c.MOCode
  258. where a.CreatedOn>CAST(CAST(DATEADD(day, -{2}, GETDATE()) as date) as varchar(10)) + ' 00:00:00' and b.=c.) as
  259. from {0}.DBO.MO_MO";
  260. SqlText = string.Format(SqlText, ERPName, workpoint, advDays);
  261. DataTable dt = Repository().GetDataTableBySql_Other(SqlText, "WMSconnstr", null);
  262. return dt;
  263. }
  264. //查询月度每日下单行数与每日完成出库行数
  265. public DataTable GetGridJson_MonthDaliyComplete()
  266. {
  267. string sql = @"
  268. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#temp1'))
  269. drop table #temp1
  270. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#temp1OO'))
  271. drop table #temp1OO
  272. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#temp2'))
  273. drop table #temp2
  274. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#temp2OO'))
  275. drop table #temp2OO
  276. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#temp111'))
  277. drop table #temp111
  278. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#temp111OO'))
  279. drop table #temp111OO
  280. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#temp222'))
  281. drop table #temp222
  282. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#temp222OO'))
  283. drop table #temp222OO
  284. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempPX3'))
  285. drop table #TempPX3
  286. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempPX3OO'))
  287. drop table #TempPX3OO
  288. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#tempSCLL'))
  289. drop table #tempSCLL
  290. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#tempSCLLOO'))
  291. drop table #tempSCLLOO
  292. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#tempAll'))
  293. drop table #tempAll
  294. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#tempRK'))
  295. drop table #tempRK
  296. select ApplyCode,count(*) Count,WorkPoint into #temp1 from ICSMOApply WITH (NOLOCK)
  297. where CONVERT(VARCHAR(10), CreateDateTime, 23) >=CONVERT(VARCHAR(10), DATEADD(day, -20, GETDATE()), 23)
  298. and CONVERT(VARCHAR(10), CreateDateTime, 23)<=CONVERT(VARCHAR(10), GETDATE(), 23)
  299. group by ApplyCode,WorkPoint
  300. select ApplyCode,sum(Quantity) Qty,WorkPoint into #temp2 from ICSMOApply WITH (NOLOCK)
  301. where CONVERT(VARCHAR(10), CreateDateTime, 23) >=CONVERT(VARCHAR(10), DATEADD(day, -20, GETDATE()), 23)
  302. and CONVERT(VARCHAR(10), CreateDateTime, 23)<=CONVERT(VARCHAR(10), GETDATE(), 23)
  303. group by ApplyCode,WorkPoint
  304. select a.ApplyCode,a.WorkPoint,a.Count,b.Qty into #temp111 from #temp1 a
  305. left join #temp2 b on a.ApplyCode = b.ApplyCode
  306. and a.WorkPoint = b.WorkPoint
  307. select TransCode,WorkPoint, CONVERT(VARCHAR(10), MTIME, 23) MTIME,Quantity,id into #temp222 from ICSWareHouseLotInfoLog WITH (NOLOCK)
  308. where CONVERT(VARCHAR(10), MTIME, 23) >=CONVERT(VARCHAR(10), DATEADD(day, -15, GETDATE()), 23)
  309. and CONVERT(VARCHAR(10), MTIME, 23)<=CONVERT(VARCHAR(10), GETDATE(), 23)
  310. and BusinessCode =14
  311. select aa.ApplyCode '',aa.WorkPoint '',aa.Count '',aa.Qty '',bb.MTIME '',bb.Quantity '', bb.id,
  312. row_number() over (partition by aa.ApplyCode order by bb.MTIME ,bb.id) rn
  313. into #TempPX3
  314. from #temp111 aa
  315. inner join #temp222 bb on aa.ApplyCode=bb.TransCode and aa.WorkPoint = bb.WorkPoint
  316. ---
  317. -- select *,case when > and <= then else 0 end
  318. -- from(
  319. -- select TT.*,
  320. -- ISNULL( (select sum() from #TempPX3 TT2
  321. -- WHERE TT2.RN<=TT.RN AND TT2.=TT. and TT2.=TT.),0)
  322. -- , ISNULL( (select sum() from #TempPX3 TT2
  323. -- WHERE TT2.RN<TT.RN AND TT2.=TT. AND TT2.=TT.),0)
  324. --
  325. -- from #TempPX3 TT
  326. -- ) gg
  327. ---
  328. select CONVERT(varchar(10), , 21) , sum(case when > and <= then else 0 end) into #tempSCLL
  329. from(
  330. select TT.*,
  331. ISNULL( (select sum() from #TempPX3 TT2
  332. WHERE TT2.RN<=TT.RN AND TT2.=TT. and TT2.=TT.),0)
  333. , ISNULL( (select sum() from #TempPX3 TT2
  334. WHERE TT2.RN<TT.RN AND TT2.=TT. and TT2.=TT.),0)
  335. from #TempPX3 TT
  336. ) gg
  337. group by CONVERT(varchar(10), , 21)
  338. select ApplyCode,count(*) Count,WorkPoint into #temp1OO from ICSOApply WITH (NOLOCK)
  339. where CONVERT(VARCHAR(10), CreateDateTime, 23) >=CONVERT(VARCHAR(10), DATEADD(day, -20, GETDATE()), 23)
  340. and CONVERT(VARCHAR(10), CreateDateTime, 23)<=CONVERT(VARCHAR(10), GETDATE(), 23)
  341. group by ApplyCode,WorkPoint
  342. select ApplyCode,sum(Quantity) Qty,WorkPoint into #temp2OO from ICSOApply WITH (NOLOCK)
  343. where CONVERT(VARCHAR(10), CreateDateTime, 23) >=CONVERT(VARCHAR(10), DATEADD(day, -20, GETDATE()), 23)
  344. and CONVERT(VARCHAR(10), CreateDateTime, 23)<=CONVERT(VARCHAR(10), GETDATE(), 23)
  345. group by ApplyCode,WorkPoint
  346. select a.ApplyCode,a.WorkPoint,a.Count,b.Qty into #temp111OO from #temp1OO a
  347. left join #temp2OO b on a.ApplyCode = b.ApplyCode
  348. and a.WorkPoint = b.WorkPoint
  349. select TransCode,WorkPoint, CONVERT(VARCHAR(10), MTIME, 23) MTIME,Quantity,id into #temp222OO from ICSWareHouseLotInfoLog WITH (NOLOCK)
  350. where CONVERT(VARCHAR(10), MTIME, 23) >=CONVERT(VARCHAR(10), DATEADD(day, -15, GETDATE()), 23)
  351. and CONVERT(VARCHAR(10), MTIME, 23)<=CONVERT(VARCHAR(10), GETDATE(), 23)
  352. and BusinessCode =6
  353. select aa.ApplyCode '',aa.WorkPoint '',aa.Count '',aa.Qty '',bb.MTIME '',bb.Quantity '', bb.id,
  354. row_number() over (partition by aa.ApplyCode order by bb.MTIME ,bb.id) rn
  355. into #TempPX3OO
  356. from #temp111OO aa
  357. inner join #temp222OO bb on aa.ApplyCode=bb.TransCode and aa.WorkPoint = bb.WorkPoint
  358. --
  359. -- select *,case when > and <= then else 0 end
  360. -- from(
  361. -- select TT.*,
  362. -- ISNULL( (select sum() from #TempPX3 TT2
  363. -- WHERE TT2.RN<=TT.RN AND TT2.=TT. and TT2.=TT.),0)
  364. -- , ISNULL( (select sum() from #TempPX3 TT2
  365. -- WHERE TT2.RN<TT.RN AND TT2.=TT. AND TT2.=TT.),0)
  366. --
  367. -- from #TempPX3 TT
  368. -- ) gg
  369. ---
  370. select CONVERT(varchar(10), , 21) , sum(case when > and <= then else 0 end) into #tempSCLLOO
  371. from(
  372. select TT.*,
  373. ISNULL( (select sum() from #TempPX3OO TT2
  374. WHERE TT2.RN<=TT.RN AND TT2.=TT. and TT2.=TT.),0)
  375. , ISNULL( (select sum() from #TempPX3OO TT2
  376. WHERE TT2.RN<TT.RN AND TT2.=TT. and TT2.=TT.),0)
  377. from #TempPX3OO TT
  378. ) gg
  379. group by CONVERT(varchar(10), , 21)
  380. select a.,a. + isnull(b.,0) into #tempRK from #tempSCLL a
  381. left join #tempSCLLOO b on a. = b.
  382. select a.MTIME,sum(FLQty) FLQty into #tempAll from(
  383. SELECT CONVERT(VARCHAR(10), CreateDateTime, 23) MTIME,count(*) FLQty from ICSMOApply WITH (NOLOCK)
  384. where CONVERT(VARCHAR(10), CreateDateTime, 23) >=CONVERT(VARCHAR(10), DATEADD(day, -15, GETDATE()), 23)
  385. and CONVERT(VARCHAR(10), CreateDateTime, 23)<=CONVERT(VARCHAR(10), GETDATE(), 23)
  386. group by CONVERT(VARCHAR(10), CreateDateTime, 23)
  387. union
  388. SELECT CONVERT(VARCHAR(10), CreateDateTime, 23) MTIME,count(*) FLQty from ICSOApply WITH (NOLOCK)
  389. where CONVERT(VARCHAR(10), CreateDateTime, 23) >=CONVERT(VARCHAR(10), DATEADD(day, -15, GETDATE()), 23)
  390. and CONVERT(VARCHAR(10), CreateDateTime, 23)<=CONVERT(VARCHAR(10), GETDATE(), 23)
  391. group by CONVERT(VARCHAR(10), CreateDateTime, 23)) a GROUP BY a.MTIME
  392. select a.MTIME,a.FLQty,b. RkQty from #tempAll a
  393. left join #tempRK b on a.MTIME = b. order by a.MTIME";
  394. DataTable dt = Repository().GetDataTableBySql_Other(sql, "WMSconnstr", null);
  395. return dt;
  396. }
  397. //查询月度每日合格数数与每日完成入库数
  398. public DataTable GetGridJson_MonthDaliyRcv()
  399. {
  400. string SqlText = @"
  401. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#temp1'))
  402. drop table #temp1
  403. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#temp1OO'))
  404. drop table #temp1OO
  405. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#temp2'))
  406. drop table #temp2
  407. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#temp2OO'))
  408. drop table #temp2OO
  409. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#temp111'))
  410. drop table #temp111
  411. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#temp111OO'))
  412. drop table #temp111OO
  413. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#temp222'))
  414. drop table #temp222
  415. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#temp222OO'))
  416. drop table #temp222OO
  417. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempPX3'))
  418. drop table #TempPX3
  419. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempPX3OO'))
  420. drop table #TempPX3OO
  421. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#tempSCLL'))
  422. drop table #tempSCLL
  423. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#tempSCLLOO'))
  424. drop table #tempSCLLOO
  425. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#tempAll'))
  426. drop table #tempAll
  427. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#tempRK'))
  428. drop table #tempRK
  429. select DNCode,count(*) Count,WorkPoint into #temp1 from ICSDeliveryNotice WITH (NOLOCK)
  430. where CONVERT(VARCHAR(10), CreateDateTime, 23) >=CONVERT(VARCHAR(10), DATEADD(day, -20, GETDATE()), 23)
  431. and CONVERT(VARCHAR(10), CreateDateTime, 23)<=CONVERT(VARCHAR(10), GETDATE(), 23)
  432. group by DNCode,WorkPoint
  433. select DNCode,sum(Quantity) Qty,WorkPoint into #temp2 from ICSDeliveryNotice WITH (NOLOCK)
  434. where CONVERT(VARCHAR(10), CreateDateTime, 23) >=CONVERT(VARCHAR(10), DATEADD(day, -20, GETDATE()), 23)
  435. and CONVERT(VARCHAR(10), CreateDateTime, 23)<=CONVERT(VARCHAR(10), GETDATE(), 23)
  436. group by DNCode,WorkPoint
  437. select a.DNCode,a.WorkPoint,a.Count,b.Qty into #temp111 from #temp1 a
  438. left join #temp2 b on a.DNCode = b.DNCode
  439. and a.WorkPoint = b.WorkPoint
  440. select TransCode,WorkPoint, CONVERT(VARCHAR(10), MTIME, 23) MTIME,Quantity,id into #temp222 from ICSWareHouseLotInfoLog WITH (NOLOCK)
  441. where CONVERT(VARCHAR(10), MTIME, 23) >=CONVERT(VARCHAR(10), DATEADD(day, -15, GETDATE()), 23)
  442. and CONVERT(VARCHAR(10), MTIME, 23)<=CONVERT(VARCHAR(10), GETDATE(), 23)
  443. and BusinessCode =2
  444. select aa.DNCode '',aa.WorkPoint '',aa.Count '',aa.Qty '',bb.MTIME '',bb.Quantity '', bb.id,
  445. row_number() over (partition by aa.DNCode order by bb.MTIME ,bb.id) rn
  446. into #TempPX3
  447. from #temp111 aa
  448. inner join #temp222 bb on aa.DNCode=bb.TransCode and aa.WorkPoint = bb.WorkPoint
  449. ---
  450. -- select *,case when > and <= then else 0 end
  451. -- from(
  452. -- select TT.*,
  453. -- ISNULL( (select sum() from #TempPX3 TT2
  454. -- WHERE TT2.RN<=TT.RN AND TT2.=TT. and TT2.=TT.),0)
  455. -- , ISNULL( (select sum() from #TempPX3 TT2
  456. -- WHERE TT2.RN<TT.RN AND TT2.=TT. AND TT2.=TT.),0)
  457. --
  458. -- from #TempPX3 TT
  459. -- ) gg
  460. ---
  461. select CONVERT(varchar(10), , 21) , sum(case when > and <= then else 0 end) into #tempSCLL
  462. from(
  463. select TT.*,
  464. ISNULL( (select sum() from #TempPX3 TT2
  465. WHERE TT2.RN<=TT.RN AND TT2.=TT. and TT2.=TT.),0)
  466. , ISNULL( (select sum() from #TempPX3 TT2
  467. WHERE TT2.RN<TT.RN AND TT2.=TT. and TT2.=TT.),0)
  468. from #TempPX3 TT
  469. ) gg
  470. group by CONVERT(varchar(10), , 21)
  471. select RCVCode,count(*) Count,WorkPoint into #temp1OO from ICSManufactureReceive WITH (NOLOCK)
  472. where CONVERT(VARCHAR(10), CreateDateTime, 23) >=CONVERT(VARCHAR(10), DATEADD(day, -20, GETDATE()), 23)
  473. and CONVERT(VARCHAR(10), CreateDateTime, 23)<=CONVERT(VARCHAR(10), GETDATE(), 23)
  474. and STATUS =1
  475. group by RCVCode,WorkPoint
  476. select RCVCode,sum(Quantity) Qty,WorkPoint into #temp2OO from ICSManufactureReceive WITH (NOLOCK)
  477. where CONVERT(VARCHAR(10), CreateDateTime, 23) >=CONVERT(VARCHAR(10), DATEADD(day, -20, GETDATE()), 23)
  478. and CONVERT(VARCHAR(10), CreateDateTime, 23)<=CONVERT(VARCHAR(10), GETDATE(), 23)
  479. and STATUS =1
  480. group by RCVCode,WorkPoint
  481. select a.RCVCode,a.WorkPoint,a.Count,b.Qty into #temp111OO from #temp1OO a
  482. left join #temp2OO b on a.RCVCode = b.RCVCode
  483. and a.WorkPoint = b.WorkPoint
  484. select TransCode,WorkPoint, CONVERT(VARCHAR(10), MTIME, 23) MTIME,Quantity,id into #temp222OO from ICSWareHouseLotInfoLog WITH (NOLOCK)
  485. where CONVERT(VARCHAR(10), MTIME, 23) >=CONVERT(VARCHAR(10), DATEADD(day, -15, GETDATE()), 23)
  486. and CONVERT(VARCHAR(10), MTIME, 23)<=CONVERT(VARCHAR(10), GETDATE(), 23)
  487. and BusinessCode =18
  488. select aa.RCVCode '',aa.WorkPoint '',aa.Count '',aa.Qty '',bb.MTIME '',bb.Quantity '', bb.id,
  489. row_number() over (partition by aa.RCVCode order by bb.MTIME ,bb.id) rn
  490. into #TempPX3OO
  491. from #temp111OO aa
  492. inner join #temp222OO bb on aa.RCVCode=bb.TransCode and aa.WorkPoint = bb.WorkPoint
  493. --
  494. -- select *,case when > and <= then else 0 end
  495. -- from(
  496. -- select TT.*,
  497. -- ISNULL( (select sum() from #TempPX3 TT2
  498. -- WHERE TT2.RN<=TT.RN AND TT2.=TT. and TT2.=TT.),0)
  499. -- , ISNULL( (select sum() from #TempPX3 TT2
  500. -- WHERE TT2.RN<TT.RN AND TT2.=TT. AND TT2.=TT.),0)
  501. --
  502. -- from #TempPX3 TT
  503. -- ) gg
  504. ---
  505. select CONVERT(varchar(10), , 21) , sum(case when > and <= then else 0 end) into #tempSCLLOO
  506. from(
  507. select TT.*,
  508. ISNULL( (select sum() from #TempPX3OO TT2
  509. WHERE TT2.RN<=TT.RN AND TT2.=TT. and TT2.=TT.),0)
  510. , ISNULL( (select sum() from #TempPX3OO TT2
  511. WHERE TT2.RN<TT.RN AND TT2.=TT. and TT2.=TT.),0)
  512. from #TempPX3OO TT
  513. ) gg
  514. group by CONVERT(varchar(10), , 21)
  515. select a.,a. + isnull(b.,0) into #tempRK from #tempSCLL a
  516. left join #tempSCLLOO b on a. = b.
  517. select xx.Mtime,sum(LLQty) FLQty into #tempAll from(
  518. SELECT CONVERT(VARCHAR(10), CreateDateTime, 23) MTIME,count(*) LLQty from ICSDeliveryNotice WITH (NOLOCK)
  519. where CONVERT(VARCHAR(10), CreateDateTime, 23) >=CONVERT(VARCHAR(10), DATEADD(day, -15, GETDATE()), 23)
  520. and CONVERT(VARCHAR(10), CreateDateTime, 23)<=CONVERT(VARCHAR(10), GETDATE(), 23)
  521. group by CONVERT(VARCHAR(10), CreateDateTime, 23)
  522. union all
  523. SELECT CONVERT(VARCHAR(10), CreateDateTime, 23) MTIME,count(*) LLQty from ICSManufactureReceive WITH (NOLOCK)
  524. where CONVERT(VARCHAR(10), CreateDateTime, 23) >=CONVERT(VARCHAR(10), DATEADD(day, -15, GETDATE()), 23)
  525. and CONVERT(VARCHAR(10), CreateDateTime, 23)<=CONVERT(VARCHAR(10), GETDATE(), 23)
  526. and status =1
  527. group by CONVERT(VARCHAR(10), CreateDateTime, 23)) xx group by xx.Mtime
  528. select a.MTIME,a.FLQty,b. RkQty from #tempAll a
  529. left join #tempRK b on a.MTIME = b. order by a.MTIME";
  530. DataTable dt = Repository().GetDataTableBySql_Other(SqlText, "WMSconnstr", null);
  531. return dt;
  532. }
  533. //查询配、发料及时率
  534. public DataTable GetGridJson_MonthLLPer()
  535. {
  536. string SqlText = @"
  537. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#temp1'))
  538. drop table #temp1
  539. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#temp2'))
  540. drop table #temp2
  541. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempPX3'))
  542. drop table #TempPX3
  543. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#tempSCLL'))
  544. drop table #tempSCLL
  545. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#tempALL'))
  546. drop table #tempALL
  547. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#tempX'))
  548. drop table #tempX
  549. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#temp111'))
  550. drop table #temp111
  551. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#tempWc'))
  552. drop table #tempWc
  553. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#temp1JS'))
  554. drop table #temp1JS
  555. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#temp2JS'))
  556. drop table #temp2JS
  557. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#TempPX3JS'))
  558. drop table #TempPX3JS
  559. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#tempSCLLJS'))
  560. drop table #tempSCLLJS
  561. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#tempALLJS'))
  562. drop table #tempALLJS
  563. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#tempXJS'))
  564. drop table #tempXJS
  565. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#temp111JS'))
  566. drop table #temp111JS
  567. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#tempALLDataJS'))
  568. drop table #tempALLDataJS
  569. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#tempLastJS'))
  570. drop table #tempLastJS
  571. if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#tempJs'))
  572. drop table #tempJs
  573. select ApplyCode,count(*) Count,WorkPoint into #temp1 from ICSMOApply WITH (NOLOCK)
  574. where NeedDate >=CONVERT(VARCHAR(10), DATEADD(day, -15, GETDATE()), 23)
  575. and NeedDate<=CONVERT(VARCHAR(10), GETDATE(), 23)
  576. and EATTRIBUTE ='01'
  577. group by ApplyCode,WorkPoint
  578. select ApplyCode,sum(Quantity) Qty,WorkPoint into #tempX from ICSMOApply WITH (NOLOCK)
  579. where NeedDate >=CONVERT(VARCHAR(10), DATEADD(day, -15, GETDATE()), 23)
  580. and NeedDate<=CONVERT(VARCHAR(10), GETDATE(), 23)
  581. and EATTRIBUTE ='01'
  582. group by ApplyCode,WorkPoint
  583. select a.ApplyCode,a.WorkPoint,a.Count,b.Qty into #temp111 from #temp1 a
  584. left join #tempX b on a.ApplyCode = b.ApplyCode
  585. and a.WorkPoint = b.WorkPoint
  586. select TransCode,WorkPoint, CONVERT(VARCHAR(10), MTIME, 23) MTIME,Quantity,id into #temp2 from ICSWareHouseLotInfoLog WITH (NOLOCK)
  587. where CONVERT(VARCHAR(10), MTIME, 23) >=CONVERT(VARCHAR(10), DATEADD(day, -30, GETDATE()), 23)
  588. and CONVERT(VARCHAR(10), MTIME, 23)<=CONVERT(VARCHAR(10), GETDATE(), 23)
  589. and BusinessCode =14
  590. select aa.ApplyCode '',aa.WorkPoint '',aa.Count '',aa.Qty '',bb.MTIME '',bb.Quantity '', bb.id,
  591. row_number() over (partition by aa.ApplyCode order by bb.MTIME ,bb.id) rn
  592. into #TempPX3
  593. from #temp111 aa
  594. inner join #temp2 bb on aa.ApplyCode=bb.TransCode and aa.WorkPoint = bb.WorkPoint
  595. ---
  596. select ,sum(case when > and <= then else 0 end) into #tempSCLL
  597. from(
  598. select TT.*,
  599. ISNULL( (select sum() from #TempPX3 TT2
  600. WHERE TT2.RN<=TT.RN AND TT2.=TT. and TT2.=TT.),0)
  601. , ISNULL( (select sum() from #TempPX3 TT2
  602. WHERE TT2.RN<TT.RN AND TT2.=TT. and TT2.=TT.),0)
  603. from #TempPX3 TT
  604. ) gg
  605. group by
  606. SELECT NeedDate,count(*) Qty into #tempALL from ICSMOApply WITH (NOLOCK)
  607. where NeedDate >=CONVERT(VARCHAR(10), DATEADD(day, -15, GETDATE()), 23)
  608. and NeedDate<=CONVERT(VARCHAR(10), GETDATE(), 23)
  609. and EATTRIBUTE ='01'
  610. group by NeedDate
  611. select a.NeedDate,ISNULL(Convert(decimal(18,2),Round(Convert(decimal(18,6),isnull(b.,0))/Convert(decimal(18,6),isnull(a.Qty,0)),2)*100),100) Per into #tempWc from #tempALL a
  612. left join #tempSCLL b on a.NeedDate = b. order by a.NeedDate;
  613. select ApplyCode,count(*) Count into #temp1JS from ICSMOApply WITH (NOLOCK)
  614. where NeedDate >=CONVERT(VARCHAR(10), DATEADD(day, -20, GETDATE()), 23)
  615. and NeedDate<=CONVERT(VARCHAR(10), GETDATE(), 23)
  616. and EATTRIBUTE ='01'
  617. group by ApplyCode
  618. select ApplyCode,sum(Quantity) Qty into #tempXJS from ICSMOApply WITH (NOLOCK)
  619. where NeedDate >=CONVERT(VARCHAR(10), DATEADD(day, -20, GETDATE()), 23)
  620. and NeedDate<=CONVERT(VARCHAR(10), GETDATE(), 23)
  621. and EATTRIBUTE ='01'
  622. group by ApplyCode
  623. select a.ApplyCode,a.Count,b.Qty into #temp111JS from #temp1JS a
  624. left join #tempXJS b on a.ApplyCode = b.ApplyCode
  625. select TransCode, CONVERT(VARCHAR(10), MTIME, 23) MTIME,Quantity,id into #temp2JS from ICSWareHouseLotInfoLog WITH (NOLOCK)
  626. where CONVERT(VARCHAR(10), MTIME, 23) >=CONVERT(VARCHAR(10), DATEADD(day, -30, GETDATE()), 23)
  627. and CONVERT(VARCHAR(10), MTIME, 23)<=CONVERT(VARCHAR(10), GETDATE(), 23)
  628. and BusinessCode =14
  629. select aa.ApplyCode '',aa.Count '',aa.Qty '',bb.MTIME '',bb.Quantity '', bb.id,
  630. row_number() over (partition by aa.ApplyCode order by bb.MTIME ,bb.id) rn
  631. into #TempPX3JS
  632. from #temp111JS aa
  633. inner join #temp2JS bb on aa.ApplyCode=bb.TransCode
  634. ---
  635. select ,, sum(case when > and <= then else 0 end) into #tempSCLLJS
  636. from(
  637. select TT.*,
  638. ISNULL( (select sum() from #TempPX3JS TT2
  639. WHERE TT2.RN<=TT.RN AND TT2.=TT.),0)
  640. , ISNULL( (select sum() from #TempPX3JS TT2
  641. WHERE TT2.RN<TT.RN AND TT2.=TT.),0)
  642. from #TempPX3JS TT
  643. ) gg
  644. group by ,
  645. --SELECT sum() FROM #tempSCLL where ='2024-01-15' GROUP BY
  646. select distinct b.NeedDate ,a.,case when a. <= b.NeedDate then else 0 end into #tempALLDataJS
  647. from #tempSCLLJS a
  648. left join ICSMOApply b on a. = b.ApplyCode
  649. --GROUP BY b.NeedDate,a.
  650. select sum() ,NeedDate into #tempLastJS from #tempALLDataJS GROUP BY NeedDate
  651. SELECT NeedDate ,count(*) Qty into #tempALLJS
  652. from ICSMOApply WITH (NOLOCK)
  653. where NeedDate >=CONVERT(VARCHAR(10), DATEADD(day, -15, GETDATE()), 23)
  654. and NeedDate<=CONVERT(VARCHAR(10), GETDATE(), 23)
  655. and EATTRIBUTE ='01'
  656. group by NeedDate
  657. select a.NeedDate,ISNULL(Convert(decimal(18,2),Round(Convert(decimal(18,6),isnull(b.,0))/Convert(decimal(18,6),isnull(a.Qty,0)),2)*100),100) Per into #tempJs from #tempALLJS a
  658. left join #tempLastJS b on a.NeedDate = b.NeedDate order by a.NeedDate
  659. select a.NeedDate,a.Per 'WcPer',b.Per 'JsPer' from #tempWc a left join #tempJs b on a.NeedDate = b.NeedDate
  660. ";
  661. DataTable dt = Repository().GetDataTableBySql_Other(SqlText, "WMSconnstr", null);
  662. return dt;
  663. }
  664. //查询一期库存状态
  665. public DataTable GetGridJson_WareStatusOne()
  666. {
  667. List<DbParameter> parameter = new List<DbParameter>();
  668. string SqlText = @"select a.LocationCode,isnull(b.Qty,0) Qty from ICSLocation a left join (
  669. select LocationCode,isnull(max(Quantity),0) Qty
  670. from ICSWareHouseLotInfo GROUP BY LocationCode) b on a.LocationCode = b.LocationCode
  671. where SUBSTRING(SUBSTRING(a.LocationCode,CHARINDEX('-',a.LocationCode)+1,len(a.LocationCode)),1,1) = '0'";
  672. DataTable dt = Repository().GetDataTableBySql_Other(SqlText, "WMSconnstr", null);
  673. return dt;
  674. }
  675. //查询二期库存状态
  676. public DataTable GetGridJson_WareStatusTwo()
  677. {
  678. List<DbParameter> parameter = new List<DbParameter>();
  679. string SqlText = @"select a.LocationCode,isnull(b.Qty,0) Qty from ICSLocation a left join (
  680. select LocationCode,isnull(max(Quantity),0) Qty
  681. from ICSWareHouseLotInfo GROUP BY LocationCode) b on a.LocationCode = b.LocationCode
  682. where SUBSTRING(SUBSTRING(a.LocationCode,CHARINDEX('-',a.LocationCode)+1,len(a.LocationCode)),1,1) = '2'";
  683. DataTable dt = Repository().GetDataTableBySql_Other(SqlText, "WMSconnstr", null);
  684. return dt;
  685. }
  686. //查询三期库存状态
  687. public DataTable GetGridJson_WareStatusThree()
  688. {
  689. List<DbParameter> parameter = new List<DbParameter>();
  690. string SqlText = @"select a.LocationCode,isnull(b.Qty,0) Qty from ICSLocation a left join (
  691. select LocationCode,isnull(max(Quantity),0) Qty
  692. from ICSWareHouseLotInfo GROUP BY LocationCode) b on a.LocationCode = b.LocationCode
  693. where SUBSTRING(SUBSTRING(a.LocationCode,CHARINDEX('-',a.LocationCode)+1,len(a.LocationCode)),1,1) = '3'";
  694. DataTable dt = Repository().GetDataTableBySql_Other(SqlText, "WMSconnstr", null);
  695. return dt;
  696. }
  697. //查询物料配料进度
  698. public DataTable GetGridJson_ApplyStatus()
  699. {
  700. #region 注释
  701. // //范围内的所有生产领料单号
  702. // string SqlText = @"select distinct a.DispatcherName,a.ReceiverName,a.ApplyCode,a.Urgency,
  703. //a.MTIME,isnull(b.MUSER,'') MUSER,isnull(c.F_RealName,'') MUSERName,a.NeedDate+' '+a.NeedTime NeedTime,a.WorkPoint
  704. //from ICSMOApply a
  705. //left join ICSWareHouseLotInfoLog b on a.ApplyCode = b.TransCode and a.WorkPoint = b.WorkPoint
  706. //left join Sys_SRM_User c on b.MUSER = c.F_Account
  707. //where a.EATTRIBUTE ='01'
  708. //and CONVERT(VARCHAR(10), a.MTIME, 23) >=CONVERT(VARCHAR(10), DATEADD(day, -15, GETDATE()), 23)
  709. //and CONVERT(VARCHAR(10), a.MTIME, 23) <= CONVERT(VARCHAR(10), GETDATE(), 23) ";
  710. // DataTable dt = Repository().GetDataTableBySql_Other(SqlText, "WMSconnstr", null);
  711. // //是否配料
  712. // SqlText = @"select distinct a.ApplyCode,a.WorkPoint from ICSMOApply a
  713. // left join ICSWareHouseLotInfoLog b on a.ApplyCode = b.TransCode and a.WorkPoint = b.WorkPoint
  714. // where b.TransType ='15' and a.EATTRIBUTE ='01'
  715. //and CONVERT(VARCHAR(10), a.MTIME, 23) >=CONVERT(VARCHAR(10), DATEADD(day, -15, GETDATE()), 23)
  716. //and CONVERT(VARCHAR(10), a.MTIME, 23) <= CONVERT(VARCHAR(10), GETDATE(), 23) ";
  717. // DataTable dtPL = Repository().GetDataTableBySql_Other(SqlText, "WMSconnstr", null);
  718. // //是否配料完成
  719. // SqlText = @"select distinct a.ApplyCode,a.WorkPoint from (
  720. //select sum(Quantity) Quantity,sum(IssueQuantity) IssueQuantity,ApplyCode,WorkPoint
  721. //from ICSMOApply
  722. //where EATTRIBUTE ='01'
  723. //and CONVERT(VARCHAR(10), MTIME, 23) >=CONVERT(VARCHAR(10), DATEADD(day, -15, GETDATE()), 23)
  724. //and CONVERT(VARCHAR(10), MTIME, 23) <= CONVERT(VARCHAR(10), GETDATE(), 23)
  725. //group by ApplyCode,WorkPoint) a where a.Quantity = a.IssueQuantity";
  726. // DataTable dtPLCom = Repository().GetDataTableBySql_Other(SqlText, "WMSconnstr", null);
  727. // //运输中
  728. // SqlText = @"select distinct a.ApplyCode,a.WorkPoint FROM ICSMOApply a
  729. //left join ICSWareHouseLotInfoLog b on a.ApplyCode = b.TransCode and a.WorkPoint = b.WorkPoint
  730. //left join ICSContainerLot c on b.LotNo = c.lotNo and b.WorkPoint = c.WorkPoint
  731. //left join ICSContainer d on c.ContainerID = d.ID
  732. //left join ICSAGVTaskLog e on d.ContainerCode = e.ContainerCode and d.WorkPoint = e.WorkPoint
  733. //where (e.EATTRIBUTE2 = '未完成')
  734. //and CONVERT(VARCHAR(10), a.MTIME, 23) >=CONVERT(VARCHAR(10), DATEADD(day, -15, GETDATE()), 23)
  735. //and CONVERT(VARCHAR(10), a.MTIME, 23) <= CONVERT(VARCHAR(10), GETDATE(), 23)";
  736. // DataTable dtYsing = Repository().GetDataTableBySql_Other(SqlText, "WMSconnstr", null);
  737. // //运输完成
  738. // SqlText = @"select distinct a.ApplyCode,a.WorkPoint FROM ICSMOApply a
  739. //left join ICSWareHouseLotInfoLog b on a.ApplyCode = b.TransCode and a.WorkPoint = b.WorkPoint
  740. //left join ICSContainerLot c on b.LotNo = c.lotNo and b.WorkPoint = c.WorkPoint
  741. //left join ICSContainer d on c.ContainerID = d.ID
  742. //left join ICSAGVTaskLog e on d.ContainerCode = e.ContainerCode and d.WorkPoint = e.WorkPoint
  743. //where e.EATTRIBUTE2 = '已完成'
  744. //and CONVERT(VARCHAR(10), a.MTIME, 23) >=CONVERT(VARCHAR(10), DATEADD(day, -15, GETDATE()), 23)
  745. //and CONVERT(VARCHAR(10), a.MTIME, 23) <= CONVERT(VARCHAR(10), GETDATE(), 23)";
  746. // DataTable dtYsed = Repository().GetDataTableBySql_Other(SqlText, "WMSconnstr", null);
  747. // //收料完成
  748. // // SqlText = @"select distinct ApplyCode,WorkPoint from ICSMOApply where isnull(MUSERName,'') <> 'JOB'
  749. // //and CONVERT(VARCHAR(10), MTIME, 23) >=CONVERT(VARCHAR(10), DATEADD(day, -15, GETDATE()), 23)
  750. // //and CONVERT(VARCHAR(10), MTIME, 23) <= CONVERT(VARCHAR(10), GETDATE(), 23)";
  751. // // DataTable dtSlCom = Repository().GetDataTableBySql_Other(SqlText, "WMSconnstr", null);
  752. // dt.Columns.Add("Status", typeof(string));
  753. #endregion
  754. string sql = @"if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#tempPL'))
  755. drop table #tempPL
  756. --
  757. select distinct a.ApplyCode,a.WorkPoint into #tempPL from (
  758. select sum(Quantity) Quantity,sum(IssueQuantity) IssueQuantity,ApplyCode,WorkPoint
  759. from ICSMOApply
  760. where EATTRIBUTE ='01'
  761. and CONVERT(VARCHAR(10), MTIME, 23) >=CONVERT(VARCHAR(10), DATEADD(day, -15, GETDATE()), 23)
  762. and CONVERT(VARCHAR(10), MTIME, 23) <= CONVERT(VARCHAR(10), GETDATE(), 23)
  763. group by ApplyCode,WorkPoint) a where a.Quantity = a.IssueQuantity
  764. select distinct a.DispatcherName,a.ReceiverName,a.ApplyCode,a.Urgency,
  765. max(a.MTIME) MTIME,isnull(b.MUSER,'') MUSER,isnull(c.F_RealName,'') MUSERName,a.NeedDate+' '+a.NeedTime NeedTime,h.LocationCode,
  766. case when b.TransType ='15' then '' else
  767. (case when d.ApplyCode is not null then '' else
  768. (case when g.EATTRIBUTE2 ='' then '' else
  769. (case when g.EATTRIBUTE2 ='' then '' else '' end) end) end) end as 'Status'
  770. from ICSMOApply a
  771. left join ICSWareHouseLotInfoLog b on a.ApplyCode = b.TransCode and a.WorkPoint = b.WorkPoint
  772. left join Sys_SRM_User c on b.MUSER = c.F_Account
  773. left join #tempPL d on a.ApplyCode = d.ApplyCode and a.WorkPoint = d.WorkPoint
  774. left join ICSContainerLot e on b.LotNo = e.lotNo and b.WorkPoint = e.WorkPoint
  775. left join ICSContainer f on e.ContainerID = f.ID
  776. left join ICSAGVTaskLog g on f.ContainerCode = g.ContainerCode and f.WorkPoint = g.WorkPoint
  777. left join ICSInventoryDetail h on a.InvCode = h.InvCode and a.WHCode = h.WHCode
  778. where a.EATTRIBUTE ='01' and isnull(a.MUSERName,'') = 'JOB'
  779. and CONVERT(VARCHAR(10), a.MTIME, 23) >=CONVERT(VARCHAR(10), DATEADD(day, -15, GETDATE()), 23)
  780. and CONVERT(VARCHAR(10), a.MTIME, 23) <= CONVERT(VARCHAR(10), GETDATE(), 23)
  781. group by a.DispatcherName,a.ReceiverName,a.ApplyCode,a.Urgency,b.MUSER,
  782. c.F_RealName,a.NeedDate,a.NeedTime,b.TransType,d.ApplyCode,g.EATTRIBUTE2,h.LocationCode";
  783. DataTable dt = Repository().GetDataTableBySql_Other(sql, "WMSconnstr", null);
  784. List<DataRow> DrList = dt.Select("1=1").OrderByDescending(x => x["Urgency"].ToString()).ThenBy(x => x["NeedTime"]).ToList();
  785. DataTable dtNew = new DataTable();
  786. if (DrList.Count > 0)
  787. {
  788. dtNew = DrList[0].Table.Clone();
  789. foreach (DataRow item in DrList)
  790. {
  791. dtNew.ImportRow(item);
  792. }
  793. }
  794. return dtNew;
  795. }
  796. //查询物料账龄分布
  797. public DataTable GetGridJson_ItemAge()
  798. {
  799. DataTable dt = new DataTable();
  800. GetItemAge.ZWMS_SK_KB_WXQKCZLClient client = new GetItemAge.ZWMS_SK_KB_WXQKCZLClient();
  801. List<GetItemAge.ZgcnyStrc> list = new List<GetItemAge.ZgcnyStrc>();
  802. List<GetItemAge.ZwxqkczlStrc> listX = new List<GetItemAge.ZwxqkczlStrc>();
  803. client.ClientCredentials.UserName.UserName = "NWBG";
  804. client.ClientCredentials.UserName.Password = "nwbg321";
  805. list.Add(new GetItemAge.ZgcnyStrc { Mandt = "900", Werks = "1701", Kmonth = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString().PadLeft(2, '0') });
  806. list.Add(new GetItemAge.ZgcnyStrc { Mandt = "900", Werks = "1701", Kmonth = DateTime.Now.AddMonths(-1).Year.ToString() + DateTime.Now.AddMonths(-1).Month.ToString().PadLeft(2, '0') });
  807. list.Add(new GetItemAge.ZgcnyStrc { Mandt = "900", Werks = "1701", Kmonth = DateTime.Now.AddMonths(-2).Year.ToString() + DateTime.Now.AddMonths(-2).Month.ToString().PadLeft(2, '0') });
  808. list.Add(new GetItemAge.ZgcnyStrc { Mandt = "900", Werks = "1701", Kmonth = DateTime.Now.AddMonths(-3).Year.ToString() + DateTime.Now.AddMonths(-3).Month.ToString().PadLeft(2, '0') });
  809. list.Add(new GetItemAge.ZgcnyStrc { Mandt = "900", Werks = "1701", Kmonth = DateTime.Now.AddMonths(-4).Year.ToString() + DateTime.Now.AddMonths(-4).Month.ToString().PadLeft(2, '0') });
  810. list.Add(new GetItemAge.ZgcnyStrc { Mandt = "900", Werks = "1701", Kmonth = DateTime.Now.AddMonths(-5).Year.ToString() + DateTime.Now.AddMonths(-5).Month.ToString().PadLeft(2, '0') });
  811. dt.Columns.Add("YearRound", typeof(string));
  812. dt.Columns.Add("Qty1", typeof(decimal));
  813. dt.Columns.Add("Qty2", typeof(decimal));
  814. dt.Columns.Add("Qty3", typeof(decimal));
  815. dt.Columns.Add("Qty4", typeof(decimal));
  816. dt.Columns.Add("Qty5", typeof(decimal));
  817. dt.Columns.Add("Qty6", typeof(decimal));
  818. GetItemAge.ZwmsSkKbWxqkczlResponse res = client.ZwmsSkKbWxqkczl(new GetItemAge.ZwmsSkKbWxqkczl
  819. {
  820. Zflag = "Y",
  821. ItGcny = list.ToArray(),
  822. ItWxqkczl = listX.ToArray()
  823. });
  824. List<GetItemAge.ZwxqkczlStrc> list1 = res.ItWxqkczl.ToList().Where(x => x.Kmonth == DateTime.Now.AddMonths(-5).Year.ToString() + DateTime.Now.AddMonths(-5).Month.ToString().PadLeft(2, '0')).ToList();
  825. List<GetItemAge.ZwxqkczlStrc> list2 = res.ItWxqkczl.ToList().Where(x => x.Kmonth == DateTime.Now.AddMonths(-4).Year.ToString() + DateTime.Now.AddMonths(-4).Month.ToString().PadLeft(2, '0')).ToList();
  826. List<GetItemAge.ZwxqkczlStrc> list3 = res.ItWxqkczl.ToList().Where(x => x.Kmonth == DateTime.Now.AddMonths(-3).Year.ToString() + DateTime.Now.AddMonths(-3).Month.ToString().PadLeft(2, '0')).ToList();
  827. List<GetItemAge.ZwxqkczlStrc> list4 = res.ItWxqkczl.ToList().Where(x => x.Kmonth == DateTime.Now.AddMonths(-2).Year.ToString() + DateTime.Now.AddMonths(-2).Month.ToString().PadLeft(2, '0')).ToList();
  828. List<GetItemAge.ZwxqkczlStrc> list5 = res.ItWxqkczl.ToList().Where(x => x.Kmonth == DateTime.Now.AddMonths(-1).Year.ToString() + DateTime.Now.AddMonths(-1).Month.ToString().PadLeft(2, '0')).ToList();
  829. List<GetItemAge.ZwxqkczlStrc> list6 = res.ItWxqkczl.ToList().Where(x => x.Kmonth == DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString().PadLeft(2, '0')).ToList();
  830. dt.Rows.Add("1年以下", list1.Count == 0 ? 0 : list1.Where(x => x.Zaging == "1年以下").ToList()[0].Zstock,
  831. list2.Count == 0 ? 0 : list2.Where(x => x.Zaging == "1年以下").ToList()[0].Zstock,
  832. list3.Count == 0 ? 0 : list3.Where(x => x.Zaging == "1年以下").ToList()[0].Zstock,
  833. list4.Count == 0 ? 0 : list4.Where(x => x.Zaging == "1年以下").ToList()[0].Zstock,
  834. list5.Count == 0 ? 0 : list5.Where(x => x.Zaging == "1年以下").ToList()[0].Zstock,
  835. list6.Count == 0 ? 0 : list6.Where(x => x.Zaging == "1年以下").ToList()[0].Zstock);
  836. dt.Rows.Add("1-2年", list1.Count == 0 ? 0 : list1.Where(x => x.Zaging == "1-2年").ToList()[0].Zstock,
  837. list2.Count == 0 ? 0 : list2.Where(x => x.Zaging == "1-2年").ToList()[0].Zstock,
  838. list3.Count == 0 ? 0 : list3.Where(x => x.Zaging == "1-2年").ToList()[0].Zstock,
  839. list4.Count == 0 ? 0 : list4.Where(x => x.Zaging == "1-2年").ToList()[0].Zstock,
  840. list5.Count == 0 ? 0 : list5.Where(x => x.Zaging == "1-2年").ToList()[0].Zstock,
  841. list6.Count == 0 ? 0 : list6.Where(x => x.Zaging == "1-2年").ToList()[0].Zstock);
  842. dt.Rows.Add("2-3年", list1.Count == 0 ? 0 : list1.Where(x => x.Zaging == "2-3年").ToList()[0].Zstock,
  843. list2.Count == 0 ? 0 : list2.Where(x => x.Zaging == "2-3年").ToList()[0].Zstock,
  844. list3.Count == 0 ? 0 : list3.Where(x => x.Zaging == "2-3年").ToList()[0].Zstock,
  845. list4.Count == 0 ? 0 : list4.Where(x => x.Zaging == "2-3年").ToList()[0].Zstock,
  846. list5.Count == 0 ? 0 : list5.Where(x => x.Zaging == "2-3年").ToList()[0].Zstock,
  847. list6.Count == 0 ? 0 : list6.Where(x => x.Zaging == "2-3年").ToList()[0].Zstock);
  848. dt.Rows.Add("3-4年", list1.Count == 0 ? 0 : list1.Where(x => x.Zaging == "3-4年").ToList()[0].Zstock,
  849. list2.Count == 0 ? 0 : list2.Where(x => x.Zaging == "3-4年").ToList()[0].Zstock,
  850. list3.Count == 0 ? 0 : list3.Where(x => x.Zaging == "3-4年").ToList()[0].Zstock,
  851. list4.Count == 0 ? 0 : list4.Where(x => x.Zaging == "3-4年").ToList()[0].Zstock,
  852. list5.Count == 0 ? 0 : list5.Where(x => x.Zaging == "3-4年").ToList()[0].Zstock,
  853. list6.Count == 0 ? 0 : list6.Where(x => x.Zaging == "3-4年").ToList()[0].Zstock);
  854. dt.Rows.Add("4-5年", list1.Count == 0 ? 0 : list1.Where(x => x.Zaging == "4-5年").ToList()[0].Zstock,
  855. list2.Count == 0 ? 0 : list2.Where(x => x.Zaging == "4-5年").ToList()[0].Zstock,
  856. list3.Count == 0 ? 0 : list3.Where(x => x.Zaging == "4-5年").ToList()[0].Zstock,
  857. list4.Count == 0 ? 0 : list4.Where(x => x.Zaging == "4-5年").ToList()[0].Zstock,
  858. list5.Count == 0 ? 0 : list5.Where(x => x.Zaging == "4-5年").ToList()[0].Zstock,
  859. list6.Count == 0 ? 0 : list6.Where(x => x.Zaging == "4-5年").ToList()[0].Zstock);
  860. dt.Rows.Add("5-6年", list1.Count == 0 ? 0 : list1.Where(x => x.Zaging == "5-6年").ToList()[0].Zstock,
  861. list2.Count == 0 ? 0 : list2.Where(x => x.Zaging == "5-6年").ToList()[0].Zstock,
  862. list3.Count == 0 ? 0 : list3.Where(x => x.Zaging == "5-6年").ToList()[0].Zstock,
  863. list4.Count == 0 ? 0 : list4.Where(x => x.Zaging == "5-6年").ToList()[0].Zstock,
  864. list5.Count == 0 ? 0 : list5.Where(x => x.Zaging == "5-6年").ToList()[0].Zstock,
  865. list6.Count == 0 ? 0 : list6.Where(x => x.Zaging == "5-6年").ToList()[0].Zstock);
  866. dt.Rows.Add("6-7年", list1.Count == 0 ? 0 : list1.Where(x => x.Zaging == "6-7年").ToList()[0].Zstock,
  867. list2.Count == 0 ? 0 : list2.Where(x => x.Zaging == "6-7年").ToList()[0].Zstock,
  868. list3.Count == 0 ? 0 : list3.Where(x => x.Zaging == "6-7年").ToList()[0].Zstock,
  869. list4.Count == 0 ? 0 : list4.Where(x => x.Zaging == "6-7年").ToList()[0].Zstock,
  870. list5.Count == 0 ? 0 : list5.Where(x => x.Zaging == "6-7年").ToList()[0].Zstock,
  871. list6.Count == 0 ? 0 : list6.Where(x => x.Zaging == "6-7年").ToList()[0].Zstock);
  872. dt.Rows.Add("7-8年", list1.Count == 0 ? 0 : list1.Where(x => x.Zaging == "7-8年").ToList()[0].Zstock,
  873. list2.Count == 0 ? 0 : list2.Where(x => x.Zaging == "7-8年").ToList()[0].Zstock,
  874. list3.Count == 0 ? 0 : list3.Where(x => x.Zaging == "7-8年").ToList()[0].Zstock,
  875. list4.Count == 0 ? 0 : list4.Where(x => x.Zaging == "7-8年").ToList()[0].Zstock,
  876. list5.Count == 0 ? 0 : list5.Where(x => x.Zaging == "7-8年").ToList()[0].Zstock,
  877. list6.Count == 0 ? 0 : list6.Where(x => x.Zaging == "7-8年").ToList()[0].Zstock);
  878. dt.Rows.Add("8-9年", list1.Count == 0 ? 0 : list1.Where(x => x.Zaging == "8-9年").ToList()[0].Zstock,
  879. list2.Count == 0 ? 0 : list2.Where(x => x.Zaging == "8-9年").ToList()[0].Zstock,
  880. list3.Count == 0 ? 0 : list3.Where(x => x.Zaging == "8-9年").ToList()[0].Zstock,
  881. list4.Count == 0 ? 0 : list4.Where(x => x.Zaging == "8-9年").ToList()[0].Zstock,
  882. list5.Count == 0 ? 0 : list5.Where(x => x.Zaging == "8-9年").ToList()[0].Zstock,
  883. list6.Count == 0 ? 0 : list6.Where(x => x.Zaging == "8-9年").ToList()[0].Zstock);
  884. dt.Rows.Add("9-10年", list1.Count == 0 ? 0 : list1.Where(x => x.Zaging == "9-10年").ToList()[0].Zstock,
  885. list2.Count == 0 ? 0 : list2.Where(x => x.Zaging == "9-10年").ToList()[0].Zstock,
  886. list3.Count == 0 ? 0 : list3.Where(x => x.Zaging == "9-10年").ToList()[0].Zstock,
  887. list4.Count == 0 ? 0 : list4.Where(x => x.Zaging == "9-10年").ToList()[0].Zstock,
  888. list5.Count == 0 ? 0 : list5.Where(x => x.Zaging == "9-10年").ToList()[0].Zstock,
  889. list6.Count == 0 ? 0 : list6.Where(x => x.Zaging == "9-10年").ToList()[0].Zstock);
  890. dt.Rows.Add("10年以上", list1.Count == 0 ? 0 : list1.Where(x => x.Zaging == "10年以上").ToList()[0].Zstock,
  891. list2.Count == 0 ? 0 : list2.Where(x => x.Zaging == "10年以上").ToList()[0].Zstock,
  892. list3.Count == 0 ? 0 : list3.Where(x => x.Zaging == "10年以上").ToList()[0].Zstock,
  893. list4.Count == 0 ? 0 : list4.Where(x => x.Zaging == "10年以上").ToList()[0].Zstock,
  894. list5.Count == 0 ? 0 : list5.Where(x => x.Zaging == "10年以上").ToList()[0].Zstock,
  895. list6.Count == 0 ? 0 : list6.Where(x => x.Zaging == "10年以上").ToList()[0].Zstock);
  896. return dt;
  897. }
  898. //查询193/199/zmm188处理进度
  899. public List<DataTable> GetGridJson_StoreStatus()
  900. {
  901. List<DataTable> dtList = new List<DataTable>();
  902. DataTable dt = new DataTable();
  903. dt.Columns.Add("Month", typeof(string));
  904. dt.Columns.Add("QtyHangCount", typeof(decimal));
  905. dt.Columns.Add("QtyCount", typeof(decimal));
  906. DataTable dt1 = new DataTable();
  907. dt1.Columns.Add("Month", typeof(string));
  908. dt1.Columns.Add("QtyHangCount", typeof(decimal));
  909. dt1.Columns.Add("QtyCount", typeof(decimal));
  910. DataTable dt2 = new DataTable();
  911. dt2.Columns.Add("Month", typeof(string));
  912. dt2.Columns.Add("QtyHangCount", typeof(decimal));
  913. dt2.Columns.Add("QtyCount", typeof(decimal));
  914. GetStoreStatus.ZWMS_WS_HGPJDClient client = new GetStoreStatus.ZWMS_WS_HGPJDClient();
  915. client.ClientCredentials.UserName.UserName = "NWBG";
  916. client.ClientCredentials.UserName.Password = "nwbg321";
  917. List<GetStoreStatus.ZhgpJd> list = new List<GetStoreStatus.ZhgpJd>();
  918. GetStoreStatus.ZwmsWsHgpjdResponse res = client.ZwmsWsHgpjd(new GetStoreStatus.ZwmsWsHgpjd
  919. {
  920. THgjd = list.ToArray()
  921. });
  922. #region 193库位
  923. List<GetStoreStatus.ZhgpJd> list193 = res.THgjd.ToList().Where(x => x.Lgort == "193").ToList();//193库位
  924. foreach (GetStoreStatus.ZhgpJd item in list193)
  925. {
  926. dt.Rows.Add(item.Spmon, item.Zbhgh, item.Zbhgs);
  927. }
  928. dtList.Add(dt);
  929. #endregion
  930. #region 199库位
  931. List<GetStoreStatus.ZhgpJd> list199 = res.THgjd.ToList().Where(x => x.Lgort == "199").ToList();//199库位
  932. foreach (GetStoreStatus.ZhgpJd item in list199)
  933. {
  934. dt1.Rows.Add(item.Spmon, item.Zbhgh, item.Zbhgs);
  935. }
  936. dtList.Add(dt1);
  937. #endregion
  938. #region 188库位
  939. List<GetStoreStatus.ZhgpJd> list188 = res.THgjd.ToList().Where(x => x.Tcode == "ZMM188").ToList();//188库位
  940. foreach (GetStoreStatus.ZhgpJd item in list188)
  941. {
  942. dt2.Rows.Add(item.Spmon, item.Zbhgh, item.Zbhgs);
  943. }
  944. dtList.Add(dt2);
  945. #endregion
  946. return dtList;
  947. }
  948. //查询库存物料周转天数
  949. public DataTable GetGridJson_ItemZzDays()
  950. {
  951. DataTable dt = new DataTable();
  952. GetItemZzDays.ZWMS_SK_KCWLZZTSClient client = new GetItemZzDays.ZWMS_SK_KCWLZZTSClient();
  953. client.ClientCredentials.UserName.UserName = "NWBG";
  954. client.ClientCredentials.UserName.Password = "nwbg321";
  955. dt.Columns.Add("Week", typeof(string));
  956. dt.Columns.Add("Days", typeof(string));
  957. GetItemZzDays.ZwmsSkKcwlzztsResponse res = client.ZwmsSkKcwlzzts(new GetItemZzDays.ZwmsSkKcwlzzts { T_906t1 = new GetItemZzDays.Zmm906t1[] { } });
  958. List<GetItemZzDays.Zmm906t1> list = res.T_906t1.ToList().OrderBy(x => x.Zcycle).ToList();
  959. foreach (GetItemZzDays.Zmm906t1 item in list)
  960. {
  961. dt.Rows.Add(item.Zcycle, item.Zaging);
  962. }
  963. return dt;
  964. }
  965. //发货信息
  966. public DataTable GetSo()
  967. {
  968. List<DbParameter> parameter = new List<DbParameter>();
  969. string SqlText = @"
  970. SELECT DISTINCT a1.CreatedOn ,A1.BusinessDate ,A1.DocNo ,A2.DocLineNo ,A5.Code ,A6.NameCombineName ,
  971. A5.SPECS ,A10.Name ,ISNULL(A2.ShipQtyInvAmount, 0) ,ISNULL(so.HasQuantity, 0) ,ISNULL(A2.ShipQtyInvAmount,0)-isnull(so.HasQuantity, 0) WMS未发数量
  972. from {0}.DBO.SM_Ship A1
  973. LEFT JOIN {0}.dbo.SM_ShipLine A2 ON A2.Ship=A1.ID
  974. LEFT JOIN {0}.dbo.SM_ShipLine_Trl A3 ON A2.ID=A3.ID AND A3.SysMLFlag='zh-CN'
  975. LEFT JOIN {0}.dbo.CBO_ItemMaster A5 ON A2.ItemInfo_ItemID=A5.ID
  976. LEFT JOIN {0}.dbo.CBO_ItemMaster_Trl A6 ON A6.ID = A5.ID AND A6.SysMLFlag='zh-CN'
  977. LEFT JOIN {0}.dbo.CBO_Wh A7 ON A2.WH=A7.ID
  978. LEFT JOIN {0}.dbo.CBO_Wh_Trl A8 ON A8.ID = A7.ID AND A8.SysMLFlag='zh-CN'
  979. LEFT JOIN {0}.dbo.Base_UOM A9 ON A2.PriceUOM=A9.ID
  980. LEFT JOIN {0}.dbo.Base_UOM_Trl A10 ON A10.ID = A9.ID AND A10.SysMLFlag='zh-CN'
  981. LEFT JOIN ICSSODispatch so on A1.DocNo=so.DispatchCode AND A2.DocLineNo=so.DispatchRow
  982. where 1=1 AND ISNULL(A2.WH,'')!=''";
  983. if (!string.IsNullOrWhiteSpace(StratTime))
  984. {
  985. SqlText += " and a1.CreatedOn>'" + StratTime + "'";
  986. }
  987. if (!string.IsNullOrWhiteSpace(EndTime))
  988. {
  989. SqlText += " and a1.CreatedOn<'" + EndTime + "'";
  990. }
  991. if (string.IsNullOrWhiteSpace(StratTime) && string.IsNullOrWhiteSpace(EndTime) && !string.IsNullOrWhiteSpace(advDays))
  992. {
  993. SqlText += " and a1.CreatedOn>CAST(CAST(DATEADD(day, -" + advDays + ", GETDATE()) as date) as varchar(10)) + ' 00:00:00'";
  994. }
  995. if (string.IsNullOrWhiteSpace(StratTime) && string.IsNullOrWhiteSpace(EndTime) && string.IsNullOrWhiteSpace(advDays))
  996. {
  997. SqlText += " and a1.CreatedOn>CAST(CAST(GETDATE() as date) as varchar(10)) + ' 00:00:00'";
  998. }
  999. SqlText += @"order by a1.CreatedOn ";
  1000. SqlText = string.Format(SqlText, ERPName, workpoint);
  1001. DataTable dt = Repository().GetDataTableBySql_Other(SqlText, "WMSconnstr", null);
  1002. return dt;
  1003. }
  1004. //工单欠料信息
  1005. public DataTable GetOwe()
  1006. {
  1007. List<DbParameter> parameter = new List<DbParameter>();
  1008. string SqlText = @" SELECT a.DocNo U9工单,a.startDate 开工日期,BItem.Code 母件料号,BItem.Name 母件名称,BItem.SPECS 母件规格,A.ProductQty 工单数量,
  1009. UOM.Name ,cBItem.Code ,cBItem.Name ,cBItem.SPECS ,--b.id,c.id,d.MO,
  1010. b.ActualReqQty,c.IssuedQty,d.qty,
  1011. ISNULL(b.ActualReqQty, 0)-ISNULL(c.IssuedQty, 0)+ISNULL(d.qty, 0) as
  1012. from {0}.DBO.MO_MO a
  1013. LEFT JOIN {0}.DBO.CBO_ItemMaster BItem on BItem.ID=a.ItemMaster
  1014. LEFT JOIN {0}.DBO.Base_UOM_Trl UOM ON UOM.ID = BItem.InventoryUOM
  1015. LEFT JOIN {0}.DBO.MO_MoPickList b on a.ID=B.MO
  1016. LEFT JOIN {0}.DBO.CBO_ItemMaster cBItem on b.ItemMaster=cBItem.ID
  1017. LEFT JOIN {0}.DBO.MO_IssueDocLine c on a.ID=c.MO and b.ItemMaster=c.Item
  1018. LEFT JOIN (SELECT b.MO,b.IssuedQty as qty,b.Item from {0}.DBO.mo_IssueDoc a
  1019. INNER JOIN {0}.DBO.MO_IssueDocLine b on a.ID=b.IssueDoc
  1020. INNER JOIN {0}.DBO.MO_IssueDocLine c on b.SourceIssueDocLine=c.ID
  1021. where a.IssueType='1' ) d on a.ID=d.MO and b.ItemMaster=d.Item
  1022. where a.DocState<>3 ";
  1023. //if (!string.IsNullOrWhiteSpace(StratTime))
  1024. //{
  1025. // SqlText += " and a.CreatedOn>'" + StratTime + "'";
  1026. //}
  1027. //if (!string.IsNullOrWhiteSpace(EndTime))
  1028. //{
  1029. // SqlText += " and a.CreatedOn<'" + EndTime + "'";
  1030. //}
  1031. if (!string.IsNullOrWhiteSpace(advDays))
  1032. {
  1033. SqlText += @" and a.startDate>CAST(CAST(DATEADD(day, -" + advDays + @", GETDATE()) as date) as varchar(10)) + ' 00:00:00'
  1034. and a.startDate<=CAST(CAST(GETDATE() as date) as varchar(10)) + ' 23:59:59'";
  1035. }
  1036. if (string.IsNullOrWhiteSpace(StratTime) && string.IsNullOrWhiteSpace(EndTime) && string.IsNullOrWhiteSpace(advDays))
  1037. {
  1038. SqlText += @" and a.startDate>CAST(CAST(GETDATE() as date) as varchar(10)) + ' 00:00:00'
  1039. and a.startDate<=CAST(CAST(GETDATE() as date) as varchar(10)) + ' 23:59:59'";
  1040. }
  1041. SqlText += @"order by a.startDate ";
  1042. SqlText = string.Format(SqlText, ERPName, workpoint);
  1043. DataTable dt = Repository().GetDataTableBySql_Other(SqlText, "WMSconnstr", null);
  1044. return dt;
  1045. }
  1046. public static void WriteLogFile(string input, string txtName)
  1047. {
  1048. try
  1049. {
  1050. string logAdress = "C:\\看板日志" + "\\";
  1051. if (!System.IO.Directory.Exists(logAdress))
  1052. {
  1053. System.IO.Directory.CreateDirectory(logAdress);//不存在就创建目录
  1054. }
  1055. string adress = logAdress + txtName;
  1056. if (!System.IO.Directory.Exists(adress))
  1057. {
  1058. System.IO.Directory.CreateDirectory(adress);//不存在就创建目录
  1059. }
  1060. // string logAdress = ConfigurationManager.AppSettings["logAdress"].ToString();
  1061. /**/
  1062. ///指定日志文件的目录
  1063. string fname = adress + "\\" + "log" + DateTime.Now.ToString("yy-MM-dd") + ".txt";
  1064. /**/
  1065. ///定义文件信息对象
  1066. FileInfo finfo = new FileInfo(fname);
  1067. if (!finfo.Exists)
  1068. {
  1069. FileStream fs;
  1070. fs = File.Create(fname);
  1071. fs.Close();
  1072. finfo = new FileInfo(fname);
  1073. }
  1074. /**/
  1075. ///判断文件是否存在以及是否大于2K
  1076. if (finfo.Length > 1024 * 1024 * 10)
  1077. {
  1078. /**/
  1079. ///文件超过10MB则重命名
  1080. File.Move(logAdress + "\\Log\\" + txtName + ".txt", Directory.GetCurrentDirectory() + DateTime.Now.TimeOfDay + "\\Log\\" + txtName + ".txt");
  1081. /**/
  1082. ///删除该文件
  1083. //finfo.Delete();
  1084. }
  1085. //finfo.AppendText();
  1086. /**/
  1087. ///创建只写文件流
  1088. using (FileStream fs = finfo.OpenWrite())
  1089. {
  1090. /**/
  1091. ///根据上面创建的文件流创建写数据流
  1092. StreamWriter w = new StreamWriter(fs);
  1093. /**/
  1094. ///设置写数据流的起始位置为文件流的末尾
  1095. ///设置写数据流的起始位置为文件流的末尾
  1096. w.BaseStream.Seek(0, SeekOrigin.End);
  1097. w.WriteLine("*****************Start*****************");
  1098. w.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
  1099. /**/
  1100. ///写入当前系统时间并换行
  1101. /**/
  1102. ///写入日志内容并换行
  1103. w.WriteLine(input);
  1104. /**/
  1105. ///写入------------------------------------“并换行
  1106. w.WriteLine("------------------END------------------------");
  1107. /**/
  1108. ///清空缓冲区内容,并把缓冲区内容写入基础流
  1109. w.Flush();
  1110. /**/
  1111. ///关闭写数据流
  1112. w.Close();
  1113. }
  1114. }
  1115. catch (Exception ex)
  1116. { }
  1117. }
  1118. }
  1119. }