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

472 lines
24 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year 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. namespace NFine.Application.WMS
  13. {
  14. public class WatchPanelApp : RepositoryFactory<ModuleEntity>
  15. {
  16. string workpoint = ConfigurationManager.ConnectionStrings["WorkPointCode"].ConnectionString;
  17. private static string U9IP = ConfigurationManager.ConnectionStrings["U9connstr"].ConnectionString;
  18. private static string StratTimecfg = ConfigurationManager.ConnectionStrings["StratTime"].ConnectionString;
  19. private static string EndTimecfg = ConfigurationManager.ConnectionStrings["EndTime"].ConnectionString;
  20. private static string advDays = ConfigurationManager.ConnectionStrings["advDays"].ConnectionString;
  21. private static string workPoint = ConfigurationManager.ConnectionStrings["WorkPoint"].ConnectionString;
  22. string StratTime = DateTime.Parse(DateTime.Now.AddDays(-1).ToString()).ToString("yyyy-MM-dd") + ' ' + StratTimecfg;
  23. string EndTime = DateTime.Parse(DateTime.Now.ToString()).ToString("yyyy-MM-dd") + ' ' + EndTimecfg;
  24. //private string ERPName = U9IP.Substring(U9IP.IndexOf("Server=") + 7, 9) + "." + U9IP.Substring(U9IP.IndexOf("Catalog=") + 8, 7);
  25. //string dsaq = ConfigurationManager.ConnectionStrings["advDays"].ConnectionString;
  26. private static string conbegin = "Data Source=";
  27. private static int end = U9IP.IndexOf(";Uid=");
  28. private static string ERPName = "[" + U9IP.Substring(conbegin.Length, end - conbegin.Length).Replace(";Database=", "].");
  29. private static string ERPName1 = ERPName.Split('.')[ERPName.Split('.').Length - 1];
  30. string EndTime2 = "";
  31. //到货明细
  32. public DataTable GetList1(string queryJson, ref Pagination jqgridparam)
  33. {
  34. var queryParam = queryJson.ToJObject();
  35. OperatorModel oo = NFine.Code.OperatorProvider.Provider.GetCurrent();
  36. List<DbParameter> parameter = new List<DbParameter>();
  37. string SqlText = @"
  38. select * from (
  39. SELECT *,
  40. - ,
  41. CASE WHEN -> 0 THEN '' WHEN > 0 THEN '' ELSE '' END
  42. FROM (
  43. SELECT dd.orderno ,dd.itemcode ,dd.planqty ,inv.invname ,
  44. isnull((
  45. SELECT SUM (lotqty)
  46. FROM icsitemlot lot
  47. WHERE lot.TransNO=dd.ReceiptNO AND lot.TransLine=dd.ReceiptLine
  48. AND isnull(IQCStatus,'') !='' AND cc.workpoint=lot.workpoint),0) ,
  49. isnull((
  50. SELECT SUM (lotqty)
  51. FROM icsitemlot lot
  52. WHERE lot.TransNO=dd.ReceiptNO AND lot.TransLine=dd.ReceiptLine
  53. AND isnull(IQCStatus,'') !='' AND cc.workpoint=lot.workpoint
  54. AND NOT EXISTS (
  55. SELECT 1 FROM ICSWareHouseLotInfo info
  56. WHERE info.lotno=lot.lotno AND info.workpoint=lot.workpoint)),0)
  57. FROM ICSINVReceipt cc
  58. LEFT JOIN ICSINVReceiptDetail dd ON cc.ReceiptNO=dd.ReceiptNO AND dd.workpoint=cc.workpoint
  59. LEFT JOIN ICSINVENTORY inv ON inv.invcode=dd.itemcode AND dd.workpoint=inv.workpoint
  60. WHERE cc.mtime >=DATEADD(week, -1,getdate())
  61. and cc.workpoint='" + workpoint + @"'
  62. ) ff ) gg
  63. ";
  64. DataTable dt = Repository().FindTablePageBySql_Other(SqlText, "WMSconnstr", parameter.ToArray(), ref jqgridparam);
  65. return dt;
  66. }
  67. //来料不合格明细
  68. public DataTable GetList2(string queryJson, ref Pagination jqgridparam)
  69. {
  70. var queryParam = queryJson.ToJObject();
  71. OperatorModel oo = NFine.Code.OperatorProvider.Provider.GetCurrent();
  72. List<DbParameter> parameter = new List<DbParameter>();
  73. string SqlText = @"
  74. select * from (
  75. SELECT cc.receiptNo ,dd.orderno ,dd.itemcode , inv.invname ,
  76. sum(lot.lotqty) ,kk.CKITEMDESC
  77. FROM ICSINVReceipt cc
  78. LEFT JOIN ICSINVReceiptDetail dd ON cc.ReceiptNO=dd.ReceiptNO AND dd.workpoint=cc.workpoint
  79. LEFT JOIN ICSINVENTORY inv ON inv.invcode=dd.itemcode AND dd.workpoint=inv.workpoint
  80. left join icsitemlot lot on lot.TransNO=dd.ReceiptNO AND lot.TransLine=dd.ReceiptLine
  81. AND cc.workpoint=lot.workpoint
  82. left join (select * from (select ROW_NUMBER()over(partition by LOTNO order by mtime desc,id ) rowId,lotno ,errdata ,CKITEMDESC
  83. from ICSIQCErrList ck where workpoint='" + workpoint + @"' ) as AuctionRecords
  84. where rowId=1) kk on kk.lotno=lot.lotno
  85. WHERE 1=1
  86. and cc.mtime >=DATEADD(MONTH, -1,getdate())
  87. and kk.errdata=''
  88. and cc.workpoint='" + workpoint + @"'
  89. group by cc.receiptNo ,dd.orderno ,dd.itemcode , inv.invname ,kk.CKITEMDESC ) jj
  90. ";
  91. DataTable dt = Repository().FindTablePageBySql_Other(SqlText, "WMSconnstr", parameter.ToArray(), ref jqgridparam);
  92. return dt;
  93. }
  94. public DataTable GetWIPDATA()
  95. {
  96. List<DbParameter> parameter = new List<DbParameter>();
  97. string SqlText = @"
  98. select distinct mo.mocode ,mo.moseq ,mo.itemcode ,inv.invname ,
  99. mo.moplanqty ,sim.MUSERName ,sim.opcode
  100. ,row_number() over (partition by mo.mocode ,mo.moseq , sim.MUSERName ,sim.opcode order by sim.mtime desc,sim.id desc) rn
  101. from icsmo mo
  102. left join ICSITEMLot lot on lot.transno =mo.mocode and lot.TransLine=mo.moseq and lot.workpoint =mo.workpoint
  103. left join ICSLOTSIMULATION sim on mo.WorkPoint=sim.WorkPoint and sim.lotno=lot.lotno
  104. left join ICSINVENTORY inv on inv.invcode=mo.itemcode and inv.workpoint=mo.workpoint
  105. where sim.mtime>CAST(CAST(GETDATE() as date) as varchar(10)) + ' 00:00:00'
  106. and mo.WorkPoint='" + workpoint + @"'
  107. ";
  108. DataTable dt = Repository().GetDataTableBySql_Other(SqlText, "WMSconnstr", null);
  109. //测试
  110. for (int i = 0; i < 20; i++)
  111. {
  112. DataRow newRow;
  113. newRow = dt.NewRow();
  114. newRow["生产订单号"] = "MO-0001"+i.ToString();
  115. newRow["行号"] = "22";
  116. dt.Rows.Add(newRow);
  117. }
  118. return dt;
  119. }
  120. //车间人员信息
  121. public DataTable GetWIPUser()
  122. {
  123. List<DbParameter> parameter = new List<DbParameter>();
  124. string SqlText = @"
  125. select distinct mo.mocode ,mo.moseq ,mo.itemcode ,inv.invname ,
  126. mo.moplanqty ,sim.MUSERName ,sim.opcode
  127. ,row_number() over (partition by mo.mocode ,mo.moseq , sim.MUSERName ,sim.opcode order by sim.mtime desc,sim.id desc) rn
  128. from icsmo mo
  129. left join ICSITEMLot lot on lot.transno =mo.mocode and lot.TransLine=mo.moseq and lot.workpoint =mo.workpoint
  130. left join ICSLOTSIMULATION sim on mo.WorkPoint=sim.WorkPoint and sim.lotno=lot.lotno
  131. left join ICSINVENTORY inv on inv.invcode=mo.itemcode and inv.workpoint=mo.workpoint
  132. where sim.mtime>CAST(CAST(GETDATE() as date) as varchar(10)) + ' 00:00:00'
  133. and mo.WorkPoint='" + workpoint + @"'
  134. ";
  135. DataTable dt = Repository().GetDataTableBySql_Other(SqlText, "WMSconnstr", null);
  136. //测试
  137. for (int i = 0; i < 20; i++)
  138. {
  139. DataRow newRow;
  140. newRow = dt.NewRow();
  141. newRow["生产订单号"] = "MO-0001" + i.ToString();
  142. newRow["行号"] = "22";
  143. dt.Rows.Add(newRow);
  144. }
  145. return dt;
  146. }
  147. //收料信息
  148. public DataTable GetWIPRCV()
  149. {
  150. List<DbParameter> parameter = new List<DbParameter>();
  151. string SqlText = @"
  152. select B.CreatedOn ,A.DescFlexField_PrivateDescSeg1 ,A.DocNO ,B.DocLineNo
  153. ,ISNULL(B.QCBillNo,'') AS ,CASE WHEN A.Status='0' THEN '' WHEN A.Status='2' THEN '' WHEN A.Status='3' THEN '' ELSE '' END AS
  154. ,A.Supplier_ShortName ,A.DescFlexField_PubDescSeg13 ,B.ItemInfo_ItemCode
  155. ,B.ItemInfo_ItemName ,C.INVSTD ,C.INVUOM ,B.ArriveQtyTU ,B.QualifiedQtyTU
  156. ,case when B.Status='5' then B.QualifiedQtyTU When B.Status='5' AND ISNULL(B.QCBillNo,'')='' then B.QualifiedQtyTU ELSE 0 end as U9已上架数量
  157. ,ISNULL(F.QTY,0) AS WMS已上架数量,B.ArriveQtyTU-ISNULL(F.QTY,0) AS WMS未上架数量,E.Name
  158. from
  159. {0}.DBO.PM_Receivement A
  160. LEFT JOIN (SELECT a.ID,b.CreatedOn,b.DocLineNo,b.QCBillNo,b.ItemInfo_ItemCode,b.ItemInfo_ItemName,b.ItemInfo_ItemID,b.WhMan
  161. ,sum(b.ArriveQtyTU) ArriveQtyTU,SUM(b.QualifiedQtyTU) QualifiedQtyTU,b.Status
  162. from {0}.DBO.PM_Receivement a LEFT JOIN {0}.DBO.PM_RcvLine b on b.Receivement=a.ID
  163. where (SplitFlag=0 OR SplitFlag=2)
  164. GROUP BY a.ID,b.CreatedOn,b.DocLineNo,b.QCBillNo,b.ItemInfo_ItemCode,b.ItemInfo_ItemName,b.ItemInfo_ItemID,b.WhMan,b.Status ) B
  165. ON B.ID=A.ID
  166. LEFT JOIN ICSINVENTORY C on C.ID=B.ItemInfo_ItemID
  167. LEFT JOIN {0}.DBO.CBO_Operators_trl E on E.ID=B.WhMan
  168. LEFT JOIN (SELECT ASN.STNO,ASN.ITEMCODE,SUM(ISNULL(WHLOT.LotQty,0)) AS QTY FROM ICSASNDETAIL ASN
  169. LEFT JOIN ICSITEMLot LOT ON LOT.LotNO=ASN.LOTNO AND LOT.WorkPoint=ASN.WorkPoint
  170. LEFT JOIN ICSWareHouseLotInfo WHLOT ON WHLOT.LotNO=LOT.LotNO AND WHLOT.WorkPoint=LOT.WorkPoint
  171. GROUP BY ASN.STNO,ASN.ITEMCODE) F ON F.STNO=A.DescFlexField_PrivateDescSeg1 AND F.ITEMCODE=B.ItemInfo_ItemCode
  172. where 1=1 and B.CreatedOn>CAST(CAST(GETDATE() as date) as varchar(10)) + ' 00:00:00'
  173. order by B.CreatedOn";
  174. SqlText = string.Format(SqlText, ERPName, workpoint);
  175. DataTable dt = Repository().GetDataTableBySql_Other(SqlText, "WMSconnstr", null);
  176. return dt;
  177. }
  178. //收料图表
  179. public DataTable GetWIPRCVChart()
  180. {
  181. List<DbParameter> parameter = new List<DbParameter>();
  182. string SqlText = @"
  183. SELECT top 1 (SELECT COUNT(ID) FROM {0}.DBO.PM_RcvLine
  184. where (SplitFlag=0 OR SplitFlag=2)
  185. and CreatedOn>CAST(CAST(GETDATE() as date) as varchar(10)) + ' 00:00:00' and status<>'5') as U9dk,
  186. (SELECT COUNT(ID) FROM {0}.DBO.PM_RcvLine
  187. where (SplitFlag=0 OR SplitFlag=2)
  188. and CreatedOn>CAST(CAST(GETDATE() as date) as varchar(10)) + ' 00:00:00' and status='5') as U9gb
  189. from {0}.DBO.PM_RcvLine";
  190. SqlText = string.Format(SqlText, ERPName, workpoint);
  191. DataTable dt = Repository().GetDataTableBySql_Other(SqlText, "WMSconnstr", null);
  192. return dt;
  193. }
  194. //发料信息
  195. public DataTable GetMaterialPick()
  196. {
  197. List<DbParameter> parameter = new List<DbParameter>();
  198. string SqlText = $@" SELECT
  199. a.ApplyCode,
  200. A.Sequence,
  201. --a.SAPSequence,
  202. a.InvCode,
  203. c.LotNo,
  204. c.Quantity,
  205. e.StartLocation,
  206. e.EndLocation
  207. -- e.TaskCode
  208. FROM
  209. ICSMOApply a
  210. -- INNER JOIN ICSContainerReceiptsNumber b ON a.ApplyCode= b.TransCode
  211. INNER JOIN ICSWareHouseLotInfoLog c ON a.ApplyCode= c.TransCode
  212. AND
  213. c.TransType= '15'
  214. AND a.Sequence= c.TransSequence
  215. INNER JOIN ( SELECT DISTINCT e.StartLocation,e.EndLocation FROM
  216. 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
  217. WHERE
  218. a.WorkPoint in({workPoint})";
  219. //if (!string.IsNullOrWhiteSpace(StratTime))
  220. //{
  221. // SqlText += " and a.CreatedOn>'" + StratTime + "'";
  222. //}
  223. //if (!string.IsNullOrWhiteSpace(EndTime))
  224. //{
  225. // SqlText += " and a.CreatedOn<'" + EndTime + "'";
  226. //}
  227. //if (!string.IsNullOrWhiteSpace(advDays))
  228. //{
  229. // SqlText += @" and a.MTIME>CAST(CAST(DATEADD(day, -" + advDays + @", GETDATE()) as date) as varchar(10)) + ' 00:00:00'
  230. // and a.MTIME<=CAST(CAST(GETDATE() as date) as varchar(10)) + ' 23:59:59'";
  231. //}
  232. //if (string.IsNullOrWhiteSpace(StratTime) && string.IsNullOrWhiteSpace(EndTime) && string.IsNullOrWhiteSpace(advDays))
  233. //{
  234. // SqlText += @" and a.MTIME>CAST(CAST(GETDATE() as date) as varchar(10)) + ' 00:00:00'
  235. // and a.MTIME<=CAST(CAST(GETDATE() as date) as varchar(10)) + ' 23:59:59'";
  236. //}
  237. SqlText += @"order by a.MTIME ";
  238. //SqlText = string.Format(SqlText, ERPName, workpoint);
  239. DataTable dt = Repository().GetDataTableBySql_Other(SqlText, "WMSconnstr", null);
  240. return dt;
  241. }
  242. //发料图表
  243. public DataTable GetMaterialPickChart()
  244. {
  245. List<DbParameter> parameter = new List<DbParameter>();
  246. string SqlText = @" SELECT top 1
  247. (SELECT COUNT(*) from {0}.DBO.MO_MO a
  248. where a.CreatedOn>CAST(CAST(DATEADD(day, -{2}, GETDATE()) as date) as varchar(10)) + ' 00:00:00')-
  249. (SELECT COUNT(*) from {0}.DBO.MO_MO a
  250. LEFT JOIN (SELECT DISTINCT COUNT(VouchRow) ,MOCode from ICSMaterialPick GROUP BY MOCode) b on a.DocNo=b.MOCode
  251. LEFT JOIN (SELECT DISTINCT COUNT(VouchRow) ,MOCode from ICSMaterialPick where Quantity<=HasQuantity GROUP BY MOCode) c on a.DocNo=c.MOCode
  252. where a.CreatedOn>CAST(CAST(DATEADD(day, -{2}, GETDATE()) as date) as varchar(10)) + ' 00:00:00' and b.=c.)
  253. as ,
  254. (SELECT COUNT(*) from {0}.DBO.MO_MO a
  255. LEFT JOIN (SELECT DISTINCT COUNT(VouchRow) ,MOCode from ICSMaterialPick GROUP BY MOCode) b on a.DocNo=b.MOCode
  256. LEFT JOIN (SELECT DISTINCT COUNT(VouchRow) ,MOCode from ICSMaterialPick where Quantity<=HasQuantity GROUP BY MOCode) c on a.DocNo=c.MOCode
  257. where a.CreatedOn>CAST(CAST(DATEADD(day, -{2}, GETDATE()) as date) as varchar(10)) + ' 00:00:00' and b.=c.) as
  258. from {0}.DBO.MO_MO";
  259. SqlText = string.Format(SqlText, ERPName, workpoint, advDays);
  260. DataTable dt = Repository().GetDataTableBySql_Other(SqlText, "WMSconnstr", null);
  261. return dt;
  262. }
  263. //发货信息
  264. public DataTable GetSo()
  265. {
  266. List<DbParameter> parameter = new List<DbParameter>();
  267. string SqlText = @"
  268. SELECT DISTINCT a1.CreatedOn ,A1.BusinessDate ,A1.DocNo ,A2.DocLineNo ,A5.Code ,A6.NameCombineName ,
  269. A5.SPECS ,A10.Name ,ISNULL(A2.ShipQtyInvAmount, 0) ,ISNULL(so.HasQuantity, 0) ,ISNULL(A2.ShipQtyInvAmount,0)-isnull(so.HasQuantity, 0) WMS未发数量
  270. from {0}.DBO.SM_Ship A1
  271. LEFT JOIN {0}.dbo.SM_ShipLine A2 ON A2.Ship=A1.ID
  272. LEFT JOIN {0}.dbo.SM_ShipLine_Trl A3 ON A2.ID=A3.ID AND A3.SysMLFlag='zh-CN'
  273. LEFT JOIN {0}.dbo.CBO_ItemMaster A5 ON A2.ItemInfo_ItemID=A5.ID
  274. LEFT JOIN {0}.dbo.CBO_ItemMaster_Trl A6 ON A6.ID = A5.ID AND A6.SysMLFlag='zh-CN'
  275. LEFT JOIN {0}.dbo.CBO_Wh A7 ON A2.WH=A7.ID
  276. LEFT JOIN {0}.dbo.CBO_Wh_Trl A8 ON A8.ID = A7.ID AND A8.SysMLFlag='zh-CN'
  277. LEFT JOIN {0}.dbo.Base_UOM A9 ON A2.PriceUOM=A9.ID
  278. LEFT JOIN {0}.dbo.Base_UOM_Trl A10 ON A10.ID = A9.ID AND A10.SysMLFlag='zh-CN'
  279. LEFT JOIN ICSSODispatch so on A1.DocNo=so.DispatchCode AND A2.DocLineNo=so.DispatchRow
  280. where 1=1 AND ISNULL(A2.WH,'')!=''";
  281. if (!string.IsNullOrWhiteSpace(StratTime))
  282. {
  283. SqlText += " and a1.CreatedOn>'" + StratTime + "'";
  284. }
  285. if (!string.IsNullOrWhiteSpace(EndTime))
  286. {
  287. SqlText += " and a1.CreatedOn<'" + EndTime + "'";
  288. }
  289. if (string.IsNullOrWhiteSpace(StratTime) && string.IsNullOrWhiteSpace(EndTime) && !string.IsNullOrWhiteSpace(advDays))
  290. {
  291. SqlText += " and a1.CreatedOn>CAST(CAST(DATEADD(day, -" + advDays + ", GETDATE()) as date) as varchar(10)) + ' 00:00:00'";
  292. }
  293. if (string.IsNullOrWhiteSpace(StratTime) && string.IsNullOrWhiteSpace(EndTime) && string.IsNullOrWhiteSpace(advDays))
  294. {
  295. SqlText += " and a1.CreatedOn>CAST(CAST(GETDATE() as date) as varchar(10)) + ' 00:00:00'";
  296. }
  297. SqlText += @"order by a1.CreatedOn ";
  298. SqlText = string.Format(SqlText, ERPName, workpoint);
  299. DataTable dt = Repository().GetDataTableBySql_Other(SqlText, "WMSconnstr", null);
  300. return dt;
  301. }
  302. //工单欠料信息
  303. public DataTable GetOwe()
  304. {
  305. List<DbParameter> parameter = new List<DbParameter>();
  306. string SqlText = @" SELECT a.DocNo U9工单,a.startDate 开工日期,BItem.Code 母件料号,BItem.Name 母件名称,BItem.SPECS 母件规格,A.ProductQty 工单数量,
  307. UOM.Name ,cBItem.Code ,cBItem.Name ,cBItem.SPECS ,--b.id,c.id,d.MO,
  308. b.ActualReqQty,c.IssuedQty,d.qty,
  309. ISNULL(b.ActualReqQty, 0)-ISNULL(c.IssuedQty, 0)+ISNULL(d.qty, 0) as
  310. from {0}.DBO.MO_MO a
  311. LEFT JOIN {0}.DBO.CBO_ItemMaster BItem on BItem.ID=a.ItemMaster
  312. LEFT JOIN {0}.DBO.Base_UOM_Trl UOM ON UOM.ID = BItem.InventoryUOM
  313. LEFT JOIN {0}.DBO.MO_MoPickList b on a.ID=B.MO
  314. LEFT JOIN {0}.DBO.CBO_ItemMaster cBItem on b.ItemMaster=cBItem.ID
  315. LEFT JOIN {0}.DBO.MO_IssueDocLine c on a.ID=c.MO and b.ItemMaster=c.Item
  316. LEFT JOIN (SELECT b.MO,b.IssuedQty as qty,b.Item from {0}.DBO.mo_IssueDoc a
  317. INNER JOIN {0}.DBO.MO_IssueDocLine b on a.ID=b.IssueDoc
  318. INNER JOIN {0}.DBO.MO_IssueDocLine c on b.SourceIssueDocLine=c.ID
  319. where a.IssueType='1' ) d on a.ID=d.MO and b.ItemMaster=d.Item
  320. where a.DocState<>3 ";
  321. //if (!string.IsNullOrWhiteSpace(StratTime))
  322. //{
  323. // SqlText += " and a.CreatedOn>'" + StratTime + "'";
  324. //}
  325. //if (!string.IsNullOrWhiteSpace(EndTime))
  326. //{
  327. // SqlText += " and a.CreatedOn<'" + EndTime + "'";
  328. //}
  329. if (!string.IsNullOrWhiteSpace(advDays))
  330. {
  331. SqlText += @" and a.startDate>CAST(CAST(DATEADD(day, -" + advDays + @", GETDATE()) as date) as varchar(10)) + ' 00:00:00'
  332. and a.startDate<=CAST(CAST(GETDATE() as date) as varchar(10)) + ' 23:59:59'";
  333. }
  334. if (string.IsNullOrWhiteSpace(StratTime) && string.IsNullOrWhiteSpace(EndTime) && string.IsNullOrWhiteSpace(advDays))
  335. {
  336. SqlText += @" and a.startDate>CAST(CAST(GETDATE() as date) as varchar(10)) + ' 00:00:00'
  337. and a.startDate<=CAST(CAST(GETDATE() as date) as varchar(10)) + ' 23:59:59'";
  338. }
  339. SqlText += @"order by a.startDate ";
  340. SqlText = string.Format(SqlText, ERPName, workpoint);
  341. DataTable dt = Repository().GetDataTableBySql_Other(SqlText, "WMSconnstr", null);
  342. return dt;
  343. }
  344. public static void WriteLogFile(string input, string txtName)
  345. {
  346. try
  347. {
  348. string logAdress = "C:\\看板日志" + "\\";
  349. if (!System.IO.Directory.Exists(logAdress))
  350. {
  351. System.IO.Directory.CreateDirectory(logAdress);//不存在就创建目录
  352. }
  353. string adress = logAdress + txtName;
  354. if (!System.IO.Directory.Exists(adress))
  355. {
  356. System.IO.Directory.CreateDirectory(adress);//不存在就创建目录
  357. }
  358. // string logAdress = ConfigurationManager.AppSettings["logAdress"].ToString();
  359. /**/
  360. ///指定日志文件的目录
  361. string fname = adress + "\\" + "log" + DateTime.Now.ToString("yy-MM-dd") + ".txt";
  362. /**/
  363. ///定义文件信息对象
  364. FileInfo finfo = new FileInfo(fname);
  365. if (!finfo.Exists)
  366. {
  367. FileStream fs;
  368. fs = File.Create(fname);
  369. fs.Close();
  370. finfo = new FileInfo(fname);
  371. }
  372. /**/
  373. ///判断文件是否存在以及是否大于2K
  374. if (finfo.Length > 1024 * 1024 * 10)
  375. {
  376. /**/
  377. ///文件超过10MB则重命名
  378. File.Move(logAdress + "\\Log\\" + txtName + ".txt", Directory.GetCurrentDirectory() + DateTime.Now.TimeOfDay + "\\Log\\" + txtName + ".txt");
  379. /**/
  380. ///删除该文件
  381. //finfo.Delete();
  382. }
  383. //finfo.AppendText();
  384. /**/
  385. ///创建只写文件流
  386. using (FileStream fs = finfo.OpenWrite())
  387. {
  388. /**/
  389. ///根据上面创建的文件流创建写数据流
  390. StreamWriter w = new StreamWriter(fs);
  391. /**/
  392. ///设置写数据流的起始位置为文件流的末尾
  393. ///设置写数据流的起始位置为文件流的末尾
  394. w.BaseStream.Seek(0, SeekOrigin.End);
  395. w.WriteLine("*****************Start*****************");
  396. w.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
  397. /**/
  398. ///写入当前系统时间并换行
  399. /**/
  400. ///写入日志内容并换行
  401. w.WriteLine(input);
  402. /**/
  403. ///写入------------------------------------“并换行
  404. w.WriteLine("------------------END------------------------");
  405. /**/
  406. ///清空缓冲区内容,并把缓冲区内容写入基础流
  407. w.Flush();
  408. /**/
  409. ///关闭写数据流
  410. w.Close();
  411. }
  412. }
  413. catch (Exception ex)
  414. { }
  415. }
  416. }
  417. }