chore: 初始化东安动力MES采集程序
This commit is contained in:
25
MIS_FuntionSaveData/MIS_FuntionSaveData.sln
Normal file
25
MIS_FuntionSaveData/MIS_FuntionSaveData.sln
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.32901.82
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MIS_FuntionSaveData", "MIS_FuntionSaveData\MIS_FuntionSaveData.csproj", "{55B510C1-59E9-4BFD-AE84-D76D46F6E365}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{55B510C1-59E9-4BFD-AE84-D76D46F6E365}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{55B510C1-59E9-4BFD-AE84-D76D46F6E365}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{55B510C1-59E9-4BFD-AE84-D76D46F6E365}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{55B510C1-59E9-4BFD-AE84-D76D46F6E365}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {A8F630BE-FDC2-40FF-8EAE-917E83ABAB6F}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,96 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{55B510C1-59E9-4BFD-AE84-D76D46F6E365}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>MIS_FuntionSaveData</RootNamespace>
|
||||
<AssemblyName>MIS_FuntionSaveData</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="MQTTnet, Version=3.0.15.0, Culture=neutral, PublicKeyToken=b69712f52770c0a7, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\Common\dll\MQTTnet.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MQTTnet.Extensions.ManagedClient, Version=3.0.15.0, Culture=neutral, PublicKeyToken=b69712f52770c0a7, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\Common\dll\MQTTnet.Extensions.ManagedClient.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Funtion.Alarm.cs" />
|
||||
<Compile Include="Funtion.EngTypeGetOver.cs" />
|
||||
<Compile Include="Funtion.MesRead.cs" />
|
||||
<Compile Include="Funtion.WorkStart.cs" />
|
||||
<Compile Include="MIS_Funtion.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Common\00-1Json8.3\Json8.3\00-0Json8.3.1.csproj">
|
||||
<Project>{1a10fdb2-1a6a-44a8-ab4d-33387563247e}</Project>
|
||||
<Name>00-0Json8.3.1</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Common\00MesWorkMqtt\MesWorkMqtt\00MesWorkMqtt.csproj">
|
||||
<Project>{f55da1a0-a982-4479-8c47-0d9a5aaf3e18}</Project>
|
||||
<Name>00MesWorkMqtt</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Common\01DoWhatPlc\01_01DoWhatPlc.csproj">
|
||||
<Project>{0d1af432-439a-4920-8692-43ae139f5530}</Project>
|
||||
<Name>01_01DoWhatPlc</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Common\04DataBaseAccess\DataBaseAccess\04-DataBaseAccess.csproj">
|
||||
<Project>{f434e066-4c59-47c8-aa82-6f48cc84501a}</Project>
|
||||
<Name>04-DataBaseAccess</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Common\07WebBusinessFacade\BusinessFacade\07BusinessFacade.csproj">
|
||||
<Project>{f0a0c525-03fd-428a-9b17-7f54aa0e4475}</Project>
|
||||
<Name>07BusinessFacade</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Common\08WebFun_base\WebFun_base\08-WebFun_base.csproj">
|
||||
<Project>{d98be764-adeb-488d-9714-61e308aa8201}</Project>
|
||||
<Name>08-WebFun_base</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Common\09MesDataFunction\MesDataFunction\09-MesDataFunction.csproj">
|
||||
<Project>{90e76fb4-646d-45e2-95db-0b8ab4e465d6}</Project>
|
||||
<Name>09-MesDataFunction</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\MisDataFun\SendMessageToWebMqtt\12SendMessageToWeb.csproj">
|
||||
<Project>{E4EB6420-906D-4672-947A-CA33DDCDADFC}</Project>
|
||||
<Name>12SendMessageToWeb</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
187
MIS_FuntionSaveData/MIS_FuntionSaveData/Funtion.Alarm.cs
Normal file
187
MIS_FuntionSaveData/MIS_FuntionSaveData/Funtion.Alarm.cs
Normal file
@@ -0,0 +1,187 @@
|
||||
using bizFacade;
|
||||
using DataLinkMesWork;
|
||||
using DoWhatPlc;
|
||||
using MesServerFunctions;
|
||||
using MesServerWork;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MisDataSaveDate
|
||||
{
|
||||
public partial class FuntionMesRead
|
||||
{
|
||||
|
||||
#region 2023.05.14,新增报警
|
||||
|
||||
public static Hashtable Base_TagIdList = new Hashtable();
|
||||
|
||||
|
||||
public static void GetAlarmInit()
|
||||
{
|
||||
Base_TagIdList.Clear();
|
||||
GetTagIdList("", out DataTable dt);
|
||||
|
||||
for (int i = 0; i < dt.Rows.Count; i++)
|
||||
{
|
||||
string tagid = dt.Rows[i]["TagID"].ToString();
|
||||
|
||||
if (tagid[0].ToString() == "9")
|
||||
{
|
||||
var opName = dt.Rows[i]["工位号"].ToString();
|
||||
var ItemName = dt.Rows[i]["测量项目"].ToString();
|
||||
var ShaftID = dt.Rows[i]["测量位置"].ToString();
|
||||
|
||||
string SendMessage = "MES|PlcAlarm|" + opName + "|" + tagid + "&@TagValue&" + ItemName + "&" + ShaftID;
|
||||
Base_TagIdList.Add(tagid, SendMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void Send_AlarmMsg(string tagid, string tagVvalue)
|
||||
{
|
||||
var val = Base_TagIdList[tagid];
|
||||
if (val != null)
|
||||
{
|
||||
var msg = Base_TagIdList[tagid].ToString();
|
||||
var sendmsg = msg.Replace("@TagValue", tagVvalue);
|
||||
SendMessageFun.AsyncSendMessage(sendmsg);
|
||||
}
|
||||
}
|
||||
|
||||
static public void GetTagIdList(string opName, out DataTable dt)
|
||||
{
|
||||
string procedureName;
|
||||
procedureName = "MES_基本变量_原始数据_根据工位号查询";
|
||||
SqlParameter[] thisParms = new SqlParameter[1];
|
||||
thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
|
||||
DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out dt);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
private static void Alarm_Insert(DoWhatPlc.CustomeEvetnArgs e)
|
||||
{
|
||||
string TagID;
|
||||
string opName;
|
||||
string tagTypeID;
|
||||
int TagValue;
|
||||
|
||||
DateTime alarmStartTime;
|
||||
DateTime alarmEndTime;
|
||||
int TimeDiff;
|
||||
string TagOrderBy;
|
||||
string Text1;
|
||||
string Text2;
|
||||
TagID = e.TagID.ToString();
|
||||
tagTypeID = e.TagTypeID.ToString();
|
||||
opName = e.OpName.ToString();
|
||||
TagValue = Convert.ToInt32(e.TagValue);
|
||||
|
||||
alarmStartTime = Convert.ToDateTime(e.TimeStampBefore);
|
||||
alarmEndTime = Convert.ToDateTime(e.TimeStamp);
|
||||
TimeDiff = Convert.ToInt32(e.TagKeepTime);
|
||||
TagOrderBy = e.TagOrderBy.ToString();
|
||||
Text1 = e.ItemName.ToString();
|
||||
Text2 = e.ShaftID.ToString();
|
||||
|
||||
Alarm_Insert(TagID, tagTypeID, opName, TagValue,
|
||||
alarmStartTime, alarmEndTime, TimeDiff, Text1, Text2, TagOrderBy);
|
||||
}
|
||||
private static void Alarm_InsertBak(ReturnValueString rv)
|
||||
{
|
||||
string TagID;
|
||||
string opName;
|
||||
string tagTypeID;
|
||||
int TagValue;
|
||||
|
||||
DateTime alarmStartTime;
|
||||
DateTime alarmEndTime;
|
||||
int TimeDiff;
|
||||
string TagOrderBy;
|
||||
string Text1;
|
||||
string Text2;
|
||||
TagID = rv.TagID;
|
||||
tagTypeID = rv.TagTypeID;
|
||||
opName = rv.OpName;
|
||||
TagValue = Convert.ToInt32(rv.TagValue);
|
||||
|
||||
alarmStartTime = Convert.ToDateTime(rv.TimeStampBefore);
|
||||
alarmEndTime = Convert.ToDateTime(rv.TimeStamp);
|
||||
TimeDiff = Convert.ToInt32(rv.TagKeepTime);
|
||||
TagOrderBy = rv.TagOrderBy;
|
||||
Text1 = rv.ItemName;
|
||||
Text2 = rv.ShaftID;
|
||||
|
||||
Alarm_Insert(TagID, tagTypeID, opName, TagValue,
|
||||
alarmStartTime, alarmEndTime, TimeDiff, Text1, Text2, TagOrderBy);
|
||||
}
|
||||
|
||||
public static void Alarm_InitAlarm_Send(string opName, out Hashtable ht)
|
||||
{
|
||||
//读取工位全部数据
|
||||
var tagValues = MIS_BASE.ReadPLC_OpName(opName); //GetDbAndMaxLengthByOpNameByBytes(opName);
|
||||
var keyValues = tagValues.OrderBy(x => x.Key).ToDictionary(k => k.Key, v => v.Value);
|
||||
ht = new Hashtable();
|
||||
|
||||
|
||||
foreach (KeyValuePair<string, object> _cd in keyValues)
|
||||
{
|
||||
var tf = (TagFormat)_cd.Value;
|
||||
if (tf.TagID[0].ToString() == "9")
|
||||
{
|
||||
string tagValue = tf.TagValue.ToString();
|
||||
if (tf.TagValue == null) return;
|
||||
switch (tagValue.ToLower())
|
||||
{
|
||||
case "1":
|
||||
case "true":
|
||||
tagValue = "1";
|
||||
break;
|
||||
default:
|
||||
tagValue = "0";
|
||||
break;
|
||||
}
|
||||
if (tagValue == "1")
|
||||
{
|
||||
ht.Add(tf.TagID, tagValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public static bool Alarm_Insert(string TagID, string tagTypeID, string opName, int TagValue,
|
||||
DateTime alarmStartTime, DateTime alarmEndTime, int TimeDiff,
|
||||
string Text1, string Text2, string TagOrderBy)
|
||||
{
|
||||
|
||||
|
||||
string produceName = "测量数据工位报警全部_增加数据";
|
||||
SqlParameter[] thisParms = new SqlParameter[10];
|
||||
thisParms[0] = new System.Data.SqlClient.SqlParameter("@TagID", TagID);
|
||||
thisParms[1] = new System.Data.SqlClient.SqlParameter("@TagTypeID", tagTypeID);
|
||||
thisParms[2] = new System.Data.SqlClient.SqlParameter("@opName", opName);
|
||||
thisParms[3] = new System.Data.SqlClient.SqlParameter("@TagValue", TagValue);
|
||||
thisParms[4] = new System.Data.SqlClient.SqlParameter("@alarmStartTime", alarmStartTime);
|
||||
thisParms[5] = new System.Data.SqlClient.SqlParameter("@alarmEndTime", alarmEndTime);
|
||||
thisParms[6] = new System.Data.SqlClient.SqlParameter("@TimeDiff", TimeDiff);
|
||||
thisParms[7] = new System.Data.SqlClient.SqlParameter("@Text1", Text1);
|
||||
thisParms[8] = new System.Data.SqlClient.SqlParameter("@Text2", Text2);
|
||||
thisParms[9] = new System.Data.SqlClient.SqlParameter("@TagOrderBy", TagOrderBy);
|
||||
if (DataAccess.ExecuteStoredProcedure(produceName, ref thisParms))
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
using bizFacade;
|
||||
using DataLinkMesWork;
|
||||
using DoWhatPlc;
|
||||
using MesServerWork;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MisDataSaveDateMesRead
|
||||
{
|
||||
public partial class Funtion
|
||||
{
|
||||
//private static void EngTypeGetOver(string opName,string tagValue)
|
||||
//{
|
||||
// if (hashtable_EngineGetOver.Contains(opName))
|
||||
// {
|
||||
// hashtable_EngineGetOver.Remove(opName);
|
||||
// }
|
||||
// hashtable_EngineGetOver.Add(opName, tagValue);
|
||||
// if (tagValue == "1")
|
||||
// {
|
||||
|
||||
// int EngineTypeID;
|
||||
// string EngineType;
|
||||
// string EngineID;
|
||||
// int PartPalletCode;
|
||||
// // 1 读取机型等信息,保存到监控表
|
||||
|
||||
// DtWebApi.ReadWritePLC.GetEngineTypeFromPLC(opName, out EngineTypeID, out EngineType, out EngineID, out PartPalletCode);
|
||||
// string OrderForm;
|
||||
// MIS_BASE.Read_OrderForm(opName, out OrderForm);
|
||||
// if (hashtable_EngineGetOver_EngineTypeID.Contains(opName))
|
||||
// {
|
||||
// hashtable_EngineGetOver_EngineTypeID.Remove(opName);
|
||||
// }
|
||||
// hashtable_EngineGetOver_EngineTypeID.Add(opName, EngineTypeID);
|
||||
|
||||
// if (hashtable_EngineGetOver_EngineType.Contains(opName))
|
||||
// {
|
||||
// hashtable_EngineGetOver_EngineType.Remove(opName);
|
||||
// }
|
||||
// hashtable_EngineGetOver_EngineType.Add(opName, EngineType);
|
||||
|
||||
|
||||
// if (hashtable_EngineGetOver_EngineID.Contains(opName))
|
||||
// {
|
||||
// hashtable_EngineGetOver_EngineID.Remove(opName);
|
||||
// }
|
||||
// hashtable_EngineGetOver_EngineID.Add(opName, EngineID);
|
||||
// if (hashtable_PartPalletCode.Contains(opName))
|
||||
// {
|
||||
// hashtable_PartPalletCode.Remove(opName);
|
||||
// }
|
||||
// hashtable_PartPalletCode.Add(opName, PartPalletCode);
|
||||
|
||||
// EngTypeGetOverInsert(opName, EngineTypeID, EngineType, EngineID, PartPalletCode, OrderForm);
|
||||
|
||||
|
||||
// // 2 保存工件到位信息
|
||||
|
||||
// }
|
||||
//}
|
||||
|
||||
//
|
||||
/// <summary>
|
||||
/// @工位号 nvarchar(50)=null,
|
||||
///@产品型号代码 int=1 ,
|
||||
///@发动机型号 nvarchar(50)=null ,
|
||||
///@发动机号 nvarchar(50)=null ,
|
||||
///@托盘号 nvarchar(50)='0'
|
||||
/// </summary>
|
||||
/// <param name="EngineID"></param>
|
||||
/// <param name="tagID"></param>
|
||||
/// <param name="EngineType"></param>
|
||||
/// <param name="EngineTypeID"></param>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="isGoodBad"></param>
|
||||
/// <param name="PartPalletCode"></param>
|
||||
/// <param name="Id_tagCF"></param>
|
||||
/// <returns></returns>
|
||||
//public static bool EngTypeGetOverInsert(string opName, int EngineTypeID, string EngineType,string EngineID, int PartPalletCode,string OrderForm)
|
||||
//{
|
||||
// string procedureName;
|
||||
// procedureName = "测量数据工位_监控系统_增加";
|
||||
// SqlParameter[] thisParms = new SqlParameter[6];
|
||||
// thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
|
||||
// thisParms[1] = new System.Data.SqlClient.SqlParameter("@产品型号代码", EngineTypeID);
|
||||
// thisParms[2] = new System.Data.SqlClient.SqlParameter("@发动机型号", EngineType);
|
||||
// thisParms[3] = new System.Data.SqlClient.SqlParameter("@发动机号", EngineID);
|
||||
// thisParms[4] = new System.Data.SqlClient.SqlParameter("@托盘编号", PartPalletCode);
|
||||
// thisParms[6] = new System.Data.SqlClient.SqlParameter("@订单号", OrderForm);
|
||||
|
||||
// if (DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms))
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
// return false;
|
||||
//
|
||||
//}
|
||||
}
|
||||
}
|
||||
998
MIS_FuntionSaveData/MIS_FuntionSaveData/Funtion.MesRead.cs
Normal file
998
MIS_FuntionSaveData/MIS_FuntionSaveData/Funtion.MesRead.cs
Normal file
@@ -0,0 +1,998 @@
|
||||
using bizFacade;
|
||||
using DataLinkMesWork;
|
||||
using DoWhatPlc;
|
||||
using MesServerFunctions;
|
||||
using MesServerWork;
|
||||
using MesWork;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MisDataSaveDateMesRead
|
||||
{
|
||||
public partial class Funtion
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 允许保存(针对半自动和手动压装工位)
|
||||
/// </summary>
|
||||
/// <param name="OpName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
public static int MesRead(string opName, string tagValue, string tagid, bool isCheck = false)
|
||||
{
|
||||
int qualityMask = 0;
|
||||
|
||||
if (tagValue == "0")
|
||||
{
|
||||
MIS_BASE.Write_TagTypeID(20, opName, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
qualityMask = SaveQualityData(opName, Convert.ToInt32(tagValue), tagid, isCheck);
|
||||
MIS_BASE.Write_TagTypeID(20, opName, true);
|
||||
}
|
||||
return qualityMask;
|
||||
}
|
||||
public static string GetRealTimeQualityData(string opName)
|
||||
{
|
||||
string message = "";
|
||||
DataTable dt1 = new DataTable();
|
||||
DataTable dt_WWW;
|
||||
DataTable dt_WWW_Copy1;
|
||||
DataTable dt_WWW_Copy2;
|
||||
Hashtable valueList;
|
||||
try
|
||||
{
|
||||
|
||||
//读取工位全部数据
|
||||
var rtList = MIS_BASE.ReadPLC_OpName(opName); //GetDbAndMaxLengthByOpNameByBytes(opName);
|
||||
var pp = JsonConvert.SerializeObject(rtList);
|
||||
var tagValues = JsonConvert.DeserializeObject<ConcurrentDictionary<string, TagFormat>>(pp);
|
||||
|
||||
//过滤出来质量数据 //获得带合格标志的质量数据
|
||||
valueList = ReadPLC_OpName_Qd(tagValues);
|
||||
|
||||
string engineType;
|
||||
engineType = GetValueByTagTypeCodeID(tagValues, Convert.ToInt32(EnumTagTypeCodeID.EngineType)).ToString();
|
||||
|
||||
//0 - 无
|
||||
//1 - 防错 2 - 拧紧
|
||||
//3 - 加注油 4 - 压机
|
||||
//5 - 左翻转 6 - 右翻转
|
||||
//7 - 涂胶 8 - 举升
|
||||
// 获取该工位的拧紧程序列表,处理完后传入GetQualityDataTable
|
||||
DataTable screwUpdt = BaseDataSystemMES.BOMScrewUpSave_Select(opName, engineType);
|
||||
// 存放处理完的数据列表
|
||||
List<List<string>> screwUpStrList = new List<List<string>>();
|
||||
// 一级遍历 遍历有哪些需要累加的数据
|
||||
for (int i = 0; i < screwUpdt.Rows.Count; i++)
|
||||
{
|
||||
DataRow dr = screwUpdt.Rows[i];
|
||||
// 二级遍历,将每一项螺丝的数量有多少颗就添加多少组数据
|
||||
int Count = Convert.ToInt32(dr["数量"]);
|
||||
for (int j = 0; j < Count; j++)
|
||||
{
|
||||
DataRow dr2 = dr;
|
||||
List<string> itemList = new List<string>();
|
||||
// 列表顺序 0:名称 1:单位 2:单位2 3:理论值 4:理论值2 5:上限值 6:上限值2 7:下限值 8:下限值2 9:测量项目 10 测量项目2
|
||||
//如果该零件数量大于1则在后面加后缀 -1 -2
|
||||
if (Count > 1)
|
||||
{
|
||||
itemList.Add(dr2["零件名称"].ToString() + "-" + (j + 1));
|
||||
screwUpStrList.Add(itemList);
|
||||
}
|
||||
else
|
||||
{
|
||||
itemList.Add(dr2["零件名称"].ToString());
|
||||
screwUpStrList.Add(itemList);
|
||||
}
|
||||
//float getIntStr = Convert.ToInt32(System.Text.RegularExpressions.Regex.Replace(dr2["设计参数"].ToString(), @"[^0-9]+", ""));
|
||||
double getIntStr = 0;
|
||||
string setStr = dr2["设计参数"].ToString();
|
||||
string toIntStr = Regex.Replace(setStr, @"[^\d.\d]", "");
|
||||
// 如果是数字,则转换为decimal类型
|
||||
if (toIntStr == "")
|
||||
{
|
||||
getIntStr = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
getIntStr = Convert.ToDouble(toIntStr);
|
||||
}
|
||||
// 单位
|
||||
switch (dr2["主线设备操作类型"])
|
||||
{
|
||||
case 2: // 拧紧
|
||||
itemList.Add("Nm"); // 单位
|
||||
itemList.Add("Deg");// 单位2
|
||||
itemList.Add(getIntStr.ToString());// 理论值
|
||||
itemList.Add("");// 理论值2
|
||||
itemList.Add((getIntStr / 1.05).ToString("f2"));// 上限值
|
||||
itemList.Add("");// 上限值2
|
||||
itemList.Add((getIntStr / 0.95).ToString("f2"));// 下限值
|
||||
itemList.Add("");// 下限值2
|
||||
itemList.Add("扭矩");// 测量项目
|
||||
itemList.Add("角度");// 测量项目2
|
||||
break;
|
||||
case 3: //注油
|
||||
itemList.Add("");// 单位
|
||||
itemList.Add("L");// 单位2
|
||||
itemList.Add("");// 理论值
|
||||
itemList.Add("");// 理论值2
|
||||
itemList.Add("");// 上限值
|
||||
itemList.Add("");// 上限值2
|
||||
itemList.Add("");// 下限值
|
||||
itemList.Add("");// 下限值2
|
||||
itemList.Add("");// 测量项目
|
||||
itemList.Add("注油");// 测量项目2
|
||||
break;
|
||||
case 4: //压机
|
||||
itemList.Add("KN");// 单位
|
||||
itemList.Add("mm");// 单位2
|
||||
itemList.Add("");// 理论值
|
||||
itemList.Add("");// 理论值2
|
||||
itemList.Add("");// 上限值
|
||||
itemList.Add("");// 上限值2
|
||||
itemList.Add("");// 下限值
|
||||
itemList.Add("");// 下限值2
|
||||
itemList.Add("压力");// 测量项目
|
||||
itemList.Add("位移");// 测量项目2
|
||||
break;
|
||||
default:
|
||||
itemList.Add("");// 单位
|
||||
itemList.Add("");// 单位2
|
||||
itemList.Add("");// 理论值
|
||||
itemList.Add("");// 理论值2
|
||||
itemList.Add("");// 上限值
|
||||
itemList.Add("");// 上限值2
|
||||
itemList.Add("");// 下限值
|
||||
itemList.Add("");// 下限值2
|
||||
itemList.Add("");// 测量项目
|
||||
itemList.Add("");// 测量项目2
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 若没有查询到数据 则置为0
|
||||
if (screwUpStrList.Count == 0) screwUpStrList = null;
|
||||
|
||||
//获得带基本信息的质量数据表
|
||||
GetQualityDataTable(valueList, opName, MIS_BASE.BasicDataTagValue, MIS_BASE.BasicDataTagValueUpDown, out dt_WWW, screwUpStrList);
|
||||
|
||||
dt_WWW_Copy1 = dt_WWW.Copy().Select("变量排序 = 1").CopyToDataTable();
|
||||
DataView dv1 = dt_WWW_Copy1.DefaultView;
|
||||
dv1.Sort = "列位置 DESC";
|
||||
dt_WWW_Copy1 = dv1.ToTable();
|
||||
|
||||
dt_WWW_Copy2 = dt_WWW.Copy().Select("变量排序 = 2").CopyToDataTable();
|
||||
DataView dv2 = dt_WWW_Copy2.DefaultView;
|
||||
dv2.Sort = "列位置 DESC";
|
||||
dt_WWW_Copy2 = dv2.ToTable();
|
||||
|
||||
dt1.Columns.Add("列位置", System.Type.GetType("System.String"));
|
||||
dt1.Columns.Add("测量项目1", System.Type.GetType("System.String"));
|
||||
dt1.Columns.Add("测量项目2", System.Type.GetType("System.String"));
|
||||
dt1.Columns.Add("合格标志", System.Type.GetType("System.String"));
|
||||
dt1.Columns.Add("名称", System.Type.GetType("System.String"));
|
||||
|
||||
for (int i = 0; i < dt_WWW_Copy1.Rows.Count; i++)
|
||||
{
|
||||
if (dt_WWW_Copy1.Rows[i]["TagValue"].ToString() != "0" || dt_WWW_Copy2.Rows[i]["TagValue"].ToString() != "0")
|
||||
{
|
||||
var dr = dt1.NewRow();
|
||||
dr["列位置"] = dt_WWW_Copy1.Rows[i]["列位置"].ToString();
|
||||
dr["测量项目1"] = dt_WWW_Copy1.Rows[i]["TagValue"].ToString();
|
||||
dr["测量项目2"] = dt_WWW_Copy2.Rows[i]["TagValue"].ToString();
|
||||
dr["合格标志"] = dt_WWW_Copy1.Rows[i]["IsGoodBad"].ToString();
|
||||
dr["名称"] = dt_WWW_Copy1.Rows[i]["测量位置"].ToString();
|
||||
dt1.Rows.Add(dr);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
}
|
||||
message = JsonHelper.CreateJsonParameters(dt1);
|
||||
|
||||
return message;
|
||||
}
|
||||
/// <summary>
|
||||
/// 返回合格标志
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
/// <param name="tagID"></param>
|
||||
/// <returns></returns>
|
||||
private static int SaveQualityData(string opName, int tagValue, string tagID, bool isCheck = false)
|
||||
{
|
||||
int id_tagCF;
|
||||
int qualityMask = 0;
|
||||
int engineTypeID = 0;
|
||||
string engineID = "";
|
||||
string engineType = "";
|
||||
string partPallet = "";
|
||||
string orderFormPlc = "";
|
||||
DataTable dt_WWW;
|
||||
Hashtable valueList;
|
||||
try
|
||||
{
|
||||
|
||||
//读取工位全部数据
|
||||
var rtList = MIS_BASE.ReadPLC_OpName(opName); //GetDbAndMaxLengthByOpNameByBytes(opName);
|
||||
var pp = JsonConvert.SerializeObject(rtList);
|
||||
var tagValues = JsonConvert.DeserializeObject<ConcurrentDictionary<string, TagFormat>>(pp);
|
||||
//过滤出来质量数据 //获得带合格标志的质量数据
|
||||
valueList = ReadPLC_OpName_Qd(tagValues);
|
||||
|
||||
engineTypeID = Convert.ToInt32(GetValueByTagTypeCodeID(tagValues, Convert.ToInt32(EnumTagTypeCodeID.EngineTypeID)));
|
||||
engineID = GetValueByTagTypeCodeID(tagValues, Convert.ToInt32(EnumTagTypeCodeID.EngineID)).ToString();
|
||||
engineType = GetValueByTagTypeCodeID(tagValues, Convert.ToInt32(EnumTagTypeCodeID.EngineType)).ToString();
|
||||
orderFormPlc = GetValueByTagTypeCodeID(tagValues, Convert.ToInt32(EnumTagTypeCodeID.OrderFormPLC)).ToString();
|
||||
qualityMask = Convert.ToInt32(GetValueByTagTypeCodeID(tagValues, Convert.ToInt32(EnumTagTypeCodeID.QualityMask)));
|
||||
|
||||
//0 - 无
|
||||
//1 - 防错 2 - 拧紧
|
||||
//3 - 加注油 4 - 压机
|
||||
//5 - 左翻转 6 - 右翻转
|
||||
//7 - 涂胶 8 - 举升
|
||||
// 获取该工位的拧紧程序列表,处理完后传入GetQualityDataTable
|
||||
DataTable screwUpdt = BaseDataSystemMES.BOMScrewUpSave_Select(opName, engineType);
|
||||
// 存放处理完的数据列表
|
||||
List<List<string>> screwUpStrList = new List<List<string>>();
|
||||
// 一级遍历 遍历有哪些需要累加的数据
|
||||
for (int i = 0; i < screwUpdt.Rows.Count; i++)
|
||||
{
|
||||
DataRow dr = screwUpdt.Rows[i];
|
||||
// 二级遍历,将每一项螺丝的数量有多少颗就添加多少组数据
|
||||
int Count = Convert.ToInt32(dr["数量"]);
|
||||
for (int j = 0; j < Count; j++)
|
||||
{
|
||||
DataRow dr2 = dr;
|
||||
List<string> itemList = new List<string>();
|
||||
// 列表顺序 0:名称 1:单位 2:单位2 3:理论值 4:理论值2 5:上限值 6:上限值2 7:下限值 8:下限值2 9:测量项目 10 测量项目2
|
||||
//如果该零件数量大于1则在后面加后缀 -1 -2
|
||||
if (Count > 1)
|
||||
{
|
||||
itemList.Add(dr2["零件名称"].ToString() + "-" + (j + 1));
|
||||
screwUpStrList.Add(itemList);
|
||||
}
|
||||
else
|
||||
{
|
||||
itemList.Add(dr2["零件名称"].ToString());
|
||||
screwUpStrList.Add(itemList);
|
||||
}
|
||||
//float getIntStr = Convert.ToInt32(System.Text.RegularExpressions.Regex.Replace(dr2["设计参数"].ToString(), @"[^0-9]+", ""));
|
||||
double getIntStr = 0;
|
||||
string setStr = dr2["设计参数"].ToString();
|
||||
string toIntStr = Regex.Replace(setStr, @"[^\d.\d]", "");
|
||||
// 如果是数字,则转换为decimal类型
|
||||
if (toIntStr == "")
|
||||
{
|
||||
getIntStr = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
getIntStr = Convert.ToDouble(toIntStr);
|
||||
}
|
||||
// 单位
|
||||
switch (dr2["主线设备操作类型"])
|
||||
{
|
||||
case 2: // 拧紧
|
||||
itemList.Add("Nm"); // 单位
|
||||
itemList.Add("Deg");// 单位2
|
||||
itemList.Add(getIntStr.ToString());// 理论值
|
||||
itemList.Add("");// 理论值2
|
||||
itemList.Add((getIntStr / 1.05).ToString("f2"));// 上限值
|
||||
itemList.Add("");// 上限值2
|
||||
itemList.Add((getIntStr / 0.95).ToString("f2"));// 下限值
|
||||
itemList.Add("");// 下限值2
|
||||
itemList.Add("扭矩");// 测量项目
|
||||
itemList.Add("角度");// 测量项目2
|
||||
break;
|
||||
case 3: //注油
|
||||
itemList.Add("L");// 单位
|
||||
itemList.Add("");// 单位2
|
||||
itemList.Add("");// 理论值
|
||||
itemList.Add("");// 理论值2
|
||||
itemList.Add("");// 上限值
|
||||
itemList.Add("");// 上限值2
|
||||
itemList.Add("");// 下限值
|
||||
itemList.Add("");// 下限值2
|
||||
itemList.Add("注油");// 测量项目
|
||||
itemList.Add("");// 测量项目2
|
||||
break;
|
||||
case 4: //压机
|
||||
itemList.Add("KN");// 单位
|
||||
itemList.Add("mm");// 单位2
|
||||
itemList.Add("");// 理论值
|
||||
itemList.Add("");// 理论值2
|
||||
itemList.Add("");// 上限值
|
||||
itemList.Add("");// 上限值2
|
||||
itemList.Add("");// 下限值
|
||||
itemList.Add("");// 下限值2
|
||||
itemList.Add("压力");// 测量项目
|
||||
itemList.Add("位移");// 测量项目2
|
||||
break;
|
||||
default:
|
||||
itemList.Add("");// 单位
|
||||
itemList.Add("");// 单位2
|
||||
itemList.Add("");// 理论值
|
||||
itemList.Add("");// 理论值2
|
||||
itemList.Add("");// 上限值
|
||||
itemList.Add("");// 上限值2
|
||||
itemList.Add("");// 下限值
|
||||
itemList.Add("");// 下限值2
|
||||
itemList.Add("");// 测量项目
|
||||
itemList.Add("");// 测量项目2
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 若没有查询到数据 则置为0
|
||||
if (screwUpStrList.Count == 0) screwUpStrList = null;
|
||||
|
||||
//获得带基本信息的质量数据表
|
||||
GetQualityDataTable(valueList, opName, MIS_BASE.BasicDataTagValue,
|
||||
MIS_BASE.BasicDataTagValueUpDown, out dt_WWW, screwUpStrList);
|
||||
|
||||
DateTime lastupdatetime = DateTime.Now;
|
||||
//保存质量数
|
||||
if ((opName == "J07PA040" && Convert.ToBoolean(MIS_BASE.ReadPLC(64, opName))) || opName == "J07PA030")
|
||||
{
|
||||
engineID = engineID + "-2";
|
||||
}
|
||||
BaseData_tagTable_QualityData_B5A_IndexInsert(engineID, tagID, engineType, engineTypeID, opName, qualityMask, partPallet, out id_tagCF);
|
||||
BaseData_tagTable_QualityData_B5A_Insert(id_tagCF, engineTypeID, engineID, opName, dt_WWW, isCheck);
|
||||
|
||||
// }
|
||||
BaseDataSystemMES.Material_Insert(opName, 1);
|
||||
|
||||
//更新订单完工数量及物料
|
||||
SendMessageFun.SendMessage("24c", "111", opName);
|
||||
//回写保存完成数据
|
||||
MIS_BASE.Write_TagTypeID(20, opName, true);
|
||||
#region
|
||||
//string orderForm = "";
|
||||
//string operatorCode = "";
|
||||
//int shiftCode = 1;
|
||||
//DateTime arrivedTime;
|
||||
//DateTime leavedTime;
|
||||
//int TimeDiff;
|
||||
//int targetTime = 0;
|
||||
//string lineType = "";
|
||||
//string isPass;
|
||||
//int machineWorkOn = 0;
|
||||
//int arrivedOrLeaved = 2;
|
||||
//int cartColorOpName = 0;
|
||||
//int cartColorConfirm = 0;
|
||||
//// int partMoveDirection;
|
||||
//int partGoOver = 0;
|
||||
//if (qualityMask == 1)
|
||||
//{
|
||||
// isPass = "PASS";
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// isPass = "FAIL";
|
||||
//}
|
||||
|
||||
////工位上下线类型
|
||||
////(0普通工位)(1正常上线)(2正常下线)(3返修上线)(4返修下线)
|
||||
//int OpNameUpDownType;
|
||||
//OpNameUpDownType = Convert.ToInt32(hashtableOpName_OpType[opName]);
|
||||
//arrivedTime = (DateTime)m_WorkStart_OpName_Time[opName];
|
||||
//leavedTime = DateTime.Now;
|
||||
//TimeDiff = Convert.ToInt32(leavedTime.Subtract(arrivedTime).TotalSeconds);
|
||||
|
||||
//lineType = hashtableOpName_LineType[opName].ToString();
|
||||
|
||||
//string isHaveComputer = hashtableOpName_IsHaveComputer[opName].ToString();
|
||||
////isHaveComputer = MIS_BASE.hashtable_tagTable_OpName_SaveData[opName].ToString();
|
||||
////有计算机的工位,通过工位计算机保存[测量数据发动机在线状态]。
|
||||
//if (Convert.ToInt32(isHaveComputer) == 0)
|
||||
//{
|
||||
// //1->0 工件离开 工件刚刚离开
|
||||
// if (Convert.ToInt32(m_WorkStart_OpName[opName]) == 1)
|
||||
// {
|
||||
|
||||
// //[测量数据发动机在线状态]
|
||||
// QualityDataSystem.WorkStartInsert
|
||||
// (opName, orderForm, engineTypeID, engineType, engineID, partPallet.ToString(), operatorCode, shiftCode,
|
||||
// arrivedTime, leavedTime, TimeDiff, targetTime, lineType, isPass, machineWorkOn,
|
||||
// arrivedOrLeaved, cartColorOpName, cartColorConfirm, partMoveDirection, partGoOver, mes_MustTest, onLineState, OpNameUpDownType);
|
||||
// }
|
||||
//}
|
||||
#endregion
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
MIS_BASE.Write_TagTypeID(20, opName, true);
|
||||
////ApplicationLog.WriteLog(err, err.Message);
|
||||
}
|
||||
return qualityMask;
|
||||
}
|
||||
static public void GetQualityDataTable(Hashtable valuList, string opName, DataTable BasicDataTagValue, DataTable BasicDataTagValueUpDown, out DataTable dt, List<List<string>> screwUpList = null)
|
||||
{
|
||||
//78 0:屏蔽MES;1:启用MES(必须MIS)
|
||||
//79 通过线体工位PC实现下达工位工作状态:工位有三种状态:在线、离线、屏蔽。在线;0正常状态,实现正常功能。1离线:2屏蔽。(必须MIS)
|
||||
//41 机体流向标志(1 BYTE):0普通工位:1:上线(发动机上线);2:下线(发动机下线);(必须PLC)
|
||||
//51 返修工位,修改后的数据MES将数据写入PLC ,MES通知PLC数据修改完成。(YN)
|
||||
//8 只要返修,必须由mes发送此信号,plc接收此信号后才能放行
|
||||
//(暂时没用)用于有扳手拧紧工位。通知设备螺钉拧紧完成。PC已经将数据保存到数据库中。(B5A)
|
||||
|
||||
QualityDataType qualityData;
|
||||
//是否有数据
|
||||
//bool isUsing;
|
||||
|
||||
DataRow dr;
|
||||
DataRow[] dr_WWW;
|
||||
//MES_基本数据_测量范围
|
||||
DataRow[] dr_WWW_UpDown;
|
||||
|
||||
dt = BaseDataSystemMES.BuildDataTables_WWW();
|
||||
|
||||
//测量位置
|
||||
string shaftID;
|
||||
//测量项目
|
||||
string item;
|
||||
//测量单位
|
||||
string unit;
|
||||
//机体类型
|
||||
//原始数据中的机型代码
|
||||
int engineTypeID_Source;
|
||||
//上限值
|
||||
string tagValueUp;
|
||||
//下限值
|
||||
string tagValueDown;
|
||||
//理论值
|
||||
string tagValeNormal;
|
||||
//TagValue
|
||||
// 合格标志
|
||||
//string IsGoodBad;
|
||||
|
||||
foreach (DictionaryEntry valueItem in valuList) //ht为一个Hashtable实例
|
||||
{
|
||||
try
|
||||
{
|
||||
qualityData = (QualityDataType)valueItem.Value;
|
||||
|
||||
//if ((qualityData.tagProperty != 2) || (qualityData.tagProperty != 6))
|
||||
//{
|
||||
// continue ;
|
||||
//}
|
||||
//if ((qualityData.tagProperty == 2) || (qualityData.tagProperty == 6))
|
||||
{
|
||||
//if (engineTypeID == 0)
|
||||
//{d
|
||||
// engineTypeID = 1;
|
||||
//}
|
||||
dr_WWW = BasicDataTagValue.Select("TagID = " + qualityData.tagID);
|
||||
try
|
||||
{
|
||||
dr_WWW_UpDown = BasicDataTagValueUpDown.Select("TagID = " + qualityData.tagID);
|
||||
}
|
||||
catch { dr_WWW_UpDown = null; }
|
||||
|
||||
|
||||
//if (dr_WWW.Length > 0)
|
||||
//{
|
||||
// {
|
||||
// engineTypeID_Source = Convert.ToInt32(dr_WWW[0]["机体类型"]);
|
||||
// int temp;
|
||||
// temp = engineTypeID_Source & engineTypeID;
|
||||
// if (temp == 0)
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
// if (qualityData.isGoodBad == -1)
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// continue;
|
||||
|
||||
//}
|
||||
|
||||
try
|
||||
{
|
||||
shaftID = dr_WWW[0]["测量位置"].ToString();
|
||||
}
|
||||
catch
|
||||
{
|
||||
shaftID = "";
|
||||
}
|
||||
try
|
||||
{
|
||||
item = dr_WWW[0]["测量项目"].ToString();
|
||||
}
|
||||
catch
|
||||
{
|
||||
item = "";
|
||||
}
|
||||
try
|
||||
{
|
||||
unit = dr_WWW[0]["测量单位"].ToString();
|
||||
}
|
||||
catch
|
||||
{
|
||||
unit = "";
|
||||
}
|
||||
try
|
||||
{
|
||||
tagValueUp = "";
|
||||
if (dr_WWW_UpDown != null && dr_WWW_UpDown.Length > 0)
|
||||
{
|
||||
tagValueUp = dr_WWW_UpDown[0]["值上限"].ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
tagValueUp = "";
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
tagValueUp = "";
|
||||
}
|
||||
try
|
||||
{
|
||||
tagValueDown = "";
|
||||
if (dr_WWW_UpDown != null && dr_WWW_UpDown.Length > 0)
|
||||
{
|
||||
tagValueDown = dr_WWW_UpDown[0]["值下限"].ToString();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
tagValueDown = "";
|
||||
}
|
||||
try
|
||||
{
|
||||
tagValeNormal = "";
|
||||
if (dr_WWW_UpDown != null && dr_WWW_UpDown.Length > 0)
|
||||
{
|
||||
tagValeNormal = dr_WWW_UpDown[0]["理论值"].ToString();
|
||||
}
|
||||
|
||||
}
|
||||
catch
|
||||
{
|
||||
tagValeNormal = "";
|
||||
}
|
||||
|
||||
dr = dt.NewRow();
|
||||
|
||||
dr["TagID"] = qualityData.tagID;
|
||||
dr["测量位置"] = shaftID;
|
||||
dr["测量项目"] = item;
|
||||
dr["测量单位"] = unit;
|
||||
dr["上限值"] = tagValueUp;
|
||||
dr["下限值"] = tagValueDown;
|
||||
dr["理论值"] = tagValeNormal;
|
||||
dr["工位号"] = opName;
|
||||
dr["列位置"] = qualityData.tagOrderBy;
|
||||
dr["变量排序"] = qualityData.tagItemOrderBy;
|
||||
|
||||
dr["IsGoodBad"] = qualityData.isGoodBad;
|
||||
|
||||
// 如果传递了拧紧列表的话那就按拧紧列表里来
|
||||
if (screwUpList != null)
|
||||
{
|
||||
if (qualityData.tagOrderBy <= screwUpList.Count)
|
||||
{
|
||||
List<String> WorkNameList = screwUpList[qualityData.tagOrderBy - 1];
|
||||
// 列表顺序 0:名称 1:单位 2:单位2 3:理论值 4:理论值2 5:上限值 6:上限值2 7:下限值 8:下限值2 9:测量项目 10 测量项目2
|
||||
dr["测量位置"] = WorkNameList[0];
|
||||
if (qualityData.tagItemOrderBy == 1)
|
||||
{
|
||||
dr["测量单位"] = WorkNameList[1];
|
||||
dr["理论值"] = WorkNameList[3];
|
||||
dr["上限值"] = WorkNameList[5];
|
||||
dr["下限值"] = WorkNameList[7];
|
||||
dr["测量项目"] = WorkNameList[9];
|
||||
}
|
||||
else if (qualityData.tagItemOrderBy == 2)
|
||||
{
|
||||
dr["测量单位"] = WorkNameList[2];
|
||||
dr["理论值"] = WorkNameList[4];
|
||||
dr["上限值"] = WorkNameList[6];
|
||||
dr["下限值"] = WorkNameList[8];
|
||||
dr["测量项目"] = WorkNameList[10];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
switch (qualityData.tagTypeID)//
|
||||
{
|
||||
//合格标志数组
|
||||
case 8203:
|
||||
dr["TagValue"] = BaseDataSystemMES.GetQualityData_GoodBad_String((bool[])qualityData.tagValue);
|
||||
break;
|
||||
case 8209:
|
||||
dr["TagValue"] = "";
|
||||
break;
|
||||
//非标准REAL
|
||||
case 8210:
|
||||
dr["TagValue"] = BaseDataSystemMES.GetNoNormalReal(qualityData.tagValue);
|
||||
dt.Rows.Add(dr);
|
||||
break;
|
||||
default:
|
||||
dr["TagValue"] = Convert.ToString(qualityData.tagValue);
|
||||
dt.Rows.Add(dr);
|
||||
break;
|
||||
}
|
||||
|
||||
//福田对质量数据特殊处理,MA20保留4位小数点,其余保留两位
|
||||
if (opName == "J07MA020")
|
||||
{
|
||||
dr["TagValue"] = Convert.ToDouble(dr["TagValue"]).ToString("0.####");
|
||||
}
|
||||
else if (opName == "J07ET050")
|
||||
{
|
||||
dr["TagValue"] = Convert.ToDouble(dr["TagValue"]).ToString("0.###");
|
||||
}
|
||||
else
|
||||
{
|
||||
dr["TagValue"] = Convert.ToDouble(dr["TagValue"]).ToString("0.##");
|
||||
//dr["TagValue"] = String.Format("{0:0000.00}", Convert.ToDouble(dr["TagValue"]));
|
||||
}
|
||||
|
||||
if (opName == "J07MA150")
|
||||
{
|
||||
dr["变量排序"] = 1;
|
||||
dr["IsGoodBad"] = 1;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
//ApplicationLog.WriteLog(err, err.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 数据表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private static object GetValueByTagTypeCodeID(ConcurrentDictionary<string, TagFormat> opTagList, int TagTypeCodeID)
|
||||
{
|
||||
try
|
||||
{
|
||||
return opTagList.Where(x => x.Value.TagTypeCodeID == TagTypeCodeID).ToList()[0].Value.TagValue;
|
||||
|
||||
}
|
||||
catch (Exception err) { return "-3"; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据工位名称,读取工位对应的质量数据,带合格标志
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <returns></returns>
|
||||
public static Hashtable ReadPLC_OpName_Qd(ConcurrentDictionary<string, TagFormat> tagValues)
|
||||
{
|
||||
//lock (l)
|
||||
{
|
||||
|
||||
//var tagValues = DtWebApi.ReadWritePLC.ReadPLC_OpName(opName); //GetDbAndMaxLengthByOpNameByBytes(opName);
|
||||
|
||||
var keyValues = tagValues.OrderBy(x => x.Key).ToDictionary(k => k.Key, v => v.Value);
|
||||
|
||||
TagFormat tagFormatTemp;
|
||||
int tagIndex = 1;
|
||||
int isOK = 0;
|
||||
|
||||
Hashtable ht = new Hashtable();
|
||||
|
||||
|
||||
foreach (KeyValuePair<string, TagFormat> _cd in keyValues)
|
||||
{
|
||||
if (_cd.Key.ToString()[0].ToString() == "7")
|
||||
{
|
||||
tagFormatTemp = _cd.Value;
|
||||
if (tagIndex % 3 == 1)
|
||||
{
|
||||
isOK = Convert.ToInt32(tagFormatTemp.TagValue);
|
||||
}
|
||||
else if (tagIndex % 3 == 2)
|
||||
{
|
||||
var TF = _cd.Value;
|
||||
|
||||
QualityDataType qualityDataType;
|
||||
qualityDataType = GetQualityDataType(TF);
|
||||
qualityDataType.isGoodBad = isOK;
|
||||
ht.Add(qualityDataType.tagID, qualityDataType);
|
||||
}
|
||||
else if (tagIndex % 3 == 0)
|
||||
{
|
||||
var TF = (TagFormat)_cd.Value;
|
||||
|
||||
QualityDataType qualityDataType;
|
||||
qualityDataType = GetQualityDataType(TF);
|
||||
qualityDataType.isGoodBad = isOK;
|
||||
ht.Add(qualityDataType.tagID, qualityDataType);
|
||||
}
|
||||
|
||||
tagIndex++;
|
||||
}
|
||||
//Console.WriteLine($"key:{kv.Key} value:{kv.Value}");
|
||||
}
|
||||
return ht;
|
||||
}
|
||||
}
|
||||
|
||||
//public static Hashtable ReadPLC_OpName_Entite(string opName)
|
||||
//{
|
||||
// //lock (l)
|
||||
// {
|
||||
|
||||
// var tagValues = DtWebApi.ReadWritePLC.ReadPLC_OpName(opName); //GetDbAndMaxLengthByOpNameByBytes(opName);
|
||||
|
||||
// var keyValues = tagValues.OrderBy(x => x.Key).ToDictionary(k => k.Key, v => v.Value);
|
||||
|
||||
// TagFormat tagFormatTemp;
|
||||
// int tagIndex = 1;
|
||||
// int isOK = 0;
|
||||
|
||||
// Hashtable ht = new Hashtable();
|
||||
|
||||
|
||||
// foreach (KeyValuePair<string, TagFormat> _cd in keyValues)
|
||||
// {
|
||||
// if (_cd.Key.ToString()[0].ToString() == "7")
|
||||
// {
|
||||
// tagFormatTemp = _cd.Value;
|
||||
// if (tagIndex % 3 == 1)
|
||||
// {
|
||||
// isOK = Convert.ToInt32(tagFormatTemp.TagValue);
|
||||
// }
|
||||
// else if (tagIndex % 3 == 2)
|
||||
// {
|
||||
// var TF = _cd.Value;
|
||||
|
||||
// QualityDataType qualityDataType;
|
||||
// qualityDataType = GetQualityDataType(TF);
|
||||
// qualityDataType.isGoodBad = isOK;
|
||||
// ht.Add(qualityDataType.tagID, qualityDataType);
|
||||
// }
|
||||
// else if (tagIndex % 3 == 0)
|
||||
// {
|
||||
// var TF = (TagFormat)_cd.Value;
|
||||
|
||||
// QualityDataType qualityDataType;
|
||||
// qualityDataType = GetQualityDataType(TF);
|
||||
// qualityDataType.isGoodBad = isOK;
|
||||
// ht.Add(qualityDataType.tagID, qualityDataType);
|
||||
// }
|
||||
|
||||
// tagIndex++;
|
||||
// }
|
||||
// //Console.WriteLine($"key:{kv.Key} value:{kv.Value}");
|
||||
// }
|
||||
// return ht;
|
||||
// }
|
||||
//}
|
||||
public static QualityDataType GetQualityDataType(TagFormat TF)
|
||||
{
|
||||
QualityDataType qualityDataType;
|
||||
|
||||
qualityDataType = new QualityDataType();
|
||||
|
||||
qualityDataType.tagID = TF.TagID;
|
||||
qualityDataType.tagTypeID = TF.TagTypeID;//变量类型
|
||||
qualityDataType.opName = TF.OpName;
|
||||
int.TryParse(TF.TagQuality, out int TagQuality);
|
||||
qualityDataType.tagQuality = TagQuality;
|
||||
qualityDataType.tagValueType = TF.TagTypeCodeID;
|
||||
int.TryParse(TF.TagOrderBy, out int TagOrderBy);
|
||||
qualityDataType.tagOrderBy = TagOrderBy;
|
||||
int.TryParse(TF.TagItemOrderBy, out int TagItemOrderBy);
|
||||
qualityDataType.tagItemOrderBy = TagItemOrderBy;
|
||||
qualityDataType.tagProperty = TF.TagProperty;//变量特点
|
||||
qualityDataType.tagValue = TF.TagValue;//变量值
|
||||
|
||||
return qualityDataType;
|
||||
}
|
||||
|
||||
public static bool BaseData_tagTable_QualityData_B5A_IndexInsert(string EngineID, string tagID, string EngineType, int EngineTypeID, string opName, int isGoodBad, string PartPalletCode, out int Id_tagCF)
|
||||
{
|
||||
string procedureName;
|
||||
procedureName = "测量数据合格索引_增加";
|
||||
Id_tagCF = 0;
|
||||
SqlParameter[] thisParms = new SqlParameter[8];
|
||||
thisParms[0] = new System.Data.SqlClient.SqlParameter("@EngineID", EngineID);
|
||||
thisParms[1] = new System.Data.SqlClient.SqlParameter("@TagID_CF", tagID);
|
||||
thisParms[2] = new System.Data.SqlClient.SqlParameter("@EngineType", EngineType);
|
||||
thisParms[3] = new System.Data.SqlClient.SqlParameter("@EngineTypeID", EngineTypeID);
|
||||
thisParms[4] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
|
||||
thisParms[5] = new System.Data.SqlClient.SqlParameter("@托盘编号", PartPalletCode);
|
||||
thisParms[6] = new System.Data.SqlClient.SqlParameter("@合格标志", isGoodBad);
|
||||
thisParms[7] = new System.Data.SqlClient.SqlParameter("@Id_tagCF", Id_tagCF);
|
||||
thisParms[7].Direction = ParameterDirection.Output;
|
||||
|
||||
if (DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms))
|
||||
{
|
||||
Id_tagCF = Convert.ToInt32(thisParms[7].Value.ToString());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static bool BaseData_tagTable_QualityData_B5A_Insert(int Id_tagCF, int engineTypeID, string engineID, string opName, DataTable dt, bool IsCheck = false)
|
||||
{
|
||||
string procedureName;
|
||||
procedureName = "测量数据合格_增加";
|
||||
SqlParameter[] thisParms = new SqlParameter[13];
|
||||
thisParms[0] = new System.Data.SqlClient.SqlParameter("@Id_tagCF", Id_tagCF);
|
||||
thisParms[1] = new System.Data.SqlClient.SqlParameter("@EngineTypeID", engineTypeID);
|
||||
thisParms[2] = new System.Data.SqlClient.SqlParameter("@EngineID", engineID);
|
||||
thisParms[3] = new System.Data.SqlClient.SqlParameter("@TagID", SqlDbType.Int, 4, "TagID");
|
||||
thisParms[4] = new System.Data.SqlClient.SqlParameter("@TagValue", SqlDbType.NVarChar, 100, "TagValue");
|
||||
thisParms[5] = new System.Data.SqlClient.SqlParameter("@IsGoodBad", SqlDbType.Int, 4, "IsGoodBad");
|
||||
//是否保存无合格标志数据数据
|
||||
thisParms[6] = new System.Data.SqlClient.SqlParameter("@IsCheck", IsCheck);
|
||||
thisParms[7] = new System.Data.SqlClient.SqlParameter("@测量位置", SqlDbType.NVarChar, 50, "测量位置");
|
||||
thisParms[8] = new System.Data.SqlClient.SqlParameter("@测量项目", SqlDbType.NVarChar, 50, "测量项目");
|
||||
//thisParms[8] = new System.Data.SqlClient.SqlParameter("@工位号", opName); //为了给J07MA020 保留四位精度而设置
|
||||
thisParms[9] = new System.Data.SqlClient.SqlParameter("@理论值", SqlDbType.NVarChar, 50, "理论值");
|
||||
thisParms[10] = new System.Data.SqlClient.SqlParameter("@上限值", SqlDbType.NVarChar, 50, "上限值");
|
||||
thisParms[11] = new System.Data.SqlClient.SqlParameter("@下限值", SqlDbType.NVarChar, 50, "下限值");
|
||||
thisParms[12] = new System.Data.SqlClient.SqlParameter("@测量单位", SqlDbType.NVarChar, 50, "测量单位");
|
||||
//thisParms[13] = new System.Data.SqlClient.SqlParameter("@列位置", SqlDbType.Int, 4, "列位置");
|
||||
//thisParms[14] = new System.Data.SqlClient.SqlParameter("@变量排序", SqlDbType.Int, 4, "变量排序");
|
||||
//table.Columns.Add("TagID", typeof(System.Int32));
|
||||
//table.Columns.Add("TagValue", typeof(System.String));
|
||||
//table.Columns.Add("IsGoodBad", typeof(System.Int32));
|
||||
//table.Columns.Add("测量位置", typeof(System.String));
|
||||
//table.Columns.Add("测量项目", typeof(System.String));
|
||||
//table.Columns.Add("工位号", typeof(System.String));
|
||||
//table.Columns.Add("理论值", typeof(System.String));
|
||||
//table.Columns.Add("上限值", typeof(System.String));
|
||||
//table.Columns.Add("下限值", typeof(System.String));
|
||||
//table.Columns.Add("测量单位", typeof(System.String));
|
||||
//table.Columns.Add("列位置", typeof(System.Int32));
|
||||
//table.Columns.Add("变量排序", typeof(System.Int32));
|
||||
return DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, dt);
|
||||
}
|
||||
|
||||
|
||||
public static int MesRead_J07MA150(string opName, string tagValue, string tagid)
|
||||
{
|
||||
int qualityMask = 0;
|
||||
|
||||
if (tagValue == "0")
|
||||
{
|
||||
MIS_BASE.Write_TagTypeID(20, opName, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
qualityMask = SaveQualityData_J07MA150(opName, Convert.ToInt32(tagValue), tagid);
|
||||
MIS_BASE.Write_TagTypeID(20, opName, true);
|
||||
}
|
||||
return qualityMask;
|
||||
}
|
||||
/// <summary>
|
||||
/// 返回合格标志, 注油工位 质量数据为字符串,读取备用点 变量类型代码 = 41
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
/// <param name="tagID"></param>
|
||||
/// <returns></returns>
|
||||
private static int SaveQualityData_J07MA150(string opName, int tagValue, string tagID)
|
||||
{
|
||||
int id_tagCF;
|
||||
int qualityMask = 0;
|
||||
int engineTypeID = 0;
|
||||
string engineID = "";
|
||||
string engineType = "";
|
||||
string partPallet = "";
|
||||
string orderFormPlc = "";
|
||||
DataTable dt_WWW;
|
||||
Hashtable valueList;
|
||||
try
|
||||
{
|
||||
|
||||
//读取工位全部数据
|
||||
var rtList = MIS_BASE.ReadPLC_OpName(opName); //GetDbAndMaxLengthByOpNameByBytes(opName);
|
||||
var pp = JsonConvert.SerializeObject(rtList);
|
||||
var tagValues = JsonConvert.DeserializeObject<ConcurrentDictionary<string, TagFormat>>(pp);
|
||||
//过滤出来质量数据 //获得带合格标志的质量数据
|
||||
valueList = ReadPLC_OpName_Qd_J07MA150(tagValues);
|
||||
|
||||
engineTypeID = Convert.ToInt32(GetValueByTagTypeCodeID(tagValues, Convert.ToInt32(EnumTagTypeCodeID.EngineTypeID)));
|
||||
engineID = GetValueByTagTypeCodeID(tagValues, Convert.ToInt32(EnumTagTypeCodeID.EngineID)).ToString();
|
||||
engineType = GetValueByTagTypeCodeID(tagValues, Convert.ToInt32(EnumTagTypeCodeID.EngineType)).ToString();
|
||||
orderFormPlc = GetValueByTagTypeCodeID(tagValues, Convert.ToInt32(EnumTagTypeCodeID.OrderFormPLC)).ToString();
|
||||
engineID = GetValueByTagTypeCodeID(tagValues, Convert.ToInt32(EnumTagTypeCodeID.EngineID)).ToString();
|
||||
qualityMask = Convert.ToInt32(GetValueByTagTypeCodeID(tagValues, Convert.ToInt32(EnumTagTypeCodeID.QualityMask)));
|
||||
|
||||
//获得带基本信息的质量数据表
|
||||
GetQualityDataTable(valueList, opName, MIS_BASE.BasicDataTagValue,
|
||||
MIS_BASE.BasicDataTagValueUpDown, out dt_WWW);
|
||||
|
||||
|
||||
DateTime lastupdatetime = DateTime.Now;
|
||||
//保存质量数
|
||||
BaseData_tagTable_QualityData_B5A_IndexInsert(engineID, tagID, engineType, engineTypeID, opName, qualityMask, partPallet, out id_tagCF);
|
||||
BaseData_tagTable_QualityData_B5A_Insert(id_tagCF, engineTypeID, engineID, opName, dt_WWW);
|
||||
|
||||
// }
|
||||
BaseDataSystemMES.Material_Insert(opName, 1);
|
||||
|
||||
//更新订单完工数量及物料
|
||||
SendMessageFun.SendMessage("24c", "111", opName);
|
||||
|
||||
//回写保存完成数据
|
||||
MIS_BASE.Write_TagTypeID(20, opName, true);
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
MIS_BASE.Write_TagTypeID(20, opName, true);
|
||||
////ApplicationLog.WriteLog(err, err.Message);
|
||||
}
|
||||
return qualityMask;
|
||||
}
|
||||
public static Hashtable ReadPLC_OpName_Qd_J07MA150(ConcurrentDictionary<string, TagFormat> tagValues)
|
||||
{
|
||||
//lock (l)
|
||||
{
|
||||
|
||||
//var tagValues = DtWebApi.ReadWritePLC.ReadPLC_OpName(opName); //GetDbAndMaxLengthByOpNameByBytes(opName);
|
||||
|
||||
var keyValues = tagValues.OrderBy(x => x.Key).ToDictionary(k => k.Key, v => v.Value);
|
||||
|
||||
TagFormat tagFormatTemp;
|
||||
int tagIndex = 1;
|
||||
int isOK = 1;
|
||||
|
||||
Hashtable ht = new Hashtable();
|
||||
|
||||
|
||||
//var TF = _cd.Value;
|
||||
////var TF = Read_TagTypeID(39, opName, out OrderForm);
|
||||
|
||||
//QualityDataType qualityDataType;
|
||||
//qualityDataType = GetQualityDataType(TF);
|
||||
//qualityDataType.isGoodBad = isOK;
|
||||
//ht.Add(qualityDataType.tagID, qualityDataType);
|
||||
|
||||
|
||||
foreach (KeyValuePair<string, TagFormat> _cd in keyValues)
|
||||
{
|
||||
|
||||
if (_cd.Value.TagTypeCodeID.ToString() == "41")
|
||||
{
|
||||
tagFormatTemp = _cd.Value;
|
||||
|
||||
var TF = _cd.Value;
|
||||
|
||||
QualityDataType qualityDataType;
|
||||
qualityDataType = GetQualityDataType(TF);
|
||||
qualityDataType.isGoodBad = isOK;
|
||||
qualityDataType.tagItemOrderBy = 1;
|
||||
qualityDataType.tagOrderBy = 1;
|
||||
ht.Add(qualityDataType.tagID, qualityDataType);
|
||||
}
|
||||
//Console.WriteLine($"key:{kv.Key} value:{kv.Value}");
|
||||
}
|
||||
return ht;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
186
MIS_FuntionSaveData/MIS_FuntionSaveData/Funtion.WorkStart.cs
Normal file
186
MIS_FuntionSaveData/MIS_FuntionSaveData/Funtion.WorkStart.cs
Normal file
@@ -0,0 +1,186 @@
|
||||
using DataLinkMesWork;
|
||||
using MesServerFunctions;
|
||||
using MesServerWork;
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
namespace MisDataSaveDateMesRead
|
||||
{
|
||||
public partial class Funtion
|
||||
{
|
||||
public static string MqttTargetTopic = ConfigurationManager.AppSettings["MqttTargetTopic"];
|
||||
|
||||
private static void WorkStart(DoWhatPlc.CustomeEvetnArgs e)
|
||||
{
|
||||
//var ro = rv.ReturnValueToObject();
|
||||
|
||||
string opName = e.OpName.ToString();
|
||||
DateTime arrivedTime = Convert.ToDateTime(e.TimeStampBefore);
|
||||
DateTime leavedTime = Convert.ToDateTime(e.TimeStamp);
|
||||
int TimeDiff = e.TagKeepTime;
|
||||
//int targetTime = 0;
|
||||
string isPass = "";
|
||||
|
||||
int QualityMark = 0;
|
||||
string tagValue = "0";
|
||||
switch (e.TagValue.ToString().ToLower())
|
||||
{
|
||||
case "1":
|
||||
case "true":
|
||||
tagValue = "1";
|
||||
break;
|
||||
default:
|
||||
tagValue = "0";
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int EngineTypeID = -1;//机型代码
|
||||
int PartPalletCode = -1;//托盘编号
|
||||
string EngineType = "-1";//机型
|
||||
string EngineID = "-1";//工件编号
|
||||
//if (hashtable_EngineGetOver_EngineTypeID.Contains(opName))
|
||||
//{
|
||||
// EngineTypeID = Convert.ToInt32( hashtable_EngineGetOver_EngineTypeID[opName]);
|
||||
//}
|
||||
//if (hashtable_EngineGetOver_EngineType.Contains(opName))
|
||||
//{
|
||||
// EngineType = hashtable_EngineGetOver_EngineType[opName].ToString();
|
||||
//}
|
||||
//if (hashtable_EngineGetOver_EngineID.Contains(opName))
|
||||
//{
|
||||
// EngineID = hashtable_EngineGetOver_EngineID[opName].ToString();
|
||||
//}
|
||||
//if (hashtable_PartPalletCode.Contains(opName))
|
||||
//{
|
||||
// PartPalletCode = Convert.ToInt32(hashtable_PartPalletCode[opName]);
|
||||
//}
|
||||
//int EngineTypeID;//机型代码
|
||||
//int PartPallet_Code;//托盘编号
|
||||
//string EngineType;//机型
|
||||
//string EngineID;//工件编号
|
||||
string OrderForm;
|
||||
MIS_BASE.GetEngineTypeFromPLC(opName, out EngineTypeID, out EngineType, out EngineID, out int PartPallet_Code, out OrderForm);
|
||||
|
||||
//MIS_BASE.GetEngineTypeFromPLC(opName, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code);
|
||||
|
||||
//EngineData Enginedata = (EngineData)EngineData_Hash_Read(opName);
|
||||
//WorkStartInsert_AutoWorkStation(opName, EngineID, PartPalletCode, arrivedTime, leavedTime, TimeDiff, targetTime, null, isPass, 0);
|
||||
|
||||
if (tagValue == "0")
|
||||
{
|
||||
QualityMark = Convert.ToInt32(MIS_BASE.ReadPLC(21, opName));
|
||||
|
||||
if (QualityMark == 1)
|
||||
{
|
||||
isPass = "1";
|
||||
}
|
||||
else
|
||||
{
|
||||
isPass = "0";
|
||||
}
|
||||
|
||||
WorkStartInsert_V2022(opName, arrivedTime, leavedTime, TimeDiff, isPass);
|
||||
|
||||
MIS_BASE.Write_TagTypeID(5, opName, false);//MES传递机型
|
||||
MIS_BASE.Write_TagTypeID(66, opName, false);//允许工作
|
||||
MIS_BASE.Write_TagTypeID(51, opName, false);//合格放行
|
||||
MIS_BASE.Write_TagTypeID(8, opName, false);//不合格放行
|
||||
MIS_BASE.Write_TagTypeID(7, opName, false);//工作完成
|
||||
MIS_BASE.Write_TagTypeID(20, opName, false);//保存完成
|
||||
|
||||
}
|
||||
|
||||
//通知WEB更新产量
|
||||
SendMessage.SendActuallyCount(opName, 0);
|
||||
}
|
||||
|
||||
//}
|
||||
/// <summary>
|
||||
/// 基本数据_工作日历_班次产量查询_New
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="opNameCount">在线产量</param>
|
||||
/// <param name="opNameCountTime">在线节拍</param>
|
||||
static public void OpNameCount_New(string opName, out int opNameCount, out int opNameCountTime)
|
||||
{
|
||||
opNameCount = 0;
|
||||
opNameCountTime = 0;
|
||||
string procedureName;
|
||||
procedureName = "基本数据_工作日历_班次产量查询_New";
|
||||
SqlParameter[] thisParms = new SqlParameter[3];
|
||||
thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
|
||||
thisParms[1] = new System.Data.SqlClient.SqlParameter("@在线产量", 0);
|
||||
thisParms[1].Direction = ParameterDirection.Output;
|
||||
thisParms[2] = new System.Data.SqlClient.SqlParameter("@在线节拍", 0);
|
||||
thisParms[2].Direction = ParameterDirection.Output;
|
||||
if (DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms))
|
||||
{
|
||||
opNameCount = Convert.ToInt32(thisParms[1].Value);
|
||||
opNameCountTime = Convert.ToInt32(thisParms[2].Value);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 测量数据发动机在线状态_增加数据_自动工位
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="EngineID"></param>
|
||||
/// <param name="Pallet"></param>
|
||||
/// <param name="arrivedTime"></param>
|
||||
/// <param name="leavedTime"></param>
|
||||
/// <param name="TimeDiff"></param>
|
||||
/// <param name="Target"></param>
|
||||
/// <param name="lineType"></param>
|
||||
/// <param name="isPass"></param>
|
||||
/// <param name="OpNameUpDownType"></param>
|
||||
static public void WorkStartInsert_AutoWorkStation(string opName, string EngineID, int Pallet, DateTime arrivedTime, DateTime leavedTime, int TimeDiff, int Target, string lineType, string isPass, int OpNameUpDownType)
|
||||
{
|
||||
string procedureName;
|
||||
procedureName = "测量数据发动机在线状态_增加数据_自动工位";
|
||||
SqlParameter[] thisParms = new SqlParameter[10];
|
||||
thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
|
||||
thisParms[1] = new System.Data.SqlClient.SqlParameter("@发动机号", EngineID);
|
||||
thisParms[2] = new System.Data.SqlClient.SqlParameter("@托盘编号", Pallet);
|
||||
thisParms[3] = new System.Data.SqlClient.SqlParameter("@到达时间", arrivedTime);
|
||||
thisParms[4] = new System.Data.SqlClient.SqlParameter("@离开时间", leavedTime);
|
||||
thisParms[5] = new System.Data.SqlClient.SqlParameter("@在线时间", TimeDiff);
|
||||
thisParms[6] = new System.Data.SqlClient.SqlParameter("@目标时间", Target);
|
||||
thisParms[7] = new System.Data.SqlClient.SqlParameter("@线体类型", lineType);
|
||||
thisParms[8] = new System.Data.SqlClient.SqlParameter("@是否合格", isPass);
|
||||
thisParms[9] = new System.Data.SqlClient.SqlParameter("@工位上下线类型", OpNameUpDownType);
|
||||
DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms);
|
||||
}
|
||||
|
||||
static public void WorkStartInsert_V2022(string opName, DateTime arrivedTime, DateTime leavedTime, int TimeDiff, string isPass)
|
||||
{
|
||||
string procedureName;
|
||||
procedureName = "测量数据发动机在线状态_增加数据_V2022";
|
||||
SqlParameter[] thisParms = new SqlParameter[5];
|
||||
thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
|
||||
thisParms[1] = new System.Data.SqlClient.SqlParameter("@到达时间", arrivedTime);
|
||||
thisParms[2] = new System.Data.SqlClient.SqlParameter("@离开时间", leavedTime);
|
||||
thisParms[3] = new System.Data.SqlClient.SqlParameter("@在线时间", TimeDiff);
|
||||
thisParms[4] = new System.Data.SqlClient.SqlParameter("@是否合格", isPass);
|
||||
DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms);
|
||||
}
|
||||
|
||||
static public void WorkStartInsert(string opName, DateTime arrivedTime, DateTime leavedTime, int TimeDiff, int Target, string lineType, string isPass, int OpNameUpDownType)
|
||||
{
|
||||
string procedureName;
|
||||
procedureName = "测量数据发动机在线状态_增加数据";
|
||||
SqlParameter[] thisParms = new SqlParameter[8];
|
||||
thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
|
||||
thisParms[1] = new System.Data.SqlClient.SqlParameter("@到达时间", arrivedTime);
|
||||
thisParms[2] = new System.Data.SqlClient.SqlParameter("@离开时间", leavedTime);
|
||||
thisParms[3] = new System.Data.SqlClient.SqlParameter("@在线时间", TimeDiff);
|
||||
thisParms[4] = new System.Data.SqlClient.SqlParameter("@目标时间", Target);
|
||||
thisParms[5] = new System.Data.SqlClient.SqlParameter("@线体类型", lineType);
|
||||
thisParms[6] = new System.Data.SqlClient.SqlParameter("@是否合格", isPass);
|
||||
thisParms[7] = new System.Data.SqlClient.SqlParameter("@工位上下线类型", OpNameUpDownType);
|
||||
DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms);
|
||||
}
|
||||
}
|
||||
}
|
||||
269
MIS_FuntionSaveData/MIS_FuntionSaveData/MIS_Funtion.cs
Normal file
269
MIS_FuntionSaveData/MIS_FuntionSaveData/MIS_Funtion.cs
Normal file
@@ -0,0 +1,269 @@
|
||||
using DoWhatPlc;
|
||||
using MesServerWork;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using bizFacade;
|
||||
using System.Data;
|
||||
using MesServerFunctions;
|
||||
|
||||
namespace MisDataSaveDateMesRead
|
||||
{
|
||||
public partial class Funtion
|
||||
{
|
||||
/// <summary>
|
||||
/// 发动机类型转换表
|
||||
/// SELECT ID,发动机机型代码 FROM MES_计划BOM_发动机型号代码
|
||||
/// </summary>
|
||||
public static Hashtable hashtable_EngineTypeID = new Hashtable();
|
||||
/// <summary>
|
||||
/// 记录工件到位的发动机机型代码
|
||||
/// </summary>
|
||||
public static Hashtable hashtable_EngineGetOver_EngineTypeID = new Hashtable();
|
||||
/// <summary>
|
||||
/// 记录工件到位的发动机机型
|
||||
/// </summary>
|
||||
public static Hashtable hashtable_EngineGetOver_EngineType = new Hashtable();
|
||||
/// <summary>
|
||||
/// 记录工件到位的发动机号
|
||||
/// </summary>
|
||||
public static Hashtable hashtable_EngineGetOver_EngineID = new Hashtable();
|
||||
/// <summary>
|
||||
/// 记录工件到位的订单号
|
||||
/// </summary>
|
||||
public static Hashtable hashtable_EngineGetOver_OrderForm = new Hashtable();
|
||||
|
||||
public static Hashtable hashtable_EngineGetOver = new Hashtable();
|
||||
|
||||
public static Hashtable hashtable_PartPalletCode = new Hashtable();
|
||||
/// <summary>
|
||||
/// 保存质量数据和过站信息
|
||||
/// </summary>
|
||||
/// <param name="e"></param>
|
||||
public static void MIS_Funtion(object e)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
string recData = e.ToString();
|
||||
List<string> dataArray = DoWhatPlc.MessageText.GetCmdStringList(recData);
|
||||
|
||||
//string[] dataArray = recData.Split('|');
|
||||
//if (dataArray.Count != 4)
|
||||
//return;
|
||||
//消息来源
|
||||
string m_Source = dataArray[0].ToString();
|
||||
//消息类型
|
||||
string m_Command = dataArray[1].ToString();
|
||||
//工位号
|
||||
string m_OpName = dataArray[2].ToString();
|
||||
//消息参数
|
||||
string m_Value = dataArray[3].ToString();
|
||||
|
||||
DoWhatPlc.CustomeEvetnArgs msgEvent = Newtonsoft.Json.JsonConvert.DeserializeObject<DoWhatPlc.CustomeEvetnArgs>(m_Value);
|
||||
//DoWhatPlc.ReturnValueString rv = Newtonsoft.Json.JsonConvert.DeserializeObject<DoWhatPlc.ReturnValueString>(m_Value);
|
||||
//Console.WriteLine($"【【{rv.TagID}【【【【{ rv.TagKeepTime}");
|
||||
if (msgEvent == null) return;
|
||||
int tagType;
|
||||
int tagTypeCodeID;
|
||||
string opName;
|
||||
string tagValue;
|
||||
string tagid;
|
||||
//DoWhatPlc.ReturnValueString msgEvent = rv;
|
||||
if (msgEvent.TagValue == null) return;
|
||||
tagType = Convert.ToInt32(msgEvent.TagTypeID);
|
||||
opName = msgEvent.OpName.ToString();
|
||||
tagid = msgEvent.TagID.ToString();
|
||||
tagTypeCodeID = Convert.ToInt32(msgEvent.TagTypeCodeID);
|
||||
|
||||
|
||||
switch (tagType)
|
||||
{
|
||||
case 11:
|
||||
switch (msgEvent.TagValue.ToString().ToLower())
|
||||
{
|
||||
case "1":
|
||||
case "true":
|
||||
tagValue = "1";
|
||||
break;
|
||||
default:
|
||||
tagValue = "0";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
tagValue = msgEvent.TagValue.ToString();
|
||||
break;
|
||||
}
|
||||
///根据信号处理逻辑
|
||||
switch (tagTypeCodeID)
|
||||
{
|
||||
case 19:
|
||||
//允许保存
|
||||
MesRead(opName, tagValue, tagid);
|
||||
break;
|
||||
case 14:
|
||||
//心跳
|
||||
//Heartbeat(opName, tagValue);
|
||||
break;
|
||||
case 44://PLC传递机型过后 才允许保存过站信息,否则不允许保存
|
||||
//EngTypeGetOver(opName, tagValue);
|
||||
break;
|
||||
case 2://工件到位 离开信息
|
||||
|
||||
if (tagValue == "0")
|
||||
{
|
||||
bool S_EngineGetOver;
|
||||
MIS_BASE.Read_EngineGetOver_PLC(opName, out S_EngineGetOver);
|
||||
//传递机型
|
||||
//if (S_EngineGetOver)
|
||||
{
|
||||
//if (hashtable_EngineGetOver[opName].ToString() == "1")
|
||||
{
|
||||
WorkStart(msgEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 51:
|
||||
//if (hashtableOpName_IsHaveComputer[opName].ToString() == "1")
|
||||
//{
|
||||
// SaveProductLeaveData(opName, 1);
|
||||
//}
|
||||
|
||||
break;
|
||||
case 8:
|
||||
//if (hashtableOpName_IsHaveComputer[opName].ToString() == "1")
|
||||
//{
|
||||
// SaveProductLeaveData(opName, 2);
|
||||
//}
|
||||
break;
|
||||
case 103:
|
||||
|
||||
//Alarm_Insert(msgEvent);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
////ApplicationLog.WriteLog(err, err.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//public static void MIS_Funtion(object e)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
|
||||
// string recData = e.ToString();
|
||||
// string[] dataArray = recData.Split('|');
|
||||
// if (dataArray.Length != 4)
|
||||
// return;
|
||||
// //消息来源
|
||||
// string m_Source = dataArray[0].ToString();
|
||||
// //消息类型
|
||||
// string m_Command = dataArray[1].ToString();
|
||||
// //工位号
|
||||
// string m_OpName = dataArray[2].ToString();
|
||||
// //消息参数
|
||||
// string m_Value = dataArray[3].ToString();
|
||||
|
||||
// DoWhatPlc.ReturnValueString rv = Newtonsoft.Json.JsonConvert.DeserializeObject<DoWhatPlc.ReturnValueString>(m_Value);
|
||||
// //Console.WriteLine($"【【{rv.TagID}【【【【{ rv.TagKeepTime}");
|
||||
// if (rv == null) return;
|
||||
// int tagType;
|
||||
// int tagTypeCodeID;
|
||||
// string opName;
|
||||
// string tagValue;
|
||||
// int tagid;
|
||||
// DoWhatPlc.ReturnValueString msgEvent = rv;
|
||||
// if (msgEvent.TagValue == null) return;
|
||||
// tagType = Convert.ToInt32(msgEvent.TagTypeID);
|
||||
// opName = msgEvent.OpName.ToString();
|
||||
// tagid = Convert.ToInt32(msgEvent.TagID);
|
||||
// tagTypeCodeID = Convert.ToInt32(msgEvent.TagTypeCodeID);
|
||||
|
||||
|
||||
// switch (tagType)
|
||||
// {
|
||||
// case 11:
|
||||
// switch (msgEvent.TagValue.ToLower())
|
||||
// {
|
||||
// case "1":
|
||||
// case "true":
|
||||
// tagValue = "1";
|
||||
// break;
|
||||
// default:
|
||||
// tagValue = "0";
|
||||
// break;
|
||||
// }
|
||||
// break;
|
||||
// default:
|
||||
// tagValue = msgEvent.TagValue.ToString();
|
||||
// break;
|
||||
// }
|
||||
// ///根据信号处理逻辑
|
||||
// switch (tagTypeCodeID)
|
||||
// {
|
||||
// case 19:
|
||||
// //允许保存
|
||||
// MesRead(opName, tagValue, tagid);
|
||||
// break;
|
||||
// case 14:
|
||||
// //心跳
|
||||
// //Heartbeat(opName, tagValue);
|
||||
// break;
|
||||
// case 44://PLC传递机型过后 才允许保存过站信息,否则不允许保存
|
||||
// EngTypeGetOver(opName, tagValue);
|
||||
// break;
|
||||
// case 2://工件到位 离开信息
|
||||
|
||||
// if (tagValue == "0")
|
||||
// {
|
||||
// //传递机型
|
||||
// //if (hashtable_EngineGetOver.Contains(opName))
|
||||
// {
|
||||
// //if (hashtable_EngineGetOver[opName].ToString() == "1")
|
||||
// {
|
||||
// WorkStart(e);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
// case 51:
|
||||
// //if (hashtableOpName_IsHaveComputer[opName].ToString() == "1")
|
||||
// //{
|
||||
// // SaveProductLeaveData(opName, 1);
|
||||
// //}
|
||||
|
||||
// break;
|
||||
// case 8:
|
||||
// //if (hashtableOpName_IsHaveComputer[opName].ToString() == "1")
|
||||
// //{
|
||||
// // SaveProductLeaveData(opName, 2);
|
||||
// //}
|
||||
// break;
|
||||
// case 103:
|
||||
|
||||
// Alarm_Insert(e);
|
||||
|
||||
// break;
|
||||
// }
|
||||
|
||||
// }
|
||||
// catch (Exception err)
|
||||
// {
|
||||
// ////ApplicationLog.WriteLog(err, err.Message);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// 有关程序集的一般信息由以下
|
||||
// 控制。更改这些特性值可修改
|
||||
// 与程序集关联的信息。
|
||||
[assembly: AssemblyTitle("MIS_FuntionSaveData")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("MIS_FuntionSaveData")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2022")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// 将 ComVisible 设置为 false 会使此程序集中的类型
|
||||
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
|
||||
//请将此类型的 ComVisible 特性设置为 true。
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
|
||||
[assembly: Guid("55b510c1-59e9-4bfd-ae84-d76d46f6e365")]
|
||||
|
||||
// 程序集的版本信息由下列四个值组成:
|
||||
//
|
||||
// 主版本
|
||||
// 次版本
|
||||
// 生成号
|
||||
// 修订号
|
||||
//
|
||||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
|
||||
//通过使用 "*",如下所示:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
Reference in New Issue
Block a user