@ -3,13 +3,15 @@ using Mesnac.Action.ChemicalWeighing.Entity;
using Mesnac.Action.ChemicalWeighing.Entity.PptPlan ;
using Mesnac.Action.ChemicalWeighing.Product.XlPlan ;
using Mesnac.Action.ChemicalWeighing.Report ;
using Steema.TeeChart.Functions ;
using System ;
using System.Collections.Generic ;
using System.Linq ;
using System.Security.Claims ;
namespace Mesnac.Action.ChemicalWeighing.XlPlcHelper
{
public class PlcPlanHelper
public class PlcPlanHelper
{
public static object sender = null ;
public static event EventHandler AutoDownloadPlan ;
@ -24,9 +26,9 @@ namespace Mesnac.Action.ChemicalWeighing.XlPlcHelper
public static bool AutoDownloadPlanData ( )
{
bool result = true ;
string planNo ; //计划号
int batch = 0 ;
string planNo ; //计划号
int batch = 0 ;
#region 获取当前计划号,判断当前计划状态
//读取配方编码获取配方物料所在的工位,根据工位查询状态
//当PLC将状态位置"1"时计划完成
@ -37,7 +39,7 @@ namespace Mesnac.Action.ChemicalWeighing.XlPlcHelper
planNo = BasePlcHelper . Instance . plt_Set_PlanNo . NowValue . ToString ( ) ; //执行序号
batch = BasePlcHelper . Instance . plt_Batch . NowValue . ToInt ( ) ; //计划执行册数
bool IsExec = Product . XlPlan . PlanHelper . GetXlPlanState ( planNo , batch ) ; //检查当前任务是否还处于执行中
if ( ! IsExec ) return true ;
@ -120,7 +122,7 @@ namespace Mesnac.Action.ChemicalWeighing.XlPlcHelper
double total = 0 ;
decimal set_station_weight = 0 ;
decimal set_station_error = 0 ;
try
{
planId = item . Plan_Id ;
@ -129,9 +131,9 @@ namespace Mesnac.Action.ChemicalWeighing.XlPlcHelper
total = item . Total_Weight ;
//setWeight = item.Station_SetWeight;
//setError = item.Station_SetError;
set_station_weight = item . Set_Weight * 100 ;
set_station_weight = item . Set_Weight * 100 ;
set_station_error = item . Set_Error * 100 ;
if ( i = = 0 )
{
//BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.plt_Set_PlanNo, new object[] { item.Plan_Id }); //计划号
@ -143,142 +145,142 @@ namespace Mesnac.Action.ChemicalWeighing.XlPlcHelper
switch ( item . Station . ToString ( ) )
{
case "1" :
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station1_Weight1 , new object [ ] { set_station_weight } ) ;
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station1_Error1 , new object [ ] { set_station_error } ) ;
break ;
case "2" :
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station1_Weight2 , new object [ ] { set_station_weight } ) ;
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station1_Error2 , new object [ ] { set_station_error } ) ;
break ;
case "3" :
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station2_Weight3 , new object [ ] { set_station_weight } ) ;
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station2_Error3 , new object [ ] { set_station_error } ) ;
break ;
case "4" :
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station2_Weight4 , new object [ ] { set_station_weight } ) ;
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station2_Error4 , new object [ ] { set_station_error } ) ;
break ;
case "5" :
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station3_Weight5 , new object [ ] { set_station_weight } ) ;
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station3_Error5 , new object [ ] { set_station_error } ) ;
break ;
case "6" :
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station3_Weight6 , new object [ ] { set_station_weight } ) ;
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station3_Error6 , new object [ ] { set_station_error } ) ;
break ;
case "7" :
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station4_Weight7 , new object [ ] { set_station_weight } ) ;
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station4_Error7 , new object [ ] { set_station_error } ) ;
break ;
case "8" :
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station4_Weight8 , new object [ ] { set_station_weight } ) ;
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station4_Error8 , new object [ ] { set_station_error } ) ;
break ;
case "9" :
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station5_Weight9 , new object [ ] { set_station_weight } ) ;
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station5_Error9 , new object [ ] { set_station_error } ) ;
break ;
case "10" :
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station5_Weight10 , new object [ ] { set_station_weight } ) ;
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station5_Error10 , new object [ ] { set_station_error } ) ;
break ;
case "11" :
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station6_Weight11 , new object [ ] { set_station_weight } ) ;
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station6_Error11 , new object [ ] { set_station_error } ) ;
break ;
case "12" :
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station6_Weight12 , new object [ ] { set_station_weight } ) ;
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station6_Error12 , new object [ ] { set_station_error } ) ;
break ;
case "13" :
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station7_Weight13 , new object [ ] { set_station_weight } ) ;
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station7_Error13 , new object [ ] { set_station_error } ) ;
break ;
case "14" :
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station7_Weight14 , new object [ ] { set_station_weight } ) ;
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station7_Error14 , new object [ ] { set_station_error } ) ;
break ;
case "15" :
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station8_Weight15 , new object [ ] { set_station_weight } ) ;
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station8_Error15 , new object [ ] { set_station_error } ) ;
break ;
case "16" :
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station8_Weight16 , new object [ ] { set_station_weight } ) ;
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station8_Error16 , new object [ ] { set_station_error } ) ;
break ;
case "17" :
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station9_Weight17 , new object [ ] { set_station_weight } ) ;
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station9_Error17 , new object [ ] { set_station_error } ) ;
break ;
case "18" :
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station9_Weight18 , new object [ ] { set_station_weight } ) ;
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station9_Error18 , new object [ ] { set_station_error } ) ;
break ;
case "19" :
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station10_Weight19 , new object [ ] { set_station_weight } ) ;
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station10_Error19 , new object [ ] { set_station_error } ) ;
break ;
case "20" :
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station10_Weight20 , new object [ ] { set_station_weight } ) ;
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station10_Error20 , new object [ ] { set_station_error } ) ;
break ;
case "21" :
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station11_Weight21 , new object [ ] { set_station_weight } ) ;
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station11_Error21 , new object [ ] { set_station_error } ) ;
break ;
case "22" :
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station11_Weight22 , new object [ ] { set_station_weight } ) ;
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station11_Error22 , new object [ ] { set_station_error } ) ;
break ;
case "23" :
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station12_Weight23 , new object [ ] { set_station_weight } ) ;
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station12_Error23 , new object [ ] { set_station_error } ) ;
break ;
case "24" :
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station12_Weight24 , new object [ ] { set_station_weight } ) ;
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station12_Error24 , new object [ ] { set_station_error } ) ;
break ;
case "25" :
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station13_Weight25 , new object [ ] { set_station_weight } ) ;
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station13_Error25 , new object [ ] { set_station_error } ) ;
break ;
case "26" :
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station13_Weight26 , new object [ ] { set_station_weight } ) ;
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station13_Error26 , new object [ ] { set_station_error } ) ;
break ;
case "27" :
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station14_Weight27 , new object [ ] { set_station_weight } ) ;
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station14_Error27 , new object [ ] { set_station_error } ) ;
break ;
case "28" :
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station14_Weight28 , new object [ ] { set_station_weight } ) ;
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station14_Error28 , new object [ ] { set_station_error } ) ;
break ;
@ -323,10 +325,10 @@ namespace Mesnac.Action.ChemicalWeighing.XlPlcHelper
try
{
planId = item . Plan_Id ;
if ( item . Station = = 0 ) continue ;
if ( item . Station = = 0 ) continue ;
set_station_weight = Convert . ToInt32 ( item . Set_Weight * 100 ) ;
set_station_error = Convert . ToInt32 ( item . Set_Error * 100 ) ;
set_station_weight = Convert . ToInt32 ( item . Set_Weight * 100 ) ;
set_station_error = Convert . ToInt32 ( item . Set_Error * 100 ) ;
if ( ! string . IsNullOrEmpty ( item . Plan_Id ) )
{
@ -335,7 +337,15 @@ namespace Mesnac.Action.ChemicalWeighing.XlPlcHelper
//BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.plt_Set_RecipeName, new object[] { item.Recipe_Name }); //配方名称
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Batch , new object [ ] { item . Plan_Num } ) ; //设定执行数量
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Plan_Serial , new object [ ] { item . Plan_Serial } ) ; //计划号
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_plc_Spare7 , new object [ ] { item . IsPrenatalTest } ) ; //是否产前检查表标识
if ( item . IsPrenatalTest = = 1 )
{
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_plc_Spare7 , new object [ ] { 2 } ) ; //产前检查表标识
}
else
{
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_plc_Spare7 , new object [ ] { 0 } ) ;
}
}
switch ( item . Station )
{
@ -346,7 +356,7 @@ namespace Mesnac.Action.ChemicalWeighing.XlPlcHelper
break ;
case 2 :
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station1_Weight2 , new object [ ] { set_station_weight } ) ;
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station1_Error2 , new object [ ] { set_station_error } ) ;
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Set_Station1_Error2 , new object [ ] { set_station_error } ) ;
j + + ;
break ;
case 3 :
@ -516,10 +526,10 @@ namespace Mesnac.Action.ChemicalWeighing.XlPlcHelper
ICSharpCode . Core . LoggingService < PlcPlanHelper > . Debug ( String . Format ( "[{0}]计划信息下传失败..." , item . Plan_Id ) ) ;
}
}
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_plc_Start , new object [ ] { 1 } ) ; //设定启动信号
return true ;
}
catch ( Exception ex )
@ -571,8 +581,8 @@ namespace Mesnac.Action.ChemicalWeighing.XlPlcHelper
{
int plt_Set_Plan_Serial = BasePlcHelper . Instance . plt_Set_Plan_Serial . NowValue . ToInt ( ) ; //执行序号 Plan_Serial
List < Xl_DowLoadPlan > materialList = PlanHelper . GetExecPlan ( plt_Set_Plan_Serial ) ; //正在执行的任务
if ( materialList = = null | | materialList . Count = = 0 ) { return ; }
if ( materialList = = null | | materialList . Count = = 0 ) { return ; }
materialList . OrderBy ( d = > d . Station ) ;
foreach ( var item in materialList )
{
switch ( item . Station )
@ -581,7 +591,7 @@ namespace Mesnac.Action.ChemicalWeighing.XlPlcHelper
if ( BasePlcHelper . Instance . plt_Read11_PlcState . NowValue . ToInt ( ) = = 1 ) //1工位A
{
int batch = BasePlcHelper . Instance . plt_Station1_Batch . NowValue . ToInt ( ) ; //工位批次
decimal real_Weight = Convert . ToDecimal ( BasePlcHelper . Instance . plt_Station1_Weight . NowValue . ToInt ( ) ) / 100 ; //实际重量
decimal real_Weight = Convert . ToDecimal ( BasePlcHelper . Instance . plt_Station1_Weight . NowValue . ToInt ( ) ) / 100 ; //实际重量
bool result = SaveToData ( item , batch , real_Weight ) ;
@ -596,7 +606,7 @@ namespace Mesnac.Action.ChemicalWeighing.XlPlcHelper
if ( BasePlcHelper . Instance . plt_Read12_PlcState . NowValue . ToInt ( ) = = 1 ) //1工位B
{
int batch = BasePlcHelper . Instance . plt_Station1_Batch . NowValue . ToInt ( ) ; //工位批次
decimal weight = Convert . ToDecimal ( BasePlcHelper . Instance . plt_Station1_Weight . NowValue . ToInt ( ) ) / 100 ; //实际重量
decimal weight = Convert . ToDecimal ( BasePlcHelper . Instance . plt_Station1_Weight . NowValue . ToInt ( ) ) / 100 ; //实际重量
bool result = SaveToData ( item , batch , weight ) ;
if ( result )
@ -710,7 +720,7 @@ namespace Mesnac.Action.ChemicalWeighing.XlPlcHelper
int batch = BasePlcHelper . Instance . plt_Station5_Batch . NowValue . ToInt ( ) ; //工位批次
int i = BasePlcHelper . Instance . plt_Station5_Weight . NowValue . ToInt ( ) ;
string i2 = BasePlcHelper . Instance . plt_Station5_Weight . NowValue . ToString ( ) ;
decimal weight = Convert . ToDecimal ( BasePlcHelper . Instance . plt_Station5_Weight . NowValue . ToInt ( ) ) / 100 ; //实际重量
bool result = SaveToData ( item , batch , weight ) ;
@ -739,7 +749,7 @@ namespace Mesnac.Action.ChemicalWeighing.XlPlcHelper
break ;
case 11 :
//if (BasePlcHelper.Instance.plt_Station6_WorkState.NowValue.ToInt() == 200) break;//称量中返回
if ( BasePlcHelper . Instance . plt_Read61_PlcState . NowValue . ToInt ( ) = = 1 ) //6工位A
{
int batch = BasePlcHelper . Instance . plt_Station6_Batch . NowValue . ToInt ( ) ; //工位批次
@ -772,7 +782,7 @@ namespace Mesnac.Action.ChemicalWeighing.XlPlcHelper
break ;
case 13 :
//if (BasePlcHelper.Instance.plt_Station7_WorkState.NowValue.ToInt() == 100) break;//称量中返回
// var t = BasePlcHelper.Instance.plt_Read71_PlcState.NowValue.ToString();
// var t = BasePlcHelper.Instance.plt_Read71_PlcState.NowValue.ToString();
if ( BasePlcHelper . Instance . plt_Read71_PlcState . NowValue . ToInt ( ) = = 1 ) //7工位A
{
int batch = BasePlcHelper . Instance . plt_Station7_Batch . NowValue . ToInt ( ) ; //工位批次
@ -852,7 +862,7 @@ namespace Mesnac.Action.ChemicalWeighing.XlPlcHelper
break ;
case 18 :
//if (BasePlcHelper.Instance.plt_Station9_WorkState.NowValue.ToInt() == 200) break;//称量中返回
if ( BasePlcHelper . Instance . plt_Read92_PlcState . NowValue . ToInt ( ) = = 1 ) //9工位B
{
int batch = BasePlcHelper . Instance . plt_Station9_Batch . NowValue . ToInt ( ) ; //工位批次
@ -937,7 +947,7 @@ namespace Mesnac.Action.ChemicalWeighing.XlPlcHelper
if ( BasePlcHelper . Instance . plt_Read121_PlcState . NowValue . ToInt ( ) = = 1 ) //12工位A
{
// int batch = BasePlcHelper.Instance.plt_Station12_Batch.NowValue.ToInt();//工位批次
// int batch = BasePlcHelper.Instance.plt_Station12_Batch.NowValue.ToInt();//工位批次
string b = BasePlcHelper . Instance . plt_Station11_Batch . NowValue . ToString ( ) ; //工位批次
int batch = Convert . ToInt16 ( b ) ;
int batch2 = Convert . ToInt32 ( b ) ;
@ -973,7 +983,7 @@ namespace Mesnac.Action.ChemicalWeighing.XlPlcHelper
if ( BasePlcHelper . Instance . plt_Read131_PlcState . NowValue . ToInt ( ) = = 1 ) //13工位A
{
int batch = BasePlcHelper . Instance . plt_Station13_Batch . NowValue . ToInt ( ) ; //工位批次
decimal weight = Convert . ToDecimal ( BasePlcHelper . Instance . plt_Station13_Weight . NowValue . ToInt ( ) ) / 100 ; //实际重量
bool result = SaveToData ( item , batch , weight ) ;
@ -1021,7 +1031,7 @@ namespace Mesnac.Action.ChemicalWeighing.XlPlcHelper
if ( BasePlcHelper . Instance . plt_Read142_PlcState . NowValue . ToInt ( ) = = 1 ) //14工位B
{
int batch = BasePlcHelper . Instance . plt_Station14_Batch . NowValue . ToInt ( ) ; //工位批次
decimal weight = Convert . ToDecimal ( BasePlcHelper . Instance . plt_Station14_Weight . NowValue . ToInt ( ) ) / 100 ; //实际重量
decimal weight = Convert . ToDecimal ( BasePlcHelper . Instance . plt_Station14_Weight . NowValue . ToInt ( ) ) / 100 ; //实际重量
bool result = SaveToData ( item , batch , weight ) ;
if ( result )
@ -1031,7 +1041,7 @@ namespace Mesnac.Action.ChemicalWeighing.XlPlcHelper
}
}
break ;
default :
break ;
}
@ -1040,16 +1050,16 @@ namespace Mesnac.Action.ChemicalWeighing.XlPlcHelper
//检量秤检查结束信息
Xl_DowLoadPlan down = materialList . FirstOrDefault ( ) ;
if ( down = = null ) return ;
if ( down . IsPrenatalTest = = 1 )
if ( down . IsPrenatalTest = = 1 )
{
if ( BasePlcHelper . Instance . plt_Read1Jc . NowValue . ToInt ( ) = = 1 )
{
double tcheckWeight = BasePlcHelper . Instance . plt_TCheck_Weight . NowValue . ToInt ( ) ; //检量秤重量
int tcheckBatch = BasePlcHelper . Instance . plt_Batch . NowValue . ToInt ( ) ; //当前执行的批次
if ( tcheckBatch = = 1 )
if ( tcheckBatch = = down . Plan_Num )
{
PlanHelper . UpdateCheckPlanCompletedQuantity ( down .Plan_Id , tcheckBatch , DateTime . Now , tcheckWeight ) ;
PlanHelper . UpdateCheckPlanCompletedQuantity ( down , tcheckBatch , 8 , DateTime . Now , tcheckWeight ) ;
BasePlcHelper . Instance . PlcWriteByDataKey ( BasePlcHelper . Instance . plt_Read1Jc , new object [ ] { 2 } ) ;
}
}
@ -1104,11 +1114,11 @@ namespace Mesnac.Action.ChemicalWeighing.XlPlcHelper
// BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.plt_Read1Jc, new object[] { 6 });
// }
//}
}
catch ( Exception ex )
{
}
}
@ -2383,7 +2393,7 @@ namespace Mesnac.Action.ChemicalWeighing.XlPlcHelper
}
}
# endregion
@ -2625,8 +2635,8 @@ namespace Mesnac.Action.ChemicalWeighing.XlPlcHelper
{
try
{
LR_plan lrPlan = XlDbHelper . GetLrPlan ( item . Plan_Id , batch );
if ( lrPlan . Plan_Id ! = null )
LR_plan lrPlan = XlDbHelper . GetLrPlan ( item . Plan_Id , batch , item . FlagNum );
if ( lrPlan ! = null )
{
decimal totalWeight = lrPlan . Total_Weight + real_Weight ;
decimal totalError = lrPlan . Total_Error + error ;
@ -2658,7 +2668,7 @@ namespace Mesnac.Action.ChemicalWeighing.XlPlcHelper
alarm . MaterialName = item . Material_name ;
alarm . Weights = real_Weight ;
alarm . TypeName = "出库" ;
bool result = XlDbHelper . UpdatePlanDetail ( lrPlan, weigh , alarm ) ;
bool result = XlDbHelper . UpdatePlanDetail ( item, lrPlan, weigh , alarm , 0 ) ;
if ( result )
{
return true ;
@ -2712,7 +2722,7 @@ namespace Mesnac.Action.ChemicalWeighing.XlPlcHelper
alarm . MaterialName = item . Material_name ;
alarm . Weights = real_Weight ;
alarm . TypeName = "出库" ;
bool result = BinHelper . SaveDataToBDb ( weigh, plan , binInfo , alarm ) ;
bool result = BinHelper . SaveDataToBDb ( item, weigh, plan , binInfo , alarm , 1 ) ;
if ( result )
{
@ -2737,60 +2747,92 @@ namespace Mesnac.Action.ChemicalWeighing.XlPlcHelper
/// <param name="real_Weight"></param>
/// <param name="error"></param>
/// <returns></returns>
public static bool SaveCHeckData ( Xl_DowLoadPlan item , int batch , decimal real_Weight , decimal error )
public static bool SaveCHeckData ( Xl_DowLoadPlan item , int batch , decimal real_Weight , decimal error )
{
//保存计划
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 ;
//addPlan = XlDbHelper.LRAddPlan(plan);//报表主表
//addWeigh = XlDbHelper.LRAddWeigh(weigh);//报表物料详细表
//更新料仓数据
var binInfo = BinHelper . GetFristBinInfo ( item . Station ) ;
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 = "出库" ;
bool result = BinHelper . SaveDataToBDb ( weigh , plan , binInfo , alarm ) ;
if ( result )
LR_plan lrPlan = XlDbHelper . GetLrPlan ( item . Plan_Id , batch , item . FlagNum ) ;
if ( lrPlan ! = null )
{
return true ;
//保存物料
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 = BinHelper . GetFristBinInfo ( item . Station ) ;
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 BinHelper . SaveDataToBDb ( item , weigh , lrPlan , binInfo , alarm , 0 ) ;
}
else
{
return false ;
//保存计划
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" ) ;
//更新料仓数据
var binInfo = BinHelper . GetFristBinInfo ( item . Station ) ;
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 = "出库" ;
bool result = BinHelper . SaveDataToBDb ( item , weigh , plan , binInfo , alarm , 1 ) ;
if ( result )
{
return true ;
}
else
{
return false ;
}
}
}
}
}