Terminal.cs 52 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121
  1. using Terminal;
  2. using db;
  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. using BroadcastModule;
  11. using parkMonitor.LOG;
  12. namespace Terminal
  13. {
  14. public class Terminal
  15. {
  16. public static List<TerminalStru> terminalInfo = new List<PLCS7.TerminalStru>();
  17. public static Dictionary<int, string> idLicMap = new Dictionary<int, string>();
  18. public static Dictionary<int, bool> termUsedMap = new Dictionary<int, bool>();
  19. public static bool isClosing = false;
  20. public void FeeCal()
  21. {
  22. }
  23. public void GetTerminalState()
  24. {
  25. }
  26. private object SearchPaymentScheme()
  27. {
  28. return null;
  29. }
  30. private void UpdateParkingRecords(int Object)
  31. {
  32. }
  33. /// <summary>
  34. /// 从终端结构体中获得车牌号
  35. /// </summary>
  36. /// <param name="ts"></param>
  37. /// <returns></returns>
  38. private static string GetLicenseFromTerm(TerminalStru ts)
  39. {
  40. string header = Encoding.ASCII.GetString(BitConverter.GetBytes(ts.licenseCodeB));
  41. string identityA = Encoding.ASCII.GetString(BitConverter.GetBytes(ts.licenseCodeC));
  42. byte[] bytes = BitConverter.GetBytes(ts.licenseCodeD);
  43. List<byte> newBytes = new List<byte>();
  44. for (int i = 0; i < bytes.Length; i++)
  45. {
  46. if (bytes[i] != 0x00) { newBytes.Add(bytes[i]); }
  47. }
  48. string identityB = Encoding.ASCII.GetString(newBytes.ToArray());
  49. Log.WriteLog(LogType.process, LogFile.INFO, "已从终端" + ts.terminalID + "获得号牌:" + header + identityA + identityB);
  50. //根据省份对应的两位数字查找汉字
  51. string province = header.Substring(0, 2);
  52. string provinceIndex = header.Substring(2);
  53. string provinceQuerySql = "select NumberPlateHeader from numberplatemapping where mappedString = " + province + ";";
  54. lock (Monitor.Monitor.localDBOper)
  55. {
  56. //object[] result = Monitor.Monitor.localDBOper.Query(provinceQuerySql);
  57. MySqlDataReader reader = Monitor.Monitor.localDBOper.Query(provinceQuerySql);
  58. try
  59. {
  60. if (reader != null && reader.Read() && reader.HasRows)
  61. {
  62. province = reader.GetString("NumberPlateHeader");
  63. //Console.WriteLine(province);
  64. }
  65. }
  66. catch { }
  67. try
  68. {
  69. //if (result!=null && result.Length > 0) { province = (string)result[0]; }
  70. if (reader != null)
  71. {
  72. reader.Close();
  73. reader.Dispose();
  74. }
  75. }
  76. catch { }
  77. }
  78. return province + provinceIndex + identityA + identityB;
  79. }
  80. /// <summary>
  81. /// 更新所有车位信息
  82. /// </summary>
  83. private static void UpdateAllParkingSpace()
  84. {
  85. string findParkingSpace = "select parkingSpaceID from parkingspace;";
  86. HashSet<int> recordsIDSet = new HashSet<int>();
  87. lock (Monitor.Monitor.localDBOper)
  88. {
  89. //object[] result = Monitor.Monitor.localDBOper.Query(findParkingSpace);
  90. //if(result!=null && result.Length > 0)
  91. //{
  92. // for (int i = 0; i < result.Length; i++)
  93. // {
  94. // recordsIDSet.Add((int)result[i]);
  95. // }
  96. //}
  97. MySqlDataReader reader = Monitor.Monitor.localDBOper.Query(findParkingSpace);
  98. if (reader != null)
  99. {
  100. try
  101. {
  102. while (reader.Read())
  103. {
  104. if (reader.HasRows)
  105. {
  106. recordsIDSet.Add(reader.GetInt32("parkingSpaceID"));
  107. }
  108. }
  109. }
  110. catch { }
  111. try
  112. {
  113. reader.Close();
  114. reader.Dispose();
  115. }
  116. catch { }
  117. }
  118. }
  119. List<string> updateSpaceList = new List<string>();
  120. List<string> insertSpaceList = new List<string>();
  121. string updateParkingSpace = "";
  122. string insertParkingSpace = "";
  123. for (int i = 0; i < Monitor.Monitor.parkingSpaceInfo.Count; i++)
  124. {
  125. if (recordsIDSet.Contains(Monitor.Monitor.parkingSpaceInfo[i].parkingSpace))
  126. {
  127. updateParkingSpace = "update parkingspace set parkingSpaceX = " + Monitor.Monitor.parkingSpaceInfo[i].coordX +
  128. ",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 + ");";
  129. updateSpaceList.Add(updateParkingSpace);
  130. }
  131. else
  132. {
  133. insertParkingSpace = "insert into parkingspace (parkingSpaceID,parkingSpaceX,parkingSpaceY,parkingSpaceZ,parkingSpaceState) values (" + Monitor.Monitor.parkingSpaceInfo[i].parkingSpace + "," + Monitor.Monitor.parkingSpaceInfo[i].coordX +
  134. "," + Monitor.Monitor.parkingSpaceInfo[i].coordY + "," + Monitor.Monitor.parkingSpaceInfo[i].floorNo + "," + Monitor.Monitor.parkingSpaceInfo[i].spaceStatus + ");";
  135. insertSpaceList.Add(insertParkingSpace);
  136. }
  137. }
  138. try
  139. {
  140. lock (Monitor.Monitor.localDBOper)
  141. {
  142. Monitor.Monitor.localDBOper.UpdateTransaction(updateSpaceList);
  143. Monitor.Monitor.localDBOper.Insert(insertSpaceList);
  144. }
  145. }
  146. catch (Exception e) { Log.WriteLog(LogType.process, LogFile.ERROR, "更新本地所有车位异常"); Console.WriteLine("更新本地所有车位异常" + e.Message); }
  147. }
  148. /// <summary>
  149. /// 更新车辆状态
  150. /// </summary>
  151. /// <param name="lic"></param>
  152. /// <param name="state"></param>
  153. private static void UpdateVehicle(string lic, int state, int parkingRecordsID, bool park, bool remote, int parkingSpaceID)
  154. {
  155. if (lic != "")
  156. {
  157. MySqlDataReader reader;
  158. //查询车辆是否在车辆表中
  159. string checkVehicleState = "select * from vehicle where numberPlate = '" + lic + "';";
  160. if (!remote)
  161. {
  162. reader = Monitor.Monitor.localDBOper.Query(checkVehicleState);
  163. }
  164. else
  165. {
  166. reader = Monitor.Monitor.remoteDBOper.Query(checkVehicleState);
  167. }
  168. if (reader != null)
  169. {
  170. if (reader.Read() && reader.HasRows)
  171. {
  172. //更新车辆状态
  173. string updateVehicleState = "";
  174. string updateRemoteVehicleState = "";
  175. if (park)
  176. {
  177. if (parkingRecordsID > 0)
  178. {
  179. if (parkingSpaceID == 0)
  180. {
  181. updateVehicleState = "update vehicle set vehiclepParkState = " + state + " ,parkingRecordsID = " + parkingRecordsID + " where numberPlate = '" + lic + "';";
  182. updateRemoteVehicleState = "update vehicle set vehiclepParkState = " + state + " ,parkingRecordsID = " + parkingRecordsID + ",garageID = " + Monitor.Monitor.garageID + " where numberPlate = '" + lic + "';";
  183. }
  184. else
  185. {
  186. updateVehicleState = "update vehicle set vehiclepParkState = " + state + " ,parkingRecordsID = " + parkingRecordsID + ",parkingSpaceID = " + parkingSpaceID + " where numberPlate = '" + lic + "';";
  187. updateRemoteVehicleState = "update vehicle set vehiclepParkState = " + state + " ,parkingRecordsID = " + parkingRecordsID + ",parkingSpaceID = " + parkingSpaceID + ",garageID = " + Monitor.Monitor.garageID + " where numberPlate = '" + lic + "';";
  188. }
  189. }
  190. else
  191. {
  192. updateVehicleState = "update vehicle set vehiclepParkState = " + state + " where numberPlate = '" + lic + "';";
  193. updateRemoteVehicleState = updateVehicleState;
  194. }
  195. }
  196. else
  197. {
  198. updateVehicleState = "update vehicle set vehiclepParkState = " + state + " where numberPlate = '" + lic + "';";
  199. updateRemoteVehicleState = updateVehicleState;
  200. }
  201. List<string> list = new List<string>();
  202. if (!remote)
  203. {
  204. list.Add(updateVehicleState);
  205. Monitor.Monitor.localDBOper.UpdateTransaction(list);
  206. }
  207. else
  208. {
  209. list.Add(updateRemoteVehicleState);
  210. Monitor.Monitor.remoteDBOper.UpdateTransaction(list);
  211. }
  212. }
  213. else
  214. {
  215. //插入车辆
  216. string insertVehicleWithState = "";
  217. if (park)
  218. {
  219. if (parkingRecordsID > 0)
  220. insertVehicleWithState = "insert into vehicle (numberPlate,vehicleTypeID,vehiclepParkState,parkingRecordsID) values " +
  221. "('" + lic + "',NULL,'" + state + "'," + parkingRecordsID + ");";
  222. else
  223. insertVehicleWithState = "insert into vehicle (numberPlate,vehicleTypeID,vehiclepParkState) values " +
  224. "('" + lic + "',NULL,'" + state + "');";
  225. }
  226. else
  227. {
  228. Log.WriteLog(LogType.process, LogFile.ERROR, "取车无法获得车辆信息");
  229. Console.WriteLine("明显异常,取车发现无车辆");
  230. try
  231. {
  232. reader.Close();
  233. reader.Dispose();
  234. }
  235. catch { }
  236. return;
  237. }
  238. List<string> list = new List<string>();
  239. list.Add(insertVehicleWithState);
  240. if (!remote)
  241. {
  242. Monitor.Monitor.localDBOper.Insert(list);
  243. }
  244. else
  245. {
  246. Monitor.Monitor.remoteDBOper.Insert(list);
  247. }
  248. }
  249. try
  250. {
  251. reader.Close();
  252. reader.Dispose();
  253. }
  254. catch { }
  255. }
  256. }
  257. }
  258. /// <summary>
  259. /// 流程结束清除终端相关信息
  260. /// </summary>
  261. /// <param name="id"></param>
  262. private static void ClearTerminal(int id)
  263. {
  264. TerminalStru tsFromCentral = new TerminalStru
  265. {
  266. terminalID = (short)id,
  267. parkingFee = (short)32767,
  268. };
  269. TerminalStru tsFromTerminal = new TerminalStru
  270. {
  271. terminalID = (short)id,
  272. btnStatus = -1,
  273. };
  274. Monitor.Monitor.PLC.WriteToPLC(tsFromCentral, PLCDataType.central);
  275. Monitor.Monitor.PLC.WriteToPLC(tsFromTerminal, PLCDataType.terminal);
  276. }
  277. /// <summary>
  278. /// 验证会员信息
  279. /// </summary>
  280. /// <param name="ts"></param>
  281. /// <param name="userID"></param>
  282. /// <param name="license"></param>
  283. /// <param name="status"></param>
  284. private static void ValidateUserInfo(TerminalStru ts, int userID, string license, out int status)
  285. {
  286. status = 0;
  287. //与云端数据比对
  288. string checkNetSql = "select * from user where userID = 1;";
  289. MySqlDataReader readerTest = Monitor.Monitor.remoteDBOper.Query(checkNetSql);
  290. if (readerTest != null)
  291. {
  292. if (readerTest.Read() && readerTest.HasRows)
  293. {
  294. string userInfoCheckSql = "select * from usercarrelation where userID = '" + userID + "'and numberPlate = '" + license + "';";
  295. MySqlDataReader reader = Monitor.Monitor.remoteDBOper.Query(userInfoCheckSql);
  296. if (reader != null && reader.Read() && reader.HasRows && userID != 0 && license != "")
  297. {
  298. ts.licVerification = 1;//验证成功
  299. Monitor.Monitor.PLC.WriteToPLC(ts, PLCDataType.central);
  300. status = 1;
  301. Log.WriteLog(LogType.process, LogFile.INFO, "号牌验证成功");
  302. Monitor.Monitor.AddNotification("注册用户,号牌验证成功");
  303. }
  304. else
  305. {
  306. ts.licVerification = 2;//验证失败
  307. Monitor.Monitor.PLC.WriteToPLC(ts, PLCDataType.central);
  308. status = 2;
  309. Log.WriteLog(LogType.process, LogFile.WARNING, "号牌验证失败");
  310. Monitor.Monitor.AddNotification("注册用户,号牌验证失败");
  311. }
  312. try
  313. {
  314. reader.Close();
  315. reader.Dispose();
  316. }
  317. catch { }
  318. }
  319. else
  320. {
  321. ts.licVerification = 1;//网络异常,跳过验证
  322. Monitor.Monitor.PLC.WriteToPLC(ts, PLCDataType.central);
  323. status = 1;
  324. Log.WriteLog(LogType.process, LogFile.ERROR, "网络异常,无法验证号牌");
  325. }
  326. try
  327. {
  328. readerTest.Close();
  329. readerTest.Dispose();
  330. }
  331. catch { }
  332. }
  333. }
  334. /// <summary>
  335. /// 查询停车记录id
  336. /// </summary>
  337. /// <param name="querySql"></param>
  338. /// <param name="recordsID"></param>
  339. /// <param name="remote"></param>
  340. private static void QueryParkingRecordsID(string querySql, out int recordsID, bool remote)
  341. {
  342. recordsID = 0;
  343. MySqlDataReader reader = null;
  344. if (!remote)
  345. {
  346. reader = Monitor.Monitor.localDBOper.Query(querySql);
  347. }
  348. else
  349. {
  350. reader = Monitor.Monitor.remoteDBOper.Query(querySql);
  351. }
  352. if (reader != null)
  353. {
  354. try
  355. {
  356. if (reader.Read())
  357. {
  358. recordsID = reader.GetInt32("parkingRecordsID");
  359. }
  360. }
  361. catch (Exception e) { Log.WriteLog(LogType.process, LogFile.ERROR, "查询停车记录id失败"); ; Console.WriteLine(e.Message); };
  362. try
  363. {
  364. reader.Close();
  365. reader.Dispose();
  366. }
  367. catch { }
  368. }
  369. }
  370. /// <summary>
  371. /// 停车流程,收到号牌机启动后操作过程
  372. /// </summary>
  373. private static void ParkNumSubProcess()
  374. {
  375. int numMachineLaunch = Monitor.Monitor.mainBlockInfo.numMachineLaunch;
  376. if (numMachineLaunch != 0)
  377. {
  378. for (int i = 0; i < terminalInfo.Count; i++)
  379. {
  380. //启动指令与终端id匹配
  381. if (numMachineLaunch == terminalInfo[i].terminalID)
  382. {
  383. int numReceivedStatus = 0;//1获得,2终止
  384. TerminalStru term = terminalInfo[i];
  385. if (term.terminalStatus == (short)1)
  386. {
  387. string license = Monitor.Monitor.numMachineLinker.GetLicensePlate(numMachineLaunch);
  388. Monitor.Monitor.AddNotification("启动" + numMachineLaunch + "号号牌机,号牌:" + license);
  389. //未获得号牌,告知PLC终止,告诉终端提示用户重新操作
  390. if (license == "")
  391. {
  392. MainBlockStru mb = new MainBlockStru
  393. {
  394. licenseReceived = (short)2
  395. };
  396. Monitor.Monitor.PLC.WriteToPLC(mb, PLCDataType.central);
  397. TerminalStru ts = new TerminalStru
  398. {
  399. terminalID = (short)numMachineLaunch,
  400. paymentStatus = -1,
  401. parkingFee = -1,
  402. userType = -1,
  403. licVerification = (short)2
  404. };
  405. Monitor.Monitor.PLC.WriteToPLC(ts, PLCDataType.central);
  406. Log.WriteLog(LogType.process, LogFile.ERROR, "未获得号牌");
  407. }
  408. else
  409. {
  410. //记录或更新当前号牌
  411. lock (idLicMap)
  412. {
  413. if (idLicMap.ContainsKey(numMachineLaunch))
  414. {
  415. idLicMap[numMachineLaunch] = license;
  416. }
  417. else
  418. {
  419. idLicMap.Add(numMachineLaunch, license);
  420. }
  421. }
  422. Log.WriteLog(LogType.process, LogFile.ERROR, "号牌" + license + "已记录");
  423. TerminalStru ts = new TerminalStru
  424. {
  425. terminalID = (short)numMachineLaunch,
  426. paymentStatus = -1,
  427. parkingFee = -1,
  428. userType = -1
  429. };
  430. //注册用户
  431. if (term.btnStatus == (short)2)
  432. {
  433. int userID = term.licenseCodeA;
  434. string userLicense = GetLicenseFromTerm(term);
  435. //与云端数据比对
  436. ValidateUserInfo(ts, userID, userLicense, out numReceivedStatus);
  437. }
  438. //非注册用户
  439. else if (term.btnStatus == (short)1)
  440. {
  441. numReceivedStatus = 1;
  442. ts.licVerification = 1;
  443. Monitor.Monitor.PLC.WriteToPLC(ts, PLCDataType.central);
  444. }
  445. //无论是否注册,皆告知PLC,已获取号牌或比对异常、终止流程
  446. MainBlockStru mb = new MainBlockStru
  447. {
  448. licenseReceived = (short)numReceivedStatus
  449. };
  450. Monitor.Monitor.PLC.WriteToPLC(mb, PLCDataType.central);
  451. //号牌获取结果被清零才跳出
  452. Monitor.Monitor.AddNotification("已写入号牌获取结果,等待号牌机启动指令清零");
  453. }
  454. while (Monitor.Monitor.mainBlockInfo.numMachineLaunch != 0)
  455. {
  456. Thread.Sleep(1000);
  457. }
  458. }
  459. }
  460. }
  461. }
  462. }
  463. /// <summary>
  464. /// 停车流程,收到PLC停车完成信号后操作过程
  465. /// </summary>
  466. private static void ParkCompleteSubProcess()
  467. {
  468. int processAttrib = Monitor.Monitor.mainBlockInfo.parkingRunning;
  469. int processCompleted = Monitor.Monitor.mainBlockInfo.processCompleted;
  470. int currentTerm = Monitor.Monitor.mainBlockInfo.terminalID;
  471. int parkingSpaceID = 0;
  472. if (processAttrib == 1 && processCompleted == 1)
  473. {
  474. TerminalStru term;
  475. string license;
  476. //找到终端号,判断是否注册用户
  477. for (int i = 0; i < terminalInfo.Count; i++)
  478. {
  479. //拿到号牌
  480. if (terminalInfo[i].terminalID == currentTerm && idLicMap.TryGetValue(currentTerm, out license) && license != "")
  481. {
  482. term = terminalInfo[i];
  483. //找到停车位置
  484. for (int s = 0; s < Monitor.Monitor.parkingSpaceInfo.Count; s++)
  485. {
  486. if (Monitor.Monitor.parkingSpaceInfo[i].receiptNum == term.receiptNum)
  487. {
  488. parkingSpaceID = Monitor.Monitor.parkingSpaceInfo[i].parkingSpace;
  489. break;
  490. }
  491. }
  492. //无车位信息则跳出当前循环
  493. if (parkingSpaceID == 0) break;
  494. UpdateVehicle(license, 0, 0, true, false, 0);
  495. UpdateVehicle(license, 0, 0, true, true, 0);
  496. //插入停车记录
  497. string parkingRecordsSql = "";
  498. if (term.licenseCodeA != 0)
  499. {
  500. parkingRecordsSql = "INSERT INTO parkingrecords (userID, numberPlate,parkingSpaceID,garageID,parkingRecordsState,realParkTime,receiptNum,parkingPrice)" +
  501. "values ('" + term.licenseCodeA + "','" + license + "','" + parkingSpaceID + "','" + Monitor.Monitor.garageID + "',3,'" + DateTime.Now.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss") + "','" + term.receiptNum + "',NULL);";
  502. }
  503. else
  504. {
  505. parkingRecordsSql = "INSERT INTO parkingrecords (userID, numberPlate,parkingSpaceID,garageID,parkingRecordsState,realParkTime,receiptNum,parkingPrice)" +
  506. "values ('" + 1 + "','" + license + "','" + parkingSpaceID + "','" + Monitor.Monitor.garageID + "',3,'" + DateTime.Now.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss") + "','" + term.receiptNum + "',NULL);";
  507. }
  508. List<string> list = new List<string>();
  509. list.Add(parkingRecordsSql);
  510. Monitor.Monitor.localDBOper.Insert(list);
  511. Monitor.Monitor.remoteDBOper.Insert(list);
  512. Log.WriteLog(LogType.process, LogFile.INFO, "停车记录已插入," + license + "停在" + parkingSpaceID + ",凭证号:" + term.receiptNum);
  513. Monitor.Monitor.AddNotification("停车记录已插入");
  514. ////注册用户记录插入云端
  515. //if (term.btnStatus == 0)
  516. //{
  517. //Monitor.Monitor.remoteDBOper.Insert(list);
  518. //}
  519. //查询记录ID号
  520. string findRecordSql = "select parkingRecordsID from parkingrecords where receiptNum = " + term.receiptNum + ";";
  521. int parkingRecordsID = 0;
  522. int remoteParkingRecordsID = 0;
  523. QueryParkingRecordsID(findRecordSql, out parkingRecordsID, false);
  524. QueryParkingRecordsID(findRecordSql, out remoteParkingRecordsID, true);
  525. //更新本地车辆表
  526. if (parkingRecordsID != 0)
  527. {
  528. UpdateVehicle(license, 1, parkingRecordsID, true, false, parkingSpaceID);
  529. }
  530. if (remoteParkingRecordsID != 0)
  531. {
  532. UpdateVehicle(license, 1, remoteParkingRecordsID, true, true, parkingSpaceID);
  533. }
  534. Log.WriteLog(LogType.process, LogFile.INFO, "停车记录表已更新");
  535. //更新本地车位
  536. UpdateAllParkingSpace();
  537. Monitor.Monitor.AddNotification("停车数据库已更新,等待流程结束状态清零。");
  538. while (Monitor.Monitor.mainBlockInfo.processCompleted != 0)
  539. {
  540. Thread.Sleep(1000);
  541. }
  542. //中控清除车牌、凭证号、号牌验证等信息
  543. ClearTerminal(term.terminalID);
  544. Monitor.Monitor.AddNotification(license + " 停车流程结束");
  545. }
  546. }
  547. }
  548. }
  549. /// <summary>
  550. /// 停车相关操作
  551. /// 1.读取到号牌机启动指令,启动号牌机并根据是否注册用户进行操作
  552. /// 非注册拿到号牌后记录并告知plc
  553. /// 注册用户,核对号牌与用户关联信息
  554. /// 2.停车流程结束,写数据库
  555. /// </summary>
  556. ///
  557. private static void ParkProcess()
  558. {
  559. Task.Factory.StartNew(() =>
  560. {
  561. while (!isClosing)
  562. {
  563. ParkNumSubProcess();
  564. Thread.Sleep(Monitor.Monitor.plcRefreshInterval);
  565. }
  566. });
  567. Task.Factory.StartNew(() =>
  568. {
  569. while (!isClosing)
  570. {
  571. ParkCompleteSubProcess();
  572. Thread.Sleep(Monitor.Monitor.plcRefreshInterval);
  573. }
  574. });
  575. }
  576. /// <summary>
  577. /// 根据凭证号查询停车记录
  578. /// </summary>
  579. /// <param name="receipt"></param>
  580. /// <param name="recordID"></param>
  581. /// <param name="userID"></param>
  582. /// <param name="numberPlate"></param>
  583. /// <param name="realParkTime"></param>
  584. private static bool FindLocalParkingRecord(int receipt, out int recordID, out int userID, out string numberPlate, out string realParkTime)
  585. {
  586. recordID = 0;
  587. userID = 0;
  588. numberPlate = "";
  589. realParkTime = "";
  590. string parkRecordsSql = "select parkingRecordsID,userID,numberPlate,realParkTime from parkingrecords where receiptNum = " + receipt + ";";
  591. MySqlDataReader reader = Monitor.Monitor.localDBOper.Query(parkRecordsSql);
  592. try
  593. {
  594. if (reader != null && reader.Read())
  595. {
  596. object[] receiver = new object[4];
  597. reader.GetValues(receiver);
  598. recordID = (int)receiver[0];
  599. userID = (int)receiver[1];
  600. numberPlate = (string)receiver[2];
  601. realParkTime = (string)receiver[3];
  602. }
  603. if (reader != null)
  604. {
  605. reader.Close();
  606. reader.Dispose();
  607. }
  608. }
  609. catch (Exception e) { Log.WriteLog(LogType.process, LogFile.ERROR, "根据凭证号查询停车记录失败"); Console.WriteLine(e.Message); return false; }
  610. try
  611. {
  612. if (reader != null)
  613. {
  614. reader.Close();
  615. reader.Dispose();
  616. }
  617. }
  618. catch { }
  619. Log.WriteLog(LogType.process, LogFile.INFO, "根据凭证号查询停车记录成功");
  620. return true;
  621. }
  622. /// <summary>
  623. /// 预约与停车费用计算
  624. /// </summary>
  625. /// <param name="scheme"></param>
  626. /// <param name="parkTime"></param>
  627. /// <param name="orderTimeLength"></param>
  628. /// <returns></returns>
  629. private static int FeeCalc(PaymentScheme scheme, DateTime parkTime, TimeSpan orderTimeLength)
  630. {
  631. try
  632. {
  633. int orderFee = scheme.bookCharge * (int)orderTimeLength.TotalHours;
  634. int parkFee = 0;
  635. int hours = (int)(DateTime.Now - parkTime).TotalHours;
  636. switch (scheme.schemeType)
  637. {
  638. //按时计费
  639. case 1:
  640. if (hours > scheme.firstChargeTime)
  641. {
  642. parkFee = Math.Min(scheme.firstCharge + scheme.intervalCharge * hours / scheme.chargeInterval, scheme.upperBound);
  643. }
  644. else
  645. {
  646. parkFee = scheme.firstCharge;
  647. }
  648. break;
  649. //按次计费
  650. case 2:
  651. int overnightCount = hours / 24;
  652. parkFee = scheme.eachCharge + overnightCount * scheme.overnightCharge;
  653. break;
  654. //按时间段计费
  655. case 3:
  656. TimeSpan currentTimeOfDay = DateTime.Now.TimeOfDay;
  657. TimeSpan parkTimeOfDay = parkTime.TimeOfDay;
  658. TimeSpan startTimeOfDay = DateTime.Parse(scheme.startChargeTime).TimeOfDay;
  659. TimeSpan endTimeOfDay = DateTime.Parse(scheme.endChargeTime).TimeOfDay;
  660. double countingHoursOfDay = endTimeOfDay.TotalHours - startTimeOfDay.TotalHours;
  661. int days = (int)((DateTime.Now - parkTime).TotalHours - currentTimeOfDay.TotalHours + parkTimeOfDay.TotalHours);
  662. int previousOffset = (int)(-(Math.Max(0, parkTimeOfDay.TotalHours - startTimeOfDay.TotalHours)));
  663. int currentOffset = (int)Math.Min((currentTimeOfDay.TotalHours - startTimeOfDay.TotalHours), countingHoursOfDay);
  664. int peakTimeLength = days * (int)countingHoursOfDay + previousOffset + currentOffset;
  665. parkFee = peakTimeLength * scheme.chargeStandard + ((int)((DateTime.Now - parkTime).TotalHours) - peakTimeLength) * scheme.intervalCharge;
  666. break;
  667. }
  668. Log.WriteLog(LogType.process, LogFile.INFO, "停车费用" + parkFee);
  669. return parkFee;
  670. }
  671. catch (Exception e) { Console.WriteLine("费用计算异常"); return -1; }
  672. }
  673. /// <summary>
  674. /// 取车计费子操作
  675. /// </summary>
  676. private static void FetchFeeCalcSubProcess()
  677. {
  678. int fetchState = Monitor.Monitor.mainBlockInfo.fetchingRunning;
  679. int receiptNum = 0;
  680. int termIndex = -1;
  681. TerminalStru ts = new TerminalStru();
  682. for (int i = 0; i < terminalInfo.Count; i++)
  683. {
  684. if (terminalInfo[i].terminalID == Monitor.Monitor.mainBlockInfo.terminalID)
  685. {
  686. ts = terminalInfo[i];
  687. termIndex = ts.terminalID;
  688. receiptNum = ts.receiptNum;
  689. break;
  690. }
  691. }
  692. //取车状态、凭证号不为空,查询数据库计费
  693. if (termIndex != -1 && termUsedMap.Count >= termIndex && termUsedMap.TryGetValue(termIndex, out bool value) && !value && fetchState == 1 && receiptNum != 0)
  694. {
  695. fetchState = Monitor.Monitor.mainBlockInfo.fetchingRunning;
  696. Monitor.Monitor.AddNotification("取车流程,准备计算费用");
  697. termUsedMap[termIndex] = true;
  698. Console.WriteLine("终端编号" + termIndex);
  699. Task.Factory.StartNew(() =>
  700. {
  701. int parkingRecordsID = 0;
  702. int remoteParkingRecordsID = 0;
  703. int userID = 0;
  704. string license = "";
  705. string realParkTime = "";
  706. //1.根据凭证号查询停车记录
  707. if (!FindLocalParkingRecord(receiptNum, out parkingRecordsID, out userID, out license, out realParkTime))
  708. {
  709. return;
  710. }
  711. string remoteParkRecordsSql = "select parkingRecordsID from parkingrecords where receiptNum = " + receiptNum + ";";
  712. MySqlDataReader reader = Monitor.Monitor.remoteDBOper.Query(remoteParkRecordsSql);
  713. try
  714. {
  715. if (reader != null && reader.Read())
  716. {
  717. object[] receiver = new object[1];
  718. reader.GetValues(receiver);
  719. remoteParkingRecordsID = (int)receiver[0];
  720. }
  721. }
  722. catch (Exception e) { Console.WriteLine(e.Message); }
  723. try
  724. {
  725. if (reader != null)
  726. {
  727. reader.Close();
  728. reader.Dispose();
  729. }
  730. }
  731. catch (Exception e) { Console.WriteLine(e.Message); }
  732. //本地存在号牌,后续操作
  733. if (license != "")
  734. {
  735. //2.根据号牌查询车辆月卡信息与预约记录
  736. int orderRecordsID = 0;
  737. int monthCardType = -1;
  738. string monthCardTime = "";
  739. TimeSpan monthCardTimeLength = new TimeSpan(0);
  740. TimeSpan orderTimeLength = new TimeSpan(0);
  741. //本地VIP信息
  742. string vipInfoSql = "select orderRecordsID,monthCardType,monthCardTime from vehicle where numberPlate = '" + license + "';";
  743. try
  744. {
  745. reader = Monitor.Monitor.localDBOper.Query(vipInfoSql);
  746. if (reader != null && reader.Read())
  747. {
  748. object[] receiver = new object[3];
  749. reader.GetValues(receiver);
  750. Console.WriteLine(receiver[2].GetType());
  751. if (!receiver[0].GetType().Equals(typeof(DBNull)))
  752. {
  753. orderRecordsID = (int)receiver[0];
  754. }
  755. if (!receiver[1].GetType().Equals(typeof(DBNull)))
  756. {
  757. monthCardType = (int)(UInt32)receiver[1];
  758. }
  759. if (!receiver[2].GetType().Equals(typeof(DBNull)))
  760. {
  761. monthCardTime = (string)receiver[2];
  762. }
  763. //orderRecordsID = (Int32)receiver[0];
  764. //monthCardType = (Int32)receiver[1];
  765. //monthCardTime = (string)receiver[2];
  766. monthCardTimeLength = DateTime.Parse(monthCardTime) - DateTime.Now;
  767. if (monthCardTimeLength.TotalHours <= 0)
  768. {
  769. monthCardType = 0;
  770. }
  771. Log.WriteLog(LogType.process, LogFile.INFO, "已获取本地预约与月卡信息");
  772. }
  773. }
  774. catch (Exception e) { Console.WriteLine(e.Message); }
  775. try
  776. {
  777. if (reader != null)
  778. {
  779. reader.Close();
  780. reader.Dispose();
  781. }
  782. }
  783. catch (Exception e) { Console.WriteLine(e.Message); }
  784. //云端VIP信息
  785. try
  786. {
  787. reader = Monitor.Monitor.remoteDBOper.Query(vipInfoSql);
  788. if (reader != null && reader.Read())
  789. {
  790. object[] receiver = new object[3];
  791. reader.GetValues(receiver);
  792. int cardType = (int)(UInt32)receiver[1];
  793. string CardTime = (string)receiver[2];
  794. TimeSpan t = DateTime.Parse(CardTime) - DateTime.Now;
  795. //云端
  796. if (t.TotalHours > 0 && cardType > monthCardType)
  797. {
  798. monthCardType = cardType;
  799. monthCardTimeLength = t;
  800. }
  801. Log.WriteLog(LogType.process, LogFile.INFO, "已获取云端预约与月卡信息");
  802. }
  803. }
  804. catch (Exception e) { Console.WriteLine(e.Message); }
  805. try
  806. {
  807. if (reader != null)
  808. {
  809. reader.Close();
  810. reader.Dispose();
  811. }
  812. }
  813. catch (Exception e) { Console.WriteLine(e.Message); }
  814. //有预约记录,判断记录有效性,有效则获取预约时长
  815. if (orderRecordsID != 0)
  816. {
  817. //修改orderTimeLength
  818. }
  819. //3.获取停车时刻,根据用户类型计费发送给PLC,暂认为无预约
  820. DateTime parkTime = DateTime.Parse(realParkTime);
  821. DateTime currentTime = DateTime.Now;
  822. int fee = 32767;
  823. if (PaymentScheme.ins != null && monthCardType != -1)
  824. {
  825. if (monthCardTimeLength.TotalHours > 0)
  826. {
  827. fee = 0;
  828. }
  829. else
  830. {
  831. fee = FeeCalc(PaymentScheme.ins, parkTime, orderTimeLength);
  832. }
  833. try
  834. {
  835. if (Monitor.Monitor.PLC != null)
  836. {
  837. TerminalStru FeeMsg = new TerminalStru();
  838. FeeMsg.terminalID = (short)termIndex;
  839. FeeMsg.paymentStatus = (short)-1;
  840. FeeMsg.licVerification = (short)-1;
  841. FeeMsg.parkingFee = (short)fee;
  842. FeeMsg.userType = (short)(monthCardType + 1);
  843. Console.WriteLine(FeeMsg);
  844. Monitor.Monitor.PLC.WriteToPLC(FeeMsg, PLCDataType.central);
  845. Log.WriteLog(LogType.process, LogFile.INFO, "停车费用已发送至PLC");
  846. }
  847. }
  848. catch { Console.WriteLine("error"); }
  849. }
  850. Monitor.Monitor.AddNotification("用户类型:" + monthCardType + ",费用:" + fee + ",等待凭证号被清除后更新车辆状态");
  851. //4.等待终端获得收费完成信号且将凭证号清除后,清除收费完成信号并将信息写入数据库
  852. while (!isClosing && termIndex != -1)
  853. {
  854. if (terminalInfo[termIndex - 1].receiptNum == 0 && Monitor.Monitor.mainBlockInfo.processCompleted == 1)
  855. {
  856. Log.WriteLog(LogType.process, LogFile.INFO, "检测到凭证号已被清除");
  857. TerminalStru fetchReset = new TerminalStru
  858. {
  859. terminalID = (short)termIndex,
  860. paymentStatus = (short)-1,
  861. licVerification = (short)0,
  862. parkingFee = (short)32767,
  863. userType = (short)0
  864. };
  865. Monitor.Monitor.PLC.WriteToPLC(fetchReset, PLCDataType.central);
  866. //更新停车记录与车辆状态
  867. string updateParkingRecordsSql = "update parkingrecords set parkingRecordsState = 6,realGetTime = '" + currentTime.ToString("yyyy-MM-dd HH:mm:ss") +
  868. "',parkingPrice = " + fee + " where receiptNum = '" + receiptNum + "';";
  869. List<string> list = new List<string>();
  870. list.Add(updateParkingRecordsSql);
  871. lock (Monitor.Monitor.localDBOper)
  872. {
  873. Monitor.Monitor.localDBOper.UpdateTransaction(list);
  874. UpdateVehicle(license, 0, parkingRecordsID, false, false, 0);
  875. }
  876. lock (Monitor.Monitor.remoteDBOper)
  877. {
  878. Monitor.Monitor.remoteDBOper.UpdateTransaction(list);
  879. UpdateVehicle(license, 0, remoteParkingRecordsID, false, true, 0);
  880. }
  881. break;
  882. }
  883. Thread.Sleep(1000);
  884. }
  885. }
  886. termUsedMap[termIndex] = false;
  887. Monitor.Monitor.AddNotification(license + " 取车流程结束");
  888. });
  889. }
  890. }
  891. /// <summary>
  892. /// 取车相关操作
  893. ///
  894. /// </summary>
  895. private static void FetchProcess()
  896. {
  897. Task.Factory.StartNew(() =>
  898. {
  899. while (!isClosing)
  900. {
  901. FetchFeeCalcSubProcess();
  902. Thread.Sleep(Monitor.Monitor.plcRefreshInterval);
  903. }
  904. });
  905. }
  906. public static void Start()
  907. {
  908. ParkProcess();
  909. FetchProcess();
  910. }
  911. public static void Stop()
  912. {
  913. isClosing = true;
  914. }
  915. }
  916. public class PaymentScheme
  917. {
  918. public static PaymentScheme ins;
  919. public int paymentSchemeID;
  920. /// <summary>
  921. /// 策略类型。1按时,2按次,3按时间段
  922. /// </summary>
  923. public int schemeType;
  924. /// <summary>
  925. /// 免费时间
  926. /// </summary>
  927. public int freeTime;
  928. //******************** 按时收费 *******************
  929. /// <summary>
  930. /// 首段收费时间
  931. /// </summary>
  932. public int firstChargeTime;
  933. /// <summary>
  934. /// 首段费用
  935. /// </summary>
  936. public int firstCharge;
  937. /// <summary>
  938. /// 间隔收费时间
  939. /// </summary>
  940. public int chargeInterval;
  941. /// <summary>
  942. /// 间隔收费单价
  943. /// </summary>
  944. public int intervalCharge;
  945. /// <summary>
  946. /// 每日停车收费上限
  947. /// </summary>
  948. public int upperBound;
  949. //******************** 按天收费 *******************
  950. /// <summary>
  951. /// 按天收费,每天费用
  952. /// </summary>
  953. public int eachCharge;
  954. /// <summary>
  955. /// 按次收费,加收过夜费
  956. /// </summary>
  957. public int overnightCharge;
  958. //******************** 按时间段收费 *******************
  959. /// <summary>
  960. /// 按时间段收费,起始时间
  961. /// </summary>
  962. public string startChargeTime;
  963. /// <summary>
  964. /// 按时间段收费,终止时间
  965. /// </summary>
  966. public string endChargeTime;
  967. /// <summary>
  968. /// 按时间段收费,每小时费用
  969. /// </summary>
  970. public int chargeStandard;
  971. //******************** VIP卡 *******************
  972. /// <summary>
  973. /// 月卡办理价格
  974. /// </summary>
  975. public int monthCardCharge;
  976. /// <summary>
  977. /// 季卡办理价格
  978. /// </summary>
  979. public int seasonCardCharge;
  980. /// <summary>
  981. /// 半年卡办理价格
  982. /// </summary>
  983. public int halfYearCardCharge;
  984. /// <summary>
  985. /// 年卡办理价格
  986. /// </summary>
  987. public int yearCardCharge;
  988. /// <summary>
  989. /// 预约小时费用
  990. /// </summary>
  991. public int bookCharge;
  992. public PaymentScheme()
  993. {
  994. this.paymentSchemeID = 0;
  995. this.schemeType = 0;
  996. this.freeTime = 0;
  997. this.firstChargeTime = 0;
  998. this.firstCharge = 0;
  999. this.chargeInterval = 0;
  1000. this.intervalCharge = 0;
  1001. this.upperBound = 0;
  1002. this.eachCharge = 0;
  1003. this.overnightCharge = 0;
  1004. this.startChargeTime = "";
  1005. this.endChargeTime = "";
  1006. this.chargeStandard = 0;
  1007. this.monthCardCharge = 0;
  1008. this.seasonCardCharge = 0;
  1009. this.halfYearCardCharge = 0;
  1010. this.yearCardCharge = 0;
  1011. this.bookCharge = 0;
  1012. }
  1013. public PaymentScheme(int pID, int type, int freeTime, int firstChargeTime, int firstCharge, int chargeInterval, int intervalCharge,
  1014. int upperBound, int eachCharge, int overnightCharge, string startChargeTime, string endChargeTime, int chargeStandard,
  1015. int monthCardCharge, int seasonCardCharge, int halfYearCardCharge, int yearCardCharge, int bookCharge)
  1016. {
  1017. ins = new PaymentScheme();
  1018. ins.paymentSchemeID = pID;
  1019. ins.schemeType = type;
  1020. ins.freeTime = freeTime;
  1021. ins.firstChargeTime = firstChargeTime;
  1022. ins.firstCharge = firstCharge;
  1023. ins.chargeInterval = chargeInterval;
  1024. ins.intervalCharge = intervalCharge;
  1025. ins.upperBound = upperBound;
  1026. ins.eachCharge = eachCharge;
  1027. ins.overnightCharge = overnightCharge;
  1028. ins.startChargeTime = startChargeTime;
  1029. ins.endChargeTime = endChargeTime;
  1030. ins.chargeStandard = chargeStandard;
  1031. ins.monthCardCharge = monthCardCharge;
  1032. ins.seasonCardCharge = seasonCardCharge;
  1033. ins.halfYearCardCharge = halfYearCardCharge;
  1034. ins.yearCardCharge = yearCardCharge;
  1035. ins.bookCharge = bookCharge;
  1036. }
  1037. public static PaymentScheme GetCurrentPaymentScheme(int index)
  1038. {
  1039. string currentPaymentSchemeQuerySql = "select * from paymentScheme where paymentSchemeID = " + index + ";";
  1040. object[] paramArray = null;
  1041. PaymentScheme scheme = null;
  1042. MySqlDataReader reader = Monitor.Monitor.localDBOper.Query(currentPaymentSchemeQuerySql);
  1043. try
  1044. {
  1045. if (reader != null && reader.Read())
  1046. {
  1047. scheme = new PaymentScheme();
  1048. paramArray = new object[reader.FieldCount];
  1049. reader.GetValues(paramArray);
  1050. scheme.paymentSchemeID = index;
  1051. scheme.schemeType = (int)((UInt32)paramArray[1]);
  1052. scheme.freeTime = (int)paramArray[2];
  1053. scheme.firstChargeTime = (int)paramArray[3];
  1054. scheme.firstCharge = (int)paramArray[4];
  1055. scheme.chargeInterval = (int)paramArray[5];
  1056. scheme.intervalCharge = (int)paramArray[6];
  1057. scheme.upperBound = (int)paramArray[7];
  1058. scheme.eachCharge = (int)paramArray[8];
  1059. scheme.overnightCharge = (int)paramArray[9];
  1060. scheme.startChargeTime = (string)paramArray[10];
  1061. scheme.endChargeTime = (string)paramArray[11];
  1062. scheme.chargeStandard = (int)paramArray[12];
  1063. scheme.monthCardCharge = (int)paramArray[13];
  1064. scheme.seasonCardCharge = (int)paramArray[14];
  1065. scheme.halfYearCardCharge = (int)paramArray[15];
  1066. scheme.yearCardCharge = (int)paramArray[16];
  1067. scheme.bookCharge = (int)paramArray[17];
  1068. }
  1069. }
  1070. catch (Exception e) { Console.WriteLine("读取本地计费策略," + e.Message); }
  1071. try
  1072. {
  1073. if (reader != null)
  1074. {
  1075. reader.Close();
  1076. reader.Dispose();
  1077. }
  1078. }
  1079. catch (Exception e) { Console.WriteLine(e.Message); }
  1080. return scheme;
  1081. }
  1082. public static bool SetPaymentScheme(PaymentScheme ps)
  1083. {
  1084. string updateScheme = "UPDATE paymentscheme SET freeTime='"+(ps.freeTime>=0? ps.freeTime:ins.freeTime)+ "', firstChargeTime='"+(ps.firstChargeTime>=0?ps.firstChargeTime:ins.firstChargeTime)+"', firstCharge='"+(ps.firstCharge>=0?ps.firstCharge:ins.firstCharge)+"', intervalCharge='"+(ps.intervalCharge>=0?ps.intervalCharge:ins.intervalCharge)+"', upperBound='"+(ps.upperBound>=0?ps.upperBound:ins.upperBound)+"'," +
  1085. " eachCharge='"+(ps.eachCharge>=0?ps.eachCharge:ins.eachCharge)+"', overnightCharge='"+(ps.overnightCharge>=0?ps.overnightCharge:ins.overnightCharge)+"', startChargeTime='"+(DateTime.TryParse(ps.startChargeTime,out DateTime t0)?ps.startChargeTime:ins.startChargeTime)+"', endChargeTime='"+(DateTime.TryParse(ps.endChargeTime,out DateTime t1)?ps.endChargeTime:ins.endChargeTime)+"', chargeStandard='"+(ps.chargeStandard>=0?ps.chargeStandard:ins.chargeStandard)+"'," +
  1086. " monthCardCharge='"+(ps.monthCardCharge>=0?ps.monthCardCharge:ins.monthCardCharge)+"', seasonCardCharge='"+ (ps.seasonCardCharge >= 0 ? ps.seasonCardCharge : ins.seasonCardCharge) + "', halfYearCardCharge='"+ (ps.halfYearCardCharge >= 0 ? ps.halfYearCardCharge : ins.halfYearCardCharge) + "', yearCardCharge='"+ (ps.yearCardCharge >= 0 ? ps.yearCardCharge : ins.yearCardCharge) + "', bookCharge='"+ (ps.bookCharge >= 0 ? ps.bookCharge : ins.bookCharge) + "' WHERE paymentSchemeID='1';";
  1087. List<string> sqls = new List<string>();
  1088. sqls.Add(updateScheme);
  1089. return Monitor.Monitor.localDBOper.UpdateTransaction(sqls);
  1090. }
  1091. }
  1092. }