Commit 57adacc3 LN

匈牙利料仓增加文件条码读取功能

1 个父辈 e2bf183f
......@@ -46,6 +46,10 @@
<add key="DIMS" value="20" />
<add key="DOMS" value="200" />
<add key="SinglePosId" value="1#AC2_1_1_6" />
<!--是否使用文件条码 ,1=使用文件二维码,不需要扫码,0=使用相机扫码-->
<add key ="UseFileCode" value ="1"/>
<!--条码文件的位置,绝对路径-->
<add key ="CodeFilePath" value ="D:\CodeFile.txt"/>
</appSettings>
<log4net>
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
......
......@@ -1775,5 +1775,16 @@ namespace OnlineStore.AutoInOutStore
}
}
private void button1_Click_2(object sender, EventArgs e)
{
FileCodeController.ReloadFileCode();
}
private void btnGetCode_Click(object sender, EventArgs e)
{
string code = FileCodeController.NextCode();
MessageBox.Show(code);
}
}
}
......@@ -222,5 +222,23 @@ DI9 不要,只判断DI10
20190814修改:
匈牙利条码拼接修改,如果有2T475则拼接,没有的话按原来的方式返回。
// p/n 的码是P打头,SKID码是2T475打头
// RI;PN;QTY
\ No newline at end of file
//p/n 的码是P打头,SKID码是2T475打头
// RI;PN;QTY
20190816匈牙利料仓增加文件条码读取功能:
AutoInOutStore.exe.config增加配置:
<!--是否使用文件条码 ,1=使用文件二维码,不需要扫码,0=使用相机扫码-->
<add key ="UseFileCode" value ="1"/>
<!--条码文件的位置,绝对路径-->
<add key ="CodeFilePath" value ="D:\CodeFile.txt"/>
文件格式(PN1和RI1为最下面料盘的条码,以此类推):
PN1
RI1
PN2
RI2
PN3
RI3
PN4
RI4
\ No newline at end of file
......@@ -93,5 +93,15 @@ namespace OnlineStore.Common
/// 单盘入库默认PosID
/// </summary>
public static string SinglePosId = "SinglePosId";
/// <summary>
/// 是否使用远程文件条码 ,1=使用文件二维码,不需要扫码
/// </summary>
public static string UseFileCode = "UseFileCode";
/// <summary>
/// 条码文件的位置,绝对路径
/// </summary>
public static string CodeFilePath = "CodeFilePath";
}
}
......@@ -59,6 +59,7 @@
<Compile Include="acSingleStore\AC_SA_BoxBean.cs" />
<Compile Include="acSingleStore\AC_SA_BoxBean_Partial.cs" />
<Compile Include="acSingleStore\AutomaticBaiting_Partial.cs" />
<Compile Include="acSingleStore\FileCodeController.cs" />
<Compile Include="acSingleStore\StoreManager.cs" />
<Compile Include="acSingleStore\AutomaticBaiting.cs" />
<Compile Include="DeviceLibrary\IO\AIOBOX\BLL2.cs" />
......
......@@ -311,6 +311,7 @@ namespace OnlineStore.DeviceLibrary
StoreMove.NewMove(StoreMoveType.InStore);
StoreMove.NextMoveStep(StoreMoveStep.AUTO_I01_Wait);
LogUtil.info(Name + "启动入料");
FileCodeController.ReloadFileCode();
return true;
}
else
......@@ -629,11 +630,27 @@ namespace OnlineStore.DeviceLibrary
if (IOManager.IOValue(IO_Type.TrayCheck_LoadMaterial).Equals(IO_VALUE.HIGH))
{
StoreMove.NextMoveStep(StoreMoveStep.AUTO_I03_ScanCode);
LogUtil.info(Name + "入料: 开始扫码,最多等待6000 ");
StoreMove.OneWaitCanEndStep = true;
StoreMove.WaitList.Add(WaitResultInfo.WaitCodeOK());
StoreMove.WaitList.Add(WaitResultInfo.WaitTime(6000));
GetCameraCode();
if (FileCodeController.UseFileCode)
{
StoreMove.WaitList.Add(WaitResultInfo.WaitTime(1000));
string code = FileCodeController.NextCode();
LogUtil.info(Name + "入料: 开始扫码,获取下一个文件二维码 : "+code);
LastCodeList = new List<string> { code };
LastCode = code;
if (LastCode.Equals(""))
{
StoreManager.Store.CodeOrInoutMsg = ResourceControl.GetString(ResourceControl.InStoreNoCode, "未扫到二维码,需要将料盘送出");
LogUtil.error("未扫到二维码,需要将料盘送出");
}
}
else
{
LogUtil.info(Name + "入料: 开始扫码,最多等待6000 ");
StoreMove.OneWaitCanEndStep = true;
StoreMove.WaitList.Add(WaitResultInfo.WaitCodeOK());
StoreMove.WaitList.Add(WaitResultInfo.WaitTime(6000));
GetCameraCode();
}
}
else
{
......
......@@ -380,6 +380,11 @@ namespace OnlineStore.DeviceLibrary
// RI;PN;QTY
string split = ";";
string result = "";
//如果使用文件条码,直接返回
if (FileCodeController.UseFileCode)
{
return result;
}
try
{
List<string> rCodes = new List<string>();
......
using OnlineStore.Common;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OnlineStore.DeviceLibrary
{
/// <summary>
/// 文件条码操作类
/// </summary>
public class FileCodeController
{
public static bool UseFileCode = false;
public static string FilePath = "";
public static List<string> CurrCodeList = new List<string>();
public static int CurrCodeIndex = -1;
static FileCodeController()
{
int isuse = ConfigAppSettings.GetIntValue(Setting_Init.UseFileCode);
if (isuse.Equals(1))
{
FilePath = ConfigAppSettings.GetValue(Setting_Init.CodeFilePath);
if (!FilePath.Equals(""))
{
UseFileCode = true;
}
}
}
/// <summary>
/// 点击开始批量入库,开始读取文件并把条码放入内存
/// </summary>
/// <returns></returns>
public static bool ReloadFileCode()
{
if (!UseFileCode)
{
return false ;
}
try
{
CurrCodeList = new List<string>();
CurrCodeIndex = -1;
List<string> Data = new List<string>();
if (File.Exists(FilePath))
{
string[] allLines = File.ReadAllLines(FilePath);
foreach (string str in allLines)
{
string code = str.Trim();
if (String.IsNullOrEmpty(code))
{
continue;
}
Data.Add(str);
}
//清理文件内容
File.WriteAllLines(FilePath, new string[] { });
}
else
{
LogUtil.error("文件【" + FilePath + "】不存在");
return false;
}
//文件格式,需要拼接成:RI:PN:Q
//PN1
//RI1
//PN2
//RI2
//倒叙拼接二维码
if (Data.Count > 0)
{
string codeMsg = "";
for (int i = Data.Count - 1; i >= 1; i -= 2)
{
string ri = Data[i];
string pn = Data[i - 1];
string code = ri + ";" + pn + ";1";
CurrCodeList.Add(code);
codeMsg += code + "\r\n";
}
LogUtil.info("文件【" + FilePath + "】解析到条码=\r\n" + codeMsg);
}
else
{
LogUtil.error("文件【" + FilePath + "】未读取到条码");
}
}
catch (Exception ex)
{
LogUtil.error("ReloadFileCode出错:" + ex.ToString());
}
return false;
}
public static string NextCode()
{
if (UseFileCode&&CurrCodeList.Count > 0)
{
CurrCodeIndex++;
if (CurrCodeList.Count > CurrCodeIndex)
{
return CurrCodeList[CurrCodeIndex];
}
}
return "";
}
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!