小料投料安全库存

dep_wangsr
liulb@mesnac.com 1 year ago
parent 2f0a1d1fb5
commit 7f1773bc54

@ -299,14 +299,7 @@
<param name="code">料仓条码信息</param>
<returns></returns>
</member>
<member name="M:Admin.Core.Api.xl_materialController.ExecPlcCode(System.Int32,System.Int32)">
<summary>
执行PLC
</summary>
<param name="code">料仓排序Bin_Serial</param>
<param name="state">匹配状态条码匹配写“1”不匹配时写“2”</param>
<returns></returns>
</member>
<!-- Badly formed XML comment ignored for member "M:Admin.Core.Api.xl_materialController.ExecPlcCode(System.Int32,System.Int32,System.String,System.Decimal)" -->
<member name="M:Admin.Core.Api.xl_materialController.BindBarrel(System.String)">
<summary>
检量称扫码绑定桶(新加)

@ -308,6 +308,60 @@
Nullable:True
</summary>
</member>
<member name="T:Admin.Core.Model.Hw_BinAlarm">
<summary>
料仓报表
</summary>
</member>
<member name="P:Admin.Core.Model.Hw_BinAlarm.Id">
<summary>
Desc:主键
Default:
Nullable:False
</summary>
</member>
<member name="P:Admin.Core.Model.Hw_BinAlarm.BinId">
<summary>
Desc:料仓编码
Default:
Nullable:True
</summary>
</member>
<member name="P:Admin.Core.Model.Hw_BinAlarm.BinName">
<summary>
Desc:料仓名称
Default:
Nullable:True
</summary>
</member>
<member name="P:Admin.Core.Model.Hw_BinAlarm.MaterialCode">
<summary>
Desc:物料编码
Default:
Nullable:True
</summary>
</member>
<member name="P:Admin.Core.Model.Hw_BinAlarm.MaterialName">
<summary>
Desc:物料名称
Default:
Nullable:True
</summary>
</member>
<member name="P:Admin.Core.Model.Hw_BinAlarm.Weights">
<summary>
Desc:物料重量
Default:
Nullable:True
</summary>
</member>
<member name="P:Admin.Core.Model.Hw_BinAlarm.CreateTime">
<summary>
Desc:创建时间
Default:
Nullable:True
</summary>
</member>
<member name="T:Admin.Core.Model.Hw_BinTypeErrorPreventionReport">
<summary>
@ -1103,6 +1157,16 @@
Nullable:True
</summary>
</member>
<member name="P:Admin.Core.Model.Pmt_Bin.BinWeight">
<summary>
料仓实时重量
</summary>
</member>
<member name="P:Admin.Core.Model.Pmt_Bin.LimitWeight">
<summary>
料仓设定重量上限
</summary>
</member>
<member name="T:Admin.Core.Model.Pmt_material">
<summary>

@ -138,11 +138,11 @@ namespace Admin.Core.Api
return Failed<bool>("匹配状态传入参数为空!");
}
var result = await _xl_materialService.ExecPlcState(code, state, materialCode, weight);
if (result)
if (result.success)
{
return Success(result);
return result;
}
return Failed<bool>("执行失败!");
return Failed<bool>(result.msg);
}
#endregion

@ -25,7 +25,7 @@
<PackageReference Include="Microsoft.Extensions.Options" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="5.0.0" />
<PackageReference Include="MiniProfiler.AspNetCore.Mvc" Version="4.2.22" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="NPOI" Version="2.5.5" />
<PackageReference Include="Portable.BouncyCastle" Version="1.8.10" />
<PackageReference Include="Serilog" Version="2.10.0" />

@ -0,0 +1,11 @@
using Admin.Core.Model;
namespace Admin.Core.IRepository
{
/// <summary>
/// IHw_BinAlarmRepository
/// </summary>
public interface IHw_BinAlarmRepository : IBaseRepository<Hw_BinAlarm>
{
}
}

@ -1,4 +1,5 @@
using Admin.Core.Model;
using System.Threading.Tasks;
namespace Admin.Core.IRepository
{
@ -7,5 +8,6 @@ namespace Admin.Core.IRepository
/// </summary>
public interface IPmt_BinRepository : IBaseRepository<Pmt_Bin>
{
Task<bool> AddData(Hw_BinAlarm alarm, Hw_BinTypeErrorPreventionReport type, Pmt_Bin bin);
}
}

@ -0,0 +1,12 @@
using Admin.Core.IService;
using Admin.Core.Model;
namespace Admin.Core.IService
{
/// <summary>
/// IHw_BinAlarmServices
/// </summary>
public interface IHw_BinAlarmServices :IBaseServices<Hw_BinAlarm>
{
}
}

@ -12,7 +12,7 @@ namespace Admin.Core.IService
public interface Ixl_materialServices :IBaseServices<xl_material>
{
Task<xl_material> GetByMaterialCode(string code);
Task<bool> ExecPlcState(int binSerial, int state,string materialCode,decimal weight);
Task<MessageModel<bool>> ExecPlcState(int binSerial, int state,string materialCode,decimal weight);
/// <summary>
/// 绑定料桶信息
/// </summary>

@ -0,0 +1,62 @@
using System;
using System.Linq;
using System.Text;
using SqlSugar;
namespace Admin.Core.Model
{
///<summary>
///料仓报表
///</summary>
[SugarTable("Hw_BinAlarm", "cwss_xl")]
public class Hw_BinAlarm
{
public Hw_BinAlarm()
{
}
/// <summary>
/// Desc:主键
/// Default:
/// Nullable:False
/// </summary>
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int Id { get; set; }
/// <summary>
/// Desc:料仓编码
/// Default:
/// Nullable:True
/// </summary>
public int BinId { get; set; }
/// <summary>
/// Desc:料仓名称
/// Default:
/// Nullable:True
/// </summary>
public string BinName { get; set; }
/// <summary>
/// Desc:物料编码
/// Default:
/// Nullable:True
/// </summary>
public string MaterialCode { get; set; }
/// <summary>
/// Desc:物料名称
/// Default:
/// Nullable:True
/// </summary>
public string MaterialName { get; set; }
/// <summary>
/// Desc:物料重量
/// Default:
/// Nullable:True
/// </summary>
public decimal? Weights { get; set; }
/// <summary>
/// Desc:创建时间
/// Default:
/// Nullable:True
/// </summary>
public DateTime? CreateTime { get; set; }
}
}

@ -12,22 +12,19 @@ namespace Admin.Core.Model
[SugarTable("Hw_BinTypeErrorPreventionReport", "cwss_xl")]
public class Hw_BinTypeErrorPreventionReport
{
public Hw_BinTypeErrorPreventionReport()
{
}
/// <summary>
/// Desc:
/// Default:
/// Nullable:False
/// </summary>
[SugarColumn(IsIdentity = true)]
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int ID { get; set; }
/// <summary>
/// Desc:料仓主键
/// Default:
/// Nullable:True
/// </summary>
public int? BinID { get; set; }
public int BinID { get; set; }
/// <summary>
/// Desc:名称
/// Default:

@ -118,5 +118,13 @@ namespace Admin.Core.Model
/// Nullable:True
/// </summary>
public int? IF_FLAG { get; set; }
/// <summary>
/// 料仓实时重量
/// </summary>
public decimal BinWeight { get; set; }
/// <summary>
/// 料仓设定重量上限
/// </summary>
public decimal LimitWeight { get; set; }
}
}

@ -15,7 +15,7 @@ namespace Admin.Core.PlcServer
{
private readonly log4net.ILog log = LogManager.GetLogger(typeof(SiemensPlc));
private SiemensS7Net siemensS7Net;
private SiemensPLCS siemensPLCS = SiemensPLCS.S1200;
private SiemensPLCS siemensPLCS = SiemensPLCS.S1500;
#region 构造函数
//public MelsecPlc()
@ -87,7 +87,7 @@ namespace Admin.Core.PlcServer
}
else
{
siemensS7Net.ConnectClose();
siemensS7Net.StopAsync();
IsConnected = false;
return false;
}

@ -0,0 +1,15 @@
using Admin.Core.IRepository;
using Admin.Core.Model;
namespace Admin.Core.Repository
{
/// <summary>
/// Hw_BinAlarmRepository
/// </summary>
public class Hw_BinAlarmRepository : BaseRepository<Hw_BinAlarm>, IHw_BinAlarmRepository
{
public Hw_BinAlarmRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
{
}
}
}

@ -1,5 +1,10 @@
using Admin.Core.IRepository;
using Admin.Core.Model;
using log4net;
using Microsoft.AspNetCore.Razor.TagHelpers;
using Microsoft.IdentityModel.Logging;
using System;
using System.Threading.Tasks;
namespace Admin.Core.Repository
{
@ -8,8 +13,28 @@ namespace Admin.Core.Repository
/// </summary>
public class Pmt_BinRepository : BaseRepository<Pmt_Bin>, IPmt_BinRepository
{
private static readonly log4net.ILog logHelper = LogManager.GetLogger(typeof(Pmt_BinRepository));
public Pmt_BinRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
{
}
public async Task<bool> AddData(Hw_BinAlarm alarm, Hw_BinTypeErrorPreventionReport type, Pmt_Bin bin)
{
try
{
Db.Ado.BeginTran();
Db.Saveable(alarm).ExecuteCommand();
Db.Saveable(type).ExecuteCommand();
Db.Updateable(bin).ExecuteCommand();
Db.Ado.CommitTran();
return await Task.FromResult(true);
}
catch (Exception ex)
{
Db.Ado.RollbackTran();
logHelper.Error($"小料投料物料信息保存异常:{ex.Message}");
return await Task.FromResult(false);
}
}
}
}

@ -0,0 +1,17 @@
using Admin.Core.IRepository;
using Admin.Core.Service;
using Admin.Core.IService;
using Admin.Core.Model;
namespace Admin.Core.Service
{
public class Hw_BinAlarmServices : BaseServices<Hw_BinAlarm>, IHw_BinAlarmServices
{
private readonly IBaseRepository<Hw_BinAlarm> _dal;
public Hw_BinAlarmServices(IBaseRepository<Hw_BinAlarm> dal)
{
this._dal = dal;
base.BaseDal = dal;
}
}
}

@ -1,16 +1,12 @@
using Admin.Core.IRepository;
using Admin.Core.Service;
using Admin.Core.IService;
using Admin.Core.Model;
using System.Threading.Tasks;
using Admin.Core.Model.ViewModels;
using System.Linq;
using System.Collections.Generic;
using S71500.Impl;
using MySqlX.XDevAPI.Common;
using System.Numerics;
using log4net;
using log4net.Util;
using Admin.Core.PlcServer;
namespace Admin.Core.Service
{
@ -55,129 +51,137 @@ namespace Admin.Core.Service
{
try
{
if (view.Weighbridge== "1号地磅")
var plcList = PlcHelper.siemensList.SingleOrDefault(d => d.EquipName.Equals("溶剂PLC"));
if (plcList.plc.IsConnected)
{
bool matCode = Adapter.WriteInt16("DB110.DBW400.0", "1");//执行启动
if (matCode)
if (view.Weighbridge == "1号地磅")
{
Hw_SolventErrorPreventionReport report = new Hw_SolventErrorPreventionReport()
bool matCode = plcList.plc.WriteInt16("DB110.DBW400.0", "1");//执行启动
if (matCode)
{
PlanId = view.Plan_Id,
FinishedNum = Adapter.ReadInt16("DB110.DBW2") + 1,
RMatCode = view.RMatCode,
MaterialID = view.MaterialID,
MaterialName = view.MaterialName,
Weight = view.MaterialWeight,
WholeMaterial = view.WholeMaterial
};
var rtPlanList = await _planRepository.QueryAsync(d => d.Plan_State == 3);
if (rtPlanList.Count > 0)
{
var rtPlan = rtPlanList.FirstOrDefault(d => d.Plan_Id == view.Plan_Id);
Hw_SolventErrorPreventionReport report = new Hw_SolventErrorPreventionReport()
{
PlanId = view.Plan_Id,
FinishedNum = plcList.plc.ReadInt16("DB110.DBW2") + 1,
RMatCode = view.RMatCode,
MaterialID = view.MaterialID,
MaterialName = view.MaterialName,
Weight = view.MaterialWeight,
WholeMaterial = view.WholeMaterial
};
if (Adapter.ReadInt16("DB110.DBW402") != 250)
var rtPlanList = await _planRepository.QueryAsync(d => d.Plan_State == 3);
if (rtPlanList.Count > 0)
{
var hwWeighList = await _hwWeighRepository.GetWaiteMaterial(view.Plan_Id);
if (hwWeighList!=null)
var rtPlan = rtPlanList.FirstOrDefault(d => d.Plan_Id == view.Plan_Id);
if (plcList.plc.ReadInt16("DB110.DBW402") != 250)
{
if (hwWeighList.Count()>(rtPlan.Exec_Num + 1))
var hwWeighList = await _hwWeighRepository.GetWaiteMaterial(view.Plan_Id);
if (hwWeighList != null)
{
rtPlan.Exec_Num = 1;
if (hwWeighList.Count() > (rtPlan.Exec_Num + 1))
{
rtPlan.Exec_Num = 1;
}
else if (hwWeighList.Count() == (rtPlan.Exec_Num + 1))
{
rtPlan.Exec_Num = rtPlan.Exec_Num + 1;
}
else
{
rtPlan.Exec_Num = 1;
}
}
else if(hwWeighList.Count() == (rtPlan.Exec_Num + 1))
{
rtPlan.Exec_Num = rtPlan.Exec_Num + 1;
}
else
//保存本次数据
int i = await _solventErrorPreventionReportRepository.AddAsync(report);
var cylinderList = _hwCylinderRepository.Query();
if (cylinderList.Count == 0)
{
rtPlan.Exec_Num = 1;
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);//更新数据库
return true;
}
//保存本次数据
int i = await _solventErrorPreventionReportRepository.AddAsync(report);
var cylinderList = _hwCylinderRepository.Query();
if (cylinderList.Count==0)
{
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);//更新数据库
return true;
}
}
return false;
}
return false;
}
return false;
}
else if (view.Weighbridge == "2号地磅")
{
bool matCode = Adapter.WriteInt16("DB111.DBW400.0", "1");//执行启动
if (matCode)
else if (view.Weighbridge == "2号地磅")
{
Hw_SolventErrorPreventionReport report = new Hw_SolventErrorPreventionReport()
bool matCode = plcList.plc.WriteInt16("DB111.DBW400.0", "1");//执行启动
if (matCode)
{
PlanId = view.Plan_Id,
FinishedNum = Adapter.ReadInt16("DB111.DBW2") + 1,
RMatCode = view.RMatCode,
MaterialID = view.MaterialID,
MaterialName = view.MaterialName,
Weight = view.MaterialWeight,
WholeMaterial = view.WholeMaterial
};
var rtPlanList = await _planRepository.QueryAsync(d => d.Plan_State == 3);
if (rtPlanList.Count > 0)
{
var rtPlan = rtPlanList.FirstOrDefault(d => d.Plan_Id == view.Plan_Id);
Hw_SolventErrorPreventionReport report = new Hw_SolventErrorPreventionReport()
{
PlanId = view.Plan_Id,
FinishedNum = plcList.plc.ReadInt16("DB111.DBW2") + 1,
RMatCode = view.RMatCode,
MaterialID = view.MaterialID,
MaterialName = view.MaterialName,
Weight = view.MaterialWeight,
WholeMaterial = view.WholeMaterial
};
if (Adapter.ReadInt16("DB111.DBW402") != 250)
var rtPlanList = await _planRepository.QueryAsync(d => d.Plan_State == 3);
if (rtPlanList.Count > 0)
{
var hwWeighList = await _hwWeighRepository.GetWaiteMaterial(view.Plan_Id);
if (hwWeighList != null)
var rtPlan = rtPlanList.FirstOrDefault(d => d.Plan_Id == view.Plan_Id);
if (plcList.plc.ReadInt16("DB111.DBW402") != 250)
{
if (hwWeighList.Count() > (rtPlan.Exec_Num + 1))
{
rtPlan.Exec_Num = 1;
}
if (hwWeighList.Count() == (rtPlan.Exec_Num + 1))
var hwWeighList = await _hwWeighRepository.GetWaiteMaterial(view.Plan_Id);
if (hwWeighList != null)
{
rtPlan.Exec_Num = rtPlan.Exec_Num + 1;
if (hwWeighList.Count() > (rtPlan.Exec_Num + 1))
{
rtPlan.Exec_Num = 1;
}
if (hwWeighList.Count() == (rtPlan.Exec_Num + 1))
{
rtPlan.Exec_Num = rtPlan.Exec_Num + 1;
}
if (hwWeighList.Count() > (rtPlan.Exec_Num + 1))
{
rtPlan.Exec_Num = rtPlan.Exec_Num + 1;
}
}
if (hwWeighList.Count() > (rtPlan.Exec_Num + 1))
//保存本次数据
int i = await _solventErrorPreventionReportRepository.AddAsync(report);
var cylinderList = _hwCylinderRepository.Query();
if (cylinderList.Count == 0)
{
rtPlan.Exec_Num = rtPlan.Exec_Num + 1;
return false;
}
}
//保存本次数据
int i = await _solventErrorPreventionReportRepository.AddAsync(report);
var cylinderList = _hwCylinderRepository.Query();
if (cylinderList.Count == 0)
{
return false;
rtPlan.CylinderName = cylinderList.FirstOrDefault(d => d.BarCode == view.CylinderBarCode).Name;
rtPlan.CylinderBarCode = view.CylinderBarCode;
log.Info(view.CylinderBarCode);
await _planRepository.UpdateExecDb(rtPlan);//更新数据库
return true;
}
rtPlan.CylinderName = cylinderList.FirstOrDefault(d => d.BarCode == view.CylinderBarCode).Name;
rtPlan.CylinderBarCode = view.CylinderBarCode;
log.Info(view.CylinderBarCode);
await _planRepository.UpdateExecDb(rtPlan);//更新数据库
return true;
}
}
return false;
}
return false;
}
else
{
return false;
}
return false;
}
else
{
return false;
return true;
}
}
catch (System.Exception ex)
@ -197,7 +201,6 @@ namespace Admin.Core.Service
/// <param name="pumpCode">泵Code</param>
/// <param name="cylinderCode">投料泵Code</param>
/// <returns></returns>
/// <exception cref="System.NotImplementedException"></exception>
public async Task<bool> ExecState(string planId, string pumpCode, string cylinderCode)
{
try
@ -205,91 +208,109 @@ namespace Admin.Core.Service
var result = await _planRepository.QueryAsync(d => d.Plan_Id == planId && d.PumpBarCode == pumpCode && d.CylinderBarCode == cylinderCode);
if (result.Count > 0)
{
#region 写入PLC
var pumpList = _hwPumpRepository.Query();
if (pumpList.Count == 0) { return false; }
var pump = pumpList.FirstOrDefault(d => d.BarCode == pumpCode);
if (pump == null) { return false; }
switch (pump.RowNum)
var plcList = PlcHelper.siemensList.SingleOrDefault(d => d.EquipName.Equals("溶剂PLC"));
if (plcList.plc.IsConnected)
{
case 1:
Adapter.WriteInt16("DB110.DBW282.0", "1");
break;
case 2:
Adapter.WriteInt16("DB110.DBW294.0", "1");
break;
case 3:
Adapter.WriteInt16("DB110.DBW306.0", "1");
break;
case 4:
Adapter.WriteInt16("DB110.DBW318.0", "1");
break;
case 5:
Adapter.WriteInt16("DB110.DBW330.0", "1");
break;
case 6:
Adapter.WriteInt16("DB110.DBW342.0", "1");
break;
case 7:
Adapter.WriteInt16("DB110.DBW354.0", "1");
break;
case 8:
Adapter.WriteInt16("DB110.DBW366.0", "1");
break;
case 9:
Adapter.WriteInt16("DB110.DBW 378.0", "1");
break;
default:
break;
}
#region 写入PLC
#endregion
var pumpList = _hwPumpRepository.Query();
if (pumpList.Count == 0) { return false; }
var pump = pumpList.FirstOrDefault(d => d.BarCode == pumpCode);
if (pump == null) { return false; }
switch (pump.RowNum)
{
case 1:
plcList.plc.WriteInt16("DB110.DBW282.0", "1");
break;
case 2:
plcList.plc.WriteInt16("DB110.DBW294.0", "1");
break;
case 3:
plcList.plc.WriteInt16("DB110.DBW306.0", "1");
break;
case 4:
plcList.plc.WriteInt16("DB110.DBW318.0", "1");
break;
case 5:
plcList.plc.WriteInt16("DB110.DBW330.0", "1");
break;
case 6:
plcList.plc.WriteInt16("DB110.DBW342.0", "1");
break;
case 7:
plcList.plc.WriteInt16("DB110.DBW354.0", "1");
break;
case 8:
plcList.plc.WriteInt16("DB110.DBW366.0", "1");
break;
case 9:
plcList.plc.WriteInt16("DB110.DBW 378.0", "1");
break;
default:
break;
}
return true;
#endregion
return true;
}
else
{
return false;
}
}
else
{
#region 写入PLC
var pumpList = _hwPumpRepository.Query();
if (pumpList.Count > 0) { return false; }
var pump = pumpList.FirstOrDefault(d => d.BarCode == pumpCode);
if (pump == null) { return false; }
switch (pump.RowNum)
var plcList = PlcHelper.siemensList.SingleOrDefault(d => d.EquipName.Equals("溶剂PLC"));
if (plcList.plc.IsConnected)
{
case 1:
Adapter.WriteInt16("DB110.DBW282.0", "2");
break;
case 2:
Adapter.WriteInt16("DB110.DBW294.0", "2");
break;
case 3:
Adapter.WriteInt16("DB110.DBW306.0", "2");
break;
case 4:
Adapter.WriteInt16("DB110.DBW318.0", "2");
break;
case 5:
Adapter.WriteInt16("DB110.DBW330.0", "2");
break;
case 6:
Adapter.WriteInt16("DB110.DBW342.0", "2");
break;
case 7:
Adapter.WriteInt16("DB110.DBW354.0", "2");
break;
case 8:
Adapter.WriteInt16("DB110.DBW366.0", "2");
break;
case 9:
Adapter.WriteInt16("DB110.DBW 378.0", "2");
break;
default:
break;
}
var pumpList = _hwPumpRepository.Query();
if (pumpList.Count > 0) { return false; }
var pump = pumpList.FirstOrDefault(d => d.BarCode == pumpCode);
if (pump == null) { return false; }
switch (pump.RowNum)
{
case 1:
plcList.plc.WriteInt16("DB110.DBW282.0", "2");
break;
case 2:
plcList.plc.WriteInt16("DB110.DBW294.0", "2");
break;
case 3:
plcList.plc.WriteInt16("DB110.DBW306.0", "2");
break;
case 4:
plcList.plc.WriteInt16("DB110.DBW318.0", "2");
break;
case 5:
plcList.plc.WriteInt16("DB110.DBW330.0", "2");
break;
case 6:
plcList.plc.WriteInt16("DB110.DBW342.0", "2");
break;
case 7:
plcList.plc.WriteInt16("DB110.DBW354.0", "2");
break;
case 8:
plcList.plc.WriteInt16("DB110.DBW366.0", "2");
break;
case 9:
plcList.plc.WriteInt16("DB110.DBW 378.0", "2");
break;
default:
break;
}
#endregion
return true;
#endregion
return true;
}
else
{
return false;
}
}
}
catch (System.Exception)
@ -311,19 +332,34 @@ namespace Admin.Core.Service
{
try
{
var list = await _planRepository.GetDownLoadPlan(code, weighbridge);
if (list.Count == 0) return null;
var plan = list.FirstOrDefault();
var hwWeighList = await _hwWeighRepository.GetWaiteMaterial(plan.Plan_Id);
if (hwWeighList == null) return null;
if (Adapter.IsConnected)
var plcList = PlcHelper.siemensList.SingleOrDefault(d => d.EquipName.Equals("溶剂PLC"));
if (plcList.plc.IsConnected)
{
int endStatus = Adapter.ReadInt16("DB110.DBW6.0");//完成信号
if (endStatus == 1)
var list = await _planRepository.GetDownLoadPlan(code, weighbridge);
if (list.Count == 0) return null;
var plan = list.FirstOrDefault();
var hwWeighList = await _hwWeighRepository.GetWaiteMaterial(plan.Plan_Id);
if (hwWeighList == null) return null;
if (plcList.plc.IsConnected)
{
int planNum = Adapter.ReadInt16("DB110.DBW2.0");//执行批次
if (plan.Plan_Num > plan.Real_Num)
int endStatus = plcList.plc.ReadInt16("DB110.DBW6.0");//完成信号
if (endStatus == 1)
{
int planNum = plcList.plc.ReadInt16("DB110.DBW2.0");//执行批次
if (plan.Plan_Num > plan.Real_Num)
{
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;
var hwWeigh = hwWeighList.FirstOrDefault(d => d.MID == execNum);
if (hwWeigh == null) return null;
return hwWeigh;
}
}
else
{
var rtPlanList = await _planRepository.QueryAsync(d => d.Plan_State == 3);
var rtPlan = rtPlanList.FirstOrDefault(d => d.Plan_Id == plan.Plan_Id);
@ -335,17 +371,6 @@ namespace Admin.Core.Service
return hwWeigh;
}
}
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;
var hwWeigh = hwWeighList.FirstOrDefault(d => d.MID == execNum);
if (hwWeigh == null) return null;
return hwWeigh;
}
}
return null;

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save