添加首检try catch

master
zhaojian 2 years ago
parent 5870e51dcc
commit 85f178f0d1

@ -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;
}
/// <summary>
/// 插入消耗表
/// </summary>

@ -996,7 +996,7 @@ where detail.parent_work_order = '{processid}'"; //where CONVERT(VARCHAR(10), w
/// <returns></returns>
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;

@ -0,0 +1,23 @@
<Window x:Class="XGL.Views.Classes"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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:local="clr-namespace:XGL.Views"
mc:Ignorable="d"
Title="班次交接" Height="450" Width="800" WindowStartupLocation="CenterScreen" >
<Grid Background="Gray">
<Grid.RowDefinitions>
<RowDefinition Height="0.2*"/>
<RowDefinition Height="0.8*"/>
</Grid.RowDefinitions>
<Label Content="当前班次为:" FontSize="30" Margin="0,0,610,32" Foreground="White"></Label>
<Label Name="shift" Content="无" FontSize="30" Margin="170,0,460,32" Foreground="White"></Label>
<Border BorderThickness="3" Grid.Row="1" Margin="67,113,527,174" BorderBrush="Aqua" CornerRadius="4">
<Button Grid.Row="1" Content="上 班" FontSize="30" BorderThickness="0" Background='#2B7EE6' Foreground="White" Click="Button_Click" ></Button>
</Border>
<Border BorderThickness="3" Grid.Row="1" Margin="491,113,103,174" BorderBrush="Aqua" CornerRadius="4">
<Button Grid.Row="1" Content="下 班" FontSize="30" BorderThickness="0" Background='#2B7EE6' Foreground="White" Click="Button_Click_1"></Button>
</Border>
</Grid>
</Window>

@ -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
{
/// <summary>
/// Classes.xaml 的交互逻辑
/// </summary>
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);
}
}
}
}

@ -33,7 +33,7 @@
</Style.Triggers>
</Style>
<Style x:Key="btnKey" TargetType="Button">
<Setter Property="Width" Value="150" />
<Setter Property="Width" Value="140" />
<Setter Property="Height" Value="60" />
<Setter Property="Margin" Value="5.5"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
@ -382,7 +382,6 @@ Grid.ColumnSpan="10" Grid.Column="0" Width="Auto">
Height="90" Visibility="Visible">
<Button Style="{StaticResource btnKey}"
x:Name="btnChangeShifts"
Width="170"
Height="60"
Margin="10,5"
HorizontalAlignment="Center"
@ -427,6 +426,22 @@ Background="#F2F3F5"
Foreground="White"
Click="btnRefresh_Click" Content="刷新"></Button>
</StackPanel>
<StackPanel
Grid.Row="0"
Grid.Column="8"
>
<Button
x:Name="jilu"
Style="{StaticResource btnKey}"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Background="#2B7EE6"
FontSize="20"
Foreground="White"
Click="jilu_Click" Content="记录"></Button>
</StackPanel>
</StackPanel>
</ScrollViewer>
<DataGrid

@ -188,7 +188,7 @@ namespace XGL.Views
//modelWareHouse = new List<WorkOrder>();
userDbWareHouse = new DBService();
DataTable dt = formingMachineService.GetFormingMachineInfo(deviceCode, currShiftDate.ToString());
DataTable dt = formingMachineService.GetFormingMachineInfo(deviceCode, LoginUser.ShiftCode);
if (dt == null) return;
foreach (DataRow i in dt.Rows)
{
@ -318,7 +318,7 @@ namespace XGL.Views
//modelWareHouse = new List<WorkOrder>();
userDbWareHouse = new DBService();
DataTable dt = formingMachineService.GetFormingMachineInfo(deviceCode,currShiftDate.ToString());
DataTable dt = formingMachineService.GetFormingMachineInfo(deviceCode, LoginUser.WorkDate);
if (dt == null) return;
foreach (DataRow i in dt.Rows)
{
@ -603,7 +603,7 @@ VALUES
Environment.Exit(0);
}
}
private void btnMachineRepair_Click(object sender, RoutedEventArgs e)
@ -614,5 +614,11 @@ VALUES
MachineRepairWin machineRepairWin = new MachineRepairWin(apiUrl, formingMachineService.ConvertToFaultModelList());
machineRepairWin.ShowDialog();
}
private void jilu_Click(object sender, RoutedEventArgs e)
{
ProductionData productionData = new ProductionData();
productionData.Show();
}
}
}

@ -0,0 +1,155 @@
<Window x:Class="XGL.Views.ProductionData"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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:local="clr-namespace:XGL.Views"
mc:Ignorable="d"
Height="650" Width="1000" WindowStartupLocation="CenterScreen" >
<Window.Resources>
<!-- 自定义Calendar样式 -->
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="0.15*"/>
<RowDefinition Height="0.85*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100*"/>
<ColumnDefinition Width="265*"/>
<ColumnDefinition Width="87*"/>
<ColumnDefinition Width="204*"/>
<ColumnDefinition Width="344*"/>
</Grid.ColumnDefinitions>
<Label Content="时间:" FontSize="25" Margin="0,20,0,0" HorizontalAlignment="Right" Grid.Column="0" Width="66"></Label>
<Label Content="班次:" FontSize="25" Margin="0,20,0,0" HorizontalAlignment="Center" Grid.Column="2" Width="66"/>
<!-- 应用自定义Calendar样式的DatePicker -->
<DatePicker Visibility="Visible" Width="130" Name="pickerstart" IsEnabled="True" HorizontalAlignment="Left" VerticalAlignment="Top" Grid.Column="1" Margin="0,20,0,0" Height="27">
<DatePicker.LayoutTransform>
<ScaleTransform ScaleX="1.7" ScaleY="1.7"/>
</DatePicker.LayoutTransform>
</DatePicker>
<ComboBox Name="banci" Width="150" Margin="0,20,0,30" Grid.Column="3" FontSize="25" HorizontalAlignment="Center">
<ComboBoxItem Content="白班" />
<ComboBoxItem Content="夜班" />
</ComboBox>
<ComboBox Name="eqment" Width="150" Margin="10,20,0,30" Grid.Column="4" FontSize="25" HorizontalAlignment="Left">
<ComboBoxItem Content="C1" />
<ComboBoxItem Content="C2" />
<ComboBoxItem Content="C3" />
<ComboBoxItem Content="C4" />
<ComboBoxItem Content="C5" />
<ComboBoxItem Content="C6" />
<ComboBoxItem Content="C7" />
<ComboBoxItem Content="C8" />
</ComboBox>
<Border BorderThickness="2" Margin="192,15,22,25" BorderBrush="Gray" CornerRadius="4" Grid.Column="4">
<Button Content="查询" FontSize="25" Margin="0" BorderThickness="0" Background="#2B7EE6" Foreground="White" Click="Button_Click"/>
</Border>
</Grid>
<DataGrid
Margin="10,95,10,10"
x:Name="LoadMaterial"
AlternationCount="2"
AutoGenerateColumns="False"
CanUserAddRows="False"
CanUserReorderColumns="False"
CanUserResizeColumns="False"
CanUserResizeRows="False"
Focusable="False"
HeadersVisibility="Column"
IsReadOnly="True"
RowHeaderWidth="0"
SelectionMode="Single" FontSize="16"
Visibility="Visible" Grid.RowSpan="2">
<DataGrid.Columns>
<DataGridTemplateColumn
x:Name="grid1"
Width="100"
MinWidth="10"
Header=" 序号"
IsReadOnly="True">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock
Margin="0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Focusable="False"
FontSize="20"
Text="{Binding Header, RelativeSource={RelativeSource AncestorType={x:Type DataGridRow}, Mode=FindAncestor}}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn
Width="255*"
Binding="{Binding upDate,StringFormat='{}{0:yyyy-MM-dd HH:mm:ss}'}"
CanUserSort="False"
FontSize="20"
Header="吊满时间"
IsReadOnly="True" />
<DataGridTextColumn
Width="370"
Binding="{Binding vinCode}"
CanUserSort="False"
FontSize="20"
Header="间隔"
IsReadOnly="True" />
<!--<DataGridTextColumn
Width="*"
Binding="{Binding materialName}"
CanUserSort="False"
FontSize="20"
Header="产品名称"
IsReadOnly="True" />-->
</DataGrid.Columns>
<DataGrid.CellStyle>
<Style TargetType="{x:Type DataGridCell}">
<Setter Property="Background" Value="#2B7EE6" />
<Setter Property="Foreground" Value="White" />
<Setter Property="Height" Value="50" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
</Style>
</DataGrid.CellStyle>
<DataGrid.RowStyle>
<Style TargetType="{x:Type DataGridRow}">
<Setter Property="Background" Value="#2B7EE6" />
<Setter Property="Foreground" Value="White" />
<Setter Property="Height" Value="50" />
</Style>
</DataGrid.RowStyle>
<DataGrid.RowHeaderStyle>
<Style TargetType="{x:Type DataGridRowHeader}">
<Setter Property="Background" Value="#2B7EE6" />
<Setter Property="Foreground" Value="White" />
<Setter Property="Height" Value="50" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
</Style>
</DataGrid.RowHeaderStyle>
<DataGrid.ColumnHeaderStyle>
<Style TargetType="{x:Type DataGridColumnHeader}">
<Setter Property="Background" Value="#2B7EE6" />
<Setter Property="Foreground" Value="White" />
<Setter Property="Height" Value="50" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="Margin" Value="0,0,0,0" />
<Setter Property="BorderThickness" Value="5" />
<Setter Property="BorderBrush" Value="White" />
<Setter Property="FontSize" Value="30" />
</Style>
</DataGrid.ColumnHeaderStyle>
</DataGrid>
</Grid>
</Window>

@ -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
{
/// <summary>
/// ProductionData.xaml 的交互逻辑
/// </summary>
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);
}
}
}

@ -340,12 +340,18 @@
<Compile Include="Views\CheckUserWin.xaml.cs">
<DependentUpon>CheckUserWin.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Classes.xaml.cs">
<DependentUpon>Classes.xaml</DependentUpon>
</Compile>
<Compile Include="Views\DryingRoomUC.xaml.cs">
<DependentUpon>DryingRoomUC.xaml</DependentUpon>
</Compile>
<Compile Include="Views\HBLogWin.xaml.cs">
<DependentUpon>HBLogWin.xaml</DependentUpon>
</Compile>
<Compile Include="Views\ProductionData.xaml.cs">
<DependentUpon>ProductionData.xaml</DependentUpon>
</Compile>
<Compile Include="Views\ShouPeiWin.xaml.cs">
<DependentUpon>ShouPeiWin.xaml</DependentUpon>
</Compile>
@ -584,6 +590,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Classes.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\DryingRoomUC.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@ -592,6 +602,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Views\ProductionData.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\ShouPeiWin.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>

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

@ -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
/// <returns></returns>
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<Rootobjectresu>(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<Rootobjectresu>(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)

@ -106,19 +106,19 @@ namespace XGLFinishPro.Views
OnWorkUserList.ForEach(t => t.IsChecked = false);
dataSource = OnWorkUserList;// Utils.userList;
List<sys_user> 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;
}
//之前如果已经插入了,先删除,
//暂时不更新工单状态

Loading…
Cancel
Save