debug - 修改乱码问题,解决新接口不适配老服务类问题

master
SoulStar 4 months ago
parent 1171d1cd87
commit 3d3b1cae2e

@ -11,29 +11,27 @@ namespace SlnMesnac.Business.@base
public class BaseStateRefreshBusiness
{
private IAGVStateService _AGVStateService;
private IManipulatorStateService _ManipulatorStateService;
private ILogger<BaseStateRefreshBusiness> _logger;
private static BaseStateRefreshBusiness instance;
public BaseStateRefreshBusiness(ILogger<BaseStateRefreshBusiness> logger, IAGVStateService agvService, IManipulatorStateService manipulatorStateService)
public BaseStateRefreshBusiness(ILogger<BaseStateRefreshBusiness> logger, IAGVStateService agvService)
{
_logger = logger;
_AGVStateService = agvService;
_ManipulatorStateService = manipulatorStateService;
}
public static BaseStateRefreshBusiness GetInstance(ILogger<BaseStateRefreshBusiness> logger, IAGVStateService agvService, IManipulatorStateService manipulatorStateService)
public static BaseStateRefreshBusiness GetInstance(ILogger<BaseStateRefreshBusiness> logger, IAGVStateService agvService)
{
if (instance == null)
{
instance = new BaseStateRefreshBusiness(logger, agvService, manipulatorStateService);
instance = new BaseStateRefreshBusiness(logger, agvService);
}
return instance;
}
public bool UpdateAGVStateByResposne(AGVStateRequestEntity request)
public bool UpdateAGVStateByResposne()
{
try
{
var response = AirPorthttpClient.AGVStateRequest(request);
var response = AirPorthttpClient.AGVStateRequest();
_AGVStateService.UpdateOrAddByResponse(response);
}
catch (Exception e)
@ -43,18 +41,5 @@ namespace SlnMesnac.Business.@base
return true;
}
public bool UpdateManipulatorStateByResposne(ManipulatorStateRequestEntity request)
{
try
{
var response = AirPorthttpClient.ManipulatorStateRequest(request);
_ManipulatorStateService.UpdateOrAddByResponse(response);
}
catch (Exception e)
{
_logger.LogError("Error:" + e);
}
return true;
}
}
}

@ -30,8 +30,8 @@ namespace SlnMesnac.Business.@base
{
_logger = logger;
_tcpServer = tcpServer;
_tcpServer.VisionSysStateEvent += TcpServerOnVisionSysStateEvent;
_tcpServer.StackWorkDoneEvent += _tcpServer_StackWorkDoneEvent;
_tcpServer.ReceiveVisionSysStateEvent += TcpServerOnVisionSysStateEvent;
_tcpServer.ReceiveStackWorkDoneEvent += _tcpServer_StackWorkDoneEvent;
_Taskservice = Taskservice;
_AGVStateService = agvService;
InitClearTimer();
@ -41,7 +41,7 @@ namespace SlnMesnac.Business.@base
/// 一次码垛完成,发送码垛结果
/// </summary>
/// <param name="entity"></param>
private void _tcpServer_StackWorkDoneEvent(TcpVisionEntity entity)
private void _tcpServer_StackWorkDoneEvent(TcpVisionEntity entity, string id)
{
try
{
@ -76,7 +76,7 @@ namespace SlnMesnac.Business.@base
/// 视觉系统回复给上位机调度系统开始工作状态
/// </summary>
/// <param name="entity"></param>
private void TcpServerOnVisionSysStateEvent(TcpVisionEntity entity)
private void TcpServerOnVisionSysStateEvent(TcpVisionEntity entity, string id)
{
try
{

@ -74,11 +74,6 @@ namespace SlnMesnac.Config
/// </summary>
public string AGVIpConfig { get; set; }
/// <summary>
/// 机械臂地址配置
/// </summary>
public string ManipulatorIpConfig { get; set; }
/// <summary>
/// 机械臂地址配置
/// </summary>

@ -24,7 +24,7 @@ namespace SlnMesnac.Repository
public int id {get;set;}
/// <summary>
/// Desc:
/// Desc:AGV编号
/// Default:
/// Nullable:False
/// </summary>
@ -32,7 +32,7 @@ namespace SlnMesnac.Repository
public string agvno {get;set;}
/// <summary>
/// Desc:
/// Desc:AGV类型 1AMR 2: 机械臂
/// Default:
/// Nullable:False
/// </summary>
@ -40,7 +40,7 @@ namespace SlnMesnac.Repository
public string agvtype {get;set;}
/// <summary>
/// Desc:
/// Desc:任务编号
/// Default:
/// Nullable:False
/// </summary>
@ -48,7 +48,7 @@ namespace SlnMesnac.Repository
public string taskno {get;set;}
/// <summary>
/// Desc:
/// Desc:AGV报警状态
/// Default:
/// Nullable:False
/// </summary>
@ -56,7 +56,7 @@ namespace SlnMesnac.Repository
public string agvalarmstate {get;set;}
/// <summary>
/// Desc:
/// Desc:AGV工作状态
/// Default:
/// Nullable:False
/// </summary>
@ -64,7 +64,7 @@ namespace SlnMesnac.Repository
public string agvworkstate {get;set;}
/// <summary>
/// Desc:
/// Desc:刷新时间
/// Default:
/// Nullable:False
/// </summary>

@ -35,7 +35,7 @@ namespace SlnMesnac.Repository.service
/// </summary>
/// <param name="response"></param>
/// <returns></returns>
Task<bool> UpdateOrAddByResponse(AGVStateResponseEntity response);
Task<bool> UpdateOrAddByResponse(AGVResponseEntity<List<ResponseRobotAtrributeDataEntity>> response);
}
}

@ -1,39 +0,0 @@
using SlnMesnac.Model.AirportApiEntity;
using SlnMesnac.Model.domain;
using SlnMesnac.Repository.service.@base;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
namespace SlnMesnac.Repository.service
{
public interface IManipulatorStateService : IBaseService<ManipulatorState>
{
/// <summary>
/// 查询空闲的机械臂信息
/// </summary>
/// <returns></returns>
List<ManipulatorState> GetFreeManipulatorState();
/// <summary>
/// 查询所有机械臂信息
/// </summary>
/// <returns></returns>
List<ManipulatorState> GetAllManipulatorState();
/// <summary>
/// 更新机械臂设备状态信息
/// </summary>
/// <param name="record"></param>
/// <returns></returns>
Task<bool> UpdateAsync(ManipulatorState record);
/// <summary>
/// 更新或插入机械臂设备状态信息
/// </summary>
/// <param name="response"></param>
/// <returns></returns>
Task<bool> UpdateOrAddByResponse(ManipulatorStateResponseEntity response);
}
}

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

@ -1,92 +0,0 @@
using Microsoft.Extensions.Logging;
using SlnMesnac.Common;
using SlnMesnac.Model.AirportApiEntity;
using SlnMesnac.Model.domain;
using SlnMesnac.Repository.service.@base;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace SlnMesnac.Repository.service.Impl
{
public class ManipulatorStateServiceImpl : BaseServiceImpl<ManipulatorState>, IManipulatorStateService
{
private ILogger<ManipulatorStateServiceImpl> _logger;
public ManipulatorStateServiceImpl(Repository<ManipulatorState> rep, ILogger<ManipulatorStateServiceImpl> logger) : base(rep)
{
_logger = logger;
}
public List<ManipulatorState> GetAllManipulatorState()
{
var list = new List<ManipulatorState>();
try
{
list = base._rep.GetList();
}
catch (Exception ex)
{
_logger.LogError($"所有机械臂状态信息获取异常:{ex.Message}");
}
return list;
}
public List<ManipulatorState> GetFreeManipulatorState()
{
var list = new List<ManipulatorState>();
try
{
list = base._rep.GetList()
.Where(x => x.ManipulatorNo != "" && (x.TaskNo == null || x.TaskNo == "") && x.ManipulatorWorkState == "任务空闲")
.ToList();
}
catch (Exception ex)
{
_logger.LogError($"空闲机械臂状态信息获取异常:{ex.Message}");
}
return list;
}
public async Task<bool> UpdateAsync(ManipulatorState record)
{
bool result = await _rep.UpdateAsync(record);
return result;
}
public async Task<bool> UpdateOrAddByResponse(ManipulatorStateResponseEntity response)
{
ManipulatorState record = new ManipulatorState()
{
ManipulatorNo = response.ManipulatorNo,
ManipulatorAlarmState = response.ManipulatorAlarmState,
ManipulatorWorkState = response.ManipulatorWorkState,
TaskNo = response.TaskNo,
RefreshTime = DateTime.Now,
};
bool result = false;
try
{
var list = GetAllManipulatorState();
if (list.Where(x => x.ManipulatorNo == response.ManipulatorNo).Count() == 0)
{
result = _rep.Insert(record);
}
else
{
record.ID = list.Where(x => x.ManipulatorNo == response.ManipulatorNo).FirstOrDefault().ID;
result = await _rep.UpdateAsync(record);
}
}
catch(Exception ex)
{
_logger.LogError($"机械臂状态信息更新异常:{ex.Message}");
}
return result;
}
}
}

@ -54,7 +54,6 @@ namespace SlnMesnac.TouchSocket
try
{
AirportAGVClient = CreateWebApiClient(_appConfig.AGVIpConfig);
AirportManipulatorClient = CreateWebApiClient(_appConfig.ManipulatorIpConfig);
}
catch (Exception ex)
{
@ -65,7 +64,7 @@ namespace SlnMesnac.TouchSocket
}
/// <summary>
/// AGV呼叫请求
///
/// </summary>
/// <returns></returns>
public static string AGVCallRequest()
@ -76,26 +75,49 @@ namespace SlnMesnac.TouchSocket
}
/// <summary>
/// AGV状态请求
/// AGV下发任务请求
/// </summary>
/// <param name="aGVStateRequest"></param>
/// <returns></returns>
public static AGVStateResponseEntity AGVStateRequest(AGVStateRequestEntity aGVStateRequest)
public static AGVResponseEntity<ResponseAddTaskDataEntity> AGVAddTaskRequest(AGVRequestAddTaskEntity addTaskEntity)
{
JToken responseValue = AirportAGVClient.InvokeT<JToken>("POST:/m1/5051269-4712337-default/apitest/AGVtest", null, aGVStateRequest);
JToken responseValue = AirportAGVClient.InvokeT<JToken>("POST:/api/task/addTask", null, addTaskEntity);
if (responseValue == null)
{
return new AGVStateResponseEntity();
return new AGVResponseEntity<ResponseAddTaskDataEntity>();
}
string json = responseValue.ToString();
if (string.IsNullOrEmpty(json))
{
return new AGVStateResponseEntity();
return new AGVResponseEntity<ResponseAddTaskDataEntity>();
}
AGVStateResponseEntity aGVStateResponseEntity = new AGVStateResponseEntity();
aGVStateResponseEntity = JsonSerializer.Deserialize<AGVStateResponseEntity>(json);
return aGVStateResponseEntity;
AGVResponseEntity<ResponseAddTaskDataEntity> responseEntity;
responseEntity = JsonSerializer.Deserialize<AGVResponseEntity<ResponseAddTaskDataEntity>>(json);
return responseEntity;
}
/// <summary>
/// 获取AGV所有信息
/// </summary>
/// <param name="aGVStateRequest"></param>
/// <returns></returns>
public static AGVResponseEntity<List<ResponseRobotAtrributeDataEntity>> AGVStateRequest()
{
JToken responseValue = AirportAGVClient.InvokeT<JToken>("GET:http://192.168.40.81:5102/api/task/robot/getRobot", null);
if (responseValue == null)
{
return new AGVResponseEntity<List<ResponseRobotAtrributeDataEntity>>();
}
string json = responseValue.ToString();
if (string.IsNullOrEmpty(json))
{
return new AGVResponseEntity<List<ResponseRobotAtrributeDataEntity>>();
}
AGVResponseEntity<List<ResponseRobotAtrributeDataEntity>> ResponseEntity;
ResponseEntity = JsonSerializer.Deserialize<AGVResponseEntity<List<ResponseRobotAtrributeDataEntity>>>(json);
return ResponseEntity;
}
}
}

@ -53,7 +53,6 @@ namespace SlnMesnac.WPF.ViewModel.IndexPage
private ILogger<BaseStateRefreshBusiness> _stateBusinessLogger;
private IAirportTaskService _taskservice;
private IAGVStateService _agvstateService;
private IManipulatorStateService _monipulatorstateService;
private BaseTaskInfoBusiness _taskInfoBusiness;
private BaseStateRefreshBusiness _StateRefreshBusiness;
private DispatcherTimer _timer;

@ -82,8 +82,7 @@
"redisConfig": "175.27.215.92:6379,password=redis@2023",
"AGVIpConfig": "127.0.0.1:4523",
"ManipulatorIpConfig": "127.0.0.1:4523",
"AGVIpConfig": "http://192.168.40.81:5102",
"TCPVisionConfig": "127.0.0.1:6000"
}

Loading…
Cancel
Save