You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
95 lines
6.6 KiB
C#
95 lines
6.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Mesnac.Action.ChemicalWeighing.FinishBatch
|
|
{
|
|
public class GHFinshBatchHelper
|
|
{
|
|
#region 冠合项目存盘数据
|
|
/// <summary>
|
|
/// 冠合项目数据存盘
|
|
/// </summary>
|
|
public static void SaveData()
|
|
{
|
|
try
|
|
{
|
|
#region 存盘信号读取
|
|
if (BasePlcHelper.Instance.GH_PC_ConfirmSDReady.NowValue.ToInt() == 1)
|
|
{
|
|
Entity.RecordSaveDataInfo recordSaveDataInfo = new Entity.RecordSaveDataInfo();
|
|
bool PlanId = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_SavePlanId, out int[] GH_PC_SavePlanId);
|
|
bool SaveCode = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_SaveCode, out int[] GH_PC_SaveCode);
|
|
bool SaveFinishedNum = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_SaveFinishedNum, out int[] GH_PC_SaveFinishedNum);
|
|
bool SaveRow = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_SaveRow, out int[] GH_PC_SaveRow);
|
|
bool SaveCol = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_SaveCol, out int[] GH_PC_SaveCol);
|
|
bool SaveVCCSet = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_SaveVCCSet, out int[] GH_PC_SaveVCCSet);
|
|
bool SaveVCCAct = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_SaveVCCAct, out int[] GH_PC_SaveVCCAct);
|
|
bool SaveGFASet = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_SaveGFASet, out int[] GH_PC_SaveGFASet);
|
|
bool SaveGFAAct = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_SaveGFAAct, out int[] GH_PC_SaveGFAAct);
|
|
bool Save3thSet = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_Save3thSet, out int[] GH_PC_Save3thSet);
|
|
bool Save3thAct = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_Save3thAct, out int[] GH_PC_Save3thAct);
|
|
bool SaveLevel = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_SaveLevel, out int[] GH_PC_SaveLevel);
|
|
bool SaveFillTime = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_SaveFillTime, out int[] GH_PC_SaveFillTime);
|
|
bool SaveSpeed1 = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_SaveSpeed1, out int[] GH_PC_SaveSpeed1);
|
|
bool SaveSpeed2 = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_SaveSpeed2, out int[] GH_PC_SaveSpeed2);
|
|
bool SaveTime = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_SaveTime, out int[] GH_PC_SaveTime);
|
|
recordSaveDataInfo.PlanId = Mesnac.Basic.DataProcessor.ToSiemensInt32(GH_PC_SavePlanId).ToString();
|
|
recordSaveDataInfo.SaveCode = Mesnac.Basic.DataProcessor.ToSiemensInt32(GH_PC_SavePlanId).ToString();
|
|
recordSaveDataInfo.SaveFinishedNum = Mesnac.Basic.DataProcessor.ToSiemensInt32(GH_PC_SaveFinishedNum);
|
|
recordSaveDataInfo.SaveRow = Mesnac.Basic.DataProcessor.ToSiemensInt32(GH_PC_SaveRow);
|
|
recordSaveDataInfo.SaveCol = Mesnac.Basic.DataProcessor.ToSiemensInt32(GH_PC_SaveCol);
|
|
recordSaveDataInfo.SaveVCCSet = Mesnac.Basic.DataProcessor.ToSiemensFloat(GH_PC_SaveVCCSet);
|
|
recordSaveDataInfo.SaveVCCAct = Mesnac.Basic.DataProcessor.ToSiemensFloat(GH_PC_SaveVCCAct);
|
|
recordSaveDataInfo.SaveGFASet = Mesnac.Basic.DataProcessor.ToSiemensFloat(GH_PC_SaveGFASet);
|
|
recordSaveDataInfo.Save3thSet = Mesnac.Basic.DataProcessor.ToSiemensFloat(GH_PC_Save3thSet);
|
|
recordSaveDataInfo.Save3thAct = Mesnac.Basic.DataProcessor.ToSiemensFloat(GH_PC_Save3thAct);
|
|
recordSaveDataInfo.SaveLevel = Mesnac.Basic.DataProcessor.ToSiemensFloat(GH_PC_SaveLevel);
|
|
recordSaveDataInfo.SaveFillTime = Mesnac.Basic.DataProcessor.ToSiemensInt32(GH_PC_SaveFillTime);
|
|
recordSaveDataInfo.SaveSpeed1 = Mesnac.Basic.DataProcessor.ToSiemensInt32(GH_PC_SaveSpeed1);
|
|
recordSaveDataInfo.SaveSpeed2 = Mesnac.Basic.DataProcessor.ToSiemensInt32(GH_PC_SaveSpeed2);
|
|
recordSaveDataInfo.SaveTime = Mesnac.Basic.DataProcessor.ToSiemensInt32(GH_PC_SaveTime);
|
|
recordSaveDataInfo.RecordTime = DateTime.Now;
|
|
//将实体保存至数据库
|
|
SaveHelper.LotSaveHelper.InsertGHSaveData(recordSaveDataInfo);
|
|
//存盘数据保存完成,写入反馈信号
|
|
ICSharpCode.Core.LoggingService<GHFinshBatchHelper>.Debug("数据存盘_PLC物料数据写入数据库处理完毕!");
|
|
bool result = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_RpSaved, new object[] { 1 });
|
|
if (!result)
|
|
{
|
|
ICSharpCode.Core.LoggingService<GHFinshBatchHelper>.Debug("数据存盘后写入反馈信号失败!");
|
|
}
|
|
//将车次与计划表中的数量比对,更新计划数量中的完成数量
|
|
if (recordSaveDataInfo.PlanId != "")
|
|
{
|
|
Product.PptPlan.entity.Base_PlanInfo planInfo = Product.PptPlan.PlanHelper.getPlanInfoByPlanId(recordSaveDataInfo.PlanId);
|
|
//不相等则更新计划中的完成数量
|
|
planInfo.real_Amount = recordSaveDataInfo.SaveFinishedNum;
|
|
planInfo.update_Time = DateTime.Now;
|
|
if (planInfo.real_Amount != recordSaveDataInfo.SaveFinishedNum)
|
|
{
|
|
Product.PptPlan.PlanHelper.UpdateBasePlanStateInfo(planInfo);
|
|
}
|
|
else //本次计划完成
|
|
{
|
|
planInfo.plan_endTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
planInfo.plan_State = 2;
|
|
Product.PptPlan.PlanHelper.UpdateBasePlanStateInfo(planInfo);
|
|
}
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ICSharpCode.Core.LoggingService<GHFinshBatchHelper>.Error(String.Format("数据存盘异常:{1}", ex.Message), ex);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|