diff --git a/SlnMesnac.Model/domain/ProdPLanInfo.cs b/SlnMesnac.Model/domain/ProdPLanInfo.cs
index f432b6f..ecbf709 100644
--- a/SlnMesnac.Model/domain/ProdPLanInfo.cs
+++ b/SlnMesnac.Model/domain/ProdPLanInfo.cs
@@ -68,7 +68,7 @@ namespace SlnMesnac.Model.domain
/// 实际开始时间
///
[SugarColumn(ColumnName = "begin_time")]
- public string BeginTIme { get; set; }
+ public string BeginTime { get; set; }
///
/// 实际完成时间
@@ -111,5 +111,11 @@ namespace SlnMesnac.Model.domain
///
[SugarColumn(ColumnName = "device_code")]
public string DeviceCode { get; set; }
+
+ ///
+ /// 工单状态
+ ///
+ [SugarColumn(ColumnName = "plan_status")]
+ public string PlanStatus { get; set; }
}
}
diff --git a/SlnMesnac.Model/domain/ProdPlanDetail.cs b/SlnMesnac.Model/domain/ProdPlanDetail.cs
new file mode 100644
index 0000000..19390d2
--- /dev/null
+++ b/SlnMesnac.Model/domain/ProdPlanDetail.cs
@@ -0,0 +1,97 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Runtime.Serialization;
+using System.Text;
+
+namespace SlnMesnac.Model.domain
+{
+ [SugarTable("prod_plan_detail"), TenantAttribute("mes")]
+ [DataContract(Name = "ProdPLanDetail 员工信息")]
+ public class ProdPlanDetail
+ {
+ ///
+ ///
+ ///
+ [SugarColumn(ColumnName = "obj_id", IsPrimaryKey = true, IsIdentity = true)]
+ public int ObjId { get; set; }
+
+ ///
+ /// 工单编号
+ ///
+ [SugarColumn(ColumnName = "plan_code")]
+ public string PlanCode { get; set; }
+
+ ///
+ /// 物料编号
+ ///
+ [SugarColumn(ColumnName = "material_code")]
+ public string MaterialCode { get; set; }
+
+ ///
+ /// 计划完成数
+ ///
+ [SugarColumn(ColumnName = "plan_amount")]
+ public string PlanAmount { get; set; }
+
+ ///
+ /// 实际完成数
+ ///
+ [SugarColumn(ColumnName = "complete_amount")]
+ public string CompleteAmount { get; set; }
+
+ ///
+ /// 开始时间
+ ///
+ [SugarColumn(ColumnName = "begin_time")]
+ public string BeginTime { get; set; }
+
+ ///
+ /// 结束时间
+ ///
+ [SugarColumn(ColumnName = "end_time")]
+ public string EndTime { get; set; }
+
+ ///
+ /// 当前班组长
+ ///
+ [SugarColumn(ColumnName = "current_staff_id")]
+ public string CurrentStaffId { get; set; }
+
+ ///
+ /// 下一班组长
+ ///
+ [SugarColumn(ColumnName = "next_staff_id")]
+ public string NextStaffId { get; set; }
+
+ ///
+ /// 结束标志
+ ///
+ [SugarColumn(ColumnName = "end_flag")]
+ public string EndFlag { get; set; }
+
+ ///
+ /// 创建人
+ ///
+ [SugarColumn(ColumnName = "created_by")]
+ public string CreatedBy { get; set; }
+
+ ///
+ /// 创建时间
+ ///
+ [SugarColumn(ColumnName = "created_time")]
+ public string CreatedTime { get; set; }
+
+ ///
+ /// 更新人
+ ///
+ [SugarColumn(ColumnName = "updated_by")]
+ public string UpdatedBy { get; set; }
+
+ ///
+ /// 更新时间
+ ///
+ [SugarColumn(ColumnName = "updated_time")]
+ public string UpdatedTime { get; set; }
+ }
+}
diff --git a/SlnMesnac.Repository/service/IRecordStaffAttendanceService.cs b/SlnMesnac.Repository/service/IRecordStaffAttendanceService.cs
index 4fa93d6..e7de803 100644
--- a/SlnMesnac.Repository/service/IRecordStaffAttendanceService.cs
+++ b/SlnMesnac.Repository/service/IRecordStaffAttendanceService.cs
@@ -20,5 +20,17 @@ namespace SlnMesnac.Repository.service
///
///
bool InsertRecordStaffAttendance(List recordStaffAttendances);
+
+ ///
+ /// 获取最后的上班记录
+ ///
+ ///
+ RecordStaffAttendance GetLastestOnRecord();
+
+ ///
+ /// 获取最后的下班记录
+ ///
+ ///
+ RecordStaffAttendance GetLastestOffRecord();
}
}
diff --git a/SlnMesnac.Repository/service/Impl/ProdPlanDetailServiceImpl.cs b/SlnMesnac.Repository/service/Impl/ProdPlanDetailServiceImpl.cs
new file mode 100644
index 0000000..062abce
--- /dev/null
+++ b/SlnMesnac.Repository/service/Impl/ProdPlanDetailServiceImpl.cs
@@ -0,0 +1,56 @@
+using Microsoft.Extensions.Logging;
+using SlnMesnac.Model.domain;
+using SlnMesnac.Repository.service.@base;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace SlnMesnac.Repository.service.Impl
+{
+ public class ProdPlanDetailServiceImpl : BaseServiceImpl, ProdPlanDetailService
+ {
+ private ILogger _logger;
+ public ProdPlanDetailServiceImpl(Repository repository, ILogger logger) : base(repository)
+ {
+ _logger = logger;
+ }
+
+ public List GetPlanDetails()
+ {
+ List pLanDetails = null;
+ try
+ {
+ pLanDetails = base._rep.GetList();
+ pLanDetails.Reverse();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError($"获取员工打卡信息异常{ex.Message}");
+ }
+ return pLanDetails;
+ }
+
+ public bool InsertPlanDetails(List planDetails)
+ {
+ bool result = false;
+ try
+ {
+ base._rep.AsTenant().BeginTran();
+ result = base._rep.InsertRange(planDetails);
+ base._rep.AsTenant().CommitTran();
+ }
+ catch (Exception ex)
+ {
+ base._rep.AsTenant().RollbackTran();
+ _logger.LogError($"员工打卡信息添加异常:{ex.Message}");
+ }
+ return result;
+ }
+
+ public ProdPlanDetail GetPlanDetailsByPlanCode(string planCode)
+ {
+ ProdPlanDetail prodPlanDetail = _rep.AsQueryable().WhereIF(!string.IsNullOrEmpty(planCode),x=>x.PlanCode == planCode).First();
+ return prodPlanDetail;
+ }
+ }
+}
diff --git a/SlnMesnac.Repository/service/Impl/ProdPlanInfoServiceImpl.cs b/SlnMesnac.Repository/service/Impl/ProdPlanInfoServiceImpl.cs
index 89cb8a1..3fafdfc 100644
--- a/SlnMesnac.Repository/service/Impl/ProdPlanInfoServiceImpl.cs
+++ b/SlnMesnac.Repository/service/Impl/ProdPlanInfoServiceImpl.cs
@@ -26,13 +26,14 @@ namespace SlnMesnac.Repository.service.Impl
///
///
///
- public List GetRecordStaffAttendancesByConditions(string? orderCode, string? planCode, string? materialCode, string? stationCode)
+ public List GetRecordStaffAttendancesByConditions(string? orderCode, string? planCode, string? materialCode, string? stationCode,string? planStatus)
{
List recordStaffAttendances = new List();
List planInfoList = _rep.AsQueryable().WhereIF(!string.IsNullOrEmpty(orderCode), x => x.OrderCode == orderCode)
.WhereIF(!string.IsNullOrEmpty(planCode), x => x.PlanCode == planCode)
.WhereIF(!string.IsNullOrEmpty(materialCode), x => x.MaterialCode == materialCode)
.WhereIF(!string.IsNullOrEmpty(stationCode), x => x.StationCode == stationCode)
+ .WhereIF(!string.IsNullOrEmpty(planStatus),x => x.PlanStatus == planStatus)
.ToList();
return planInfoList;
}
diff --git a/SlnMesnac.Repository/service/Impl/RecordStaffAttendanceServiceImpl.cs b/SlnMesnac.Repository/service/Impl/RecordStaffAttendanceServiceImpl.cs
index 3340024..afd21bf 100644
--- a/SlnMesnac.Repository/service/Impl/RecordStaffAttendanceServiceImpl.cs
+++ b/SlnMesnac.Repository/service/Impl/RecordStaffAttendanceServiceImpl.cs
@@ -48,5 +48,17 @@ namespace SlnMesnac.Repository.service.Impl
}
return result;
}
+
+ public RecordStaffAttendance GetLastestOnRecord()
+ {
+ RecordStaffAttendance recordStaffAttendances = _rep.AsQueryable().Where(x => x.AttendanceType == "0").OrderByDescending(x => x.CreateTime).First();
+ return recordStaffAttendances;
+ }
+
+ public RecordStaffAttendance GetLastestOffRecord()
+ {
+ RecordStaffAttendance recordStaffAttendances = _rep.AsQueryable().Where(x => x.AttendanceType == "1").OrderByDescending(x => x.CreateTime).First();
+ return recordStaffAttendances;
+ }
}
}
diff --git a/SlnMesnac.Repository/service/ProdPlanDetailService.cs b/SlnMesnac.Repository/service/ProdPlanDetailService.cs
new file mode 100644
index 0000000..33e568b
--- /dev/null
+++ b/SlnMesnac.Repository/service/ProdPlanDetailService.cs
@@ -0,0 +1,32 @@
+using SlnMesnac.Model.domain;
+using SlnMesnac.Repository.service.@base;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace SlnMesnac.Repository.service
+{
+ public interface ProdPlanDetailService : IBaseService
+ {
+ ///
+ /// 获取所有工单信息
+ ///
+ ///
+ List GetPlanDetails();
+
+ ///
+ /// 验证添加员工打卡记录
+ ///
+ ///
+ ///
+ bool InsertPlanDetails(List planDetails);
+
+ ///
+ /// 根据工单号查询此工单所有明细
+ ///
+ ///
+ ///
+ ///
+ ProdPlanDetail GetPlanDetailsByPlanCode(string planCode);
+ }
+}
diff --git a/SlnMesnac.Repository/service/ProdPlanInfoService.cs b/SlnMesnac.Repository/service/ProdPlanInfoService.cs
index 42209e4..e54044b 100644
--- a/SlnMesnac.Repository/service/ProdPlanInfoService.cs
+++ b/SlnMesnac.Repository/service/ProdPlanInfoService.cs
@@ -18,6 +18,6 @@ namespace SlnMesnac.Repository.service
/// 根据订单编号、工单编号、物料名称获取工单信息
///
///
- List GetRecordStaffAttendancesByConditions(string orderCode,string planCode,string materialCode, string stationCode);
+ List GetRecordStaffAttendancesByConditions(string orderCode,string planCode,string materialCode, string stationCode, string planStatus);
}
}
diff --git a/SlnMesnac.WPF/UserControls/ExecutePage.xaml b/SlnMesnac.WPF/UserControls/ExecutePage.xaml
index ff7acbe..4646b23 100644
--- a/SlnMesnac.WPF/UserControls/ExecutePage.xaml
+++ b/SlnMesnac.WPF/UserControls/ExecutePage.xaml
@@ -120,7 +120,7 @@
-
+
@@ -131,12 +131,12 @@
-
+ Foreground="#FFFFFF" SelectedItem="{Binding SelectedRow}">
@@ -158,9 +158,8 @@
-
-
-
+
+
@@ -201,6 +200,7 @@
+
@@ -209,6 +209,7 @@
+
@@ -217,6 +218,7 @@
+
@@ -225,6 +227,7 @@
+
@@ -232,18 +235,25 @@
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
@@ -254,10 +264,10 @@
-
+
-
+
diff --git a/SlnMesnac.WPF/UserControls/ExecutePage.xaml.cs b/SlnMesnac.WPF/UserControls/ExecutePage.xaml.cs
index cda9a0f..ba2b552 100644
--- a/SlnMesnac.WPF/UserControls/ExecutePage.xaml.cs
+++ b/SlnMesnac.WPF/UserControls/ExecutePage.xaml.cs
@@ -2,6 +2,7 @@
using SlnMesnac.WPF.Views;
using System;
using System.Collections.Generic;
+using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -50,5 +51,30 @@ namespace SlnMesnac.WPF.Page
{
e.Row.Header = (e.Row.GetIndex() + 1).ToString();
}
+
+ public string GetSelectedRowValue()
+ {
+ if (DataGridPlanInfo.SelectedItem != null)
+ {
+ DataRowView row = (DataRowView)DataGridPlanInfo.SelectedItems[0];
+
+ // 获取选中行中指定列的值
+ string value = row["PlanCode"].ToString();
+
+ //// 或者直接遍历选中行中的所有列
+ //foreach (DataColumn col in row.Row.Table.Columns)
+ //{
+ // string colName = col.ColumnName;
+ // string colValue = row[colName].ToString();
+ //}
+ return value;
+ }
+ else
+ {
+ return string.Empty;
+ }
+ }
+
+
}
}
diff --git a/SlnMesnac.WPF/ViewModel/ExecuteViewModel.cs b/SlnMesnac.WPF/ViewModel/ExecuteViewModel.cs
index d26208f..bd02dc8 100644
--- a/SlnMesnac.WPF/ViewModel/ExecuteViewModel.cs
+++ b/SlnMesnac.WPF/ViewModel/ExecuteViewModel.cs
@@ -5,10 +5,13 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.IdentityModel.Protocols;
using SlnMesnac.Business.business;
using SlnMesnac.Model.domain;
+using SlnMesnac.Model.dto;
using SlnMesnac.Repository.service;
+using SlnMesnac.WPF.Page;
using SlnMesnac.WPF.Views;
using SqlSugar;
using System;
+using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
@@ -30,22 +33,40 @@ namespace SlnMesnac.WPF.ViewModel
public ObservableCollection MaterialNameComboBoxItems { get; set; }
private ProdPlanInfoService _prodPlanInfoService;
private List prodPlanInfos;
+ private ProdPlanDetailService _prodPlanDetailService;
+ private IRecordStaffAttendanceService _recordStaffAttendanceService;
private string StationCode;
+ private bool isComplete = true;
///
/// 按钮文字转换事件
///
public event PropertyChangedEventHandler PropertyChanged;
+ ///
+ /// 检索命令
+ ///
+ public ICommand SearchCommand { get; private set; }
///
/// 换班命令
///
public ICommand HandoverCommand { get; private set; }
+ ///
+ /// 报工命令
+ ///
+ public ICommand ProductionReportCommand { get; private set; }
+
+ ///
+ /// 执行命令
+ ///
+ public ICommand ExecuteCommand { get; private set; }
+
public ExecuteViewModel()
{
_prodPlanInfoService = App.ServiceProvider.GetService();
- // 读取appsettings.json配置文件
+ _prodPlanDetailService = App.ServiceProvider.GetService();
+ _recordStaffAttendanceService = App.ServiceProvider.GetService();
IConfigurationBuilder configurationBuilder = new ConfigurationBuilder()
.SetBasePath(System.AppContext.BaseDirectory)
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
@@ -54,7 +75,9 @@ namespace SlnMesnac.WPF.ViewModel
stationTextBlock = configuration.GetSection("AppConfig")["ProductLineName"];
StationCode = configuration.GetSection("AppConfig")["ProductLineCode"];
HandoverCommand = new RelayCommand(Handover);
+ ProductionReportCommand = new RelayCommand(ProductionReport);
SearchCommand = new RelayCommand(Search);
+ ExecuteCommand = new RelayCommand(Execute);
}
///
@@ -64,15 +87,18 @@ namespace SlnMesnac.WPF.ViewModel
{
var handOverWin = new HandOverWin();
handOverWin.WindowStartupLocation = WindowStartupLocation.CenterScreen; // 让窗体出现在屏幕中央
-
handOverWin.ShowDialog();//窗体出现后禁止后面的用户控件
- //其他操作
}
///
- /// 检索命令
+ /// 换班弹窗
///
- public ICommand SearchCommand { get; private set; }
+ private void ProductionReport()
+ {
+ var reportWin = new ProductionReportWin();
+ reportWin.WindowStartupLocation = WindowStartupLocation.CenterScreen; // 让窗体出现在屏幕中央
+ reportWin.ShowDialog();//窗体出现后禁止后面的用户控件
+ }
///
/// 检索事件
@@ -80,18 +106,61 @@ namespace SlnMesnac.WPF.ViewModel
private void Search()
{
// 在这里执行其他操作,可以通过InputText获取用户输入的信息
- Console.WriteLine("用户输入的信息:" + OrderCodeTextBox + PlanCodeTextBox + MaterialCodeTextBox);
+ //Console.WriteLine("用户输入的信息:" + OrderCodeTextBox + PlanCodeTextBox + MaterialCodeTextBox);
//ProductLineNameTextBlock = ConfigurationManager.AppSettings["ProductLineNameTextBlock"];
- List list = _prodPlanInfoService.GetRecordStaffAttendancesByConditions(OrderCodeTextBox, PlanCodeTextBox, MaterialCodeTextBox, StationCode);
+ List list = _prodPlanInfoService.GetRecordStaffAttendancesByConditions(OrderCodeTextBox, PlanCodeTextBox, MaterialCodeTextBox, StationCode,"0");
System.Windows.Application.Current.Dispatcher.Invoke((Action)(async () =>
{
ProdPLanInfoDataGrid.Clear();
list.ForEach(item =>
- {
+ {
ProdPLanInfoDataGrid.Add(item);
});
}));
- //
+ }
+
+ // 新增的执行事件
+ private void Execute()
+ {
+ if (isComplete)
+ {
+ // 将当前记录存为实体,可以通过parameter获取当前记录的信息
+ string orderCode = _selectedRow.OrderCode.ToString();
+ string planCode = _selectedRow.PlanCode.ToString();
+ ProdPLanInfo pLanInfo = _prodPlanInfoService.GetRecordStaffAttendancesByConditions(orderCode, planCode, "", "", "0").First();
+ RecordStaffAttendance currentRecord = _recordStaffAttendanceService.GetLastestOnRecord();
+ RecordStaffAttendance nextRecord = _recordStaffAttendanceService.GetLastestOffRecord();
+ // 向detail表里插入一条数据
+ ProdPlanDetail prodPlanDetail = new ProdPlanDetail
+ {
+ PlanCode = pLanInfo.PlanCode,
+ MaterialCode = pLanInfo.MaterialCode,
+ PlanAmount = pLanInfo.PlanAmount,
+ CompleteAmount = pLanInfo.CompleteAmount,
+ BeginTime = DateTime.Now.ToString(),
+ CurrentStaffId = currentRecord.StaffId,
+ //NextStaffId = nextRecord.StaffId,
+ };
+ _prodPlanDetailService.Insert(prodPlanDetail);
+ //按钮文字变成执行中并锁定,其他的订单执行按钮也禁用
+ pLanInfo.BeginTime = DateTime.Now.ToString();
+ pLanInfo.PlanStatus = "1";
+ _prodPlanInfoService.Update(pLanInfo);
+ Search();
+ //查明细表显示出来
+ ProdPlanDetail planDetail = _prodPlanDetailService.GetPlanDetailsByPlanCode(pLanInfo.PlanCode);
+ PlanCodeText = planDetail.PlanCode;
+ OrderCodeText = pLanInfo.OrderCode;
+ MaterialCodeText = planDetail.MaterialCode;
+ StationCodeText = pLanInfo.StationCode;
+ System.Windows.Application.Current.Dispatcher.Invoke((Action)(async () =>
+ {
+ ProdPLanDetailDataGrid.Clear();
+ ProdPLanDetailDataGrid.Add(planDetail);
+ }));
+ isComplete = false;
+ }
+
}
#region
@@ -136,7 +205,7 @@ namespace SlnMesnac.WPF.ViewModel
}
///
- /// DataGrid
+ /// PlanDataGrid
///
private ObservableCollection prodPLanInfoDataGrid = new ObservableCollection();
public ObservableCollection ProdPLanInfoDataGrid
@@ -144,6 +213,69 @@ namespace SlnMesnac.WPF.ViewModel
get { return prodPLanInfoDataGrid; }
set { prodPLanInfoDataGrid = value; OnPropertyChanged("ProdPLanInfoDataGrid"); }
}
+
+ ///
+ /// DetailDataGrid
+ ///
+ private ObservableCollection prodPLanDetailDataGrid = new ObservableCollection();
+ public ObservableCollection ProdPLanDetailDataGrid
+ {
+ get { return prodPLanDetailDataGrid; }
+ set { ProdPLanDetailDataGrid = value; OnPropertyChanged("ProdPLanDetailDataGrid"); }
+ }
+
+ ///
+ /// 选中行
+ ///
+ public ProdPLanInfo _selectedRow;
+ public ProdPLanInfo SelectedRow
+ {
+ get { return _selectedRow; }
+ set
+ {
+ _selectedRow = value; OnPropertyChanged(nameof(SelectedRow));
+ }
+ }
+
+ ///
+ /// 订单Text
+ ///
+ private string orderCodeText;
+ public string OrderCodeText
+ {
+ get { return orderCodeText; }
+ set { orderCodeText = value; OnPropertyChanged("OrderCodeText"); }
+ }
+
+ ///
+ /// 工单Text
+ ///
+ private string planCodeText;
+ public string PlanCodeText
+ {
+ get { return planCodeText; }
+ set { planCodeText = value; OnPropertyChanged("PlanCodeText"); }
+ }
+
+ ///
+ /// 原料Text
+ ///
+ private string materialCodeText;
+ public string MaterialCodeText
+ {
+ get { return materialCodeText; }
+ set { materialCodeText = value; OnPropertyChanged("MaterialCodeText"); }
+ }
+
+ ///
+ /// 订单
+ ///
+ private string stationCodeText;
+ public string StationCodeText
+ {
+ get { return stationCodeText; }
+ set { stationCodeText = value; OnPropertyChanged("StationCodeText"); }
+ }
#endregion
public void OnPropertyChanged([CallerMemberName] string propertyName = "")
diff --git a/SlnMesnac.WPF/ViewModel/HandOverViewModel.cs b/SlnMesnac.WPF/ViewModel/HandOverViewModel.cs
index 9e2e5ea..607065a 100644
--- a/SlnMesnac.WPF/ViewModel/HandOverViewModel.cs
+++ b/SlnMesnac.WPF/ViewModel/HandOverViewModel.cs
@@ -1,4 +1,5 @@
using ConsoleApp;
+using GalaSoft.MvvmLight.Command;
using Microsoft.Extensions.DependencyInjection;
using SlnMesnac.Model.domain;
using SlnMesnac.Repository.service;
@@ -9,29 +10,100 @@ using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
+using System.Windows.Input;
namespace SlnMesnac.WPF.ViewModel
{
public class HandOverViewModel : INotifyPropertyChanged
{
- //private HidUtils hidUtils = new HidUtils();
private IBaseStaffService _baseStaffService;
+ private ProdPlanInfoService _prodPlanInfoService;
+ private ProdPlanDetailService _prodPlanDetailService;
+ private ProdPLanInfo planInfo;
+ private ProdPlanDetail planDetail;
private int times;
///
/// 按钮文字转换事件
///
- public event PropertyChangedEventHandler PropertyChanged;
+ public event PropertyChangedEventHandler PropertyChanged = delegate { };
public HandOverViewModel()
{
+ _prodPlanDetailService = App.ServiceProvider.GetService();
+ _prodPlanInfoService = App.ServiceProvider.GetService();
+ planInfo = _prodPlanInfoService.GetRecordStaffAttendancesByConditions("", "", "", "", "1").FirstOrDefault();
+ HandoverCommand = new RelayCommand(Handover);
Init();
_baseStaffService = App.ServiceProvider.GetService();
}
+ ///
+ /// 初始化
+ ///
+ private void Init()
+ {
+ planDetail = _prodPlanDetailService.GetPlanDetailsByPlanCode(planInfo.PlanCode);
+ PlanAmountText = planDetail.PlanAmount.ToString();
+ CompleteAmountText = planDetail.CompleteAmount.ToString();
+ var hidUtils = EmployeeLoginViewModel.hidUtils;
+ // hidUtils.Initial();
+ hidUtils.StartScan();
+ hidUtils.pushReceiveDataEvent += (bytes, str) =>
+ {
+ if (times < 2)//打卡超过2次无效
+ {
+ str = str.ToString().Replace(" ", "");
+ BaseStaffInfo user = _baseStaffService.GetStaffInfoByCardId(str);
+ if (user != null)
+ {
+ string staffType = user.StaffType;
+ if (staffType == "1")//判断是否为班长
+ {
+ //显示记录
+ StaffIdText = user.StaffId;
+ StaffNameText = user.StaffName;
+ StaffTypeText = user.StaffType;
+ TeamCodeText = user.TeamCode;
+ //数量+1
+ times++;
+ }
+ else
+ {
+ HintText = "打卡人员非班长,打卡无效!";
+ }
+ }
+ else
+ {
+ HintText = "没有匹配的员工,打卡失败!";
+ }
+ }
+ };
+ }
+
#region
+ ///
+ /// 计划数量Text
+ ///
+ private string planAmountText;
+ public string PlanAmountText
+ {
+ get { return planAmountText; }
+ set { planAmountText = value; OnPropertyChanged("PlanAmountText"); }
+ }
+
+ ///
+ /// 完成数量Text
+ ///
+ private string completeAmountText;
+ public string CompleteAmountText
+ {
+ get { return completeAmountText; }
+ set { completeAmountText = value; OnPropertyChanged("CompleteAmountText"); }
+ }
+
///
/// 员工id
///
@@ -94,43 +166,20 @@ namespace SlnMesnac.WPF.ViewModel
#endregion
///
- /// 初始化
+ /// 确认交班
///
- private void Init()
+ public ICommand HandoverCommand { get; private set; }
+ private void Handover()
{
- var hidUtils = EmployeeLoginViewModel.hidUtils;
- // hidUtils.Initial();
- hidUtils.StartScan();
- hidUtils.pushReceiveDataEvent += (bytes, str) =>
+ //判断两个班长是否都已打卡
+ if(times == 2)
{
- if (times < 2)
- {
- str = str.ToString().Replace(" ", "");
- BaseStaffInfo user = _baseStaffService.GetStaffInfoByCardId(str);
- if (user != null)
- {
- string staffType = user.StaffType;
- if (staffType == "1")
- {
- //显示记录
- StaffIdText = user.StaffId;
- StaffNameText = user.StaffName;
- StaffTypeText = user.StaffType;
- TeamCodeText = user.TeamCode;
- //数量+1
- times++;
- }
- else
- {
- HintText = "打卡人员非班长,打卡无效!";
- }
- }
- else
- {
- HintText = "没有匹配的员工,打卡失败!";
- }
- }
- };
+ //在工单明细插入一条,记录两个班长
+ }
+ else
+ {
+ HintText = "有人未打卡,请检查!";
+ }
}
public void OnPropertyChanged([CallerMemberName] string propertyName = "")
diff --git a/SlnMesnac.WPF/ViewModel/ProductionReportViewModel.cs b/SlnMesnac.WPF/ViewModel/ProductionReportViewModel.cs
new file mode 100644
index 0000000..276be28
--- /dev/null
+++ b/SlnMesnac.WPF/ViewModel/ProductionReportViewModel.cs
@@ -0,0 +1,179 @@
+using GalaSoft.MvvmLight.Command;
+using Microsoft.Extensions.DependencyInjection;
+using SlnMesnac.Model.domain;
+using SlnMesnac.Repository.service;
+using SlnMesnac.WPF.Views;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Runtime.CompilerServices;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Input;
+
+namespace SlnMesnac.WPF.ViewModel
+{
+ public class ProductionReportViewModel : INotifyPropertyChanged
+ {
+ private ProdPlanInfoService _prodPlanInfoService;
+ private ProdPlanDetailService _prodPlanDetailService;
+ private ProdPLanInfo planInfo;
+ private ProdPlanDetail planDetail;
+
+ ///
+ /// 按钮文字转换事件
+ ///
+ public event PropertyChangedEventHandler PropertyChanged = delegate { };
+
+ public ProductionReportViewModel()
+ {
+ _prodPlanDetailService = App.ServiceProvider.GetService();
+ _prodPlanInfoService = App.ServiceProvider.GetService();
+ ConfirmCommand = new RelayCommand(Confirm);
+ EndPlanCommand = new RelayCommand(EndPlan);
+ Init();
+ }
+
+ private void Init()
+ {
+ planInfo = _prodPlanInfoService.GetRecordStaffAttendancesByConditions("", "", "", "","1").FirstOrDefault();
+ Refresh();
+ }
+
+ private void Refresh()
+ {
+ if (planInfo != null)
+ {
+ planDetail = _prodPlanDetailService.GetPlanDetailsByPlanCode(planInfo.PlanCode);
+ PlanAmountText = planDetail.PlanAmount.ToString();
+ CompleteAmountText = planDetail.CompleteAmount.ToString();
+ }
+ else
+ {
+ HintText = "没有正在执行的工单,请执行工单!";
+ }
+ }
+
+ #region
+ ///
+ /// 计划数量Text
+ ///
+ private string planAmountText;
+ public string PlanAmountText
+ {
+ get { return planAmountText; }
+ set { planAmountText = value; OnPropertyChanged("PlanAmountText"); }
+ }
+
+ ///
+ /// 完成数量Text
+ ///
+ private string completeAmountText;
+ public string CompleteAmountText
+ {
+ get { return completeAmountText; }
+ set { completeAmountText = value; OnPropertyChanged("CompleteAmountText"); }
+ }
+
+ ///
+ /// 新增数量Text
+ ///
+ private string newAmountText;
+ public string NewAmountText
+ {
+ get { return newAmountText; }
+ set { newAmountText = value; OnPropertyChanged("NewAmountText"); }
+ }
+
+ ///
+ /// 提示框
+ ///
+ private string hintText;
+ public string HintText
+ {
+ get { return hintText; }
+ set { hintText = value; OnPropertyChanged("HintText"); }
+ }
+ #endregion
+
+ ///
+ /// 确认命令
+ ///
+ public ICommand ConfirmCommand { get; private set; }
+ ///
+ /// 确认事件
+ ///
+ private void Confirm()
+ {
+ string newAmount = NewAmountText;
+ if (newAmount != null)
+ {
+ bool isNum = true;
+ foreach (char x in newAmount)
+ {
+ if (!char.IsNumber(x) && x != '.')
+ {
+ isNum = false;
+ }
+ }
+ if (isNum)
+ {
+ //将新增产量加到实际产量中
+ double currentAmountDouble = Convert.ToDouble(planDetail.CompleteAmount);
+ double newAmountDouble = Convert.ToDouble(newAmount);
+ double result = currentAmountDouble + newAmountDouble;
+ planDetail.CompleteAmount = result.ToString();
+ _prodPlanDetailService.Update(planDetail);
+ Refresh();
+ NewAmountText = null;
+ HintText = "已提交!";
+ }
+ else
+ {
+ //提示框提示错误信息
+ HintText = "输入有误,请输入阿拉伯数字!";
+ }
+ }
+ else
+ {
+ HintText = "不能为空!";
+ }
+ }
+
+ ///
+ /// 确认命令
+ ///
+ public ICommand EndPlanCommand { get; private set; }
+ private void EndPlan()
+ {
+ planDetail.EndTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+ _prodPlanDetailService.Update(planDetail);
+ planInfo.PlanStatus = "2";
+ planInfo.EndTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+ double planAmountDouble = Convert.ToDouble(planDetail.PlanAmount);
+ double completeAmountDouble = Convert.ToDouble(planDetail.CompleteAmount);
+ if(planAmountDouble == completeAmountDouble)
+ {
+ planInfo.CompFlag = "0";//正常完成
+ }
+ else if(planAmountDouble > completeAmountDouble)
+ {
+ planInfo.CompFlag = "1";//不足目标产量降级处理
+ }
+ else
+ {
+ planInfo.CompFlag = "2";//超额完成
+ }
+ _prodPlanInfoService.Update(planInfo);
+ //关闭窗口
+ Application.Current.Windows.OfType().First().Close();
+ }
+
+ public void OnPropertyChanged([CallerMemberName] string propertyName = "")
+ {
+ PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
+ }
+ }
+}
diff --git a/SlnMesnac.WPF/Views/HandOverWin.xaml b/SlnMesnac.WPF/Views/HandOverWin.xaml
index 164e7d4..6ee74a0 100644
--- a/SlnMesnac.WPF/Views/HandOverWin.xaml
+++ b/SlnMesnac.WPF/Views/HandOverWin.xaml
@@ -94,7 +94,7 @@
-
+
@@ -103,7 +103,7 @@
-
+
@@ -172,13 +172,9 @@
-
-
-
-
-
+
-
+
diff --git a/SlnMesnac.WPF/Views/HandOverWin.xaml.cs b/SlnMesnac.WPF/Views/HandOverWin.xaml.cs
index e9247eb..a7cd1eb 100644
--- a/SlnMesnac.WPF/Views/HandOverWin.xaml.cs
+++ b/SlnMesnac.WPF/Views/HandOverWin.xaml.cs
@@ -25,5 +25,10 @@ namespace SlnMesnac.WPF.Views
InitializeComponent();
this.DataContext = new HandOverViewModel();
}
+
+ private void ProductionReport_Click(object sender, RoutedEventArgs e)
+ {
+
+ }
}
}
diff --git a/SlnMesnac.WPF/Views/ProductionReportWin.xaml b/SlnMesnac.WPF/Views/ProductionReportWin.xaml
new file mode 100644
index 0000000..663fa05
--- /dev/null
+++ b/SlnMesnac.WPF/Views/ProductionReportWin.xaml
@@ -0,0 +1,161 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/SlnMesnac.WPF/Views/ProductionReportWin.xaml.cs b/SlnMesnac.WPF/Views/ProductionReportWin.xaml.cs
new file mode 100644
index 0000000..a3956d6
--- /dev/null
+++ b/SlnMesnac.WPF/Views/ProductionReportWin.xaml.cs
@@ -0,0 +1,29 @@
+using SlnMesnac.WPF.ViewModel;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+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.Shapes;
+
+namespace SlnMesnac.WPF.Views
+{
+ ///
+ /// ProductionReportWin.xaml 的交互逻辑
+ ///
+ public partial class ProductionReportWin : Window
+ {
+ public ProductionReportWin()
+ {
+ InitializeComponent();
+ this.DataContext = new ProductionReportViewModel();
+ }
+ }
+}
diff --git a/SlnMesnac.WPF/appsettings.json b/SlnMesnac.WPF/appsettings.json
index 7becd68..54c8fdd 100644
--- a/SlnMesnac.WPF/appsettings.json
+++ b/SlnMesnac.WPF/appsettings.json
@@ -57,7 +57,7 @@
}
],
"redisConfig": "175.27.215.92:6379,password=redis@2023",
- "ProductLineCode": "1001",
- "ProductLineName": "一产线"
+ "StationCode": "1010",
+ "ProductLineName": "压延一工位"
}
}