diff --git a/shangjian/XGL.Data/DBService/FormingMachineService.cs b/shangjian/XGL.Data/DBService/FormingMachineService.cs index 2d322ef..3c16119 100644 --- a/shangjian/XGL.Data/DBService/FormingMachineService.cs +++ b/shangjian/XGL.Data/DBService/FormingMachineService.cs @@ -66,7 +66,7 @@ namespace XGL.Data.DBService pro_order_workorder ord WITH (NOLOCK) LEFT JOIN base_shifts_t shift WITH (NOLOCK) on ord.shift_id = shift.Shift_Id WHERE - CONVERT(VARCHAR(10), ord.product_date , 120) = CONVERT(VARCHAR(10), '{workDate}', 120 ) + CONVERT(VARCHAR(10), ord.product_date , 120) = CONVERT(VARCHAR(10), '{workDate+ " 0:00:00"}', 120 ) And ord.prod_line_code like '%{devicecode}%' AND ord.del_flag='0'"; DataSet dtset = Utils.netClientDBHelper.getDataSet(sql); if (dtset != null && dtset.Tables.Count > 0 && dtset.Tables[0].Rows.Count > 0) @@ -707,7 +707,7 @@ VALUES if (!selectRow["status"].ToString().Equals("w4")) { //更新订单状态为已报工; - string updateOrderSql = $@"update pro_order_workorder set status = 'w3', update_by = '{LoginUser.UserName}',update_time = GETDATE() where belong_work_order = '{selectRow["workorder_code"]}' "; + string updateOrderSql = $@"update pro_order_workorder set status = 'w3', update_by = '{LoginUser.UserName}',update_time = GETDATE() ,end_work_time =GETDATE() where belong_work_order = '{selectRow["workorder_code"]}' "; sqlList.Add(updateOrderSql); //修改报工逻辑,最终报工时添加子母工单领料单状态更新2024-02-20 @@ -865,12 +865,29 @@ VALUES { // string sql = $@"INSERT INTO [dbo].[mes_changeshift_info] ([id], [shift_code], [change_time], [create_time], [create_by], [last_update], [update_by], [work_date],[device_code]) - VALUES ('{Common.GetUUID()}', '{LoginUser.ShiftCode}', GetDate(), GetDate(), '{LoginUser.UserName}', GetDate(), '{LoginUser.UserName}', '{LoginUser.WorkDate}','{deviceCode}');"; + VALUES ('{Common.GetUUID()}', '{LoginUser.ShiftCode}', GetDate(), GetDate(), '{LoginUser.UserName}',Null, '{LoginUser.UserName}', '{LoginUser.WorkDate}','{deviceCode}');"; int ret = Utils.netClientDBHelper.executeUpdate(sql); return ret > 0 ? true : false; } - - + public bool ChangeShiftsInfo(string deviceCode ,string data,string shift) + { + // + string sql = $@"UPDATE mes_changeshift_info SET last_update=GetDate( ) WHERE device_code='{deviceCode}' AND CONVERT(VARCHAR, create_time, 23) = '{data}' AND shift_code='{shift}';"; + int ret = Utils.netClientDBHelper.executeUpdate(sql); + return ret > 0 ? true : false; + } + public DataTable selectShiftsInfo(string deviceCode, string data, string shift) + { + // + string sql = $@" + SELECT top 1 * FROM mes_changeshift_info WHERE device_code='{deviceCode}' AND work_date = '{data}' AND last_update is NULL AND shift_code='{shift}' ORDER BY create_time DESC"; + DataSet dtset = Utils.netClientDBHelper.getDataSet(sql); + if (dtset != null && dtset.Tables.Count > 0 && dtset.Tables[0].Rows.Count > 0) + { + return dtset.Tables[0]; + } + return null; + } /// /// 插入消耗表 /// diff --git a/shangjian/XGL.Data/DBServiceFinishProd/FinishProdDBService.cs b/shangjian/XGL.Data/DBServiceFinishProd/FinishProdDBService.cs index 09a8a80..30a322d 100644 --- a/shangjian/XGL.Data/DBServiceFinishProd/FinishProdDBService.cs +++ b/shangjian/XGL.Data/DBServiceFinishProd/FinishProdDBService.cs @@ -996,7 +996,7 @@ where detail.parent_work_order = '{processid}'"; //where CONVERT(VARCHAR(10), w /// public bool UpdateSycnFlag(string workOrderID,string deviceCode,string user) { - string sql1 = $@"update pro_order_workorder set status = 'w2',workorder_name = '{deviceCode}', update_by = '{LoginUser.UserName}',attr3='{user}',update_time = GETDATE() where workorder_code = '{workOrderID}' "; + string sql1 = $@"update pro_order_workorder set status = 'w2',workorder_name = '{deviceCode}', update_by = '{LoginUser.UserName}',attr3='{user}',update_time = GETDATE(),start_work_time = GETDATE() where workorder_code = '{workOrderID}' "; return Utils.netClientDBHelper.executeUpdate(sql1) > 0 ? true : false; diff --git a/shangjian/XGL/Views/Classes.xaml b/shangjian/XGL/Views/Classes.xaml new file mode 100644 index 0000000..01357f0 --- /dev/null +++ b/shangjian/XGL/Views/Classes.xaml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + diff --git a/shangjian/XGL/Views/Classes.xaml.cs b/shangjian/XGL/Views/Classes.xaml.cs new file mode 100644 index 0000000..54bd94a --- /dev/null +++ b/shangjian/XGL/Views/Classes.xaml.cs @@ -0,0 +1,145 @@ +using CommonFunc; +using CommonFunc.Tools; +using System; +using System.Collections.Generic; +using System.Data; +using System.Diagnostics; +using System.Globalization; +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; +using XGL.Data.DBService; + +namespace XGL.Views +{ + /// + /// Classes.xaml 的交互逻辑 + /// + public partial class Classes : Window + { + string deviceCode = Utils.GetAppSetting("DeviceCode"); + FormingMachineService formingMachineService = new FormingMachineService(); + DataTable table =new DataTable(); + public Classes() + { + InitializeComponent(); + //if (LoginUser.ShiftCode=="2") + //{ + // var shi = formingMachineService.selectShiftsInfo(deviceCode, ((DateTime.ParseExact(LoginUser.WorkDate, "yyyy-MM-dd", CultureInfo.InvariantCulture)).AddDays(-1)).ToString("yyyy-MM-dd"),"2"); + // if (shi != null && shi.Rows.Count > 0) + // { + // table = shi; + // // 遍历 DataTable 的每一行 + // foreach (DataRow row in shi.Rows) + // { + // // 获取 shift_code 的值 + // var shiftCode = row["shift_code"].ToString(); + + // // 根据 shift_code 的值设置 shift.Content + // if (shiftCode == "5") + // { + // shift.Content = "白班"; + // } + // else if (shiftCode == "2") + // { + // shift.Content = "夜班"; + // } + // } + // } + // else + // { + // shift.Content = "无"; + // } + //} + //else + //{ + // var shi = formingMachineService.selectShiftsInfo1(deviceCode, LoginUser.WorkDate); + // // 检查 DataTable 是否为空 + // if (shi != null && shi.Rows.Count > 0) + // { + // table = shi; + // // 遍历 DataTable 的每一行 + // foreach (DataRow row in shi.Rows) + // { + // // 获取 shift_code 的值 + // var shiftCode = row["shift_code"].ToString(); + + // // 根据 shift_code 的值设置 shift.Content + // if (shiftCode == "5") + // { + // shift.Content = "白班"; + // } + // else if (shiftCode == "2") + // { + // shift.Content = "夜班"; + // } + // } + // } + // else + // { + // shift.Content = "无"; + // // 处理 DataTable 为空的情况 + // Console.WriteLine("未找到班次信息。"); + // } + //} + } + + private void Button_Click(object sender, RoutedEventArgs e) + { + var shi= formingMachineService.selectShiftsInfo(deviceCode, LoginUser.WorkDate, LoginUser.ShiftCode); + if (shi==null) + { + formingMachineService.ChangeShiftsInfo(deviceCode); + CustomMessageBox.Show("开始工作吧~", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Success, 1500); + return; + } + if (shi.Rows.Count>0) + { + CustomMessageBox.Show("检测到有正在上班的班次,请先下班!!!!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning); + } + else + { + formingMachineService.ChangeShiftsInfo(deviceCode); + CustomMessageBox.Show("开始工作吧~", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Success,1500); + } + } + + private void Button_Click_1(object sender, RoutedEventArgs e) + { + if (CustomMessageBox.Show("下班后产量会计入下一班次,您确定要下班吗?", CustomMessageBoxButton.OKCancel, CustomMessageBoxIcon.Warning) == CustomMessageBoxResult.OK) + { + formingMachineService.ChangeShiftsInfo(deviceCode, LoginUser.WorkDate, LoginUser.ShiftCode); + //因为程序多开受限制,先启动一个中间程序,再启动本程序 + //设置要启动的应用程序名称和参数 + string appName = "RestartApp.exe"; // 替换为你的目标控制台应用程序的名称 + string appArguments = System.Diagnostics.Process.GetCurrentProcess().MainModule.ModuleName;//sresu;// 替换为你的应用程序需要的参数 + + // 创建进程启动信息 + ProcessStartInfo startInfo = new ProcessStartInfo + { + FileName = appName, + Arguments = appArguments, + RedirectStandardOutput = false, // 可以选择是否重定向标准输出 + UseShellExecute = false, // 必须设置为false,以便在控制台中启动应用程序 + CreateNoWindow = false // 设置为true,以便在后台启动应用程序 + }; + + // 创建并启动进程 + Process process = new Process + { + StartInfo = startInfo + }; + process.Start(); + Environment.Exit(0); + } + } + } +} diff --git a/shangjian/XGL/Views/LanJu_Operator.xaml b/shangjian/XGL/Views/LanJu_Operator.xaml index 4e52c93..5d2fb86 100644 --- a/shangjian/XGL/Views/LanJu_Operator.xaml +++ b/shangjian/XGL/Views/LanJu_Operator.xaml @@ -33,7 +33,7 @@ + + + + + + + + + + + + + + diff --git a/shangjian/XGL/Views/ProductionData.xaml.cs b/shangjian/XGL/Views/ProductionData.xaml.cs new file mode 100644 index 0000000..e3876f1 --- /dev/null +++ b/shangjian/XGL/Views/ProductionData.xaml.cs @@ -0,0 +1,35 @@ +using CommonFunc; +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; +using XGL.Data.DBService; + +namespace XGL.Views +{ + /// + /// ProductionData.xaml 的交互逻辑 + /// + public partial class ProductionData : Window + { + FormingMachineService formingMachineService = new FormingMachineService(); + public ProductionData() + { + InitializeComponent(); + } + + private void Button_Click(object sender, RoutedEventArgs e) + { + //var shi = formingMachineService.selectShiftsInfo(deviceCode, LoginUser.WorkDate); + } + } +} diff --git a/shangjian/XGL/XGL.csproj b/shangjian/XGL/XGL.csproj index 64f6f10..61adf5c 100644 --- a/shangjian/XGL/XGL.csproj +++ b/shangjian/XGL/XGL.csproj @@ -340,12 +340,18 @@ CheckUserWin.xaml + + Classes.xaml + DryingRoomUC.xaml HBLogWin.xaml + + ProductionData.xaml + ShouPeiWin.xaml @@ -584,6 +590,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -592,6 +602,10 @@ MSBuild:Compile Designer + + Designer + MSBuild:Compile + Designer MSBuild:Compile diff --git a/shangjian/XGLFinishPro/App.config b/shangjian/XGLFinishPro/App.config index 2de7c83..11adb0f 100644 --- a/shangjian/XGLFinishPro/App.config +++ b/shangjian/XGLFinishPro/App.config @@ -10,7 +10,7 @@ - + diff --git a/shangjian/XGLFinishPro/Views/LanJu_Operator.xaml.cs b/shangjian/XGLFinishPro/Views/LanJu_Operator.xaml.cs index 097bb91..0884aa3 100644 --- a/shangjian/XGLFinishPro/Views/LanJu_Operator.xaml.cs +++ b/shangjian/XGLFinishPro/Views/LanJu_Operator.xaml.cs @@ -635,7 +635,21 @@ namespace XGLFinishPro.Views CustomMessageBox.Show("请选择要开始的工单!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning); return; } - + // 创建JsonSerializerSettings实例,并配置其属性来忽略自引用循环 + var settings = new JsonSerializerSettings + { + ReferenceLoopHandling = ReferenceLoopHandling.Ignore, + Formatting = Formatting.Indented + }; + if (dgWorkOrderInfo.SelectedItem is DataRowView selectedRow) + { + string rowContent = string.Join(", ", selectedRow.Row.ItemArray); + LogHelper.instance.log.Info("选择的行内容: " + rowContent); + } + else + { + LogHelper.instance.log.Info("未选择任何行或选择的项不是 DataRowView 类型"); + } string workorderID = (dgWorkOrderInfo.SelectedItem as DataRowView)["workorder_code"].ToString(); string status = (dgWorkOrderInfo.SelectedItem as DataRowView)["status"].ToString(); LogHelper.instance.log.Info("记录工单状态:"+ status +", 工单号为:"+ workorderID); @@ -801,67 +815,59 @@ namespace XGLFinishPro.Views /// private async Task CallCheckApi(string checkType) { - string workorderCode = (dgWorkOrderInfo.SelectedItem as DataRowView)["workorder_code"].ToString(); - string workorderID = (dgWorkOrderInfo.SelectedItem as DataRowView)["workorder_id"].ToString(); - string batchCode = (dgWorkOrderInfo.SelectedItem as DataRowView)["batch_code"].ToString(); - - //调用首件检验接口 - string apiUrl = formingMachineService.GetInterfaceUrl("createCheckProduceTask"); - FirstCheckModel firstCheck = new FirstCheckModel(); - firstCheck.factoryCode = Utils.GetAppSetting("SiteCode"); - string taskName = ""; - if (checkType.Equals("checkTypeSCXJ")) + try { - taskName = "巡检任务"; - firstCheck.incomeBatchNo = null; - } - else - { - taskName = "首件检验任务"; - firstCheck.incomeBatchNo = (dgWorkOrderInfo.SelectedItem as DataRowView)["batch_code"].ToString(); - } + string workorderCode = (dgWorkOrderInfo.SelectedItem as DataRowView)["workorder_code"].ToString(); + string workorderID = (dgWorkOrderInfo.SelectedItem as DataRowView)["workorder_id"].ToString(); + string batchCode = (dgWorkOrderInfo.SelectedItem as DataRowView)["batch_code"].ToString(); - firstCheck.orderNo = workorderCode; - firstCheck.materialName = (dgWorkOrderInfo.SelectedItem as DataRowView)["product_name"].ToString(); - firstCheck.materialCode = (dgWorkOrderInfo.SelectedItem as DataRowView)["product_code"].ToString(); - firstCheck.checkType = checkType;//"checkTypeSC"; - firstCheck.quality = (dgWorkOrderInfo.SelectedItem as DataRowView)["quantity_split"].ToString(); - firstCheck.unit = (dgWorkOrderInfo.SelectedItem as DataRowView)["unit"].ToString(); - //根据线体编码获取车间编码 - DataTable dtCar = userDbWareHouse.GetCarInfo(deviceCode); - string carCode = dtCar.Rows[0][0].ToString(); - string carName = dtCar.Rows[0][1].ToString(); - - firstCheck.carName = carName; - firstCheck.carCode = carCode; - firstCheck.produceDate = (dgWorkOrderInfo.SelectedItem as DataRowView)["plan_time"].ToString(); - firstCheck.checkManName = LoginUser.UserName; - firstCheck.checkManCode = LoginUser.UserCode; - firstCheck.checkLoc = deviceCode; - - // 将要发送的数据序列化为JSON格式 - var jsonContent = JsonConvert.SerializeObject(firstCheck); - LogHelper.instance.log.Info($"开始{taskName}>>" + jsonContent); - RestHelper restClient = new RestHelper(); - //var response =; - - Rootobjectresu result = Utils.DeJson(await restClient.PostAsync(apiUrl, jsonContent)); - - - if (result.code == 200) - { - //巡检 + //调用首件检验接口 + string apiUrl = formingMachineService.GetInterfaceUrl("createCheckProduceTask"); + FirstCheckModel firstCheck = new FirstCheckModel(); + firstCheck.factoryCode = Utils.GetAppSetting("SiteCode"); + string taskName = ""; if (checkType.Equals("checkTypeSCXJ")) { - CustomMessageBox.Show($"{taskName}创建成功", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Success); - LogHelper.instance.log.Info($"{taskName}创建成功>>" + result.msg); - GetWorkOrderInfo(); + taskName = "巡检任务"; + firstCheck.incomeBatchNo = null; } else { - //调用首件检验 - bool isSuccess = formingMachineService.UpdateFirstCheckTask(workorderID, batchCode); - if (isSuccess) + taskName = "首件检验任务"; + firstCheck.incomeBatchNo = (dgWorkOrderInfo.SelectedItem as DataRowView)["batch_code"].ToString(); + } + + firstCheck.orderNo = workorderCode; + firstCheck.materialName = (dgWorkOrderInfo.SelectedItem as DataRowView)["product_name"].ToString(); + firstCheck.materialCode = (dgWorkOrderInfo.SelectedItem as DataRowView)["product_code"].ToString(); + firstCheck.checkType = checkType;//"checkTypeSC"; + firstCheck.quality = (dgWorkOrderInfo.SelectedItem as DataRowView)["quantity_split"].ToString(); + firstCheck.unit = (dgWorkOrderInfo.SelectedItem as DataRowView)["unit"].ToString(); + //根据线体编码获取车间编码 + DataTable dtCar = userDbWareHouse.GetCarInfo(deviceCode); + string carCode = dtCar.Rows[0][0].ToString(); + string carName = dtCar.Rows[0][1].ToString(); + + firstCheck.carName = carName; + firstCheck.carCode = carCode; + firstCheck.produceDate = (dgWorkOrderInfo.SelectedItem as DataRowView)["plan_time"].ToString(); + firstCheck.checkManName = LoginUser.UserName; + firstCheck.checkManCode = LoginUser.UserCode; + firstCheck.checkLoc = deviceCode; + + // 将要发送的数据序列化为JSON格式 + var jsonContent = JsonConvert.SerializeObject(firstCheck); + LogHelper.instance.log.Info($"开始{taskName}>>" + jsonContent); + RestHelper restClient = new RestHelper(); + //var response =; + + Rootobjectresu result = Utils.DeJson(await restClient.PostAsync(apiUrl, jsonContent)); + + + if (result.code == 200) + { + //巡检 + if (checkType.Equals("checkTypeSCXJ")) { CustomMessageBox.Show($"{taskName}创建成功", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Success); LogHelper.instance.log.Info($"{taskName}创建成功>>" + result.msg); @@ -869,17 +875,34 @@ namespace XGLFinishPro.Views } else { - CustomMessageBox.Show($"更新{taskName}状态失败", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning); - LogHelper.instance.log.Info($"更新{taskName}状态失败>>" + result.msg); + //调用首件检验 + bool isSuccess = formingMachineService.UpdateFirstCheckTask(workorderID, batchCode); + if (isSuccess) + { + CustomMessageBox.Show($"{taskName}创建成功", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Success); + LogHelper.instance.log.Info($"{taskName}创建成功>>" + result.msg); + GetWorkOrderInfo(); + } + else + { + CustomMessageBox.Show($"更新{taskName}状态失败", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning); + LogHelper.instance.log.Info($"更新{taskName}状态失败>>" + result.msg); + } } - } + } + else + { + LogHelper.instance.log.Info($"{taskName}失败>>" + result.msg); + CustomMessageBox.Show($"调用{taskName}接口失败:" + result.msg, CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning); + } } - else + catch (Exception ex) { - LogHelper.instance.log.Info($"{taskName}失败>>" + result.msg); - CustomMessageBox.Show($"调用{taskName}接口失败:" + result.msg, CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning); + LogHelper.instance.log.Error("首检检验接口发生异常>>" + ex.Message); + CustomMessageBox.Show("首检检验接口发生异常:" + ex.Message, CustomMessageBoxButton.OK, CustomMessageBoxIcon.Error); } + } private void btnMachineRepair_Click(object sender, RoutedEventArgs e) diff --git a/shangjian/XGLFinishPro/Views/PieceSalaryCalWin.xaml.cs b/shangjian/XGLFinishPro/Views/PieceSalaryCalWin.xaml.cs index 8e0e48d..fa1fcf9 100644 --- a/shangjian/XGLFinishPro/Views/PieceSalaryCalWin.xaml.cs +++ b/shangjian/XGLFinishPro/Views/PieceSalaryCalWin.xaml.cs @@ -106,19 +106,19 @@ namespace XGLFinishPro.Views OnWorkUserList.ForEach(t => t.IsChecked = false); dataSource = OnWorkUserList;// Utils.userList; List usernumbers = new List< sys_user >(); - if (dataSource.Count!=0) - { - string num= prodDBService.GetUsernumbereData(_workOrderCode); - foreach (var item in dataSource) - { - sys_user usernumber = new sys_user(); - usernumber.user_name = item.user_name; - usernumber.nick_name = item.nick_name; - usernumber.number =Convert.ToInt32(num).ToString(); - usernumbers.Add(usernumber); - } - } - this.dgUserInfo.ItemsSource = usernumbers; + // if (dataSource.Count!=0) + //{ + // string num= prodDBService.GetUsernumbereData(_workOrderCode); + // foreach (var item in dataSource) + // { + // sys_user usernumber = new sys_user(); + // usernumber.user_name = item.user_name; + // usernumber.nick_name = item.nick_name; + // usernumber.number =Convert.ToInt32(num).ToString(); + // usernumbers.Add(usernumber); + // } + //} + this.dgUserInfo.ItemsSource = dataSource; } private void dgUserInfo_SelectionChanged(object sender, SelectionChangedEventArgs e) @@ -414,17 +414,29 @@ namespace XGLFinishPro.Views CreateUnitPriceSqlList.Add(delSql); //prodDBService.DelUnitPriceData(_workOrderCode, _childprocessCode, _deviceCode); } - + string name = ""; string sapCode = _deviceCode;//ds.Tables[0].Rows[0][0].ToString(); foreach (sys_user item in checkedRowsCache) { - if (item.number.IsNullOrEmpty()) + if (item.number.IsNullOrEmpty()||item.number=="0") { - item.number = "0"; + if (name.IsNullOrEmpty()) + { + name = item.nick_name; + } + else + { + name = name + "," + item.nick_name; + } } string sql = prodDBService.GetCreateUnitPriceInfo(item, _workOrderCode, _sapWorkOrderCode, _productCode, _productName, _childprocessCode, _childprocessName, sapCode, item.number,LoginUser.WorkDate); CreateUnitPriceSqlList.Add(sql); } + if (!name.IsNullOrEmpty()) + { + CustomMessageBox.Show($"当前选择的人员[{name}]报工总数为空或者为0,请填写数量后再提交!!!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning); + return; + } //之前如果已经插入了,先删除, //暂时不更新工单状态