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

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