|
|
|
@ -0,0 +1,866 @@
|
|
|
|
|
using HslCommunication.Profinet.Siemens;
|
|
|
|
|
using Mesnac.Action.ChemicalWeighing.DBHelper;
|
|
|
|
|
using Mesnac.Action.ChemicalWeighing.Entity;
|
|
|
|
|
using Mesnac.Action.ChemicalWeighing.Entity.PptPlan;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace Mesnac.Action.ChemicalWeighing.Services
|
|
|
|
|
{
|
|
|
|
|
public class PlanHelperServer
|
|
|
|
|
{
|
|
|
|
|
#region 更新任务状态
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 更新任务状态
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static void ExecPlanState()
|
|
|
|
|
{
|
|
|
|
|
bool result = true;
|
|
|
|
|
|
|
|
|
|
#region 获取当前计划号,判断当前计划状态
|
|
|
|
|
//读取配方编码获取配方物料所在的工位,根据工位查询状态
|
|
|
|
|
//当PLC状态未"1" PLC准备好 上位机读取数据
|
|
|
|
|
//存盘完成后上位机需要将PLC点位置为2
|
|
|
|
|
//点位DBW0 设定PLC需要执行次数,点位DBW212 为计量秤称量批次,可以此判断计划是否完成
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
result = false;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine($"执行称量任务异常:{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
finally { result = true; }
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 保存数据
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 保存数据 PLC点位信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="listMaterial">计划列表</param>
|
|
|
|
|
/// <returns>是否设置成功</returns>
|
|
|
|
|
public static void SavePlcData()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
SiemensS7Net plc = PlcConnect.Instance;
|
|
|
|
|
int plt_Set_Plan_Serial = plc.ReadInt16("DB114.DBW126").Content;//执行序号 Plan_Serial
|
|
|
|
|
List<Xl_DownLoadPlan> materialList = PlanDbHelper.GetExecPlan(plt_Set_Plan_Serial);//正在执行的任务
|
|
|
|
|
if (materialList == null || materialList.Count == 0) { return; }
|
|
|
|
|
materialList.OrderBy(d => d.Station);
|
|
|
|
|
foreach (var item in materialList)
|
|
|
|
|
{
|
|
|
|
|
switch (item.Station)
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
|
|
|
|
if (plc.ReadInt16("DB110.DBW0").Content == 1)//1工位A
|
|
|
|
|
{
|
|
|
|
|
int batch = plc.ReadInt16("DB110.DBW152").Content;//工位批次
|
|
|
|
|
Console.WriteLine($"工位批次:{batch}");
|
|
|
|
|
decimal real_Weight = Convert.ToDecimal(plc.ReadInt16("DB110.DBW150").Content) / 1000;//实际重量
|
|
|
|
|
Console.WriteLine($"实际重量:{real_Weight}");
|
|
|
|
|
bool result = SaveToData(item, batch, real_Weight);
|
|
|
|
|
Console.WriteLine($"保存结果{result}");
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
//存盘成功上位机完成置为2
|
|
|
|
|
plc.Write("DB110.DBW0", short.Parse("2"));
|
|
|
|
|
Console.WriteLine("1工位存盘成功上位机完成置为2");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
if (plc.ReadInt16("DB110.DBW2").Content == 1)//1工位A
|
|
|
|
|
{
|
|
|
|
|
int batch = plc.ReadInt16("DB110.DBW152").Content;//工位批次
|
|
|
|
|
Console.WriteLine($"工位批次:{batch}");
|
|
|
|
|
decimal real_Weight = Convert.ToDecimal(plc.ReadInt16("DB110.DBW150").Content) / 1000;//实际重量
|
|
|
|
|
Console.WriteLine($"实际重量:{real_Weight}");
|
|
|
|
|
bool result = SaveToData(item, batch, real_Weight);
|
|
|
|
|
Console.WriteLine($"保存结果{result}");
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
//存盘成功上位机完成置为2
|
|
|
|
|
plc.Write("DB110.DBW2", short.Parse("2"));
|
|
|
|
|
Console.WriteLine("2工位存盘成功上位机完成置为2");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
if (plc.ReadInt16("DB110.DBW6").Content == 1)//1工位A
|
|
|
|
|
{
|
|
|
|
|
int batch = plc.ReadInt16("DB110.DBW156").Content;//工位批次
|
|
|
|
|
Console.WriteLine($"工位批次:{batch}");
|
|
|
|
|
decimal real_Weight = Convert.ToDecimal(plc.ReadInt16("DB110.DBW154").Content) / 1000;//实际重量
|
|
|
|
|
Console.WriteLine($"实际重量:{real_Weight}");
|
|
|
|
|
bool result = SaveToData(item, batch, real_Weight);
|
|
|
|
|
Console.WriteLine($"保存结果{result}");
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
//存盘成功上位机完成置为2
|
|
|
|
|
plc.Write("DB110.DBW6", short.Parse("2"));
|
|
|
|
|
Console.WriteLine("3工位存盘成功上位机完成置为2");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
if (plc.ReadInt16("DB110.DBW8").Content == 1)//1工位A
|
|
|
|
|
{
|
|
|
|
|
int batch = plc.ReadInt16("DB110.DBW156").Content;//工位批次
|
|
|
|
|
Console.WriteLine($"工位批次:{batch}");
|
|
|
|
|
decimal real_Weight = Convert.ToDecimal(plc.ReadInt16("DB110.DBW156").Content) / 1000;//实际重量
|
|
|
|
|
Console.WriteLine($"实际重量:{real_Weight}");
|
|
|
|
|
bool result = SaveToData(item, batch, real_Weight);
|
|
|
|
|
Console.WriteLine($"保存结果{result}");
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
//存盘成功上位机完成置为2
|
|
|
|
|
plc.Write("DB110.DBW8", short.Parse("2"));
|
|
|
|
|
Console.WriteLine("4工位存盘成功上位机完成置为2");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 5:
|
|
|
|
|
if (plc.ReadInt16("DB110.DBW12").Content == 1)//1工位A
|
|
|
|
|
{
|
|
|
|
|
int batch = plc.ReadInt16("DB110.DBW160").Content;//工位批次
|
|
|
|
|
Console.WriteLine($"工位批次:{batch}");
|
|
|
|
|
decimal real_Weight = Convert.ToDecimal(plc.ReadInt16("DB110.DBW158").Content) / 1000;//实际重量
|
|
|
|
|
Console.WriteLine($"实际重量:{real_Weight}");
|
|
|
|
|
bool result = SaveToData(item, batch, real_Weight);
|
|
|
|
|
Console.WriteLine($"保存结果{result}");
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
//存盘成功上位机完成置为2
|
|
|
|
|
plc.Write("DB110.DBW12", short.Parse("2"));
|
|
|
|
|
Console.WriteLine("5工位存盘成功上位机完成置为2");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 6:
|
|
|
|
|
if (plc.ReadInt16("DB110.DBW14").Content == 1)//1工位A
|
|
|
|
|
{
|
|
|
|
|
int batch = plc.ReadInt16("DB110.DBW160").Content;//工位批次
|
|
|
|
|
Console.WriteLine($"工位批次:{batch}");
|
|
|
|
|
decimal real_Weight = Convert.ToDecimal(plc.ReadInt16("DB110.DBW158").Content) / 1000;//实际重量
|
|
|
|
|
Console.WriteLine($"实际重量:{real_Weight}");
|
|
|
|
|
bool result = SaveToData(item, batch, real_Weight);
|
|
|
|
|
Console.WriteLine($"保存结果{result}");
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
//存盘成功上位机完成置为2
|
|
|
|
|
plc.Write("DB110.DBW14", short.Parse("2"));
|
|
|
|
|
Console.WriteLine("6工位存盘成功上位机完成置为2");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 7:
|
|
|
|
|
if (plc.ReadInt16("DB110.DBW18").Content == 1)//1工位A
|
|
|
|
|
{
|
|
|
|
|
int batch = plc.ReadInt16("DB110.DBW164").Content;//工位批次
|
|
|
|
|
Console.WriteLine($"工位批次:{batch}");
|
|
|
|
|
decimal real_Weight = Convert.ToDecimal(plc.ReadInt16("DB110.DBW162").Content) / 1000;//实际重量
|
|
|
|
|
Console.WriteLine($"实际重量:{real_Weight}");
|
|
|
|
|
bool result = SaveToData(item, batch, real_Weight);
|
|
|
|
|
Console.WriteLine($"保存结果{result}");
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
//存盘成功上位机完成置为2
|
|
|
|
|
plc.Write("DB110.DBW18", short.Parse("2"));
|
|
|
|
|
Console.WriteLine("7工位存盘成功上位机完成置为2");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 8:
|
|
|
|
|
if (plc.ReadInt16("DB110.DBW20").Content == 1)//1工位A
|
|
|
|
|
{
|
|
|
|
|
int batch = plc.ReadInt16("DB110.DBW164").Content;//工位批次
|
|
|
|
|
Console.WriteLine($"工位批次:{batch}");
|
|
|
|
|
decimal real_Weight = Convert.ToDecimal(plc.ReadInt16("DB110.DBW162").Content) / 1000;//实际重量
|
|
|
|
|
Console.WriteLine($"实际重量:{real_Weight}");
|
|
|
|
|
bool result = SaveToData(item, batch, real_Weight);
|
|
|
|
|
Console.WriteLine($"保存结果{result}");
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
//存盘成功上位机完成置为2
|
|
|
|
|
plc.Write("DB110.DBW20", short.Parse("2"));
|
|
|
|
|
Console.WriteLine("8工位存盘成功上位机完成置为2");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 9:
|
|
|
|
|
if (plc.ReadInt16("DB110.DBW24").Content == 1)//1工位A
|
|
|
|
|
{
|
|
|
|
|
int batch = plc.ReadInt16("DB110.DBW168").Content;//工位批次
|
|
|
|
|
Console.WriteLine($"工位批次:{batch}");
|
|
|
|
|
decimal real_Weight = Convert.ToDecimal(plc.ReadInt16("DB110.DBW166").Content) / 1000;//实际重量
|
|
|
|
|
Console.WriteLine($"实际重量:{real_Weight}");
|
|
|
|
|
bool result = SaveToData(item, batch, real_Weight);
|
|
|
|
|
Console.WriteLine($"保存结果{result}");
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
//存盘成功上位机完成置为2
|
|
|
|
|
plc.Write("DB110.DBW24", short.Parse("2"));
|
|
|
|
|
Console.WriteLine("9工位存盘成功上位机完成置为2");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 10:
|
|
|
|
|
if (plc.ReadInt16("DB110.DBW26").Content == 1)//1工位A
|
|
|
|
|
{
|
|
|
|
|
int batch = plc.ReadInt16("DB110.DBW168").Content;//工位批次
|
|
|
|
|
Console.WriteLine($"工位批次:{batch}");
|
|
|
|
|
decimal real_Weight = Convert.ToDecimal(plc.ReadInt16("DB110.DBW166").Content) / 1000;//实际重量
|
|
|
|
|
Console.WriteLine($"实际重量:{real_Weight}");
|
|
|
|
|
bool result = SaveToData(item, batch, real_Weight);
|
|
|
|
|
Console.WriteLine($"保存结果{result}");
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
//存盘成功上位机完成置为2
|
|
|
|
|
plc.Write("DB110.DBW26", short.Parse("2"));
|
|
|
|
|
Console.WriteLine("10工位存盘成功上位机完成置为2");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 11:
|
|
|
|
|
if (plc.ReadInt16("DB110.DBW30").Content == 1)//1工位A
|
|
|
|
|
{
|
|
|
|
|
int batch = plc.ReadInt16("DB110.DBW172").Content;//工位批次
|
|
|
|
|
Console.WriteLine($"工位批次:{batch}");
|
|
|
|
|
decimal real_Weight = Convert.ToDecimal(plc.ReadInt16("DB110.DBW170").Content) / 1000;//实际重量
|
|
|
|
|
Console.WriteLine($"实际重量:{real_Weight}");
|
|
|
|
|
bool result = SaveToData(item, batch, real_Weight);
|
|
|
|
|
Console.WriteLine($"保存结果{result}");
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
//存盘成功上位机完成置为2
|
|
|
|
|
plc.Write("DB110.DBW30", short.Parse("2"));
|
|
|
|
|
Console.WriteLine("11工位存盘成功上位机完成置为2");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 12:
|
|
|
|
|
if (plc.ReadInt16("DB110.DBW32").Content == 1)//1工位A
|
|
|
|
|
{
|
|
|
|
|
int batch = plc.ReadInt16("DB110.DBW172").Content;//工位批次
|
|
|
|
|
Console.WriteLine($"工位批次:{batch}");
|
|
|
|
|
decimal real_Weight = Convert.ToDecimal(plc.ReadInt16("DB110.DBW170").Content) / 1000;//实际重量
|
|
|
|
|
Console.WriteLine($"实际重量:{real_Weight}");
|
|
|
|
|
bool result = SaveToData(item, batch, real_Weight);
|
|
|
|
|
Console.WriteLine($"保存结果{result}");
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
//存盘成功上位机完成置为2
|
|
|
|
|
plc.Write("DB110.DBW32", short.Parse("2"));
|
|
|
|
|
Console.WriteLine("12工位存盘成功上位机完成置为2");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 13:
|
|
|
|
|
if (plc.ReadInt16("DB110.DBW36").Content == 1)//1工位A
|
|
|
|
|
{
|
|
|
|
|
int batch = plc.ReadInt16("DB110.DBW176").Content;//工位批次
|
|
|
|
|
Console.WriteLine($"工位批次:{batch}");
|
|
|
|
|
decimal real_Weight = Convert.ToDecimal(plc.ReadInt16("DB110.DBW174").Content) / 1000;//实际重量
|
|
|
|
|
Console.WriteLine($"实际重量:{real_Weight}");
|
|
|
|
|
bool result = SaveToData(item, batch, real_Weight);
|
|
|
|
|
Console.WriteLine($"保存结果{result}");
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
//存盘成功上位机完成置为2
|
|
|
|
|
plc.Write("DB110.DBW36", short.Parse("2"));
|
|
|
|
|
Console.WriteLine("13工位存盘成功上位机完成置为2");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 14:
|
|
|
|
|
if (plc.ReadInt16("DB110.DBW38").Content == 1)//1工位A
|
|
|
|
|
{
|
|
|
|
|
int batch = plc.ReadInt16("DB110.DBW176").Content;//工位批次
|
|
|
|
|
Console.WriteLine($"工位批次:{batch}");
|
|
|
|
|
decimal real_Weight = Convert.ToDecimal(plc.ReadInt16("DB110.DBW174").Content) / 1000;//实际重量
|
|
|
|
|
Console.WriteLine($"实际重量:{real_Weight}");
|
|
|
|
|
bool result = SaveToData(item, batch, real_Weight);
|
|
|
|
|
Console.WriteLine($"保存结果{result}");
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
//存盘成功上位机完成置为2
|
|
|
|
|
plc.Write("DB110.DBW38", short.Parse("2"));
|
|
|
|
|
Console.WriteLine("14工位存盘成功上位机完成置为2");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 15:
|
|
|
|
|
if (plc.ReadInt16("DB110.DBW42").Content == 1)//1工位A
|
|
|
|
|
{
|
|
|
|
|
int batch = plc.ReadInt16("DB110.DBW180").Content;//工位批次
|
|
|
|
|
Console.WriteLine($"工位批次:{batch}");
|
|
|
|
|
decimal real_Weight = Convert.ToDecimal(plc.ReadInt16("DB110.DBW178").Content) / 1000;//实际重量
|
|
|
|
|
Console.WriteLine($"实际重量:{real_Weight}");
|
|
|
|
|
bool result = SaveToData(item, batch, real_Weight);
|
|
|
|
|
Console.WriteLine($"保存结果{result}");
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
//存盘成功上位机完成置为2
|
|
|
|
|
plc.Write("DB110.DBW42", short.Parse("2"));
|
|
|
|
|
Console.WriteLine("15工位存盘成功上位机完成置为2");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 16:
|
|
|
|
|
if (plc.ReadInt16("DB110.DBW44").Content == 1)//1工位A
|
|
|
|
|
{
|
|
|
|
|
int batch = plc.ReadInt16("DB110.DBW180").Content;//工位批次
|
|
|
|
|
Console.WriteLine($"工位批次:{batch}");
|
|
|
|
|
decimal real_Weight = Convert.ToDecimal(plc.ReadInt16("DB110.DBW178").Content) / 1000;//实际重量
|
|
|
|
|
Console.WriteLine($"实际重量:{real_Weight}");
|
|
|
|
|
bool result = SaveToData(item, batch, real_Weight);
|
|
|
|
|
Console.WriteLine($"保存结果{result}");
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
//存盘成功上位机完成置为2
|
|
|
|
|
plc.Write("DB110.DBW44", short.Parse("2"));
|
|
|
|
|
Console.WriteLine("16工位存盘成功上位机完成置为2");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 17:
|
|
|
|
|
if (plc.ReadInt16("DB110.DBW48").Content == 1)//1工位A
|
|
|
|
|
{
|
|
|
|
|
int batch = plc.ReadInt16("DB110.DBW184").Content;//工位批次
|
|
|
|
|
Console.WriteLine($"工位批次:{batch}");
|
|
|
|
|
decimal real_Weight = Convert.ToDecimal(plc.ReadInt16("DB110.DBW182").Content) / 1000;//实际重量
|
|
|
|
|
Console.WriteLine($"实际重量:{real_Weight}");
|
|
|
|
|
bool result = SaveToData(item, batch, real_Weight);
|
|
|
|
|
Console.WriteLine($"保存结果{result}");
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
//存盘成功上位机完成置为2
|
|
|
|
|
plc.Write("DB110.DBW48", short.Parse("2"));
|
|
|
|
|
Console.WriteLine("17工位存盘成功上位机完成置为2");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 18:
|
|
|
|
|
if (plc.ReadInt16("DB110.DBW50").Content == 1)//1工位A
|
|
|
|
|
{
|
|
|
|
|
int batch = plc.ReadInt16("DB110.DBW184").Content;//工位批次
|
|
|
|
|
Console.WriteLine($"工位批次:{batch}");
|
|
|
|
|
decimal real_Weight = Convert.ToDecimal(plc.ReadInt16("DB110.DBW182").Content) / 1000;//实际重量
|
|
|
|
|
Console.WriteLine($"实际重量:{real_Weight}");
|
|
|
|
|
bool result = SaveToData(item, batch, real_Weight);
|
|
|
|
|
Console.WriteLine($"保存结果{result}");
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
//存盘成功上位机完成置为2
|
|
|
|
|
plc.Write("DB110.DBW50", short.Parse("2"));
|
|
|
|
|
Console.WriteLine("18工位存盘成功上位机完成置为2");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 19:
|
|
|
|
|
if (plc.ReadInt16("DB110.DBW54").Content == 1)//1工位A
|
|
|
|
|
{
|
|
|
|
|
int batch = plc.ReadInt16("DB110.DBW188").Content;//工位批次
|
|
|
|
|
Console.WriteLine($"工位批次:{batch}");
|
|
|
|
|
decimal real_Weight = Convert.ToDecimal(plc.ReadInt16("DB110.DBW186").Content) / 1000;//实际重量
|
|
|
|
|
Console.WriteLine($"实际重量:{real_Weight}");
|
|
|
|
|
bool result = SaveToData(item, batch, real_Weight);
|
|
|
|
|
Console.WriteLine($"保存结果{result}");
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
//存盘成功上位机完成置为2
|
|
|
|
|
plc.Write("DB110.DBW54", short.Parse("2"));
|
|
|
|
|
Console.WriteLine("19工位存盘成功上位机完成置为2");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 20:
|
|
|
|
|
if (plc.ReadInt16("DB110.DBW56").Content == 1)//1工位A
|
|
|
|
|
{
|
|
|
|
|
int batch = plc.ReadInt16("DB110.DBW188").Content;//工位批次
|
|
|
|
|
Console.WriteLine($"工位批次:{batch}");
|
|
|
|
|
decimal real_Weight = Convert.ToDecimal(plc.ReadInt16("DB110.DBW186").Content) / 1000;//实际重量
|
|
|
|
|
Console.WriteLine($"实际重量:{real_Weight}");
|
|
|
|
|
bool result = SaveToData(item, batch, real_Weight);
|
|
|
|
|
Console.WriteLine($"保存结果{result}");
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
//存盘成功上位机完成置为2
|
|
|
|
|
plc.Write("DB110.DBW56", short.Parse("2"));
|
|
|
|
|
Console.WriteLine("20工位存盘成功上位机完成置为2");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 21:
|
|
|
|
|
if (plc.ReadInt16("DB110.DBW60").Content == 1)//1工位A
|
|
|
|
|
{
|
|
|
|
|
int batch = plc.ReadInt16("DB110.DBW192").Content;//工位批次
|
|
|
|
|
Console.WriteLine($"工位批次:{batch}");
|
|
|
|
|
decimal real_Weight = Convert.ToDecimal(plc.ReadInt16("DB110.DBW190").Content) / 1000;//实际重量
|
|
|
|
|
Console.WriteLine($"实际重量:{real_Weight}");
|
|
|
|
|
bool result = SaveToData(item, batch, real_Weight);
|
|
|
|
|
Console.WriteLine($"保存结果{result}");
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
//存盘成功上位机完成置为2
|
|
|
|
|
plc.Write("DB110.DBW60", short.Parse("2"));
|
|
|
|
|
Console.WriteLine("21工位存盘成功上位机完成置为2");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 22:
|
|
|
|
|
if (plc.ReadInt16("DB110.DBW62").Content == 1)//1工位A
|
|
|
|
|
{
|
|
|
|
|
int batch = plc.ReadInt16("DB110.DBW192").Content;//工位批次
|
|
|
|
|
Console.WriteLine($"工位批次:{batch}");
|
|
|
|
|
decimal real_Weight = Convert.ToDecimal(plc.ReadInt16("DB110.DBW190").Content) / 1000;//实际重量
|
|
|
|
|
Console.WriteLine($"实际重量:{real_Weight}");
|
|
|
|
|
bool result = SaveToData(item, batch, real_Weight);
|
|
|
|
|
Console.WriteLine($"保存结果{result}");
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
//存盘成功上位机完成置为2
|
|
|
|
|
plc.Write("DB110.DBW62", short.Parse("2"));
|
|
|
|
|
Console.WriteLine("22工位存盘成功上位机完成置为2");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 23:
|
|
|
|
|
if (plc.ReadInt16("DB110.DBW66").Content == 1)//1工位A
|
|
|
|
|
{
|
|
|
|
|
int batch = plc.ReadInt16("DB110.DBW196").Content;//工位批次
|
|
|
|
|
Console.WriteLine($"工位批次:{batch}");
|
|
|
|
|
decimal real_Weight = Convert.ToDecimal(plc.ReadInt16("DB110.DBW194").Content) / 1000;//实际重量
|
|
|
|
|
Console.WriteLine($"实际重量:{real_Weight}");
|
|
|
|
|
bool result = SaveToData(item, batch, real_Weight);
|
|
|
|
|
Console.WriteLine($"保存结果{result}");
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
//存盘成功上位机完成置为2
|
|
|
|
|
plc.Write("DB110.DBW66", short.Parse("2"));
|
|
|
|
|
Console.WriteLine("23工位存盘成功上位机完成置为2");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 24:
|
|
|
|
|
if (plc.ReadInt16("DB110.DBW68").Content == 1)//1工位A
|
|
|
|
|
{
|
|
|
|
|
int batch = plc.ReadInt16("DB110.DBW196").Content;//工位批次
|
|
|
|
|
Console.WriteLine($"工位批次:{batch}");
|
|
|
|
|
decimal real_Weight = Convert.ToDecimal(plc.ReadInt16("DB110.DBW194").Content) / 1000;//实际重量
|
|
|
|
|
Console.WriteLine($"实际重量:{real_Weight}");
|
|
|
|
|
bool result = SaveToData(item, batch, real_Weight);
|
|
|
|
|
Console.WriteLine($"保存结果{result}");
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
//存盘成功上位机完成置为2
|
|
|
|
|
plc.Write("DB110.DBW68", short.Parse("2"));
|
|
|
|
|
Console.WriteLine("24工位存盘成功上位机完成置为2");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 25:
|
|
|
|
|
if (plc.ReadInt16("DB110.DBW72").Content == 1)//1工位A
|
|
|
|
|
{
|
|
|
|
|
int batch = plc.ReadInt16("DB110.DBW200").Content;//工位批次
|
|
|
|
|
Console.WriteLine($"工位批次:{batch}");
|
|
|
|
|
decimal real_Weight = Convert.ToDecimal(plc.ReadInt16("DB110.DBW198").Content) / 1000;//实际重量
|
|
|
|
|
Console.WriteLine($"实际重量:{real_Weight}");
|
|
|
|
|
bool result = SaveToData(item, batch, real_Weight);
|
|
|
|
|
Console.WriteLine($"保存结果{result}");
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
//存盘成功上位机完成置为2
|
|
|
|
|
plc.Write("DB110.DBW72", short.Parse("2"));
|
|
|
|
|
Console.WriteLine("25工位存盘成功上位机完成置为2");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 26:
|
|
|
|
|
if (plc.ReadInt16("DB110.DBW74").Content == 1)//1工位A
|
|
|
|
|
{
|
|
|
|
|
int batch = plc.ReadInt16("DB110.DBW200").Content;//工位批次
|
|
|
|
|
Console.WriteLine($"工位批次:{batch}");
|
|
|
|
|
decimal real_Weight = Convert.ToDecimal(plc.ReadInt16("DB110.DBW198").Content) / 1000;//实际重量
|
|
|
|
|
Console.WriteLine($"实际重量:{real_Weight}");
|
|
|
|
|
bool result = SaveToData(item, batch, real_Weight);
|
|
|
|
|
Console.WriteLine($"保存结果{result}");
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
//存盘成功上位机完成置为2
|
|
|
|
|
plc.Write("DB110.DBW74", short.Parse("2"));
|
|
|
|
|
Console.WriteLine("26工位存盘成功上位机完成置为2");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 27:
|
|
|
|
|
if (plc.ReadInt16("DB110.DBW78").Content == 1)//1工位A
|
|
|
|
|
{
|
|
|
|
|
int batch = plc.ReadInt16("DB110.DBW204").Content;//工位批次
|
|
|
|
|
Console.WriteLine($"工位批次:{batch}");
|
|
|
|
|
decimal real_Weight = Convert.ToDecimal(plc.ReadInt16("DB110.DBW202").Content) / 1000;//实际重量
|
|
|
|
|
Console.WriteLine($"实际重量:{real_Weight}");
|
|
|
|
|
bool result = SaveToData(item, batch, real_Weight);
|
|
|
|
|
Console.WriteLine($"保存结果{result}");
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
//存盘成功上位机完成置为2
|
|
|
|
|
plc.Write("DB110.DBW78", short.Parse("2"));
|
|
|
|
|
Console.WriteLine("27工位存盘成功上位机完成置为2");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 28:
|
|
|
|
|
if (plc.ReadInt16("DB110.DBW80").Content == 1)//1工位A
|
|
|
|
|
{
|
|
|
|
|
int batch = plc.ReadInt16("DB110.DBW204").Content;//工位批次
|
|
|
|
|
Console.WriteLine($"工位批次:{batch}");
|
|
|
|
|
decimal real_Weight = Convert.ToDecimal(plc.ReadInt16("DB110.DBW202").Content) / 1000;//实际重量
|
|
|
|
|
Console.WriteLine($"实际重量:{real_Weight}");
|
|
|
|
|
bool result = SaveToData(item, batch, real_Weight);
|
|
|
|
|
Console.WriteLine($"保存结果{result}");
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
//存盘成功上位机完成置为2
|
|
|
|
|
plc.Write("DB110.DBW80", short.Parse("2"));
|
|
|
|
|
Console.WriteLine("28工位存盘成功上位机完成置为2");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//检量秤检查结束信息
|
|
|
|
|
Xl_DownLoadPlan down = materialList.FirstOrDefault();
|
|
|
|
|
if (down == null) return;
|
|
|
|
|
|
|
|
|
|
if (down.IsPrenatalTest == 1)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine($"产前自检检量称:{plc.ReadInt16("DB110.DBW90").Content}");
|
|
|
|
|
if (plc.ReadInt16("DB110.DBW90").Content == 1)
|
|
|
|
|
{
|
|
|
|
|
double tcheckWeight = plc.ReadInt16("DB110.DBW210").Content / 1000;//检量秤重量
|
|
|
|
|
int tcheckBatch = plc.ReadInt16("DB110.DBW212").Content;//当前执行的批次
|
|
|
|
|
if (tcheckBatch == down.Plan_Num)
|
|
|
|
|
{
|
|
|
|
|
PlanDbHelper.UpdateCheckPlanCompletedQuantity(down, tcheckBatch, 8, DateTime.Now, tcheckWeight);
|
|
|
|
|
PlanDbHelper.UpdateCheckLrPlanCompletedQuantity(down, tcheckBatch, 8, DateTime.Now, tcheckWeight, down.FlagNum);
|
|
|
|
|
|
|
|
|
|
plc.Write("DB110.DBW90",short.Parse("2"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine($"执行保存工位称量数据异常:{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 存盘数据
|
|
|
|
|
public static bool SaveToData(Xl_DownLoadPlan item, int batch, decimal real_Weight)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
decimal error = real_Weight - item.Set_Weight;
|
|
|
|
|
|
|
|
|
|
if (item.IsPrenatalTest == 1)
|
|
|
|
|
{
|
|
|
|
|
bool result = SaveCHeckData(item, batch, real_Weight, error);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
return SavePlanInfo(item, batch, real_Weight, error);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 保存产前检查数据
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 保存产前检查数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="item"></param>
|
|
|
|
|
/// <param name="batch"></param>
|
|
|
|
|
/// <param name="real_Weight"></param>
|
|
|
|
|
/// <param name="error"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static bool SaveCHeckData(Xl_DownLoadPlan item, int batch, decimal real_Weight, decimal error)
|
|
|
|
|
{
|
|
|
|
|
LR_plan lrPlan = PlanDbHelper.GetLrPlan(item.Plan_Id, batch, item.FlagNum);
|
|
|
|
|
if (lrPlan != null)
|
|
|
|
|
{
|
|
|
|
|
//保存物料
|
|
|
|
|
LR_weigh weigh = new LR_weigh();
|
|
|
|
|
weigh.Dosing_ID = batch.ToString();
|
|
|
|
|
weigh.Plan_ID = item.Plan_Id;
|
|
|
|
|
weigh.Recipe_ID = item.Recipe_ID;
|
|
|
|
|
weigh.Bin_Serial = item.Station;
|
|
|
|
|
weigh.Material_ID = item.MaterialID;
|
|
|
|
|
weigh.Material_Name = item.Material_name;
|
|
|
|
|
weigh.Set_Weight = item.Set_Weight;
|
|
|
|
|
weigh.Set_Error = item.Set_Error;
|
|
|
|
|
weigh.Real_Weight = real_Weight;
|
|
|
|
|
weigh.Real_Error = error;
|
|
|
|
|
weigh.EndTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
weigh.MainId = lrPlan.ID;
|
|
|
|
|
bool saveResult = SaveDataToBDb(item, weigh, lrPlan, null, null, 0);
|
|
|
|
|
if (saveResult) return true;
|
|
|
|
|
else return false;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//保存计划
|
|
|
|
|
LR_plan plan = new LR_plan();
|
|
|
|
|
plan.Plan_Id = item.Plan_Id;
|
|
|
|
|
plan.Plan_Serial = item.Plan_Serial;
|
|
|
|
|
plan.Recipe_ID = item.Recipe_ID;
|
|
|
|
|
plan.Recipe_Name = item.Recipe_Name;
|
|
|
|
|
plan.Version = item.Version;
|
|
|
|
|
plan.Plan_Num = item.Plan_Num;
|
|
|
|
|
plan.Real_Num = batch;
|
|
|
|
|
plan.Shift_Id = item.Shift_Id;
|
|
|
|
|
plan.Shift_Class = item.Shift_Class;
|
|
|
|
|
plan.Total_Weight = real_Weight;
|
|
|
|
|
plan.Total_Error = error;
|
|
|
|
|
plan.IsRetransmission = item.IsRetransmission;
|
|
|
|
|
plan.Retransmission_Num = item.Retransmission_Num;
|
|
|
|
|
plan.FlagNum = item.FlagNum;
|
|
|
|
|
//保存物料
|
|
|
|
|
LR_weigh weigh = new LR_weigh();
|
|
|
|
|
weigh.Dosing_ID = batch.ToString();
|
|
|
|
|
weigh.Plan_ID = item.Plan_Id;
|
|
|
|
|
weigh.Recipe_ID = item.Recipe_ID;
|
|
|
|
|
weigh.Bin_Serial = item.Station;
|
|
|
|
|
weigh.Material_ID = item.MaterialID;
|
|
|
|
|
weigh.Material_Name = item.Material_name;
|
|
|
|
|
weigh.Set_Weight = item.Set_Weight;
|
|
|
|
|
weigh.Set_Error = item.Set_Error;
|
|
|
|
|
weigh.Real_Weight = real_Weight;
|
|
|
|
|
weigh.Real_Error = error;
|
|
|
|
|
weigh.EndTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
|
|
|
|
bool result = SaveDataToBDb(item, weigh, plan, null, null, 1);
|
|
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 根据料仓号实时更新料仓物料重量
|
|
|
|
|
public static bool SaveDataToBDb(Xl_DownLoadPlan item, LR_weigh lrWeigh, LR_plan lrPlan, Pmt_Bin bin, Hw_BinAlarm alarm, int key)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IFreeSql fsql = FreeHelper.Instance;
|
|
|
|
|
{
|
|
|
|
|
if (item.IsPrenatalTest == 1)
|
|
|
|
|
{
|
|
|
|
|
if (key == 1)
|
|
|
|
|
{
|
|
|
|
|
fsql.Transaction(() =>
|
|
|
|
|
{
|
|
|
|
|
var affrows = Convert.ToInt32(fsql.Insert<LR_plan>(lrPlan).ExecuteIdentity());
|
|
|
|
|
if (affrows < 1)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("存盘计划详细数据失败!");//抛出异常,回滚事务,事务退出
|
|
|
|
|
}
|
|
|
|
|
lrWeigh.MainId = affrows;//获取主键
|
|
|
|
|
affrows = fsql.Insert<LR_weigh>(lrWeigh).ExecuteAffrows();
|
|
|
|
|
//判断是否插入成功
|
|
|
|
|
if (affrows < 1)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("存盘物料详细数据失败!"); //抛出异常,回滚事务,事务退出
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
fsql.Transaction(() =>
|
|
|
|
|
{
|
|
|
|
|
var affrows = fsql.Insert<LR_weigh>(lrWeigh).ExecuteAffrows();
|
|
|
|
|
if (affrows < 1)
|
|
|
|
|
throw new Exception("存盘物料详细数据失败!");//抛出异常,回滚事务,事务退出
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (key == 1)
|
|
|
|
|
{
|
|
|
|
|
fsql.Transaction(() =>
|
|
|
|
|
{
|
|
|
|
|
var affrows = Convert.ToInt32(fsql.Insert<LR_plan>(lrPlan).ExecuteIdentity());
|
|
|
|
|
if (affrows < 1)
|
|
|
|
|
throw new Exception("存盘计划详细数据失败!");//抛出异常,回滚事务,事务退出
|
|
|
|
|
affrows = fsql.Insert<LR_weigh>(lrWeigh).ExecuteAffrows();
|
|
|
|
|
//判断是否插入成功
|
|
|
|
|
if (affrows < 1)
|
|
|
|
|
throw new Exception("存盘物料详细数据失败!"); //抛出异常,回滚事务,事务退出
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
fsql.Transaction(() =>
|
|
|
|
|
{
|
|
|
|
|
var affrows = fsql.Insert<LR_weigh>(lrWeigh).ExecuteAffrows();
|
|
|
|
|
//判断是否插入成功
|
|
|
|
|
if (affrows < 1)
|
|
|
|
|
throw new Exception("存盘物料详细数据失败!"); //抛出异常,回滚事务,事务退出
|
|
|
|
|
affrows = fsql.Update<Pmt_Bin>(bin.Bin_Serial).Set(a => a.BinWeight, bin.BinWeight).ExecuteAffrows();
|
|
|
|
|
//判断是否插入成功
|
|
|
|
|
if (affrows < 1)
|
|
|
|
|
throw new Exception("存盘物料详细数据失败!"); //抛出异常,回滚事务,事务退出
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine(ex.ToString());
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 保存非产前检查数据
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 保存非产前检查数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="item"></param>
|
|
|
|
|
/// <param name="batch"></param>
|
|
|
|
|
/// <param name="real_Weight"></param>
|
|
|
|
|
/// <param name="error"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
private static bool SavePlanInfo(Xl_DownLoadPlan item, int batch, decimal real_Weight, decimal error)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
LR_plan lrPlan = PlanDbHelper.GetLrPlan(item.Plan_Id, batch, item.FlagNum);
|
|
|
|
|
if (lrPlan != null)
|
|
|
|
|
{
|
|
|
|
|
decimal totalWeight = lrPlan.Total_Weight + real_Weight;
|
|
|
|
|
decimal totalError = lrPlan.Total_Error + error;
|
|
|
|
|
|
|
|
|
|
//保存物料
|
|
|
|
|
LR_weigh weigh = new LR_weigh();
|
|
|
|
|
weigh.Dosing_ID = batch.ToString();
|
|
|
|
|
weigh.Plan_ID = item.Plan_Id;
|
|
|
|
|
weigh.Recipe_ID = item.Recipe_ID;
|
|
|
|
|
weigh.Bin_Serial = item.Station;
|
|
|
|
|
weigh.Material_ID = item.MaterialID;
|
|
|
|
|
weigh.Material_Name = item.Material_name;
|
|
|
|
|
weigh.Set_Weight = item.Set_Weight;
|
|
|
|
|
weigh.Set_Error = item.Set_Error;
|
|
|
|
|
weigh.Real_Weight = real_Weight;
|
|
|
|
|
weigh.Real_Error = error;
|
|
|
|
|
weigh.MainId = lrPlan.ID;
|
|
|
|
|
weigh.EndTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
|
|
|
|
lrPlan.Plan_Id = item.Plan_Id;
|
|
|
|
|
lrPlan.Real_Num = batch;
|
|
|
|
|
lrPlan.Total_Weight = totalWeight;
|
|
|
|
|
lrPlan.Total_Error = totalError;
|
|
|
|
|
|
|
|
|
|
var binInfo = PlanDbHelper.GetFristBinInfo(item.Station);
|
|
|
|
|
binInfo.BinWeight = binInfo.BinWeight - real_Weight;
|
|
|
|
|
|
|
|
|
|
Hw_BinAlarm alarm = new Hw_BinAlarm();
|
|
|
|
|
alarm.BinId = item.Station;
|
|
|
|
|
alarm.BinName = item.StationName;
|
|
|
|
|
alarm.MaterialCode = item.MaterialID;
|
|
|
|
|
alarm.MaterialName = item.Material_name;
|
|
|
|
|
alarm.Weights = real_Weight;
|
|
|
|
|
alarm.TypeName = "出库";
|
|
|
|
|
|
|
|
|
|
return PlanDbHelper.UpdatePlanDetail(item, lrPlan, weigh, binInfo, alarm, 0);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//保存计划
|
|
|
|
|
LR_plan plan = new LR_plan();
|
|
|
|
|
plan.Plan_Id = item.Plan_Id;
|
|
|
|
|
plan.Plan_Serial = item.Plan_Serial;
|
|
|
|
|
plan.Recipe_ID = item.Recipe_ID;
|
|
|
|
|
plan.Recipe_Name = item.Recipe_Name;
|
|
|
|
|
plan.Version = item.Version;
|
|
|
|
|
plan.Plan_Num = item.Plan_Num;
|
|
|
|
|
plan.Real_Num = batch;
|
|
|
|
|
plan.Shift_Id = item.Shift_Id;
|
|
|
|
|
plan.Shift_Class = item.Shift_Class;
|
|
|
|
|
plan.Total_Weight = real_Weight;
|
|
|
|
|
plan.Total_Error = error;
|
|
|
|
|
plan.IsRetransmission = item.IsRetransmission;
|
|
|
|
|
plan.Retransmission_Num = item.Retransmission_Num;
|
|
|
|
|
|
|
|
|
|
//保存物料
|
|
|
|
|
LR_weigh weigh = new LR_weigh();
|
|
|
|
|
weigh.Dosing_ID = batch.ToString();
|
|
|
|
|
weigh.Plan_ID = item.Plan_Id;
|
|
|
|
|
weigh.Recipe_ID = item.Recipe_ID;
|
|
|
|
|
weigh.Bin_Serial = item.Station;
|
|
|
|
|
weigh.Material_ID = item.MaterialID;
|
|
|
|
|
weigh.Material_Name = item.Material_name;
|
|
|
|
|
weigh.Set_Weight = item.Set_Weight;
|
|
|
|
|
weigh.Set_Error = item.Set_Error;
|
|
|
|
|
weigh.Real_Weight = real_Weight;
|
|
|
|
|
weigh.Real_Error = error;
|
|
|
|
|
weigh.EndTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
|
|
|
|
var binInfo = PlanDbHelper.GetFristBinInfo(item.Station);
|
|
|
|
|
binInfo.Equip_Code = "00";
|
|
|
|
|
binInfo.BinWeight = binInfo.BinWeight - real_Weight;
|
|
|
|
|
|
|
|
|
|
Hw_BinAlarm alarm = new Hw_BinAlarm();
|
|
|
|
|
alarm.BinId = binInfo.Bin_Serial;
|
|
|
|
|
alarm.BinName = binInfo.Bin_Name;
|
|
|
|
|
alarm.MaterialCode = binInfo.Material_ID;
|
|
|
|
|
alarm.MaterialName = item.Material_name;
|
|
|
|
|
alarm.Weights = real_Weight;
|
|
|
|
|
alarm.TypeName = "出库";
|
|
|
|
|
|
|
|
|
|
return PlanDbHelper.UpdatePlanDetail(item, plan, weigh, binInfo, alarm, 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine(ex.Message);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|