init: 潍柴发动机线 中央控制程序 项目首次入库

This commit is contained in:
XingCheng3
2026-06-08 12:05:16 +08:00
commit 196c66b9ff
547 changed files with 379162 additions and 0 deletions

View File

@@ -0,0 +1,88 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace SYNC_SAP_MES
{
internal class CALL_Interfalce_WebAPI
{
public static SyncPlan_WebAPI_ResponseBody Get_Plans_ByWebAPI(string lineid, string startdate, string islocked)
{
var m_msgRequest = new SyncPlan_WebAPI_RequestBody
{
lineId = lineid,
startDate = startdate,
isLocked = islocked
};
return RequestPost_Plans_AMS_To_SAP(m_msgRequest);
}
public static SyncPlan_WebAPI_ResponseBody Get_BarCode_Plans_ByWebAPI(string lineid, string startdate)
{
var m_msgRequest = new SyncBarCodePlan_WebAPI_RequestBody
{
lineId = lineid,
startDate = startdate + " 00:00:00",
endDate = startdate + " 23:59:59"
};
return RequestPost_BarCode_Plans_AMS_To_SAP(m_msgRequest);
}
public static SyncPlan_WebAPI_ResponseBody RequestPost_BarCode_Plans_AMS_To_SAP(Object m_msg)
{
var demoData = JsonConvert.SerializeObject(m_msg);
return JsonConvert.DeserializeObject<SyncPlan_WebAPI_ResponseBody>(HttpCli.Post(Program.WebAPI_Url_BarCodePlans, demoData));
//var Gen_ProductPlan = File.ReadAllText("C:\\项目\\AMS计划下达.json");
//return JsonConvert.DeserializeObject<SyncPlan_WebAPI_ResponseBody>(Gen_ProductPlan);
}
public static SyncPlan_WebAPI_ResponseBody RequestPost_Plans_AMS_To_SAP(Object m_msg)
{
var demoData = JsonConvert.SerializeObject(m_msg);
return JsonConvert.DeserializeObject<SyncPlan_WebAPI_ResponseBody>(HttpCli.Post(Program.WebAPI_Url_Plans, demoData));
//var Gen_ProductPlan = File.ReadAllText("C:\\项目\\AMS计划下达.json");
//return JsonConvert.DeserializeObject<SyncPlan_WebAPI_ResponseBody>(Gen_ProductPlan);
}
public static ResponseBody_WebAPI_Boms Get_BOMs_ByWebAPI(string lineid, string productcode)
{
var m_msgRequest = new RequestBody_WebAPI_Boms
{
lineId = lineid,
productCode = productcode
};
return RequestPost_Boms_AMS_To_SAP(m_msgRequest);
}
public static ResponseBody_WebAPI_Boms RequestPost_Boms_AMS_To_SAP(RequestBody_WebAPI_Boms m_msg)
{
var demoData = JsonConvert.SerializeObject(m_msg);
return JsonConvert.DeserializeObject<ResponseBody_WebAPI_Boms>(HttpCli.Post(Program.WebAPI_Url_Boms, demoData));
//var Gen_ProductPlan = File.ReadAllText("C:\\项目\\AMS计划下达.json");
//return JsonConvert.DeserializeObject<ResponseBody_WebAPI_Boms>(Gen_ProductPlan);
}
public static SyncPlan_WebAPI_ResponseBody Put_MisFun_ByWebAPI(string type,string opName,string value = "")
{
var m_msgRequest = new DataBody_WebApi_MisFun
{
type = type,
opName = opName,
value = value
};
var jsonData = JsonConvert.SerializeObject(m_msgRequest);
return JsonConvert.DeserializeObject<SyncPlan_WebAPI_ResponseBody>(HttpCli.Post(Program.WebAPI_Url_MisFun, jsonData));
}
}
}

103
SAP/SAP_Sync/D_Sure.Designer.cs generated Normal file
View File

@@ -0,0 +1,103 @@
namespace SYNC_SAP_MES
{
partial class D_Sure
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.btn_Sure = new System.Windows.Forms.Button();
this.btn_Cancel = new System.Windows.Forms.Button();
this.label2 = new System.Windows.Forms.Label();
this.txt_Sure = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// btn_Sure
//
this.btn_Sure.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btn_Sure.Location = new System.Drawing.Point(174, 185);
this.btn_Sure.Name = "btn_Sure";
this.btn_Sure.Size = new System.Drawing.Size(80, 38);
this.btn_Sure.TabIndex = 2;
this.btn_Sure.Text = "确定";
this.btn_Sure.UseVisualStyleBackColor = true;
this.btn_Sure.Click += new System.EventHandler(this.btn_Sure_Click);
//
// btn_Cancel
//
this.btn_Cancel.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btn_Cancel.Location = new System.Drawing.Point(260, 185);
this.btn_Cancel.Name = "btn_Cancel";
this.btn_Cancel.Size = new System.Drawing.Size(80, 38);
this.btn_Cancel.TabIndex = 2;
this.btn_Cancel.Text = "取消";
this.btn_Cancel.UseVisualStyleBackColor = true;
this.btn_Cancel.Click += new System.EventHandler(this.btn_Cancel_Click);
//
// label2
//
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label2.Location = new System.Drawing.Point(58, 85);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(112, 14);
this.label2.TabIndex = 0;
this.label2.Text = "请输入“确认”";
//
// txt_Sure
//
this.txt_Sure.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txt_Sure.Location = new System.Drawing.Point(61, 110);
this.txt_Sure.Multiline = true;
this.txt_Sure.Name = "txt_Sure";
this.txt_Sure.Size = new System.Drawing.Size(279, 37);
this.txt_Sure.TabIndex = 1;
//
// D_Sure
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(398, 269);
this.Controls.Add(this.btn_Cancel);
this.Controls.Add(this.btn_Sure);
this.Controls.Add(this.txt_Sure);
this.Controls.Add(this.label2);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Name = "D_Sure";
this.ShowIcon = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "信息确认";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button btn_Sure;
private System.Windows.Forms.Button btn_Cancel;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox txt_Sure;
}
}

50
SAP/SAP_Sync/D_Sure.cs Normal file
View File

@@ -0,0 +1,50 @@
using SYNC_SAP_MES;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SYNC_SAP_MES
{
/// <summary>
///
/// </summary>
public partial class D_Sure : Form
{
/// <summary>
///
/// </summary>
public D_Sure()
{
InitializeComponent();
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btn_Sure_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(txt_Sure.Text))
{
MessageBox.Show("为了防止错误操作,请填写在文本框填入 确认 ");
return;
}
DialogResult = DialogResult.OK;
}
private void btn_Cancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
}
}
}

120
SAP/SAP_Sync/D_Sure.resx Normal file
View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

182
SAP/SAP_Sync/D_Update_FlowNo.Designer.cs generated Normal file
View File

@@ -0,0 +1,182 @@
namespace SYNC_SAP_MES
{
partial class D_Update_FlowNo
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.txt_FlowNo_CurrMax = new System.Windows.Forms.TextBox();
this.txt_FlowNo = new System.Windows.Forms.TextBox();
this.btn_Sure = new System.Windows.Forms.Button();
this.btn_Cancel = new System.Windows.Forms.Button();
this.btn_Query = new System.Windows.Forms.Button();
this.label2 = new System.Windows.Forms.Label();
this.txt_Sure = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label1.Location = new System.Drawing.Point(75, 51);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(157, 14);
this.label1.TabIndex = 0;
this.label1.Text = "最大流水号(已占用)";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label3.Location = new System.Drawing.Point(75, 138);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(127, 14);
this.label3.TabIndex = 0;
this.label3.Text = "最大流水号(新)";
//
// txt_FlowNo_CurrMax
//
this.txt_FlowNo_CurrMax.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txt_FlowNo_CurrMax.Location = new System.Drawing.Point(78, 78);
this.txt_FlowNo_CurrMax.Multiline = true;
this.txt_FlowNo_CurrMax.Name = "txt_FlowNo_CurrMax";
this.txt_FlowNo_CurrMax.ReadOnly = true;
this.txt_FlowNo_CurrMax.Size = new System.Drawing.Size(198, 34);
this.txt_FlowNo_CurrMax.TabIndex = 1;
//
// txt_FlowNo
//
this.txt_FlowNo.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txt_FlowNo.Location = new System.Drawing.Point(78, 158);
this.txt_FlowNo.Multiline = true;
this.txt_FlowNo.Name = "txt_FlowNo";
this.txt_FlowNo.Size = new System.Drawing.Size(279, 30);
this.txt_FlowNo.TabIndex = 1;
//
// btn_Sure
//
this.btn_Sure.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btn_Sure.Location = new System.Drawing.Point(191, 311);
this.btn_Sure.Name = "btn_Sure";
this.btn_Sure.Size = new System.Drawing.Size(80, 38);
this.btn_Sure.TabIndex = 2;
this.btn_Sure.Text = "确定";
this.btn_Sure.UseVisualStyleBackColor = true;
this.btn_Sure.Click += new System.EventHandler(this.btn_Sure_Click);
//
// btn_Cancel
//
this.btn_Cancel.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btn_Cancel.Location = new System.Drawing.Point(277, 311);
this.btn_Cancel.Name = "btn_Cancel";
this.btn_Cancel.Size = new System.Drawing.Size(80, 38);
this.btn_Cancel.TabIndex = 2;
this.btn_Cancel.Text = "取消";
this.btn_Cancel.UseVisualStyleBackColor = true;
this.btn_Cancel.Click += new System.EventHandler(this.btn_Cancel_Click);
//
// btn_Query
//
this.btn_Query.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btn_Query.Location = new System.Drawing.Point(282, 78);
this.btn_Query.Name = "btn_Query";
this.btn_Query.Size = new System.Drawing.Size(75, 34);
this.btn_Query.TabIndex = 2;
this.btn_Query.Text = "查询";
this.btn_Query.UseVisualStyleBackColor = true;
this.btn_Query.Click += new System.EventHandler(this.btn_Query_Click);
//
// label2
//
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label2.Location = new System.Drawing.Point(75, 236);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(112, 14);
this.label2.TabIndex = 0;
this.label2.Text = "请输入“确认”";
//
// txt_Sure
//
this.txt_Sure.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txt_Sure.Location = new System.Drawing.Point(78, 257);
this.txt_Sure.Multiline = true;
this.txt_Sure.Name = "txt_Sure";
this.txt_Sure.Size = new System.Drawing.Size(279, 37);
this.txt_Sure.TabIndex = 1;
//
// label4
//
this.label4.AutoSize = true;
this.label4.ForeColor = System.Drawing.Color.Red;
this.label4.Location = new System.Drawing.Point(76, 195);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(329, 12);
this.label4.TabIndex = 0;
this.label4.Text = "下次生成流水号,从此值+1开始可设置值只能>=生产最大值";
//
// D_Update_FlowNo
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(451, 379);
this.Controls.Add(this.btn_Query);
this.Controls.Add(this.btn_Cancel);
this.Controls.Add(this.btn_Sure);
this.Controls.Add(this.txt_Sure);
this.Controls.Add(this.txt_FlowNo);
this.Controls.Add(this.label2);
this.Controls.Add(this.txt_FlowNo_CurrMax);
this.Controls.Add(this.label3);
this.Controls.Add(this.label4);
this.Controls.Add(this.label1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Name = "D_Update_FlowNo";
this.ShowIcon = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "流水号修改";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox txt_FlowNo_CurrMax;
private System.Windows.Forms.TextBox txt_FlowNo;
private System.Windows.Forms.Button btn_Sure;
private System.Windows.Forms.Button btn_Cancel;
private System.Windows.Forms.Button btn_Query;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox txt_Sure;
private System.Windows.Forms.Label label4;
}
}

View File

@@ -0,0 +1,97 @@
using SYNC_SAP_MES;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SYNC_SAP_MES
{
/// <summary>
///
/// </summary>
public partial class D_Update_FlowNo : Form
{
/// <summary>
///
/// </summary>
public string FlowNo = "";
/// <summary>
///
/// </summary>
public D_Update_FlowNo()
{
InitializeComponent();
}
/// <summary>
///
/// </summary>
/// <param name="from_Opera"></param>
public D_Update_FlowNo(string flowNo)
{
InitializeComponent();
txt_FlowNo.Text = flowNo;
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btn_Sure_Click(object sender, EventArgs e)
{
if (!ifIntValue(txt_FlowNo.Text.Trim()))
{
MessageBox.Show("流水号不能为空,且必须为整数!");
return;
}
else
{
Sql_Biz_SAP.GetFlowNo_CurrMax(out string flowNo_CurrMax);
var setFlowNo = txt_FlowNo.Text;
if (Convert.ToInt32(setFlowNo) < Convert.ToInt32(flowNo_CurrMax))
{
//允许设置 >= 的流水号
MessageBox.Show("不允许设置小于当前生产的流水号!");
return;
}
}
if (string.IsNullOrEmpty(txt_Sure.Text))
{
MessageBox.Show("为了防止错误操作,请填写在文本框填入 确认 ");
return;
}
FlowNo = txt_FlowNo.Text;
DialogResult = DialogResult.OK;
}
private bool ifIntValue(string inputValue)
{
try
{
var k = Convert.ToInt32(inputValue);
return true;
}
catch
{
return false;
}
}
private void btn_Cancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
}
private void btn_Query_Click(object sender, EventArgs e)
{
Sql_Biz_SAP.GetFlowNo_CurrMax(out string FlowNo);
txt_FlowNo_CurrMax.Text = FlowNo;
}
}
}

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

439
SAP/SAP_Sync/FormSAP.Designer.cs generated Normal file
View File

@@ -0,0 +1,439 @@
namespace SYNC_SAP_MES
{
partial class FormSAP
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.dgv_SpiltPlan_toDay = new System.Windows.Forms.TabControl();
this.tab_Main = new System.Windows.Forms.TabPage();
this.chk_syncModel = new System.Windows.Forms.CheckBox();
this.dtPicker_SyncDate = new System.Windows.Forms.DateTimePicker();
this.button3 = new System.Windows.Forms.Button();
this.lb_ErrCount = new System.Windows.Forms.Label();
this.txt_Err = new System.Windows.Forms.TextBox();
this.btn_ManualCheck = new System.Windows.Forms.Button();
this.btn_ManualSync = new System.Windows.Forms.Button();
this.panel8 = new System.Windows.Forms.Panel();
this.label13 = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
this.pb_OnLine_SAP = new System.Windows.Forms.PictureBox();
this.pb_OnLine_Sql = new System.Windows.Forms.PictureBox();
this.label4 = new System.Windows.Forms.Label();
this.tab_QueryMesPlan = new System.Windows.Forms.TabPage();
this.label16 = new System.Windows.Forms.Label();
this.dtPicker_MES = new System.Windows.Forms.DateTimePicker();
this.btn_Refresh_MesPlan = new System.Windows.Forms.Button();
this.dgv_MesPlan = new System.Windows.Forms.DataGridView();
this.tab_Order_Exec = new System.Windows.Forms.TabPage();
this.dgv_ExcutePlan = new System.Windows.Forms.DataGridView();
this.label12 = new System.Windows.Forms.Label();
this.btn_Query = new System.Windows.Forms.Button();
this.dtPicker_ProductDate = new System.Windows.Forms.DateTimePicker();
this.txt_OrderNum = new System.Windows.Forms.TextBox();
this.label14 = new System.Windows.Forms.Label();
this.timer_OnLine_Show = new System.Windows.Forms.Timer(this.components);
this.dgv_SpiltPlan_toDay.SuspendLayout();
this.tab_Main.SuspendLayout();
this.panel8.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pb_OnLine_SAP)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pb_OnLine_Sql)).BeginInit();
this.tab_QueryMesPlan.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dgv_MesPlan)).BeginInit();
this.tab_Order_Exec.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dgv_ExcutePlan)).BeginInit();
this.SuspendLayout();
//
// dgv_SpiltPlan_toDay
//
this.dgv_SpiltPlan_toDay.Controls.Add(this.tab_Main);
this.dgv_SpiltPlan_toDay.Controls.Add(this.tab_QueryMesPlan);
this.dgv_SpiltPlan_toDay.Controls.Add(this.tab_Order_Exec);
this.dgv_SpiltPlan_toDay.Location = new System.Drawing.Point(5, 5);
this.dgv_SpiltPlan_toDay.Name = "dgv_SpiltPlan_toDay";
this.dgv_SpiltPlan_toDay.SelectedIndex = 0;
this.dgv_SpiltPlan_toDay.Size = new System.Drawing.Size(1202, 714);
this.dgv_SpiltPlan_toDay.TabIndex = 9;
//
// tab_Main
//
this.tab_Main.Controls.Add(this.chk_syncModel);
this.tab_Main.Controls.Add(this.dtPicker_SyncDate);
this.tab_Main.Controls.Add(this.button3);
this.tab_Main.Controls.Add(this.lb_ErrCount);
this.tab_Main.Controls.Add(this.txt_Err);
this.tab_Main.Controls.Add(this.btn_ManualCheck);
this.tab_Main.Controls.Add(this.btn_ManualSync);
this.tab_Main.Controls.Add(this.panel8);
this.tab_Main.Controls.Add(this.label4);
this.tab_Main.Location = new System.Drawing.Point(4, 22);
this.tab_Main.Name = "tab_Main";
this.tab_Main.Padding = new System.Windows.Forms.Padding(3);
this.tab_Main.Size = new System.Drawing.Size(1194, 688);
this.tab_Main.TabIndex = 0;
this.tab_Main.Text = "同步页面";
this.tab_Main.UseVisualStyleBackColor = true;
//
// chk_syncModel
//
this.chk_syncModel.AutoSize = true;
this.chk_syncModel.Location = new System.Drawing.Point(996, 310);
this.chk_syncModel.Name = "chk_syncModel";
this.chk_syncModel.Size = new System.Drawing.Size(72, 16);
this.chk_syncModel.TabIndex = 1808;
this.chk_syncModel.Text = "手动模式";
this.chk_syncModel.UseVisualStyleBackColor = true;
this.chk_syncModel.CheckedChanged += new System.EventHandler(this.chk_syncModel_CheckedChanged);
//
// dtPicker_SyncDate
//
this.dtPicker_SyncDate.Location = new System.Drawing.Point(996, 350);
this.dtPicker_SyncDate.Name = "dtPicker_SyncDate";
this.dtPicker_SyncDate.Size = new System.Drawing.Size(141, 21);
this.dtPicker_SyncDate.TabIndex = 1807;
this.dtPicker_SyncDate.ValueChanged += new System.EventHandler(this.dtPicker_SyncDate_ValueChanged);
//
// button3
//
this.button3.BackColor = System.Drawing.Color.Salmon;
this.button3.Location = new System.Drawing.Point(996, 605);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(92, 41);
this.button3.TabIndex = 1806;
this.button3.Text = "测试";
this.button3.UseVisualStyleBackColor = false;
this.button3.Visible = false;
this.button3.Click += new System.EventHandler(this.button3_Click_1);
//
// lb_ErrCount
//
this.lb_ErrCount.AutoSize = true;
this.lb_ErrCount.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold);
this.lb_ErrCount.Location = new System.Drawing.Point(783, 8);
this.lb_ErrCount.Name = "lb_ErrCount";
this.lb_ErrCount.Size = new System.Drawing.Size(82, 12);
this.lb_ErrCount.TabIndex = 1804;
this.lb_ErrCount.Text = "lb_ErrCount";
//
// txt_Err
//
this.txt_Err.Location = new System.Drawing.Point(6, 26);
this.txt_Err.Multiline = true;
this.txt_Err.Name = "txt_Err";
this.txt_Err.ScrollBars = System.Windows.Forms.ScrollBars.Both;
this.txt_Err.Size = new System.Drawing.Size(881, 648);
this.txt_Err.TabIndex = 1803;
this.txt_Err.WordWrap = false;
//
// btn_ManualCheck
//
this.btn_ManualCheck.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btn_ManualCheck.Location = new System.Drawing.Point(1058, 470);
this.btn_ManualCheck.Name = "btn_ManualCheck";
this.btn_ManualCheck.Size = new System.Drawing.Size(111, 78);
this.btn_ManualCheck.TabIndex = 1802;
this.btn_ManualCheck.Text = "手动检查\r\n\r\n通讯状态";
this.btn_ManualCheck.UseVisualStyleBackColor = true;
this.btn_ManualCheck.Click += new System.EventHandler(this.btn_ManualCheck_Click);
//
// btn_ManualSync
//
this.btn_ManualSync.Enabled = false;
this.btn_ManualSync.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btn_ManualSync.Location = new System.Drawing.Point(915, 470);
this.btn_ManualSync.Name = "btn_ManualSync";
this.btn_ManualSync.Size = new System.Drawing.Size(113, 78);
this.btn_ManualSync.TabIndex = 1802;
this.btn_ManualSync.Text = "手动同步";
this.btn_ManualSync.UseVisualStyleBackColor = true;
this.btn_ManualSync.Click += new System.EventHandler(this.btn_ManualSync_Click);
//
// panel8
//
this.panel8.BackColor = System.Drawing.Color.Gainsboro;
this.panel8.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.panel8.Controls.Add(this.label13);
this.panel8.Controls.Add(this.label9);
this.panel8.Controls.Add(this.pb_OnLine_SAP);
this.panel8.Controls.Add(this.pb_OnLine_Sql);
this.panel8.Location = new System.Drawing.Point(962, 116);
this.panel8.Name = "panel8";
this.panel8.Size = new System.Drawing.Size(175, 100);
this.panel8.TabIndex = 1801;
//
// label13
//
this.label13.AutoSize = true;
this.label13.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Bold);
this.label13.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.label13.Location = new System.Drawing.Point(101, 13);
this.label13.Name = "label13";
this.label13.Size = new System.Drawing.Size(48, 22);
this.label13.TabIndex = 1;
this.label13.Text = "AMS";
//
// label9
//
this.label9.AutoSize = true;
this.label9.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Bold);
this.label9.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.label9.Location = new System.Drawing.Point(20, 13);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(58, 22);
this.label9.TabIndex = 1;
this.label9.Text = "伺服器";
//
// pb_OnLine_SAP
//
this.pb_OnLine_SAP.Image = global::SYNC_SAP_MES.Properties.Resources.;
this.pb_OnLine_SAP.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.pb_OnLine_SAP.Location = new System.Drawing.Point(98, 41);
this.pb_OnLine_SAP.Name = "pb_OnLine_SAP";
this.pb_OnLine_SAP.Size = new System.Drawing.Size(51, 52);
this.pb_OnLine_SAP.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pb_OnLine_SAP.TabIndex = 16;
this.pb_OnLine_SAP.TabStop = false;
//
// pb_OnLine_Sql
//
this.pb_OnLine_Sql.Image = global::SYNC_SAP_MES.Properties.Resources.;
this.pb_OnLine_Sql.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.pb_OnLine_Sql.Location = new System.Drawing.Point(24, 41);
this.pb_OnLine_Sql.Name = "pb_OnLine_Sql";
this.pb_OnLine_Sql.Size = new System.Drawing.Size(51, 52);
this.pb_OnLine_Sql.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pb_OnLine_Sql.TabIndex = 16;
this.pb_OnLine_Sql.TabStop = false;
//
// label4
//
this.label4.AutoSize = true;
this.label4.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label4.Location = new System.Drawing.Point(923, 354);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(67, 14);
this.label4.TabIndex = 0;
this.label4.Text = "同步日期";
//
// tab_QueryMesPlan
//
this.tab_QueryMesPlan.AutoScroll = true;
this.tab_QueryMesPlan.Controls.Add(this.label16);
this.tab_QueryMesPlan.Controls.Add(this.dtPicker_MES);
this.tab_QueryMesPlan.Controls.Add(this.btn_Refresh_MesPlan);
this.tab_QueryMesPlan.Controls.Add(this.dgv_MesPlan);
this.tab_QueryMesPlan.Location = new System.Drawing.Point(4, 22);
this.tab_QueryMesPlan.Name = "tab_QueryMesPlan";
this.tab_QueryMesPlan.Size = new System.Drawing.Size(1194, 688);
this.tab_QueryMesPlan.TabIndex = 3;
this.tab_QueryMesPlan.Text = "AMS生产计划浏览";
this.tab_QueryMesPlan.UseVisualStyleBackColor = true;
//
// label16
//
this.label16.AutoSize = true;
this.label16.Location = new System.Drawing.Point(7, 16);
this.label16.Name = "label16";
this.label16.Size = new System.Drawing.Size(29, 12);
this.label16.TabIndex = 26;
this.label16.Text = "日期";
//
// dtPicker_MES
//
this.dtPicker_MES.Location = new System.Drawing.Point(44, 11);
this.dtPicker_MES.Name = "dtPicker_MES";
this.dtPicker_MES.Size = new System.Drawing.Size(200, 21);
this.dtPicker_MES.TabIndex = 25;
//
// btn_Refresh_MesPlan
//
this.btn_Refresh_MesPlan.Location = new System.Drawing.Point(264, 5);
this.btn_Refresh_MesPlan.Name = "btn_Refresh_MesPlan";
this.btn_Refresh_MesPlan.Size = new System.Drawing.Size(95, 30);
this.btn_Refresh_MesPlan.TabIndex = 4;
this.btn_Refresh_MesPlan.Text = "查询";
this.btn_Refresh_MesPlan.UseVisualStyleBackColor = true;
this.btn_Refresh_MesPlan.Click += new System.EventHandler(this.btn_Refresh_MesPlan_Click);
//
// dgv_MesPlan
//
this.dgv_MesPlan.AllowUserToAddRows = false;
this.dgv_MesPlan.AllowUserToDeleteRows = false;
this.dgv_MesPlan.AllowUserToResizeRows = false;
this.dgv_MesPlan.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
this.dgv_MesPlan.BackgroundColor = System.Drawing.SystemColors.ButtonHighlight;
this.dgv_MesPlan.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgv_MesPlan.Location = new System.Drawing.Point(3, 38);
this.dgv_MesPlan.Name = "dgv_MesPlan";
this.dgv_MesPlan.ReadOnly = true;
this.dgv_MesPlan.RowHeadersVisible = false;
this.dgv_MesPlan.RowTemplate.Height = 23;
this.dgv_MesPlan.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.dgv_MesPlan.Size = new System.Drawing.Size(1188, 639);
this.dgv_MesPlan.TabIndex = 3;
//
// tab_Order_Exec
//
this.tab_Order_Exec.Controls.Add(this.dgv_ExcutePlan);
this.tab_Order_Exec.Controls.Add(this.label12);
this.tab_Order_Exec.Controls.Add(this.btn_Query);
this.tab_Order_Exec.Controls.Add(this.dtPicker_ProductDate);
this.tab_Order_Exec.Controls.Add(this.txt_OrderNum);
this.tab_Order_Exec.Controls.Add(this.label14);
this.tab_Order_Exec.Location = new System.Drawing.Point(4, 22);
this.tab_Order_Exec.Name = "tab_Order_Exec";
this.tab_Order_Exec.Size = new System.Drawing.Size(1194, 688);
this.tab_Order_Exec.TabIndex = 4;
this.tab_Order_Exec.Text = "订单执行情况浏览";
this.tab_Order_Exec.UseVisualStyleBackColor = true;
//
// dgv_ExcutePlan
//
this.dgv_ExcutePlan.AllowUserToAddRows = false;
this.dgv_ExcutePlan.AllowUserToDeleteRows = false;
this.dgv_ExcutePlan.AllowUserToResizeRows = false;
this.dgv_ExcutePlan.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
this.dgv_ExcutePlan.BackgroundColor = System.Drawing.SystemColors.ButtonHighlight;
this.dgv_ExcutePlan.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgv_ExcutePlan.Location = new System.Drawing.Point(3, 34);
this.dgv_ExcutePlan.Name = "dgv_ExcutePlan";
this.dgv_ExcutePlan.ReadOnly = true;
this.dgv_ExcutePlan.RowHeadersVisible = false;
this.dgv_ExcutePlan.RowTemplate.Height = 23;
this.dgv_ExcutePlan.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.dgv_ExcutePlan.Size = new System.Drawing.Size(1188, 651);
this.dgv_ExcutePlan.TabIndex = 12;
//
// label12
//
this.label12.AutoSize = true;
this.label12.Location = new System.Drawing.Point(9, 12);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(53, 12);
this.label12.TabIndex = 10;
this.label12.Text = "生产日期";
//
// btn_Query
//
this.btn_Query.Font = new System.Drawing.Font("宋体", 9F);
this.btn_Query.Location = new System.Drawing.Point(474, 6);
this.btn_Query.Name = "btn_Query";
this.btn_Query.Size = new System.Drawing.Size(124, 25);
this.btn_Query.TabIndex = 7;
this.btn_Query.Text = "查询";
this.btn_Query.UseVisualStyleBackColor = true;
this.btn_Query.Click += new System.EventHandler(this.btn_Query_Click);
//
// dtPicker_ProductDate
//
this.dtPicker_ProductDate.Location = new System.Drawing.Point(65, 7);
this.dtPicker_ProductDate.Name = "dtPicker_ProductDate";
this.dtPicker_ProductDate.Size = new System.Drawing.Size(200, 21);
this.dtPicker_ProductDate.TabIndex = 8;
//
// txt_OrderNum
//
this.txt_OrderNum.Location = new System.Drawing.Point(318, 7);
this.txt_OrderNum.Name = "txt_OrderNum";
this.txt_OrderNum.Size = new System.Drawing.Size(147, 21);
this.txt_OrderNum.TabIndex = 9;
//
// label14
//
this.label14.AutoSize = true;
this.label14.Location = new System.Drawing.Point(276, 12);
this.label14.Name = "label14";
this.label14.Size = new System.Drawing.Size(41, 12);
this.label14.TabIndex = 11;
this.label14.Text = "订单号";
//
// timer_OnLine_Show
//
this.timer_OnLine_Show.Interval = 5000;
this.timer_OnLine_Show.Tick += new System.EventHandler(this.timer_OnLine_Show_Tick);
//
// FormSAP
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1215, 723);
this.Controls.Add(this.dgv_SpiltPlan_toDay);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Name = "FormSAP";
this.ShowIcon = false;
this.Text = "AMS计划同步程序";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FormSAP_FormClosing);
this.Load += new System.EventHandler(this.FormSAP_Load);
this.dgv_SpiltPlan_toDay.ResumeLayout(false);
this.tab_Main.ResumeLayout(false);
this.tab_Main.PerformLayout();
this.panel8.ResumeLayout(false);
this.panel8.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pb_OnLine_SAP)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pb_OnLine_Sql)).EndInit();
this.tab_QueryMesPlan.ResumeLayout(false);
this.tab_QueryMesPlan.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.dgv_MesPlan)).EndInit();
this.tab_Order_Exec.ResumeLayout(false);
this.tab_Order_Exec.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.dgv_ExcutePlan)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.TabControl dgv_SpiltPlan_toDay;
private System.Windows.Forms.TabPage tab_Main;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Panel panel8;
private System.Windows.Forms.Label label13;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.PictureBox pb_OnLine_SAP;
private System.Windows.Forms.PictureBox pb_OnLine_Sql;
private System.Windows.Forms.Timer timer_OnLine_Show;
private System.Windows.Forms.Button btn_ManualSync;
private System.Windows.Forms.TextBox txt_Err;
private System.Windows.Forms.Label lb_ErrCount;
private System.Windows.Forms.Button btn_ManualCheck;
private System.Windows.Forms.TabPage tab_QueryMesPlan;
private System.Windows.Forms.Button btn_Refresh_MesPlan;
private System.Windows.Forms.DataGridView dgv_MesPlan;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.TabPage tab_Order_Exec;
private System.Windows.Forms.Label label12;
private System.Windows.Forms.Button btn_Query;
private System.Windows.Forms.DateTimePicker dtPicker_ProductDate;
private System.Windows.Forms.TextBox txt_OrderNum;
private System.Windows.Forms.Label label14;
private System.Windows.Forms.DataGridView dgv_ExcutePlan;
private System.Windows.Forms.Label label16;
private System.Windows.Forms.DateTimePicker dtPicker_MES;
private System.Windows.Forms.DateTimePicker dtPicker_SyncDate;
private System.Windows.Forms.CheckBox chk_syncModel;
}
}

296
SAP/SAP_Sync/FormSAP.cs Normal file
View File

@@ -0,0 +1,296 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net.NetworkInformation;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Configuration.ConfigurationManager;
using static System.Windows.Forms.LinkLabel;
/// <summary>
///
/// </summary>
namespace SYNC_SAP_MES
{
/// <summary>
///
/// </summary>
public partial class FormSAP : Form
{
/// <summary>
///
/// </summary>
static string Curr_OrderNo = "";
static string Split_OrderNo = "";
static string Split_Order = "";
/// <summary>
///
/// </summary>
public FormSAP()
{
InitializeComponent();
PP.ConnectionString = AppSettings["ConnectionString"];
timer_OnLine_Show.Enabled = true;
dtPicker_SyncDate.Value = DateTime.Now;
}
/// <summary>
/// 显示通讯状态
/// </summary>
private void Show_OnLineState()
{
//状态显示
OnLineStatus_Check();
OnLineState_C(pb_OnLine_Sql, PP.OnLine_Sql);
OnLineState_C(pb_OnLine_SAP, PP.OnLine_SAP);
}
/// <summary>
/// 显示通讯状态
/// </summary>
/// <param name="pb"></param>
/// <param name="onLine"></param>
private void OnLineState_C(PictureBox pb, bool onLine)
{
pb.Image = onLine ? global::SYNC_SAP_MES.Properties.Resources.
: global::SYNC_SAP_MES.Properties.Resources.;
}
private static bool Ping(string ip)
{
return new Ping().Send(ip).Status == IPStatus.Success ? true : false;
}
public static void OnLineStatus_Check()
{
try
{
PP.OnLine_Sql = SqlOperation.ExecuteSql("select getdate()", out DataTable dt, out string error);
}
catch (Exception err)
{
PP.OnLine_Sql = false;
}
try
{
//PP.OnLine_SAP = READ_SAP.GetMCode().Rows.Count > 0 ? true : false;
PP.OnLine_SAP = Ping("mes4api.weichai.com");
}
catch (Exception err)
{
PP.OnLine_SAP = false;
}
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void timer_OnLine_Show_Tick(object sender, EventArgs e)
{
timer_OnLine_Show.Enabled = false;
Show_OnLineState();
if (!chk_syncModel.Checked && DateTime.Now.Date > dtPicker_SyncDate.Value.Date)
{
dtPicker_SyncDate.Value = DateTime.Now;
SyncFunc_From_SAP.SyncDate = dtPicker_SyncDate.Value.ToString("yyyy-MM-dd");
}
timer_OnLine_Show.Enabled = true;
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btn_ManualSync_Click(object sender, EventArgs e)
{
if (SyncFunc_From_SAP.IsSyncing)
{
PP.main.ShowError("您正在同步计划数据,不能重复操作!");
return;
}
if (MessageBox.Show("确认手动同步计划数据吗?", "确认提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
SyncFunc_From_SAP.SyncDataOperationTask("手动同步");
}
}
/// <summary>
///
/// </summary>
private int count = 0;
/// <summary>
///
/// </summary>
public void ReInit()
{
count = 0;
if (lb_ErrCount.InvokeRequired)
{
lb_ErrCount.Invoke(new Action(delegate ()
{
lb_ErrCount.Text = "消息数量:" + 0.ToString();
}));
}
else
{
lb_ErrCount.Text = "消息数量:" + 0.ToString();
}
if (txt_Err.InvokeRequired)
{
txt_Err.Invoke(new Action(delegate ()
{
txt_Err.Clear();
}));
}
else
{
txt_Err.Clear();
}
}
/// <summary>
///
/// </summary>
/// <param name="s"></param>
public void ShowError(string s)
{
count++;
if (count > 3000) ReInit();
if (lb_ErrCount.InvokeRequired)
{
lb_ErrCount.Invoke(new Action(delegate ()
{
lb_ErrCount.Text = "消息数量:" + count.ToString();
}));
}
else
{
lb_ErrCount.Text = "消息数量:" + count.ToString();
}
if (txt_Err.InvokeRequired)
{
txt_Err.Invoke(new Action(delegate ()
{
txt_Err.AppendText(count.ToString("000000") + " [ " + DateTime.Now.ToString("G") + " ] " + s + "\r\n");
txt_Err.ScrollToCaret();
// SlMesDbIterface.LogRecord.Insert_Log(SlMesDbIterface.LogRecord.Type_Log.Tip, s);
}));
}
else
{
txt_Err.AppendText(count.ToString("000000") + " [ " + DateTime.Now.ToString("G") + " ] " + s + "\r\n");
txt_Err.ScrollToCaret();
// SlMesDbIterface.LogRecord.Insert_Log(SlMesDbIterface.LogRecord.Type_Log.Tip, s);
}
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btn_ManualCheck_Click(object sender, EventArgs e)
{
SyncFunc_From_SAP.OnLineStatus_Check();
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btn_Refresh_MesPlan_Click(object sender, EventArgs e)
{
DateTime SearchDate= dtPicker_MES.Value;
//Sql_Biz_SAP.Get_MesPlan(SearchDate, out DataTable table_Plan);
////Sql_Biz_SAP.Get_MesSpiltPlan(DateTime.Parse("2024-01-04"), out DataTable table_Plan);
//dgv_MesPlan.DataSource = table_Plan;
//var dateDay = dtp_yyyyMMdd.Value;
//var line = txt_Line.Text;
//var table = READ_SAP.GetPlan(dateDay, line);
//dgv_SAPPlan.DataSource = table;
//label_Count_Plan.Text = $"数量:{table.Rows.Count}";
//if (cb_SaveFile.Checked)
//{
// var str = JsonConvert.SerializeObject(table);
// File.WriteAllText("Plan.json", str);
//}
//dgv_SpiltPlan.DataSource=null;
//dgv_MesOrderNo_BOM.DataSource = null;
}
private void FormSAP_Load(object sender, EventArgs e)
{
SyncFunc_From_SAP.SyncTask_SAP();
}
private void btn_ManualSync_Plan_Click(object sender, EventArgs e)
{
}
private void btn_ManualSync_PlanBOM_Click(object sender, EventArgs e)
{
//var dlg = new D_Sure();
//if (dlg.ShowDialog() == DialogResult.OK)
//{
// //3.同步订单BOM
// var success_BOM = SyncFunc_From_SAP.Move_SAP_To_MES_Order_BOM(Curr_OrderNo);
// PP.main.ShowError($"【手动强制】{Curr_OrderNo}订单BOM同步完成\r\n");
// MessageBox.Show("【手动强制】订单BOM同步成功");
//}
}
private void button3_Click_1(object sender, EventArgs e)
{
DateTime startdate = DateTime.Parse("2024-06-11");
//READ_SAP.GetPlan_Test(startdate, "ZP02");
}
private void btn_Query_Click(object sender, EventArgs e)
{
DateTime SearchDate = dtPicker_ProductDate.Value;
var key_OrderNum=this.txt_OrderNum.Text.Trim();
Sql_Biz_SAP.Get_Mes_ExcutePlan(SearchDate, key_OrderNum, out DataTable table_ExcutePlan);
//Sql_Biz_SAP.Get_MesSpiltPlan(DateTime.Parse("2024-01-04"), out DataTable table_Plan);
dgv_ExcutePlan.DataSource = table_ExcutePlan;
}
private void FormSAP_FormClosing(object sender, FormClosingEventArgs e)
{
if (MessageBox.Show("确认退出计划同步程序吗?", "操作确认", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
{
e.Cancel = true;
}
}
private void chk_syncModel_CheckedChanged(object sender, EventArgs e)
{
btn_ManualSync.Enabled= chk_syncModel.Checked;
}
private void dtPicker_SyncDate_ValueChanged(object sender, EventArgs e)
{
SyncFunc_From_SAP.SyncDate=dtPicker_SyncDate.Value.ToString("yyyy-MM-dd");
}
}
}

126
SAP/SAP_Sync/FormSAP.resx Normal file
View File

@@ -0,0 +1,126 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="timer_OnLine_Show.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>7, 6</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>30</value>
</metadata>
</root>

351
SAP/SAP_Sync/HttpCli.cs Normal file
View File

@@ -0,0 +1,351 @@
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
namespace SYNC_SAP_MES
{
public class HttpCli
{
/// <summary>
/// 指定Url地址使用Get 方式获取全部字符串
/// </summary>
/// <param name="url">请求链接地址</param>
/// <returns></returns>
public static string Get(string url)
{
string result = "";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
Stream stream = resp.GetResponseStream();
try
{
//获取内容
using (StreamReader reader = new StreamReader(stream))
{
result = reader.ReadToEnd();
}
}
finally
{
stream.Close();
}
return result;
}
public static void GetFile(string url,string path)
{
WebRequest request = WebRequest.Create(url);
WebResponse response = request.GetResponse();
if (response.ContentType.ToLower().Length > 0)
{
using (Stream reader = response.GetResponseStream())
{
using (FileStream writer = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write))
{
byte[] buffer = new byte[1024];
int c = 0;
while ((c = reader.Read(buffer, 0, buffer.Length)) > 0)
{
writer.Write(buffer, 0, c);
}
}
}
//HttpContext
}
}
public static byte[] GetFile_Bytes(string url)
{
byte[] bytesAll = null;
WebRequest request = WebRequest.Create(url);
WebResponse response = request.GetResponse();
if (response.ContentType.ToLower().Length > 0)
{
using (Stream reader = response.GetResponseStream())
{
MemoryStream ms = new MemoryStream();
byte[] buffer = new byte[1024];
while (true)
{
int sz = reader.Read(buffer, 0, 1024);
if (sz == 0) break;
ms.Write(buffer, 0, sz);
}
bytesAll = ms.ToArray();
}
}
//如是图片
//System.Drawing.Image img = System.Drawing.Image.FromStream(ms);
return bytesAll;
}
public void FGHJ()
{
// Create a 'WebRequest' object with the specified url.
WebRequest myWebRequest = WebRequest.Create("http://www.contoso.com");
// Send the 'WebRequest' and wait for response.
WebResponse myWebResponse = myWebRequest.GetResponse();
// Obtain a 'Stream' object associated with the response object.
Stream ReceiveStream = myWebResponse.GetResponseStream();
Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
// Pipe the stream to a higher level stream reader with the required encoding format.
StreamReader readStream = new StreamReader(ReceiveStream, encode);
Console.WriteLine("\nResponse stream received");
Char[] read = new Char[256];
// Read 256 charcters at a time.
int count = readStream.Read(read, 0, 256);
Console.WriteLine("HTML...\r\n");
while (count > 0)
{
// Dump the 256 characters on a string and display the string onto the console.
String str = new String(read, 0, count);
Console.Write(str);
count = readStream.Read(read, 0, 256);
}
Console.WriteLine("");
// Release the resources of stream object.
readStream.Close();
// Release the resources of response object.
myWebResponse.Close();
}
/// <summary>
/// 发送Get请求
/// </summary>
/// <param name="url">地址</param>
/// <param name="dic">请求参数定义</param>
/// <returns></returns>
public static string Get(string url, Dictionary<string, string> dic)
{
string result = "";
StringBuilder builder = new StringBuilder();
builder.Append(url);
if (dic.Count > 0)
{
builder.Append("?");
int i = 0;
foreach (var item in dic)
{
if (i > 0)
builder.Append("&");
builder.AppendFormat("{0}={1}", item.Key, item.Value);
i++;
}
}
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(builder.ToString());
//添加参数
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
Stream stream = resp.GetResponseStream();
try
{
//获取内容
using (StreamReader reader = new StreamReader(stream))
{
result = reader.ReadToEnd();
}
}
finally
{
stream.Close();
}
return result;
}
/// <summary>
/// 指定Post地址使用Get 方式获取全部字符串
/// </summary>
/// <param name="url">请求后台地址</param>
/// <returns></returns>
public static string Post(string url)
{
string result = "";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
req.Method = "POST";
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
Stream stream = resp.GetResponseStream();
//获取内容
using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
{
result = reader.ReadToEnd();
}
return result;
}
/// <summary>
/// 指定Post地址使用Get 方式获取全部字符串
/// </summary>
/// <param name="url">请求后台地址</param>
/// <returns></returns>
public static string Post(string url, Dictionary<string, string> dic)
{
string result = "";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
#region Post
StringBuilder builder = new StringBuilder();
int i = 0;
foreach (var item in dic)
{
if (i > 0)
builder.Append("&");
builder.AppendFormat("{0}={1}", item.Key, item.Value);
i++;
}
byte[] data = Encoding.UTF8.GetBytes(builder.ToString());
req.ContentLength = data.Length;
using (Stream reqStream = req.GetRequestStream())
{
reqStream.Write(data, 0, data.Length);
reqStream.Close();
}
#endregion
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
Stream stream = resp.GetResponseStream();
//获取响应内容
using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
{
result = reader.ReadToEnd();
}
return result;
}
/// <summary>
/// 指定Post地址使用Get 方式获取全部字符串
/// </summary>
/// <param name="url">请求后台地址</param>
/// <param name="content">Post提交数据内容(utf-8编码的)</param>
/// <returns></returns>
public static string Post(string url, string content)
{
string result = "";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
req.Method = "POST";
req.Headers.Add("token", "factory2"); //如果接口需要鉴权, 把"token"换成自己需要的
req.ContentType = "application/json";
#region Post
byte[] data = Encoding.UTF8.GetBytes(content);
req.ContentLength = data.Length;
using (Stream reqStream = req.GetRequestStream())
{
reqStream.Write(data, 0, data.Length);
reqStream.Close();
}
#endregion
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
Stream stream = resp.GetResponseStream();
//获取响应内容
using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
{
result = reader.ReadToEnd();
}
return result;
}
/// <summary>
/// Http下载文件
/// </summary>
/// <param name="uri">下载地址</param>
/// <param name="filefullpath">存放完整路径(含文件名)</param>
/// <param name="size">每次多的大小</param>
/// <returns>下载操作是否成功</returns>
public static bool DownLoadFiles(string uri, string filefullpath, int size = 1000000)
{
try
{
if (File.Exists(filefullpath))
{
try
{
File.Delete(filefullpath);
}
catch (Exception ex)
{
return false;
}
}
string fileDirectory = System.IO.Path.GetDirectoryName(filefullpath);
if (!Directory.Exists(fileDirectory))
{
Directory.CreateDirectory(fileDirectory);
}
FileStream fs = new FileStream(filefullpath, FileMode.Create);
byte[] buffer = new byte[size];
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uri);
request.Timeout = 100000;
request.AddRange((int)fs.Length);
Stream ns = request.GetResponse().GetResponseStream();
long contentLength = request.GetResponse().ContentLength;
int length = ns.Read(buffer, 0, buffer.Length);
while (length > 0)
{
fs.Write(buffer,0 , length);
buffer = new byte[size];
length = ns.Read(buffer, 0, buffer.Length);
}
fs.Close();
return true;
}
catch (Exception ex)
{
return false;
}
}
}
}

425
SAP/SAP_Sync/PP.cs Normal file
View File

@@ -0,0 +1,425 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace SYNC_SAP_MES
{
public class PP
{
/// <summary>
///
/// </summary>
public static string ConnectionString = "";
/// <summary>
///
/// </summary>
public static string SyncTimePoin_TomorrowPlan = "";
/// <summary>
///
/// </summary>
public static string AppServerHost = "";
/// <summary>
///
/// </summary>
public static string SystemNumber = "";
/// <summary>
///
/// </summary>
public static string User = "";
/// <summary>
///
/// </summary>
public static string Password = "";
/// <summary>
///
/// </summary>
public static string Client = "";
/// <summary>
///
/// </summary>
public static string Language = "";
/// <summary>
///
/// </summary>
public static string PoolSize = "";
/// <summary>
///
/// </summary>
public static string IdleTimeout = "";
/// <summary>
///
/// </summary>
public static string Name = "";
/// <summary>
///
/// </summary>
public static string IsDemo = "";
/// <summary>
///
/// </summary>
public static int ReachSyncCount = 1;
/// <summary>
///
/// </summary>
public static string LineCode = "";
/// <summary>
///
/// </summary>
public static bool OnLine_Sql = false;
/// <summary>
///
/// </summary>
public static bool OnLine_SAP = false;
/// <summary>
///
/// </summary>
public static FormSAP main = null;
}
//入参:
//{
//lineId:"200000502",
//startDate:"2022-06-28",
//isLocked: "3"
//}
public class SyncPlan_WebAPI_RequestBody
{
public string lineId
{
get;
set;
} = "";
public string startDate
{
get;
set;
} = "";
public string isLocked
{
get;
set;
} = "";
}
/*
{
"code": 200,
"message": "操作成功",
"data":
[
{
"productCode": "9922G000244",
"itemCode": "B-DHT14Q0008*01",
"itemId": "-801513",
"productType": "WP14T610E62",
"wipEntityId": "1004124840",
"wipEntityName": "5221052206000018",
"bomHeaderId": "11000656073",
"mesPlanOrder": "282",
"erpStartDate": "2022-06-28 00:00:00.0",
"mesStartDate": null,
"isLocked": "3"
},
{
"productCode": "9922G000243",
"itemCode": "B-DHT14Q0008*01",
"itemId": "-801513",
"productType": "WP14T610E62",
"wipEntityId": "1004124840",
"wipEntityName": "5221052206000018",
"bomHeaderId": "11000656073",
"mesPlanOrder": "283",
"erpStartDate": "2022-06-28 00:00:00.0",
"mesStartDate": null,
"isLocked": "3"
},
]
}
*/
//入参:
// lineId计划产线idstring必填二号厂总装1线120000004
// startDate总装上线扫描时间段的开始时间string必填格式yyyy-mm-dd
// endDate总装上线扫描时间段的结束时间string必填格式yyyy-mm-dd
//{
// "lineId": "120000007",
// "startDate": "2022-06-29 00:00:00",
// "endDate": "2022-06-30 00:00:00"
//}
public class SyncBarCodePlan_WebAPI_RequestBody
{
public string lineId
{
get;
set;
} = "";
public string startDate
{
get;
set;
} = "";
public string endDate
{
get;
set;
} = "";
}
/*
{
"code": 200,
"message": "操作成功",
"data": [
{
"productCode": "1422G024877",
"itemCode": "B-DHP12Q3807*01",
"itemId": "-775264",
"productType": "WP12.460E62",
"wipEntityId": "1004119083",
"wipEntityName": "5222012206061324",
"bomHeaderId": "11000656454",
"mesPlanOrder": "6",
"erpStartDate": "2022-06-29 00:00:00.0",
"mesStartDate": "2022-06-29 07:52:43.0",
"isLocked": null
},
{
"productCode": "1422G024878",
"itemCode": "B-DHP12Q3807*01",
"itemId": "-775264",
"productType": "WP12.460E62",
"wipEntityId": "1004119083",
"wipEntityName": "5222012206061324",
"bomHeaderId": "11000656454",
"mesPlanOrder": "7",
"erpStartDate": "2022-06-29 00:00:00.0",
"mesStartDate": "2022-06-29 07:54:00.0",
"isLocked": null
},
]
}
*/
public class SyncPlan_WebAPI_ResponseBody
{
public string code
{
get;
set;
} = "";
public string message
{
get;
set;
} = "";
public List<SyncPlan_WebAPI_DataParts> Data
{
get;
set;
}
}
public class SyncPlan_WebAPI_DataParts
{
//"productCode": "9922G000243",
//"itemCode": "B-DHT14Q0008*01",
//"itemId": "-801513",
//"productType": "WP14T610E62",
//"wipEntityId": "1004124840",
//"wipEntityName": "5221052206000018",
//"bomHeaderId": "11000656073",
//"mesPlanOrder": "283",
//"erpStartDate": "2022-06-28 00:00:00.0",
//"mesStartDate": null,
//"isLocked": "3"
public string productCode
{
get;
set;
}
public string itemCode
{
get;
set;
}
public string itemId
{
get;
set;
}
public string productType
{
get;
set;
}
public string wipEntityId
{
get;
set;
}
public string wipEntityName
{
get;
set;
}
public string bomHeaderId
{
get;
set;
}
public string mesPlanOrder
{
get;
set;
}
public string erpStartDate
{
get;
set;
}
public string mesStartDate
{
get;
set;
}
public string isLocked
{
get;
set;
}
}
public class RequestBody_WebAPI_Boms
{
public string lineId
{
get;
set;
}
public string productCode
{
get;
set;
}
}
public class ResponseBody_WebAPI_Boms
{
public string code
{
get;
set;
} = "";
public string message
{
get;
set;
} = "";
public List<DataBody_WebAPI_Boms> Data
{
get;
set;
}
}
public class DataBody_WebApi_MisFun
{
public string type
{
get;
set;
}
public string opName
{
get;
set;
}
public string value
{
get;
set;
}
}
public class DataBody_WebAPI_Boms
{
/*
(name="bomHeaderId",value="bom头id")
(name ="materialId",value ="物料id")
(name="materialCode".value="物料编码")
(name="materialName" value="物料名称"
(name="quanity",value="量”
(name="keyFlag",value="是否关键件1是0否")
(name ="operationId",value="工位id")
(name=operationCode,value="工位编码")
(name="assginedSupplierId",value="指定供应商id")
(name="assginedSupplierCode".value="指定供应商code")
*/
public string bomHeaderId
{
get;
set;
}
public string materialId
{
get;
set;
}
public string materialCode
{
get;
set;
}
public string materialName
{
get;
set;
}
public string quanity
{
get;
set;
}
public string keyFlag
{
get;
set;
}
public string operationId
{
get;
set;
}
public string operationCode
{
get;
set;
}
public string assginedSupplierId
{
get;
set;
}
public string assginedSupplierCode
{
get;
set;
}
}
}

View File

@@ -0,0 +1,75 @@
using SYNC_SAP_MES;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
namespace SYNC_SAP_MES
{
public class SqlOperation
{
public static bool ExecuteStoredProcedure(string name, SqlParameter[] sqlParameters, out string errorMessage)
{
return DataLinkMesWork.SQLCommon.ExecuteStoredProcedure(name, PP.ConnectionString, ref sqlParameters, out errorMessage);
}
public static bool ExecuteStoredProcedure(string name, SqlParameter[] sqlParameters, out DataTable dt, out string errorMessage)
{
return DataLinkMesWork.SQLCommon.ExecuteStoredProcedure(name, PP.ConnectionString, ref sqlParameters, out dt, out errorMessage);
}
public static bool ExecuteStoredProcedure(string name, SqlParameter[] sqlParameters, out DataSet ds, out string errorMessage)
{
return DataLinkMesWork.SQLCommon.ExecuteStoredProcedure(name, PP.ConnectionString, ref sqlParameters, out ds, out errorMessage);
}
public static bool ExecuteSql(string sql, out DataTable dt, out string errorMessage)
{
try
{
return DataLinkMesWork.SQLCommon.ExecuteSql(sql, PP.ConnectionString, out dt, out errorMessage);
}
catch (Exception ex) {
dt = null;
errorMessage = ex.Message;
return false;
}
}
public static bool ExecuteSql(string sql, out string errorMessage)
{
return DataLinkMesWork.SQLCommon.ExecuteSql(sql, PP.ConnectionString, out errorMessage);
}
/// <summary>
/// 通过SqlBulkCopy复制table数据到数据库
/// </summary>
/// <param name="dataset"></param>
public static bool SqlbulkcopyInsert(DataTable dt,out string ErrMessage)
{
bool success = false;
ErrMessage = "";
try
{
// SqlBulkCopy sqlbulkcopy = new SqlBulkCopy(connectString, SqlBulkCopyOptions.KeepIdentity);//删除自增ID插入原始数据
SqlBulkCopy sqlbulkcopy = new SqlBulkCopy(PP.ConnectionString, SqlBulkCopyOptions.UseInternalTransaction);//批量事务处理
sqlbulkcopy.DestinationTableName = dt.TableName;//数据库中的表名
for (int i = 0; i < dt.Columns.Count; i++)
{
var columnName = dt.Columns[i].ColumnName.ToString();
sqlbulkcopy.ColumnMappings.Add(columnName, columnName);
}
sqlbulkcopy.WriteToServer(dt);
success = true;
}
catch (Exception err)
{
ErrMessage=err.Message;
}
return success;
}
}
}

303
SAP/SAP_Sync/Sql_Biz_SAP.cs Normal file
View File

@@ -0,0 +1,303 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace SYNC_SAP_MES
{
public class Sql_Biz_SAP
{
/// <summary>
///
/// </summary>
public static void LoadConfig()
{
var sql =
$" SELECT TOP 1 [AID],[AppServerHost],[SystemNumber],[User],[Password],[Client]" +
$",[Language],[PoolSize],[IdleTimeout],[Name],[SystemType],[Enable]" +
$",[IsDemo],[ReachSyncCount],[LineCode]" +
$" FROM [大柴_接口_SAP登录信息]" +
$" WHERE [Enable] = 'True'";
DataLinkMesWork.SQLCommon.ExecuteDataTable(sql, PP.ConnectionString, out DataTable dt, out string err);
if (dt.Rows.Count > 0)
{
var row = dt.Rows[0];
PP.AppServerHost = row["AppServerHost"].ToString();
PP.SystemNumber = row["SystemNumber"].ToString();
PP.User = row["User"].ToString();
PP.Password = row["Password"].ToString();
PP.Client = row["Client"].ToString();
PP.Language = row["Language"].ToString();
PP.PoolSize = row["PoolSize"].ToString();
PP.IdleTimeout = row["IdleTimeout"].ToString();
PP.Name = row["Name"].ToString();
PP.IsDemo = row["IsDemo"].ToString();
PP.ReachSyncCount = Convert.ToInt32(row["ReachSyncCount"]);
PP.LineCode = row["LineCode"].ToString();
}
}
/// <summary>
///
/// </summary>
/// <param name="date"></param>
/// <param name="dateTime"></param>
/// <returns></returns>
public static bool Select_SyncParam_SAP(out string date, out string dateTime)
{
bool success = false;
date = "";
dateTime = "";
//SELECT top 1 [AID],[日期],[更新时间] FROM [大柴_接口_SAP生产计划_标记]
var sql = "SELECT top 1 [AID],[日期],[更新时间] FROM [大柴_接口_SAP生产计划_标记]";
success = DataLinkMesWork.SQLCommon.ExecuteDataTable(sql, PP.ConnectionString, out DataTable dt, out string err);
success = err.Length > 0 ? false : true;
if (dt.Rows.Count > 0)
{
date = DateTime.Parse(dt.Rows[0]["日期"].ToString()).ToString("yyyy-MM-dd");
dateTime = DateTime.Parse(dt.Rows[0]["更新时间"].ToString()).ToString("yyyy-MM-dd HH:mm:ss.fff");
}
else
{
var sql_Insert =
$" INSERT INTO [大柴_接口_SAP生产计划_标记]([日期],[修改时间])" +
$" VALUES(getdate(),getdate())";
DataLinkMesWork.SQLCommon.ExecuteSql(sql_Insert, PP.ConnectionString, out string err_Index);
Select_SyncParam_SAP(out date, out dateTime);
}
return success;
}
/// <summary>
///
/// </summary>
/// <param name="date"></param>
/// <returns></returns>
public static bool Update_SyncParam_SAP(string date)
{
//SELECT top 1 [AID],[日期],[更新时间] FROM [大柴_接口_SAP生产计划_标记]
var sql =
$" UPDATE [大柴_接口_SAP生产计划_标记]" +
$" SET [日期] = '{date}',[更新时间] = getdate()";
return DataLinkMesWork.SQLCommon.ExecuteSql(sql, PP.ConnectionString, out string err);
}
/// <summary>
///
/// </summary>
/// <param name="startFlowNo"></param>
/// <param name="flowNoTime"></param>
/// <returns></returns>
public static bool Select_SyncParam_FlowNo(out int startFlowNo,out string flowNoTime)
{
bool success = false;
startFlowNo = 0;
flowNoTime = "";
//SELECT [AID],[流水号],[更新时间] FROM [大柴_接口_SAP生产计划_流水号]
var sql = $"SELECT top 1 [AID],[流水号],[更新时间] FROM [大柴_接口_SAP生产计划_流水号] ORDER BY 更新时间 DESC";
success = DataLinkMesWork.SQLCommon.ExecuteDataTable(sql, PP.ConnectionString, out DataTable dt, out string err);
success = err.Length > 0 ? false : true;
if (dt.Rows.Count > 0)
{
startFlowNo = Convert.ToInt32(dt.Rows[0]["流水号"]);
flowNoTime = DateTime.Parse(dt.Rows[0]["更新时间"].ToString()).ToString("yyyy-MM-dd HH:mm:ss.fff");
}
return success;
}
/// <summary>
/// 根据上线日期获取到 这天的流水号,若这天没有则用【历史最大】流水号
/// </summary>
/// <param name="上线日期"></param>
/// <param name="startFlowNo"></param>
/// <param name="flowNoTime"></param>
/// <returns></returns>
public static bool Select_SyncParam_FlowNo(string useDate,out int startFlowNo, out string flowNoTime)
{
bool success = false;
startFlowNo = 0;
flowNoTime = "";
//SELECT [AID],[流水号],[更新时间] FROM [大柴_接口_SAP生产计划_流水号]
var sql = $"SELECT top 1 [AID],[流水号],[更新时间] FROM [大柴_接口_SAP生产计划_流水号] WHERE 使用日期 = '{useDate}'";
//var sql = $"SELECT top 1 [AID],[流水号],[更新时间] FROM [大柴_接口_SAP生产计划_流水号] ORDER BY 使用时间 ASC";
success = DataLinkMesWork.SQLCommon.ExecuteDataTable(sql, PP.ConnectionString, out DataTable dt, out string err);
success = err.Length > 0 ? false : true;
if (dt.Rows.Count > 0)
{
startFlowNo = Convert.ToInt32(dt.Rows[0]["流水号"]);
flowNoTime = DateTime.Parse(dt.Rows[0]["更新时间"].ToString()).ToString("yyyy-MM-dd HH:mm:ss.fff");
}
else
{
// 获取前一天的流水号 用这个流水号往下排
DateTime date = DateTime.ParseExact(useDate, "yyyy-MM-dd", CultureInfo.InvariantCulture);
DateTime previousDay = date.AddDays(-1); // 获取前一天的日期
string formattedDate = previousDay.ToString("yyyy-MM-dd"); // 格式化为字符串形式
var sql2 = $"SELECT top 1 [AID],[流水号],[更新时间] FROM [大柴_接口_SAP生产计划_流水号] WHERE 使用日期 <= '{formattedDate}' ORDER BY [流水号] DESC";
success = DataLinkMesWork.SQLCommon.ExecuteDataTable(sql2, PP.ConnectionString, out DataTable dt2, out string err2);
success = err2.Length > 0 ? false : true;
if (dt2.Rows.Count > 0)
{
startFlowNo = Convert.ToInt32(dt2.Rows[0]["流水号"]);
flowNoTime = DateTime.Parse(dt2.Rows[0]["更新时间"].ToString()).ToString("yyyy-MM-dd HH:mm:ss.fff");
}
}
return success;
}
/// <summary>
///
/// </summary>
/// <param name="FlowNo"></param>
/// <returns></returns>
public static bool GetFlowNo_CurrMax(out string FlowNo)
{
var success = false;
FlowNo = "-1";
var sql =
$" SELECT MAX([发动机流水号]) FROM [大柴_接口_SAP生产计划_执行计划]";
success = SqlOperation.ExecuteSql(sql, out DataTable dt, out string error);
if (dt.Rows.Count > 0)
{
FlowNo = dt.Rows[0][0].ToString();
}
return success;
}
/// <summary>
/// 获取今天明天两天的订单信息
/// </summary>
/// <param name="dateDay"></param>
/// <param name="table_Plan"></param>
/// <returns></returns>
public static bool Get_MesPlan(DateTime dateDay,out DataTable table_Plan)
{
TimeSpan oneDay = new TimeSpan(1, 0, 0, 0); // 创建一个表示一天的 TimeSpan 对象
//var sql = $"SELECT [AID],[订单号],[订单类型],[工厂],[机型号],[数量],[单位],[上线日期],[上线序号],[用户],[修改时间]" +
// $" FROM [大柴_接口_SAP生产计划]" +
// $" WHERE [上线日期] >= '{dateDay.ToString("yyyy-MM-dd")}'" + //OR [上线日期] = '{tomorrow.ToString("yyyy-MM-dd")}'
// $" ORDER BY [上线日期] ,[上线序号]";
var sql = $"SELECT a.[订单号],[订单类型],[工厂],[机型号],[数量],[单位],[上线日期],[上线序号],[用户],[修改时间],isnull(b.Exist_InMes,0) as Exist_InMes" +
$" FROM [大柴_接口_SAP生产计划] a left join " +
$" (select 订单号,count(*) as Exist_InMes from 大柴_接口_SAP生产计划_执行计划 where 生产日期>='{dateDay.ToString("yyyy-MM-dd")}' group by 订单号) b on a.订单号=b.订单号 " +
$" WHERE [上线日期] >= '{dateDay.ToString("yyyy-MM-dd")}'" + //OR [上线日期] = '{tomorrow.ToString("yyyy-MM-dd")}'
$" ORDER BY [上线日期] ,[上线序号]";
return DataLinkMesWork.SQLCommon.ExecuteDataTable(sql, PP.ConnectionString, out table_Plan, out string err);
}
public static bool Get_Mes_ExcutePlan(DateTime dateDay,string key_OrderNum,out DataTable table_Plan)
{
var sql = $@"
SELECT [订单类型],[订单号],[机型号],[订单数量],[生产日期],[上线序号],[上线总排序],[发动机流水号],[起始流水号],[终止流水号],[执行状态]
FROM[大柴_接口_SAP生产计划_执行计划] WHERE 生产日期 = '{dateDay.ToString("yyyy-MM-dd")}' AND 订单号 LIKE '%{key_OrderNum}%'";
return DataLinkMesWork.SQLCommon.ExecuteDataTable(sql, PP.ConnectionString, out table_Plan, out string err);
}
/// <summary>
/// 只获取今天的订单信息
/// </summary>
/// <param name="dateDay"></param>
/// <param name="table_Plan"></param>
/// <returns></returns>
public static bool Get_MesTodayPlan(DateTime dateDay, out DataTable table_Plan)
{
//SELECT [AID],[订单号],[订单类型],[工厂],[机型号],[数量],[单位],[上线日期],[上线序号],[用户],[修改时间] FROM [大柴_接口_SAP生产计划]
var sql = $"SELECT [AID],[订单号],[订单类型],[工厂],[机型号],[数量],[单位],[上线日期],[上线序号],[用户],[修改时间],isnull([流水号拆分已上报],0) as 流水号拆分已上报" +
$" FROM [大柴_接口_SAP生产计划]" +
$" WHERE [上线日期] = '{dateDay.ToString("yyyy-MM-dd")}'" +
$" ORDER BY [上线序号]";
return DataLinkMesWork.SQLCommon.ExecuteDataTable(sql, PP.ConnectionString, out table_Plan, out string err);
}
/// <summary>
/// 更新订单的流水号拆分上报状态:流水号拆分已上报=0未上报流水号拆分已上报=1 已上报
/// </summary>
/// <param name="OrderNum"></param>
/// <returns></returns>
public static bool Update_FlowNoSplit_UpLoadState(string OrderNum)
{
//SELECT [AID],[订单号],[订单类型],[工厂],[机型号],[数量],[单位],[上线日期],[上线序号],[用户],[修改时间] FROM [大柴_接口_SAP生产计划]
var sql = $"Update [大柴_接口_SAP生产计划] set 流水号拆分已上报=1 WHERE [订单号] = '{OrderNum}'";
return SqlOperation.ExecuteSql(sql, out string error);
}
/// <summary>
/// 获取拆分后数据 展示到网页
/// </summary>
/// <param name="dateDay">数据日期</param>
/// <param name="table_Plan"></param>
/// <returns></returns>
public static bool Get_MesSpiltPlan(DateTime dateDay, out DataTable table_Plan)
{
var sql = $"SELECT [AID],[订单类型],[生产日期],[班次],[上线序号],[上线总排序],[发动机流水号],[机型号],[托盘号],[订单号],[订单序号],[订单数量],[起始流水号],[终止流水号],[创建时间],[执行状态],[状态变更时间],[操作标记]" +
$" FROM [大柴_接口_SAP生产计划_执行计划]" +
$" WHERE [生产日期] = '{dateDay.ToString("yyyy-MM-dd")}'" +
$" ORDER BY 起始流水号";
return DataLinkMesWork.SQLCommon.ExecuteDataTable(sql, PP.ConnectionString, out table_Plan, out string err);
}
public static bool Get_MesPlan_ExecPlan(string orderNo, out DataTable table_ExecPlan)
{
var sql = $"SELECT [订单号],[订单类型],[机型号],[订单数量],[发动机流水号],[上线序号],[上线总排序],[执行状态],[生产日期]" +
$" FROM [大柴_接口_SAP生产计划_执行计划]" +
$" WHERE [订单号] = '{orderNo}'" +
$" ORDER BY [上线总排序]";
return DataLinkMesWork.SQLCommon.ExecuteDataTable(sql, PP.ConnectionString, out table_ExecPlan, out string err);
}
public static DateTime Get_BOMChanged_DateFlag(string LineCode)
{
var sql = $"SELECT [编辑时间标识] FROM [大柴_接口_SAP订单BOM_编辑时间标识] WHERE [LineCode]='{LineCode}'";
DataLinkMesWork.SQLCommon.ExecuteDataTable(sql, PP.ConnectionString, out DataTable dt, out string err);
if(dt.Rows.Count>0)
{
return DateTime.Parse(dt.Rows[0]["编辑时间标识"].ToString());
}
else
{
return DateTime.Now.AddDays(-10);
}
}
public static void Update_TimeFlag_BomChanged(DateTime NewTimeFlag,string LineCode)
{
var name = "Event_接口_SAP订单BOM_时间标识";
var sqlParameters = new SqlParameter[] {
new SqlParameter("@NewTimeFlag", NewTimeFlag),
new SqlParameter("@LineCode", LineCode)
};
SqlOperation.ExecuteStoredProcedure(name, sqlParameters, out DataSet ds, out string error);
}
public static bool Get_MesBOM_ByOrderNo(string orderNo, out DataTable table_BOM)
{
var sql = $"SELECT [订单号],[工序号],[物料号],[物料描述],[总数量],[指定厂家代码],[指定厂家简称],[指定厂家名称],[工艺合件]," +
$"[虚拟件],[试装标识],[单台数量],[创建时间] FROM [大柴_接口_SAP订单BOM] where 订单号 = {orderNo}";
return DataLinkMesWork.SQLCommon.ExecuteDataTable(sql, PP.ConnectionString, out table_BOM, out string err);
}
}
}

View File

@@ -0,0 +1,425 @@
using Newtonsoft.Json;
using SYNC_SAP_MES;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net.NetworkInformation;
using System.Runtime.InteropServices.ComTypes;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml.Linq;
/// <summary>
/// SlMesDbIterface
/// </summary>
namespace SYNC_SAP_MES
{
/// <summary>
/// SyncFunc_From_SAP
/// </summary>
public class SyncFunc_From_SAP
{
/// <summary>
/// 同步的年月日
/// </summary>
public static string SyncDate = "";
/// <summary>
/// 同步的变更时间
/// </summary>
public static string SyncTime = "";
/// <summary>
/// 发动机要生成流水号的起始流水号
/// </summary>
public static int EngineFlowNo = 0;
/// <summary>
/// 发动机要生成流水号的起始流水号
/// 的变更时间
/// </summary>
public static string EngineFlowNoTime = "";
/// <summary>
/// 当前次数,用于刷新计数
/// </summary>
public static int CurrCount = 0;
/// <summary>
/// 同步中...
/// </summary>
public static bool IsSyncing = false;
/// <summary>
/// 同步执行任务
/// </summary>
public static void SyncTask_SAP()
{
//new Thread(new ThreadStart(delegate ()
//{
// while (true)
// {
// try
// {
// if (CurrCount <= 0)
// {
// SyncFunc_From_SAP.SyncDataOperationTask("设定时间");
// CurrCount = PP.ReachSyncCount;
// }
// CurrCount--;
// }
// catch (Exception) { }
// Thread.Sleep(1000 * 60 * 60); //10分钟
// }
//}))
//{ IsBackground = true }.Start();
new Thread(new ThreadStart(delegate ()
{
while (true)
{
try
{
SyncFunc_From_SAP.SyncBarCodeDataOperationTask("周期执行");
}
catch (Exception) { }
Thread.Sleep(1000 * 1); //1秒
}
}))
{ IsBackground = true }.Start();
}
/// <summary>
/// SyncGuide
/// </summary>
/// <param name="call"></param>
public static void SyncDataOperationTask(object call)
{
var mode = (string)call;
if (IsSyncing == false)
{
IsSyncing = true;
try
{
var dt_01 = DateTime.Now;
PP.main.ShowError($"[{mode}]AMS开始同步...");
Move_Mes_DataOperation();
var dt_02 = DateTime.Now;
PP.main.ShowError($"[{mode}]AMS已完成一次同步总耗时{(dt_02 - dt_01).TotalMilliseconds.ToString("0.")} ms");
PP.main.ShowError($"");
PP.main.ShowError($"\r\n");
}
catch (Exception err)
{
PP.main.ShowError($"AMS数据同步出错{err.Message}");
}
IsSyncing = false;
}
else
{
PP.main.ShowError("您正在同步操作,不能重复操作!");
}
}
/// <summary>
/// SyncBarCodeGuide
/// </summary>
/// <param name="call"></param>
public static void SyncBarCodeDataOperationTask(object call)
{
var mode = (string)call;
if (IsSyncing == false)
{
IsSyncing = true;
try
{
var dt_01 = DateTime.Now;
//PP.main.ShowError($"[{mode}]AMS开始同步...");
Move_Mes_BarCode_DataOperation();
var dt_02 = DateTime.Now;
//PP.main.ShowError($"[{mode}]AMS已完成一次同步总耗时{(dt_02 - dt_01).TotalMilliseconds.ToString("0.")} ms");
//PP.main.ShowError($"");
//PP.main.ShowError($"\r\n");
}
catch (Exception err)
{
PP.main.ShowError($"AMS扫码数据同步出错{err.Message}");
}
IsSyncing = false;
}
else
{
PP.main.ShowError("您正在扫码数据同步操作,不能重复操作!");
}
}
/// <summary>
/// SyncBarCode
/// </summary>
private static void Move_Mes_BarCode_DataOperation()
{
//OnLineStatus_Check();
//lineId计划产线idstring必填如一号厂总装线120000001
//startDate计划开始时间date必填
//isLocked计划状态是否已锁定1代表未锁定3代表已锁定非必填
var LineID = "120000001";
//var StartDate = "2022-06-28";
var StartDate = SyncDate;
var isLocked = "3";
try
{
//StartDate = "2024-09-06";
var PlanData_From_SAP = CALL_Interfalce_WebAPI.Get_BarCode_Plans_ByWebAPI(LineID, StartDate);
var res = Sync_BarCode_ProductPlan_To_AMS(LineID, StartDate, PlanData_From_SAP);
}
catch (Exception err)
{
PP.main.ShowError($"【{LineID}_{StartDate}】生产计划读取失败,{err.Message}");
}
}
/// <summary>
/// Sync
/// </summary>
private static void Move_Mes_DataOperation()
{
//OnLineStatus_Check();
//lineId计划产线idstring必填如一号厂总装线120000001
//startDate计划开始时间date必填
//isLocked计划状态是否已锁定1代表未锁定3代表已锁定非必填
var LineID = "120000001";
//var StartDate = "2022-06-28";
var StartDate = SyncDate;
var isLocked = "3";
try
{
//StartDate = "2024-09-09";
var PlanData_From_SAP = CALL_Interfalce_WebAPI.Get_Plans_ByWebAPI(LineID, StartDate, isLocked);
var res = Sync_ProductPlan_To_AMS(LineID, StartDate, PlanData_From_SAP);
}
catch (Exception err)
{
PP.main.ShowError($"【{LineID}_{StartDate}】生产计划读取失败,{err.Message}");
}
}
public static bool Sync_ProductPlan_To_AMS(string LineID,string startDate, SyncPlan_WebAPI_ResponseBody PlanData)
{
var res_success = PlanData.code == "200" ? true : false;
var res_Message = PlanData.message;
if (res_success)
{
/*
(name = "productCode", value = "发动机编号")
(name = "itemCode", value = "订货号")
(name = "itemId", value = "订货号Id")
(name = "productType", value = "机型")
(name = "wipEntityId", value = "工单ID")
(name = "wipEntityName", value = "工单号")
(name = "bomHeaderId", value = "bom头id")
(name = "mesPlanOrder", value = "mes计划顺序")
(name = "erpStartDate", value = "计划开始时间")
(name = " mesStartDate", value = "总装上线扫描时间")
(name = "isLocked", value = "计划状态")
*/
var min_EngineNo = PlanData.Data.Min(s=>s.productCode);
var max_EngineNo = PlanData.Data.Max(s=>s.productCode);
var sql_AMS_Plan = $" SELECT [发动机编号],[订货号],[订货号ID],[机型号],[工单ID],[工单号],[BOM头ID],[MES计划顺序],[计划开始时间]," +
$"[总装上线扫描时间],[计划状态],[计划同步时间],[执行状态],[LineID],[AMS计划顺序] FROM [潍柴_接口_生产计划_执行计划] " +
$" where [发动机编号] >='{min_EngineNo}' and [发动机编号] <='{max_EngineNo}' order by AID";
SqlOperation.ExecuteSql(sql_AMS_Plan, out DataTable dt_PlanInAMS, out string err1);
DataTable dt_NewPlans = dt_PlanInAMS.Clone();
dt_NewPlans.TableName = "潍柴_接口_生产计划_执行计划";
int maxSort = Get_AMS_MaxSort();
for (int i = 0; i < PlanData.Data.Count; i++)
{
var check_ifExist = dt_PlanInAMS.Select($"发动机编号='{PlanData.Data[i].productCode}'");
if (check_ifExist.Length > 0)
{
continue;
}
DataRow newPlan= dt_NewPlans.NewRow();
newPlan["发动机编号"] = PlanData.Data[i].productCode;
newPlan["订货号"] = PlanData.Data[i].itemCode;
newPlan["订货号ID"] = PlanData.Data[i].itemId;
newPlan["机型号"] = PlanData.Data[i].productType;
newPlan["工单ID"] = PlanData.Data[i].wipEntityId;
newPlan["工单号"] = PlanData.Data[i].wipEntityName;
newPlan["BOM头ID"] = PlanData.Data[i].bomHeaderId;
newPlan["MES计划顺序"] = PlanData.Data[i].mesPlanOrder;
newPlan["计划开始时间"] = PlanData.Data[i].erpStartDate;
if(PlanData.Data[i].mesStartDate != null) newPlan["总装上线扫描时间"] = PlanData.Data[i].mesStartDate;
newPlan["计划状态"] = PlanData.Data[i].isLocked;
newPlan["计划同步时间"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
newPlan["执行状态"] = 1;
newPlan["LineID"] = LineID;
newPlan["AMS计划顺序"] = maxSort + i;
dt_NewPlans.Rows.Add(newPlan);
}
if (dt_NewPlans.Rows.Count > 0)
{
SqlOperation.SqlbulkcopyInsert(dt_NewPlans, out string err);
SqlOperation.ExecuteSql($"update 潍柴_接口_生产计划_标记 set [日期]='{startDate}',[更新时间]='{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}'", out string err2);
if (err.Length==0) PP.main.ShowError($"【{LineID}_{startDate}】计划数据读取成功!新增数量【{dt_NewPlans.Rows.Count}】\r\n");
else PP.main.ShowError($"【{LineID}_{startDate}】计划数据读取失败,{res_Message}");
}
else PP.main.ShowError($"【{LineID}_{startDate}】计划数据读取成功!新增数量【{dt_NewPlans.Rows.Count}】\r\n");
return true;
}
else
{
PP.main.ShowError($"【{LineID}_{startDate}】生产计划读取失败,{res_Message}");
return false;
}
}
public static int Get_AMS_MaxSort()
{
var sql = $" SELECT max(AMS计划顺序 + 1) as maxSort FROM 潍柴_接口_生产计划_执行计划";
SqlOperation.ExecuteSql(sql, out DataTable maxSortDt, out string err1);
int maxSort = Convert.ToInt32(maxSortDt.Rows[0]["maxSort"]);
return maxSort;
}
public static bool Sync_BarCode_ProductPlan_To_AMS(string LineID, string startDate, SyncPlan_WebAPI_ResponseBody PlanData)
{
var res_success = PlanData.code == "200" ? true : false;
var res_Message = PlanData.message;
if (res_success)
{
/*
(name = "productCode", value = "发动机编号")
(name = "itemCode", value = "订货号")
(name = "itemId", value = "订货号Id")
(name = "productType", value = "机型")
(name = "wipEntityId", value = "工单ID")
(name = "wipEntityName", value = "工单号")
(name = "bomHeaderId", value = "bom头id")
(name = "mesPlanOrder", value = "mes计划顺序")
(name = "erpStartDate", value = "计划开始时间")
(name = "mesStartDate", value = "总装上线扫描时间段的开始时间")
(name = "isLocked", value = "计划状态")
*/
var min_EngineNo = PlanData.Data.Min(s => s.productCode);
var max_EngineNo = PlanData.Data.Max(s => s.productCode);
string inWhere = "(";
if (PlanData.Data.Count > 0) {
PlanData.Data.ForEach(item =>
{
inWhere = inWhere += $"'{item.productCode}',";
});
inWhere = inWhere.Remove(inWhere.Length - 1) + ")";
}
int maxSort = Get_AMS_MaxSort();
var sql_AMS_Plan = $" SELECT [发动机编号],[订货号],[订货号ID],[机型号],[工单ID],[工单号],[BOM头ID],[MES计划顺序],[计划开始时间]," +
$"[总装上线扫描时间],[计划状态],[计划同步时间],[执行状态],[LineID],[AMS计划顺序] FROM [潍柴_接口_生产计划_执行计划] " +
$" where [发动机编号] in {inWhere} order by AID";
SqlOperation.ExecuteSql(sql_AMS_Plan, out DataTable dt_PlanInAMS, out string err1);
DataTable dt_NewPlans = dt_PlanInAMS.Clone();
dt_NewPlans.TableName = "潍柴_接口_生产计划_执行计划";
for (int i = 0; i < PlanData.Data.Count; i++)
{
var check_ifExist = dt_PlanInAMS.Select($"发动机编号='{PlanData.Data[i].productCode}'");
if (check_ifExist.Length > 0)
{
continue;
}
DataRow newPlan = dt_NewPlans.NewRow();
newPlan["发动机编号"] = PlanData.Data[i].productCode;
newPlan["订货号"] = PlanData.Data[i].itemCode;
newPlan["订货号ID"] = PlanData.Data[i].itemId;
newPlan["机型号"] = PlanData.Data[i].productType;
newPlan["工单ID"] = PlanData.Data[i].wipEntityId;
newPlan["工单号"] = PlanData.Data[i].wipEntityName;
newPlan["BOM头ID"] = PlanData.Data[i].bomHeaderId;
newPlan["MES计划顺序"] = PlanData.Data[i].mesPlanOrder;
newPlan["计划开始时间"] = PlanData.Data[i].erpStartDate;
if (PlanData.Data[i].mesStartDate != null) newPlan["总装上线扫描时间"] = PlanData.Data[i].mesStartDate;
newPlan["计划状态"] = PlanData.Data[i].isLocked;
newPlan["计划同步时间"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
newPlan["执行状态"] = 1;
newPlan["LineID"] = LineID;
newPlan["AMS计划顺序"] = maxSort;
maxSort++;
dt_NewPlans.Rows.Add(newPlan);
}
if (dt_NewPlans.Rows.Count > 0)
{
SqlOperation.SqlbulkcopyInsert(dt_NewPlans, out string err);
SqlOperation.ExecuteSql($"update 潍柴_接口_生产计划_标记 set [日期]='{startDate}',[更新时间]='{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}'", out string err2);
if (err.Length == 0)
{
PP.main.ShowError($"【{LineID}_{startDate}】计划数据读取成功!新增数量【{dt_NewPlans.Rows.Count}】");
// 发送给MisFun接口 重新申请上线 接受反馈值记录到日志
SyncPlan_WebAPI_ResponseBody res = CALL_Interfalce_WebAPI.Put_MisFun_ByWebAPI("1","OP3020");
if(res.code == "200") PP.main.ShowError($"【自动申请上线成功】Code:{res.code} msg:{res.message}\r\n");
else PP.main.ShowError($"【自动申请上线失败】Code:{res.code} msg:{res.message}\r\n");
}
else PP.main.ShowError($"【{LineID}_{startDate}】计划数据读取失败,{res_Message}");
}
//else PP.main.ShowError($"【{LineID}_{startDate}】计划数据读取成功!新增数量【{dt_NewPlans.Rows.Count}】\r\n");
return true;
}
else
{
PP.main.ShowError($"【{LineID}_{startDate}】生产计划读取失败,{res_Message}");
return false;
}
}
/// <summary>
/// 检查在线状态
/// </summary>
public static void OnLineStatus_Check()
{
try
{
PP.OnLine_Sql = SqlOperation.ExecuteSql("select getdate()", out DataTable dt, out string error);
}
catch (Exception err)
{
PP.OnLine_Sql = false;
}
try
{
//PP.OnLine_SAP = READ_SAP.GetMCode().Rows.Count > 0 ? true : false;
PP.OnLine_SAP = Ping("mes4api.weichai.com");
}
catch (Exception err)
{
PP.OnLine_SAP = false;
}
}
private static bool Ping(string ip)
{
return new Ping().Send(ip).Status == IPStatus.Success ? true : false;
}
}
}