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

dev
liuwf 12 months ago
parent 2c8d32369c
commit 8b5e9bb901

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

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

@ -14,6 +14,7 @@ using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.StartPanel;
namespace Aucma.Core.Palletiz.Business
{
@ -35,7 +36,8 @@ namespace Aucma.Core.Palletiz.Business
#region 变量定义
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
#region 接口引用
@ -49,7 +51,7 @@ namespace Aucma.Core.Palletiz.Business
public void test()
{
// B24010183025014160001 SN:16160030000000910999
// B240101 8302501416 0001 SN:16160030000000910999
Task.Run(async () =>
{
Thread.Sleep(3000);
@ -76,66 +78,59 @@ namespace Aucma.Core.Palletiz.Business
List<int> spaceNumList = new List<int>();
// 入库记录
RecordInStore recordInstore = new RecordInStore();
recordInstore.StoreCode = storeCode;
//1.根据成品码找货道
List<BaseSpaceInfo> spaceList = getSpaceBySNCode(SNCode,recordInstore);
// 根据货道信息判断下发plc信号
if (spaceList == null)
if (spaceList == null || spaceList.Count==0)
{
logHelper.Error("未找到匹配货道,请手动入库!");
// 刷新页面提示信息
return;
}
if (spaceList.Count == 1)
// 过滤货道,找到最终需要下发的货道
BaseSpaceInfo finalSpace = FilterSpace(spaceList);
// 大产品占两道
if (finalSpace.IsTwoSpace == 1)
{
spaceNumList.Add(int.Parse(spaceList[0].SpaceCode.Substring(5, 3)));
spaceNumList.Add(0);
spaceNumList.Add(int.Parse(finalSpace.SpaceCode.Substring(5, 3)));
spaceNumList.Add(int.Parse(getOtherSpace(finalSpace, spaceList).SpaceCode.Substring(5, 3)));
plcResult = sendAndAnswerPlc(scannerIp, spaceList[0].RotationRange, spaceNumList);
spaceList[0].LastSpace = spaceList[0].SpaceCode;
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 if (spaceList.Count >= 2)
else
{
// 大产品占两道
if (spaceList[0].IsTwoSpace == 1)
// last不等于自己可以先入自己否则入另一条货
if (isOddNumber(finalSpace))
{
spaceNumList.Add(int.Parse(spaceList[0].SpaceCode.Substring(5, 3)));
spaceNumList.Add(int.Parse(spaceList[1].SpaceCode.Substring(5, 3)));
plcResult = sendAndAnswerPlc(scannerIp, spaceList[0].RotationRange, spaceNumList);
recordInstore.SpaceCode = spaceList[0].SpaceCode;
spaceNumList.Add(int.Parse(finalSpace.SpaceCode.Substring(5, 3)));
spaceNumList.Add(0);
plcResult = sendAndAnswerPlc(scannerIp, finalSpace.RotationRange, spaceNumList);
updateSapceList(finalSpace.ObjId, spaceList);
}
else
{
// last不等于自己可以先入自己否则入另一条货道
if (!spaceList[0].LastSpace.Equals(spaceList[0].SpaceCode))
{
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
{
spaceNumList.Add(0);
spaceNumList.Add(int.Parse(spaceList[1].SpaceCode.Substring(5, 3)));
sendAndAnswerPlc(scannerIp, spaceList[0].RotationRange, spaceNumList);
spaceList[0].LastSpace = spaceList[1].SpaceCode;
recordInstore.SpaceCode = spaceList[1].SpaceCode;
}
spaceNumList.Add(0);
spaceNumList.Add(int.Parse(finalSpace.SpaceCode.Substring(5, 3)));
plcResult = sendAndAnswerPlc(scannerIp, finalSpace.RotationRange, spaceNumList);
updateSapceList(finalSpace.ObjId, spaceList);
}
}
if(plcResult==true)
if (plcResult==true)
{
// 更新货道信息,入库记录,刷新界面
_baseSpaceInfoServices.UpdateAsync(spaceList);
// 更新入库记录,刷新界面
#region 添加入库记录
recordInstore.SpaceCode = finalSpace.SpaceCode;
recordInstore.StoreCode = finalSpace.StoreCode;
recordInstore.InStoreAmount = 1;
recordInstore.InStoreTime = 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();
if (bindingRecord == null) return null;
recordInstore.BarCodeCode = bindingRecord.BoxCode;
recordInstore.MaterialCode = bindingRecord.BoxCode;
recordInstore.MaterialType = bindingRecord.BoxCode.Substring(7, 10);
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)
{
@ -183,26 +179,90 @@ 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>
/// <param name="spaceInfo"></param>
private string getOtherSpace(BaseSpaceInfo spaceInfo)
private BaseSpaceInfo getOtherSpace(BaseSpaceInfo spaceInfo,List<BaseSpaceInfo> spaceList)
{
// 找到当前货道匹配的另一条货道
int num = int.Parse(spaceInfo.SpaceCode.Substring(5, 3));
string otherSpaceCode = string.Empty;
if (num % 2 == 0) // 偶数如7,8当前8找7
try
{
otherSpaceCode = spaceInfo.SpaceCode.Substring(0, 5) + (num - 1).ToString("D3");
// 找到当前货道匹配的另一条货道
int num = int.Parse(spaceInfo.SpaceCode.Substring(5, 3));
string otherSpaceCode = string.Empty;
if (num % 2 == 0) // 偶数如7,8当前8找7
{
otherSpaceCode = spaceInfo.SpaceCode.Substring(0, 5) + (num - 1).ToString("D3");
}
else
{
otherSpaceCode = spaceInfo.SpaceCode.Substring(0, 5) + (num + 1).ToString("D3");
}
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
{
otherSpaceCode = spaceInfo.SpaceCode.Substring(0, 5) + (num + 1).ToString("D3");
return true;
}
return otherSpaceCode;
}
/// <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
#region plc信号下发
@ -318,7 +378,7 @@ namespace Aucma.Core.Palletiz.Business
}
/// <summary>
/// 根据扫码器ip确定是属于哪个plc
/// 根据扫码器ip确定是属于哪个plc
/// </summary>
/// <param name="scannerIp"></param>
/// <returns></returns>

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

@ -100,7 +100,7 @@
<DataGridTextColumn Binding="{Binding typeNameA}" Header="产品名称" Width="3*" 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 LastSpace}" Header="上次入货道" Width="1*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<!--<DataGridTextColumn Binding="{Binding LastSpace}" Header="上次入货道" Width="1*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>-->
</DataGrid.Columns>
</DataGrid>
</Grid>

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

Loading…
Cancel
Save