Commit f720347f LN

自动出入库修改

1 个父辈 3a026cc2
......@@ -12,7 +12,7 @@
<!-- 停止吹气的判断值(配置值=服务器发送的湿度值-停止吹气值)-->
<add key="StopBlowValue" value="4"/>
<!--Server address-->
<add key="http.server" value="http://192.168.101.11/myproject/" />
<add key="http.server" value="http://10.85.160.25/myproject/" />
<!--storeType-->
<add key="store_count" value="2"/>
<add key="Store_ConfigPath" value="\StoreConfig\StoreConfig.csv"/>
......@@ -29,7 +29,7 @@
<add key="InOutDefaultPosition" value="8000"/>
<add key="Config_Pwd" value="123456"/>
<!--二维码类型列表配置,用#分割,一维码=Barcode 二维码: QR Code#Data Matrix ECC 200#Micro QR Code-->
<add key="CodeType" value="QR Code" />
<add key="CodeType" value="QR Code#Data Matrix ECC 200" />
<!--二维码参数文件所在路径,文件名与二维码类型名一样-->
<add key="CodeParamPath" value="\CodeParam\" />
<!--出库等待料盘拿走的时间,秒-->
......
......@@ -119,6 +119,9 @@
this.chbDebug = new System.Windows.Forms.CheckBox();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.btnUPosId = new System.Windows.Forms.Button();
this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
this.label3 = new System.Windows.Forms.Label();
this.txtCID = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.btnSaveCID = new System.Windows.Forms.Button();
......@@ -133,6 +136,7 @@
this.btnTempClose = new System.Windows.Forms.Button();
this.btnTempInit = new System.Windows.Forms.Button();
this.axisMoveControl1 = new OnlineStore.ACPackingStore.AxisMoveControl();
this.lblMoveInfo = new System.Windows.Forms.Label();
this.groupShelf.SuspendLayout();
this.panel1.SuspendLayout();
this.tabControl1.SuspendLayout();
......@@ -142,6 +146,7 @@
this.groupBox3.SuspendLayout();
this.tabPage1.SuspendLayout();
this.groupBox2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
this.groupBox7.SuspendLayout();
this.SuspendLayout();
//
......@@ -1493,6 +1498,7 @@
this.groupBox3.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox3.Controls.Add(this.lblMoveInfo);
this.groupBox3.Controls.Add(this.lblTemp);
this.groupBox3.Controls.Add(this.lblMoveEquipInfo);
this.groupBox3.Controls.Add(this.lblWarnMsg);
......@@ -1500,7 +1506,7 @@
this.groupBox3.Controls.Add(this.chbDebug);
this.groupBox3.Location = new System.Drawing.Point(3, 3);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(1289, 110);
this.groupBox3.Size = new System.Drawing.Size(1295, 110);
this.groupBox3.TabIndex = 268;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "设备状态";
......@@ -1511,7 +1517,7 @@
this.lblTemp.AutoSize = true;
this.lblTemp.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblTemp.ForeColor = System.Drawing.Color.Black;
this.lblTemp.Location = new System.Drawing.Point(994, 18);
this.lblTemp.Location = new System.Drawing.Point(629, 15);
this.lblTemp.Name = "lblTemp";
this.lblTemp.Size = new System.Drawing.Size(159, 20);
this.lblTemp.TabIndex = 270;
......@@ -1536,7 +1542,7 @@
this.lblWarnMsg.ForeColor = System.Drawing.Color.Red;
this.lblWarnMsg.Location = new System.Drawing.Point(5, 50);
this.lblWarnMsg.Name = "lblWarnMsg";
this.lblWarnMsg.Size = new System.Drawing.Size(1279, 53);
this.lblWarnMsg.Size = new System.Drawing.Size(896, 53);
this.lblWarnMsg.TabIndex = 224;
this.lblWarnMsg.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
......@@ -1556,7 +1562,7 @@
this.chbDebug.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.chbDebug.AutoSize = true;
this.chbDebug.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.chbDebug.Location = new System.Drawing.Point(1173, 18);
this.chbDebug.Location = new System.Drawing.Point(808, 15);
this.chbDebug.Name = "chbDebug";
this.chbDebug.Size = new System.Drawing.Size(93, 25);
this.chbDebug.TabIndex = 271;
......@@ -1579,20 +1585,67 @@
//
// groupBox2
//
this.groupBox2.Controls.Add(this.btnUPosId);
this.groupBox2.Controls.Add(this.numericUpDown1);
this.groupBox2.Controls.Add(this.label3);
this.groupBox2.Controls.Add(this.txtCID);
this.groupBox2.Controls.Add(this.label4);
this.groupBox2.Controls.Add(this.btnSaveCID);
this.groupBox2.Location = new System.Drawing.Point(560, 177);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(532, 88);
this.groupBox2.Size = new System.Drawing.Size(532, 97);
this.groupBox2.TabIndex = 273;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "CID修改";
//
// btnUPosId
//
this.btnUPosId.Location = new System.Drawing.Point(322, 59);
this.btnUPosId.Name = "btnUPosId";
this.btnUPosId.Size = new System.Drawing.Size(157, 33);
this.btnUPosId.TabIndex = 246;
this.btnUPosId.Text = "更新库位名称";
this.btnUPosId.UseVisualStyleBackColor = true;
this.btnUPosId.Click += new System.EventHandler(this.btnUPosId_Click);
//
// numericUpDown1
//
this.numericUpDown1.Location = new System.Drawing.Point(130, 63);
this.numericUpDown1.Maximum = new decimal(new int[] {
24,
0,
0,
0});
this.numericUpDown1.Minimum = new decimal(new int[] {
18,
0,
0,
0});
this.numericUpDown1.Name = "numericUpDown1";
this.numericUpDown1.Size = new System.Drawing.Size(120, 26);
this.numericUpDown1.TabIndex = 245;
this.numericUpDown1.Value = new decimal(new int[] {
18,
0,
0,
0});
//
// label3
//
this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label3.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
this.label3.Location = new System.Drawing.Point(41, 68);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(83, 17);
this.label3.TabIndex = 244;
this.label3.Text = "库位料仓编号:";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// txtCID
//
this.txtCID.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtCID.Location = new System.Drawing.Point(95, 28);
this.txtCID.Location = new System.Drawing.Point(128, 27);
this.txtCID.MaxLength = 30;
this.txtCID.Name = "txtCID";
this.txtCID.Size = new System.Drawing.Size(184, 26);
......@@ -1604,7 +1657,7 @@
this.label4.AutoSize = true;
this.label4.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label4.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
this.label4.Location = new System.Drawing.Point(41, 33);
this.label4.Location = new System.Drawing.Point(83, 33);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(32, 17);
this.label4.TabIndex = 242;
......@@ -1615,7 +1668,7 @@
//
this.btnSaveCID.Location = new System.Drawing.Point(322, 24);
this.btnSaveCID.Name = "btnSaveCID";
this.btnSaveCID.Size = new System.Drawing.Size(100, 33);
this.btnSaveCID.Size = new System.Drawing.Size(157, 33);
this.btnSaveCID.TabIndex = 88;
this.btnSaveCID.Text = "保存";
this.btnSaveCID.UseVisualStyleBackColor = true;
......@@ -1743,6 +1796,17 @@
this.axisMoveControl1.Size = new System.Drawing.Size(547, 449);
this.axisMoveControl1.TabIndex = 0;
//
// lblMoveInfo
//
this.lblMoveInfo.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.lblMoveInfo.AutoSize = true;
this.lblMoveInfo.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblMoveInfo.Location = new System.Drawing.Point(922, 15);
this.lblMoveInfo.Name = "lblMoveInfo";
this.lblMoveInfo.Size = new System.Drawing.Size(56, 17);
this.lblMoveInfo.TabIndex = 269;
this.lblMoveInfo.Text = "运转状态";
//
// FrmBox
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
......@@ -1771,6 +1835,7 @@
this.tabPage1.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
this.groupBox7.ResumeLayout(false);
this.groupBox7.PerformLayout();
this.ResumeLayout(false);
......@@ -1888,6 +1953,10 @@
public System.Windows.Forms.TextBox txtComMaxP3;
public System.Windows.Forms.TextBox txtComP3_P2;
public System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.NumericUpDown numericUpDown1;
private System.Windows.Forms.Button btnUPosId;
private System.Windows.Forms.Label lblMoveInfo;
}
}
......@@ -103,7 +103,17 @@ namespace OnlineStore.ACPackingStore
timer1.Start();
chbDebug.Checked = BoxBean.IsDebug;
this.ShowInTaskbar = true;
try
{
int num =Convert.ToInt32( BoxBean.CID.Substring(BoxBean.CID.Length - 2, 2));
if (num >= 18 && num <= 24)
{
numericUpDown1.Value = num;
}
}catch(Exception ex)
{
}
txtTempPort.Text = BoxBean.Config.Humiture_Port;
LoadOk = true;
}
......@@ -142,7 +152,7 @@ namespace OnlineStore.ACPackingStore
}
lblTemp.Text = BoxBean.humBean.currTempStr;
lblWarnMsg.Text = BoxBean.GetWarnMsg();
lblMoveInfo.Text = BoxBean.GetMoveStr();
//ReadPosistion();
if (BoxBean.storeRunStatus > StoreRunStatus.Wait)
{
......@@ -964,5 +974,35 @@ namespace OnlineStore.ACPackingStore
AxisABSMove(BoxBean.Config.UpDown_Axis, value, BoxBean.Config.UpDownAxis_P1_Speed);
}
}
private void btnUPosId_Click(object sender, EventArgs e)
{
int num = (int)numericUpDown1.Value;
if (num < 18 || num > 24)
{
return;
}
DialogResult result = MessageBox.Show("确定将库位改为【4D" + num.ToString().PadLeft(2,'0') + "XXXXXX】的格式?", "", MessageBoxButtons.YesNo);
if (result.Equals(DialogResult.Yes))
{
string appPath = Application.StartupPath;
//如果总配置文件存在,保存到总的配置文件
string positionConfigFile = appPath + ConfigAppSettings.GetValue(Setting_Init.Store_Position_Config);
if (!File.Exists(positionConfigFile))
{
string nameStr = BoxBean.DeviceID.ToString();
positionConfigFile = positionConfigFile.Replace(".csv", "_" + nameStr + ".csv");
}
if (!CSVPositionReader<ACBoxPosition>.UpdatePostion(positionConfigFile, num))
{
MessageBox.Show("更新文件【" + positionConfigFile + "】失败!");
}
else
{
MessageBox.Show("更新文件【" + positionConfigFile + "】成功!");
}
}
}
}
}
......@@ -61,7 +61,7 @@ namespace OnlineStore.DeviceLibrary
//添加调试
IsDebug = config.IsInDebug.Equals(1);
Name = ("料仓BOX_" + config.DeviceID + " ").ToUpper();
Name = (" BOX_" + config.DeviceID + " ").ToUpper();
this.DeviceID = config.DeviceID;;
this.Config = config;
DoorBean = new EnteryDoorBean(DeviceID);
......@@ -844,5 +844,16 @@ namespace OnlineStore.DeviceLibrary
IOMove(IO_Type.Line_BackRun, IO_VALUE.LOW);
IOMove(IO_Type.Line_Run, IO_VALUE.LOW);
}
public string GetMoveStr()
{
string msg = "";
msg += "runS: " + storeRunStatus + "\n";
msg += "lineS: " + storeStatus + "\n";
msg += "alarm: " + alarmType + "\n";
msg += "MoveT:" + MoveInfo.MoveType + "\n";
msg += "MoveS: " + MoveInfo.SLog + "\n";
msg += "Shlef: " + LastShelfData.NumStr() ;
return msg;
}
}
}
\ No newline at end of file
......@@ -211,25 +211,20 @@ namespace OnlineStore.DeviceLibrary
if (!StoreManager.LoadInoutParam(param, true, this))
{
LogUtil.error(Name + " 启动入库【" + posId + "】出错,找不到库位信息");
LogUtil.error(Name + " 启动入库【" + param.ToStr() + "】出错,找不到库位信息");
return;
}
//if (IOValue(IO_Type.TrayCheck_Fixture).Equals(IO_VALUE.HIGH))
//{
// LogUtil.error(Name + " 启动入库【" + posId + "】出错,叉子料盘检测有料");
// return;
//}
param.NeedEnterShelf = false;
param.NeedOutShelf = false;
LogInfo(" 启动入库【" + posId + "】");
LogInfo(" 启动入库【" + param.ToStr() + "】,压紧点P2【"+ param.MoveP.ComPress_P2+"】压紧前点P3【"+ param.MoveP.ComPress_P3+"】");
storeRunStatus = StoreRunStatus.Busy;
storeStatus = StoreStatus.InStoreExecute;
MoveInfo.NewMove(StoreMoveType.InStore, param);
//新的料架库位
MoveInfo.NextMoveStep(StoreMoveStep.BI_17_InoutBack);
MoveInfo.NextMoveStep(StoreMoveStep.BI_11_InoutToP1);
MoveInfo.SingleInstore = true;
InOutStoreLog("料架取料:叉子后退到待机点P1, 重置盘信息");
InOutStoreLog("料架取料:"+MoveInfo.SLog+" 叉子后退到待机点P1, 重置盘信息");
ACAxisMove(Config.InOut_Axis, Config.InOutAxis_P1_Position, Config.InOutAxis_P1_Speed);
ClearLastTrayInfo();
}
......@@ -369,12 +364,21 @@ namespace OnlineStore.DeviceLibrary
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_14_UpdownToP102))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_15_StartCompress);
InOutStoreLog("料架取料 " + MoveInfo.SLog + ":压紧轴开始缓慢压紧到P4 :"+ Config.CompAxis_P4_Position);
MoveInfo.WaitList.Add(WaitResultInfo.WaitComAxis(Config.Comp_Axis, Config.CompAxis_P4_Position, Config.CompAxis_P4_Speed));
Config.Comp_Axis.TargetPosition = Config.CompAxis_P4_Position;
ACServerManager.AbsMove(Config.Comp_Axis.DeviceName, Config.Comp_Axis.GetAxisValue(), Config.CompAxis_P4_Position, Config.CompAxis_P4_Speed);
ComAxisStartCheck();
if (MoveInfo.SingleInstore)
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_16_ComAxisDownMove);
InOutStoreLog("单盘入库,料架取料 " + MoveInfo.SLog + ":压紧轴走到压紧点P2: "+MoveInfo.MoveParam.MoveP.ComPress_P2);
ACAxisMove(Config.Comp_Axis, MoveInfo.MoveParam.MoveP.ComPress_P2, Config.CompAxis_P2_Speed);
}
else
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_15_StartCompress);
InOutStoreLog("料架取料 " + MoveInfo.SLog + ":压紧轴开始缓慢压紧到P4 :" + Config.CompAxis_P4_Position);
MoveInfo.WaitList.Add(WaitResultInfo.WaitComAxis(Config.Comp_Axis, Config.CompAxis_P4_Position, Config.CompAxis_P4_Speed));
Config.Comp_Axis.TargetPosition = Config.CompAxis_P4_Position;
ACServerManager.AbsMove(Config.Comp_Axis.DeviceName, Config.Comp_Axis.GetAxisValue(), Config.CompAxis_P4_Position, Config.CompAxis_P4_Speed);
ComAxisStartCheck();
}
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_15_StartCompress))
{
......@@ -394,7 +398,7 @@ namespace OnlineStore.DeviceLibrary
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_16_ComAxisDownMove))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_17_InoutBack);
InOutStoreLog("料架取料 " + MoveInfo.SLog + ":记录压紧高度,叉子后退到扫码点");
InOutStoreLog("料架取料 " + MoveInfo.SLog + ":叉子后退到扫码点");
ACAxisMove(Config.InOut_Axis, moveP.InOut_P1, Config.CompAxis_P1_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_17_InoutBack))
......@@ -865,7 +869,12 @@ namespace OnlineStore.DeviceLibrary
//判断是否需要送出料架
bool isNeedSend = false;
//包装料料仓料架=A
if (EmprtShelfList.Count <= 0)
if (AutoInout.autoNext)
{
InOutStoreLog("出库完成,自动出入库启动中,不需要送出料架");
isNeedSend = false;
}
else if (EmprtShelfList.Count <= 0)
{
InOutStoreLog("出库完成,料架【" + LastShelfData + "】没有剩余位置,送出料架");
isNeedSend = true;
......
......@@ -487,13 +487,6 @@ namespace OnlineStore.DeviceLibrary
index++;
string plateW = plateWArray[index];
string plateH = plateHArray[index];
string[] posArray = posId.Split('#');
//if (posArray.Length != 2)
//{
// WarnMsg = Name + "出库格式错误:库位号【" + posId + "】";
// LogUtil.error(Name + "收到服务器出库命令:库位号【" + posId + "】格式错误");
// continue;
//}
InOutParam inoutParam = new InOutParam(barcode, posId, "", plateW, plateH, urgentReel, cutReel, smallReel, rfid, rfidLoc);
//根据发送的posId获取位置列表
ACBoxPosition position = CSVPositionReader<ACBoxPosition>.GetPositon(posId);
......@@ -619,16 +612,7 @@ namespace OnlineStore.DeviceLibrary
string posId = data[ParamDefine.posId];
string plateW = data[ParamDefine.plateW];
string plateH = data[ParamDefine.plateH];
string[] posArray = posId.Split('#');
if (!(posArray.Length == 2))
{
WarnMsg = Name + "入库库位格式错误:二维码【" + message + "】库位【" + posId + "】";
LogUtil.error(Name + "服务器反馈 入库库位格式错误:二维码【" + message + "】库位【" + posId + "】");
return false;
}
int storeId = int.Parse(posArray[0]);
int storeId = InOutParam.GetPosStoreId(posId);
//根据发送的posId获取位置列表
ACBoxPosition position = CSVPositionReader<ACBoxPosition>.GetPositon(posId);
if (position == null)
......
......@@ -312,10 +312,11 @@ namespace OnlineStore.DeviceLibrary
{
return msg = deviceName + " PutShelfFinished【 " + barcode + "】【" + rfid + "】【" + rfidPosId + "】 :" + serverResult.msg;
}
if (String.IsNullOrEmpty(serverResult.data).Equals(false))
{
shelfData = JsonHelper.DeserializeJsonToObject<ShelfData>(serverResult.data);
}
//if (String.IsNullOrEmpty(serverResult.data).Equals(false))
//{
// shelfData = JsonHelper.DeserializeJsonToObject<ShelfData>(serverResult.data);
//}
shelfData = serverResult.data;
}
catch (Exception ex)
{
......@@ -352,7 +353,7 @@ namespace OnlineStore.DeviceLibrary
public string msg { get; set; }
public string data { get; set; }
public ShelfData data { get; set; }
}
public class ShelfData
......
......@@ -77,19 +77,21 @@ namespace OnlineStore.DeviceLibrary
positionIndex = newIndex;
string posid = boxBean.PositionNumList[positionIndex];
InOutParam param = new InOutParam("AAAA", posid, shelfPosId);
param.NeedOutShelf = false;
//判断是否需要重置
if (CurrInOutACount >= boxBean.Config.Box_ResetACount)
{
boxBean.LogInfo("自动进入下一个出库:posid=" + posid + ",当时已经出入库" + CurrInOutACount + "次,需要重置BOX,先把出库信息存入排队列表中");
boxBean.Reset(false);
autoMsg = "自动出库:" + posid;
boxBean.waitOutStoreList.Enqueue(new InOutParam("", posid, shelfPosId));
boxBean.waitOutStoreList.Enqueue(param);
}
else
{
boxBean.LogInfo("自动进入下一个出库:posid=" + posid);
autoMsg = "自动出库:" + posid;
boxBean.StartOutStoreMove(new InOutParam("", posid, shelfPosId));
boxBean.StartOutStoreMove(param);
}
}
}
......@@ -113,19 +115,21 @@ namespace OnlineStore.DeviceLibrary
else
{
string posid = boxBean.PositionNumList[newIndex];
InOutParam param = new InOutParam("AAAA", posid, shelfPosId);
param.NeedOutShelf = false;
//判断是否需要重置
if (CurrInOutACount >= boxBean.Config.Box_ResetACount)
{
boxBean.LogInfo("自动进入下一个入库:posid=" + posid + ",当时已经出入库" + CurrInOutACount + "次,需要重置BOX,先把入库信息存入排队列表中");
boxBean.Reset(false);
autoMsg = "自动入库:" + posid;
boxBean.waitOutStoreList.Enqueue(new InOutParam("AAAA", posid, shelfPosId));
boxBean.waitOutStoreList.Enqueue(param);
}
else
{
boxBean.LogInfo("自动进入下一个入库:posid=" + posid);
autoMsg = "自动入库:" + posid;
boxBean.StartInStoreMove(new InOutParam("AAAA", posid, shelfPosId));
boxBean.StartInStoreMove(param);
}
}
}
......
......@@ -112,20 +112,29 @@ namespace OnlineStore.DeviceLibrary
/// <returns></returns>
public int GetStoreId()
{
if (!PosID.Equals(""))
return GetPosStoreId(PosID);
}
public static int GetPosStoreId(string posId)
{
if (!posId.Equals(""))
{
string[] arr = PosID.Split('#');
if (arr.Length >= 2)
try
{
try
string[] arr = posId.Split('#');
if (arr.Length >= 2)
{
return int.Parse(arr[0]);
}
catch (Exception ex)
else
{
return int.Parse(posId.Substring(2, 2));
}
}
catch (Exception ex)
{
}
}
return -1;
}
......

using log4net;
using OnlineStore.Common;
using System;
using System.Collections.Generic;
using System.Data;
......@@ -254,7 +255,122 @@ namespace OnlineStore.LoadCSVLibrary
}
return newStr;
}
public static bool UpdatePostion(string filePath, int storeIndex)
{
Type type = typeof(T);
Dictionary<string, string> proTitleMap = getProAttributeMap(typeof(T));
if (proTitleMap.Count <= 4)
{
LOGGER.Error(typeof(T).ToString() + "只读取到" + proTitleMap.Count + "个属性");
}
List<string> cvsTitleList = new List<string>(proTitleMap.Values);
List<string> propertyList = new List<string>(proTitleMap.Keys);
int positionNumIndex = propertyList.IndexOf("PositionNum");
int posIdIndex = -1;
string[] lines = ReadCSVFile(filePath);
int index = 0;
Dictionary<string, int> titleIndex = new Dictionary<string, int>();
foreach (var line in lines)
{
var array = line.Split(',');
if (index == 0)
{
titleIndex = GetTitleIndex(filePath, line, cvsTitleList);
}
else
{
if (array.Length >= titleIndex.Count)
{
if (posIdIndex < 0)
{
posIdIndex = titleIndex[cvsTitleList[positionNumIndex]];
}
string PosId = array[posIdIndex];
PostionBase position = (GetPositon(PosId));
if (position != null)
{
try
{
// 仓位命名: 4D01020304
//第1和第2位表示楼层(4D)
//第3和第4位表示料仓(01) 01 - 18为流水线料仓, 19 - 24为包装料仓
//第5和第6位表示列(02)
//第7和第8位表示行(03)
//第9和第10位表示隔板位置(04)
//例如: 4D12010124 表示4楼12号料仓第1列第1行架子上的第24个隔板位置
//4D19050208 表示4楼19号料仓(包装料仓)第5列第2行架子上的第8个隔板位置
string oldPosId = position.PositionNum;//08#AC1_18_3_18
string newPosId = "";
int jIndex = oldPosId.IndexOf("#");
string louceng = "4D";
string storeId = storeIndex.ToString().PadLeft(2, '0');
if (jIndex > 0)
{
string[] hengStr = oldPosId.Split('_');
int lie = 0;
int hang = 0;
int p = 0;
if (hengStr.Length == 4)
{
lie = Convert.ToInt32(hengStr[1]);
hang = Convert.ToInt32(hengStr[2]);
p = Convert.ToInt32(hengStr[3]);
}
string hangStr = "AA";
if (hang.Equals(1))
{
hangStr = "AA";
}
else if (hang.Equals(2))
{
hangStr = "BB";
}
else if (hang.Equals(3))
{
hangStr = "CC";
}
else if (hang.Equals(4))
{
hangStr = "DD";
}
else if (hang.Equals(5))
{
hangStr = "EE";
}
else if (hang.Equals(6))
{
hangStr = "FF";
}
lie++;
newPosId = louceng + storeId + lie.ToString().PadLeft(2, '0') + hangStr + p.ToString().PadLeft(4, '0');
}
else
{
newPosId = louceng + storeId + oldPosId.Substring(4, oldPosId.Length - 4);
}
position.PositionNum = newPosId;
position.StoreId = storeIndex;
string newValue = PostionToString(position, titleIndex, proTitleMap);
lines[index] = newValue;
}
catch (Exception ex)
{
LogUtil.error("更新【" + filePath + "】位置出错【" + line + "】" + ex.ToString());
}
}
}
}
index++;
}
return WriteCSVFile(filePath, lines);
}
}
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!