|
|
@ -31,7 +31,7 @@ namespace Admin.Core.Service
|
|
|
|
|
|
|
|
|
|
|
|
#region 构造函数
|
|
|
|
#region 构造函数
|
|
|
|
public xl_materialServices(IBaseRepository<xl_material> dal, Ixl_materialRepository xl_materialRepository,
|
|
|
|
public xl_materialServices(IBaseRepository<xl_material> dal, Ixl_materialRepository xl_materialRepository,
|
|
|
|
IPmt_BinRepository pmt_BinRepository,Ixl_planRepository planRepository,
|
|
|
|
IPmt_BinRepository pmt_BinRepository, Ixl_planRepository planRepository,
|
|
|
|
IHw_BarrelRepository hw_BarrelRepository, ILR_planRepository lrPlanRepository,
|
|
|
|
IHw_BarrelRepository hw_BarrelRepository, ILR_planRepository lrPlanRepository,
|
|
|
|
Ixl_weighRepository xlWeighRepository, IBinFeedingReportRepository binFeedingReportRepository)
|
|
|
|
Ixl_weighRepository xlWeighRepository, IBinFeedingReportRepository binFeedingReportRepository)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -57,9 +57,9 @@ namespace Admin.Core.Service
|
|
|
|
/// <param name="weight">物料重量</param>
|
|
|
|
/// <param name="weight">物料重量</param>
|
|
|
|
/// <param name="barCode">物料二维码</param>
|
|
|
|
/// <param name="barCode">物料二维码</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <returns></returns>
|
|
|
|
public async Task<MessageModel<bool>> ExecPlcState(int binSerial, int state, string materialCode, decimal weight,string? barCode)
|
|
|
|
public async Task<MessageModel<bool>> ExecPlcState(int binSerial, int state, string materialCode, decimal weight, string? barCode)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
MessageModel<bool> mesage=new MessageModel<bool>();
|
|
|
|
MessageModel<bool> mesage = new MessageModel<bool>();
|
|
|
|
log.Info(materialCode + "|" + weight);
|
|
|
|
log.Info(materialCode + "|" + weight);
|
|
|
|
string station = string.Empty;
|
|
|
|
string station = string.Empty;
|
|
|
|
try
|
|
|
|
try
|
|
|
@ -74,7 +74,7 @@ namespace Admin.Core.Service
|
|
|
|
var plcList = PlcHelper.siemensList.SingleOrDefault(d => d.EquipName.Equals("小料PLC"));
|
|
|
|
var plcList = PlcHelper.siemensList.SingleOrDefault(d => d.EquipName.Equals("小料PLC"));
|
|
|
|
if (plcList.plc.IsConnected)
|
|
|
|
if (plcList.plc.IsConnected)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int ponintVal= plcList.plc.ReadInt16(station);
|
|
|
|
int ponintVal = plcList.plc.ReadInt16(station);
|
|
|
|
if (ponintVal == 1)
|
|
|
|
if (ponintVal == 1)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mesage.success = false;
|
|
|
|
mesage.success = false;
|
|
|
@ -88,7 +88,7 @@ namespace Admin.Core.Service
|
|
|
|
{
|
|
|
|
{
|
|
|
|
string[] str = barCode.Split("#");
|
|
|
|
string[] str = barCode.Split("#");
|
|
|
|
|
|
|
|
|
|
|
|
//保存料仓投料重量
|
|
|
|
//保存料仓投料重量
|
|
|
|
Hw_BinTypeErrorPreventionReport hw = new Hw_BinTypeErrorPreventionReport()
|
|
|
|
Hw_BinTypeErrorPreventionReport hw = new Hw_BinTypeErrorPreventionReport()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
BinID = binSerial,
|
|
|
|
BinID = binSerial,
|
|
|
@ -290,9 +290,9 @@ namespace Admin.Core.Service
|
|
|
|
{
|
|
|
|
{
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var query = await _xl_materialRepository.QueryAsync(d=>d.IsEnable == "是");
|
|
|
|
var query = await _xl_materialRepository.QueryAsync(d => d.IsEnable == "是");
|
|
|
|
if (query == null) return null;
|
|
|
|
if (query == null) return null;
|
|
|
|
var m= query.FirstOrDefault(d => d.Material_code.Trim() == code.Trim());
|
|
|
|
var m = query.FirstOrDefault(d => d.Material_code.Trim() == code.Trim());
|
|
|
|
|
|
|
|
|
|
|
|
return m;
|
|
|
|
return m;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -340,7 +340,7 @@ namespace Admin.Core.Service
|
|
|
|
/// <exception cref="NotImplementedException"></exception>
|
|
|
|
/// <exception cref="NotImplementedException"></exception>
|
|
|
|
public async Task<int> BindBarrel(string code)
|
|
|
|
public async Task<int> BindBarrel(string code)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
List<XlPlanView> down=new List<XlPlanView>();
|
|
|
|
List<XlPlanView> down = new List<XlPlanView>();
|
|
|
|
if (flag)
|
|
|
|
if (flag)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
flag = false;
|
|
|
|
flag = false;
|
|
|
@ -364,7 +364,7 @@ namespace Admin.Core.Service
|
|
|
|
if (barrelList == null) return 1;
|
|
|
|
if (barrelList == null) return 1;
|
|
|
|
|
|
|
|
|
|
|
|
Hw_Barrel barrel = barrelList.FirstOrDefault(d => d.BarCode == code.Trim());
|
|
|
|
Hw_Barrel barrel = barrelList.FirstOrDefault(d => d.BarCode == code.Trim());
|
|
|
|
bool bl = barrel == null?true:false;
|
|
|
|
bool bl = barrel == null ? true : false;
|
|
|
|
|
|
|
|
|
|
|
|
if (barrel == null) return 2;
|
|
|
|
if (barrel == null) return 2;
|
|
|
|
//if (!string.IsNullOrEmpty(barrel.MaterialID)) return 3;//判断桶是否绑定
|
|
|
|
//if (!string.IsNullOrEmpty(barrel.MaterialID)) return 3;//判断桶是否绑定
|
|
|
@ -434,7 +434,7 @@ namespace Admin.Core.Service
|
|
|
|
{
|
|
|
|
{
|
|
|
|
log.Info($"no3>>剩余批次:{batch}>计划批次:{exec.Plan_Num}》当前批次》{tcheckBatch}");
|
|
|
|
log.Info($"no3>>剩余批次:{batch}>计划批次:{exec.Plan_Num}》当前批次》{tcheckBatch}");
|
|
|
|
await _hw_BarrelRepository.UpdateAsync(barrel);
|
|
|
|
await _hw_BarrelRepository.UpdateAsync(barrel);
|
|
|
|
bool r = await UpdatePlanCompletedQuantity(plcList,exec.Plan_Id, tcheckBatch, 8, DateTime.Now, total_Weight, total_Error);
|
|
|
|
bool r = await UpdatePlanCompletedQuantity(plcList, exec.Plan_Id, tcheckBatch, 8, DateTime.Now, total_Weight, total_Error);
|
|
|
|
log.Info("超重-称量完成:" + r);
|
|
|
|
log.Info("超重-称量完成:" + r);
|
|
|
|
if (r)
|
|
|
|
if (r)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -468,20 +468,20 @@ namespace Admin.Core.Service
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
log.Error("检量称状态显示未完成");
|
|
|
|
log.Error("执行批次未获取");
|
|
|
|
return 110;//检量称状态显示未完成
|
|
|
|
return 110;//执行批次未获取
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
log.Error("PLC连接失败");
|
|
|
|
log.Error("检量称状态显示未完成");
|
|
|
|
return 110;//PLC连接失败
|
|
|
|
return 110;//检量称状态显示未完成
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
log.Error("执行批次未获取");
|
|
|
|
log.Error("PLC连接失败");
|
|
|
|
return 8;//执行批次未获取
|
|
|
|
return 8;//PLC连接失败
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
catch (Exception ex)
|
|
|
@ -539,13 +539,13 @@ namespace Admin.Core.Service
|
|
|
|
/// <param name="planId">计划号</param>
|
|
|
|
/// <param name="planId">计划号</param>
|
|
|
|
/// <param name="quantity">完成数量</param>
|
|
|
|
/// <param name="quantity">完成数量</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <returns></returns>
|
|
|
|
public async Task<bool> UpdatePlanCompletedQuantity(PlcModel mode, string planId, int quantity, int state, DateTime date, decimal totalWeight, decimal totalError)
|
|
|
|
public async Task<bool> UpdatePlanCompletedQuantity(PlcModel mode, string planId, int quantity, int state, DateTime date, decimal totalWeight, decimal totalError)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var planList= await _planRepository.QueryAsync();
|
|
|
|
var planList = await _planRepository.QueryAsync();
|
|
|
|
if (planList == null) return false;
|
|
|
|
if (planList == null) return false;
|
|
|
|
var plan= planList.FirstOrDefault(d=>d.Plan_Id== planId);
|
|
|
|
var plan = planList.FirstOrDefault(d => d.Plan_Id == planId);
|
|
|
|
if (plan == null) return false;
|
|
|
|
if (plan == null) return false;
|
|
|
|
|
|
|
|
|
|
|
|
plan.Real_Num = mode.plc.ReadInt16("DB110.DBW212");
|
|
|
|
plan.Real_Num = mode.plc.ReadInt16("DB110.DBW212");
|
|
|
@ -554,7 +554,7 @@ namespace Admin.Core.Service
|
|
|
|
plan.Plan_TotalWeight = totalWeight;
|
|
|
|
plan.Plan_TotalWeight = totalWeight;
|
|
|
|
plan.Plan_TotalError = totalError;
|
|
|
|
plan.Plan_TotalError = totalError;
|
|
|
|
plan.Plan_StateText = StateToShow(state);
|
|
|
|
plan.Plan_StateText = StateToShow(state);
|
|
|
|
var result= await _planRepository.UpdateAsync(plan);
|
|
|
|
var result = await _planRepository.UpdateAsync(plan);
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception)
|
|
|
|
catch (Exception)
|
|
|
@ -637,12 +637,7 @@ namespace Admin.Core.Service
|
|
|
|
public int GetTcheckBatch(PlcModel model)
|
|
|
|
public int GetTcheckBatch(PlcModel model)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int tb = 0;
|
|
|
|
int tb = 0;
|
|
|
|
int i = 0;
|
|
|
|
tb = model.plc.ReadInt16("DB110.DBW212");
|
|
|
|
do
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
tb = model.plc.ReadInt16("DB110.DBW212");
|
|
|
|
|
|
|
|
i++;
|
|
|
|
|
|
|
|
} while (i >3);
|
|
|
|
|
|
|
|
log.Info("获取批次:" + tb);
|
|
|
|
log.Info("获取批次:" + tb);
|
|
|
|
return tb;
|
|
|
|
return tb;
|
|
|
|
}
|
|
|
|
}
|
|
|
|