@ -61,13 +61,8 @@ namespace Admin.Core.Service
int rate = Convert . ToInt32 ( view . Rate * 100 ) ;
bool rr = plcList . plc . WriteInt16 ( "DB110.DBW10.0" , rate . ToString ( ) ) ; //传入固率
bool barCode = plcList . plc . WriteInt16 ( "DB110.DBW1768.0" , "1" ) ;
// bool matCode = plcList.plc.WriteInt16("DB110.DBW482.0", "1");//执行启动
if ( barCode )
{
//log.Info(view.Rate + "&" + rate);
Hw_SolventErrorPreventionReport report = new Hw_SolventErrorPreventionReport ( )
{
PlanId = view . Plan_Id ,
@ -82,6 +77,11 @@ namespace Admin.Core.Service
var rtPlanList = await _planRepository . QueryAsync ( d = > d . Plan_State = = 3 ) ;
if ( rtPlanList . Count > 0 )
{
if ( string . IsNullOrEmpty ( view . Plan_Id ) )
{
var r = rtPlanList . FirstOrDefault ( ) ;
view . Plan_Id = r . Plan_Id ;
}
var rtPlan = rtPlanList . FirstOrDefault ( d = > d . Plan_Id = = view . Plan_Id ) ;
if ( plcList . plc . ReadInt16 ( "DB110.DBW8" ) ! = 250 )
@ -103,7 +103,16 @@ namespace Admin.Core.Service
// rtPlan.Exec_Num = 1;
// }
//}
rtPlan . Exec_Num = plcList . plc . ReadInt16 ( "DB110.DBW1758.0" ) ;
var num = plcList . plc . ReadInt16 ( "DB110.DBW1758.0" ) ;
if ( num = = 0 )
{
rtPlan . Exec_Num = 1 ;
}
else
{
rtPlan . Exec_Num = num ;
}
//rtPlan.Exec_Num = plcList.plc.ReadInt16("DB110.DBW1758.0");
//保存本次数据
int i = await _solventErrorPreventionReportRepository . AddAsync ( report ) ;
var cylinderList = _hwCylinderRepository . Query ( ) ;
@ -111,11 +120,22 @@ namespace Admin.Core.Service
{
return false ;
}
Hw_Cylinder hw_Cylinder = cylinderList . FirstOrDefault ( d = > d . BarCode = = view . CylinderBarCode . Trim ( ) ) ;
rtPlan . CylinderName = hw_Cylinder . Name ;
rtPlan . CylinderBarCode = hw_Cylinder . BarCode ;
log . Info ( view . CylinderBarCode ) ;
await _planRepository . UpdateExecDb ( rtPlan ) ; //更新数据库
if ( view . CylinderBarCode . Trim ( ) = = "00000000" )
{
rtPlan . CylinderName = "00000000" ;
rtPlan . CylinderBarCode = "00000000" ;
await _planRepository . UpdateExecDb ( rtPlan ) ; //更新数据库
}
else
{
Hw_Cylinder hw_Cylinder = cylinderList . FirstOrDefault ( d = > d . BarCode = = view . CylinderBarCode . Trim ( ) ) ;
rtPlan . CylinderName = hw_Cylinder . Name ;
rtPlan . CylinderBarCode = hw_Cylinder . BarCode ;
log . Info ( view . CylinderBarCode ) ;
await _planRepository . UpdateExecDb ( rtPlan ) ; //更新数据库
}
return true ;
}
}
@ -168,7 +188,16 @@ namespace Admin.Core.Service
// rtPlan.Exec_Num = 1;
// }
//}
rtPlan . Exec_Num = plcList . plc . ReadInt16 ( "DB110.DBW1758.0" ) ;
var num = plcList . plc . ReadInt16 ( "DB110.DBW1758.0" ) ;
if ( num = = 0 )
{
rtPlan . Exec_Num = 1 ;
}
else
{
rtPlan . Exec_Num = num ;
}
//保存本次数据
int i = await _solventErrorPreventionReportRepository . AddAsync ( report ) ;
var cylinderList = _hwCylinderRepository . Query ( ) ;
@ -354,14 +383,14 @@ namespace Admin.Core.Service
var plcList = PlcHelper . siemensList . SingleOrDefault ( d = > d . EquipName . Equals ( "溶剂PLC" ) ) ;
if ( plcList . plc . IsConnected )
{
if ( weighbridge = = "1号地磅" )
if ( weighbridge = = "1号地磅" )
{
int planNum = plcList . plc . ReadInt16 ( "DB110.DBW2.0" ) ; //执行批次
if ( plan . Plan_Num > planNum )
{
var rtPlanList = await _planRepository . QueryAsync ( d = > d . Plan_State = = 3 ) ;
var rtPlan = rtPlanList . FirstOrDefault ( d = > d . Plan_Id = = plan . Plan_Id ) ;
execNum = rtPlan . Exec_Num ;
int materialNo = plcList . plc . ReadInt16 ( "DB110.DBW1758" ) ; //当前执行物料
if ( materialNo = = 0 ) materialNo = 1 ;
var hwWeigh = hwWeighList . FirstOrDefault ( d = > d . MID = = materialNo ) ;
@ -371,13 +400,6 @@ namespace Admin.Core.Service
}
else
{
//var rtPlanList = await _planRepository.QueryAsync(d => d.Plan_State == 3);
//var rtPlan = rtPlanList.FirstOrDefault(d => d.Plan_Id == plan.Plan_Id);
//execNum = rtPlan.Exec_Num;
//int materialNo = plcList.plc.ReadInt16("DB110.DBW478.0");//当前执行物料
//var hwWeigh = hwWeighList.FirstOrDefault(d => d.MID == materialNo);
//if (hwWeigh == null) return null;
return null ;
}
}
@ -397,17 +419,9 @@ namespace Admin.Core.Service
}
else
{
//var rtPlanList = await _planRepository.QueryAsync(d => d.Plan_State == 3);
//var rtPlan = rtPlanList.FirstOrDefault(d => d.Plan_Id == plan.Plan_Id);
//execNum = rtPlan.Exec_Num;
//int materialNo = plcList.plc.ReadInt16("DB110.DBW478.0");//当前执行物料
//var hwWeigh = hwWeighList.FirstOrDefault(d => d.MID == materialNo);
//if (hwWeigh == null) return null;
return null ;
}
}
}
else
{