diff --git a/SlnMesnac.Business/business/DatabaseHandleBusniess.cs b/SlnMesnac.Business/business/DatabaseHandleBusniess.cs
index d687c0c..6f5545b 100644
--- a/SlnMesnac.Business/business/DatabaseHandleBusniess.cs
+++ b/SlnMesnac.Business/business/DatabaseHandleBusniess.cs
@@ -56,6 +56,7 @@ namespace SlnMesnac.Business.business
OrderCode = orderCode,
MaterialCode = orderInfo.MaterialCode,
MaterialName = orderInfo.MaterialName,
+ BeginTime =DateTime.Now.ToString(),
StationCode = stationCode,
DeviceCode = deviceCode,
PlanAmount = orderInfo.OrderAmount,
@@ -152,6 +153,16 @@ namespace SlnMesnac.Business.business
return _prodPlanInfoService.GetPlanInfoByConditions(orderCode,"","", stationCode,"0").FirstOrDefault();
}
+ ///
+ /// 更新订单信息状态
+ ///
+ ///
+ ///
+ public void UpdateOrderInfoStatus(string orderCode,string status)
+ {
+ _prodOrderInfoService.UpdateOrderInfoStatus(orderCode,status);
+ }
+
/////
///// 查询所有计划工位
/////
diff --git a/SlnMesnac.Business/business/RfidHandleBusniess.cs b/SlnMesnac.Business/business/RfidHandleBusniess.cs
index 2004cc2..1b647c0 100644
--- a/SlnMesnac.Business/business/RfidHandleBusniess.cs
+++ b/SlnMesnac.Business/business/RfidHandleBusniess.cs
@@ -26,6 +26,7 @@ namespace SlnMesnac.Business.business
private List members = new List();
public static string stationCode = "";
public static List stationList;
+ public static string staffId = "";
public RfidHandleBusniess(IRecordStaffAttendanceService recordStaffAttendanceService, IRecordStaffCommuteService recordStaffCommuteService, IRecordStaffRealTimeService recordStaffRealTimeService)
{
@@ -57,6 +58,28 @@ namespace SlnMesnac.Business.business
return _recordStaffAttendanceService.GetRecordStaffAttendances(stationCode);
}
+ ///
+ /// 处理并插入打卡记录(强退)
+ ///
+ ///
+ ///
+ ///
+ public List HandleAndInsertRemove(BaseStaffInfo staff, int isCheckOn)
+ {
+ RecordStaffAttendance recordStaffAttendance = new RecordStaffAttendance
+ {
+ StaffId = staff.StaffId,
+ AttendanceType = isCheckOn.ToString(),
+ TeamCode = staff.TeamCode,
+ Remark = staffId,
+ CreateBy = staff.StaffName,
+ CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
+ StationCode = stationCode
+ };
+ _recordStaffAttendanceService.Insert(recordStaffAttendance);
+ return _recordStaffAttendanceService.GetRecordStaffAttendances(stationCode);
+ }
+
///
/// 处理上下班记录
///
diff --git a/SlnMesnac.Repository/service/Impl/ProdOrderInfoServiceImpl.cs b/SlnMesnac.Repository/service/Impl/ProdOrderInfoServiceImpl.cs
index 49b95eb..5686b2d 100644
--- a/SlnMesnac.Repository/service/Impl/ProdOrderInfoServiceImpl.cs
+++ b/SlnMesnac.Repository/service/Impl/ProdOrderInfoServiceImpl.cs
@@ -35,5 +35,33 @@ namespace SlnMesnac.Repository.service.Impl
}
return prodOrderInfo;
}
+
+ ///
+ /// 更新订单状态
+ ///
+ ///
+ ///
+ ///
+ public void UpdateOrderInfoStatus(string orderCode, string status)
+ {
+ try
+ {
+ var prodOrderInfo = _rep.GetFirst(x => x.OrderCode == orderCode);
+ if (prodOrderInfo != null)
+ {
+ prodOrderInfo.OrderStatus = status; // 更新订单状态
+ _rep.Update(prodOrderInfo); // 假设有一个Update方法来保存更改
+ }
+ else
+ {
+ _logger.LogWarning($"未找到订单号为 {orderCode} 的订单信息");
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError($"更新订单状态异常:{ex.Message}");
+ }
+ }
+
}
}
diff --git a/SlnMesnac.Repository/service/Impl/ProdPlanInfoServiceImpl.cs b/SlnMesnac.Repository/service/Impl/ProdPlanInfoServiceImpl.cs
index 56dd8d7..b1a136c 100644
--- a/SlnMesnac.Repository/service/Impl/ProdPlanInfoServiceImpl.cs
+++ b/SlnMesnac.Repository/service/Impl/ProdPlanInfoServiceImpl.cs
@@ -53,7 +53,7 @@ namespace SlnMesnac.Repository.service.Impl
.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 || x.PlanStatus == "4")
+ .WhereIF(!string.IsNullOrEmpty(planStatus), x => x.PlanStatus == planStatus)
.OrderByDescending(x => x.ObjId)
.ToList();
return planInfoList;
@@ -85,7 +85,8 @@ namespace SlnMesnac.Repository.service.Impl
ProdPLanInfo prodPLan = new ProdPLanInfo();
try
{//只显示未执行的
- prodPLan = _rep.GetFirst(x => x.OrderCode == orderCode && x.StationCode == stationCode && x.PlanStatus == "0" || x.PlanStatus == "4");
+ prodPLan = _rep.GetFirst(x => x.OrderCode == orderCode && x.StationCode == stationCode);
+ //&& (x.PlanStatus == "0" || x.PlanStatus == "4")
}
catch (Exception ex)
{
diff --git a/SlnMesnac.Repository/service/ProdOrderInfoService.cs b/SlnMesnac.Repository/service/ProdOrderInfoService.cs
index 04cbe30..63713cf 100644
--- a/SlnMesnac.Repository/service/ProdOrderInfoService.cs
+++ b/SlnMesnac.Repository/service/ProdOrderInfoService.cs
@@ -9,5 +9,6 @@ namespace SlnMesnac.Repository.service
public interface ProdOrderInfoService : IBaseService
{
ProdOrderInfo GetProdOrderInfoByOrderCode(string orderCode);
+ public void UpdateOrderInfoStatus(string orderCode,string status);
}
}
diff --git a/SlnMesnac.WPF/UserControls/ExecutePage.xaml b/SlnMesnac.WPF/UserControls/ExecutePage.xaml
index 2c1bcc2..7d0c120 100644
--- a/SlnMesnac.WPF/UserControls/ExecutePage.xaml
+++ b/SlnMesnac.WPF/UserControls/ExecutePage.xaml
@@ -123,13 +123,13 @@
-
+
+
@@ -156,9 +156,9 @@
-
+
-
+
@@ -230,6 +230,54 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/SlnMesnac.WPF/ViewModel/EmployeeLoginViewModel.cs b/SlnMesnac.WPF/ViewModel/EmployeeLoginViewModel.cs
index 99fd716..cacf0df 100644
--- a/SlnMesnac.WPF/ViewModel/EmployeeLoginViewModel.cs
+++ b/SlnMesnac.WPF/ViewModel/EmployeeLoginViewModel.cs
@@ -52,7 +52,7 @@ namespace SlnMesnac.WPF.ViewModel
public static bool isOnDuty = false;//是否有班组当班
private List uniqueStrings = new List();
private List timestamps = new List();
- //private BaseStaffInfo user;
+ private BaseStaffInfo user;
///
/// 按钮文字转换事件
@@ -290,7 +290,11 @@ namespace SlnMesnac.WPF.ViewModel
var result = ExtractStrings(SelectedItem);
RfidHandleBusniess.stationCode = result.Item1;
stationName = result.Item2;
+ //ExecuteViewModel.stationTextBlock = stationName;
+ TransmitStationNameAction?.Invoke(stationName);
isSelectedStationCode = true;
+ TransmitUserDelegateEvent?.Invoke();
+ ShowStaffAttendances(null, isCheckOn);
MessageBox.Show("已确认工位:" + stationName);
}
else
@@ -314,7 +318,7 @@ namespace SlnMesnac.WPF.ViewModel
if (RemoveConfirmViewModel.times == 1)
{
var theUser = baseStaffService.GetStaffInfoByStaffId(staffId);
- _rfidHandleBusniess.HandleAndInsertStaffAttendance(theUser, 2);
+ _rfidHandleBusniess.HandleAndInsertRemove(theUser, 2);
var list = _rfidHandleBusniess.HandleAndInsertStaffRealTime(theUser, 2);
if (list.Count>=0)
{
@@ -323,6 +327,7 @@ namespace SlnMesnac.WPF.ViewModel
RecordStaffRealTimeDataGrid.Clear();
list.ForEach(item => { RecordStaffRealTimeDataGrid.Add(item); });
}));
+ _rfidHandleBusniess.HandleStaffCommute(user, 1);
}
if(list.Count == 0)
{
@@ -355,7 +360,7 @@ namespace SlnMesnac.WPF.ViewModel
// Additional logic for processing the unique string goes here
if (isUse)
{
- var user = baseStaffService.GetStaffInfoByCardId(cleanStr);
+ user = baseStaffService.GetStaffInfoByCardId(cleanStr);
if (user != null)
{
RecordStaffAttendance recordStaffAttendance = _recordStaffAttendanceService.GetRecordStaffAttendanceByStaffId(user.StaffId, RfidHandleBusniess.stationCode);
@@ -523,7 +528,7 @@ namespace SlnMesnac.WPF.ViewModel
}
///
- /// 30分钟内过滤重复str
+ /// 5秒内过滤重复str
///
///
///
@@ -531,7 +536,7 @@ namespace SlnMesnac.WPF.ViewModel
{
for (int i = 0; i < uniqueStrings.Count; i++)
{
- if (uniqueStrings[i] == str && (DateTime.Now - timestamps[i]).TotalSeconds < 30)
+ if (uniqueStrings[i] == str && (DateTime.Now - timestamps[i]).TotalSeconds < 5)
{
return true;
}
diff --git a/SlnMesnac.WPF/ViewModel/ExecuteViewModel.cs b/SlnMesnac.WPF/ViewModel/ExecuteViewModel.cs
index 3fff773..2d61387 100644
--- a/SlnMesnac.WPF/ViewModel/ExecuteViewModel.cs
+++ b/SlnMesnac.WPF/ViewModel/ExecuteViewModel.cs
@@ -2,6 +2,7 @@
using Microsoft.AspNetCore.Components.Forms;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Logging;
using Microsoft.IdentityModel.Protocols;
using NVelocity.Util.Introspection;
using SlnMesnac.Business;
@@ -30,6 +31,7 @@ namespace SlnMesnac.WPF.ViewModel
{
public class ExecuteViewModel : INotifyPropertyChanged
{
+ private readonly ILogger _logger;
public ObservableCollection OrderCodeComboBoxItems { get; set; }
public ObservableCollection PlanCodeComboBoxItems { get; set; }
public ObservableCollection MaterialNameComboBoxItems { get; set; }
@@ -44,6 +46,9 @@ namespace SlnMesnac.WPF.ViewModel
private string DeviceCode;
private string ProcessCode;
public static bool isComplete = true;
+ public static string theStartTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");//记录每个明细的开始时间
+ public static int stations = 0;
+ private string theOrderCode = "";
private ProdPLanInfo pLanInfo;
private ProdPLanInfo haveInfo;
private SerialPortBusiness _serialPortBusiness;
@@ -132,10 +137,10 @@ namespace SlnMesnac.WPF.ViewModel
/// 工位
///
private string stationTextBlock;
- public string StationTextBox
+ public string StationTextBox
{
get { return stationTextBlock; }
- set { stationTextBlock = value; new PropertyChangedEventArgs(nameof(StationTextBox)); }
+ set { stationTextBlock = value; OnPropertyChanged("StationTextBox"); }
}
///
@@ -194,11 +199,11 @@ namespace SlnMesnac.WPF.ViewModel
///
/// 原料Text
///
- private string materialCodeText;
- public string MaterialCodeText
+ private string materialNameText;
+ public string MaterialNameText
{
- get { return materialCodeText; }
- set { materialCodeText = value; OnPropertyChanged("MaterialCodeText"); }
+ get { return materialNameText; }
+ set { materialNameText = value; OnPropertyChanged("MaterialNameText"); }
}
///
@@ -224,6 +229,7 @@ namespace SlnMesnac.WPF.ViewModel
public ExecuteViewModel()
{
+ _logger = App.ServiceProvider.GetService>();
_prodPlanInfoService = App.ServiceProvider.GetService();
_prodPlanDetailService = App.ServiceProvider.GetService();
_recordStaffAttendanceService = App.ServiceProvider.GetService();
@@ -246,6 +252,10 @@ namespace SlnMesnac.WPF.ViewModel
//};
//StationList = ConvertStringToList(StationCodes);
//RfidHandleBusniess.stationCode = StationCodes;
+ EmployeeLoginViewModel.TransmitStationNameAction += stationName =>
+ {
+ updateStationName(stationName);
+ };
DeviceCode = configuration.GetSection("AppConfig")["DeviceCode"];
ProcessCode = configuration.GetSection("AppConfig")["ProcessCode"];
HandoverCommand = new RelayCommand(Handover);
@@ -259,6 +269,9 @@ namespace SlnMesnac.WPF.ViewModel
MainWindowViewModel.TransferOrderCodeEvent += HandleOrderCode;
}
+ ///
+ /// 是否有计划正在执行
+ ///
private void havePlanOnDuty()
{
haveInfo = _prodPlanInfoService.GetPlanInfoByConditions("", "", "", "", "1").FirstOrDefault();
@@ -271,6 +284,15 @@ namespace SlnMesnac.WPF.ViewModel
}
}
+ ///
+ /// 更新工位名称
+ ///
+ ///
+ private void updateStationName(string stationName)
+ {
+ StationTextBox = EmployeeLoginViewModel.stationName;
+ }
+
///
/// 换班弹窗
///
@@ -299,6 +321,10 @@ namespace SlnMesnac.WPF.ViewModel
reportWin.ShowDialog();//窗体出现后禁止后面的用户控件
Refresh(pLanInfo);
ShowTeamMember();
+ if (stations >= 3)
+ {
+ _databaseHandleBusniess.UpdateOrderInfoStatus(theOrderCode, "2");
+ }
MainWindowViewModel.wins = 1;
}
else
@@ -364,10 +390,13 @@ namespace SlnMesnac.WPF.ViewModel
///
private void HandleOrderCode(string orderCode)
{
+ theOrderCode = orderCode;
if (isComplete)
{
if (isSearch == 1)
{
+ //更新当前工单状态
+ _databaseHandleBusniess.UpdateOrderInfoStatus(orderCode,"1");
//判断当前工位的工单编号是否存在
var plan = _prodPlanInfoService.GetProdPLanInfoByOrderCode(RfidHandleBusniess.stationCode, orderCode);
if (plan == null)//不存在,就在生产工单表中新增一条当前工位的订单,且执行状态改为4,重新检索,并高亮这条工单,执行按钮可用
@@ -393,10 +422,10 @@ namespace SlnMesnac.WPF.ViewModel
}
Search();
}
- else
- {
- MessageBox.Show("请先检索工单!");
- }
+ //else
+ //{
+ // MessageBox.Show("请先检索工单!");
+ //}
}
else
{
@@ -415,33 +444,40 @@ namespace SlnMesnac.WPF.ViewModel
{
if (isComplete)//判断是否完成,未完成不能执行其他工单
{
- // 将当前记录存为实体,可以通过parameter获取当前记录的信息
- string orderCode = _selectedRow.OrderCode.ToString();
- string planCode = _selectedRow.PlanCode.ToString();
- pLanInfo = _prodPlanInfoService.GetRecordStaffAttendancesByConditions(orderCode, planCode, "", "", "0").First();
- RecordStaffAttendance currentRecord = _recordStaffAttendanceService.GetLastestOnRecord();
- BaseStaffInfo staffInfo = _baseStaffService.GetMonitorByTeamCode(currentRecord.TeamCode);
- RecordStaffAttendance nextRecord = _recordStaffAttendanceService.GetLastestOffRecord();
- // 向detail表里插入一条数据
- ProdPlanDetail prodPlanDetail = new ProdPlanDetail
+ try
{
- PlanCode = pLanInfo.PlanCode,
- MaterialCode = pLanInfo.MaterialCode,
- PlanAmount = pLanInfo.PlanAmount,
- CompleteAmount = pLanInfo.CompleteAmount,
- BeginTime = DateTime.Now.ToString(),
- CurrentStaffId = staffInfo.StaffId
- //NextStaffId = nextRecord.StaffId,
- };
- _prodPlanDetailService.Insert(prodPlanDetail);
- //按钮文字变成执行中并锁定,其他的订单执行按钮也禁用
- pLanInfo.BeginTime = DateTime.Now.ToString();
- pLanInfo.PlanStatus = "1";
- _prodPlanInfoService.Update(pLanInfo);
- Search();
- //查明细表显示出来
- Refresh(pLanInfo);
- isComplete = false;
+ // 将当前记录存为实体,可以通过parameter获取当前记录的信息
+ string orderCode = _selectedRow.OrderCode.ToString();
+ string planCode = _selectedRow.PlanCode.ToString();
+ pLanInfo = _prodPlanInfoService.GetRecordStaffAttendancesByConditions(orderCode, planCode, "", "", "0").First();
+ //RecordStaffAttendance currentRecord = _recordStaffAttendanceService.GetLastestOnRecord();
+ //BaseStaffInfo staffInfo = _baseStaffService.GetMonitorByTeamCode(currentRecord.TeamCode);
+ 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 = staffInfo.StaffId
+ //NextStaffId = nextRecord.StaffId,
+ };
+ _prodPlanDetailService.Insert(prodPlanDetail);
+ //按钮文字变成执行中并锁定,其他的订单执行按钮也禁用
+ //pLanInfo.BeginTime = DateTime.Now.ToString();
+ pLanInfo.PlanStatus = "1";
+ _prodPlanInfoService.Update(pLanInfo);
+ Search();
+ //查明细表显示出来
+ Refresh(pLanInfo);
+ isComplete = false;
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError("执行异常", ex);
+ }
}
else
{
@@ -461,7 +497,7 @@ namespace SlnMesnac.WPF.ViewModel
var planDetail = planDetails.FirstOrDefault();
PlanCodeText = planDetail.PlanCode;
OrderCodeText = pLanInfo.OrderCode;
- MaterialCodeText = planDetail.MaterialCode;
+ MaterialNameText = pLanInfo.MaterialName;
StationCodeText = pLanInfo.StationCode;
System.Windows.Application.Current.Dispatcher.Invoke((Action)(async () =>
{
diff --git a/SlnMesnac.WPF/ViewModel/ProductionReportViewModel.cs b/SlnMesnac.WPF/ViewModel/ProductionReportViewModel.cs
index b9c05c5..1b7cfb4 100644
--- a/SlnMesnac.WPF/ViewModel/ProductionReportViewModel.cs
+++ b/SlnMesnac.WPF/ViewModel/ProductionReportViewModel.cs
@@ -53,7 +53,7 @@ namespace SlnMesnac.WPF.ViewModel
private void Init()
{
- planInfo = _prodPlanInfoService.GetPlanInfoByConditions("", "", "", RfidHandleBusniess.stationCode, "1").FirstOrDefault();
+ planInfo = _prodPlanInfoService.GetRecordStaffAttendancesByConditions("", "", "", RfidHandleBusniess.stationCode, "1").FirstOrDefault();
if (planInfo != null)
{
complateRate = GetComplateRate(Convert.ToDouble(planInfo.CompleteAmount), planInfo.PlanAmount);
@@ -168,7 +168,9 @@ namespace SlnMesnac.WPF.ViewModel
//planDetail = new ProdPlanDetail();
planDetail.CompleteAmount = newAmountDouble.ToString();
planInfo.CompleteAmount = result.ToString();
+ planDetail.BeginTime = ExecuteViewModel.theStartTime;
planDetail.EndTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+ ExecuteViewModel.theStartTime = planDetail.EndTime;
planDetail.BatchNumber += 1;
planInfo.PlanStatus = "4";
//保存工单的执行人员
@@ -221,8 +223,8 @@ namespace SlnMesnac.WPF.ViewModel
//_prodPlanDetailService.Insert(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);
+ double planAmountDouble = Convert.ToDouble(planInfo.PlanAmount);
+ double completeAmountDouble = Convert.ToDouble(planInfo.CompleteAmount);
if (planAmountDouble == completeAmountDouble)
{
planInfo.CompFlag = "0";//正常完成
@@ -236,6 +238,7 @@ namespace SlnMesnac.WPF.ViewModel
planInfo.CompFlag = "2";//超额完成
}
_prodPlanInfoService.Update(planInfo);
+ ExecuteViewModel.stations += 1;
}
//关闭窗口
Application.Current.Windows.OfType().First().Close();
diff --git a/SlnMesnac.WPF/ViewModel/RemoveConfirmViewModel.cs b/SlnMesnac.WPF/ViewModel/RemoveConfirmViewModel.cs
index 0e23c43..df10063 100644
--- a/SlnMesnac.WPF/ViewModel/RemoveConfirmViewModel.cs
+++ b/SlnMesnac.WPF/ViewModel/RemoveConfirmViewModel.cs
@@ -13,6 +13,7 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
+using SlnMesnac.Business.business;
namespace SlnMesnac.WPF.ViewModel
{
@@ -75,6 +76,7 @@ namespace SlnMesnac.WPF.ViewModel
{
HintText = "成功!";
times++;
+ RfidHandleBusniess.staffId = user.StaffId;
}
else
{