Commit 1f1501be 贾鹏旭

1

2 个父辈 7f3a73ca 4ec07436
......@@ -67,7 +67,7 @@
<HintPath>..\..\..\..\IDHIKCamera\bin\Debug\MvCameraControl.Net.dll</HintPath>
</Reference>
<Reference Include="MvCodeReaderSDK.Net">
<HintPath>..\..\..\..\IDHIKCamera\bin\Debug\MvCodeReaderSDK.Net.dll</HintPath>
<HintPath>..\SharedDll\MvCodeReaderSDK.Net.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
......
......@@ -122,6 +122,7 @@ namespace BLL
{
cameraVision.Open();
result = cameraVision.GetImage();
barcodeInfos = Camera.GetBarCode(result[0]);
cameraVision.Close();
}
return result;
......
......@@ -311,6 +311,8 @@ namespace BLL
/// </summary>
[MyConfigComment("软件后台运行")]
public static MyConfig<bool> Backgrounder;
[MyConfigComment("是否http替换条码内容")]
public static MyConfig<bool> isReplaceData;
[MyConfigComment("数据源类型")]
public static MyConfig<string> DataSource_Type;
......
......@@ -262,6 +262,10 @@ namespace BLL
currentExtension.Update();
}
public Dictionary<string, string> ReplaceData(Dictionary<string,string> dic)
{
return General.ReplaceData(dic);
}
private void LoadRow(object row)
{
object[] cols = (object[])row;
......
......@@ -158,7 +158,8 @@ namespace BLL
errmsg = "";
if (!string.IsNullOrEmpty(config.HttpReelID))
{
if (!GetHttpReelID(key, out errmsg))
Dictionary<string, object> pairs = new Dictionary<string, object>();
if (!GetHttpReelID(key, out errmsg,out pairs))
{
LogNet.log.Error("GetHttpReelID:" + errmsg);
return false;
......@@ -289,14 +290,20 @@ namespace BLL
else
lastkey.Add(extensions[i].Key, extensions[i].Control.Text);
}
//var keys =new List<string>(lastkey.Keys);
Printing?.Invoke(lastkey);
SaveRetrospect?.Invoke(lastkey);
Printing?.Invoke(lastkey);
}
private bool GetHttpReelID(Dictionary<string, string> key, out string errmsg)
/// <summary>
///
/// </summary>
/// <param name="key"></param>
/// <param name="errmsg"></param>
/// <param name="dic">返回请求后,替换完成的键值对</param>
/// <returns></returns>
private bool GetHttpReelID(Dictionary<string, string> key, out string errmsg,out Dictionary<string,object> dic)
{
errmsg = "";
dic = null;
string url = config.HttpReelID;
string json = Http.PostJson(url, null, key);
if (json == "")
......@@ -304,11 +311,11 @@ namespace BLL
errmsg = "Api error";
if (extensions != null && !extensions[0].Control.InvokeRequired)
new FaceMessageBox("BoxReelIDInfoMaintain", errmsg, System.Windows.Forms.MessageBoxButtons.OK, true).ShowDialog();
return false;
}
JavaScriptSerializer serializer = new();
Dictionary<string, object> dic;
//Dictionary<string, object> dic;
try
{
dic = (Dictionary<string, object>)serializer.DeserializeObject(json);
......@@ -552,18 +559,26 @@ namespace BLL
{
if (extensions != null && !extensions[0].Control.InvokeRequired)
{
//自动打印and模板匹配成功,只负责打印标签
if (config.AutoPrint && match)
{
//if (CanPrint())
PrintLabel(null, EventArgs.Empty);
}
}
else
{
//PrintLabel(null, EventArgs.Empty);
}
}
//进行追溯配置保存
SaveRetrospect?.Invoke(key);
}
public Dictionary<string, string> ReplaceData(Dictionary<string, string> key)
{
string err = null;
Dictionary<string, object> dic=new Dictionary<string, object>();
if (!GetHttpReelID(key, out err, out dic))
{
return key;
}
return dic?.ToDictionary(a=>a.Key,a=>a.Value.ToString());
}
}
}
......@@ -18,7 +18,6 @@ namespace BLL
public class KaiFa : IExtension
{
public event IExtension.PrintDelegate Printing;
public event IExtension.PrintDelegate SaveRetrospect;
private Config config;
private int reelID = 0;
......@@ -51,6 +50,7 @@ namespace BLL
this.extensions = extensions;
ReadReelID();
}
static bool mesResult = false;
public bool SetKey(string[] originalCode, Dictionary<string, string> key, bool hasMatch,out string errmsg)
{
......@@ -101,9 +101,6 @@ namespace BLL
{
}
private bool CanPrint()
{
int index = extensions.FindIndex(match => match.Control.Name == "TxtPart");
......@@ -327,7 +324,5 @@ namespace BLL
//业务数据
public object Data { get; set; }
}
}
}
......@@ -154,7 +154,10 @@ namespace BLL
if (Config.Func_EnabledOCR)
{
//保存需要识别ocr的区域
CurrntBitmap?.Save(@"ocr.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
//CurrntBitmap?.Save(@"ocr.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
string currentDirectory = System.Windows.Forms.Application.StartupPath;
string filePath = System.IO.Path.Combine(currentDirectory, "ocr.jpg");
CurrntBitmap?.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);
regOcrCodes = OcrRecognize("..\\ocr.jpg");
LogNet.log.Info($"OCR 识别结果:{regOcrCodes}");
}
......@@ -206,8 +209,6 @@ namespace BLL
return false;
}
private MaterialTemplate LoadFile(string filePath, string imgPath)
{
MaterialTemplate temp = new();
......@@ -752,20 +753,6 @@ namespace BLL
return key;
}
//====================================
public int FindPrimaryCode(List<MaterialCode> code)
{
//bool find = false;
......@@ -898,13 +885,10 @@ namespace BLL
//}
/// <summary>
/// 物料模板名称
/// </summary>
/// <summary>
/// 物料模板总数
/// </summary>
......@@ -1031,16 +1015,6 @@ namespace BLL
// }
//}
/// <summary>
/// 另存为
/// </summary>
......@@ -1153,11 +1127,5 @@ namespace BLL
// temp.Image.Save(temp.ImagePath, System.Drawing.Imaging.ImageFormat.Jpeg);
//}
}
}
}
\ No newline at end of file
......@@ -21,6 +21,6 @@ namespace Model
public void Dispose();
public void Print(bool match, Dictionary<string, string> key);
public abstract void DrawTextBackground(Dictionary<string, string> key);
public abstract void DrawTextBackground(Dictionary<string, string> key);
}
}
using System;
using BLL;
using Model;
using System.Threading;
using System.Windows.Forms;
using BLL;
using System;
using System.Diagnostics;
using System.IO;
using System.Threading;
using System.Windows.Forms;
namespace SmartScan
{
......
......@@ -259,7 +259,7 @@ namespace SmartScan
BLLCommon.extension.LoadPanel(PnlExtension, BLLCommon.macroKey);
//语言
CboLanguage.Items.AddRange(Language.Name);
CboLanguage.Items.AddRange(Language.Name.ToArray());
CboLanguage.SelectedText = BLLCommon.config.Language;
BLLCommon.AutoGenRules = AutoGenRule.LoadFile();
if (BLLCommon.config.OpenMaximize) Maximize();
......@@ -324,6 +324,7 @@ namespace SmartScan
BLLCommon.config.Language = CboLanguage.Text;
BLLCommon.config.Save();
changeBtnStartText();
Language.SetLanguage(this);
}
}
void changeBtnStartText()
......
......@@ -277,7 +277,11 @@ namespace SmartScan
string value = "";
if (pairs.ContainsKey(item))
{
value = pairs[item].ToString();
value = pairs[item].ToString();
}
if (value.StartsWith("<OCR>"))
{
value = value.Replace("<OCR>", "");
}
value = value.Replace("\"\"", "\"\"\"\"");
lines.Add("\""+value+"\"");
......
......@@ -74,7 +74,7 @@ namespace SmartScan
//语言
CboLanguage.Items.Clear();
CboLanguage.Items.AddRange(Language.Name);
CboLanguage.Items.AddRange(Language.Name.ToArray());
CboLanguage.SelectedText = BLLCommon.config.Language;
}
......
......@@ -286,6 +286,7 @@ namespace SmartScan
private bool MatchingTemplate()
{
LogNet.log.Info("Work MatchingTemplate");
//没有条码也继续进行模板匹配
//if (workCodeInfo.Count == 0) return false;
originalCodeText = Camera.GetBarCodeText(workCodeInfo);
......@@ -346,8 +347,5 @@ namespace SmartScan
new FaceMessageBox("", text, MessageBoxButtons.OK).ShowDialog();
}
}
}
}
......@@ -64,6 +64,7 @@ namespace SmartScan
private string[] FormatCode()
{
List<string> item = new();
for (int i = 0; i < mateCopy[mateIndex].Code.Count; i++)
{
item.Add(FormatCode(i));
......@@ -227,6 +228,7 @@ namespace SmartScan
mateCopy[mateIndex].ImagePath = "";
mateCopy[mateIndex].Image = bmp;
ImgShow.Image = bmp;
iscamp = true;
}
private void BtnLocalImage_Click(object sender, EventArgs e)
......@@ -243,8 +245,9 @@ namespace SmartScan
mateCopy[mateIndex].ImagePath = "";
mateCopy[mateIndex].Image = bmp;
ImgShow.Image = bmp;
iscamp = false;
}
public bool iscamp = true;
private void BtnScanCode_Click(object sender, EventArgs e)
{
if (mateIndex == -1) return;
......@@ -256,7 +259,8 @@ namespace SmartScan
return;
}
List<BarcodeInfo> info = null;
if (Camera.useIDCamera)
if (iscamp&&Camera.useIDCamera)
{
Bitmap[] result = Camera.CaptureAndGetCode(out info);
if (result.Length == 0) return;
......@@ -270,6 +274,7 @@ namespace SmartScan
info = Camera.GetBarCode(bmp);
}
//info = Camera.GetBarCode(bmp);
LstCode.Items.Clear();
ImgShow.CodeCenterClear();
mateCopy[mateIndex].Match.Clear();
......@@ -457,9 +462,18 @@ namespace SmartScan
{
if (bmp == null) return;
LstCode.Items.Clear();
//保存需要识别ocr的区域
bmp?.Save(@"ocrt.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
//保存需要识别ocr的区域
//bmp?.Save(@"ocrt.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
string currentDirectory = System.Windows.Forms.Application.StartupPath;
string filePath = System.IO.Path.Combine(currentDirectory, "ocrt.jpg");
bmp?.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);
string[] regOcrCodes = PaddleOCRHelper.StartTest("..\\ocrt.jpg").Split(';');
var entity= mateCopy[mateIndex].Code.Where(a => a.CodeType.Equals(Setting_Str.OCR)).ToList();
foreach (var item in entity)
{
mateCopy[mateIndex].Code.Remove(item);
}
int startidx = BLLCommon.mateMaxCodeID + 1;
foreach (var ocr in regOcrCodes)
{
......
......@@ -89,8 +89,9 @@
<Reference Include="log4net, Version=2.0.12.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.12\lib\net45\log4net.dll</HintPath>
</Reference>
<Reference Include="MaterialSkin">
<HintPath>D:\贾鹏旭_项目文件\Gilocation\Gilocation.Entrance\bin\Debug\MaterialSkin.dll</HintPath>
<Reference Include="MaterialSkin, Version=2.3.1.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>D:\Desktop\项目\ns100\NS100\SharedDll\MaterialSkin.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
......@@ -355,6 +356,12 @@
<DependentUpon>UsrCodeExtractList.cs</DependentUpon>
</EmbeddedResource>
<None Include="app.manifest" />
<None Include="Language\en-US.lngres">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Language\zh-CN.lngres">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="log4net.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
......@@ -399,12 +406,6 @@
</ItemGroup>
<ItemGroup>
<Content Include="App.ico" />
<Content Include="Language\en-US.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Language\zh-CN.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<None Include="Resources\copy.png" />
<None Include="Resources\validate.png" />
<None Include="Resources\filter.png" />
......
......@@ -82,10 +82,19 @@ namespace SmartScan
LogNet.log.Info("Work scan is done");
List<KeyValuePair<string, string>> result = new List<KeyValuePair<string, string>>();
#region 判断是否需要请求http替换数据
if (BLL.Config.isReplaceData)
{
Dictionary<string, string> keyValues = new Dictionary<string, string>();
workCodeKeyword= BLLCommon.extension.ReplaceData(workCodeKeyword);
}
#endregion
foreach (var wc in workCodeKeyword)
{
result.Add(new KeyValuePair<string, string>(wc.Key, wc.Value));
}
}
return new WebResultCode() { workCodeKeyword = result, workCodeInfo = workCodeInfo };
}
catch (Exception ex)
......
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="log4net" publicKeyToken="669e0ddf0bb1aa2a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.15.0" newVersion="2.0.15.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
......@@ -80,6 +80,7 @@ namespace paddleOCR
int flag;
log.Info($"准备读取图像:{imgPath}");
flag = VisionAPI.eyemImageRead(imgPath, -1, out image);
log.Info($"图像通道为:{image.iChannels}");
log.Info($"读取图像:{imgPath},rtnCode={flag}");
///实例分割
///
......@@ -295,9 +296,9 @@ namespace paddleOCR
EyemImage image = new EyemImage();
EyemImage tpDstImg = new EyemImage();
int flag;
log.Info($"OCRHandleRewrite:OCRHandleRewrite:准备读取图像:{imgPath}");
log.Info($"OCRHandleRewrite:准备读取图像:{imgPath}");
flag = VisionAPI.eyemImageRead(imgPath, -1, out image);
log.Info($"OCRHandleRewrite:读取图像:{imgPath},rtnCode={flag}");
log.Info($"OCRHandleRewrite:读取图像:{imgPath},rtnCode={flag},通道数为{image.iChannels}");
///实例分割
{
RotateBox container = new RotateBox();
......@@ -431,7 +432,7 @@ namespace paddleOCR
string[] strs = stringLists.ToArray();
foreach (string str in strs)
{
if (string.IsNullOrEmpty(str)) continue;
if (string.IsNullOrWhiteSpace(str)) continue;
result += str + ";";
}
if (result.EndsWith(";"))
......
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="log4net" version="2.0.15" targetFramework="net472" />
<package id="PaddleOCRSharp" version="2.3.0" targetFramework="net472" requireReinstallation="true" />
<package id="Newtonsoft.Json" version="12.0.1" targetFramework="net48" />
<package id="PaddleOCRSharp" version="2.3.0" targetFramework="net48" />
</packages>
\ No newline at end of file
......@@ -15,6 +15,21 @@
<TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>x64</PlatformTarget>
......@@ -79,12 +94,11 @@
<Reference Include="log4net, Version=2.0.15.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.15\lib\net45\log4net.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\SmartScan\bin\Debug\Newtonsoft.Json.dll</HintPath>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="PaddleOCRSharp, Version=2.3.0.0, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\PaddleOCRSharp.2.3.0\lib\net472\PaddleOCRSharp.dll</HintPath>
<HintPath>..\packages\PaddleOCRSharp.2.3.0\lib\net48\PaddleOCRSharp.dll</HintPath>
</Reference>
<Reference Include="System">
<HintPath>..\..\..\..\..\..\..\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\System.dll</HintPath>
......@@ -159,11 +173,23 @@
<Name>Model</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.8">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.8 %28x86 和 x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\PaddleOCRSharp.2.3.0\build\PaddleOCRSharp.targets" Condition="Exists('..\packages\PaddleOCRSharp.2.3.0\build\PaddleOCRSharp.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
<ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\PaddleOCRSharp.2.3.0\build\PaddleOCRSharp.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\PaddleOCRSharp.2.3.0\build\PaddleOCRSharp.targets'))" />
</Target>
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!