Terminal.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652
  1. using Terminal;
  2. using DatabaseDLL;
  3. using System.Collections.Generic;
  4. using System.Threading.Tasks;
  5. using PLCS7;
  6. using System;
  7. using System.Text;
  8. using MySql.Data.MySqlClient;
  9. using System.Threading;
  10. namespace Terminal
  11. {
  12. public class Terminal : ITerminalDisplay
  13. {
  14. public static List<TerminalStru> terminalInfo = new List<PLCS7.TerminalStru>();
  15. public static Dictionary<int, string> idLicMap = new Dictionary<int, string>();
  16. public static bool isClosing = false;
  17. public void FeeCal()
  18. {
  19. }
  20. public void GetTerminalState()
  21. {
  22. }
  23. public List<object> GetParkingRecords()
  24. {
  25. return null;
  26. }
  27. public List<object> GetOrderRecords()
  28. {
  29. return null;
  30. }
  31. private object SearchPaymentScheme()
  32. {
  33. return null;
  34. }
  35. private void UpdateParkingRecords(int Object)
  36. {
  37. }
  38. /// <summary>
  39. /// 从终端结构体中获得车牌号
  40. /// </summary>
  41. /// <param name="ts"></param>
  42. /// <returns></returns>
  43. private string GetLicenseFromTerm(TerminalStru ts)
  44. {
  45. string header = Encoding.ASCII.GetString(BitConverter.GetBytes(ts.licenseCodeB));
  46. string identityA = Encoding.ASCII.GetString(BitConverter.GetBytes(ts.licenseCodeC));
  47. byte[] bytes = BitConverter.GetBytes(ts.licenseCodeD);
  48. List<byte> newBytes = new List<byte>();
  49. for (int i = 0; i < bytes.Length; i++)
  50. {
  51. if (bytes[i] != 0x00) { newBytes.Add(bytes[i]); }
  52. }
  53. string identityB = Encoding.ASCII.GetString(newBytes.ToArray());
  54. return header + identityA + identityB;
  55. }
  56. /// <summary>
  57. /// 更新所有车位信息
  58. /// </summary>
  59. private void UpdateAllParkingSpace()
  60. {
  61. string findParkingSpace = "select parkingSpaceID from parkingspace;";
  62. MySqlDataReader reader = Monitor.Monitor.localDBOper.Query(findParkingSpace);
  63. HashSet<int> recordsIDSet = new HashSet<int>();
  64. if (reader != null)
  65. {
  66. while (reader.Read())
  67. {
  68. if (reader.HasRows)
  69. {
  70. recordsIDSet.Add(reader.GetInt32("parkingSpaceID"));
  71. }
  72. }
  73. }
  74. List<string> updateSpaceList = new List<string>();
  75. List<string> insertSpaceList = new List<string>();
  76. string updateParkingSpace = "";
  77. string insertParkingSpace = "";
  78. for (int i = 0; i < Monitor.Monitor.parkingSpaceInfo.Count; i++)
  79. {
  80. if (recordsIDSet.Contains(Monitor.Monitor.parkingSpaceInfo[i].parkingSpace))
  81. {
  82. updateParkingSpace = "update parkingspace set parkingSpaceX = " + Monitor.Monitor.parkingSpaceInfo[i].coordX +
  83. ",parkingSpaceY = " + Monitor.Monitor.parkingSpaceInfo[i].coordY + ",parkingSpaceZ = " + Monitor.Monitor.parkingSpaceInfo[i].floorNo + ",parkingSpaceState = " + Monitor.Monitor.parkingSpaceInfo[i].spaceStatus + " where (parkingSpaceID = " + Monitor.Monitor.parkingSpaceInfo[i].parkingSpace + ");";
  84. updateSpaceList.Add(updateParkingSpace);
  85. }
  86. else
  87. {
  88. insertParkingSpace = "insert into parkingspace (parkingSpaceID,parkingSpaceX,parkingSpaceY,parkingSpaceZ,parkingSpaceState) values (" + Monitor.Monitor.parkingSpaceInfo[i].parkingSpace + "," + Monitor.Monitor.parkingSpaceInfo[i].coordX +
  89. "," + Monitor.Monitor.parkingSpaceInfo[i].coordY + "," + Monitor.Monitor.parkingSpaceInfo[i].floorNo + "," + Monitor.Monitor.parkingSpaceInfo[i].spaceStatus + ");";
  90. insertSpaceList.Add(insertParkingSpace);
  91. }
  92. }
  93. try
  94. {
  95. Monitor.Monitor.localDBOper.UpdateTransaction(updateSpaceList);
  96. Monitor.Monitor.localDBOper.Insert(insertSpaceList);
  97. }
  98. catch (Exception e) { Console.WriteLine("更新本地所有车位异常" + e.Message); }
  99. }
  100. /// <summary>
  101. /// 更新车辆状态
  102. /// </summary>
  103. /// <param name="lic"></param>
  104. /// <param name="state"></param>
  105. private void UpdateVehicle(string lic, int state, int parkingRecordsID, bool park, bool remote)
  106. {
  107. MySqlDataReader reader;
  108. //查询车辆是否在车辆表中
  109. string checkVehicleState = "select * from vehicle where numberPlate = '" + lic + "';";
  110. if (!remote)
  111. {
  112. reader = Monitor.Monitor.localDBOper.Query(checkVehicleState);
  113. }
  114. else
  115. {
  116. reader = Monitor.Monitor.remoteDBOper.Query(checkVehicleState);
  117. }
  118. if (reader != null)
  119. {
  120. //更新车辆状态
  121. string updateVehicleState = "";
  122. if (park)
  123. {
  124. updateVehicleState = "update vehicle set vehiclepParkState = " + state + " ,parkingRecordsID = " + parkingRecordsID + " where numberPlate = '" + lic + "';";
  125. }
  126. else
  127. {
  128. updateVehicleState = "update vehicle set vehiclepParkState = " + state + " where numberPlate = '" + lic + "';";
  129. }
  130. List<string> list = new List<string>();
  131. list.Add(updateVehicleState);
  132. if (!remote)
  133. {
  134. Monitor.Monitor.localDBOper.UpdateTransaction(list);
  135. }
  136. else
  137. {
  138. Monitor.Monitor.localDBOper.UpdateTransaction(list);
  139. }
  140. }
  141. else
  142. {
  143. //插入车辆
  144. string insertVehicleWithState = "";
  145. if (park)
  146. {
  147. insertVehicleWithState = "insert into vehicle (numberPlate,vehicleTypeID,vehiclepParkState,parkingRecordsID) values " +
  148. "('" + lic + "',NULL,'" + state + "'," + parkingRecordsID + ");";
  149. }
  150. else
  151. {
  152. Console.WriteLine("明显异常,取车发现无车辆");
  153. return;
  154. }
  155. List<string> list = new List<string>();
  156. list.Add(insertVehicleWithState);
  157. if (!remote)
  158. {
  159. Monitor.Monitor.localDBOper.Insert(list);
  160. }
  161. else
  162. {
  163. Monitor.Monitor.remoteDBOper.Insert(list);
  164. }
  165. }
  166. }
  167. /// <summary>
  168. /// 停车流程,收到号牌机启动后操作过程
  169. /// </summary>
  170. private void ParkNumSubProcess()
  171. {
  172. int numMachineLaunch = Monitor.Monitor.mainBlockInfo.numMachineLaunch;
  173. if (numMachineLaunch != 0)
  174. {
  175. for (int i = 0; i < terminalInfo.Count; i++)
  176. {
  177. //启动指令与终端id匹配
  178. if (numMachineLaunch == terminalInfo[i].terminalID)
  179. {
  180. int numReceivedStatus = 0;//1获得,2终止
  181. TerminalStru term = terminalInfo[i];
  182. if (term.terminalStatus == (short)0)
  183. {
  184. string license = Monitor.Monitor.numMachineLinker.GetLicensePlate(numMachineLaunch);
  185. //未获得号牌,告知PLC终止,告诉终端提示用户重新操作
  186. if (license == "")
  187. {
  188. MainBlockStru mb = new MainBlockStru
  189. {
  190. licenseReceived = (short)2
  191. };
  192. Monitor.Monitor.PLC.WriteToPLC(mb, PLCDataType.central);
  193. TerminalStru ts = new TerminalStru
  194. {
  195. paymentStatus = -1,
  196. parkingFee = -1,
  197. userType = -1,
  198. licVerification = (short)2
  199. };
  200. Monitor.Monitor.PLC.WriteToPLC(ts, PLCDataType.central);
  201. }
  202. else
  203. {
  204. //记录或更新当前号牌
  205. lock (idLicMap)
  206. {
  207. if (idLicMap.ContainsKey(numMachineLaunch))
  208. {
  209. idLicMap[numMachineLaunch] = license;
  210. }
  211. else
  212. {
  213. idLicMap.Add(numMachineLaunch, license);
  214. }
  215. }
  216. //注册
  217. if (term.btnStatus == (short)0)
  218. {
  219. int userID = term.licenseCodeA;
  220. string userLicense = GetLicenseFromTerm(term);
  221. TerminalStru ts = new TerminalStru
  222. {
  223. paymentStatus = -1,
  224. parkingFee = -1,
  225. userType = -1
  226. };
  227. //与云端数据比对
  228. string checkNetSql = "select * from user where userID=1;";
  229. if (Monitor.Monitor.remoteDBOper.Query(checkNetSql) != null)
  230. {
  231. string userInfoCheckSql = "select * from usercarrelation where userID = '" + userID + "'and numberPlate = '" + userLicense + "';";
  232. MySqlDataReader reader = Monitor.Monitor.remoteDBOper.Query(userInfoCheckSql);
  233. if (reader == null)
  234. {
  235. ts.licVerification = 2;//验证失败
  236. Monitor.Monitor.PLC.WriteToPLC(ts, PLCDataType.central);
  237. numReceivedStatus = 2;
  238. }
  239. else
  240. {
  241. ts.licVerification = 1;//验证成功
  242. Monitor.Monitor.PLC.WriteToPLC(ts, PLCDataType.central);
  243. numReceivedStatus = 1;
  244. }
  245. }
  246. else
  247. {
  248. ts.licVerification = 1;//网络异常,跳过验证
  249. Monitor.Monitor.PLC.WriteToPLC(ts, PLCDataType.central);
  250. numReceivedStatus = 1;
  251. }
  252. }
  253. //无论是否注册,皆告知PLC,已获取号牌或比对异常、终止流程
  254. MainBlockStru mb = new MainBlockStru
  255. {
  256. licenseReceived = (short)numReceivedStatus
  257. };
  258. Monitor.Monitor.PLC.WriteToPLC(mb, PLCDataType.central);
  259. }
  260. }
  261. }
  262. }
  263. }
  264. }
  265. /// <summary>
  266. /// 停车流程,收到PLC停车完成信号后操作过程
  267. /// </summary>
  268. private void ParkCompleteSubProcess()
  269. {
  270. int processAttrib = Monitor.Monitor.mainBlockInfo.parkingRunning;
  271. int processCompleted = Monitor.Monitor.mainBlockInfo.processCompleted;
  272. int currentTerm = Monitor.Monitor.mainBlockInfo.terminalID;
  273. int parkingSpaceID = 0;
  274. if (processAttrib == 1 && processCompleted == 1)
  275. {
  276. TerminalStru term;
  277. string license;
  278. //找到终端号,判断是否注册用户
  279. for (int i = 0; i < terminalInfo.Count; i++)
  280. {
  281. //拿到号牌
  282. if (terminalInfo[i].terminalID == currentTerm && idLicMap.TryGetValue(currentTerm, out license) && license != "")
  283. {
  284. term = terminalInfo[i];
  285. //找到停车位置
  286. for (int s = 0; s < Monitor.Monitor.parkingSpaceInfo.Count; s++)
  287. {
  288. if (Monitor.Monitor.parkingSpaceInfo[i].receiptNum == term.receiptNum)
  289. {
  290. parkingSpaceID = Monitor.Monitor.parkingSpaceInfo[i].parkingSpace;
  291. break;
  292. }
  293. }
  294. //无车位信息则跳出当前循环
  295. if (parkingSpaceID == 0) break;
  296. //插入停车记录
  297. string parkingRecordsSql = "";
  298. if (term.licenseCodeA != 0)
  299. {
  300. parkingRecordsSql = "INSERT INTO parkingrecords (userID, numberPlate,parkingSpaceID,garageID,parkingRecordsState,realParkTime,receiptNum,parkingPrice)" +
  301. "values ('" + term.licenseCodeA + "','" + license + "','" + parkingSpaceID + "','" + Monitor.Monitor.garageID + "',3,'" + DateTime.Now.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss") + "','" + term.receiptNum + "',NULL);";
  302. }
  303. else
  304. {
  305. parkingRecordsSql = "INSERT INTO parkingrecords (userID, numberPlate,parkingSpaceID,garageID,parkingRecordsState,realParkTime,receiptNum,parkingPrice)" +
  306. "values ('" + 1 + "','" + license + "','" + parkingSpaceID + "','" + Monitor.Monitor.garageID + "',3,'" + DateTime.Now.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss") + "','" + term.receiptNum + "',NULL);";
  307. }
  308. List<string> list = new List<string>();
  309. list.Add(parkingRecordsSql);
  310. Monitor.Monitor.localDBOper.Insert(list);
  311. //查询记录ID号
  312. string findRecordSql = "select parkingRecordsID from parkingrecords where receiptNum = " + term.receiptNum + ";";
  313. MySqlDataReader reader = Monitor.Monitor.localDBOper.Query(findRecordSql);
  314. int parkingRecordsID = 0;
  315. try {
  316. if (reader!=null && reader.Read()) { parkingRecordsID = reader.GetInt32("parkingRecordsID"); }
  317. } catch (Exception) { break; };
  318. //更新本地车辆表
  319. UpdateVehicle(license, parkingRecordsID, 1, true, false);
  320. //更新本地车位
  321. UpdateAllParkingSpace();
  322. //注册用户加入云端操作
  323. if (term.btnStatus == 0)
  324. {
  325. //string
  326. //Monitor.Monitor.remoteDBOper()
  327. }
  328. }
  329. }
  330. }
  331. }
  332. /// <summary>
  333. /// 停车相关操作
  334. /// 1.读取到号牌机启动指令,启动号牌机并根据是否注册用户进行操作
  335. /// 非注册拿到号牌后记录并告知plc
  336. /// 注册用户,核对号牌与用户关联信息
  337. /// 2.停车流程结束,写数据库
  338. /// </summary>
  339. private void ParkProcess()
  340. {
  341. //1.号牌机启动
  342. Task.Factory.StartNew(() =>
  343. {
  344. while (!isClosing)
  345. {
  346. ParkNumSubProcess();
  347. Thread.Sleep(Monitor.Monitor.plcRefreshInterval);
  348. }
  349. });
  350. Task.Factory.StartNew(() =>
  351. {
  352. while (!isClosing)
  353. {
  354. ParkCompleteSubProcess();
  355. Thread.Sleep(Monitor.Monitor.plcRefreshInterval);
  356. }
  357. });
  358. }
  359. private int FeeCalc(PaymentScheme scheme, DateTime parkTime, TimeSpan orderTimeLength)
  360. {
  361. try
  362. {
  363. int orderFee = scheme.bookCharge * (int)orderTimeLength.TotalHours;
  364. int parkFee = 0;
  365. int hours = (int)(DateTime.Now - parkTime).TotalHours;
  366. switch (scheme.schemeType)
  367. {
  368. //按时计费
  369. case 1:
  370. if (hours > scheme.firstChargeTime)
  371. {
  372. parkFee = Math.Min(scheme.firstCharge + scheme.intervalCharge * hours / scheme.chargeInterval, scheme.upperBound);
  373. }
  374. else
  375. {
  376. parkFee = scheme.firstCharge;
  377. }
  378. break;
  379. //按次计费
  380. case 2:
  381. int overnightCount = hours / 24;
  382. parkFee = scheme.eachCharge + overnightCount * scheme.overnightCharge;
  383. break;
  384. //按时间段计费
  385. case 3:
  386. TimeSpan currentTimeOfDay = DateTime.Now.TimeOfDay;
  387. TimeSpan parkTimeOfDay = parkTime.TimeOfDay;
  388. TimeSpan startTimeOfDay = DateTime.Parse(scheme.startChargeTime).TimeOfDay;
  389. TimeSpan endTimeOfDay = DateTime.Parse(scheme.endChargeTime).TimeOfDay;
  390. double countingHoursOfDay = endTimeOfDay.TotalHours - startTimeOfDay.TotalHours;
  391. int days = (int)((DateTime.Now - parkTime).TotalHours - currentTimeOfDay.TotalHours + parkTimeOfDay.TotalHours);
  392. int previousOffset = (int)(-(Math.Max(0, parkTimeOfDay.TotalHours - startTimeOfDay.TotalHours)));
  393. int currentOffset = (int)Math.Min((currentTimeOfDay.TotalHours - startTimeOfDay.TotalHours), countingHoursOfDay);
  394. parkFee = (days * (int)countingHoursOfDay + previousOffset + currentOffset) * scheme.chargeStandard;
  395. break;
  396. }
  397. return parkFee;
  398. }
  399. catch (Exception e) { Console.WriteLine("费用计算异常"); return -1; }
  400. }
  401. /// <summary>
  402. /// 取车相关操作
  403. ///
  404. /// </summary>
  405. private void FetchProcess()
  406. {
  407. int fetchState = Monitor.Monitor.mainBlockInfo.fetchingRunning;
  408. int receiptNum = 0;
  409. TerminalStru ts = new TerminalStru();
  410. for (int i = 0; i < terminalInfo.Count; i++)
  411. {
  412. if (terminalInfo[i].terminalID == Monitor.Monitor.mainBlockInfo.terminalID)
  413. {
  414. ts = terminalInfo[i];
  415. receiptNum = ts.receiptNum;
  416. break;
  417. }
  418. }
  419. //取车状态且凭证号不为空,查询数据库计费
  420. if (fetchState == 1 && receiptNum != 0)
  421. {
  422. int userID = 0;
  423. string numberPlate = "";
  424. string realParkTime = "";
  425. //1.根据凭证号查询停车记录
  426. string parkRecordsSql = "select userID,numberPlate,realParkTime from parkingrecords where receiptNum = "+ receiptNum + ";";
  427. try
  428. {
  429. MySqlDataReader reader = Monitor.Monitor.localDBOper.Query(parkRecordsSql);
  430. if(reader!=null && reader.Read())
  431. {
  432. object[] receiver = new object[3];
  433. reader.GetValues(receiver);
  434. userID = (int)receiver[0];
  435. numberPlate = (string)receiver[1];
  436. realParkTime = (string)receiver[2];
  437. }
  438. }
  439. catch (Exception e) { Console.WriteLine(e.Message); }
  440. //2.根据号牌查询预约记录
  441. //3.获取停车时刻并计费发送给PLC,暂时认为皆为普通用户
  442. DateTime parkTime = DateTime.Parse(realParkTime);
  443. if (PaymentScheme.ins != null)
  444. {
  445. int fee = FeeCalc(PaymentScheme.ins, parkTime, new TimeSpan(0));
  446. if (Monitor.Monitor.PLC != null)
  447. {
  448. TerminalStru FeeMsg = new TerminalStru {
  449. paymentStatus = (short)-1,
  450. licVerification = (short)-1,
  451. parkingFee = (short)fee,
  452. userType = (short)1
  453. };
  454. Monitor.Monitor.PLC.WriteToPLC(FeeMsg,PLCDataType.central);
  455. }
  456. }
  457. }
  458. }
  459. public void Start()
  460. {
  461. //Task.Factory.StartNew(() =>
  462. //{
  463. //});
  464. }
  465. public void Stop()
  466. {
  467. isClosing = true;
  468. }
  469. }
  470. public class PaymentScheme
  471. {
  472. public static PaymentScheme ins;
  473. public int paymentSchemeID;
  474. /// <summary>
  475. /// 策略类型。1按时,2按次,3按时间段
  476. /// </summary>
  477. public int schemeType;
  478. /// <summary>
  479. /// 免费时间
  480. /// </summary>
  481. public int freeTime;
  482. //******************** 按时收费 *******************
  483. /// <summary>
  484. /// 首段收费时间
  485. /// </summary>
  486. public int firstChargeTime;
  487. /// <summary>
  488. /// 首段费用
  489. /// </summary>
  490. public int firstCharge;
  491. /// <summary>
  492. /// 间隔收费时间
  493. /// </summary>
  494. public int chargeInterval;
  495. /// <summary>
  496. /// 间隔收费单价
  497. /// </summary>
  498. public int intervalCharge;
  499. /// <summary>
  500. /// 每日停车收费上限
  501. /// </summary>
  502. public int upperBound;
  503. //******************** 按次收费 *******************
  504. /// <summary>
  505. /// 按次收费,每次费用
  506. /// </summary>
  507. public int eachCharge;
  508. /// <summary>
  509. /// 按次收费,加收过夜费
  510. /// </summary>
  511. public int overnightCharge;
  512. //******************** 按时间段收费 *******************
  513. /// <summary>
  514. /// 按时间段收费,起始时间
  515. /// </summary>
  516. public string startChargeTime;
  517. /// <summary>
  518. /// 按时间段收费,终止时间
  519. /// </summary>
  520. public string endChargeTime;
  521. /// <summary>
  522. /// 按时间段收费,每小时费用
  523. /// </summary>
  524. public int chargeStandard;
  525. //******************** VIP卡 *******************
  526. /// <summary>
  527. /// 月卡办理价格
  528. /// </summary>
  529. public int monthCardCharge;
  530. /// <summary>
  531. /// 季卡办理价格
  532. /// </summary>
  533. public int seasonCardCharge;
  534. /// <summary>
  535. /// 半年卡办理价格
  536. /// </summary>
  537. public int halfYearCardCharge;
  538. /// <summary>
  539. /// 年卡办理价格
  540. /// </summary>
  541. public int yearCardCharge;
  542. /// <summary>
  543. /// 预约小时费用
  544. /// </summary>
  545. public int bookCharge;
  546. public PaymentScheme()
  547. {
  548. ins = new PaymentScheme();
  549. ins.paymentSchemeID = 0;
  550. ins.schemeType = 0;
  551. ins.freeTime = 0;
  552. ins.firstChargeTime = 0;
  553. ins.firstCharge = 0;
  554. ins.chargeInterval = 0;
  555. ins.upperBound = 0;
  556. ins.eachCharge = 0;
  557. ins.overnightCharge = 0;
  558. ins.startChargeTime = "";
  559. ins.endChargeTime = "";
  560. ins.chargeStandard = 0;
  561. ins.monthCardCharge = 0;
  562. ins.seasonCardCharge = 0;
  563. ins.halfYearCardCharge = 0;
  564. ins.yearCardCharge = 0;
  565. ins.bookCharge = 0;
  566. }
  567. public PaymentScheme(int pID, int type, int freeTime, int firstChargeTime, int firstCharge, int chargeInterval, int intervalCharge,
  568. int upperBound, int eachCharge, int overnightCharge, string startChargeTime, string endChargeTime, int chargeStandard,
  569. int monthCardCharge, int seasonCardCharge, int halfYearCardCharge, int yearCardCharge, int bookCharge)
  570. {
  571. ins = new PaymentScheme();
  572. ins.paymentSchemeID = pID;
  573. ins.schemeType = type;
  574. ins.freeTime = freeTime;
  575. ins.firstChargeTime = firstChargeTime;
  576. ins.firstCharge = firstCharge;
  577. ins.chargeInterval = chargeInterval;
  578. ins.intervalCharge = intervalCharge;
  579. ins.upperBound = upperBound;
  580. ins.eachCharge = eachCharge;
  581. ins.overnightCharge = overnightCharge;
  582. ins.startChargeTime = startChargeTime;
  583. ins.endChargeTime = endChargeTime;
  584. ins.chargeStandard = chargeStandard;
  585. ins.monthCardCharge = monthCardCharge;
  586. ins.seasonCardCharge = seasonCardCharge;
  587. ins.halfYearCardCharge = halfYearCardCharge;
  588. ins.yearCardCharge = yearCardCharge;
  589. ins.bookCharge = bookCharge;
  590. }
  591. public static PaymentScheme GetCurrentPaymentScheme(int index)
  592. {
  593. string currentPaymentSchemeQuerySql = "select * from paymentScheme where paymentSchemeID = " + index + ";";
  594. object[] paramArray = null;
  595. PaymentScheme scheme = null;
  596. try
  597. {
  598. MySqlDataReader reader = Monitor.Monitor.localDBOper.Query(currentPaymentSchemeQuerySql);
  599. if (reader != null && reader.Read())
  600. {
  601. scheme = new PaymentScheme();
  602. paramArray = new object[reader.FieldCount];
  603. reader.GetValues(paramArray);
  604. scheme.paymentSchemeID = index;
  605. scheme.schemeType = (int)paramArray[1];
  606. scheme.freeTime = (int)paramArray[2];
  607. scheme.firstChargeTime = (int)paramArray[3];
  608. scheme.firstCharge = (int)paramArray[4];
  609. scheme.chargeInterval = (int)paramArray[5];
  610. scheme.intervalCharge = (int)paramArray[6];
  611. scheme.upperBound = (int)paramArray[7];
  612. scheme.eachCharge = (int)paramArray[8];
  613. scheme.overnightCharge = (int)paramArray[9];
  614. scheme.startChargeTime = (string)paramArray[10];
  615. scheme.endChargeTime = (string)paramArray[11];
  616. scheme.chargeStandard = (int)paramArray[12];
  617. scheme.monthCardCharge = (int)paramArray[13];
  618. scheme.seasonCardCharge = (int)paramArray[14];
  619. scheme.halfYearCardCharge = (int)paramArray[15];
  620. scheme.yearCardCharge = (int)paramArray[16];
  621. scheme.bookCharge = (int)paramArray[17];
  622. }
  623. }
  624. catch (Exception e) { Console.WriteLine("读取本地计费策略," + e.Message); }
  625. return scheme;
  626. }
  627. }
  628. }