修改报工时失败也添加检验任务

master
zhaojian 1 year ago
parent 97ca6f96af
commit ee4f07277e

@ -209,13 +209,13 @@ ORDER BY
}
public DataTable GetExistAttendanceRecord(string v)
public DataTable GetExistAttendanceRecord(string v,string data)
{
//不会存在一个人俩个班次工作的情况
string sql = $@" select id, user_id, user_name, attendance_status, sex, age,
id_number, start_time, start_addr, end_time, end_addr, attendance_time,
attendance_date, work_hours, create_time
from mes_attendance_records where attendance_date = CONVERT(VARCHAR(10), GetDate() , 120)";
from mes_attendance_records where attendance_date ='{data}'";
DataSet dtset = Utils.netClientDBHelper.getDataSet(sql);
if (dtset != null && dtset.Tables.Count > 0 && dtset.Tables[0].Rows.Count > 0)
{
@ -644,18 +644,18 @@ select a.TrayCode,a.ProductBarNo,a.carcode,a.createtime,a.lineno,b.HadNumber
public DataTable GetWetPlanInfo(string deviceCode, string date)
{
string sql = $@"select workorder.factory_code,workorder.product_date as plan_time, workorder.workorder_id,workorder.workorder_code, product_code,product_name,
product_spc,shifts.shift_desc,prod_line_code,workorder.status,route_code,quantity_split,
workorder.unit,workorder.shift_id ,batch.batch_code,batch.batch_quantity,sort_no, workorder.parent_order,batch.qc_status,isnull(batch.qc_result,'') qc_result,batch.status as batchStatus,workorder_code_sap,salary_flag,qty.batchQty,batch.batch_quantity - qty.batchQty as diffQty, chack.create_time,
chack.check_status
from pro_order_workorder workorder WITH (NOLOCK)
left JOIN base_shifts_t shifts WITH (NOLOCK) on workorder.shift_id = shifts.shift_id
left JOIN pro_order_workorder_batch batch WITH (NOLOCK) on workorder.workorder_id = batch.workorder_id
LEFT JOIN ( SELECT * FROM qc_check_task WHERE check_type='checkTypeCPPC' AND del_flag =0) chack ON workorder.workorder_code = chack.order_no AND batch.batch_code = chack.income_batch_no
left join (SELECT sum(quantity_feedback) as batchQty,workorder_code,batch FROM [dbo].[mes_report_work] where del_flag = 0 GROUP BY workorder_code,batch) qty on qty.workorder_code = workorder.workorder_code and batch.batch_code = qty.batch
where 1=1 and batch.del_flag = 0 and workorder.del_flag = 0 and
workorder.parent_order ='0' and CONVERT(VARCHAR(10), workorder.product_date , 120)= CONVERT(VARCHAR(10), '{date}' , 120) and workorder.prod_line_code like '%{deviceCode}%' order by sort_no,batch_code";
// string sql = $@"select workorder.factory_code,workorder.product_date as plan_time, workorder.workorder_id,workorder.workorder_code, product_code,product_name,
//product_spc,shifts.shift_desc,prod_line_code,workorder.status,route_code,quantity_split,
//workorder.unit,workorder.shift_id ,batch.batch_code,batch.batch_quantity,sort_no, workorder.parent_order,batch.qc_status,isnull(batch.qc_result,'') qc_result,batch.status as batchStatus,workorder_code_sap,salary_flag,qty.batchQty,batch.batch_quantity - qty.batchQty as diffQty, chack.create_time,
// chack.check_status
//from pro_order_workorder workorder WITH (NOLOCK)
//left JOIN base_shifts_t shifts WITH (NOLOCK) on workorder.shift_id = shifts.shift_id
//left JOIN pro_order_workorder_batch batch WITH (NOLOCK) on workorder.workorder_id = batch.workorder_id
//LEFT JOIN ( SELECT * FROM qc_check_task WHERE check_type='checkTypeCPPC' AND del_flag =0) chack ON workorder.workorder_code = chack.order_no AND batch.batch_code = chack.income_batch_no
//left join (SELECT sum(quantity_feedback) as batchQty,workorder_code,batch FROM [dbo].[mes_report_work] where del_flag = 0 GROUP BY workorder_code,batch) qty on qty.workorder_code = workorder.workorder_code and batch.batch_code = qty.batch
//where 1=1 and batch.del_flag = 0 and workorder.del_flag = 0 and
// workorder.parent_order ='0' and CONVERT(VARCHAR(10), workorder.product_date , 120)= CONVERT(VARCHAR(10), '{date}' , 120) and workorder.prod_line_code like '%{deviceCode}%' order by sort_no,batch_code";
string sql = $"WITH LatestCheck AS (\r\n SELECT \r\n *,\r\n ROW_NUMBER() OVER (PARTITION BY order_no, income_batch_no ORDER BY create_time DESC) AS rn\r\n FROM \r\n qc_check_task\r\n WHERE \r\n check_type = 'checkTypeCPPC' \r\n AND del_flag = 0\r\n)\r\nSELECT \r\n workorder.factory_code,\r\n workorder.product_date AS plan_time,\r\n workorder.workorder_id,\r\n workorder.workorder_code,\r\n product_code,\r\n product_name,\r\n product_spc,\r\n shifts.shift_desc,\r\n prod_line_code,\r\n workorder.status,\r\n route_code,\r\n quantity_split,\r\n workorder.unit,\r\n workorder.shift_id,\r\n batch.batch_code,\r\n batch.batch_quantity,\r\n sort_no,\r\n workorder.parent_order,\r\n batch.qc_status,\r\n ISNULL(batch.qc_result, '') AS qc_result,\r\n batch.status AS batchStatus,\r\n workorder_code_sap,\r\n salary_flag,\r\n qty.batchQty,\r\n batch.batch_quantity - qty.batchQty AS diffQty,\r\n chack.create_time,\r\n chack.check_status\r\nFROM \r\n pro_order_workorder workorder WITH (NOLOCK)\r\nLEFT JOIN \r\n base_shifts_t shifts WITH (NOLOCK) ON workorder.shift_id = shifts.shift_id\r\nLEFT JOIN \r\n pro_order_workorder_batch batch WITH (NOLOCK) ON workorder.workorder_id = batch.workorder_id\r\nOUTER APPLY \r\n (SELECT TOP 1 * \r\n FROM LatestCheck \r\n WHERE rn = 1 \r\n AND workorder.workorder_code = LatestCheck.order_no \r\n AND batch.batch_code = LatestCheck.income_batch_no) chack\r\nLEFT JOIN \r\n (SELECT sum(quantity_feedback) AS batchQty, workorder_code, batch \r\n FROM [dbo].[mes_report_work] \r\n WHERE del_flag = 0 \r\n GROUP BY workorder_code, batch) qty \r\n ON qty.workorder_code = workorder.workorder_code AND batch.batch_code = qty.batch\r\nWHERE \r\n 1 = 1 \r\n AND batch.del_flag = 0 \r\n AND workorder.del_flag = 0 \r\n AND workorder.parent_order = '0' \r\n AND CONVERT(VARCHAR(10), workorder.product_date, 120) = CONVERT(VARCHAR(10), '{date}', 120) \r\n AND workorder.prod_line_code LIKE '%{deviceCode}%'\r\nORDER BY \r\n sort_no, batch_code;\r\n";
DataSet dtset = Utils.netClientDBHelper.getDataSet(sql);
if (dtset != null && dtset.Tables.Count > 0 && dtset.Tables[0].Rows.Count > 0)
{

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

@ -366,6 +366,72 @@ namespace XGLFinishPro.Views
List<string> reportWorkSqlList = formingMachineService.GetExecuteReportWorkSql(selectedRow, _orderQuntity, _workQuntity, newReportCode, _workTime, _useMan, _costCenter, batchCode, isEndReport, _deviceCode, dicWorkTime, dicUserCount);
if (reportWorkSqlList.Count > 0)
{
if (AddConsumInfo(reportWorkSqlList, newReportCode))
{
if (comboBoxBatch.SelectedIndex != 0)
{
try
{
var getorder = formingMachineService.Getorderworkorder(selectedRow["workorder_code"].ToString());
var eqment = formingMachineService.GetWorkShop(Utils.GetAppSetting("DeviceCode"));
createCheckProductTask createCheckProductTask = new createCheckProductTask();
createCheckProductTask.factoryCode = Utils.GetAppSetting("SiteCode");//工厂编码
createCheckProductTask.incomeBatchNo = comboBoxBatch.Text.ToString();//批次号
createCheckProductTask.orderNo = selectedRow["workorder_code"].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.carCode = 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);
LogHelper.instance.log.Info("requestBodyJson批次检验任务日志" + requestBodyJson);
// 发送 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();
CustomMessageBox.Show("批次成品检验任务创建成功!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning, 2000);
LogHelper.instance.log.Error("批次成品检验任务创建成功~即将准备更改工单状态");
return true;
}
else
{
// 输出失败信息
CustomMessageBox.Show("批次成品入库检验任务创建接口调用失败,请咨询开发人员", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning, 3000);
LogHelper.instance.log.Error("批次成品入库检验任务创建接口返回失败!");
return false;
}
}
}
catch (Exception ex)
{
LogHelper.instance.log.Error("批次成品入库检验任务创建接口调用失败>>" + ex.Message);
CustomMessageBox.Show("批次成品入库检验任务创建接口调用失败:" + ex.Message, CustomMessageBoxButton.OK, CustomMessageBoxIcon.Error);
return false;
}
}
}
//报工接口不用调了
////调用报工接口
@ -383,67 +449,7 @@ namespace XGLFinishPro.Views
//createCheckProductTask createCheckProductTask = new createCheckProductTask();
//createCheckProductTask.checkLoc = deviceCode;
//createCheckProductTask.factoryCode = Utils.GetAppSetting("SiteCode");
if (comboBoxBatch.SelectedIndex != 0)
{
try
{
var getorder = formingMachineService.Getorderworkorder(selectedRow["workorder_code"].ToString());
var eqment = formingMachineService.GetWorkShop(Utils.GetAppSetting("DeviceCode"));
createCheckProductTask createCheckProductTask = new createCheckProductTask();
createCheckProductTask.factoryCode = Utils.GetAppSetting("SiteCode");//工厂编码
createCheckProductTask.incomeBatchNo = comboBoxBatch.Text.ToString();//批次号
createCheckProductTask.orderNo = selectedRow["workorder_code"].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.carCode = 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);
LogHelper.instance.log.Info("requestBodyJson批次检验任务日志"+ requestBodyJson);
// 发送 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();
CustomMessageBox.Show("批次成品检验任务创建成功!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning, 2000);
LogHelper.instance.log.Error("批次成品检验任务创建成功~即将准备更改工单状态");
return AddConsumInfo(reportWorkSqlList, newReportCode);
}
else
{
// 输出失败信息
CustomMessageBox.Show("批次成品入库检验任务创建接口调用失败,请咨询开发人员", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning, 3000);
LogHelper.instance.log.Error("批次成品入库检验任务创建接口返回失败!");
}
}
}
catch (Exception ex)
{
LogHelper.instance.log.Error("批次成品入库检验任务创建接口调用失败>>" + ex.Message);
CustomMessageBox.Show("批次成品入库检验任务创建接口调用失败:" + ex.Message, CustomMessageBoxButton.OK, CustomMessageBoxIcon.Error);
}
}
return false;
//if (result.code == 200)
//{

@ -489,7 +489,7 @@ namespace XGLFinishPro.Views
{
LogHelper.instance.log.Info("当前选择的工单"+ (dgWorkOrderInfo.SelectedItem as DataRowView)["workorder_code"].ToString() + "状态为:"+ selectedRow["status"].ToString());
string status = selectedRow["status"].ToString();
string st = status.Equals("w1") ? "派发" : status.Equals("w3") ? "已报工" : status.Equals("w0") ? "未派发" : "已暂停";
string st = status.Equals("w1") ? "派发" : status.Equals("w3") ? "已报工" : status.Equals("w0") ? "未派发" : "已暂停";
CustomMessageBox.Show("你选择的工单不能报工,请检查工单状态,当前工单状态为:"+ st, CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);
return;
}

@ -94,7 +94,7 @@ namespace XGLFinishPro.Views
string userCode = dtUserInfo.Rows[0]["user_name"].ToString();
string userName = dtUserInfo.Rows[0]["nick_name"].ToString();
string sex = dtUserInfo.Rows[0]["sex"].ToString();
DataTable dt = finishProdDBService.GetExistAttendanceRecord(deviceCode);
DataTable dt = finishProdDBService.GetExistAttendanceRecord(deviceCode,LoginUser.WorkDate);
if (dt != null && dt.Select($"user_id = '" + userCode + "' AND end_time IS NULL and start_addr='"+ deviceCode + "'").Length > 0)
{
//2024-06-21陈恒杰说一天只需要一次打卡
@ -167,7 +167,7 @@ namespace XGLFinishPro.Views
string userCode = dtUserInfo.Rows[0]["user_name"].ToString();
string userName = dtUserInfo.Rows[0]["nick_name"].ToString();
string sex = dtUserInfo.Rows[0]["sex"].ToString();
DataTable dt = finishProdDBService.GetExistAttendanceRecord(deviceCode);
DataTable dt = finishProdDBService.GetExistAttendanceRecord(deviceCode,LoginUser.WorkDate);
if (dt != null && dt.Select($"user_id = '" + userCode + "' AND end_time IS NULL and start_addr='" + deviceCode + "'").Length > 0)
{
//2024-06-21陈恒杰说一天只需要一次打卡

@ -375,27 +375,34 @@ namespace XGLFinishPro.Views
private CheckBox _previousCheckBox = null;
private void cb_child_Click_1(object sender, RoutedEventArgs e)
{
CheckBox clickedCheckBox = sender as CheckBox;
if (clickedCheckBox == null)
return;
// 如果之前有选中的CheckBox取消其选中状态
if (_previousCheckBox != null && _previousCheckBox != clickedCheckBox)
try
{
_previousCheckBox.IsChecked = false;
CheckBox clickedCheckBox = sender as CheckBox;
if (clickedCheckBox == null)
return;
// 如果之前有选中的CheckBox取消其选中状态
if (_previousCheckBox != null && _previousCheckBox != clickedCheckBox)
{
_previousCheckBox.IsChecked = false;
}
// 记录当前选中的CheckBox
_previousCheckBox = clickedCheckBox;
// 获取当前选中项的值
var selectedItem = dgUserInfo1.SelectedItem as ChildProcess; // 替换 YourDataType 为实际的数据类型
if (selectedItem != null)
{
_childprocessCode = selectedItem.childprocess_code;
_childprocessName = selectedItem.childprocess_name;
btnQueryUser_Click(null, null);
}
}
// 记录当前选中的CheckBox
_previousCheckBox = clickedCheckBox;
// 获取当前选中项的值
var selectedItem = dgUserInfo1.SelectedItem as ChildProcess; // 替换 YourDataType 为实际的数据类型
if (selectedItem != null)
catch (Exception ex)
{
_childprocessCode = selectedItem.childprocess_code;
_childprocessName = selectedItem.childprocess_name;
btnQueryUser_Click(null, null);
}
LogHelper.instance.log.Error("计件薪酬选择工序数据时发生异常:" + ex.Message);
}
}
private void btnQueryUser_Click(object sender, RoutedEventArgs e)

Loading…
Cancel
Save