- 修复结束计划报错提示顺序错误
- 删除无用do while
change
- 修改查询称量信息并且结束任务的顺序,先结束任务,后查询称量信息批次号-然后返回结果
main
SoulStar 4 days ago
parent cd4c800518
commit 12b64bec6a

@ -178,7 +178,6 @@ namespace Admin.Core.Api
{ {
if (!code.IsNotEmptyOrNull()) if (!code.IsNotEmptyOrNull())
return Failed<bool>("桶条码信息传入参数为空!"); return Failed<bool>("桶条码信息传入参数为空!");
var result = await _xl_materialService.BindBarrel(code.Trim()); var result = await _xl_materialService.BindBarrel(code.Trim());
if (result == 0) if (result == 0)
return Failed<bool>("未查询到正在执行的计划!"); return Failed<bool>("未查询到正在执行的计划!");

@ -302,29 +302,6 @@ namespace Admin.Core.Api.Controllers.Business
} }
var result = await _xl_materialService.BindBarrel(barrelBarcode.Trim()); var result = await _xl_materialService.BindBarrel(barrelBarcode.Trim());
if (result == 0)
return Failed<List<LR_weigh_BatchCode>>("未查询到正在执行的计划!");
if (result == 1)
return Failed<List<LR_weigh_BatchCode>>("未查询到桶!");
if (result == 2)
return Failed<List<LR_weigh_BatchCode>>($"未查询到[{barrelBarcode}]桶信息!");
if (result == 3)
return Failed<List<LR_weigh_BatchCode>>("该桶已经绑定物料,请联系系统管理员处理!");
if (result == 6)
//return Success(true);
log.Info("任务结束成功");
if (result == 7)
return Failed<List<LR_weigh_BatchCode>>("称重未完成!");
if (result == 8)
return Failed<List<LR_weigh_BatchCode>>("PLC连接失败请检查PLC或者联系管理员处理");
if (result == 10)
return Failed<List<LR_weigh_BatchCode>>("未知异常,请查看错误日志!");
if (result == 99)
return Failed<List<LR_weigh_BatchCode>>("保存处理数据失败!");
if (result == 100)
return Failed<List<LR_weigh_BatchCode>>("处理中....");
if (result == 110)
return Failed<List<LR_weigh_BatchCode>>("执行批次未获取!");
MessageModel<List<LR_weigh>> messageModel = new MessageModel<List<LR_weigh>>(); MessageModel<List<LR_weigh>> messageModel = new MessageModel<List<LR_weigh>>();
string materialName = _hw_BarrelService.GetMaterialNameByBarrelID(barrelBarcode.Trim()); string materialName = _hw_BarrelService.GetMaterialNameByBarrelID(barrelBarcode.Trim());
@ -345,13 +322,38 @@ namespace Admin.Core.Api.Controllers.Business
record.BatchCode = _binFeedingReportServices.GetBatchNumberByMaterialAndBinID(weigh.Material_ID, weigh.Bin_Serial ?? -1); record.BatchCode = _binFeedingReportServices.GetBatchNumberByMaterialAndBinID(weigh.Material_ID, weigh.Bin_Serial ?? -1);
list.Add(record); list.Add(record);
} }
if (list != null) if (list != null && list.Count != 0)
{ {
return Success(list); if (result == 0)
return Success(list, "查询成功,任务结束失败,原因:未查询到正在执行的计划!");
if (result == 1)
return Success(list, "查询成功,任务结束失败,原因:未查询到桶!");
if (result == 2)
return Success(list, $"查询成功,任务结束失败,原因:未查询到[{barrelBarcode}]桶信息!");
if (result == 3)
return Success(list, "查询成功,任务结束失败,原因:该桶已经绑定物料,请联系系统管理员处理!");
if (result == 6)
{
log.Info("任务结束成功");
return Success(list, "任务结束成功,计划信息查询成功");
}
if (result == 7)
return Success(list, "查询成功,任务结束失败,原因:称重未完成!");
if (result == 8)
return Success(list, "查询成功任务结束失败原因PLC连接失败请检查PLC或者联系管理员处理");
if (result == 10)
return Success(list, "查询成功,任务结束失败,原因:未知异常,请查看错误日志!");
if (result == 99)
return Success(list, "查询成功,任务结束失败,原因:保存处理数据失败!");
if (result == 100)
return Success(list, "查询成功,任务结束失败,原因:处理中....");
if (result == 110)
return Success(list, "查询成功,任务结束失败,原因:执行批次未获取!");
return Success(list, "查询成功,任务结束失败");
} }
else else
{ {
return Failed<List<LR_weigh_BatchCode>>("任务结束成功但称量信息查询失败!"); return Failed<List<LR_weigh_BatchCode>>("称量信息查询失败!查询不到称量信息!任务未结束");
} }
} }

@ -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;
} }

Loading…
Cancel
Save