|
@@ -109,6 +109,8 @@ namespace HengshanPaymentTerminal
|
|
|
|
|
|
//记录油枪状态,key-枪号,value:01:离线 02:锁枪 03:空闲 04:提枪 06:开始加油 08:加油中
|
|
|
private ConcurrentDictionary<int, int> nozzleStatusDic = new ConcurrentDictionary<int, int>();
|
|
|
+ //记录需要更新二维码信息的油枪
|
|
|
+ private HashSet<int> needUpdateQRSet = new HashSet<int>();
|
|
|
#endregion
|
|
|
|
|
|
#region Logger
|
|
@@ -858,15 +860,6 @@ namespace HengshanPaymentTerminal
|
|
|
|
|
|
foreach (var item in nozzleInfoList)
|
|
|
{
|
|
|
- //List<Byte> list = new List<Byte>();
|
|
|
- //byte[] commandAndNozzle = { 0x63, (byte)item.NozzleNum };
|
|
|
- //string qrCode = smallProgram + "/" + item.NozzleNum;
|
|
|
- //byte[] qrCodeBytes = Encoding.ASCII.GetBytes(qrCode);
|
|
|
- //list.AddRange(commandAndNozzle);
|
|
|
- //list.Add((byte)qrCodeBytes.Length);
|
|
|
- //list.AddRange(qrCodeBytes);
|
|
|
- //byte[] sendBytes = content2data(list.ToArray(), null);
|
|
|
-
|
|
|
SendQrCode sendQrCode = new SendQrCode((int)item.CloundNozzleId,item.NozzleNum, smallProgram, getFrame(null));
|
|
|
byte[] commandAndNozzle = { sendQrCode.Handle, (byte)sendQrCode.NozzleNum };
|
|
|
|
|
@@ -880,8 +873,6 @@ namespace HengshanPaymentTerminal
|
|
|
}
|
|
|
return false;
|
|
|
}, sendQrCode);
|
|
|
- //CommonMessage commonMessage = await SendMessageToMaichine("发送二维码", BitConverter.ToString(commandAndNozzle).Replace("-", ""), sendQrCode);
|
|
|
- //CommonMessage commonMessage = await SendRequestToMachine("发送二维码", BitConverter.ToString(commandAndNozzle).Replace("-", ""), sendBytes);
|
|
|
if (commonMessage.IsError && commonMessage.TheErrorType == CommonMessage.ErrorType.DISCONNECT) break;
|
|
|
}
|
|
|
|
|
@@ -979,7 +970,8 @@ namespace HengshanPaymentTerminal
|
|
|
sendAuthorizationResult.NozzleId = request.NozzleId;
|
|
|
|
|
|
//添加订单到数据库
|
|
|
- DateTime authorizationTime = request.AuthorizationTime ?? DateTime.Now;
|
|
|
+ //DateTime authorizationTime = request.AuthorizationTime ?? DateTime.Now;
|
|
|
+ DateTime authorizationTime = DateTime.Now;
|
|
|
string paymentName = "未知类型";
|
|
|
if (request.PaymentMethod != null)
|
|
|
{
|
|
@@ -1104,6 +1096,7 @@ namespace HengshanPaymentTerminal
|
|
|
sendUnAuthorizationResult.NozzleId = request.NozzleId;
|
|
|
sendUnAuthorizationResult.OilMachineStatus = OilMachineStatus.Success;
|
|
|
sendUnAuthorizationResult.TransactionID = request.Id;
|
|
|
+ sendUnAuthorizationResult.TransactionNumber = ttc.ToString();
|
|
|
|
|
|
if (ttc != 0 && !isUnauthorization)
|
|
|
{
|
|
@@ -1320,6 +1313,7 @@ namespace HengshanPaymentTerminal
|
|
|
SendUnAuthorizationResult sendUnAuthorizationResult = new SendUnAuthorizationResult();
|
|
|
sendUnAuthorizationResult.NozzleId = fccOrderInfo.NozzleNum;
|
|
|
sendUnAuthorizationResult.TransactionID = fccOrderInfo.CloundOrderId;
|
|
|
+ sendUnAuthorizationResult.TransactionNumber = fccOrderInfo.Ttc.ToString();
|
|
|
sendUnAuthorizationResult.OilMachineStatus = OilMachineStatus.Success;
|
|
|
|
|
|
SendUnAuthorization sendUnAuthorization = new SendUnAuthorization(fccOrderInfo.NozzleNum, fccOrderInfo.AuthorizationTime, fccOrderInfo.Ttc, getFrame(null));
|
|
@@ -1367,6 +1361,7 @@ namespace HengshanPaymentTerminal
|
|
|
|
|
|
mysqlDbContext.SaveChanges();
|
|
|
|
|
|
+ logger.Info($"定时任务取消授权:发送结果:{JsonConvert.SerializeObject(sendUnAuthorizationResult)}");
|
|
|
HttpResponseMessage httpResponseMessage = await httpClientUtil.SendUnAuthorizationResult(JsonConvert.SerializeObject(sendUnAuthorizationResult));
|
|
|
logger.Info($"定时任务取消授权:send Unauthorization timer result response:{JsonConvert.SerializeObject(httpResponseMessage.Content.ReadAsStringAsync())}");
|
|
|
|
|
@@ -1503,6 +1498,14 @@ namespace HengshanPaymentTerminal
|
|
|
List<int> fuelingNozzle = new List<int>();
|
|
|
foreach (var nozzleState in heartBeatMessage.NozzleStatus)
|
|
|
{
|
|
|
+ //油机UI重启,重发二维码
|
|
|
+ if (nozzleState.STATU == 1) needUpdateQRSet.Add(nozzleState.NozzleNum);
|
|
|
+ if (nozzleState.STATU == 3 && needUpdateQRSet.Contains(nozzleState.NozzleNum))
|
|
|
+ {
|
|
|
+ UpdateQRCode(nozzleState.NozzleNum);
|
|
|
+ needUpdateQRSet.Remove(nozzleState.NozzleNum);
|
|
|
+ }
|
|
|
+
|
|
|
if (nozzleStatusDic.TryGetValue(nozzleState.NozzleNum, out var value))
|
|
|
{
|
|
|
if (nozzleState.STATU == value) continue;
|
|
@@ -1556,6 +1559,41 @@ namespace HengshanPaymentTerminal
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 更新二维码信息
|
|
|
+ /// 油机ui进入配置后退出,会重启UI,此时需要重新发送二维码
|
|
|
+ /// </summary>
|
|
|
+ public async void UpdateQRCode(int nozzleNum)
|
|
|
+ {
|
|
|
+ string smallProgram = stationInfo?.SmallProgram ?? "";
|
|
|
+ if (string.IsNullOrEmpty(smallProgram))
|
|
|
+ {
|
|
|
+ logger.Info($"更新二维码信息:can not get smallProgram link");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ DetailsNozzleInfoOutput? item = nozzleInfoList.Find(nozzle => nozzle.NozzleNum == nozzleNum);
|
|
|
+ if (item == null)
|
|
|
+ {
|
|
|
+ logger.Error($"找不到{nozzleNum}号枪信息");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ SendQrCode sendQrCode = new SendQrCode((int)item.CloundNozzleId, item.NozzleNum, smallProgram, getFrame(null));
|
|
|
+ byte[] commandAndNozzle = { sendQrCode.Handle, (byte)sendQrCode.NozzleNum };
|
|
|
+
|
|
|
+ Thread.Sleep(5000);
|
|
|
+ CommonMessage commonMessage = await SendMessageToMaichine($"发送{sendQrCode.NozzleNum}号枪二维码", (request, response) =>
|
|
|
+ {
|
|
|
+ if (response.Handle == (byte)CommonMessage.Command.COMMON)
|
|
|
+ {
|
|
|
+ CommonAnswerBack commonAnswerBack = (CommonAnswerBack)response;
|
|
|
+ return commonAnswerBack.Command == (byte)CommonMessage.Command.SEND_QR_CODE && commonAnswerBack.NozzleNum == sendQrCode.NozzleNum;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }, sendQrCode);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 获取发送帧号
|
|
|
/// </summary>
|