change - 分垛入库一种型号只能设置在两个货道改为不限数量设置,入库货道筛选逻辑完善

dev
liuwf 12 months ago
parent 2c8d32369c
commit 8b5e9bb901

@ -159,7 +159,7 @@ namespace Admin.Core.Model
[SugarColumn(ColumnName = "IS_TWO_SPACE")] [SugarColumn(ColumnName = "IS_TWO_SPACE")]
public int IsTwoSpace { get; set; } public int IsTwoSpace { get; set; }
/// <summary> /// <summary>
/// 分垛使用字段,记录同型号上次入的货道如FD01_002 /// 分垛使用字段,记录同型号上次入的货道如FD01_002 == >记录上次货道ObjId
/// </summary> /// </summary>
[SugarColumn(ColumnName = "LAST_SPACE")] [SugarColumn(ColumnName = "LAST_SPACE")]
public string LastSpace { get; set; } public string LastSpace { get; set; }

@ -76,6 +76,9 @@ namespace Aucma.Core.BoxFoam.ViewModels
materialDataGrid = new ObservableCollection<BaseMaterialInfo>(); materialDataGrid = new ObservableCollection<BaseMaterialInfo>();
SearchCriteriaViewModel.RefreshPageEvent += SaveSearchCriteria; SearchCriteriaViewModel.RefreshPageEvent += SaveSearchCriteria;
Console.WriteLine(spaceCode); Console.WriteLine(spaceCode);
BaseSpaceInfo space = _baseSpaceInfoServices.FirstAsync(x => x.SpaceCode.Equals(spaceCode)).Result;
//加载快捷方式 //加载快捷方式
SaveSearchCriteria(); SaveSearchCriteria();
@ -83,14 +86,21 @@ namespace Aucma.Core.BoxFoam.ViewModels
if (ncount == 1) if (ncount == 1)
{ {
IsSelectedOptionA = true; IsSelectedOptionA = true;
PlanInfo.MaterialCode = space.MaterialType;
PlanInfo.MaterialName = space.typeNameA;
} }
else if (ncount == 2) else if (ncount == 2)
{ {
IsSelectedOptionB = true; IsSelectedOptionB = true;
PlanInfo.MaterialCode = space.typeCodeB;
PlanInfo.MaterialName = space.typeNameB;
} }
else if (ncount == 3) else if (ncount == 3)
{ {
IsSelectedOptionC = true; IsSelectedOptionC = true;
PlanInfo.MaterialCode = space.typeCodeC;
PlanInfo.MaterialName = space.typeNameC;
} }
} }

@ -14,6 +14,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.StartPanel;
namespace Aucma.Core.Palletiz.Business namespace Aucma.Core.Palletiz.Business
{ {
@ -35,7 +36,8 @@ namespace Aucma.Core.Palletiz.Business
#region 变量定义 #region 变量定义
public readonly List<ScannerModel> allScanners = Appsettings.app<ScannerModel>("ScannerServer").ToList(); public readonly List<ScannerModel> allScanners = Appsettings.app<ScannerModel>("ScannerServer").ToList();
public readonly string storeCode = Appsettings.app("StoreInfo", "PalletizStoreCode");//分垛库code public readonly string storeCodeA = Appsettings.app("StoreInfo", "PalletizStoreCodeA");//分垛库A
public readonly string storeCodeB = Appsettings.app("StoreInfo", "PalletizStoreCodeB");//分垛库B
#endregion #endregion
#region 接口引用 #region 接口引用
@ -49,7 +51,7 @@ namespace Aucma.Core.Palletiz.Business
public void test() public void test()
{ {
// B24010183025014160001 SN:16160030000000910999 // B240101 8302501416 0001 SN:16160030000000910999
Task.Run(async () => Task.Run(async () =>
{ {
Thread.Sleep(3000); Thread.Sleep(3000);
@ -76,66 +78,59 @@ namespace Aucma.Core.Palletiz.Business
List<int> spaceNumList = new List<int>(); List<int> spaceNumList = new List<int>();
// 入库记录 // 入库记录
RecordInStore recordInstore = new RecordInStore(); RecordInStore recordInstore = new RecordInStore();
recordInstore.StoreCode = storeCode;
//1.根据成品码找货道 //1.根据成品码找货道
List<BaseSpaceInfo> spaceList = getSpaceBySNCode(SNCode,recordInstore); List<BaseSpaceInfo> spaceList = getSpaceBySNCode(SNCode,recordInstore);
// 根据货道信息判断下发plc信号 // 根据货道信息判断下发plc信号
if (spaceList == null) if (spaceList == null || spaceList.Count==0)
{ {
logHelper.Error("未找到匹配货道,请手动入库!"); logHelper.Error("未找到匹配货道,请手动入库!");
// 刷新页面提示信息 // 刷新页面提示信息
return; return;
} }
if (spaceList.Count == 1) // 过滤货道,找到最终需要下发的货道
{ BaseSpaceInfo finalSpace = FilterSpace(spaceList);
spaceNumList.Add(int.Parse(spaceList[0].SpaceCode.Substring(5, 3)));
spaceNumList.Add(0);
plcResult = sendAndAnswerPlc(scannerIp, spaceList[0].RotationRange, spaceNumList);
spaceList[0].LastSpace = spaceList[0].SpaceCode;
recordInstore.SpaceCode = spaceList[0].SpaceCode;
}
// 暂时只考虑两个货道入一种型号
else if (spaceList.Count >= 2)
{
// 大产品占两道 // 大产品占两道
if (spaceList[0].IsTwoSpace == 1) if (finalSpace.IsTwoSpace == 1)
{ {
spaceNumList.Add(int.Parse(spaceList[0].SpaceCode.Substring(5, 3))); spaceNumList.Add(int.Parse(finalSpace.SpaceCode.Substring(5, 3)));
spaceNumList.Add(int.Parse(spaceList[1].SpaceCode.Substring(5, 3))); spaceNumList.Add(int.Parse(getOtherSpace(finalSpace, spaceList).SpaceCode.Substring(5, 3)));
plcResult = sendAndAnswerPlc(scannerIp, spaceList[0].RotationRange, spaceNumList); plcResult = sendAndAnswerPlc(scannerIp, spaceList[0].RotationRange, spaceNumList);
recordInstore.SpaceCode = spaceList[0].SpaceCode; recordInstore.SpaceCode = finalSpace.SpaceCode;
recordInstore.StoreCode = finalSpace.StoreCode;
// 更新货道信息,大产品last存objId大的如货道7,8存8
BaseSpaceInfo otherSpace = getOtherSpace(finalSpace, spaceList);
if (otherSpace != null)
{
updateSapceList(otherSpace.ObjId,spaceList);
}
} }
else else
{ {
// last不等于自己可以先入自己否则入另一条货道 // last不等于自己可以先入自己否则入另一条货道
if (!spaceList[0].LastSpace.Equals(spaceList[0].SpaceCode)) if (isOddNumber(finalSpace))
{ {
spaceNumList.Add(int.Parse(spaceList[0].SpaceCode.Substring(5, 3))); spaceNumList.Add(int.Parse(finalSpace.SpaceCode.Substring(5, 3)));
spaceNumList.Add(0); spaceNumList.Add(0);
plcResult = sendAndAnswerPlc(scannerIp, spaceList[0].RotationRange, spaceNumList); plcResult = sendAndAnswerPlc(scannerIp, finalSpace.RotationRange, spaceNumList);
spaceList[0].LastSpace = spaceList[0].SpaceCode; updateSapceList(finalSpace.ObjId, spaceList);
recordInstore.SpaceCode = spaceList[0].SpaceCode;
} }
else else
{ {
spaceNumList.Add(0); spaceNumList.Add(0);
spaceNumList.Add(int.Parse(spaceList[1].SpaceCode.Substring(5, 3))); spaceNumList.Add(int.Parse(finalSpace.SpaceCode.Substring(5, 3)));
sendAndAnswerPlc(scannerIp, spaceList[0].RotationRange, spaceNumList); plcResult = sendAndAnswerPlc(scannerIp, finalSpace.RotationRange, spaceNumList);
spaceList[0].LastSpace = spaceList[1].SpaceCode; updateSapceList(finalSpace.ObjId, spaceList);
recordInstore.SpaceCode = spaceList[1].SpaceCode;
}
} }
} }
if(plcResult==true) if (plcResult==true)
{ {
// 更新货道信息,入库记录,刷新界面 // 更新入库记录,刷新界面
_baseSpaceInfoServices.UpdateAsync(spaceList);
#region 添加入库记录 #region 添加入库记录
recordInstore.SpaceCode = finalSpace.SpaceCode;
recordInstore.StoreCode = finalSpace.StoreCode;
recordInstore.InStoreAmount = 1; recordInstore.InStoreAmount = 1;
recordInstore.InStoreTime = DateTime.Now; recordInstore.InStoreTime = DateTime.Now;
recordInstore.CreatedTime = DateTime.Now; recordInstore.CreatedTime = DateTime.Now;
@ -169,12 +164,13 @@ namespace Aucma.Core.Palletiz.Business
CodeBindingRecord bindingRecord = _codeBindingServices.Query(c => c.ProductCode.Equals(SNCode)).FirstOrDefault(); CodeBindingRecord bindingRecord = _codeBindingServices.Query(c => c.ProductCode.Equals(SNCode)).FirstOrDefault();
if (bindingRecord == null) return null; if (bindingRecord == null) return null;
recordInstore.BarCodeCode = bindingRecord.BoxCode; recordInstore.BarCodeCode = bindingRecord.BoxCode;
recordInstore.MaterialCode = bindingRecord.BoxCode; recordInstore.MaterialCode = bindingRecord.BoxCode;
recordInstore.MaterialType = bindingRecord.BoxCode.Substring(7, 10); recordInstore.MaterialType = bindingRecord.BoxCode.Substring(7, 10);
recordInstore.MaterialName = bindingRecord.BoxName; recordInstore.MaterialName = bindingRecord.BoxName;
return _baseSpaceInfoServices.Query(s => s.MaterialType.Equals(bindingRecord.BoxCode.Substring(7, 10)) &&s.StoreCode.Equals(storeCode)); return _baseSpaceInfoServices.Query(s => s.MaterialType.Equals(bindingRecord.BoxCode.Substring(7, 10)) && (s.StoreCode.Equals(storeCodeA) || s.StoreCode.Equals(storeCodeB)) ).OrderBy(x=>x.ObjId).ToList();
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -183,11 +179,29 @@ namespace Aucma.Core.Palletiz.Business
} }
} }
private BaseSpaceInfo FilterSpace(List<BaseSpaceInfo> spaceInfos)
{
if (spaceInfos.Count == 1 || string.IsNullOrEmpty(spaceInfos[0].LastSpace))
{
return spaceInfos[0];
}
List<BaseSpaceInfo> spaceList = spaceInfos.Where(s=>s.ObjId> int.Parse(spaceInfos[0].LastSpace)).ToList();
if(spaceList==null|| spaceList.Count == 0)
{
return spaceInfos[0];
}
else
{
return spaceList[0];
}
}
/// <summary> /// <summary>
/// 大产品占据两条货道,根据一条货道找到另一条货道 /// 大产品占据两条货道,根据一条货道找到另一条货道
/// </summary> /// </summary>
/// <param name="spaceInfo"></param> /// <param name="spaceInfo"></param>
private string getOtherSpace(BaseSpaceInfo spaceInfo) private BaseSpaceInfo getOtherSpace(BaseSpaceInfo spaceInfo,List<BaseSpaceInfo> spaceList)
{
try
{ {
// 找到当前货道匹配的另一条货道 // 找到当前货道匹配的另一条货道
int num = int.Parse(spaceInfo.SpaceCode.Substring(5, 3)); int num = int.Parse(spaceInfo.SpaceCode.Substring(5, 3));
@ -200,9 +214,55 @@ namespace Aucma.Core.Palletiz.Business
{ {
otherSpaceCode = spaceInfo.SpaceCode.Substring(0, 5) + (num + 1).ToString("D3"); otherSpaceCode = spaceInfo.SpaceCode.Substring(0, 5) + (num + 1).ToString("D3");
} }
return otherSpaceCode; spaceList = spaceList.Where(s => s.SpaceCode.Equals(otherSpaceCode)).ToList();
if (spaceList.Count > 0)
{
return spaceList[0];
}
else
{
return null;
}
}
catch (Exception ex)
{
logHelper.Error(ex.Message.ToString());
return null;
}
} }
/// <summary>
/// 判断货道编号是否为奇数
/// </summary>
/// <param name="space"></param>
/// <returns></returns>
private bool isOddNumber(BaseSpaceInfo space)
{
int num = int.Parse(space.SpaceCode.Substring(5, 3));
if(num % 2 == 0)
{
return false;
}
else
{
return true;
}
}
/// <summary>
/// 将该物料的所有货道列表的last修改为上次入库货道objId
/// </summary>
/// <param name="objId"></param>
/// <param name="spaceList"></param>
/// <returns></returns>
private bool updateSapceList(int objId,List<BaseSpaceInfo> spaceList)
{
foreach(BaseSpaceInfo space in spaceList)
{
space.LastSpace = objId.ToString();
}
return _baseSpaceInfoServices.UpdateAsync(spaceList).Result;
}
#endregion #endregion
#region plc信号下发 #region plc信号下发

@ -28,7 +28,7 @@ namespace Aucma.Core.Palletiz.ViewModels
HandPalletizCommand = new RelayCommand<string>(obj => HandPalletizCommandExecute()); HandPalletizCommand = new RelayCommand<string>(obj => HandPalletizCommandExecute());
InitEveryDayMethod(); InitEveryDayMethod();
// InstoreBusiness.Instance.test(); InstoreBusiness.Instance.test();
} }
#region 扫描信息 #region 扫描信息

@ -100,7 +100,7 @@
<DataGridTextColumn Binding="{Binding typeNameA}" Header="产品名称" Width="3*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/> <DataGridTextColumn Binding="{Binding typeNameA}" Header="产品名称" Width="3*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding RotationRange}" Header="转向角度" Width="1*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/> <DataGridTextColumn Binding="{Binding RotationRange}" Header="转向角度" Width="1*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding IsTwoSpace}" Header="是否大产品(占两道)" Width="1*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/> <DataGridTextColumn Binding="{Binding IsTwoSpace}" Header="是否大产品(占两道)" Width="1*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding LastSpace}" Header="上次入货道" Width="1*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/> <!--<DataGridTextColumn Binding="{Binding LastSpace}" Header="上次入货道" Width="1*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>-->
</DataGrid.Columns> </DataGrid.Columns>
</DataGrid> </DataGrid>
</Grid> </Grid>

@ -224,7 +224,8 @@
"LinerInventory": "NDK-001", "LinerInventory": "NDK-001",
"AfterStoreCode": "PHK-001", "AfterStoreCode": "PHK-001",
"BeforeStoreCode": "PQK-001", "BeforeStoreCode": "PQK-001",
"PalletizStoreCode": "FDK-001", "PalletizStoreCodeA": "FDK-001",
"PalletizStoreCodeB": "FDK-002",
"ProductlineCode": "CX_02" "ProductlineCode": "CX_02"
}, },
"IpRateLimiting": { "IpRateLimiting": {

Loading…
Cancel
Save