榄菊上位机更改

master
zhaojian 2 years ago
parent 1db6c5c627
commit 5870e51dcc

@ -13,6 +13,7 @@ using MySql.Data.MySqlClient;
using CommonFunc.Tools;
using XGL.Models.Model;
using XGL.Models;
using XGL.Models.Model.OrderPrepare;
namespace XGL.Dats.DBServiceFinishProd
{
@ -663,11 +664,11 @@ where 1=1 and
/// <param name="deviceCode"></param>
/// <param name="date"></param>
/// <returns></returns>
public DataTable GetUnitPriceData(string deviceCode)
public DataTable GetUnitPriceData(string deviceCode ,string sheredata)
{
string sql = $@"select [workorder_code], [workorder_code_sap], [product_name], SUBSTRING([product_code], 8, LEN(product_code)) as product_code, [user_name], [nick_name], [childprocess_code], [childprocess_name] ,[create_by], [create_time], [line_code] ,[attr1]
from mes_unitprice_report
where line_code = '{deviceCode}' and CONVERT(VARCHAR(10), Create_time , 120) = CONVERT(VARCHAR(10),GETDATE(), 120) ORDER BY childprocess_code,create_time";
where line_code = '{deviceCode}' AND create_time BETWEEN '{sheredata} 00:00:00' AND '{sheredata} 23:59:59' ORDER BY childprocess_code,create_time";
DataSet dtset = Utils.netClientDBHelper.getDataSet(sql);
if (dtset != null && dtset.Tables.Count > 0 && dtset.Tables[0].Rows.Count > 0)
@ -680,8 +681,10 @@ where line_code = '{deviceCode}' and CONVERT(VARCHAR(10), Create_time , 120) = C
public string GetUsernumbereData(string deviceCode)
{
string sql = $@"SELECT SUM(quantity_feedback) as total_quantity FROM mes_report_work WHERE workorder_code='{deviceCode}'";
string sql = $@"SELECT COALESCE(CAST(SUM(quantity_feedback) / SUM(use_man) AS INT), 0) as total_quantity
FROM mes_report_work
WHERE parent_order = '{deviceCode}' and del_flag='0';
";
DataSet dtset = Utils.netClientDBHelper.getDataSet(sql);
if (dtset != null && dtset.Tables.Count > 0 && dtset.Tables[0].Rows.Count > 0)
{
@ -717,7 +720,7 @@ where line_code = '{deviceCode}' and CONVERT(VARCHAR(10), Create_time , 120) = C
/// </summary>
/// <param name="item"></param>
/// <exception cref="NotImplementedException"></exception>
public string GetCreateUnitPriceInfo(sys_user item,string workorderCode, string sapWorkorderCode,string productCode,string productName,string childProcessCode,string childProcessName,string deviceCode,string number)
public string GetCreateUnitPriceInfo(sys_user item,string workorderCode, string sapWorkorderCode,string productCode,string productName,string childProcessCode,string childProcessName,string deviceCode,string number,string credata)
{
string sql = $@"INSERT INTO [dbo].[mes_unitprice_report] (
[id],[workorder_code], [workorder_code_sap], [product_name], [product_code],
@ -729,7 +732,7 @@ where line_code = '{deviceCode}' and CONVERT(VARCHAR(10), Create_time , 120) = C
(
'{Common.GetUUID()}', '{workorderCode}','{sapWorkorderCode}', '{productName}', '{productCode}',
N'{item.user_name}', N'{item.nick_name}', N'{childProcessCode}', N'{childProcessName}',' {number}',
NULL, NULL, '{LoginUser.UserName}', getdate(), NULL,
NULL, NULL, '{LoginUser.UserName}', '{credata} 00:00:00', NULL,
NULL, NULL,'{deviceCode}' );";
return sql;
@ -748,9 +751,9 @@ where line_code = '{deviceCode}' and CONVERT(VARCHAR(10), Create_time , 120) = C
return null;
}
public List<sys_user> GetOnWorkUserList(string deviceCode)
public List<sys_user> GetOnWorkUserList(string deviceCode,string shereDate)
{
string sql = $"SELECT user_id as user_name,user_name as nick_name,sex,age FROM [dbo].[mes_attendance_records] where start_addr = '{deviceCode}' and CONVERT(VARCHAR(10), create_time , 120) = CONVERT(VARCHAR(10), GETDATE() , 120) order by create_time desc ;";
string sql = $"WITH RankedRecords AS (\r\n SELECT \r\n user_id as user_name,\r\n user_name as nick_name,\r\n sex,\r\n age,\r\n create_time,\r\n ROW_NUMBER() OVER (PARTITION BY user_name ORDER BY create_time DESC) as rn\r\n FROM [dbo].[mes_attendance_records]\r\n WHERE start_addr = '{deviceCode}' \r\n AND create_time BETWEEN '{shereDate} 00:00:00' AND '{shereDate} 23:59:59'\r\n)\r\nSELECT \r\n user_name,\r\n nick_name,\r\n sex,\r\n age,\r\n create_time\r\nFROM RankedRecords\r\nWHERE rn = 1\r\nORDER BY create_time DESC;";
DataTable dt = Utils.netClientDBHelper.getDataSet(sql).Tables[0];
@ -991,9 +994,9 @@ where detail.parent_work_order = '{processid}'"; //where CONVERT(VARCHAR(10), w
/// 更新湿料计划同步状态、工单状态
/// </summary>
/// <returns></returns>
public bool UpdateSycnFlag(string workOrderID,string deviceCode)
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}',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() where workorder_code = '{workOrderID}' ";
return Utils.netClientDBHelper.executeUpdate(sql1) > 0 ? true : false;
@ -3498,39 +3501,8 @@ left join basedata_plcsetting f on a.PlcId5=f.Id
return null;
}
public void InsertCheckTaskDetail(string value,string where)
public int InsertCheckTaskDetail(string value,string where)
{
//StringBuilder strSql = new StringBuilder();
//strSql.Append("UPDATE qc_check_task_detail ");
//strSql.Append("SET actual_value =");
//if (value == null)
//StringBuilder strSql = new StringBuilder();
//strSql.Append("UPDATE qc_check_task_detail ");
//strSql.Append("SET actual_value =");
//if (value==null)
//{
// strSql.Append("NULL");
//}
//else
//{
// strSql.Append($"'{value}'");
//}
//strSql.Append(" WHERE record_id =");
//strSql.Append($"'{where}'");
//Utils.netClientDBHelper.executeUpdate(strSql.ToString());
//strSql.Append(" WHERE record_id =");
//strSql.Append($"'{where}'");
//int rowsAffected = Utils.netClientDBHelper.executeUpdate(strSql.ToString());
StringBuilder strSql = new StringBuilder();
strSql.Append("UPDATE qc_check_task_detail ");
strSql.Append("SET actual_value =");
@ -3545,8 +3517,8 @@ left join basedata_plcsetting f on a.PlcId5=f.Id
strSql.Append(" WHERE record_id =");
strSql.Append($"'{where}'");
Utils.netClientDBHelper.executeUpdate(strSql.ToString());
int result= Utils.netClientDBHelper.executeUpdate(strSql.ToString());
return result;
}
// /// <summary>

@ -10,7 +10,7 @@
<!--车间编码-->
<add key="SiteCode" value="1000" />
<!--设备编码-->
<add key="DeviceCode" value="XL03" />
<add key="DeviceCode" value="XL10" />
<!--上位机类型 0:工单准备1成型机\shoupei2烘房,3:人员登录,4:称重系统-->
<add key="ClientMode" value="1" />

@ -3,7 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:local="clr-namespace:XGLFinishPro.Views"
xmlns:convert="clr-namespace:XGLFinishPro.Tools"
mc:Ignorable="d"

@ -382,62 +382,62 @@ namespace XGLFinishPro.Views
//createCheckProductTask createCheckProductTask = new createCheckProductTask();
//createCheckProductTask.checkLoc = deviceCode;
//createCheckProductTask.factoryCode = Utils.GetAppSetting("SiteCode");
//if (comboBoxBatch.SelectedIndex != 0)
//{
// try
// {
// var getorder = formingMachineService.Getorderworkorder(lbCurrOrderNo.Content.ToString());
// var eqment = formingMachineService.GetWorkShop(Utils.GetAppSetting("DeviceCode"));
// createCheckProductTask createCheckProductTask = new createCheckProductTask();
// createCheckProductTask.factoryCode = Utils.GetAppSetting("SiteCode");//工厂编码
// createCheckProductTask.incomeBatchNo = comboBoxBatch.Text.ToString();//批次号
// createCheckProductTask.orderNo = lbCurrOrderNo.Content.ToString();//订单号
// if (getorder != null && getorder.Rows.Count > 0)
// {
// createCheckProductTask.materialCode = getorder.Rows[0]["product_code"].ToString(); ;//物料编码
// createCheckProductTask.materialName = getorder.Rows[0]["product_name"].ToString();//物料名称
// createCheckProductTask.unit = getorder.Rows[0]["unit"].ToString();//单位,(字典表)
// }
// createCheckProductTask.checkType = "checkTypeCPPC";//批次成品检验固定值
// createCheckProductTask.typeCode = "product";//product
// createCheckProductTask.quality = txtQuantity.Text;//数量
if (comboBoxBatch.SelectedIndex != 0)
{
try
{
var getorder = formingMachineService.Getorderworkorder(lbCurrOrderNo.Content.ToString());
var eqment = formingMachineService.GetWorkShop(Utils.GetAppSetting("DeviceCode"));
createCheckProductTask createCheckProductTask = new createCheckProductTask();
createCheckProductTask.factoryCode = Utils.GetAppSetting("SiteCode");//工厂编码
createCheckProductTask.incomeBatchNo = comboBoxBatch.Text.ToString();//批次号
createCheckProductTask.orderNo = lbCurrOrderNo.Content.ToString();//订单号
if (getorder != null && getorder.Rows.Count > 0)
{
createCheckProductTask.materialCode = getorder.Rows[0]["product_code"].ToString(); ;//物料编码
createCheckProductTask.materialName = getorder.Rows[0]["product_name"].ToString();//物料名称
createCheckProductTask.unit = getorder.Rows[0]["unit"].ToString();//单位,(字典表)
}
createCheckProductTask.checkType = "checkTypeCPPC";//批次成品检验固定值
createCheckProductTask.typeCode = "product";//product
createCheckProductTask.quality = txtQuantity.Text;//数量
// if (eqment != null && eqment.Rows.Count > 0)
// {
// createCheckProductTask.carName = eqment.Rows[0]["workshop_name"].ToString();//车间名称
// createCheckProductTask.carName = eqment.Rows[0]["workshop_code"].ToString();//车间编码
// }
// createCheckProductTask.produceDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");//生产时间格式yyyy-MM-dd HH:mm:ss
// createCheckProductTask.checkLoc = Utils.GetAppSetting("DeviceCode");//检测地点
// // 接口地址
// string apiUrl = formingMachineService.InterfaceUrl("BatcInspection");
// // 将请求参数序列化为 JSON 格式
// string requestBodyJson = Newtonsoft.Json.JsonConvert.SerializeObject(createCheckProductTask);
// // 发送 HTTP POST 请求
// using (var httpClient = new HttpClient())
// {
// var content = new StringContent(requestBodyJson, Encoding.UTF8, "application/json");
// var response = httpClient.PostAsync(apiUrl, content).Result; // 或者 .Wait();
if (eqment != null && eqment.Rows.Count > 0)
{
createCheckProductTask.carName = eqment.Rows[0]["workshop_name"].ToString();//车间名称
createCheckProductTask.carName = eqment.Rows[0]["workshop_code"].ToString();//车间编码
}
createCheckProductTask.produceDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");//生产时间格式yyyy-MM-dd HH:mm:ss
createCheckProductTask.checkLoc = Utils.GetAppSetting("DeviceCode");//检测地点
// 接口地址
string apiUrl = formingMachineService.InterfaceUrl("BatcInspection");
// 将请求参数序列化为 JSON 格式
string requestBodyJson = Newtonsoft.Json.JsonConvert.SerializeObject(createCheckProductTask);
// 发送 HTTP POST 请求
using (var httpClient = new HttpClient())
{
var content = new StringContent(requestBodyJson, Encoding.UTF8, "application/json");
var response = httpClient.PostAsync(apiUrl, content).Result; // 或者 .Wait();
// // 判断响应状态码是否为成功
// if (response.IsSuccessStatusCode)
// {
// // 获取响应内容
// string responseBody = response.Content.ReadAsStringAsync().Result; // 或者 .Wait();
// }
// else
// {
// // 输出失败信息
// CustomMessageBox.Show("批次成品入库检验任务创建接口调用失败!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning, 3000);
// }
// }
// }
// catch (Exception ex)
// {
// LogHelper.instance.log.Error("批次成品入库检验任务创建接口调用失败>>" + ex.Message);
// CustomMessageBox.Show("批次成品入库检验任务创建接口调用失败:" + ex.Message, CustomMessageBoxButton.OK, CustomMessageBoxIcon.Error);
// }
//}
// 判断响应状态码是否为成功
if (response.IsSuccessStatusCode)
{
// 获取响应内容
string responseBody = response.Content.ReadAsStringAsync().Result; // 或者 .Wait();
}
else
{
// 输出失败信息
CustomMessageBox.Show("批次成品入库检验任务创建接口调用失败!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning, 3000);
}
}
}
catch (Exception ex)
{
LogHelper.instance.log.Error("批次成品入库检验任务创建接口调用失败>>" + ex.Message);
CustomMessageBox.Show("批次成品入库检验任务创建接口调用失败:" + ex.Message, CustomMessageBoxButton.OK, CustomMessageBoxIcon.Error);
}
}
//if (result.code == 200)
//{
return AddConsumInfo(reportWorkSqlList, newReportCode);

@ -539,12 +539,12 @@ Background="#F2F3F5"
<DataGridTextColumn Width="250" Header="产品编码" Binding="{Binding product_code}" />
<DataGridTextColumn Width="200" Header="工单/SFC" Binding="{Binding workorder_code}" />
<DataGridTextColumn Width="180" Header="工单code" Visibility="Hidden" Binding="{Binding workorder_id}" />
<DataGridTextColumn Width="180" Header="工单code" Visibility="Hidden" Binding="{Binding workorder_id}" />
<DataGridTextColumn Width="100" Header="生产顺序" Binding="{Binding sort_no}" />
<DataGridTextColumn Width="250" Header="计划时间" Binding="{Binding plan_time, StringFormat={}{0:yyyy-MM-dd HH:mm:ss}}" />
<DataGridTextColumn Width="250" Header="单位" Binding="{Binding unit}" />
<!--<DataGridTextColumn Width="200" Header="创建批次成品检验时间" Binding="{Binding create_time}" />
<DataGridTextColumn Width="200" Header="批次成品检验结果" Binding="{Binding check_status}" />-->
<DataGridTextColumn Width="200" Header="创建批次成品检验时间" Binding="{Binding create_time}" />
<DataGridTextColumn Width="200" Header="批次成品检验结果" Binding="{Binding check_status}" />
<!--<DataGridTextColumn Width="340" Header="流转码" Binding="{Binding work_batch_code}" />-->
<!--<DataGridTextColumn Width="60" Header="出入" Binding="{Binding taskcode,Converter={StaticResource TaskCodeConverter}}"/>-->

@ -1,5 +1,6 @@
using CommonFunc;
using CommonFunc.Tools;
using HandyControl.Tools.Extension;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
@ -42,7 +43,6 @@ namespace XGLFinishPro.Views
{
InitializeComponent();
WindowChange(WindowID.frame);
}
@ -186,33 +186,32 @@ namespace XGLFinishPro.Views
DataTable dt = userDbWareHouse.GetWetPlanInfo(deviceCode, LoginUser.WorkDate);//formingMachineService.GetFormingMachineInfo(deviceCode, currShiftDate.ToString());
if (dt == null) return;
//if (dt != null && dt.Rows.Count > 0)
//{
// foreach (DataRow row in dt.Rows)
// {
// // 获取当前行的 check_status 字段的值
// string checkStatus = row["check_status"] as string;
if (dt != null && dt.Rows.Count > 0)
{
foreach (DataRow row in dt.Rows)
{
// 获取当前行的 check_status 字段的值
string checkStatus = row["check_status"] as string;
// // 根据不同的情况修改值
// if (checkStatus == "Y")
// {
// row["check_status"] = "合格";
// }
// else if (checkStatus == "N")
// {
// row["check_status"] = "不合格";
// }
// else if (string.IsNullOrEmpty(checkStatus))
// {
// row["check_status"] = "无";
// }
// // 如果还有其他情况需要处理,可以继续添加 elseif 分支
// // 更新当前行的值
// dt.AcceptChanges();
// }
//}
// 根据不同的情况修改值
if (checkStatus == "Y")
{
row["check_status"] = "合格";
}
else if (checkStatus == "N")
{
row["check_status"] = "不合格";
}
else if (string.IsNullOrEmpty(checkStatus))
{
row["check_status"] = "无";
}
// 如果还有其他情况需要处理,可以继续添加 elseif 分支
// 更新当前行的值
dt.AcceptChanges();
}
}
if (orderList != null)
{
//使用Dispatcher来在UI线程上更新UI
@ -310,32 +309,32 @@ namespace XGLFinishPro.Views
DataTable dt = userDbWareHouse.GetWetPlanInfo(deviceCode, LoginUser.WorkDate);
if (dt == null) return;
//if (dt != null && dt.Rows.Count > 0)
//{
// foreach (DataRow row in dt.Rows)
// {
// // 获取当前行的 check_status 字段的值
// string checkStatus = row["check_status"] as string;
if (dt != null && dt.Rows.Count > 0)
{
foreach (DataRow row in dt.Rows)
{
// 获取当前行的 check_status 字段的值
string checkStatus = row["check_status"] as string;
// // 根据不同的情况修改值
// if (checkStatus == "Y")
// {
// row["check_status"] = "合格";
// }
// else if (checkStatus == "N")
// {
// row["check_status"] = "不合格";
// }
// else if (string.IsNullOrEmpty(checkStatus))
// {
// row["check_status"] = "无";
// }
// // 如果还有其他情况需要处理,可以继续添加 elseif 分支
// 根据不同的情况修改值
if (checkStatus == "Y")
{
row["check_status"] = "合格";
}
else if (checkStatus == "N")
{
row["check_status"] = "不合格";
}
else if (string.IsNullOrEmpty(checkStatus))
{
row["check_status"] = "无";
}
// 如果还有其他情况需要处理,可以继续添加 elseif 分支
// // 更新当前行的值
// dt.AcceptChanges();
// }
//}
// 更新当前行的值
dt.AcceptChanges();
}
}
if (dt == null) return;
this.dgWorkOrderInfo.ItemsSource = null;
@ -621,57 +620,64 @@ namespace XGLFinishPro.Views
private async void btnPause1_Click(object sender, RoutedEventArgs e)
{
//陈恒杰在2024-01-07日与榄菊的苏振华确认不需要用户验证
//CheckUserWin checkUserWin = new CheckUserWin();
//checkUserWin.ShowDialog();
//if (!checkUserWin.loginFlag)
//{
// CustomMessageBox.Show("请先校验用户!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);
// return;
//}
if (dgWorkOrderInfo.SelectedItems.Count == 0)
try
{
CustomMessageBox.Show("请选择要开始的工单!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);
return;
}
string workorderID = (dgWorkOrderInfo.SelectedItem as DataRowView)["workorder_code"].ToString();
string status = (dgWorkOrderInfo.SelectedItem as DataRowView)["status"].ToString();
if (!status.Equals("w1"))
{
if (status != "")
//陈恒杰在2024-01-07日与榄菊的苏振华确认不需要用户验证
//CheckUserWin checkUserWin = new CheckUserWin();
//checkUserWin.ShowDialog();
//if (!checkUserWin.loginFlag)
//{
// CustomMessageBox.Show("请先校验用户!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);
// return;
//}
if (dgWorkOrderInfo.SelectedItems.Count == 0)
{
string st = status.Equals("w1") ? "未派发" : status.Equals("w3") ? "已报工" : status.Equals("w0") ? "未派发" : "已暂停";
CustomMessageBox.Show("该工单不符合条件,请检查工单状态,当前工单状态为:" + st, CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);
CustomMessageBox.Show("请选择要开始的工单!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);
return;
}
string workorderID = (dgWorkOrderInfo.SelectedItem as DataRowView)["workorder_code"].ToString();
string status = (dgWorkOrderInfo.SelectedItem as DataRowView)["status"].ToString();
LogHelper.instance.log.Info("记录工单状态:"+ status +", 工单号为:"+ workorderID);
if (!status.Equals("w1"))
{
if (status != "")
{
string st = status.Equals("w1") ? "未派发" : status.Equals("w3") ? "已报工" : status.Equals("w0") ? "未派发" : "已暂停";
CustomMessageBox.Show("该工单不符合条件,请检查工单状态,当前工单状态为:" + st, CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);
return;
}
}
CustomMessageBoxResult result = CustomMessageBox.Show("你确定要开始工单么?", CustomMessageBoxButton.OKCancel, CustomMessageBoxIcon.Warning);
if (result == CustomMessageBoxResult.Cancel)
return;
//2024-04-23赵啸林要求添加一条产线同一天只能有一个活动状态下的工单如果有未报工的则不允许开始新的工单
int orderCount = GetActivedOrdersCount(this.deviceCode, LoginUser.WorkDate);
if (orderCount >= 1)
{
CustomMessageBox.Show("已有活动中的工单,请先报工再开始下一个工单!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);
return;
}
//更新工单状态
if (!UpdateOrderStatus(workorderID))
{
CustomMessageBox.Show("开始工单失败!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);
}
else
{
//巡检
string materialCode = (dgWorkOrderInfo.SelectedItem as DataRowView)["product_code"].ToString();
string materialDesc = (dgWorkOrderInfo.SelectedItem as DataRowView)["product_name"].ToString();
userDbWareHouse.InsertOperationLog(workorderID, "w2", "", "开始工单", deviceCode, materialCode, materialDesc);
// await CallCheckApi("checkTypeSCXJ");20240403赵啸林因为切线方案调整要求取消上位机生成巡检任务的功能
TimerDeciveState_Elapsed(null, null);
}
}
CustomMessageBoxResult result = CustomMessageBox.Show("你确定要开始工单么?", CustomMessageBoxButton.OKCancel, CustomMessageBoxIcon.Warning);
if (result == CustomMessageBoxResult.Cancel)
return;
//2024-04-23赵啸林要求添加一条产线同一天只能有一个活动状态下的工单如果有未报工的则不允许开始新的工单
int orderCount = GetActivedOrdersCount(this.deviceCode, LoginUser.WorkDate);
if (orderCount >= 1)
catch (Exception ex)
{
CustomMessageBox.Show("已有活动中的工单,请先报工再开始下一个工单!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);
return;
}
//更新工单状态
if (!UpdateOrderStatus(workorderID))
{
CustomMessageBox.Show("开始工单失败!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);
}
else
{
//巡检
string materialCode = (dgWorkOrderInfo.SelectedItem as DataRowView)["product_code"].ToString();
string materialDesc = (dgWorkOrderInfo.SelectedItem as DataRowView)["product_name"].ToString();
userDbWareHouse.InsertOperationLog(workorderID, "w2", "", "开始工单", deviceCode, materialCode, materialDesc);
// await CallCheckApi("checkTypeSCXJ");20240403赵啸林因为切线方案调整要求取消上位机生成巡检任务的功能
TimerDeciveState_Elapsed(null, null);
LogHelper.instance.log.Error("开始工单异常:" + ex.Message);
}
}
private int GetActivedOrdersCount(string deviceCode, string workDate)
@ -685,8 +691,13 @@ namespace XGLFinishPro.Views
private bool UpdateOrderStatus(string workorderID)
{
string name = LoginUser.UserName +"-"+ LoginUser.UserId;
if (name.IsNullOrEmpty())
{
name = "无-0";
}
//更新工单状态
var updatestatus = userDbWareHouse.UpdateSycnFlag(workorderID, deviceCode);
var updatestatus = userDbWareHouse.UpdateSycnFlag(workorderID, deviceCode, name);
if (!updatestatus)
{
CustomMessageBox.Show("开始工单失败!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);

@ -1,6 +1,7 @@
using CentralControl.BaseData;
using CommonFunc;
using CommonFunc.Tools;
using HandyControl.Tools.Extension;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
@ -414,8 +415,13 @@ namespace XGLFinishPro.Views
private bool UpdateOrderStatus(string workorderID)
{
string name = LoginUser.UserName + "-" + LoginUser.UserCode;
if (name.IsNullOrEmpty())
{
name = "无-0";
}
//更新工单状态
var updatestatus = userDbWareHouse.UpdateSycnFlag(workorderID, deviceCode);
var updatestatus = userDbWareHouse.UpdateSycnFlag(workorderID, deviceCode, name);
if (!updatestatus)
{
CustomMessageBox.Show("开始工单失败!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);

@ -325,8 +325,9 @@
<TextBlock Text="请输入用户名或者ID" VerticalAlignment="Center"/>
<TextBox x:Name="txtP" Width="120" Height="30" FontSize="18" VerticalAlignment="Center" VerticalContentAlignment="Center" TextChanged="txtP_TextChanged"/>
<Button x:Name="btnQueryUser" Content="查询" FontWeight="Bold" Width="100" Height="40" Style="{StaticResource btnKey}" Click="btnQueryUser_Click" Visibility="Collapsed"/>
<Button x:Name="btnUserConfirm" Content="确认" FontWeight="Bold" Width="100" Height="40" Style="{StaticResource btnKey}" Click="btnUserConfirm_Click"/>
<Button x:Name="btnUserConfirm" Content="确认" FontWeight="Bold" Width="100" Height="40" Style="{StaticResource btnKey}" Click="btnUserConfirm_Click"/>
<Button x:Name="btnCloseWin" Content="关闭" FontWeight="Bold" Width="100" Height="40" Style="{StaticResource btnKey}" Click="btnCloseWin_Click"/>
<CheckBox Content="为所有用户更改" x:Name="alluser" Margin="10,25,0,0"></CheckBox>
</StackPanel>
<DataGrid
@ -345,7 +346,8 @@
HeadersVisibility="Column"
HorizontalAlignment="Left"
VerticalAlignment="Top" VerticalContentAlignment="Center"
AutoGenerateColumns="False" CanUserAddRows="False" SelectionMode="Extended" SelectionUnit="FullRow" SelectionChanged="dgUserInfo_SelectionChanged">
AutoGenerateColumns="False" CanUserAddRows="False" SelectionMode="Extended" SelectionUnit="FullRow" SelectionChanged="dgUserInfo_SelectionChanged"
CellEditEnding="dgUserInfo_CellEditEnding">
<DataGrid.ColumnHeaderStyle >
<Style TargetType="DataGridColumnHeader">
<Setter Property="HorizontalContentAlignment" Value="Center" />

@ -114,7 +114,7 @@ namespace XGLFinishPro.Views
sys_user usernumber = new sys_user();
usernumber.user_name = item.user_name;
usernumber.nick_name = item.nick_name;
usernumber.number = num;
usernumber.number =Convert.ToInt32(num).ToString();
usernumbers.Add(usernumber);
}
}
@ -188,7 +188,7 @@ namespace XGLFinishPro.Views
private void GetUserData()
{
OnWorkUserList = prodDBService.GetOnWorkUserList(_LineCode);
OnWorkUserList = prodDBService.GetOnWorkUserList(_LineCode,LoginUser.WorkDate);
if (OnWorkUserList == null || OnWorkUserList.Count <= 0)
{
CustomMessageBox.Show("没有找到上班的人员信息!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);
@ -198,7 +198,7 @@ namespace XGLFinishPro.Views
private void GetData()
{
DataTable dt = prodDBService.GetUnitPriceData(_deviceCode);
DataTable dt = prodDBService.GetUnitPriceData(_deviceCode ,LoginUser.WorkDate);
if (dt == null)
{
this.dgCreatedUserInfo.ItemsSource = null;
@ -261,29 +261,83 @@ namespace XGLFinishPro.Views
}
}
/// <summary>
/// 全选/取消全选
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void cb_all_Click(object sender, RoutedEventArgs e)
{
CheckBox cb = sender as CheckBox;
bool isChecked = cb.IsChecked == true;
foreach (var item in dgUserInfo.Items)
foreach (var item in dgUserInfo.Items)
{
sys_user curRow = item as sys_user;
curRow.IsChecked = isChecked;
if (isChecked)
{
sys_user curRow = item as sys_user;
curRow.IsChecked = isChecked;
if (isChecked)
if (!checkedRowsCache.Contains(curRow))
{
checkedRowsCache.Add(curRow);
}
else
}
else
{
if (checkedRowsCache.Contains(curRow))
{
checkedRowsCache.Remove(curRow);
}
}
}
dgUserInfo.Items.Refresh();
}
private void dgUserInfo_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
{
if (alluser.IsChecked == true)
{
DataGrid dataGrid = sender as DataGrid;
if (e.EditAction == DataGridEditAction.Commit)
{
var editedElement = e.EditingElement as TextBox;
if (editedElement != null)
{
string newValue = editedElement.Text;
var binding = (e.Column as DataGridBoundColumn)?.Binding as Binding;
if (binding != null)
{
string propertyName = binding.Path.Path;
// 延迟调用更新方法,确保编辑状态完成
Dispatcher.BeginInvoke(new Action(() =>
{
UpdateAllRows(propertyName, newValue);
}), System.Windows.Threading.DispatcherPriority.Background);
}
}
}
}
}
private void UpdateAllRows(string propertyName, string newValue)
{
foreach (var item in dgUserInfo.Items)
{
var property = item.GetType().GetProperty(propertyName);
if (property != null)
{
property.SetValue(item, Convert.ChangeType(newValue, property.PropertyType));
}
}
dgUserInfo.Items.Refresh();
}
private void cb_child_Click(object sender, RoutedEventArgs e)
{
CheckBox cb = e.Source as CheckBox;
@ -364,7 +418,11 @@ namespace XGLFinishPro.Views
string sapCode = _deviceCode;//ds.Tables[0].Rows[0][0].ToString();
foreach (sys_user item in checkedRowsCache)
{
string sql = prodDBService.GetCreateUnitPriceInfo(item, _workOrderCode, _sapWorkOrderCode, _productCode, _productName, _childprocessCode, _childprocessName, sapCode, item.number);
if (item.number.IsNullOrEmpty())
{
item.number = "0";
}
string sql = prodDBService.GetCreateUnitPriceInfo(item, _workOrderCode, _sapWorkOrderCode, _productCode, _productName, _childprocessCode, _childprocessName, sapCode, item.number,LoginUser.WorkDate);
CreateUnitPriceSqlList.Add(sql);
}
//之前如果已经插入了,先删除,
@ -374,8 +432,6 @@ namespace XGLFinishPro.Views
//CreateUnitPriceSqlList.Add(updateSql);
if (prodDBService.ExecuteCreateUnitPriceSql(CreateUnitPriceSqlList))
{
CustomMessageBox.Show("插入成功!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);
GetData();
foreach (sys_user item in dgUserInfo.Items)
{

@ -202,6 +202,7 @@ namespace XGLFinishPro.Views
/// <param name="Date"></param>
public async void upDateDate(string Date)
{
int issesscc=0;
// 将数据保存
CheckTaskModel newItem = new CheckTaskModel() { material_name = Date };
try
@ -212,12 +213,11 @@ namespace XGLFinishPro.Views
var saveDataTask = Task.Run(() =>
{
// 在这里执行数据库操作
userDbWareHouse.InsertCheckTaskDetail(checkTaskModel.actual_value, checkTaskModel.record_id);
issesscc= userDbWareHouse.InsertCheckTaskDetail(checkTaskModel.actual_value, checkTaskModel.record_id);
});
// 等待哪个任务先完成
var completedTask = await Task.WhenAny(saveDataTask, timeoutTask);
// 判断是哪个任务先完成
if (completedTask == timeoutTask)
{
@ -226,25 +226,33 @@ namespace XGLFinishPro.Views
}
else
{
// 获取当前应用程序的Dispatcher
dispatcher = Application.Current.Dispatcher;
Dispatcher.Invoke(() =>
LogHelper.instance.log.Error("issesscc为" + issesscc);
if (issesscc>0)
{
zhongDate.Items.Add(newItem);
});
if (string.IsNullOrEmpty(checkTaskModel.actual_value))
{
checkTaskModel.actual_value = $"[\"{Date}\"]";
// 获取当前应用程序的Dispatcher
dispatcher = Application.Current.Dispatcher;
Dispatcher.Invoke(() =>
{
zhongDate.Items.Add(newItem);
});
if (string.IsNullOrEmpty(checkTaskModel.actual_value))
{
checkTaskModel.actual_value = $"[\"{Date}\"]";
}
else
{
// 去除字符串开头和结尾的方括号
checkTaskModel.actual_value = checkTaskModel.actual_value.Trim(']');
// 在字符串末尾添加逗号和aaa的值
checkTaskModel.actual_value += $", \"{Date}\"]";
}
}
else
{
// 去除字符串开头和结尾的方括号
checkTaskModel.actual_value = checkTaskModel.actual_value.Trim(']');
// 在字符串末尾添加逗号和aaa的值
checkTaskModel.actual_value += $", \"{Date}\"]";
{ // 弹窗提醒
MessageBox.Show("保存数据失败!请重新测量~");
}
}
//userDbWareHouse.InsertCheckTaskDetail(checkTaskModel.actual_value, checkTaskModel.record_id);//保存称重数据
Button_Click_2(null, null);
@ -369,6 +377,7 @@ namespace XGLFinishPro.Views
/// <param name="e"></param>
private async void DeleteButton_Click(object sender, RoutedEventArgs e)
{
int issesscc = 0;
try
{
var button = sender as Button;
@ -390,7 +399,7 @@ namespace XGLFinishPro.Views
var saveDataTask = Task.Run(() =>
{
// 在这里执行数据库操作
userDbWareHouse.InsertCheckTaskDetail(checkTaskModel.actual_value, checkTaskModel.record_id);
issesscc= userDbWareHouse.InsertCheckTaskDetail(checkTaskModel.actual_value, checkTaskModel.record_id);
});
// 等待哪个任务先完成
@ -404,8 +413,17 @@ namespace XGLFinishPro.Views
}
else
{
// 从 DataGrid 的 ItemsSource 中移除该项
zhongDate.Items.Remove(item);
LogHelper.instance.log.Error("issesscc为" + issesscc);
if (issesscc > 0)
{
// 从 DataGrid 的 ItemsSource 中移除该项
zhongDate.Items.Remove(item);
}
else
{
// 弹窗提醒
MessageBox.Show("删除数据失败!请重新删除~");
}
}
Button_Click_2(null, null);
// 从数据源中移除该项

Loading…
Cancel
Save