|
|
|
@ -15,7 +15,7 @@ namespace SlnMesnac.Repository.service.Impl
|
|
|
|
|
public class AGVStateServiceImpl : BaseServiceImpl<AGVState>, IAGVStateService
|
|
|
|
|
{
|
|
|
|
|
private ILogger<AGVStateServiceImpl> _logger;
|
|
|
|
|
public AGVStateServiceImpl(Repository<AGVState> repository, ILogger<AGVStateServiceImpl> logger) :base(repository)
|
|
|
|
|
public AGVStateServiceImpl(Repository<AGVState> repository, ILogger<AGVStateServiceImpl> logger) : base(repository)
|
|
|
|
|
{
|
|
|
|
|
_logger = logger;
|
|
|
|
|
}
|
|
|
|
@ -26,13 +26,18 @@ namespace SlnMesnac.Repository.service.Impl
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Expression<Func<AGVState, bool>> exp = x => true;
|
|
|
|
|
exp = exp.And(x =>(x.agvno != null || x.agvno != "") && (x.taskno == null || x.taskno == "") && x.agvworkstate == "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" && (x.agvalarmstate == null || x.agvalarmstate == "") && x.agvtype == _AgvType);
|
|
|
|
|
exp = exp.And(x =>
|
|
|
|
|
(x.agvno != null || x.agvno != "")
|
|
|
|
|
&& (x.taskno == null || x.taskno == "")
|
|
|
|
|
&& x.agvworkstate == "空闲"
|
|
|
|
|
&& (x.agvalarmstate == null || x.agvalarmstate == "")
|
|
|
|
|
&& x.agvtype == _AgvType);
|
|
|
|
|
|
|
|
|
|
agvStateInfoList = base._rep.GetList(exp);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError($"<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>AGV<EFBFBD><EFBFBD>Ϣ<EFBFBD>쳣:{ex.Message}");
|
|
|
|
|
_logger.LogError($"AGV状态获取错误:{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
return agvStateInfoList;
|
|
|
|
|
}
|
|
|
|
@ -46,7 +51,7 @@ namespace SlnMesnac.Repository.service.Impl
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError($"<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>AGV<EFBFBD><EFBFBD>Ϣ<EFBFBD>쳣:{ex.Message}");
|
|
|
|
|
_logger.LogError($"所有AGV状态获取错误:{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
return agvStateInfoList;
|
|
|
|
|
}
|
|
|
|
@ -57,34 +62,43 @@ namespace SlnMesnac.Repository.service.Impl
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<bool> UpdateOrAddByResponse(AGVStateResponseEntity response)
|
|
|
|
|
public async Task<bool> UpdateOrAddByResponse(AGVResponseEntity<List<ResponseRobotAtrributeDataEntity>> response)
|
|
|
|
|
{
|
|
|
|
|
AGVState record = new AGVState()
|
|
|
|
|
List<AGVState> records = new List<AGVState>();
|
|
|
|
|
foreach (var entity in response.Data)
|
|
|
|
|
{
|
|
|
|
|
agvno = response.AGVNo,
|
|
|
|
|
agvalarmstate = response.AGVAlarmState,
|
|
|
|
|
agvtype = response.AGVType,
|
|
|
|
|
agvworkstate = response.AGVWorkState,
|
|
|
|
|
refreshtime = DateTime.Now,
|
|
|
|
|
taskno = response.TaskNo,
|
|
|
|
|
};
|
|
|
|
|
AGVState record = new AGVState()
|
|
|
|
|
{
|
|
|
|
|
agvno = entity.Guid,
|
|
|
|
|
agvalarmstate = entity.AgvMoveStatus != 6 ? "正常" : "异常",
|
|
|
|
|
agvtype = entity.Name,
|
|
|
|
|
agvworkstate = entity.AgvMoveStatus == 1 ? "空闲" : "忙碌",
|
|
|
|
|
refreshtime = DateTime.Now,
|
|
|
|
|
taskno = entity.TaskID,
|
|
|
|
|
};
|
|
|
|
|
records.Add(record);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool result = false;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var list = GetAllAGVState();
|
|
|
|
|
if (list.Where(x => x.agvno == response.AGVNo).Count() == 0)
|
|
|
|
|
{
|
|
|
|
|
result = _rep.Insert(record);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
foreach (var r in records)
|
|
|
|
|
{
|
|
|
|
|
record.id = list.Where(x => x.agvno == response.AGVNo).FirstOrDefault().id;
|
|
|
|
|
result = await _rep.UpdateAsync(record);
|
|
|
|
|
if (list.Where(x => x.agvno == r.agvno).Count() == 0)
|
|
|
|
|
{
|
|
|
|
|
result = _rep.Insert(r);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
r.id = list.Where(x => x.agvno == r.agvno).FirstOrDefault().id;
|
|
|
|
|
result = await _rep.UpdateAsync(r);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError($"<22><>е<EFBFBD><D0B5>״̬<D7B4><CCAC>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD>쳣:{ex.Message}");
|
|
|
|
|
_logger.LogError($"AGV状态更新错误:{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|