You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
2.4 KiB
58 lines
2.4 KiB
|
4 years ago
|
using Audit.View;
|
||
|
|
using Models;
|
||
|
|
using System;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using System.Globalization;
|
||
|
|
using System.Linq;
|
||
|
|
using System.Text;
|
||
|
|
using System.Threading.Tasks;
|
||
|
|
using System.Windows.Data;
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 统计机台消耗变换器
|
||
|
|
/// 输入:原料代码、机台代码、时间区间
|
||
|
|
/// 输出:机台消耗
|
||
|
|
/// </summary>
|
||
|
|
namespace Audit.ConvertMoels
|
||
|
|
{
|
||
|
|
internal class MachinesGramsSumConvert : IValueConverter
|
||
|
|
{
|
||
|
|
private Dyelots dyelots = new Dyelots();
|
||
|
|
private DyelotsBulkedRecipe dyelotsBulkedRecipe = new DyelotsBulkedRecipe();
|
||
|
|
|
||
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||
|
|
{
|
||
|
|
string machines = System.Convert.ToString(value);//转换机台号
|
||
|
|
if (string.IsNullOrWhiteSpace(StatisticsView.query_start)) StatisticsView.query_start = DateTime.Now.AddDays(-30).ToString("yyyy-MM-dd");//默认开始时间当前日期前30天
|
||
|
|
if (string.IsNullOrWhiteSpace(StatisticsView.query_end)) StatisticsView.query_end = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd");//默认结束时间当前日期后一天
|
||
|
|
if (string.IsNullOrWhiteSpace(StatisticsView.DataGridStatistics_ProductCode))//原料代码名有效返回数据,无效返回空
|
||
|
|
{
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
dyelotsBulkedRecipe.Dispenser = System.Convert.ToString(machines);//传递机台
|
||
|
|
dyelotsBulkedRecipe.ProductCode = StatisticsView.DataGridStatistics_ProductCode;
|
||
|
|
dyelotsBulkedRecipe.DispenseStartTime = System.Convert.ToDateTime(StatisticsView.query_start);
|
||
|
|
dyelotsBulkedRecipe.DispenseEndTime = System.Convert.ToDateTime(StatisticsView.query_end);
|
||
|
|
float Machines_sum = (float)new DyelotsBulkedRecipeProvider().SelectMachineSUM(dyelotsBulkedRecipe).Sum(x => x.DispenseGrams);//查询并返回统计结果
|
||
|
|
if (Machines_sum == 0)
|
||
|
|
{
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
string Machines_grams_sum = (Machines_sum / 1000).ToString("#0.00");
|
||
|
|
return Machines_grams_sum;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||
|
|
{
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|