Commit c9f8daa6 几米阳光

扫码修改:条形码需要拼接后发给服务器

1 个父辈 bde15ec7
此文件类型无法预览
......@@ -1013,6 +1013,14 @@ namespace OnlineStore.ACSingleStore
private void 扫码测试ToolStripMenuItem_Click(object sender, EventArgs e)
{
//List<string> acodeList = new List<string>();
//acodeList.Add("HCT546598.3");
//acodeList.Add("C18 / 22");
//acodeList.Add("R1");
//acodeList.Add("P1277016004");
//acodeList.Add("Q247");
//string result = CodeManager.ProcessBarcode(acodeList, 8);
store.KNDIOMove(IO_Type.CameraLight_Power, IO_VALUE.HIGH);
string message = "";
string outMsg = "";
......
......@@ -42,7 +42,7 @@
RC32-1 1174631483
RC32-2 1170697846
新拉分支:RC32-SZBOSCH-ACSingleStore 作为RC32珠海博世料仓代码。
新拉分支:RC32-SZBOSCH-ACSingleStore 作为RC32苏州博世料仓代码。
苏州博世料仓修改RC32需要修改:
......
......@@ -1483,27 +1483,28 @@ namespace OnlineStore.DeviceLibrary
DateTime date = DateTime.Now;
scanTimer.Enabled = false;
KNDIOMove(IO_Type.CameraLight_Power, IO_VALUE.HIGH);
string outMsg = "";
//string outMsg = "";
string message = "";
List<string> codeList = CodeManager.CameraScan();
if (codeList.Count <= 0)
message = CodeManager.ProcessBarcode(codeList, height);
if (codeList.Count <= 0||message.Equals(""))
{
codeList = CodeManager.CameraScan();
message = CodeManager.ProcessBarcode(codeList, height);
}
//= 1 + 123.4x100.5 - 7x12 = CODE
foreach (string str in codeList)
{
string code = str;
code = "=1+0x0-7x" + height + "=" + code;
message = message + code + spiltStr;
}
if (!outMsg.Equals(""))
{
CodeMsg = "盘尺寸错误,清理二维码【" + message + "】";
LogUtil.error("盘尺寸错误,清理二维码【" + message + "】");
message = "";
}
//foreach (string str in codeList)
//{
// string code = str;
// code = "=1+0x0-7x" + height + "=" + code;
// message = message + code + spiltStr;
//}
//if (!outMsg.Equals(""))
//{
// CodeMsg = "盘尺寸错误,清理二维码【" + message + "】";
// LogUtil.error("盘尺寸错误,清理二维码【" + message + "】");
// message = "";
//}
KNDIOMove(IO_Type.CameraLight_Power, IO_VALUE.LOW);
onCodeReceived(message);
}
......
......@@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Runtime.ExceptionServices;
using System.Text;
using System.Windows.Forms;
......@@ -90,8 +91,8 @@ namespace OnlineStore.DeviceLibrary
}
return bitm;
}
public static List<string> CameraScan( )
[HandleProcessCorruptedStateExceptions]
public static List<string> CameraScan()
{
List<string> codeList = new List<string>();
List<CodeInfo> allCodeList = new List<CodeInfo>();
......@@ -122,14 +123,20 @@ namespace OnlineStore.DeviceLibrary
}
}
allCodeList.AddRange(cc);
bitmap.Dispose();
}
}
}
catch (AccessViolationException e)
{
LogUtil.error("扫码出现AccessViolationException异常:" + e.ToString());
GC.Collect();
}
catch (Exception ex)
{
LogUtil.error("扫码出错:" + ex.ToString());
}
foreach(CodeInfo info in allCodeList)
foreach (CodeInfo info in allCodeList)
{
codeList.Add(info.CodeStr);
}
......@@ -150,7 +157,55 @@ namespace OnlineStore.DeviceLibrary
{
return "";
}
}
}
public static string ProcessBarcode(List<string> codeList,int height)
{
// 条码前面字母去掉之后用分号分割,最后不加分号
//P; H; Q
//code = "=1+0x0-7x" + height + "=" + code;
string split = ";";
string result = "";
try
{
List<string> rCodes = new List<string>();
rCodes.Add(GetCodeByStart(codeList, "P"));
rCodes.Add(GetCodeByStart(codeList, "H"));
rCodes.Add(GetCodeByStart(codeList, "Q"));
foreach (string s in rCodes)
{
if (!s.Equals(""))
{
if (result.Equals(""))
{
result = s;
}
else
{
result =result + split + s;
}
}
}
if (!result.Equals(""))
{
return "=1+0x0-7x" + height + "=" + result;
}
}catch(Exception ex)
{
LogUtil.error("处理二维码出错:"+ex.ToString());
}
return result;
}
private static string GetCodeByStart(List<string> codeList, string start)
{
List<string> pCode = (from m in codeList where m.StartsWith(start) select m).ToList<string>();
if (pCode.Count > 0)
{
return pCode[0].Substring(1, pCode[0].Length - 1);
}
return "";
}
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!