Commit d085dcda 刘韬

添加 标签二次验证结果上传接口

1 个父辈 fcf24ffe
......@@ -277,6 +277,12 @@ namespace BLL
set => config.Write(HTTP_REEL_ID, value);
}
public string HttpLabelReport
{
get => config.Read<string>(Http_Label_Report);
set => config.Write(Http_Label_Report, value);
}
/// <summary>
/// 默认的物料模板名称
/// </summary>
......@@ -407,6 +413,7 @@ namespace BLL
private const string EXTENSION_NAME = "ExtensionGroup";
private const string HTTP_SERVER = "HttpServer";
private const string HTTP_REEL_ID = "HttpReelID";
private const string Http_Label_Report = "HttpLabelReport";
private const string DEFAULT_MATERIAL_NAME = "DefaultMaterialName";
private const string TRIGGER_OPEN_LIGHT = "TriggerOpenLight";
private const string WEB_SERVICE = "WebService";
......
......@@ -265,7 +265,7 @@ namespace BLL
if (!string.IsNullOrEmpty(config.HttpReelID))
if (!string.IsNullOrEmpty(config.HttpReelID.Trim()))
listrow.Add(new object[] { A });
#region 显示替换数据按钮
string pnkey = ConfigHelper.Config.Get("SelectHttpPN_KeyWords", "");
......
......@@ -109,28 +109,6 @@ namespace BLL
{
extension.Check(text);
}
//public bool SetKey(string[] originalCode, Dictionary<string, string> key, bool hasMatch, out string errmsg)
//{
// errmsg = "";
// mesResult = false;
// var now = DateTime.Now;
// bool isSame = false;
// try
// {
// OnKeySet(originalCode, key, hasMatch);
// if (!updatereelid(key, out errmsg))
// return false;
// }
// catch (Exception ex)
// {
// return false;
// }
// return true;
//}
//读码后第一步
//
public bool SetKey(string templateName, string[] originalCode, Dictionary<string, string> key, bool hasMatch, out string errmsg)
{
......@@ -450,8 +428,8 @@ namespace BLL
errmsg = "";
try
{
LogNet.log.Info($"接口上传信息 url: {config.HttpReelID}, data: {JsonConvert.SerializeObject(key)}");
if (!string.IsNullOrEmpty(config.HttpReelID))
LogNet.log.Info($"接口上传信息 url: {config.HttpReelID.Trim()}, data: {JsonConvert.SerializeObject(key)}");
if (!string.IsNullOrEmpty(config.HttpReelID.Trim()))
{
Dictionary<string, object> pairs = new Dictionary<string, object>();
if (!GetHttpReelID(key, out errmsg, out pairs))
......@@ -585,62 +563,6 @@ namespace BLL
.ToList();
}
//private string GetReelid()
//{
// LogNet.log.Debug("Enter GetReelid Method");
// if (extensions != null)
// {
// int idIndex = extensions.FindIndex(match => match.Key == config.ReelIDKeyWord);
// if (idIndex == -1) return "";
// }
// //读取参数
// string matchID = config.ReelIDMatch;
// int matchPlace = config.ReelIDPlaces;
// bool matchFill = config.ReelIDFillZero;
// string matchPrefix = config.ReelIDPrefix;
// string matchPostfix = config.ReelIDPostfix;
// //把key替换成实际值
// string[] keys = ObjConversion.StrGetKey(matchID);
// for (int i = 0; i < keys.Length; i++)
// {
// if (keys[i].ToLower().StartsWith("datetime"))
// {
// string ov = string.Format("[{0}]", keys[i]);
// var d = keys[i].Split(':');
// if (d.Length == 2)
// {
// matchID = matchID.Replace(ov, DateTime.Now.ToString(d[1]));
// }
// else
// {
// matchID = matchID.Replace(ov, DateTime.Now.ToString());
// }
// continue;
// }
// if (extensions != null)
// {
// int index = extensions.FindIndex(match => match.Key == keys[i]);
// if (index == -1) continue;
// string oldValue = string.Format("[{0}]", keys[i]);
// //matchID = matchID.Replace(oldValue, extensions[index].Control.Text);
// matchID = matchID.Replace(oldValue, "");
// }
// }
// //SaveAddReelID();
// var reelID = ReadReelID();
// //填充0
// string text = matchPrefix + matchID;
// if (matchFill)
// text += string.Format("{0:d" + matchPlace + "}", reelID);
// else
// text += reelID.ToString();
// text += matchPostfix;
// return text;
//}
private int ReadReelID()
{
int reelID = 1;
......@@ -704,7 +626,6 @@ namespace BLL
"NEO SCAN",
true);
if (result)
{
lastKeys = null;
......@@ -848,7 +769,7 @@ namespace BLL
{
errmsg = "";
dic = null;
string url = config.HttpReelID;
string url = config.HttpReelID.Trim();
string json = Http.PostJson(url, null, key);
if (json == "")
{
......@@ -863,7 +784,10 @@ namespace BLL
//Dictionary<string, object> dic;
try
{
dic = (Dictionary<string, object>)serializer.DeserializeObject(json);
var raw = (Dictionary<string, object>)serializer.DeserializeObject(json);
// 重新建一个忽略大小写的字典,把数据拷进去
dic = new Dictionary<string, object>(raw, StringComparer.OrdinalIgnoreCase);
}
catch
{
......
......@@ -116,7 +116,7 @@ namespace BLL
if (index > -1) param.Add(key[i], extensions[index].Control.Text);
}
string url = config.HttpReelID;
string url = config.HttpReelID.Trim();
string json = Http.Post(url, param);
if (json == "") return id;
JavaScriptSerializer serializer = new();
......
......@@ -417,3 +417,4 @@ NS_KetRight_Detect 已检测字段 Detected Fields 微软雅黑,12,,
Dialog_NS_KetRight_Detect 已检测字段 Detected Fields 微软雅黑,12,,
Dialog_About_About 关于 About
Dialog_About_mrs 物料注册系统 Material Registration System
Dialog_Using_OCR_Result 是否使用OCR识别结果? 是否使用OCR识别结果? Should OCR recognition results be used?
\ No newline at end of file
using Asa.FaceControl;
using BLL;
using DocumentFormat.OpenXml.Wordprocessing;
using HandyControl.Controls;
using MemoryRead;
using Model;
using OnlineStore.Common.util;
using SmartScan.Form;
......@@ -13,6 +15,7 @@ using System.Drawing.Drawing2D;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Web.Script.Serialization;
using System.Web.UI.WebControls;
using System.Windows;
using System.Windows.Forms;
......@@ -172,7 +175,12 @@ namespace SmartScan
LoadingScreen.Instance.Hide();
originalCodeText = Camera.GetBarCodeText(workCodeInfo);
// 检查条码内容是否与文件中的内容匹配
bool isMatched = CheckCodeWithFileContent(originalCodeText);
bool isMatched = CheckCodeWithFileContent(originalCodeText, out List<string> matchedTexts);
if (isMatched)
{
isMatched = Request_API_C2(matchedTexts);
}
if (isMatched)
{
Check2s?.Invoke("2");
......@@ -242,9 +250,57 @@ namespace SmartScan
});
}
}
private bool Request_API_C2(List<string> matchedTexts)
{
string url = config.HttpLabelReport.Trim();
if (string.IsNullOrWhiteSpace(url))
return true;
var keylist = matchedTexts.Select(x => new { Content = x }).ToList();
var errmsg = "";
Dictionary<string, object> dic = null;
string json = Http.PostJson(url, null, keylist);
if (json == "")
{
LogUtil.info("Api C2 response empty error");
return false;
}
JavaScriptSerializer serializer = new();
try
{
var raw = (Dictionary<string, object>)serializer.DeserializeObject(json);
// 重新建一个忽略大小写的字典,把数据拷进去
dic = new Dictionary<string, object>(raw, StringComparer.OrdinalIgnoreCase);
}
catch
{
LogUtil.info("Api C2 parse error:\r\n" + json);
return MessageboxNeo.Show("BoxReelIDInfoMaintain", errmsg, "NEO SCAN", true);
}
if (!dic.TryGetValue("CODE", out object value))
{
LogUtil.info("Api C2 return data error:\r\n" + json);
return MessageboxNeo.Show("BoxReelIDInfoMaintain", errmsg, "NEO SCAN", true);
}
if (Convert.ToInt32(value) != 0)
{
LogUtil.info("Api C2 parse error:\r\n" + dic["MSG"].ToString());
return MessageboxNeo.Show("BoxReelIDInfoMaintain", errmsg, "NEO SCAN", true);
}
return true;
}
// 修改方法定义
private bool CheckCodeWithFileContent(string[] codeTexts)
private bool CheckCodeWithFileContent(string[] codeTexts, out List<string> matchedCodeText)
{
matchedCodeText = new List<string>();
if (codeTexts == null || codeTexts.Length == 0)
{
LogNet.log.Warn("条码文本数组为空,无法进行匹配");
......@@ -274,6 +330,7 @@ namespace SmartScan
{
LogNet.log.Info($"条码 {codeText} 在文件中找到匹配");
lines.Remove(ln);
matchedCodeText.Add(codeText.Trim());
}
}
}
......@@ -529,7 +586,7 @@ namespace SmartScan
using (Graphics g = Graphics.FromImage(bmp))
{
string str = contenI.ToString();
Font font = new Font("Arial", 60, System.Drawing.FontStyle.Bold);
System.Drawing.Font font = new System.Drawing.Font("Arial", 60, System.Drawing.FontStyle.Bold);
SizeF sz = g.MeasureString(str, font);
// 为了让文字中心落在 info.Center 上
......@@ -548,14 +605,14 @@ namespace SmartScan
StringFormat.GenericDefault);
// 描边宽度可调
using (Pen pen = new Pen(Color.White, 10f))
using (Pen pen = new Pen(System.Drawing.Color.White, 10f))
{
pen.LineJoin = LineJoin.Round;
g.DrawPath(pen, gp);
}
// 2. 填充红色字
using (Brush brush = new SolidBrush(Color.Red))
using (Brush brush = new SolidBrush(System.Drawing.Color.Red))
{
g.FillPath(brush, gp);
}
......@@ -808,7 +865,7 @@ namespace SmartScan
if (workCodeKeyword.Any(a => a.Value.StartsWith("<OCR>")))
{
BLLCommon.extension.DrawTextBackground(workCodeKeyword);
bool results = NeoAlertBox.Show("","Using OCR Result",AlertType.Warning,"NEO SCAN",true);
bool results = NeoAlertBox.Show("", Language.Dialog("Using_OCR_Result", "是否使用OCR识别结果?"),AlertType.Warning,"NEO SCAN",true);
//FrmDrawText frmDraw = new FrmDrawText();
if (results == true)
{
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!