1 year ago
commit 1386e72c86

3
.gitignore vendored

@ -339,4 +339,5 @@ ASALocalRun/
# BeatPulse healthcheck temp database
healthchecksdb
appsettings.demo.json
appsettings.demo.json
/src/Khd.Core.Wcs/appsettings.json

@ -84,11 +84,11 @@ namespace Khd.Core.Wcs
SecondFloorLine secondFloorLine = new(_host, 2);
secondFloorLine.StartPoint();
//三层接驳位
//三层接驳位
ThirdFloorPoint thirdFloorPoint = new(_host, 3);
thirdFloorPoint.StartPoint();
// 三层AGV
// 三层AGV
ThirdFloorAGV thirdFloorAGV = new(_host, 3);
thirdFloorAGV.StartPoint();

@ -1795,6 +1795,10 @@ namespace Khd.Core.Wcs.Wcs
foreach (var item in rawOutStock)
{
if (item.endStationCode == "BB_01")
{
}
decimal? RealOutNumber = item.realOutstockAmount;
var endEquip = dbContext.BaseEquip.FirstOrDefault(t => t.equipNo == item.endStationCode);
if (endEquip != null && endEquip.floorNo == 5)
@ -1988,6 +1992,7 @@ namespace Khd.Core.Wcs.Wcs
.ToList();
decimal? needNumber = order.TotalAmount - order.realOutstockAmount;
// 寻找已经创建任务的料箱中的是否含有当前物料A物料在料箱A\B中然后找B物料的时候是否在料箱A\B中
foreach (var task in tasks)
{
var wmsRawStock = rawStock.Where(t => t.palletInfoCode == task.containerNo && t.materialId == order.MaterialId && t.saleOrderId == order.SaleOrderId).ToList();
@ -2056,9 +2061,10 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
needNumber = 0;
RealOutNumber += needNumber;
qty = Convert.ToInt32(needNumber);
needNumber = 0;
stock.updateDate = DateTime.Now;
}
WmsRawOutstock? wmsRawOutstock = orderList.Where(t => t.materialId == order.MaterialId).FirstOrDefault();
@ -2391,7 +2397,7 @@ namespace Khd.Core.Wcs.Wcs
}
}
}
else if (endEquip.equipType == 13)
else if (endEquip.equipType == 13) //原材料到背板安装
{
var stock = dbContext.WmsRawStock.Where(t => t.instockBatch == item.materialBatch).FirstOrDefault();
if (stock != null)

@ -548,14 +548,20 @@ namespace Khd.Core.Wcs.Wcs
}
else if (item.taskType == StaticTaskType.FiveAccessoryIn)//入库任务
{
WmsBaseLocation wmsBaseLocation = dbContext.WmsBaseLocation
.First(t => t.locationId == item.endPointId && t.warehouseFloor == 5);
wmsBaseLocation.locationStatus = "1";
wmsBaseLocation.ContainerStatus = "1";
dbContext.Update(wmsBaseLocation);
dbContext.Remove(item);
dbContext.SaveChanges();
dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog() { taskStatus = 6 });
try
{
WmsBaseLocation wmsBaseLocation = dbContext.WmsBaseLocation
.First(t => t.locationId == item.endPointId && t.warehouseFloor == 5);
wmsBaseLocation.locationStatus = "1";
wmsBaseLocation.ContainerStatus = "1";
dbContext.Update(wmsBaseLocation);
dbContext.Remove(item);
dbContext.SaveChanges();
dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog() { taskStatus = 6 });
}catch (Exception ex)
{
_logger.Error($"入库异常捕捉:{ex.Message}");
}
}
else if (item.taskType == StaticTaskType.FiveAccessoryStorage || item.taskType == StaticTaskType.FiveAccessoryRemove)//出库任务
{

@ -1,50 +0,0 @@
{
"ConnectionStrings": {
//"DefaultConnection": "server=106.12.13.113;port=3336;database=khd_jyhb;uid=khd;pwd=khd@123;charset='utf8';persistsecurityinfo=True;SslMode=none;Allow User Variables=True",
//"DefaultConnection": "server=172.16.12.100;port=3306;database=hwjy-cloud;uid=kehaida;pwd=khdrkjy2024...;charset='utf8';persistsecurityinfo=True;SslMode=None;Allow User Variables=True"
//"DefaultConnection": "server=localhost;port=3306;database=jyhb;uid=root;pwd=root;charset='utf8';persistsecurityinfo=True;SslMode=None;Allow User Variables=True"
"DefaultConnection": "server=175.27.215.92;port=3306;database=hwjy-cloud;uid=kehaida;pwd=khd2024;charset='utf8';persistsecurityinfo=True;SslMode=None;Allow User Variables=True"
},
"DeleteLogDays": 10,//
"PlcConfigs": [
{
"IP": "192.168.2.30",
"Port": 102, //102
"CpuType": 40,
"Rack": 0,
"Slot": 1,
"Code": 0
}, //
{
"IP": "192.168.2.31",
"Port": 102, //102
"CpuType": 40,
"Rack": 0,
"Slot": 1,
"Code": 1
}, //U线
{
"IP": "192.168.2.220",
"Port": 102, //102
"CpuType": 40,
"Rack": 0,
"Slot": 1,
"Code": 2
} //
],
"PLCSetting": {
"Mode": "0",
"EquipCode": "H61,H62,H63",
"Interval": "2000",
"AutoStart": "0",
"WaitTime": "60000",
"SiteCode": "999"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Error",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}

@ -2154,10 +2154,14 @@
</StackPanel>
</Border>
<Border BorderBrush="White" BorderThickness="2" Grid.Column="0" Grid.ColumnSpan="6" Grid.Row="5" Grid.RowSpan="2" Margin="20">
<DataGrid Background="Transparent"
CanUserAddRows="False"
AutoGenerateColumns="False"
CanUserSortColumns="False"
Height="auto"
GridLinesVisibility="Horizontal"
CanUserDeleteRows="False"
CanUserReorderColumns="False"
CanUserResizeColumns="False"
@ -2167,45 +2171,62 @@
Header="物料名称"
Binding="{Binding materiaName}"
ElementStyle="{StaticResource dgCell}"
Width="3*"
Width="*"
/>
<DataGridTextColumn
Header="物料描述"
Binding="{Binding materialSpec}"
ElementStyle="{StaticResource dgCell}"
Width="5*"
Width="*"
/>
<DataGridTextColumn
<!--<DataGridTextColumn
Header="销售订单"
Binding="{Binding saleOrderId}"
ElementStyle="{StaticResource dgCell}"
Width="2*"
/>
<DataGridTextColumn
Header="箱体携带数量"
Binding="{Binding thisOutAmount}"
ElementStyle="{StaticResource dgCell}"
Width="2*"
/>
/>-->
<DataGridTextColumn
Header="申请数量"
Binding="{Binding outstockAmount}"
ElementStyle="{StaticResource dgCell}"
Width="2*"
Width="*"
/>
<DataGridTextColumn
Header="已出数量"
Binding="{Binding realOutstockAmount}"
ElementStyle="{StaticResource dgCell}"
Width="2*"
Width="*"
/>
<DataGridTextColumn
Header="是否出完"
Binding="{Binding isSendOver}"
Width="2*"
Width="*"
ElementStyle="{StaticResource dgCell}"
/>
<!--<DataGridTextColumn
Header="箱体携带数量"
Binding="{Binding thisOutAmount}"
ElementStyle="{StaticResource dgCell}"
Width="3*"
/>-->
<DataGridTemplateColumn
Width="3*"
CanUserSort="False"
Header="箱体携带数量"
IsReadOnly="True" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock TextWrapping="Wrap" Text="{Binding thisOutAmount}" ToolTip="{Binding thisOutAmount}" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="20" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
<DataGrid.CellStyle>
<Style TargetType="{x:Type DataGridCell}">

@ -395,42 +395,119 @@ namespace Khd.Core.Wpf.Form
var baseEquip = dbContext.BaseEquip.First(t => t.objid == 10);
if (!string.IsNullOrEmpty(baseEquip.endStationCode))
{
#region 待测试
//找出本工位的申请单
List<WmsRawOutstock> RawOutstocks = wmsRawOutstocks.Where(t => t.endStationCode == baseEquip.endStationCode).ToList();
// 根据 materialId 分组,并计算 outstockAmount 和 realOutstockAmount 的总和
var targetRawOutstocks = RawOutstocks
.GroupBy(t => new { t.materialId, t.saleOrderId })
.Select(g => new
{
materialId = g.Key.materialId,
saleOrderId = g.Key.saleOrderId,
totalOutstockAmount = g.Sum(t => t.outstockAmount),
totalRealOutstockAmount = g.Sum(t => t.realOutstockAmount)
}).ToList();
//本次所有任务出来的托盘号
List<WcsTask> wcsTasks = dbContext.WcsTask.Where(t => t.taskType == 30).Where(t => orderIds.Contains(t.orderId)).ToList();
List<string> containerNos = wcsTasks.Select(t => t.containerNo).ToList();
//本次所有托盘携带的物料
List<WmsRawStock> wmsRawStocks = dbContext.WmsRawStock.Where(t => containerNos.Contains(t.palletInfoCode)).ToList();
var thisOutList = wmsRawStocks.GroupBy(t => new { t.materialId, t.saleOrderId })
.Select(t => new
// Step 3: 计算每个申请单物料在各个托盘中的数量
var palletMaterialSummary = wmsRawStocks
.GroupBy(t => new { t.materialId, t.palletInfoCode,t.saleOrderId })
.Select(g => new
{
materialId = t.Key.materialId,
saleOrderId = t.Key.saleOrderId,
thisOutAmount = t.Sum(x => x.totalAmount) - t.Sum(x => x.frozenAmount)
});
List<WmsRawOutstock> endStationCodeOutRaw = wmsRawOutstocks.Where(t => t.endStationCode == baseEquip.endStationCode).ToList();
List<long?> materialIds = endStationCodeOutRaw.Select(t => t.materialId).ToList();
MaterialId = g.Key.materialId,
saleOrderId = g.Key.saleOrderId,
PalletInfoCode = g.Key.palletInfoCode,
//携带总可用库存
canUseAmount = g.Sum(x => x.totalAmount) - g.Sum(x => x.frozenAmount)
})
.ToList();
// 汇总每个申请单在各个托盘的物料数量
var result = targetRawOutstocks
.Select(order => new
{
SaleOrderId = order.saleOrderId,
MaterialId = order.materialId,
//申请数量
RequestedAmount = order.totalOutstockAmount,
//实际已出数量
RealOutstockAmount = order.totalRealOutstockAmount,
// 托盘携带可用信息,用分号分隔
PalletDetails = string.Join("\n", palletMaterialSummary
.Where(pallet => pallet.MaterialId == order.materialId)
.Select(pallet => $"托盘{pallet.PalletInfoCode}数量{pallet.canUseAmount}")
)
}).ToList();
List<long?> materialIds = RawOutstocks.Select(t => t.materialId).ToList();
List<MesBaseMaterialInfo> mesBaseMaterialInfos = dbContext.MesBaseMaterialInfo.Where(t => materialIds.Contains(t.MaterialId)).ToList();
var bill = endStationCodeOutRaw.GroupBy(t => new { t.materialId, t.materialBatch, t.saleOrderId })
.Select(t => new
{
materialId = t.Key.materialId,
materialBatch = t.Key.materialBatch,
saleOrderId = t.Key.saleOrderId,
outstockAmount = t.Sum(x => x.outstockAmount),
realOutstockAmount = t.Sum(x => x.realOutstockAmount),
});
var orderNumber = from a in bill
from b in thisOutList
from c in mesBaseMaterialInfos
where a.materialId == b.materialId && a.saleOrderId == b.saleOrderId
var orderNumber = from r in result
from m in mesBaseMaterialInfos
where r.MaterialId== m.MaterialId
select new
{
materialBatch = a.materialBatch,
saleOrderId = b.saleOrderId,
outstockAmount = a.outstockAmount,
materialSpec = c.MaterialSpec,
realOutstockAmount = a.realOutstockAmount,
thisOutAmount = b.thisOutAmount,
isSendOver = a.outstockAmount <= (a.realOutstockAmount + b.thisOutAmount) ? "已出完" : "未出完"
materiaName = m.MaterialName,
materialSpec = m.MaterialSpec,
saleOrderId = r.SaleOrderId,
outstockAmount = r.RequestedAmount,
realOutstockAmount = r.RealOutstockAmount,
isSendOver = r.RequestedAmount <= r.RealOutstockAmount ? "已出完" : "未出完",
thisOutAmount = r.PalletDetails
};
#endregion
//List<WcsTask> wcsTasks = dbContext.WcsTask.Where(t => t.taskType == 30).Where(t => orderIds.Contains(t.orderId)).ToList();
//List<string> containerNos = wcsTasks.Select(t => t.containerNo).ToList();
//List<WmsRawStock> wmsRawStocks = dbContext.WmsRawStock.Where(t => containerNos.Contains(t.palletInfoCode)).ToList();
//var thisOutList = wmsRawStocks.GroupBy(t => new { t.materialId, t.saleOrderId,t.palletInfoCode })
// .Select(t => new
// {
// palletInfoCode = t.Key.palletInfoCode,
// materialId = t.Key.materialId,
// saleOrderId = t.Key.saleOrderId,
// thisOutAmount = t.Sum(x => x.totalAmount) - t.Sum(x => x.frozenAmount)
// });
//List<WmsRawOutstock> endStationCodeOutRaw = wmsRawOutstocks.Where(t => t.endStationCode == baseEquip.endStationCode).ToList();
//List<long?> materialIds = endStationCodeOutRaw.Select(t => t.materialId).ToList();
//List<MesBaseMaterialInfo> mesBaseMaterialInfos = dbContext.MesBaseMaterialInfo.Where(t => materialIds.Contains(t.MaterialId)).ToList();
//var bill = endStationCodeOutRaw.GroupBy(t => new { t.materialId, t.materialBatch, t.saleOrderId })
// .Select(t => new
// {
// materialId = t.Key.materialId,
// materialBatch = t.Key.materialBatch,
// saleOrderId = t.Key.saleOrderId,
// outstockAmount = t.Sum(x => x.outstockAmount),
// realOutstockAmount = t.Sum(x => x.realOutstockAmount),
// });
//var orderNumber = from a in bill
// from b in thisOutList
// from c in mesBaseMaterialInfos
// where a.materialId == b.materialId && a.saleOrderId == b.saleOrderId && a.materialId ==c.MaterialId
// select new
// {
// palletInfoCode = b.palletInfoCode,
// materialBatch = a.materialBatch,
// saleOrderId = b.saleOrderId,
// outstockAmount = a.outstockAmount,
// materialSpec = c.MaterialSpec,
// realOutstockAmount = a.realOutstockAmount,
// thisOutAmount = b.thisOutAmount,
// isSendOver = a.outstockAmount <= (a.realOutstockAmount + b.thisOutAmount) ? "已出完" : "未出完"
// };
Dispatcher.Invoke(() =>
{
this.OutTaskNumber.ItemsSource = orderNumber;

Loading…
Cancel
Save