报工数量

master
1 year ago
parent ccb28b4903
commit 56cfc7cf9b

@ -21,7 +21,7 @@ namespace XGL.Data.DBService
/// <param name="edt"></param> /// <param name="edt"></param>
/// <returns></returns> /// <returns></returns>
public DataTable GetFormingMachineInfo(string devicecode, string workDate) public DataTable GetFormingMachineInfo(string devicecode, string workDate)
{ {
//过于复杂,给数据库造成了压力,经常死锁 //过于复杂,给数据库造成了压力,经常死锁
// string sql = $@"SELECT DISTINCT // string sql = $@"SELECT DISTINCT
// ord.workorder_id, // ord.workorder_id,
@ -67,7 +67,7 @@ namespace XGL.Data.DBService
pro_order_workorder ord WITH (NOLOCK) pro_order_workorder ord WITH (NOLOCK)
LEFT JOIN base_shifts_t shift WITH (NOLOCK) on ord.shift_id = shift.Shift_Id LEFT JOIN base_shifts_t shift WITH (NOLOCK) on ord.shift_id = shift.Shift_Id
WHERE WHERE
CONVERT(VARCHAR(10), ord.product_date , 120) = CONVERT(VARCHAR(10), '{workDate+ " 0:00:00"}', 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'"; And ord.prod_line_code like '%{devicecode}%' AND ord.del_flag='0'";
DataSet dtset = Utils.netClientDBHelper.getDataSet(sql); DataSet dtset = Utils.netClientDBHelper.getDataSet(sql);
if (dtset != null && dtset.Tables.Count > 0 && dtset.Tables[0].Rows.Count > 0) if (dtset != null && dtset.Tables.Count > 0 && dtset.Tables[0].Rows.Count > 0)
@ -78,8 +78,8 @@ namespace XGL.Data.DBService
string totalsql = $"SELECT count(*) FROM mes_material_transfer_result result WHERE result.equipmentCode =" + string totalsql = $"SELECT count(*) FROM mes_material_transfer_result result WHERE result.equipmentCode =" +
$" '{devicecode}' AND result.update_time >= ( SELECT TOP 1 create_time FROM mes_changeshift_info WHERE device_code" + $" '{devicecode}' AND result.update_time >= ( SELECT TOP 1 create_time FROM mes_changeshift_info WHERE device_code" +
$" = '{devicecode}' ORDER BY create_time DESC ) AND result.rfid_status='1' ;"; $" = '{devicecode}' ORDER BY create_time DESC ) AND result.rfid_status='1' ;";
// string totalcountSql = $@" select count(*) as totalCount from mes_material_transfer_result WITH (NOLOCK) // string totalcountSql = $@" select count(*) as totalCount from mes_material_transfer_result WITH (NOLOCK)
//where CONVERT(VARCHAR(10), work_date , 120) = CONVERT(VARCHAR(10),'{workDate}', 120) and equipmentCode = '{devicecode}' and OrderCode = '{work0rderID}' group by OrderCode "; //where CONVERT(VARCHAR(10), work_date , 120) = CONVERT(VARCHAR(10),'{workDate}', 120) and equipmentCode = '{devicecode}' and OrderCode = '{work0rderID}' group by OrderCode ";
DataSet dtsetTotalCount = Utils.netClientDBHelper.getDataSet(totalsql); DataSet dtsetTotalCount = Utils.netClientDBHelper.getDataSet(totalsql);
if (dtsetTotalCount != null && dtsetTotalCount.Tables.Count > 0 && dtsetTotalCount.Tables[0].Rows.Count > 0) if (dtsetTotalCount != null && dtsetTotalCount.Tables.Count > 0 && dtsetTotalCount.Tables[0].Rows.Count > 0)
{ {
@ -143,7 +143,7 @@ namespace XGL.Data.DBService
/// <param name="bdt"></param> /// <param name="bdt"></param>
/// <param name="edt"></param> /// <param name="edt"></param>
/// <returns></returns> /// <returns></returns>
public string InterfaceUrl( string url_type) public string InterfaceUrl(string url_type)
{ {
string sql = $@"select url FROM mes_interface_url WHERE url_type='{url_type}'"; string sql = $@"select url FROM mes_interface_url WHERE url_type='{url_type}'";
@ -595,7 +595,7 @@ VALUES
/// <param name="edt"></param> /// <param name="edt"></param>
/// <returns></returns> /// <returns></returns>
public List<string> GetExecuteReportWorkSql(DataRowView selectRow, string orderQuntity, string workCount, string reportCode, string workTime, string userCount, string costCenter, string batchCode, public List<string> GetExecuteReportWorkSql(DataRowView selectRow, string orderQuntity, string workCount, string reportCode, string workTime, string userCount, string costCenter, string batchCode,
string isEndReport, string deviceCode, Dictionary<int, string> workTimeDic, Dictionary<int, string> userCountDic,string xiaolv,string shijian) string isEndReport, string deviceCode, Dictionary<int, string> workTimeDic, Dictionary<int, string> userCountDic, string xiaolv, string shijian)
{ {
string getReportCodeSql = $@"SELECT equipment_code,equipment_name FROM [dbo].[base_equipment] WHERE equipment_code='{deviceCode}'"; string getReportCodeSql = $@"SELECT equipment_code,equipment_name FROM [dbo].[base_equipment] WHERE equipment_code='{deviceCode}'";
string lineName = ""; string lineName = "";
@ -607,7 +607,10 @@ VALUES
#region 生成报工数据 #region 生成报工数据
//获取子工单的信息 //获取子工单的信息
string getSubOrderSql = $"select workorder_code,product_code,product_name,quantity_split,unit from pro_order_workorder where parent_order = '{selectRow["workorder_code"]}'"; #region 订单不能是已经被删除的
string getSubOrderSql = $"select workorder_code,product_code,product_name,quantity_split,unit from pro_order_workorder where parent_order = '{selectRow["workorder_code"]}' and del_flag=0";
#endregion
//string getSubOrderSql = $"select workorder_code,product_code,product_name,quantity_split,unit from pro_order_workorder where parent_order = '{selectRow["workorder_code"]}'";
string subOrder = ""; string subOrder = "";
//string subProductCode = ""; //string subProductCode = "";
//string subProductName = ""; //string subProductName = "";
@ -747,7 +750,7 @@ VALUES
//添加批次报工状态更新--2023-12-26 //添加批次报工状态更新--2023-12-26
string updateBatchOrderStatusSql = $@"update pro_order_workorder_batch set status = '0', update_by = '{LoginUser.UserName}',update_time = GETDATE() where workorder_id = '{selectRow["workorder_id"]}' and batch_code = '{batchCode}' "; string updateBatchOrderStatusSql = $@"update pro_order_workorder_batch set status = '0', update_by = '{LoginUser.UserName}',update_time = GETDATE() where workorder_id = '{selectRow["workorder_id"]}' and batch_code = '{batchCode}' ";
sqlList.Add(updateBatchOrderStatusSql); sqlList.Add(updateBatchOrderStatusSql);
} }
#endregion #endregion
@ -779,7 +782,9 @@ VALUES
{ {
//获取子工单的信息 //获取子工单的信息
string getSubOrderSql = $"select workorder_code,product_code,product_name,quantity_split,unit from pro_order_workorder where parent_order = '{orderId}'"; #region 子单不能是已经被删除的
string getSubOrderSql = $"select workorder_code,product_code,product_name,quantity_split,unit from pro_order_workorder where parent_order = '{orderId}' and del_flag=0";
#endregion
string subOrder = ""; string subOrder = "";
string subProductCode = ""; string subProductCode = "";
string subProductName = ""; string subProductName = "";
@ -791,9 +796,9 @@ VALUES
subOrder = dtSubOrder.Tables[0].Rows[0]["workorder_code"].ToString(); subOrder = dtSubOrder.Tables[0].Rows[0]["workorder_code"].ToString();
subProductCode = dtSubOrder.Tables[0].Rows[0]["product_code"].ToString(); subProductCode = dtSubOrder.Tables[0].Rows[0]["product_code"].ToString();
subProductName = dtSubOrder.Tables[0].Rows[0]["product_name"].ToString(); subProductName = dtSubOrder.Tables[0].Rows[0]["product_name"].ToString();
subQuntity = dtSubOrder.Tables[0].Rows[0]["quantity_split"].ToString(); subQuntity = dtSubOrder.Tables[0].Rows[0]["quantity_split"].ToString();//子单数量
subUnit = dtSubOrder.Tables[0].Rows[0]["unit"].ToString(); subUnit = dtSubOrder.Tables[0].Rows[0]["unit"].ToString();
double rate = Convert.ToDouble(workCount) / Convert.ToDouble(orderQuntity); double rate = Convert.ToDouble(workCount) / Convert.ToDouble(orderQuntity);//workCount是报工数量orderQuntity是母单数量
double subOrderQty = 0; double subOrderQty = 0;
LogHelper.instance.log.Info("rate>>>" + rate); LogHelper.instance.log.Info("rate>>>" + rate);
//根据base_product_attach表里的报工比例计算子单数量又取消了 //根据base_product_attach表里的报工比例计算子单数量又取消了
@ -873,7 +878,7 @@ VALUES
int ret = Utils.netClientDBHelper.executeUpdate(sql); int ret = Utils.netClientDBHelper.executeUpdate(sql);
return ret > 0 ? true : false; return ret > 0 ? true : false;
} }
public bool ChangeShiftsInfo(string deviceCode ,string data,string shift) 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}';"; 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}';";
@ -1171,7 +1176,7 @@ where machine_code = 'X1' and bind_status = '0' order by update_time DESC";
{ {
} }
for(int i = reportList.Count; i < 6; i++) for (int i = reportList.Count; i < 6; i++)
{ {
reportList.Add(new report()); reportList.Add(new report());
} }
@ -1180,7 +1185,7 @@ where machine_code = 'X1' and bind_status = '0' order by update_time DESC";
public int EditReport(report report) public int EditReport(report report)
{ {
string sql= $@"update [dbo].[report] set team='{report.team}',OpenLineCheckBox='{report.OpenLineCheckBox}',ReplaceLineCheckBox='{report.ReplaceLineCheckBox}',unqualified='{report.unqualified}',clear='{report.clear}',residue='{report.residue}',lineClear='{report.lineClear}',UserKnow='{report.UserKnow}',qualified='{report.qualified}',equipStatus='{report.equipStatus}',StampCorrect='{report.StampCorrect}',isClear='{report.isClear}',positionCorrect='{report.positionCorrect}',isLineClear='{report.isLineClear}',create_time=GETDATE() where Id='{report.Id}'"; string sql = $@"update [dbo].[report] set team='{report.team}',OpenLineCheckBox='{report.OpenLineCheckBox}',ReplaceLineCheckBox='{report.ReplaceLineCheckBox}',unqualified='{report.unqualified}',clear='{report.clear}',residue='{report.residue}',lineClear='{report.lineClear}',UserKnow='{report.UserKnow}',qualified='{report.qualified}',equipStatus='{report.equipStatus}',StampCorrect='{report.StampCorrect}',isClear='{report.isClear}',positionCorrect='{report.positionCorrect}',isLineClear='{report.isLineClear}',create_time=GETDATE() where Id='{report.Id}'";
return Utils.netClientDBHelper.executeUpdate(sql); return Utils.netClientDBHelper.executeUpdate(sql);
} }
@ -1189,5 +1194,20 @@ where machine_code = 'X1' and bind_status = '0' order by update_time DESC";
string sql = $@"insert into [dbo].[report] (Id,team,OpenLineCheckBox,ReplaceLineCheckBox,unqualified,clear,residue,lineClear,UserKnow,qualified,equipStatus,StampCorrect,isClear,positionCorrect,isLineClear,create_time) values ('{report.Id}','{report.team}','{report.OpenLineCheckBox}','{report.ReplaceLineCheckBox}','{report.unqualified}','{report.clear}','{report.residue}','{report.lineClear}','{report.UserKnow}','{report.qualified}','{report.equipStatus}','{report.StampCorrect}','{report.isClear}','{report.positionCorrect}','{report.isLineClear}',GETDATE())"; string sql = $@"insert into [dbo].[report] (Id,team,OpenLineCheckBox,ReplaceLineCheckBox,unqualified,clear,residue,lineClear,UserKnow,qualified,equipStatus,StampCorrect,isClear,positionCorrect,isLineClear,create_time) values ('{report.Id}','{report.team}','{report.OpenLineCheckBox}','{report.ReplaceLineCheckBox}','{report.unqualified}','{report.clear}','{report.residue}','{report.lineClear}','{report.UserKnow}','{report.qualified}','{report.equipStatus}','{report.StampCorrect}','{report.isClear}','{report.positionCorrect}','{report.isLineClear}',GETDATE())";
return Utils.netClientDBHelper.executeUpdate(sql); return Utils.netClientDBHelper.executeUpdate(sql);
} }
public bool GetProOrderWorkOrder(string workorderId)
{
string sql = "select del_flag from pro_order_workorder where workorder_id = '" + workorderId + "'";
DataSet dtset = Utils.netClientDBHelper.getDataSet(sql);
if (dtset != null && dtset.Tables.Count > 0 && dtset.Tables[0].Rows.Count > 0)
{
object value = dtset.Tables[0].Rows[0]["del_flag"];
if (value != null && value.ToString() == "0")
{
return true;
}
}
return false;
}
} }
} }

@ -44,7 +44,7 @@ namespace XGLFinishPro
//this.Hide(); //this.Hide();
//Main mainWindow = new Main(); //Main mainWindow = new Main();
//mainWindow.Show(); //mainWindow.Show();
//InitVersion(); InitVersion();
//InitTeamInfo(); //InitTeamInfo();
InitShiftInfo(); InitShiftInfo();
} }

@ -678,7 +678,7 @@ Background="#F2F3F5"
<Grid <Grid
Grid.Row="3" Grid.Row="3"
Grid.ColumnSpan="10" Grid.ColumnSpan="11"
Margin="-30,0,0,0" Margin="-30,0,0,0"
Background="LightGray" Background="LightGray"
HorizontalAlignment="Center" HorizontalAlignment="Center"

@ -499,8 +499,15 @@ namespace XGLFinishPro.Views
// CustomMessageBox.Show("你选择的该批次不能报工!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning); // CustomMessageBox.Show("你选择的该批次不能报工!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);
// return; // return;
//} //}
#region 添加验证
string workorderId = selectedRow["workorder_id"].ToString();
if (!formingMachineService.GetProOrderWorkOrder(workorderId))
{
CustomMessageBox.Show("该工单已经被删除,请重新选择!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);
GetWorkOrderInfo();
return;
}
#endregion
ExecReportWorkWin execReport = new ExecReportWorkWin(selectedRow, deviceCode, Utils.GetAppSetting("SiteCode")); ExecReportWorkWin execReport = new ExecReportWorkWin(selectedRow, deviceCode, Utils.GetAppSetting("SiteCode"));
if (execReport.ShowDialog() == true) if (execReport.ShowDialog() == true)

Loading…
Cancel
Save