747575620@qq.com před 2 roky
rodič
revize
486a0c90e4
15 změnil soubory, kde provedl 162 přidání a 86 odebrání
  1. +0
    -36
      HKCardIN/COM/COMHelper.cs
  2. +1
    -1
      HKCardIN/HKCardIN.csproj
  3. +4
    -0
      HKCardIN/Helper/DataBus.cs
  4. +12
    -0
      HKCardIN/Logic/BaseLogic.cs
  5. +44
    -2
      HKCardIN/ViewModels/RootViewModel.cs
  6. +49
    -0
      HKCardIN/Views/CardView.xaml
  7. +35
    -0
      HKCardIN/Views/CardView.xaml.cs
  8. +8
    -2
      HKCardIN/Views/RootView.xaml
  9. +0
    -34
      HKCardOUT/COM/COMHelper.cs
  10. +0
    -1
      HKCardOUT/HKCardOUT.csproj
  11. +0
    -5
      HKCardOUT/Logic/Model/SaleLog.cs
  12. +4
    -0
      HKCardOUT/Logic/RemoteModel/StoreInfoResponse.cs
  13. +2
    -2
      HKCardOUT/Logic/RemoteService.cs
  14. +2
    -2
      HKCardOUT/Logic/Service/HKCore.cs
  15. +1
    -1
      HKLog/HKLog.csproj

+ 0
- 36
HKCardIN/COM/COMHelper.cs Zobrazit soubor

@@ -1,36 +0,0 @@
using HKCardIN.Helper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO.Ports;
using System.Text;
using System.Threading.Tasks;

namespace COM
{
public class COMHelper : Singleton<COMHelper>
{
public SerialPort serialPort;
public void OpenCOM(string input)
{
serialPort = new SerialPort(input, 9600, Parity.None, 8, StopBits.One);
//数据接收
serialPort.DataReceived += new SerialDataReceivedEventHandler(DataReceived);
serialPort.ReceivedBytesThreshold = 1;
serialPort.RtsEnable = true;
try
{
if (serialPort.IsOpen) return;
serialPort.Open();
}
catch { }
}
/// 数据接收事件
private void DataReceived(object sender, SerialDataReceivedEventArgs e)
{
byte[] readBuffer = new byte[serialPort.ReadBufferSize];
serialPort.Read(readBuffer, 0, readBuffer.Length);
string str = Encoding.Default.GetString(readBuffer);
}
}
}

+ 1
- 1
HKCardIN/HKCardIN.csproj Zobrazit soubor

@@ -33,13 +33,13 @@
<PackageReference Include="HandyControls" Version="3.4.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
<PackageReference Include="Stylet" Version="1.3.6" />
<PackageReference Include="System.IO.Ports" Version="6.0.0" />
<PackageReference Include="SqlSugarCore" Version="5.1.2.7" />
<PackageReference Include="XExten.Advance" Version="1.2.4.2-preview" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\HKLog\HKLog.csproj" />
<ProjectReference Include="..\UHFHelper\UHFHelper.csproj" />
</ItemGroup>
<ItemGroup>
<Resource Include="HKResouces\头像.png" />


+ 4
- 0
HKCardIN/Helper/DataBus.cs Zobrazit soubor

@@ -26,5 +26,9 @@ namespace HKCardIN.Helper
/// 推送充值到服务器
/// </summary>
public static string PushMoneyToServer = DataBus.SaasRoute + "api/member-helper/memberconsumptionorrecharge";
/// <summary>
/// 根据会员手机获取卡号
/// </summary>
public static string GetCardNoByPhone = DataBus.SaasRoute + "api/";
}
}

+ 12
- 0
HKCardIN/Logic/BaseLogic.cs Zobrazit soubor

@@ -41,5 +41,17 @@ namespace HKCardIN.Logic
}).Build().RunStringFirst();
return bool.Parse(data.ToModel<JObject>()["data"].ToString());
}
/// <summary>
/// 根据会员手机获取卡号
/// </summary>
/// <param name="Phone"></param>
/// <returns></returns>
public string GetCardNoByPhone(string Phone)
{
var data = IHttpMultiClient.HttpMulti.AddNode(t => {
t.NodePath = ApiRoute.GetCardNoByPhone;
}).Build().RunStringFirst();
return data;
}
}
}

+ 44
- 2
HKCardIN/ViewModels/RootViewModel.cs Zobrazit soubor

@@ -1,11 +1,16 @@
using HKCardIN.Helper;
using HandyControl.Data;
using HKCardIN.Helper;
using HKCardIN.Logic;
using HKCardIN.Logic.Model;
using HKCardIN.Views;
using HKLog;
using Stylet;
using System;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using UHFHelper;

namespace HKCardIN.ViewModels
{
@@ -64,6 +69,44 @@ namespace HKCardIN.ViewModels
#endregion

#region 命令

public void ReadAction()
{
if (!UHFCardHelper.GetInstance().ComOpen)
{
var res = UHFCardHelper.GetInstance().OpenPort();
HKLogImport.WriteInfo(res.ResMes);
}
var RCardNo = UHFCardHelper.GetInstance().ReadCard();
if (!Regex.IsMatch(RCardNo, "\\d{19}"))
{
var res = HandyControl.Controls.MessageBox.Show(new MessageBoxInfo
{
Button = MessageBoxButton.YesNo,
IconKey = "InfoGeometry",
IconBrushKey = "InfoBrush",
YesContent = "是",
NoContent = "否",
Message = "此卡是新卡,前往制卡",
Caption = "提示!"
});
if (res == MessageBoxResult.Yes)
{
CardView view = new CardView();
if (view.ShowDialog().Value) HandyControl.Controls.Growl.InfoGlobal("制卡成功");
else HandyControl.Controls.Growl.InfoGlobal("制卡失败");
}
Info = BaseLogic.GetInstance().PullUserAndCardInfo(CardNo);
UHFCardHelper.GetInstance().ClosePort();
}
else
{
CardNo = RCardNo;
Info = BaseLogic.GetInstance().PullUserAndCardInfo(CardNo);
UHFCardHelper.GetInstance().ClosePort();
}

}
public void InputAction(string input)
{
if (IsLocker) return;
@@ -110,7 +153,6 @@ namespace HKCardIN.ViewModels
protected override void OnViewLoaded()
{
MainThread();
//Info = BaseLogic.GetInstance().PullUserAndCardInfo("1569245210230263808");
}
private void MainThread()
{


+ 49
- 0
HKCardIN/Views/CardView.xaml Zobrazit soubor

@@ -0,0 +1,49 @@
<Window
x:Class="HKCardIN.Views.CardView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:local="clr-namespace:HKCardIN.Views"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="海科智慧一卡通平台"
Width="300"
Height="200"
ResizeMode="CanMinimize"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d">
<Window.Background>
<ImageBrush ImageSource="/HKResouces/背景.jpg" />
</Window.Background>
<WrapPanel
HorizontalAlignment="Center"
VerticalAlignment="Center"
Orientation="Vertical">
<TextBox
x:Name="Phone"
Width="200"
hc:InfoElement.Placeholder="请输入手机号"
Style="{StaticResource TextBoxExtend}" />
<WrapPanel Margin="0,10,0,0" HorizontalAlignment="Center">
<Button
x:Name="Query"
Width="80"
Height="50"
Margin="0,0,10,0"
Click="QueryClick"
Content="查询"
FontSize="18"
Style="{StaticResource ButtonDefault}" />
<Button
x:Name="Create"
Width="80"
Height="50"
Margin="10,0,0,0"
Click="CreateClick"
Content="制卡"
FontSize="18"
IsEnabled="False"
Style="{StaticResource ButtonDefault}" />
</WrapPanel>
</WrapPanel>
</Window>

+ 35
- 0
HKCardIN/Views/CardView.xaml.cs Zobrazit soubor

@@ -0,0 +1,35 @@
using HKLog;
using System.Text.RegularExpressions;
using System.Windows;
using UHFHelper;
using XExten.Advance.LinqFramework;

namespace HKCardIN.Views
{
/// <summary>
/// CardView.xaml 的交互逻辑
/// </summary>
public partial class CardView : System.Windows.Window
{
public CardView()
{
InitializeComponent();
}

private void QueryClick(object sender, RoutedEventArgs e)
{
if (this.Phone.Text.IsNullOrEmpty()) HandyControl.Controls.Growl.InfoGlobal("手机号不能为空!");
if (!Regex.IsMatch(this.Phone.Text, "\\d{11}")) HandyControl.Controls.Growl.InfoGlobal("请输入正确的手机号!");
//查询接口
Create.IsEnabled = true;
}

private void CreateClick(object sender, RoutedEventArgs e)
{
var res = UHFCardHelper.GetInstance().WriteCard("1569245210230263808");
HKLogImport.WriteInfo(res.ResMes);
DialogResult = true;
Close();
}
}
}

+ 8
- 2
HKCardIN/Views/RootView.xaml Zobrazit soubor

@@ -10,8 +10,8 @@
xmlns:viewModels="clr-namespace:HKCardIN.ViewModels"
x:Name="Root"
Title="海科智慧一卡通平台"
Width="800"
Height="460"
Width="900"
Height="480"
d:DataContext="{d:DesignInstance Type=viewModels:RootViewModel}"
ResizeMode="CanMinimize"
WindowStartupLocation="CenterScreen"
@@ -52,6 +52,7 @@
Key="E"
Command="{s:Action UnLockAction}"
CommandParameter="{Binding ., ElementName=Pwd}" />
<KeyBinding Key="R" Command="{s:Action ReadAction}" />
<KeyBinding
Key="F1"
Command="{s:Action InputAction}"
@@ -301,6 +302,11 @@
FontWeight="Bold"
Foreground="WhiteSmoke" />
<WrapPanel HorizontalAlignment="Center">
<Button
Command="{s:Action ReadAction}"
Content="读卡[R]"
IsDefault="True"
Style="{StaticResource 操作}" />
<Button
Command="{s:Action SaveAction}"
Content="确定[Enter]"


+ 0
- 34
HKCardOUT/COM/COMHelper.cs Zobrazit soubor

@@ -1,34 +0,0 @@
using HKCardOUT.Helper;
using System;
using System.Collections.Generic;
using System.IO.Ports;
using System.Text;

namespace COM
{
public class COMHelper : Singleton<COMHelper>
{
public SerialPort serialPort;
public void OpenCOM()
{
serialPort = new SerialPort("COM3", 9600, Parity.None, 8, StopBits.One);
//数据接收
serialPort.DataReceived += new SerialDataReceivedEventHandler(DataReceived);
serialPort.ReceivedBytesThreshold = 1;
serialPort.RtsEnable = true;
try
{
if (serialPort.IsOpen) return;
serialPort.Open();
}
catch { }
}
/// 数据接收事件
private void DataReceived(object sender, SerialDataReceivedEventArgs e)
{
byte[] readBuffer = new byte[serialPort.ReadBufferSize];
serialPort.Read(readBuffer, 0, readBuffer.Length);
string str = Encoding.Default.GetString(readBuffer);
}
}
}

+ 0
- 1
HKCardOUT/HKCardOUT.csproj Zobrazit soubor

@@ -38,7 +38,6 @@
<PackageReference Include="Quartz" Version="3.4.0" />
<PackageReference Include="Stylet" Version="1.3.6" />
<PackageReference Include="SqlSugarCore" Version="5.1.2.7" />
<PackageReference Include="System.IO.Ports" Version="6.0.0" />
<PackageReference Include="XExten.Advance" Version="1.2.4.2-preview" />
</ItemGroup>
<ItemGroup>


+ 0
- 5
HKCardOUT/Logic/Model/SaleLog.cs Zobrazit soubor

@@ -16,11 +16,6 @@ namespace HKCardOUT.Logic.Model
[SugarColumn(IsNullable = false)]
public string CardNo { get; set; }
/// <summary>
/// 消费金额
/// </summary>
[SugarColumn(IsNullable = false, ColumnDataType = "decimal(10,2)")]
public decimal Money { get; set; }
/// <summary>
/// 消费位置
/// </summary>
[SugarColumn(IsNullable = false)]


+ 4
- 0
HKCardOUT/Logic/RemoteModel/StoreInfoResponse.cs Zobrazit soubor

@@ -59,6 +59,10 @@ namespace Logic.RemoteModel
/// </summary>
public string GateId { get; set; }
/// <summary>
/// 地址
/// </summary>
public string Address { get; set; }
/// <summary>
/// 刷卡间隔时间
/// </summary>
public int SleepTime { get; set; }


+ 2
- 2
HKCardOUT/Logic/RemoteService.cs Zobrazit soubor

@@ -31,12 +31,12 @@ namespace HKCardOUT.Logic
/// </summary>
/// <param name="CardNo"></param>
/// <param name="Money"></param>
public static bool SyncSaleLog(string CardNo, decimal Money)
public static bool SyncSaleLog(string CardNo, string StallId)
{
var data = IHttpMultiClient.HttpMulti.AddNode(t =>
{
t.ReqType = MultiType.POST;
t.JsonParam = (new { Money, Type = -1, CardNum = CardNo }).ToJson();
t.JsonParam = (new { GateId=StallId, Type = -1, CardNum = CardNo }).ToJson();
t.NodePath = ApiRoute.SyncSaleLog;
}).Build().RunStringFirst();
return bool.Parse(data.ToModel<JObject>()["data"].ToString());


+ 2
- 2
HKCardOUT/Logic/Service/HKCore.cs Zobrazit soubor

@@ -31,7 +31,7 @@ namespace HKCardOUT.Logic.Service
var entity = DbContext.Context.Insertable(input).CallEntityMethod(t => t.Create()).ExecuteReturnEntity();
if (entity.Id!=Guid.Empty)
{
var res = RemoteService.SyncSaleLog(input.CardNo, input.Money);
var res = RemoteService.SyncSaleLog(input.CardNo, input.Location);
Main.GetInstance.Start(input.Location.AsInt());
DbContext.Context.Updateable<SaleLog>().SetColumns(t => t.IsSync == true).Where(t => t.Id == entity.Id).ExecuteCommand();
return res;
@@ -44,7 +44,7 @@ namespace HKCardOUT.Logic.Service
var entity = DbContext.Context.Insertable(input).CallEntityMethod(t => t.Create()).ExecuteReturnEntity();
if (entity.Id!=Guid.Empty)
{
var res = RemoteService.SyncSaleLog(input.CardNo, input.Money);
var res = RemoteService.SyncSaleLog(input.CardNo, input.Location);
Main.GetInstance.Start(input.Location.AsInt());
DbContext.Context.Updateable<SaleLog>().SetColumns(t => t.IsSync == true).Where(t => t.Id == entity.Id).ExecuteCommand();
return res;


+ 1
- 1
HKLog/HKLog.csproj Zobrazit soubor

@@ -4,7 +4,7 @@
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Platforms>AnyCPU;x86</Platforms>
<Platforms>x86</Platforms>
</PropertyGroup>

<ItemGroup>


Načítá se…
Zrušit
Uložit