You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
139 lines
4.7 KiB
C#
139 lines
4.7 KiB
C#
using MaterialTraceability.Business;
|
|
using MaterialTraceability.Entity.DAO;
|
|
using MaterialTraceability.Entity.DTO;
|
|
using MaterialTraceability.SqlSugar;
|
|
using MaterialTraceability.SqlSugar.ServiceImpl;
|
|
using MaterialTraceabilityUI.Common;
|
|
using SqlSugar;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Linq.Expressions;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Data;
|
|
using System.Windows.Documents;
|
|
using System.Windows.Input;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Navigation;
|
|
using System.Windows.Shapes;
|
|
|
|
namespace MaterialTraceabilityUI
|
|
{
|
|
/// <summary>
|
|
/// UpMaterialRecord.xaml 的交互逻辑
|
|
/// </summary>
|
|
public partial class DownMaterialRecord : UserControl
|
|
{
|
|
|
|
private IBaseServices<ProDownRecord> uprecordServices = new BaseServices<ProDownRecord>();
|
|
|
|
private AppConfigDto appConfig = AppConfigDto.Instance;
|
|
public DownMaterialRecord()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void Seach_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
Refresh();
|
|
}
|
|
|
|
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
|
{
|
|
Refresh();
|
|
this.beginTime.Text = DateTime.Now.ToLongDateString();
|
|
this.endTime.Text = DateTime.Now.AddDays(1).ToLongDateString();
|
|
}
|
|
|
|
public void Refresh()
|
|
{
|
|
Expression<Func<ProDownRecord, bool>> exp = s1 => true;
|
|
if (this.beginTime.Text.ToString() != "")
|
|
{
|
|
DateTime beginTime = Convert.ToDateTime(this.beginTime.Text.ToString());
|
|
exp = exp.And(x => Convert.ToDateTime(x.RecordTime) >= beginTime);
|
|
}
|
|
|
|
if (this.endTime.Text.ToString() != "")
|
|
{
|
|
DateTime endTime = Convert.ToDateTime(this.endTime.Text.ToString());
|
|
exp = exp.And(x => Convert.ToDateTime(x.RecordTime) <= endTime);
|
|
}
|
|
|
|
if (this.rfidText.Text.ToString() != "")
|
|
{
|
|
exp = exp.And(x => x.Rfid.Contains(this.rfidText.Text.ToString()));
|
|
}
|
|
|
|
if (this.sfcText.Text.ToString() != "")
|
|
{
|
|
exp = exp.And(x => x.Sfc.Contains(this.sfcText.Text.ToString()));
|
|
}
|
|
if (appConfig.processId == "AB")
|
|
{
|
|
exp = exp.And(x => x.MachineId == appConfig.machineId);
|
|
}
|
|
Expression<Func<ProDownRecord, object>> order = x => x.beginTime;
|
|
|
|
List<ProDownRecord> proUpRecords = this.SelectDownRecords(exp).Result;
|
|
proUpRecords.ForEach(x =>
|
|
{
|
|
x.DownMaterialId = x.IsProduction == 1 ? "已生产" : "未生产";
|
|
x.IsProduction = proUpRecords.IndexOf(x)+1;
|
|
if (appConfig.machineId == 4)
|
|
{
|
|
if (x.Id.Contains("左"))
|
|
{
|
|
x.Id = x.Id.Replace("左", "右");
|
|
}
|
|
else if (x.Id.Contains("右"))
|
|
{
|
|
x.Id = x.Id.Replace("右", "左");
|
|
}
|
|
}
|
|
});
|
|
this.UpMaterialDataGrid.ItemsSource = proUpRecords;
|
|
}
|
|
|
|
private async Task<List<ProDownRecord>> SelectDownRecords(Expression<Func<ProDownRecord, bool>> exp)
|
|
{
|
|
try
|
|
{
|
|
Expression<Func<ProDownRecord, ProEquip, Object[]>> joinTable = (s1, s2) => new object[]
|
|
{
|
|
JoinType.Left,
|
|
s2.machineId == appConfig.machineId && s2.positionId == s1.PositionId
|
|
};
|
|
|
|
Expression<Func<ProDownRecord, ProEquip, ProDownRecord>> selectWhere = (s1, s2) => new ProDownRecord
|
|
{
|
|
Id = s2.equipName,
|
|
MachineId = s1.MachineId,
|
|
PositionId = s1.PositionId,
|
|
Rfid = s1.Rfid,
|
|
Sfc = s1.Sfc,
|
|
IsProduction = s1.IsProduction,
|
|
isFinish = s1.isFinish,
|
|
RecordTime = s1.RecordTime,
|
|
eaValue = s1.eaValue,
|
|
beginTime = s1.beginTime,
|
|
endTime = s1.endTime,
|
|
};
|
|
|
|
List<ProDownRecord> info = await uprecordServices.QueryMuch<ProDownRecord, ProEquip, ProDownRecord>(joinTable, selectWhere, exp);
|
|
|
|
return info;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelperBusiness.LogError("下料记录查询异常", ex);
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
}
|