Commit 52e9a7f9 张东亮

两盘料库位调试

1 个父辈 fc6eba39
...@@ -164,6 +164,10 @@ namespace OnlineStore.ACPackingStore ...@@ -164,6 +164,10 @@ namespace OnlineStore.ACPackingStore
{ {
lblMoveEquipInfo.Text = "出库:" + BoxBean.MoveInfo.MoveParam.ToShortStr(); lblMoveEquipInfo.Text = "出库:" + BoxBean.MoveInfo.MoveParam.ToShortStr();
} }
else if (BoxBean.MoveInfo.MoveType.Equals(StoreMoveType.CheckPos))
{
lblMoveEquipInfo.Text = "库位调试:" + BoxBean.MoveInfo.MoveParam.ToShortStr();
}
else else
{ {
lblMoveEquipInfo.Text = ""; lblMoveEquipInfo.Text = "";
...@@ -206,43 +210,50 @@ namespace OnlineStore.ACPackingStore ...@@ -206,43 +210,50 @@ namespace OnlineStore.ACPackingStore
} }
} }
} }
if (!BoxBean.PosDebugInfo.AutoInOutPosTest)
if (BoxBean.AutoInout.autoNext)
{ {
string msg = BoxBean.AutoInout.autoMsg; btnStartAuTo.Text = "开始自动库位调试";
lblMsg.Text = msg;
if (btnStartAuTo.Text.Equals("开始自动出入库"))
{
btnStartAuTo.Text = "停止自动出入库";
}
try
{
msg = msg.Replace("自动出库:", "");
msg = msg.Replace("自动入库:", "");
int index = BoxBean.PositionNumList.IndexOf(msg);
if (index >= 0 && (!msg.Equals("")))
{
cmbPosition.SelectedIndex = index;
}
}
catch (Exception ex) { }
} }
else else
{ {
// lblMsg.Text = "没有开启自动出入库"; btnStartAuTo.Text = "停止自动库位调试";
if (btnStartAuTo.Text.Equals("停止自动出入库"))
{
btnStartAuTo.Text = "开始自动出入库";
}
} }
//if (BoxBean.AutoInout.autoNext)
//{
// string msg = BoxBean.AutoInout.autoMsg;
// lblMsg.Text = msg;
// if (btnStartAuTo.Text.Equals("开始自动出入库"))
// {
// btnStartAuTo.Text = "停止自动出入库";
// }
// try
// {
// msg = msg.Replace("自动出库:", "");
// msg = msg.Replace("自动入库:", "");
// int index = BoxBean.PositionNumList.IndexOf(msg);
// if (index >= 0 && (!msg.Equals("")))
// {
// cmbPosition.SelectedIndex = index;
// }
// }
// catch (Exception ex) { }
//}
//else
//{
// // lblMsg.Text = "没有开启自动出入库";
// if (btnStartAuTo.Text.Equals("停止自动出入库"))
// {
// btnStartAuTo.Text = "开始自动出入库";
// }
//}
} }
else else
{ {
lblThisSta.Text = "等待启动"; lblThisSta.Text = "等待启动";
// lblWarnMsg.Text = ""; // lblWarnMsg.Text = "";
btnStartAuTo.Text = "开始自动出入库"; //btnStartAuTo.Text = "开始自动出入库";
} }
if(BoxBean.CompressSigTimeOut) if (BoxBean.CompressSigTimeOut)
{ {
btnClearcurState.Visible = true; btnClearcurState.Visible = true;
} }
...@@ -607,27 +618,24 @@ namespace OnlineStore.ACPackingStore ...@@ -607,27 +618,24 @@ namespace OnlineStore.ACPackingStore
{ {
if (BoxBean.storeRunStatus >= StoreRunStatus.HomeMoving) if (BoxBean.storeRunStatus >= StoreRunStatus.HomeMoving)
{ {
if (BoxBean.AutoInout.autoNext) if (BoxBean.PosDebugInfo.AutoInOutPosTest)
{ {
BoxBean.AutoInout.StopAuto(); BoxBean.PosDebugInfo.StopAutoInOutTest();
btnStartAuTo.Text = "开始自动出入库"; btnStartAuTo.Text = "开始自动库位调试";
} }
else else
{ {
DialogResult res = MessageBox.Show("确定开始自动出入库?", "提示", MessageBoxButtons.YesNo); DialogResult res = MessageBox.Show("确定开始自动库位调试?", "提示", MessageBoxButtons.YesNo);
if (res.Equals(DialogResult.Yes) && cmbPosition.SelectedIndex >= 0) if (res.Equals(DialogResult.Yes) && cmbPosition.SelectedIndex >= 0)
{ {
int jiange = FormUtil.GetIntValue(txtJiange);
int currIndex = cmbPosition.SelectedIndex;
BoxBean.AutoInout.StartAuto(jiange, currIndex, cmbShelfPosition.Text);
string poText = cmbPosition.Text; string poText = cmbPosition.Text;
BoxBean.AutoInout.autoMsg = "自动出库:" + poText; LogUtil.info(BoxBean.Name + "开启自动库位调试,开始位置【" + poText + "】");
LogUtil.info(BoxBean.Name + "开启自动出入库模式,开始位置【" + poText + "】(索引=" + currIndex + "),间隔=" + jiange + ",入库开始!"); if (BoxBean.PosDebugInfo.StartAutoInOutTest(poText, out string msg))
//BoxBean.StartOutStoreMove(new InOutStoreParam("", poText)); btnStartAuTo.Text = "停止自动库位调试";
BoxBean.StartInStoreMove(new InOutParam("", poText, cmbShelfPosition.Text)); else
{
btnStartAuTo.Text = "停止自动出入库"; MessageBox.Show("启动自动库位调试失败:" + msg, "提示");
}
} }
} }
} }
......
...@@ -72,6 +72,7 @@ ...@@ -72,6 +72,7 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="PackingStore\AC_BOX_Bean_AutoInOutTest.cs" />
<Compile Include="PackingStore\AC_BOX_Bean_server_connect.cs" /> <Compile Include="PackingStore\AC_BOX_Bean_server_connect.cs" />
<Compile Include="PackingStore\AC_BOX_Bean.cs" /> <Compile Include="PackingStore\AC_BOX_Bean.cs" />
<Compile Include="PackingStore\AC_BOX_Bean_OutStore.cs" /> <Compile Include="PackingStore\AC_BOX_Bean_OutStore.cs" />
......
...@@ -89,6 +89,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -89,6 +89,7 @@ namespace OnlineStore.DeviceLibrary
} }
List<ShelfPosition> sPlist = CSVPositionReader<ShelfPosition>.getPositionList(); List<ShelfPosition> sPlist = CSVPositionReader<ShelfPosition>.getPositionList();
ShelfPosList = new List<string>(); ShelfPosList = new List<string>();
PosDebugInfo = new PosDebugInfo(this);
foreach (ShelfPosition p in sPlist) foreach (ShelfPosition p in sPlist)
{ {
if (p.StoreId.Equals(DeviceID)) if (p.StoreId.Equals(DeviceID))
...@@ -252,7 +253,6 @@ namespace OnlineStore.DeviceLibrary ...@@ -252,7 +253,6 @@ namespace OnlineStore.DeviceLibrary
return; return;
} }
InoutStartReset(); InoutStartReset();
isInPro = false;
} }
private void InoutStartReset() private void InoutStartReset()
{ {
...@@ -852,7 +852,6 @@ namespace OnlineStore.DeviceLibrary ...@@ -852,7 +852,6 @@ namespace OnlineStore.DeviceLibrary
ACServerManager.SuddenStop(Config.Comp_Axis.DeviceName, Config.Comp_Axis.GetAxisValue()); ACServerManager.SuddenStop(Config.Comp_Axis.DeviceName, Config.Comp_Axis.GetAxisValue());
CloseAllAxis(); CloseAllAxis();
LogInfo("StopMove"); LogInfo("StopMove");
isInPro = false;
} }
private void MoveEndToRuningStatus() private void MoveEndToRuningStatus()
......
...@@ -518,6 +518,11 @@ namespace OnlineStore.DeviceLibrary ...@@ -518,6 +518,11 @@ namespace OnlineStore.DeviceLibrary
} }
} }
protected override void InOuTestProcess()
{
throw new NotImplementedException();
}
#endregion #endregion
} }
......
...@@ -246,6 +246,12 @@ namespace OnlineStore.DeviceLibrary ...@@ -246,6 +246,12 @@ namespace OnlineStore.DeviceLibrary
return true; return true;
} }
public static bool LoadSameSizePos(string posId, out List<ACBoxPosition> boxPositions)
{
boxPositions = CSVPositionReader<ACBoxPosition>.GetSameSizePositons(posId);
if (boxPositions == null || boxPositions.Count < 3) return false;
return true;
}
#endregion #endregion
......
...@@ -18,7 +18,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -18,7 +18,7 @@ namespace OnlineStore.DeviceLibrary
//public static uint DefaultDICount = 16; //public static uint DefaultDICount = 16;
//public static uint DefaultDOCount = 16; //public static uint DefaultDOCount = 16;
// public readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); // public readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public Dictionary<string, AIOBOX> AIOMap = new Dictionary<string, AIOBOX>(); public Dictionary<string, AIOBOX> AIOMap = new Dictionary<string, AIOBOX>();
public Dictionary<string, List<Box_Sta>> DIValueMap = new Dictionary<string, List<Box_Sta>>(); public Dictionary<string, List<Box_Sta>> DIValueMap = new Dictionary<string, List<Box_Sta>>();
...@@ -122,7 +122,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -122,7 +122,7 @@ namespace OnlineStore.DeviceLibrary
} }
catch (Exception ex) catch (Exception ex)
{ {
LogUtil.error("关闭Io模块【" + ioIp + "】出错:"+ ex.ToString()); LogUtil.error("关闭Io模块【" + ioIp + "】出错:" + ex.ToString());
} }
AIOMap.Remove(ioIp); AIOMap.Remove(ioIp);
} }
...@@ -134,12 +134,12 @@ namespace OnlineStore.DeviceLibrary ...@@ -134,12 +134,12 @@ namespace OnlineStore.DeviceLibrary
{ {
DOValueMap.Remove(ioIp); DOValueMap.Remove(ioIp);
} }
int DIMS = ConfigAppSettings.GetIntValue("DIMS",60); int DIMS = ConfigAppSettings.GetIntValue("DIMS", 60);
if (DIMS < 20) if (DIMS < 20)
{ {
DIMS = 20; DIMS = 20;
} }
int DOMS = ConfigAppSettings.GetIntValue("DOMS",300); int DOMS = ConfigAppSettings.GetIntValue("DOMS", 300);
if (DOMS < 200) if (DOMS < 200)
{ {
DOMS = 200; DOMS = 200;
...@@ -201,7 +201,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -201,7 +201,7 @@ namespace OnlineStore.DeviceLibrary
} }
catch (Exception error) catch (Exception error)
{ {
LogUtil.error( "连接IO模块 " + logName + " 出错:" + error.ToString()); LogUtil.error("连接IO模块 " + logName + " 出错:" + error.ToString());
} }
} }
...@@ -390,7 +390,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -390,7 +390,7 @@ namespace OnlineStore.DeviceLibrary
} }
else else
{ {
LogUtil.error( "WriteSingleDO出错 没有连接IO模块:" + ioIp); LogUtil.error("WriteSingleDO出错 没有连接IO模块:" + ioIp);
} }
} }
catch (Exception ex) catch (Exception ex)
...@@ -415,11 +415,11 @@ namespace OnlineStore.DeviceLibrary ...@@ -415,11 +415,11 @@ namespace OnlineStore.DeviceLibrary
try try
{ {
aioBox.WriteDO(StartAddress, aioBox.ReverseStatus(currBox_Sta)); aioBox.WriteDO(StartAddress, aioBox.ReverseStatus(currBox_Sta));
LogUtil.debug( "**********定时回写入 IO [" + ioIp + "] [" + StartAddress + "]值" + aioBox.ReverseStatus(currBox_Sta) + "】:"); LogUtil.debug("**********定时回写入 IO [" + ioIp + "] [" + StartAddress + "]值" + aioBox.ReverseStatus(currBox_Sta) + "】:");
} }
catch (Exception ex) catch (Exception ex)
{ {
LogUtil.error( "**********定时回写入 出错:" + ex.StackTrace); LogUtil.error("**********定时回写入 出错:" + ex.StackTrace);
} }
}; };
mytimer.AutoReset = false;//设置是否自动重启,即自动执行多次; mytimer.AutoReset = false;//设置是否自动重启,即自动执行多次;
...@@ -428,7 +428,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -428,7 +428,7 @@ namespace OnlineStore.DeviceLibrary
} }
else else
{ {
LogUtil.error( "AIO WriteSingleDO [" + ioIp + "] [" + StartAddress + "] 出错 没有连接IO模块:" + ioIp); LogUtil.error("AIO WriteSingleDO [" + ioIp + "] [" + StartAddress + "] 出错 没有连接IO模块:" + ioIp);
} }
} }
catch (Exception ex) catch (Exception ex)
...@@ -508,9 +508,16 @@ namespace OnlineStore.DeviceLibrary ...@@ -508,9 +508,16 @@ namespace OnlineStore.DeviceLibrary
Box_Sta sta = Box_Sta.Off; Box_Sta sta = Box_Sta.Off;
// Box_Addr addr = GetAddr(StartAddress); // Box_Addr addr = GetAddr(StartAddress);
int index = StartAddress; int index = StartAddress;
if (DIValueMap.ContainsKey(ioIP) && DIValueMap[ioIP].Count > index) if (Monitor.IsEntered(DILock))
{ {
sta = DIValueMap[ioIP][index]; if (DIValueMap.ContainsKey(ioIP) && DIValueMap[ioIP].Count > index)
{
sta = DIValueMap[ioIP][index];
}
else
{
sta = aioBox.ReadDI(StartAddress);
}
} }
else else
{ {
...@@ -544,7 +551,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -544,7 +551,7 @@ namespace OnlineStore.DeviceLibrary
} }
catch (Exception ex) catch (Exception ex)
{ {
LogUtil.error( " GetIOValue [" + configIO.IO_IP + "] [" + configIO.GetIOAddr() + "] 获取数据出错:" + ex.ToString()); LogUtil.error(" GetIOValue [" + configIO.IO_IP + "] [" + configIO.GetIOAddr() + "] 获取数据出错:" + ex.ToString());
} }
return value; return value;
} }
......
...@@ -167,7 +167,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -167,7 +167,7 @@ namespace OnlineStore.DeviceLibrary
{ {
LogUtil.error( "GetPositon[" + CurShelfPosID + "]=null,没有库位不能执行出入库"); LogUtil.error( "GetPositon[" + CurShelfPosID + "]=null,没有库位不能执行出入库");
} }
if (MoveP == null) MoveP = new LineMoveP();
MoveP.InOut_P101 = sp.InoutAxis_P101; MoveP.InOut_P101 = sp.InoutAxis_P101;
MoveP.UpDown_LP101 = sp.UpDownAxis_LP101; MoveP.UpDown_LP101 = sp.UpDownAxis_LP101;
MoveP.UpDown_HP102 = sp.UpDownAxis_HP102; MoveP.UpDown_HP102 = sp.UpDownAxis_HP102;
......
...@@ -121,42 +121,45 @@ namespace OnlineStore.DeviceLibrary ...@@ -121,42 +121,45 @@ namespace OnlineStore.DeviceLibrary
/// <summary> /// <summary>
/// 运动处理 /// 运动处理
/// </summary> /// </summary>
protected bool isInPro = false; protected object isInPro = new object();
protected virtual void BusyMoveProcess() protected virtual void BusyMoveProcess()
{ {
//if (isInPro) if(Monitor.TryEnter(isInPro))
//{
// return;
//}
isInPro = true;
try
{ {
switch (MoveInfo.MoveType) try
{ {
case StoreMoveType.InStore: switch (MoveInfo.MoveType)
InStoreProcess(); {
isInPro = false; case StoreMoveType.InStore:
break; InStoreProcess();
case StoreMoveType.OutStore: break;
OutStoreProcess(); case StoreMoveType.OutStore:
isInPro = false; OutStoreProcess();
break;
case StoreMoveType.ReturnHome: break;
ResetProcess(); case StoreMoveType.ReturnHome:
isInPro = false; ResetProcess();
break;
case StoreMoveType.StoreReset: break;
ResetProcess(); case StoreMoveType.StoreReset:
isInPro = false; ResetProcess();
break;
default: break; break;
case StoreMoveType.CheckPos:
InOuTestProcess();
break;
default: break;
}
}
catch (Exception ex)
{
LogUtil.error("BusyMoveProcess出错:" + ex.ToString());
}finally
{
Monitor.Exit(isInPro);
} }
} }
catch (Exception ex)
{
LogUtil.error("BusyMoveProcess出错:" + ex.ToString());
}
isInPro = false;
} }
protected void SaveAlarmInfo(StoreAlarmType alarmType, string alarmDetial, string alarmMsg, StoreMoveType storeMoveType) protected void SaveAlarmInfo(StoreAlarmType alarmType, string alarmDetial, string alarmMsg, StoreMoveType storeMoveType)
{ {
...@@ -227,7 +230,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -227,7 +230,7 @@ namespace OnlineStore.DeviceLibrary
/// </summary> /// </summary>
protected abstract void ResetProcess(); protected abstract void ResetProcess();
protected abstract void InOuTestProcess();
/// <summary> /// <summary>
/// 松下伺服轴原点返回运动,等待收到反馈后才会返回 /// 松下伺服轴原点返回运动,等待收到反馈后才会返回
/// </summary> /// </summary>
......
...@@ -590,6 +590,140 @@ namespace OnlineStore.DeviceLibrary ...@@ -590,6 +590,140 @@ namespace OnlineStore.DeviceLibrary
/// </summary> /// </summary>
SO_21_UrgentLineRun, SO_21_UrgentLineRun,
#endregion #endregion
BT_01_StartGetTray,
BT_02_InOutToP1,
/// <summary>
/// 料架取料:升降轴移动到P101低点,旋转轴移动到P101点,压紧轴到压紧前点
/// </summary>
BT_03_MoveToShelf,
/// <summary>
/// 料架取料:叉子前进到P101点
/// </summary>
BT_04_InoutToP101,
/// <summary>
/// 料架取料:升降轴上升到P102点
/// </summary>
BT_05_UpdownToP102,
/// <summary>
/// 料架取料:压紧轴开始缓慢压紧
/// </summary>
BT_06_StartCompress,
/// <summary>
/// 料架取料:检测到料叉压紧确认信号,再次向下压紧指定的值
/// </summary>
BT_06_ComDownMove,
/// <summary>
/// 料架取料:记录压紧高度,叉子后退到P1
/// </summary>
BT_07_InoutBack,
/// <summary>
/// 料架取料: 获取库位号完成,设置位置参数, 准备入库
/// </summary>
//BT_08_SetInstoreParam,
/// <summary>
/// 入库。。移动到库位点,旋转轴至P2( 库位点)轴2(上下) 至P3(库位入库前点)
/// </summary>
BT_09_MoveToBag,
/// <summary>
/// 入库。。叉子进入库位中,进出轴到库位P3
/// </summary>
BT_10_DeviceToBag,
/// <summary>
/// 入库。。放下物品,升降轴到库位缓冲点P4,压紧轴到P3
/// </summary>
BT_11_PutWareToBag,
/// <summary>
/// 入库。。叉子从库位中返回,进出轴到P1
/// </summary>
BT_12_DeviceBackFromBag,
BT_14_StartInOutTest,
/// <summary>
/// 料仓出库,,所有轴运行到库位,压紧轴到压紧前点P3 ,旋转轴到库位点P2,轴2(上下) 至P5(库位出库前点)
/// </summary>
BT_15_ToPosition,
/// <summary>
/// 料仓出库,,叉子进入库位中, 进出轴到库位P3
/// </summary>
BT_16_ToPos,
/// <summary>
///料仓出库,, 库位的物品放入叉子上,轴2( 上下) 至P6( 库位出料缓冲点),轴4( 压紧) 至P2(压紧点)
/// </summary>
BT_17_GetReel,
/// <summary>
///料仓出库,,叉子从 库位返回,轴3( 叉子) 至P1( 待机点)
/// </summary>
BT_18_InoutBack,
/// <summary>
/// 料仓出库,等待压紧信号确认
/// </summary>
BT_19_CheckComSig,
/// <summary>
/// 料架取料: 获取库位号完成,设置位置参数, 准备入库
/// </summary>
BT_20_SetInstoreParam,
/// <summary>
/// 入库。。移动到库位点,旋转轴至P2( 库位点)轴2(上下) 至P3(库位入库前点)
/// </summary>
BT_21_MoveToBag,
/// <summary>
/// 入库。。叉子进入库位中,进出轴到库位P3
/// </summary>
BT_22_DeviceToBag,
/// <summary>
/// 入库。。放下物品,升降轴到库位缓冲点P4,压紧轴到P3
/// </summary>
BT_23_PutWareToBag,
/// <summary>
/// 入库。。叉子从库位中返回,进出轴到P1
/// </summary>
BT_24_DeviceBackFromBag,
BT_25_StartPutTray,
/// <summary>
/// 料仓出库,,所有轴运行到库位,压紧轴到压紧前点P3 ,旋转轴到库位点P2,轴2(上下) 至P5(库位出库前点)
/// </summary>
BT_26_ToPosition,
/// <summary>
/// 料仓出库,,叉子进入库位中, 进出轴到库位P3
/// </summary>
BT_27_ToPos,
/// <summary>
///料仓出库,, 库位的物品放入叉子上,轴2( 上下) 至P6( 库位出料缓冲点),轴4( 压紧) 至P2(压紧点)
/// </summary>
BT_28_GetReel,
/// <summary>
///料仓出库,,叉子从 库位返回,轴3( 叉子) 至P1( 待机点)
/// </summary>
BT_29_InoutBack,
/// <summary>
/// 料仓出库,走到料架位置,旋转轴至P20,升降轴至P102,
/// </summary>
BT_30_ToShelfPosition,
/// <summary>
/// 料仓出库,叉子到料架,进出轴至P20
/// /// </summary>
BT_31_ToShelf,
/// <summary>
/// 料仓出库,,把物品放下,压紧轴到P1,升降轴至P20
/// </summary>
BT_32_PutReel,
/// <summary>
/// 料仓出库,,叉子从出料口返回,,进出轴到P1
/// </summary>
BT_33_InoutBack,
/// <summary>
///返回待机点,轴2/轴1/轴4动作至P1( 待机点))开始
/// </summary>
BT_30_GoBack,
} }
public enum StoreAlarmType public enum StoreAlarmType
......
...@@ -493,9 +493,9 @@ namespace OnlineStore.DeviceLibrary ...@@ -493,9 +493,9 @@ namespace OnlineStore.DeviceLibrary
///// 移栽装置的停止,需要先远点返回,然后停止 ///// 移栽装置的停止,需要先远点返回,然后停止
///// </summary> ///// </summary>
//StopMove=5, //StopMove=5,
///// <summary> /// <summary>
///// 移栽检测托盘 /// 移栽检测托盘
///// </summary> /// </summary>
//CheckFixture=6, CheckPos = 6,
} }
} }
...@@ -8,17 +8,17 @@ using System.IO; ...@@ -8,17 +8,17 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Text; using System.Text;
namespace OnlineStore.LoadCSVLibrary namespace OnlineStore.LoadCSVLibrary
{ {
public class CSVPositionReader<T> : CSVReaderBase where T : PostionBase public class CSVPositionReader<T> : CSVReaderBase where T : PostionBase
{ {
/// <summary> /// <summary>
/// 所有的位置集合,key=位置 /// 所有的位置集合,key=位置
/// </summary> /// </summary>
public static Dictionary<string, Dictionary<string, T>> AllPositionMap = new Dictionary<string, Dictionary<string, T>>(); public static Dictionary<string, Dictionary<string, T>> AllPositionMap = new Dictionary<string, Dictionary<string, T>>();
private static List<string> hasReadFileList = new List<string>(); private static List<string> hasReadFileList = new List<string>();
...@@ -33,7 +33,7 @@ namespace OnlineStore.LoadCSVLibrary ...@@ -33,7 +33,7 @@ namespace OnlineStore.LoadCSVLibrary
AllPositionMap = new Dictionary<string, Dictionary<string, T>>(); AllPositionMap = new Dictionary<string, Dictionary<string, T>>();
hasReadFileList = new List<string>(); hasReadFileList = new List<string>();
return AddCSVFile(filePath); return AddCSVFile(filePath);
} }
private static string GetTName() private static string GetTName()
{ {
...@@ -41,7 +41,7 @@ namespace OnlineStore.LoadCSVLibrary ...@@ -41,7 +41,7 @@ namespace OnlineStore.LoadCSVLibrary
return type.Name; return type.Name;
} }
public static List<T> getPositionList() public static List<T> getPositionList()
{ {
string name = GetTName(); string name = GetTName();
if (AllPositionMap.ContainsKey(name)) if (AllPositionMap.ContainsKey(name))
{ {
...@@ -55,7 +55,7 @@ namespace OnlineStore.LoadCSVLibrary ...@@ -55,7 +55,7 @@ namespace OnlineStore.LoadCSVLibrary
/// </summary> /// </summary>
/// <param name="filePath">cvs文件路径+文件名</param> /// <param name="filePath">cvs文件路径+文件名</param>
/// <returns></returns> /// <returns></returns>
public static Dictionary<String, T> AddCSVFile(string filePath,int storeId=0) public static Dictionary<String, T> AddCSVFile(string filePath, int storeId = 0)
{ {
if (hasReadFileList.Contains(filePath)) if (hasReadFileList.Contains(filePath))
{ {
...@@ -74,7 +74,7 @@ namespace OnlineStore.LoadCSVLibrary ...@@ -74,7 +74,7 @@ namespace OnlineStore.LoadCSVLibrary
Dictionary<String, T> result = new Dictionary<String, T>(); Dictionary<String, T> result = new Dictionary<String, T>();
string[] lines =ReadCSVFile(filePath); string[] lines = ReadCSVFile(filePath);
int index = 0; int index = 0;
Dictionary<string, int> titleIndex = new Dictionary<string, int>(); Dictionary<string, int> titleIndex = new Dictionary<string, int>();
foreach (var line in lines) foreach (var line in lines)
...@@ -82,7 +82,7 @@ namespace OnlineStore.LoadCSVLibrary ...@@ -82,7 +82,7 @@ namespace OnlineStore.LoadCSVLibrary
var array = line.Split(Spilt_Char); var array = line.Split(Spilt_Char);
if (index == 0) if (index == 0)
{ {
titleIndex = GetTitleIndex(filePath, line, cvsTitleList); titleIndex = GetTitleIndex(filePath, line, cvsTitleList);
} }
else else
{ {
...@@ -129,17 +129,17 @@ namespace OnlineStore.LoadCSVLibrary ...@@ -129,17 +129,17 @@ namespace OnlineStore.LoadCSVLibrary
{ {
throw new PositionAlreadyExistingExection("仓位:" + PositionNum + "已存在!"); throw new PositionAlreadyExistingExection("仓位:" + PositionNum + "已存在!");
} }
AllPositionMap[tname].Add(PositionNum, (T)bllIns); AllPositionMap[tname].Add(PositionNum, (T)bllIns);
} }
else else
{ {
LogUtil.error("读取"+ filePath + ",index=" + index + ",数据格式不匹配!,line=" + line); LogUtil.error("读取" + filePath + ",index=" + index + ",数据格式不匹配!,line=" + line);
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
LogUtil.debug ( "CSV 读取行【" + line + "】行转换失败"); LogUtil.debug("CSV 读取行【" + line + "】行转换失败");
} }
} }
index++; index++;
...@@ -169,7 +169,31 @@ namespace OnlineStore.LoadCSVLibrary ...@@ -169,7 +169,31 @@ namespace OnlineStore.LoadCSVLibrary
return null; return null;
} }
/// <summary>
/// 获取同尺寸库位的所有位置信息
/// </summary>
/// <param name="positionNum"></param>
/// <returns></returns>
public static List<T> GetSameSizePositons(string positionNum)
{
if (positionNum == null)
{
return null;
}
string tname = GetTName();
if (AllPositionMap.ContainsKey(tname))
{
if (AllPositionMap[tname].ContainsKey(positionNum))
{
var result = AllPositionMap[tname][positionNum];
if (result == null) return null;
var allPos = AllPositionMap[tname].Values.ToList().FindAll(s => s.BagWidth == result.BagWidth && s.BagHigh == result.BagHigh);
return allPos;
}
}
return null;
}
public static bool SavePostion(string filePath, T position) public static bool SavePostion(string filePath, T position)
{ {
Type type = typeof(T); Type type = typeof(T);
...@@ -205,7 +229,7 @@ namespace OnlineStore.LoadCSVLibrary ...@@ -205,7 +229,7 @@ namespace OnlineStore.LoadCSVLibrary
string value = array[csvIndex]; string value = array[csvIndex];
if (value.Equals(position.PositionNum)) if (value.Equals(position.PositionNum))
{ {
if (AllPositionMap.ContainsKey(tName)) if (AllPositionMap.ContainsKey(tName))
{ {
//更新缓存 //更新缓存
...@@ -221,7 +245,7 @@ namespace OnlineStore.LoadCSVLibrary ...@@ -221,7 +245,7 @@ namespace OnlineStore.LoadCSVLibrary
index++; index++;
} }
return true; return true;
} }
private static string PostionToString(PostionBase position, Dictionary<string, int> titleIndex, Dictionary<string, string> proTitleMap) private static string PostionToString(PostionBase position, Dictionary<string, int> titleIndex, Dictionary<string, string> proTitleMap)
{ {
...@@ -243,14 +267,14 @@ namespace OnlineStore.LoadCSVLibrary ...@@ -243,14 +267,14 @@ namespace OnlineStore.LoadCSVLibrary
string newStr = ""; string newStr = "";
foreach (string str in array) foreach (string str in array)
{ {
if (newStr.Equals("")) if (newStr.Equals(""))
{ {
newStr = str; newStr = str;
} }
else else
{ {
newStr = newStr+Spilt_Char + str; newStr = newStr + Spilt_Char + str;
} }
} }
return newStr; return newStr;
...@@ -321,7 +345,7 @@ namespace OnlineStore.LoadCSVLibrary ...@@ -321,7 +345,7 @@ namespace OnlineStore.LoadCSVLibrary
lie = Convert.ToInt32(hengStr[1]); lie = Convert.ToInt32(hengStr[1]);
hang = Convert.ToInt32(hengStr[2]); hang = Convert.ToInt32(hengStr[2]);
p = Convert.ToInt32(hengStr[3]); p = Convert.ToInt32(hengStr[3]);
} }
string hangStr = "AA"; string hangStr = "AA";
if (hang.Equals(1)) if (hang.Equals(1))
{ {
...@@ -353,9 +377,9 @@ namespace OnlineStore.LoadCSVLibrary ...@@ -353,9 +377,9 @@ namespace OnlineStore.LoadCSVLibrary
else else
{ {
newPosId = louceng + storeId + oldPosId.Substring(4, oldPosId.Length - 4); newPosId = louceng + storeId + oldPosId.Substring(4, oldPosId.Length - 4);
} }
position.PositionNum = newPosId; position.PositionNum = newPosId;
// position.StoreId = storeIndex; // position.StoreId = storeIndex;
string newValue = PostionToString(position, titleIndex, proTitleMap); string newValue = PostionToString(position, titleIndex, proTitleMap);
lines[index] = newValue; lines[index] = newValue;
} }
...@@ -363,7 +387,7 @@ namespace OnlineStore.LoadCSVLibrary ...@@ -363,7 +387,7 @@ namespace OnlineStore.LoadCSVLibrary
{ {
LogUtil.error("更新【" + filePath + "】位置出错【" + line + "】" + ex.ToString()); LogUtil.error("更新【" + filePath + "】位置出错【" + line + "】" + ex.ToString());
} }
} }
} }
} }
index++; index++;
...@@ -373,5 +397,5 @@ namespace OnlineStore.LoadCSVLibrary ...@@ -373,5 +397,5 @@ namespace OnlineStore.LoadCSVLibrary
} }
} }
} }
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!