add-提交生产统计

dev
liuwf 1 month ago
parent ca3a76f6e5
commit d6c36ff463

@ -0,0 +1,189 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Security.Principal;
using System.Text;
namespace SlnMesnac.Model.domain
{
[SugarTable("wms_product_instock"), TenantAttribute("mes")]
public class WmsProductInstock
{
[SugarColumn(ColumnName = "product_instock_id", IsPrimaryKey = true, IsIdentity = true)]
public long productInstockId { get; set; }
/// <summary>
/// 任务编号
/// </summary>
[SugarColumn(ColumnName = "task_code")]
public string taskCode { get; set; }
/// <summary>
/// 仓库ID
/// </summary>
[SugarColumn(ColumnName = "warehouse_id")]
public long warehouseId { get; set; }
/// <summary>
/// 仓库楼层
/// </summary>
[SugarColumn(ColumnName = "warehouse_floor")]
public int? warehouseFloor { get; set; }
/// <summary>
/// 库位编码
/// </summary>
[SugarColumn(ColumnName = "location_code")]
public string locationCode { get; set; }
/// <summary>
/// 成品类型2半成品,3成品
/// </summary>
[SugarColumn(ColumnName = "product_type")]
public char productType { get; set; }
/// <summary>
/// 操作类型(0自动,1人工,2强制,3调度)
/// </summary>
[SugarColumn(ColumnName = "operation_type")]
public char operationType { get; set; }
/// <summary>
/// 计划编号,关联pd_base_plan_info的plan_code
/// </summary>
[SugarColumn(ColumnName = "plan_code")]
public string planCode { get; set; }
/// <summary>
/// 计划明细编号,关联pd_base_plan_detail的plan_detail_code
/// </summary>
[SugarColumn(ColumnName = "plan_detail_code")]
public string planDetailCode { get; set; }
/// <summary>
/// 销售订单ID关联销售订单主键
/// </summary>
[SugarColumn(ColumnName = "sale_order_id")]
public long? saleOrderId { get; set; }
/// <summary>
/// 销售订单编号
/// </summary>
[SugarColumn(ColumnName = "saleorder_code")]
public string saleorderCode { get; set; }
/// <summary>
/// 入库类型(1生产入库,2出半成品库,9其他入库)
/// </summary>
[SugarColumn(ColumnName = "instock_type")]
public char instockType { get; set; }
/// <summary>
/// 成品ID
/// </summary>
[SugarColumn(ColumnName = "product_id")]
public long? productId { get; set; }
/// <summary>
/// 存成品条码
/// </summary>
[SugarColumn(ColumnName = "product_batch")]
public string productBatch { get; set; }
/// <summary>
/// 入库数量
/// </summary>
[SugarColumn(ColumnName = "instock_amount")]
public decimal? instockAmount { get; set; }
/// <summary>
/// 托盘RFID代码
/// </summary>
[SugarColumn(ColumnName = "pallet_info_code")]
public string palletInfoCode { get; set; }
/// <summary>
/// 申请原因
/// </summary>
[SugarColumn(ColumnName = "apply_reason")]
public string applyReason { get; set; }
/// <summary>
/// 审核原因
/// </summary>
[SugarColumn(ColumnName = "audit_reason")]
public string auditReason { get; set; }
/// <summary>
/// 审核状态(0待审核,1审核通过,2审核未通过)
/// </summary>
[SugarColumn(ColumnName = "audit_status")]
public char auditStatus { get; set; }
/// <summary>
/// 执行状态(0待执行,1执行中,2执行完成)
/// </summary>
[SugarColumn(ColumnName = "execute_status")]
public char executeStatus { get; set; }
/// <summary>
/// 申请人
/// </summary>
[SugarColumn(ColumnName = "apply_by")]
public string applyBy { get; set; }
/// <summary>
/// 申请时间
/// </summary>
[SugarColumn(ColumnName = "apply_date")]
public DateTime? applyDate { get; set; }
/// <summary>
/// 审核人
/// </summary>
[SugarColumn(ColumnName = "audit_by")]
public string auditBy { get; set; }
/// <summary>
/// 审核时间
/// </summary>
[SugarColumn(ColumnName = "audit_date")]
public DateTime? auditDate { get; set; }
/// <summary>
/// 同步ERP状态(0:失败,1成功)
/// </summary>
[SugarColumn(ColumnName = "erp_status")]
public char? erpStatus { get; set; }
/// <summary>
/// 同步给ERP的数量
/// </summary>
[SugarColumn(ColumnName = "erp_amount")]
public decimal? erpAmount { get; set; }
/// <summary>
/// 最后更新人
/// </summary>
[SugarColumn(ColumnName = "update_by")]
public string updateBy { get; set; }
/// <summary>
/// 最后更新时间
/// </summary>
[SugarColumn(ColumnName = "update_date")]
public DateTime? updateDate { get; set; }
/// <summary>
/// 开始时间;AGV处理开始时间
/// </summary>
[SugarColumn(ColumnName = "begin_time")]
public DateTime? beginTime { get; set; }
/// <summary>
/// 结束时间;AGV处理结束时间
/// </summary>
[SugarColumn(ColumnName = "end_time")]
public DateTime? endTime { get; set; }
}
}

@ -124,6 +124,14 @@
GridLinesVisibility="None" ScrollViewer.HorizontalScrollBarVisibility="Hidden"
ScrollViewer.VerticalScrollBarVisibility="Visible" BorderThickness="0" CanUserAddRows="False" HorizontalAlignment="Center"
Foreground="White" >
<DataGrid.Resources>
<!-- 定制 ScrollBar 样式 -->
<Style TargetType="ScrollBar">
<Setter Property="Background" Value="Transparent"/>
</Style>
</DataGrid.Resources>
<!--resourceStyle 399行修改选中字体颜色-->
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding RawOutstockDetailId}" Header="序号" Width="1*" IsReadOnly="True"/>
@ -149,21 +157,27 @@
<!--计划列表-->
<Border Grid.Row="1" Grid.Column="0" BorderBrush="Green" BorderThickness="0" CornerRadius="5" Background="Transparent" Margin="1,1,5,5">
<DataGrid Grid.Row="0" ItemsSource="{Binding BarCodeTaskDataGrid}" Background="Transparent"
FontSize="15" ColumnHeaderHeight="35"
RowHeight="50" AutoGenerateColumns="False" RowHeaderWidth="0"
GridLinesVisibility="None" ScrollViewer.HorizontalScrollBarVisibility="Hidden"
ScrollViewer.VerticalScrollBarVisibility="Hidden" BorderThickness="0" CanUserAddRows="False" HorizontalAlignment="Center"
Foreground="#FFFFFF" >
<DataGrid Grid.Row="0" ItemsSource="{Binding ProductDataGrid}" Background="Transparent"
FontSize="15" ColumnHeaderHeight="35"
RowHeight="50" AutoGenerateColumns="False" RowHeaderWidth="0"
GridLinesVisibility="None" ScrollViewer.HorizontalScrollBarVisibility="Hidden"
ScrollViewer.VerticalScrollBarVisibility="Visible" BorderThickness="0" CanUserAddRows="False" HorizontalAlignment="Center"
Foreground="White" >
<DataGrid.Resources>
<!-- 定制 ScrollBar 样式 -->
<Style TargetType="ScrollBar">
<Setter Property="Background" Value="Transparent"/>
</Style>
</DataGrid.Resources>
<!--resourceStyle 399行修改选中字体颜色-->
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding ObjId}" Header="序号" Width="1*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding BarCode}" Header="条码" Width="3*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding PlanCode}" Header="计划编号" Width="3*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding MaterialCode}" Header="物料编号" Width="3*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding RecordTime ,StringFormat=\{0:MM月dd日 HH:mm\}}" Header="记录时间" Width="2*" IsReadOnly="True"/>
<!--<DataGridTextColumn Binding="{Binding RealEndTime ,StringFormat=\{0:MM月dd日 HH:mm\}}" Header="完成时间" Width="1*" IsReadOnly="True"/>-->
<DataGridTextColumn Binding="{Binding productInstockId}" Header="序号" Width="1*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding locationCode}" Header="库位编号" Width="2*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding productBatch}" Header="成品条码" Width="4*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding updateDate ,StringFormat=\{0:MM月dd日 HH:mm:ss\}}" Header="生产时间" Width="2*" IsReadOnly="True"/>
</DataGrid.Columns>
</DataGrid>
</Border>
@ -207,7 +221,41 @@ Foreground="#FFFFFF" >
</Grid>
</Border>
<Border Grid.Row="2" Grid.Column="1" BorderBrush="#1254AB" BorderThickness="2" CornerRadius="5" Background="Transparent" Margin="1,1,5,5">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
<RowDefinition Height="9*"/>
</Grid.RowDefinitions>
<Border Grid.Row="0" BorderBrush="CadetBlue" BorderThickness="0,0,0,0" CornerRadius="0" Background="Transparent" Margin="1,6,5,5" >
<TextBlock Text="日生产统计图" FontSize="20" FontWeight="Bold" Foreground="#0288d1" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Border>
<Border Grid.Row="1" BorderBrush="#0288d1" BorderThickness="0" CornerRadius="5" Background="Transparent" >
<lvc:CartesianChart Series="{Binding ProductAchievement, UpdateSourceTrigger=PropertyChanged}" LegendLocation="Top" Foreground="White" DisableAnimations="True">
<lvc:CartesianChart.DataTooltip >
<lvc:DefaultTooltip SelectionMode="OnlySender" BulletSize="10" Foreground="Black"></lvc:DefaultTooltip>
</lvc:CartesianChart.DataTooltip>
<lvc:CartesianChart.AxisX >
<lvc:Axis Labels="{Binding ProductDayList}" FontSize="18" Foreground="White" LabelsRotation="0" DisableAnimations="True" Position="LeftBottom" >
<lvc:Axis.Separator>
<lvc:Separator Visibility="Hidden" Step="1" StrokeThickness="1.5" StrokeDashArray="0" Stroke="#404F56" >
</lvc:Separator>
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisX>
<lvc:CartesianChart.AxisY>
<lvc:Axis FontSize="18" Foreground="White" MinValue="0">
<lvc:Axis.Separator>
<lvc:Separator Step="10" Visibility="Hidden" StrokeThickness="1" StrokeDashArray="3" Stroke="#404F56" >
</lvc:Separator>
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisY>
</lvc:CartesianChart>
</Border>
</Grid>
</Border>
</Grid>
</UserControl>

@ -68,7 +68,7 @@ namespace SlnMesnac.WPF.ViewModel
#region 参数定义
#region 日产量柱状图X轴日期
#region 投料X轴日期
/// <summary>
/// 日产量柱状图X轴日期
/// </summary>
@ -81,9 +81,9 @@ namespace SlnMesnac.WPF.ViewModel
}
#endregion
#region 型号统计柱状图
#region 投料柱状图
/// <summary>
/// 投料日产量统计柱状图
/// 投料统计柱状图
/// </summary>
private SeriesCollection outAchievement = new SeriesCollection();
@ -95,6 +95,35 @@ namespace SlnMesnac.WPF.ViewModel
#endregion
#region 日产量柱状图X轴日期
/// <summary>
/// 日产量柱状图X轴日期
/// </summary>
private List<string> productDayList = new List<string>();
public List<string> ProductDayList
{
get { return productDayList; }
set { productDayList = value; }
}
#endregion
#region 型号统计柱状图
/// <summary>
/// 日产量统计柱状图
/// </summary>
private SeriesCollection productAchievement = new SeriesCollection();
public SeriesCollection ProductAchievement
{
get { return productAchievement; }
set { productAchievement = value; }
}
#endregion
private DateTime _BeginDate;
public DateTime BeginDate
{
@ -135,14 +164,14 @@ namespace SlnMesnac.WPF.ViewModel
}
/// <summary>
/// 条码队列DataGrid
/// 成品入库记录DataGrid
/// </summary>
private ObservableCollection<MesPrdBarcodeInfo> barCodeTaskDataGrid;
private ObservableCollection<WmsProductInstock> productDataGrid = new ObservableCollection<WmsProductInstock>();
public ObservableCollection<MesPrdBarcodeInfo> BarCodeTaskDataGrid
public ObservableCollection<WmsProductInstock> ProductDataGrid
{
get { return barCodeTaskDataGrid; }
set { barCodeTaskDataGrid = value; RaisePropertyChanged(() => BarCodeTaskDataGrid); }
get { return productDataGrid; }
set { productDataGrid = value; RaisePropertyChanged(() => ProductDataGrid); }
}
#endregion
@ -177,6 +206,7 @@ namespace SlnMesnac.WPF.ViewModel
else
{
await RefreshWmsRawOutstockDetailDataGrid(BeginDate, EndDate);
await RefreshProductDataGrid(BeginDate, EndDate);
}
}
@ -189,7 +219,7 @@ namespace SlnMesnac.WPF.ViewModel
#region 原材料出库记录及图表
#region 3F原材料出库记录及图表
/// <summary>
/// 刷新原材料出库记录
/// </summary>
@ -214,6 +244,7 @@ namespace SlnMesnac.WPF.ViewModel
// 刷新图表
RefreshWmsRawOutstockDetailChart(list);
}
}
@ -257,5 +288,65 @@ namespace SlnMesnac.WPF.ViewModel
#endregion
#region 2F成品生产记录及统计图表
private async Task RefreshProductDataGrid(DateTime beginDate, DateTime endDate)
{
List<WmsProductInstock> list;
list = await sqlClient.AsTenant().GetConnection("mes").Queryable<WmsProductInstock>().Where(x => x.warehouseId == 231 && x.updateDate >= beginDate && x.updateDate <= endDate).OrderByDescending(t => t.updateDate).ToListAsync();
if (list != null && list.Count > 0)
{
await App.Current.Dispatcher.BeginInvoke((Action)(() =>
{
productDataGrid.Clear();
int i = 1;
foreach (WmsProductInstock verify in list)
{
verify.productInstockId = i++;
productDataGrid.Add(verify);
}
}));
// 刷新图表
RefreshProductChart(list);
}
}
private void RefreshProductChart(List<WmsProductInstock> list)
{
App.Current.Dispatcher.BeginInvoke((Action)(() =>
{
ProductAchievement.Clear();
ProductDayList.Clear();
ChartValues<ObservablePoint> achievement = new ChartValues<ObservablePoint>();
var listByDate = list
.GroupBy(detail => detail.updateDate.Value.Date) // 按日期分组
.Select(group => new
{
Date = group.Key,
TotalAmount = group.Count() // 统计出库数量
})
.ToList();
int i = 0;
foreach (var item in listByDate)
{
ProductDayList.Add(item.Date.ToString("MM-dd"));
achievement.Add(new ObservablePoint(i++, double.Parse(item.TotalAmount.ToString())));
}
//加一个汇总柱状图
ProductDayList.Add("合计");
achievement.Add(new ObservablePoint(i, list.Count));
var column = new ColumnSeries();
column.DataLabels = true;
column.Title = "日生产量";
column.Values = achievement;
column.Foreground = Brushes.White;
ProductAchievement.Add(column);
}));
}
#endregion
}
}

Loading…
Cancel
Save