change- 吃斌哥的shi

main
SoulStar 1 day ago
parent 12b64bec6a
commit 7484048f1a

@ -75,7 +75,7 @@ namespace Admin.Core.Api.Controllers.Business
/// <param name="lrweighService"></param> /// <param name="lrweighService"></param>
/// <param name="binFeedingReportServices"></param> /// <param name="binFeedingReportServices"></param>
/// <param name="xl_materialService"></param> /// <param name="xl_materialService"></param>
public WarehouseController(IHw_WarehouseServices hw_WarehouseServices, ISysUserService sysUserService, public WarehouseController(IHw_WarehouseServices hw_WarehouseServices, ISysUserService sysUserService,
IHw_BarrelServices hwBarrelService, ILR_weighServices lrweighService, IBinFeedingReportServices binFeedingReportServices, Ixl_materialServices xl_materialService) : base(sysUserService) IHw_BarrelServices hwBarrelService, ILR_weighServices lrweighService, IBinFeedingReportServices binFeedingReportServices, Ixl_materialServices xl_materialService) : base(sysUserService)
{ {
_sysUserService = sysUserService; _sysUserService = sysUserService;
@ -301,20 +301,28 @@ namespace Admin.Core.Api.Controllers.Business
return Failed<List<LR_weigh_BatchCode>>("传入参数为空!"); return Failed<List<LR_weigh_BatchCode>>("传入参数为空!");
} }
var result = await _xl_materialService.BindBarrel(barrelBarcode.Trim()); int taskResult = await _xl_materialService.BindBarrel(barrelBarcode.Trim());
int weightResult = 0;
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());
if (string.IsNullOrEmpty(materialName)) if (string.IsNullOrEmpty(materialName))
{ {
return Failed<List<LR_weigh_BatchCode>>("查询不到罐号对应的物料ID!"); weightResult = 1;
//return Failed<List<LR_weigh_BatchCode>>("查询不到罐号对应的物料ID!");
} }
if (materialName == "-1") if (materialName == "-1")
{ {
return Failed<List<LR_weigh_BatchCode>>("查询不到罐号!"); weightResult = 2;
//return Failed<List<LR_weigh_BatchCode>>("查询不到罐号!");
} }
List<LR_weigh> wlist = _lr_weighService.GetRecentWeightList(materialName); List<LR_weigh> wlist = _lr_weighService.GetRecentWeightList(materialName);
List<LR_weigh_BatchCode> list = new List<LR_weigh_BatchCode>(); List<LR_weigh_BatchCode> list = new List<LR_weigh_BatchCode>();
if (wlist.Count == 0 || wlist == null)
{
weightResult = 3;
}
foreach (LR_weigh weigh in wlist) foreach (LR_weigh weigh in wlist)
{ {
LR_weigh_BatchCode record = new LR_weigh_BatchCode(); LR_weigh_BatchCode record = new LR_weigh_BatchCode();
@ -322,39 +330,46 @@ 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 && list.Count != 0)
{ string taskString = "";
if (result == 0) string WeightString = "";
return Success(list, "查询成功,任务结束失败,原因:未查询到正在执行的计划!");
if (result == 1) if (taskResult == 0)
return Success(list, "查询成功,任务结束失败,原因:未查询到桶!"); taskString = "任务结束失败 原因:未查询到正在执行的计划!";
if (result == 2) if (taskResult == 1)
return Success(list, $"查询成功,任务结束失败,原因:未查询到[{barrelBarcode}]桶信息!"); taskString = "任务结束失败 原因:未查询到桶!";
if (result == 3) if (taskResult == 2)
return Success(list, "查询成功,任务结束失败,原因:该桶已经绑定物料,请联系系统管理员处理!"); taskString = $"任务结束失败 原因:未查询到[{barrelBarcode}]桶信息!";
if (result == 6) if (taskResult == 3)
{ taskString = "任务结束失败 原因:该桶已经绑定物料,请联系系统管理员处理!";
log.Info("任务结束成功"); if (taskResult == 6)
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
{ {
return Failed<List<LR_weigh_BatchCode>>("称量信息查询失败!查询不到称量信息!任务未结束"); log.Info("任务结束成功");
taskString = "任务结束成功";
} }
if (taskResult == 7)
taskString = "任务结束失败 原因:称重未完成!";
if (taskResult == 8)
taskString = "任务结束失败 原因PLC连接失败请检查PLC或者联系管理员处理";
if (taskResult == 10)
taskString = "任务结束失败 原因:未知异常,请查看错误日志!";
if (taskResult == 99)
taskString = "任务结束失败 原因:保存处理数据失败!";
if (taskResult == 100)
taskString = "任务结束失败 原因:处理中....";
if (taskResult == 110)
taskString = "任务结束失败 原因:执行批次未获取!";
if (weightResult == 0)
WeightString = "称量信息查询成功";
if (weightResult == 1)
WeightString = "查询不到罐号对应的物料ID!";
if (weightResult == 2)
WeightString = "查询不到罐号!";
if (weightResult == 3)
WeightString = "查询不到该罐号对应的最近一次物料的称量信息!";
return Success(list, $"{WeightString} {taskString}");
} }
#endregion #endregion

@ -22,13 +22,17 @@ namespace Admin.Core.Service
try try
{ {
List<LR_weigh> list = _dal.Query(x => x.Material_Name == MaterialName).ToList(); List<LR_weigh> list = _dal.Query(x => x.Material_Name == MaterialName).ToList();
if (list == null && list.Count == 0)
{
return new List<LR_weigh>();
}
int maxMainID = list.Max(x => x.MainId); int maxMainID = list.Max(x => x.MainId);
List<LR_weigh> groupList = list.Where(x => x.MainId == maxMainID).ToList(); List<LR_weigh> groupList = list.Where(x => x.MainId == maxMainID).ToList();
return groupList; return groupList;
} }
catch catch
{ {
throw; return new List<LR_weigh>();
} }
} }
} }

@ -375,7 +375,7 @@ namespace Admin.Core.Service
barrel.Weight = tcheckWeight; barrel.Weight = tcheckWeight;
barrel.CreateDateTime = DateTime.Now; barrel.CreateDateTime = DateTime.Now;
int tcheckBatch = GetTcheckBatch(plcList);//当前执行的车次 int tcheckBatch = plcList.plc.ReadInt16("DB110.DBW212"); //当前执行的车次
log.Info("批次:" + tcheckBatch.ToString()); log.Info("批次:" + tcheckBatch.ToString());
if (tcheckBatch > 0) if (tcheckBatch > 0)
{ {
@ -393,14 +393,14 @@ namespace Admin.Core.Service
//total_Error = total_Error; //total_Error = total_Error;
if (batch == 0) //完成 if (batch == 0) //完成
{ {
log.Info($"no1>>剩余批次:{batch}>计划批次:{exec.Plan_Num}》当前批次》{tcheckBatch}"); log.Info($"no1>>剩余批次:{batch} > 计划批次:{exec.Plan_Num}》当前批次》{tcheckBatch}");
await _hw_BarrelRepository.UpdateAsync(barrel); await _hw_BarrelRepository.UpdateAsync(barrel);
var r = await UpdatePlanCompletedQuantity(plcList, exec.Plan_Id, tcheckBatch, 8, DateTime.Now, total_Weight, total_Error); var 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)
{ {
//判断上位机判断当前值与配方总重满足要求时置“2” //判断上位机判断当前值与配方总重满足要求时置“2”
plcList.plc.WriteInt32("DB110.DBW88", 2);//2上位机完成,实点位为DB110.DBW90 plcList.plc.WriteInt32("DB110.DBW88", 2); //2上位机完成,实点位为DB110.DBW90
return 6; return 6;
} }
else else

Loading…
Cancel
Save